Package com.opengamma.engine.calcnode

Examples of com.opengamma.engine.calcnode.CalculationJobResultItem


  }

  private List<CalculationJobResultItem> createResultItems(final List<CalculationJobItem> items) {
    final List<CalculationJobResultItem> result = new ArrayList<CalculationJobResultItem>(items.size());
    for (int i = 0; i < items.size(); i++) {
      result.add(new CalculationJobResultItem(Collections.<ValueSpecification>emptySet(), Collections.<ValueSpecification>emptySet(), ExecutionLog.EMPTY));
    }
    return result;
  }
View Full Code Here


  private ValueSpecification createValueSpec(final int id) {
    return new ValueSpecification("V", ComputationTargetSpecification.NULL, ValueProperties.with(ValuePropertyNames.FUNCTION, "Test").with("Id", Integer.toString(id)).get());
  }

  private DependencyNodeJobExecutionResult createExecutionResult() {
    return new DependencyNodeJobExecutionResult("Node", new CalculationJobResultItem(Collections.<ValueSpecification>emptySet(), Collections.<ValueSpecification>emptySet(),
        ExecutionLog.EMPTY), AggregatedExecutionLog.EMPTY);
  }
View Full Code Here

@Test(groups = TestGroup.UNIT)
public class DependencyNodeJobExecutionResultTest {

  public void testGetters() {
    final String nodeId = "Node";
    final CalculationJobResultItem resultItem = new CalculationJobResultItem(Collections.<ValueSpecification>emptySet(), Collections.<ValueSpecification>emptySet(), ExecutionLog.EMPTY);
    final AggregatedExecutionLog logs = AggregatedExecutionLog.EMPTY;
    final DependencyNodeJobExecutionResult result = new DependencyNodeJobExecutionResult(nodeId, resultItem, logs);
    assertSame(result.getComputeNodeId(), nodeId);
    assertSame(result.getJobResultItem(), resultItem);
    assertSame(result.getAggregatedExecutionLog(), logs);
View Full Code Here

  }

  private DependencyNodeJobExecutionResult[] createResults() {
    final String nodeId1 = "Node1";
    final String nodeId2 = "Node2";
    final CalculationJobResultItem resultItem1 = new CalculationJobResultItem(Collections.<ValueSpecification>emptySet(), Collections.<ValueSpecification>emptySet(), ExecutionLog.EMPTY);
    final CalculationJobResultItem resultItem2 = new CalculationJobResultItem(Collections.<ValueSpecification>emptySet(), Collections.<ValueSpecification>emptySet(), MutableExecutionLog.single(
        SimpleLogEvent.of(LogLevel.WARN, "Foo"), ExecutionLogMode.FULL));
    final AggregatedExecutionLog logs1 = AggregatedExecutionLog.EMPTY;
    final AggregatedExecutionLog logs2 = new DefaultAggregatedExecutionLog(EnumSet.of(LogLevel.WARN), null, true);
    return new DependencyNodeJobExecutionResult[] {
        new DependencyNodeJobExecutionResult(nodeId1, resultItem1, logs1),
View Full Code Here

    final Set<ValueSpecification> terminalOutputs = calcConfig.getTerminalOutputs();
    final String computeNodeId = jobResult.getComputeNodeId();
    while (jobItemItr.hasNext()) {
      assert jobResultItr.hasNext();
      final CalculationJobItem jobItem = jobItemItr.next();
      final CalculationJobResultItem jobResultItem = jobResultItr.next();
      // Mark the node that corresponds to this item
      final DependencyNode node = graph.getNodeProducing(jobItem.getOutputs()[0]);
      if (jobResultItem.isFailed()) {
        getCycle().markFailed(node);
      } else {
        getCycle().markExecuted(node);
      }
      // Process the streamed result fragment
      final ExecutionLogMode executionLogMode = logModes.getLogMode(node);
      final AggregatedExecutionLog aggregatedExecutionLog;
      if (executionLogMode == ExecutionLogMode.FULL) {
        final ExecutionLog log = jobResultItem.getExecutionLog();
        MutableExecutionLog logCopy = null;
        final Set<AggregatedExecutionLog> inputLogs = new LinkedHashSet<AggregatedExecutionLog>();
        Set<ValueSpecification> missing = jobResultItem.getMissingInputs();
        if (!missing.isEmpty()) {
          if (logCopy == null) {
            logCopy = new MutableExecutionLog(log);
          }
          logCopy.add(new SimpleLogEvent(log.hasException() ? LogLevel.WARN : LogLevel.INFO, toString("Missing input", missing)));
        }
        missing = jobResultItem.getMissingOutputs();
        if (!missing.isEmpty()) {
          if (logCopy == null) {
            logCopy = new MutableExecutionLog(log);
          }
          logCopy.add(new SimpleLogEvent(LogLevel.WARN, toString("Failed to produce output", missing)));
        }
        for (final ValueSpecification inputValueSpec : node.getInputValues()) {
          final DependencyNodeJobExecutionResult nodeResult = jobExecutionResultCache.get(inputValueSpec);
          if (nodeResult == null) {
            // Market data
            continue;
          }
          inputLogs.add(nodeResult.getAggregatedExecutionLog());
        }
        aggregatedExecutionLog = DefaultAggregatedExecutionLog.fullLogMode(node, (logCopy != null) ? logCopy : log, inputLogs);
      } else {
        EnumSet<LogLevel> logs = jobResultItem.getExecutionLog().getLogLevels();
        boolean copied = false;
        for (final ValueSpecification inputValueSpec : node.getInputValues()) {
          final DependencyNodeJobExecutionResult nodeResult = jobExecutionResultCache.get(inputValueSpec);
          if (nodeResult == null) {
            // Market data
View Full Code Here

  public static CalculationJobResultItem buildObjectImpl(final FudgeDeserializer deserializer, final FudgeMsg message) {
    long[] missingInputs = message.getValue(long[].class, MISSING_INPUTS_FIELD_NAME);
    long[] missingOutputs = message.getValue(long[].class, MISSING_OUTPUTS_FIELD_NAME);
    ExecutionLog executionLog = deserializer.fieldValueToObject(ExecutionLog.class, message.getByName(EXECUTION_LOG_FIELD_NAME));
    return new CalculationJobResultItem(missingInputs, missingOutputs, executionLog);
  }
View Full Code Here

  protected static ComputedValueResult createComputedValueResult(final ValueSpecification valueSpec, final Object calculatedValue, final DependencyNodeJobExecutionResult jobExecutionResult) {
    if (jobExecutionResult == null) {
      return new ComputedValueResult(valueSpec, calculatedValue, AggregatedExecutionLog.EMPTY, null, null, null);
    } else {
      final CalculationJobResultItem jobResultItem = jobExecutionResult.getJobResultItem();
      return new ComputedValueResult(valueSpec,
          calculatedValue,
          jobExecutionResult.getAggregatedExecutionLog(),
          jobExecutionResult.getComputeNodeId(),
          jobResultItem.getMissingInputs(),
          jobResultItem.getResult());
    }
  }
View Full Code Here

 
  public void fudge() {
    IdentifierMap identifierMap = new InMemoryIdentifierMap ();
    CalculationJobSpecification spec = new CalculationJobSpecification(UniqueId.of("Test", "ViewCycle"), "config", Instant.now(), 1L);
   
    CalculationJobResultItem item1 = CalculationJobResultItem.success();
   
    MutableExecutionLog executionLog = new MutableExecutionLog(ExecutionLogMode.INDICATORS);
    CalculationJobResultItem item2 = CalculationJobResultItemBuilder.of(executionLog).withException(new RuntimeException("failure!")).toResultItem();
   
    CalculationJobResult result = new CalculationJobResult(spec,
        500,
        Lists.newArrayList(item1, item2),
        "localhost");
    AbstractIdentifierMap.convertIdentifiers(identifierMap, result);
    FudgeSerializer serializationContext = new FudgeSerializer(s_fudgeContext);
    MutableFudgeMsg inputMsg = serializationContext.objectToFudgeMsg(result);
    FudgeMsg outputMsg = s_fudgeContext.deserialize(s_fudgeContext.toByteArray(inputMsg)).getMessage();
   
    FudgeDeserializer deserializationContext = new FudgeDeserializer(s_fudgeContext);
    CalculationJobResult outputJob = deserializationContext.fudgeMsgToObject(CalculationJobResult.class, outputMsg);
   
    assertNotNull(outputJob);
    AbstractIdentifierMap.resolveIdentifiers(identifierMap, outputJob);
    assertEquals(spec, outputJob.getSpecification());
    assertEquals(500, outputJob.getDuration());
    assertEquals("localhost", outputJob.getComputeNodeId());
    assertNotNull(outputJob.getResultItems());
    assertEquals(2, outputJob.getResultItems().size());
    CalculationJobResultItem outputItem1 = outputJob.getResultItems().get(0);
    assertNotNull(outputItem1);
    assertEquals(InvocationResult.SUCCESS, outputItem1.getResult());
    assertFalse(outputItem1.getExecutionLog().getLogLevels().contains(LogLevel.ERROR));
    assertTrue(outputItem1.getMissingInputs().isEmpty());
   
    CalculationJobResultItem outputItem2 = outputJob.getResultItems().get(1);
    assertNotNull(outputItem2);
    assertEquals(InvocationResult.FUNCTION_THREW_EXCEPTION, outputItem2.getResult());
    assertEquals("java.lang.RuntimeException", outputItem2.getExecutionLog().getExceptionClass());
    assertEquals("failure!", outputItem2.getExecutionLog().getExceptionMessage());
    assertNotNull(outputItem2.getExecutionLog().getExceptionStackTrace());
    assertTrue(outputItem2.getMissingInputs().isEmpty());
  }
View Full Code Here

    final long endTime = System.nanoTime();
    assertNotNull(jobResult);
    assertTrue(jobResult.getDuration() >= 0);
    assertTrue(endTime - startTime >= jobResult.getDuration());
    assertEquals(1, jobResult.getResultItems().size());
    final CalculationJobResultItem resultItem = jobResult.getResultItems().get(0);
    assertEquals(InvocationResult.MISSING_INPUTS, resultItem.getResult());

    final ExecutionLog executionLog = resultItem.getExecutionLog();
    assertNotNull(executionLog);
    assertEquals(MissingInputException.class.getName(), executionLog.getExceptionClass());
    assertEquals("Unable to execute because of 1 missing input(s)", executionLog.getExceptionMessage());
    assertNull(executionLog.getExceptionStackTrace());
  }
View Full Code Here

    cache.putSharedValue(inputValue);

    final CalculationJobResult jobResult = calcNode.executeJob(calcJob);
    assertNotNull(jobResult);
    assertEquals(1, jobResult.getResultItems().size());
    final CalculationJobResultItem resultItem = jobResult.getResultItems().get(0);
    assertEquals(InvocationResult.SUCCESS, resultItem.getResult());
    assertEquals("Nothing we care about", cache.getValue(mockFunction.getResultSpec()));
  }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.calcnode.CalculationJobResultItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.