Package com.opengamma.engine.view.cycle

Examples of com.opengamma.engine.view.cycle.SingleComputationCycle


    return context;
  }

  private SingleComputationCycle createCycle(final JobDispatcher jobDispatcher) {
    final Instant now = Instant.now();
    final SingleComputationCycle cycle = Mockito.mock(SingleComputationCycle.class);
    Mockito.when(cycle.getUniqueId()).thenReturn(UniqueId.of("Cycle", "Test"));
    Mockito.when(cycle.getValuationTime()).thenReturn(now);
    Mockito.when(cycle.getVersionCorrection()).thenReturn(VersionCorrection.of(now, now));
    final ViewProcessContext context = createViewProcessContext(jobDispatcher);
    Mockito.when(cycle.getViewProcessContext()).thenReturn(context);
    Mockito.when(cycle.getViewProcessId()).thenReturn(UniqueId.of("View", "Test"));
    Mockito.when(cycle.toString()).thenReturn("TEST-CYCLE");
    return cycle;
  }
View Full Code Here


  @Test(timeOut = 5000)
  public void testNormalExecution() throws Throwable {
    final NormalExecutionJobDispatcher dispatcher = new NormalExecutionJobDispatcher();
    final PlanExecutor executor = new PlanExecutor(createCycle(dispatcher), createPlan());
    dispatcher.execute(executor);
    final SingleComputationCycle cycle = executor.getCycle();
    Pair<CalculationJob, CalculationJobResult> result = dispatcher.pollResult();
    Mockito.verify(cycle, Mockito.times(1)).jobCompleted(result.getFirst(), result.getSecond());
    result = dispatcher.pollResult();
    Mockito.verify(cycle, Mockito.times(1)).jobCompleted(result.getFirst(), result.getSecond());
    result = dispatcher.pollResult();
View Full Code Here

        super.notify(job, receiver);
      }
    };
    final PlanExecutor executor = new PlanExecutor(createCycle(dispatcher), createPlan());
    dispatcher.execute(executor);
    final SingleComputationCycle cycle = executor.getCycle();
    Pair<CalculationJob, CalculationJobResult> result = dispatcher.pollResult();
    Mockito.verify(cycle, Mockito.times(1)).jobCompleted(result.getFirst(), result.getSecond());
    assertNotNull(dispatcher.pollResult()); // Second one will be discarded
    result = dispatcher.pollResult();
    Mockito.verify(cycle, Mockito.times(1)).jobCompleted(result.getFirst(), result.getSecond());
View Full Code Here

    assertTrue(executor.cancel(true));
    dispatcher.completeJobs();
    assertTrue(executor.isCancelled());
    assertTrue(executor.isDone());
    // The first job (and its tail) should have attempted to complete, but the cycle not notified
    final SingleComputationCycle cycle = executor.getCycle();
    Pair<CalculationJob, CalculationJobResult> result = dispatcher.pollResult();
    Mockito.verify(cycle, Mockito.never()).jobCompleted(result.getFirst(), result.getSecond());
    result = dispatcher.pollResult();
    Mockito.verify(cycle, Mockito.never()).jobCompleted(result.getFirst(), result.getSecond());
    // No third job
View Full Code Here

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

  public void testCreateExecutor() {
    final BatchExecutorFactory factory = new BatchExecutorFactory(new SingleNodeExecutorFactory());
    final SingleComputationCycle cycle = Mockito.mock(SingleComputationCycle.class);
    final DependencyGraphExecutor executor = factory.createExecutor(cycle);
    assertEquals(executor.getClass(), BatchExecutor.class);
  }
View Full Code Here

      previous = node;
    }
    final CompiledViewDefinitionWithGraphsImpl viewEvaluationModel = new CompiledViewDefinitionWithGraphsImpl(VersionCorrection.LATEST, "", viewDefinition, Collections.singleton(graph),
        Collections.<ComputationTargetReference, UniqueId>emptyMap(), new SimplePortfolio("Test Portfolio"), 0);
    final ViewCycleExecutionOptions cycleOptions = ViewCycleExecutionOptions.builder().setValuationTime(Instant.ofEpochMilli(1)).setMarketDataSpecification(new MarketDataSpecification()).create();
    final SingleComputationCycle cycle = new SingleComputationCycle(UniqueId.of("Test", "Cycle1"), computationCycleResultListener, vpc, viewEvaluationModel,
        cycleOptions, VersionCorrection.of(Instant.ofEpochMilli(1), Instant.ofEpochMilli(1)));
    return factory.createExecutor(cycle).execute(graph);
  }
View Full Code Here

  }

  private void executeViewCycle(final ViewCycleType cycleType,
      final EngineResourceReference<SingleComputationCycle> cycleReference,
      final MarketDataSnapshot marketDataSnapshot) throws Exception {
    SingleComputationCycle deltaCycle;
    if (cycleType == ViewCycleType.FULL) {
      s_logger.info("Performing full computation");
      deltaCycle = null;
    } else {
      s_logger.info("Performing delta computation");
      deltaCycle = _previousCycleReference.get();
      if ((deltaCycle != null) && (deltaCycle.getState() != ViewCycleState.EXECUTED)) {
        // Can only do a delta cycle if the previous was valid
        deltaCycle = null;
      }
    }
    boolean continueExecution = cycleReference.get().preExecute(deltaCycle, marketDataSnapshot, _suppressExecutionOnNoMarketData);
View Full Code Here

      @Override
      public void resultAvailable(final ViewComputationResultModel result) {
        cycleFragmentCompleted(result);
      }
    };
    final SingleComputationCycle cycle = new SingleComputationCycle(cycleId, streamingResultListener, getProcessContext(), compiledViewDefinition, executionOptions, versionCorrection);
    return getProcessContext().getCycleManager().manage(cycle);
  }
View Full Code Here

            s_logger.error("Error creating next view cycle for " + getWorkerContext(), e);
            return;
          }
          try {
            try {
              final SingleComputationCycle singleComputationCycle = cycleReference.get();
              final Map<String, Collection<ComputationTargetSpecification>> configToComputationTargets = new HashMap<>();
              final Map<String, Map<ValueSpecification, Set<ValueRequirement>>> configToTerminalOutputs = new HashMap<>();
              final MarketDataSnapshot marketDataSnapshot = snapshotManager.getSnapshot();

              for (DependencyGraphExplorer graphExp : compiledViewDefinition.getDependencyGraphExplorers()) {
                final DependencyGraph graph = graphExp.getWholeGraph();
                configToComputationTargets.put(graph.getCalculationConfigurationName(), graph.getAllComputationTargets());
                configToTerminalOutputs.put(graph.getCalculationConfigurationName(), graph.getTerminalOutputs());
              }
              if (isTerminated()) {
                return;
              }
              cycleStarted(new DefaultViewCycleMetadata(
                  cycleReference.get().getUniqueId(),
                  marketDataSnapshot.getUniqueId(),
                  compiledViewDefinition.getViewDefinition().getUniqueId(),
                  versionCorrection,
                  executionOptions.getValuationTime(),
                  singleComputationCycle.getAllCalculationConfigurationNames(),
                  configToComputationTargets,
                  configToTerminalOutputs));
              if (isTerminated()) {
                return;
              }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.view.cycle.SingleComputationCycle

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.