Package com.opengamma.engine.value

Examples of com.opengamma.engine.value.ComputedValueResult


  }

  //-------------------------------------------------------------------------
  private ComputedValueResult getComputedValueResult(final String valueName, final Object value) {
    final UniqueId uniqueId = UniqueId.of("Scheme", valueName);
    return new ComputedValueResult(new ValueSpecification(valueName, ComputationTargetSpecification.of(uniqueId),
        ValueProperties.with(ValuePropertyNames.FUNCTION, "FunctionId").get()), value, AggregatedExecutionLog.EMPTY);
  }
View Full Code Here


    resultListener.assertViewDefinitionCompiled(TIMEOUT);
    final ViewComputationResultModel result1 = resultListener.getCycleCompleted(TIMEOUT).getFullResult();
    assertEquals(0, resultListener.getQueueSize());

    assertEquals(1, result1.getAllResults().size());
    final ComputedValueResult result1Value = Iterables.getOnlyElement(result1.getAllResults()).getComputedValue();
    assertEquals("result2", result1Value.getValue());

    final AggregatedExecutionLog log1 = result1Value.getAggregatedExecutionLog();
    assertNotNull(log1);
    assertTrue(log1.getLogLevels().contains(LogLevel.ERROR));
    assertTrue(log1.getLogLevels().contains(LogLevel.WARN));
    assertFalse(log1.getLogLevels().contains(LogLevel.INFO));
    assertNull(log1.getLogs());

    final Pair<String, ValueSpecification> resultSpec = Pair.of(calcConfig.getName(), Iterables.getOnlyElement(client.getLatestCompiledViewDefinition().getTerminalValuesRequirements().keySet()));
    client.setMinimumLogMode(ExecutionLogMode.FULL, ImmutableSet.of(resultSpec));

    final ViewProcessImpl viewProcess = env.getViewProcess(vp, client.getUniqueId());
    final ViewProcessWorker worker = env.getCurrentWorker(viewProcess);
    worker.triggerCycle();

    final ViewComputationResultModel result2 = resultListener.getCycleCompleted(TIMEOUT).getFullResult();
    assertEquals(0, resultListener.getQueueSize());

    assertEquals(1, result2.getAllResults().size());
    final ComputedValueResult result2Value = Iterables.getOnlyElement(result2.getAllResults()).getComputedValue();
    assertEquals("result2", result2Value.getValue());

    final AggregatedExecutionLog log2 = result2Value.getAggregatedExecutionLog();
    assertNotNull(log2);
    assertTrue(log2.getLogLevels().contains(LogLevel.ERROR));
    assertTrue(log2.getLogLevels().contains(LogLevel.WARN));
    assertFalse(log2.getLogLevels().contains(LogLevel.INFO));
    assertNotNull(log2.getLogs());
    assertEquals(2, log2.getLogs().size());

    final ExecutionLogWithContext result2LogContext = log2.getLogs().get(0);
    assertNotNull(result2LogContext);
    assertEquals(fn2.getFunctionDefinition().getShortName(), result2LogContext.getFunctionName());
    assertEquals(resultSpec.getSecond().getTargetSpecification(), result2LogContext.getTargetSpecification());
    final ExecutionLog result2Log = result2LogContext.getExecutionLog();
    assertEquals(1, result2Log.getEvents().size());
    final LogEvent result2Event1 = result2Log.getEvents().get(0);
    assertEquals(LogLevel.WARN, result2Event1.getLevel());
    assertEquals("Warning during execution", result2Event1.getMessage());
    assertNull(result2Log.getExceptionClass());
    assertNull(result2Log.getExceptionMessage());
    assertNull(result2Log.getExceptionStackTrace());

    final ExecutionLogWithContext result1LogContext = log2.getLogs().get(1);
    assertNotNull(result1LogContext);
    assertEquals(fn1.getFunctionDefinition().getShortName(), result1LogContext.getFunctionName());
    assertEquals(resultSpec.getSecond().getTargetSpecification(), result1LogContext.getTargetSpecification());
    final ExecutionLog result1Log = result1LogContext.getExecutionLog();
    assertEquals(2, result1Log.getEvents().size());
    final LogEvent result1Event1 = result1Log.getEvents().get(0);
    assertEquals(LogLevel.WARN, result1Event1.getLevel());
    assertEquals("Warning during execution", result1Event1.getMessage());
    final LogEvent result1Event2 = result1Log.getEvents().get(1);
    assertEquals(LogLevel.ERROR, result1Event2.getLevel());
    assertEquals("Error during execution", result1Event2.getMessage());
    assertNull(result1Log.getExceptionClass());
    assertNull(result1Log.getExceptionMessage());
    assertNull(result1Log.getExceptionStackTrace());

    client.setMinimumLogMode(ExecutionLogMode.INDICATORS, ImmutableSet.of(resultSpec));
    worker.triggerCycle();

    final ViewComputationResultModel result3 = resultListener.getCycleCompleted(TIMEOUT).getFullResult();
    assertEquals(0, resultListener.getQueueSize());

    assertEquals(1, result3.getAllResults().size());
    final ComputedValueResult result3Value = Iterables.getOnlyElement(result3.getAllResults()).getComputedValue();
    assertEquals("result2", result3Value.getValue());

    final AggregatedExecutionLog log3 = result3Value.getAggregatedExecutionLog();
    assertNotNull(log3);
    // Delta cycle - should reuse the previous result which *does* include logs.
    assertNotNull(log3.getLogs());

    // Force a full cycle - should *not* reuse any previous result, so back to indicators only
    // TODO: [PLAT-3215] This is bad; future optimizations will not necessarily mean a full cycle happens just because a new view definition got posted
    vd.setUniqueId(UniqueId.of(vd.getUniqueId().getScheme(), vd.getUniqueId().getValue(), "PLAT-3215"));
    worker.updateViewDefinition(vd);
    worker.triggerCycle();

    resultListener.assertViewDefinitionCompiled(TIMEOUT);
    final ViewComputationResultModel result4 = resultListener.getCycleCompleted(TIMEOUT).getFullResult();
    assertEquals(0, resultListener.getQueueSize());

    assertEquals(1, result4.getAllResults().size());
    final ComputedValueResult result4Value = Iterables.getOnlyElement(result4.getAllResults()).getComputedValue();
    assertEquals("result2", result4Value.getValue());

    final AggregatedExecutionLog log4 = result4Value.getAggregatedExecutionLog();
    assertNotNull(log4);
    assertNull(log4.getLogs());
  }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.value.ComputedValueResult

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.