Package com.opengamma.engine.view

Examples of com.opengamma.engine.view.ViewComputationResultModel


    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(
                    "Value2",
                    ComputationTargetSpecification.of(UniqueId.of("Scheme", "PrimitiveValue")),
                    ValueProperties.with("Function", newHashSet("MarketDataSourcingFunction")).get()),
                (byte) 2, AggregatedExecutionLog.EMPTY),
            new ComputedValueResult(
                new ValueSpecification(
                    "Value1",
                    ComputationTargetSpecification.of(UniqueId.of("Scheme", "PrimitiveValue")),
                    ValueProperties.with("Function", newHashSet("MarketDataSourcingFunction")).get()),
                (byte) 1, AggregatedExecutionLog.EMPTY)
        ),
        resultModel.getAllMarketData());
  }
View Full Code Here


    assertNull(_batchWriter.getRiskRun(run.getObjectId()));
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void addJobResultsToUnstartedBatch() {
    final ViewComputationResultModel result = new InMemoryViewComputationResultModel();
    _batchMaster.addJobResults(null, result);
  }
View Full Code Here

    portfolio = PortfolioCompiler.resolvePortfolio(portfolio, Executors.newSingleThreadExecutor(), getSecuritySource());
    final UniqueId viewDefinitionId = getPaymentViewDefinition(portfolio);

    final ViewClient viewClient = getViewProcessor().createViewClient(UserPrincipal.getTestUser());
    viewClient.attachToViewProcess(viewDefinitionId, ExecutionOptions.singleCycle(Instant.now(), MarketData.live()));
    ViewComputationResultModel result;
    try {
      viewClient.waitForCompletion();
      result = viewClient.getLatestResult();
    } catch (final InterruptedException e) {
      throw new OpenGammaRuntimeException("Interrupted while waiting for payment diary calculations");
    } finally {
      viewClient.shutdown();
    }
    if (result == null) {
      throw new OpenGammaRuntimeException("Cash flow view failed to run");
    }
    final PortfolioPaymentDiary paymentDiary = new PortfolioPaymentDiary();
    final ViewCalculationResultModel calcResults = result.getCalculationResult(CALC_CONFIG_NAME);
    if (calcResults == null) {
      throw new OpenGammaRuntimeException("No payments were calculated");
    }
    for (final ComputationTargetSpecification targetSpec : calcResults.getAllTargets()) {
      if (!targetSpec.getType().isTargetType(ComputationTargetType.POSITION)) {
View Full Code Here

  private void runUpdateThread() {
    getExecutorService().submit(new Runnable() {
      @Override
      public void run() {
        do {
          final ViewComputationResultModel update = getViewClient().getLatestResult();

          getRemote().startBatch();

          final long valuationTimeMillis = update.getViewCycleExecutionOptions().getValuationTime().toEpochMilli();
          final long calculationDurationMillis = update.getCalculationDuration().toMillis();

          sendStartMessage(valuationTimeMillis, calculationDurationMillis);
          try {
            processResult(update);
          } catch (final Exception e) {
            s_logger.error("Error processing result from view cycle " + update.getViewCycleId(), e);
          }
          sendEndMessage();

          getRemote().endBatch();
        } while (continueUpdateThread());
View Full Code Here

  public Pair<Instant, String> getGridContentsAsCsv(final String gridName) {
    final WebViewGrid grid = getGridByName(gridName);
    if (grid == null) {
      throw new OpenGammaRuntimeException("Unknown grid '" + gridName + "'");
    }
    final ViewComputationResultModel latestResult = getViewClient().getLatestResult();
    if (latestResult == null) {
      return null;
    }
    final String csv = grid.dumpContentsToCsv(latestResult);
    return Pair.of(latestResult.getViewCycleExecutionOptions().getValuationTime(), csv);
  }
View Full Code Here

  private static final String DELTA_RESULT_FIELD = "deltaResult";
 
  @Override
  public MutableFudgeMsg buildMessage(FudgeSerializer serializer, CycleCompletedCall object) {
    MutableFudgeMsg msg = serializer.newMessage();
    ViewComputationResultModel fullResult = object.getFullResult();
    ViewDeltaResultModel deltaResult = object.getDeltaResult();
    serializer.addToMessage(msg, FULL_RESULT_FIELD, null, fullResult);
    serializer.addToMessage(msg, DELTA_RESULT_FIELD, null, deltaResult);
    return msg;
  }
View Full Code Here

  }

  @Override
  public CycleCompletedCall buildObject(FudgeDeserializer deserializer, FudgeMsg msg) {
    FudgeField fullResultField = msg.getByName(FULL_RESULT_FIELD);
    ViewComputationResultModel fullResult = fullResultField != null ? deserializer.fieldValueToObject(ViewComputationResultModel.class, fullResultField) : null;
    FudgeField deltaResultField = msg.getByName(DELTA_RESULT_FIELD);
    ViewDeltaResultModel deltaResult = deltaResultField != null ? deserializer.fieldValueToObject(ViewDeltaResultModel.class, deltaResultField) : null;
    return new CycleCompletedCall(fullResult, deltaResult);
  }
View Full Code Here

  }

  @Override
  public CycleFragmentCompletedCall buildObject(FudgeDeserializer deserializer, FudgeMsg msg) {
    FudgeField fullResultField = msg.getByName(FULL_FRAGMENT_FIELD);
    ViewComputationResultModel fullResult = fullResultField != null ? deserializer.fieldValueToObject(ViewComputationResultModel.class, fullResultField) : null;
    FudgeField deltaResultField = msg.getByName(DELTA_FRAGMENT_FIELD);
    ViewDeltaResultModel deltaResult = deltaResultField != null ? deserializer.fieldValueToObject(ViewDeltaResultModel.class, deltaResultField) : null;
    return new CycleFragmentCompletedCall(fullResult, deltaResult);
  }
View Full Code Here

        boolean isFirstResult = updateLatestResult(fullResult);
        ViewResultListener listener = _userResultListener.get();
        if (listener != null) {
          ViewResultMode resultMode = getResultMode();
          if (!resultMode.equals(ViewResultMode.NONE)) {
            ViewComputationResultModel userFullResult = isFullResultRequired(resultMode,
                                                                             isFirstResult) ? fullResult : null;
            ViewDeltaResultModel userDeltaResult = isDeltaResultRequired(resultMode,
                                                                         isFirstResult) ? deltaResult : null;
            if (userFullResult != null || userDeltaResult != null) {
              listener.cycleCompleted(userFullResult, userDeltaResult);
            } else if (!isFirstResult || resultMode != ViewResultMode.DELTA_ONLY) {
              // Would expect this if it's the first result and we're in delta only mode, otherwise log a warning
              s_logger.warn("Ignored CycleCompleted call with no useful results to propagate");
            }
          }
        }
      }

      @Override
      public void cycleFragmentCompleted(ViewComputationResultModel fullFragment, ViewDeltaResultModel deltaFragment) {
        ViewComputationResultModel prevResult = _latestResult.get();
        ViewResultListener listener = _userResultListener.get();
        if (listener != null) {
          ViewResultMode resultMode = getFragmentResultMode();
          if (!resultMode.equals(ViewResultMode.NONE)) {
            ViewComputationResultModel userFullResult = isFullResultRequired(resultMode,
                                                                             prevResult == null) ? fullFragment : null;
            ViewDeltaResultModel userDeltaResult = isDeltaResultRequired(resultMode,
                                                                         prevResult == null) ? deltaFragment : null;
            if (userFullResult != null || userDeltaResult != null) {
              listener.cycleFragmentCompleted(userFullResult, userDeltaResult);
View Full Code Here

  @Override
  public EngineResourceReference<? extends ViewCycle> createLatestCycleReference() {
    if (!isViewCycleAccessSupported()) {
      throw new UnsupportedOperationException("Access to computation cycles is not supported from this client");
    }
    ViewComputationResultModel latestResult = getLatestResult();
    if (latestResult == null) {
      return null;
    }
    return _viewProcessor.getViewCycleManager().createReference(latestResult.getViewCycleId());
  }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.view.ViewComputationResultModel

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.