Package com.opengamma.engine.view.client

Examples of com.opengamma.engine.view.client.ViewClient


    try {
      ViewProcessor vp = new RemoteViewProcessor(
          vpBase,
          jmsConnector,
          heartbeatScheduler);
      ViewClient vc = vp.createViewClient(UserPrincipal.getLocalUser());

      HistoricalMarketDataSpecification marketDataSpecification = MarketData.historical(observationDate, null);

      ViewExecutionOptions executionOptions = ExecutionOptions.batch(valuationTime, marketDataSpecification, null);

      vc.attachToViewProcess(viewDefinitionUniqueId, executionOptions);
      vc.waitForCompletion();
    } finally {
      heartbeatScheduler.shutdown();
    }
  }
View Full Code Here


    final ViewProcessorImpl vp = env.getViewProcessor();

    vp.start();

    final ViewClient client = vp.createViewClient(ViewProcessorTestEnvironment.TEST_USER);
    client.setFragmentResultMode(ViewResultMode.FULL_ONLY);

    marketDataProvider.addValue(ViewProcessorTestEnvironment.getPrimitive1(), (byte) 1);
    marketDataProvider.addValue(ViewProcessorTestEnvironment.getPrimitive2(), (byte) 2);

    final ViewExecutionOptions executionOptions = ExecutionOptions.batch(null, MarketData.live(), null);

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

    final ViewProcessImpl viewProcess = env.getViewProcess(vp, client.getUniqueId());
    assertTrue(viewProcess.getState() == ViewProcessState.RUNNING);
    client.waitForCompletion();
    //
    final ArgumentCaptor<ViewCycleMetadata> argument = ArgumentCaptor.forClass(ViewCycleMetadata.class);
    verify(viewResultListenerMock).cycleStarted(argument.capture());

    assertEquals("boo~far", argument.getValue().getViewDefinitionId().toString());
    assertEquals(1, argument.getValue().getAllCalculationConfigurationNames().size());
    assertEquals("Test Calc Config", functional(argument.getValue().getAllCalculationConfigurationNames()).first());

    final ArgumentCaptor<ViewComputationResultModel> fullFragment = ArgumentCaptor.forClass(ViewComputationResultModel.class);
    final ArgumentCaptor<ViewDeltaResultModel> deltaFragment = ArgumentCaptor.forClass(ViewDeltaResultModel.class);
    verify(viewResultListenerMock, times(2)).cycleFragmentCompleted(fullFragment.capture(), deltaFragment.capture());

    ViewComputationResultModel resultModel = fullFragment.getAllValues().get(0);
    assertEquals(UniqueId.of("ViewProcess", client.getUniqueId().getValue()), resultModel.getViewProcessId());
    assertEquals(UniqueId.of("ViewCycle", client.getUniqueId().getValue(), "1"), resultModel.getViewCycleId());

    assertEquals(
        newHashSet(
            new ComputedValueResult(
                new ValueSpecification(
View Full Code Here

  /**
   * creates a viewport with logging enabled and then deletes it
   */
  @Test
  public void createDeleteWithLogging() {
    final ViewClient viewClient = mock(ViewClient.class);
    final LoggingViewportListener listener = new LoggingViewportListener(viewClient);
    final ViewportDefinition viewportDef = viewportDef(true, _cells12);
    listener.viewportCreated(viewportDef, _gridStructure);
    verify(viewClient).setMinimumLogMode(ExecutionLogMode.FULL, resultSpecs(_cells12));
    listener.viewportDeleted(viewportDef, _gridStructure);
View Full Code Here

   * creates a deletes a viewport with no logging enabled
   */
  @Test
  @SuppressWarnings("unchecked")
  public void createDeleteNoLogging() {
    final ViewClient viewClient = mock(ViewClient.class);
    final LoggingViewportListener listener = new LoggingViewportListener(viewClient);
    final ViewportDefinition viewportDef = viewportDef(false, _cells12);
    listener.viewportCreated(viewportDef, _gridStructure);
    listener.viewportDeleted(viewportDef, _gridStructure);
    verify(viewClient, never()).setMinimumLogMode(any(ExecutionLogMode.class), anySet());
View Full Code Here

    verify(viewClient, never()).setMinimumLogMode(any(ExecutionLogMode.class), anySet());
  }

  @Test
  public void createUpdateDeleteWithLogging() {
    final ViewClient viewClient = mock(ViewClient.class);
    final LoggingViewportListener listener = new LoggingViewportListener(viewClient);
    final ViewportDefinition viewportDef1 = viewportDef(true, _cells12);
    listener.viewportCreated(viewportDef1, _gridStructure);
    verify(viewClient).setMinimumLogMode(ExecutionLogMode.FULL, resultSpecs(_cells12));
View Full Code Here

  }

  @Test
  @SuppressWarnings("unchecked")
  public void createUpdateDeleteNoLogging() {
    final ViewClient viewClient = mock(ViewClient.class);
    final LoggingViewportListener listener = new LoggingViewportListener(viewClient);
    final ViewportDefinition viewportDef1 = viewportDef(false, _cells12);
    listener.viewportCreated(viewportDef1, _gridStructure);
    final ViewportDefinition viewportDef2 = viewportDef(false, _cells23);
    listener.viewportUpdated(viewportDef1, viewportDef2, _gridStructure);
View Full Code Here

    verify(viewClient, never()).setMinimumLogMode(any(ExecutionLogMode.class), anySet());
  }

  @Test
  public void twoViewportsWithLoggingAndOverlappingCells() {
    final ViewClient viewClient = mock(ViewClient.class);
    final LoggingViewportListener listener = new LoggingViewportListener(viewClient);
    final ViewportDefinition viewportDef1 = viewportDef(true, _cells12);
    final ViewportDefinition viewportDef2 = viewportDef(true, _cells23);
    listener.viewportCreated(viewportDef1, _gridStructure);
    verify(viewClient).setMinimumLogMode(ExecutionLogMode.FULL, resultSpecs(_cell1, _cell2));
View Full Code Here

  public void run(UniqueId viewDefId,
                  List<MarketDataSpecification> marketDataSpecs,
                  boolean batchMode,
                  ViewResultListener listener,
                  ViewProcessor viewProcessor) {
    ViewClient viewClient = viewProcessor.createViewClient(UserPrincipal.getTestUser());
    try {
      Set<DistinctMarketDataSelector> allSelectors = allSelectors();
      ViewCycleExecutionOptions baseOptions =
          ViewCycleExecutionOptions
              .builder()
              .setMarketDataSpecifications(marketDataSpecs)
              .setMarketDataSelector(CompositeMarketDataSelector.of(allSelectors))
              .create();
      List<ViewCycleExecutionOptions> cycleOptions = cycleExecutionOptions(baseOptions, allSelectors);
      ViewCycleExecutionSequence sequence = new ArbitraryViewCycleExecutionSequence(cycleOptions);
      EnumSet<ViewExecutionFlags> executionFlags = ExecutionFlags.none().awaitMarketData().runAsFastAsPossible().get();
      ViewExecutionOptions executionOptions;
      if (listener != null) {
        viewClient.setResultListener(listener);
      }
      if (batchMode) {
        executionOptions = ExecutionOptions.batch(sequence, baseOptions);
      } else if (listener != null) {
        executionOptions = ExecutionOptions.of(sequence, executionFlags);
      } else {
        s_logger.warn("Not running in batch mode and no listener specified, the results would be ignored. Exiting.");
        return;
      }
      s_logger.info("Attaching to view process, view def ID {}, execution options {}", viewDefId, executionOptions);
      viewClient.attachToViewProcess(viewDefId, executionOptions, true);
      try {
        viewClient.waitForCompletion();
      } catch (InterruptedException e) {
        s_logger.warn("Interrupted waiting for ViewClient to complete", e);
      }
    } finally {
      viewClient.shutdown();
    }
  }
View Full Code Here

    env.init();

    ViewProcessorImpl vp = env.getViewProcessor();
    vp.start();

    ViewClient client = vp.createViewClient(UserPrincipal.getTestUser());
    client.attachToViewProcess(env.getViewDefinition().getUniqueId(), ExecutionOptions.infinite(MarketData.live()));

    BlockingDependencyGraphExecutor executor = dgef.getExecutorInstance();
    assertTrue(executor.awaitFirstRun(TIMEOUT));

    // We're now blocked in the execution of the initial cycle
    assertFalse(executor.wasInterrupted());

    // Interrupting should cause everything to terminate gracefully
    ViewProcessImpl viewProcess = env.getViewProcess(vp, client.getUniqueId());
    ViewProcessWorker worker = env.getCurrentWorker(viewProcess);
    worker.terminate();
    worker.join(TIMEOUT);
    for (int i = 0; (i < TIMEOUT / 10) && !executor.wasInterrupted(); i++) {
      Thread.sleep(10);
View Full Code Here

    final ViewProcessorTestEnvironment env = new ViewProcessorTestEnvironment();
    env.init();
    final ViewProcessorImpl vp = env.getViewProcessor();
    vp.start();

    final ViewClient client = vp.createViewClient(ViewProcessorTestEnvironment.TEST_USER);
    client.attachToViewProcess(env.getViewDefinition().getUniqueId(), ExecutionOptions.infinite(MarketData.live()));

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

    assertEquals(env.getViewDefinition().getUniqueId(), viewProcess.getDefinitionId());

    viewProcess.stop();
    assertFalse(client.isAttached());
    vp.stop();
  }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.view.client.ViewClient

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.