Package com.opengamma.engine.view.execution

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


    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;
          }
        });
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;
          }
        });
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;
          }
        });
View Full Code Here

      MarketDataSpecification marketDataSpec = new FixedHistoricalMarketDataSpecification(s_observationDateTime.toLocalDate());
      ViewCycleExecutionOptions cycleOptions = ViewCycleExecutionOptions.builder().setValuationTime(s_valuationInstant).setMarketDataSpecification(marketDataSpec)
          .setResolverVersionCorrection(VersionCorrection.of(s_versionAsOf, s_correctedTo)).create();
      ViewCycleExecutionSequence executionSequence = ArbitraryViewCycleExecutionSequence.of(cycleOptions);

      ExecutionOptions executionOptions = new ExecutionOptions(executionSequence, ExecutionFlags.none().awaitMarketData().get(), null, null);

      viewClient.attachToViewProcess(UniqueId.parse(s_viewDefinitionUid), executionOptions);
    } finally {
      if (appContext != null) {
        appContext.close();
View Full Code Here

  private Integer getMaxSuccessiveDeltaCycles() {
    return _maxSuccessiveDeltaCycles;
  }

  private ViewExecutionOptions getExecutionOptions(ViewCycleExecutionSequence newSequence) {
    return new ExecutionOptions(newSequence, getExecutionFlags(), getMaxSuccessiveDeltaCycles(), getDefaultExecutionOptions());
  }
View Full Code Here

    final EnumSet<ViewExecutionFlags> flags = EnumSet.copyOf(executionOptions.getFlags());
    flags.remove(ViewExecutionFlags.PARALLEL_RECOMPILATION_AND_EXECUTION);
    flags.remove(ViewExecutionFlags.PARALLEL_RECOMPILATION_DEFERRED_EXECUTION);
    flags.remove(ViewExecutionFlags.PARALLEL_RECOMPILATION_IMMEDIATE_EXECUTION);
    flags.add(ViewExecutionFlags.IGNORE_COMPILATION_VALIDITY);
    return new ExecutionOptions(executionOptions.getExecutionSequence(), flags, executionOptions.getMaxSuccessiveDeltaCycles(), executionOptions.getDefaultExecutionOptions());
  }
View Full Code Here

TOP

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

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.