Package com.opengamma.engine.view.execution

Examples of com.opengamma.engine.view.execution.ViewExecutionOptions


    final TestViewResultListener resultListener = new TestViewResultListener();
    client.setResultListener(resultListener);

    final Instant time0 = Instant.now();
    final ViewCycleExecutionOptions defaultCycleOptions = ViewCycleExecutionOptions.builder().setMarketDataSpecification(MarketData.live()).create();
    final ViewExecutionOptions executionOptions = new ExecutionOptions(ArbitraryViewCycleExecutionSequence.of(time0, time0.plusMillis(10), time0.plusMillis(20), time0.plusMillis(30)), ExecutionFlags
        .none().get(), defaultCycleOptions);

    client.attachToViewProcess(env.getViewDefinition().getUniqueId(), executionOptions);

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

    final CompiledViewDefinitionWithGraphsImpl compilationModel1 = (CompiledViewDefinitionWithGraphsImpl) resultListener.getViewDefinitionCompiled(Timeout.standardTimeoutMillis())
        .getCompiledViewDefinition();

    assertEquals(time0, resultListener.getCycleCompleted(10 * Timeout.standardTimeoutMillis()).getFullResult().getViewCycleExecutionOptions().getValuationTime());

    worker.requestCycle();
    assertEquals(time0.plusMillis(10), resultListener.getCycleCompleted(10 * Timeout.standardTimeoutMillis()).getFullResult().getViewCycleExecutionOptions().getValuationTime());
    resultListener.assertNoCalls(Timeout.standardTimeoutMillis());

    // TODO: This test doesn't belong here; it is specific to the SingleThreadViewComputationJob.

    // Trick the compilation job into thinking it needs to rebuilt after time0 + 20
    final CompiledViewDefinitionWithGraphsImpl compiledViewDefinition = new CompiledViewDefinitionWithGraphsImpl(VersionCorrection.LATEST, "", compilationModel1.getViewDefinition(),
        CompiledViewDefinitionWithGraphsImpl.getDependencyGraphs(compilationModel1), Collections.<ComputationTargetReference, UniqueId>emptyMap(), compilationModel1.getPortfolio(),
        compilationModel1.getFunctionInitId()) {
      @Override
      public Instant getValidTo() {
        return time0.plusMillis(20);
      }
    };
    ((SingleThreadViewProcessWorker) worker).cacheCompiledViewDefinition(compiledViewDefinition);

    // Running at time0 + 20 doesn't require a rebuild - should still use our dummy
    worker.requestCycle();
    assertEquals(time0.plusMillis(20), resultListener.getCycleCompleted(10 * Timeout.standardTimeoutMillis()).getFullResult().getViewCycleExecutionOptions().getValuationTime());
    resultListener.assertNoCalls();

    // time0 + 30 requires a rebuild
    worker.requestCycle();
    final CompiledViewDefinition compilationModel2 = resultListener.getViewDefinitionCompiled(Timeout.standardTimeoutMillis()).getCompiledViewDefinition();
    assertNotSame(compilationModel1, compilationModel2);
    assertNotSame(compiledViewDefinition, compilationModel2);
    assertEquals(time0.plusMillis(30), resultListener.getCycleCompleted(Timeout.standardTimeoutMillis()).getFullResult().getViewCycleExecutionOptions().getValuationTime());
    resultListener.assertProcessCompleted(Timeout.standardTimeoutMillis());

    resultListener.assertNoCalls(Timeout.standardTimeoutMillis());

    assertTrue(executionOptions.getExecutionSequence().isEmpty());

    // Job should have terminated automatically with no further evaluation times
    assertEquals(ViewProcessState.FINISHED, viewProcess.getState());
    assertTrue(worker.isTerminated());

View Full Code Here


    final TestViewResultListener resultListener = new TestViewResultListener();
    client.setResultListener(resultListener);

    final Instant time0 = Instant.now();
    final ViewCycleExecutionOptions defaultCycleOptions = ViewCycleExecutionOptions.builder().setMarketDataSpecification(MarketData.live()).create();
    final ViewExecutionOptions executionOptions = new ExecutionOptions(ArbitraryViewCycleExecutionSequence.of(time0), ExecutionFlags.none().get(), defaultCycleOptions);

    client.attachToViewProcess(env.getViewDefinition().getUniqueId(), executionOptions);

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

    resultListener.expectNextCall(ViewDefinitionCompiledCall.class, 10 * Timeout.standardTimeoutMillis());
    resultListener.expectNextCall(CycleStartedCall.class, 10 * Timeout.standardTimeoutMillis());

    // We expect 2 calls - 1 for initial fragment, 1 for final fragment on completion
    resultListener.expectNextCall(CycleFragmentCompletedCall.class, 10 * Timeout.standardTimeoutMillis());
    resultListener.expectNextCall(CycleFragmentCompletedCall.class, 10 * Timeout.standardTimeoutMillis());

    assertEquals(time0, resultListener.getCycleCompleted(10 * Timeout.standardTimeoutMillis()).getFullResult().getViewCycleExecutionOptions().getValuationTime());

    resultListener.assertProcessCompleted(Timeout.standardTimeoutMillis());
    resultListener.assertNoCalls(Timeout.standardTimeoutMillis());

    assertTrue(executionOptions.getExecutionSequence().isEmpty());

    // Job should have terminated automatically with no further evaluation times
    assertEquals(ViewProcessState.FINISHED, viewProcess.getState());
    assertTrue(worker.isTerminated());

View Full Code Here

    final ViewProcessWorkerFactory underlying = Mockito.mock(ViewProcessWorkerFactory.class);
    final ViewProcessWorkerContext context = Mockito.mock(ViewProcessWorkerContext.class);
    final ViewDefinition viewDefinition = Mockito.mock(ViewDefinition.class);
    final ParallelRecompilationViewProcessWorkerFactory factory = new ParallelRecompilationViewProcessWorkerFactory(underlying);
    factory.setDelegate(factory);
    final ViewExecutionOptions options = new ExecutionOptions(new InfiniteViewCycleExecutionSequence(), ExecutionFlags.triggersEnabled().awaitMarketData().ignoreCompilationValidity().get());
    factory.createWorker(context, options, viewDefinition);
    Mockito.verify(underlying, Mockito.only()).createWorker(context, options, viewDefinition);
  }
View Full Code Here

    final ViewProcessWorkerFactory underlying = Mockito.mock(ViewProcessWorkerFactory.class);
    final ViewProcessWorkerContext context = Mockito.mock(ViewProcessWorkerContext.class);
    final ViewDefinition viewDefinition = Mockito.mock(ViewDefinition.class);
    final ParallelRecompilationViewProcessWorkerFactory factory = new ParallelRecompilationViewProcessWorkerFactory(underlying);
    factory.setDelegate(factory);
    final ViewExecutionOptions options = new ExecutionOptions(new InfiniteViewCycleExecutionSequence(), ExecutionFlags.triggersEnabled().awaitMarketData().get());
    factory.createWorker(context, options, viewDefinition);
    Mockito.verify(underlying, Mockito.only()).createWorker(context, options, viewDefinition);
  }
View Full Code Here

  }

  public void testParallel() {
    final ViewProcessWorkerFactory underlying = Mockito.mock(ViewProcessWorkerFactory.class);
    final ViewProcessWorkerContext context = Mockito.mock(ViewProcessWorkerContext.class);
    final ViewExecutionOptions options = new ExecutionOptions(new InfiniteViewCycleExecutionSequence(), ExecutionFlags.triggersEnabled().waitForInitialTrigger()
        .parallelCompilation(ParallelRecompilationMode.PARALLEL_EXECUTION).get());
    final ViewDefinition viewDefinition = Mockito.mock(ViewDefinition.class);
    final ViewProcessWorker delegateWorker = Mockito.mock(ViewProcessWorker.class);
    Mockito.when(underlying.createWorker(Mockito.<ViewProcessWorkerContext>anyObject(), Mockito.<ViewExecutionOptions>anyObject(), Mockito.<ViewDefinition>anyObject())).then(
        new Answer<ViewProcessWorker>() {
          @Override
          public ViewProcessWorker answer(InvocationOnMock invocation) throws Throwable {
            assertTrue(invocation.getArguments()[0] instanceof ParallelRecompilationViewProcessWorker.ParallelExecutionContext);
            final ViewExecutionOptions delegateOptions = (ViewExecutionOptions) invocation.getArguments()[1];
            assertEquals(delegateOptions.getExecutionSequence(), options.getExecutionSequence());
            assertEquals(delegateOptions.getFlags(), ExecutionFlags.triggersEnabled().waitForInitialTrigger().ignoreCompilationValidity().get());
            assertSame(invocation.getArguments()[2], viewDefinition);
            return delegateWorker;
          }
        });
    final ParallelRecompilationViewProcessWorkerFactory factory = new ParallelRecompilationViewProcessWorkerFactory(underlying);
View Full Code Here

  }

  public void testDeferred() {
    final ViewProcessWorkerFactory underlying = Mockito.mock(ViewProcessWorkerFactory.class);
    final ViewProcessWorkerContext context = Mockito.mock(ViewProcessWorkerContext.class);
    final ViewExecutionOptions options = new ExecutionOptions(new InfiniteViewCycleExecutionSequence(), ExecutionFlags.none().awaitMarketData()
        .parallelCompilation(ParallelRecompilationMode.DEFERRED_EXECUTION).get());
    final ViewDefinition viewDefinition = Mockito.mock(ViewDefinition.class);
    final ViewProcessWorker delegateWorker = Mockito.mock(ViewProcessWorker.class);
    Mockito.when(underlying.createWorker(Mockito.<ViewProcessWorkerContext>anyObject(), Mockito.<ViewExecutionOptions>anyObject(), Mockito.<ViewDefinition>anyObject())).then(
        new Answer<ViewProcessWorker>() {
          @Override
          public ViewProcessWorker answer(InvocationOnMock invocation) throws Throwable {
            assertTrue(invocation.getArguments()[0] instanceof ParallelRecompilationViewProcessWorker.DeferredExecutionContext);
            final ViewExecutionOptions delegateOptions = (ViewExecutionOptions) invocation.getArguments()[1];
            assertEquals(delegateOptions.getExecutionSequence(), options.getExecutionSequence());
            assertEquals(delegateOptions.getFlags(), ExecutionFlags.none().awaitMarketData().ignoreCompilationValidity().get());
            assertSame(invocation.getArguments()[2], viewDefinition);
            return delegateWorker;
          }
        });
    final ParallelRecompilationViewProcessWorkerFactory factory = new ParallelRecompilationViewProcessWorkerFactory(underlying);
View Full Code Here

  }

  public void testImmediate() {
    final ViewProcessWorkerFactory underlying = Mockito.mock(ViewProcessWorkerFactory.class);
    final ViewProcessWorkerContext context = Mockito.mock(ViewProcessWorkerContext.class);
    final ViewExecutionOptions options = new ExecutionOptions(new InfiniteViewCycleExecutionSequence(), ExecutionFlags.none().parallelCompilation(ParallelRecompilationMode.IMMEDIATE_EXECUTION).get());
    final ViewDefinition viewDefinition = Mockito.mock(ViewDefinition.class);
    final ViewProcessWorker delegateWorker = Mockito.mock(ViewProcessWorker.class);
    Mockito.when(underlying.createWorker(Mockito.<ViewProcessWorkerContext>anyObject(), Mockito.<ViewExecutionOptions>anyObject(), Mockito.<ViewDefinition>anyObject())).then(
        new Answer<ViewProcessWorker>() {
          @Override
          public ViewProcessWorker answer(InvocationOnMock invocation) throws Throwable {
            assertTrue(invocation.getArguments()[0] instanceof ParallelRecompilationViewProcessWorker.ImmediateExecutionContext);
            final ViewExecutionOptions delegateOptions = (ViewExecutionOptions) invocation.getArguments()[1];
            assertEquals(delegateOptions.getExecutionSequence(), options.getExecutionSequence());
            assertEquals(delegateOptions.getFlags(), ExecutionFlags.none().ignoreCompilationValidity().get());
            assertSame(invocation.getArguments()[2], viewDefinition);
            return delegateWorker;
          }
        });
    final ParallelRecompilationViewProcessWorkerFactory factory = new ParallelRecompilationViewProcessWorkerFactory(underlying);
View Full Code Here

    final List<ViewCycleExecutionOptions> cycles = new ArrayList<ViewCycleExecutionOptions>(20);
    for (int i = 0; i < 37; i++) {
      cycles.add(ViewCycleExecutionOptions.builder().setValuationTime(t.plusSeconds(i)).create());
    }
    final ViewCycleExecutionSequence sequence = new ArbitraryViewCycleExecutionSequence(cycles);
    final ViewExecutionOptions options = ExecutionOptions.of(sequence, EnumSet.of(ViewExecutionFlags.RUN_AS_FAST_AS_POSSIBLE));
    final ViewProcessWorkerContext context = Mockito.mock(ViewProcessWorkerContext.class);
    final SequencePartitioningViewProcessWorker worker = new SequencePartitioningViewProcessWorker(underlying, context, options, Mockito.mock(ViewDefinition.class), 10, 2);
    assertTrue(worker.join(4 * Timeout.standardTimeoutMillis()));
    assertTrue(worker.isTerminated());
    Mockito.verify(context, Mockito.times(cycles.size())).cycleStarted(Mockito.any(ViewCycleMetadata.class));
View Full Code Here

    Mockito.verify(context, Mockito.times(0)).viewDefinitionCompilationFailed(Mockito.any(Instant.class), Mockito.any(Exception.class));
  }

  public void testInfiniteSequence() throws InterruptedException {
    final ViewProcessWorkerFactoryMock underlying = new ViewProcessWorkerFactoryMock((int) (Timeout.standardTimeoutMillis() / 32));
    final ViewExecutionOptions options = ExecutionOptions.of(new InfiniteViewCycleExecutionSequence(), EnumSet.of(ViewExecutionFlags.RUN_AS_FAST_AS_POSSIBLE));
    final ViewProcessWorkerContext context = Mockito.mock(ViewProcessWorkerContext.class);
    final SequencePartitioningViewProcessWorker worker = new SequencePartitioningViewProcessWorker(underlying, context, options, Mockito.mock(ViewDefinition.class), 10, 2);
    assertFalse(worker.join(Timeout.standardTimeoutMillis()));
    assertFalse(worker.isTerminated());
    worker.terminate();
View Full Code Here

    vp.start();

    final ViewClient client = vp.createViewClient(ViewProcessorTestEnvironment.TEST_USER);
    final CycleCountingViewResultListener listener = new CycleCountingViewResultListener(10);
    client.setResultListener(listener);
    final ViewExecutionOptions executionOptions = ExecutionOptions.of(new InfiniteViewCycleExecutionSequence(), ViewCycleExecutionOptions.builder().setMarketDataSpecification(MarketData.live())
        .create(),
        ExecutionFlags.none().runAsFastAsPossible().get());
    client.attachToViewProcess(env.getViewDefinition().getUniqueId(), executionOptions);
    listener.awaitCycles(10 * Timeout.standardTimeoutMillis());

 
View Full Code Here

TOP

Related Classes of com.opengamma.engine.view.execution.ViewExecutionOptions

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.