Package com.opengamma.engine.marketdata

Examples of com.opengamma.engine.marketdata.InMemoryLKVMarketDataProvider


      //ignore
    }
  };

  private DependencyGraphExecutionFuture executeTestJob(final DependencyGraphExecutorFactory factory) {
    final InMemoryLKVMarketDataProvider marketDataProvider = new InMemoryLKVMarketDataProvider();
    final MarketDataProviderResolver marketDataProviderResolver = new SingleMarketDataProviderResolver(new SingletonMarketDataProviderFactory(marketDataProvider));
    final InMemoryFunctionRepository functionRepository = new InMemoryFunctionRepository();
    _functionCount.set(0);
    final MockFunction mockFunction = new MockFunction(ComputationTarget.NULL) {
      @Override
View Full Code Here


    ArgumentChecker.notNull(marketDataProvider, "marketDataProvider");
    _marketDataProvider = marketDataProvider;
  }

  private MarketDataProvider generateMarketDataProvider() {
    final InMemoryLKVMarketDataProvider provider = new InMemoryLKVMarketDataProvider();
    provider.addValue(getPrimitive1(), 0);
    provider.addValue(getPrimitive2(), 0);
    setMarketDataProvider(provider);
    return provider;
  }
View Full Code Here

    ArgumentChecker.notNull(permissionProvider, "permissionProvider");
    ArgumentChecker.notNull(marketDataUser, "marketDataUser");
    _liveDataClient = liveDataClient;
    // TODO: Should we use the default normalization rules from the live data client rather than hard code the standard rule set here?
    _availabilityProvider = availabilityFilter.withProvider(new LiveMarketDataAvailabilityProvider(StandardRules.getOpenGammaRuleSetId()));
    _underlyingProvider = new InMemoryLKVMarketDataProvider();
    _permissionProvider = permissionProvider;
    _marketDataUser = marketDataUser;

    try {
      MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
View Full Code Here

  }

  @Override
  public synchronized void init() {
    if (!isInitialized()) {
      _unstructured = new InMemoryLKVMarketDataProvider();
      final UnstructuredMarketDataSnapshot globalValues = _snapshot.getGlobalValues();
      if (globalValues != null) {
        for (final ExternalIdBundle target : globalValues.getTargets()) {
          final ComputationTargetReference targetRef = new ComputationTargetRequirement(ComputationTargetType.PRIMITIVE, target);
          for (final Map.Entry<String, ValueSnapshot> valuePair : globalValues.getTargetValues(target).entrySet()) {
View Full Code Here

  }

  @Test
  public void testWaitForMarketData() throws InterruptedException {
    final ViewProcessorTestEnvironment env = new ViewProcessorTestEnvironment();
    final InMemoryLKVMarketDataProvider underlyingProvider = new InMemoryLKVMarketDataProvider();
    final MarketDataProvider marketDataProvider = new TestLiveMarketDataProvider("source", underlyingProvider);
    env.setMarketDataProvider(marketDataProvider);
    env.init();

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

    final ViewClient client = vp.createViewClient(ViewProcessorTestEnvironment.TEST_USER);
    final TestViewResultListener resultListener = new TestViewResultListener();
    client.setResultListener(resultListener);
    final ViewCycleExecutionOptions cycleExecutionOptions = ViewCycleExecutionOptions.builder().setValuationTime(Instant.now()).setMarketDataSpecification(MarketData.live()).create();
    final EnumSet<ViewExecutionFlags> flags = ExecutionFlags.none().awaitMarketData().get();
    final ViewExecutionOptions executionOptions = ExecutionOptions.of(ArbitraryViewCycleExecutionSequence.single(cycleExecutionOptions), flags);
    client.attachToViewProcess(env.getViewDefinition().getUniqueId(), executionOptions);

    resultListener.assertViewDefinitionCompiled(TIMEOUT);

    final ViewProcessImpl viewProcess = env.getViewProcess(vp, client.getUniqueId());
    final BorrowedThread recalcThread = ((SingleThreadViewProcessWorker) env.getCurrentWorker(viewProcess)).getThread();
    assertThreadReachesState(recalcThread, Thread.State.TIMED_WAITING);

    underlyingProvider.addValue(ViewProcessorTestEnvironment.getPrimitive1(), 123d);
    underlyingProvider.addValue(ViewProcessorTestEnvironment.getPrimitive2(), 456d);
    recalcThread.join();
    resultListener.assertCycleCompleted(TIMEOUT);

    final Map<String, Object> resultValues = new HashMap<String, Object>();
    final ViewComputationResultModel result = client.getLatestResult();
View Full Code Here

  }
 
  @Test(groups = TestGroup.INTEGRATION// randomly fails
  public void testSkipCycleOnNoMarketData() throws InterruptedException {
    final ViewProcessorTestEnvironment env = new ViewProcessorTestEnvironment();
    final InMemoryLKVMarketDataProvider underlyingProvider = new InMemoryLKVMarketDataProvider();
    underlyingProvider.addValue(ViewProcessorTestEnvironment.getPrimitive1(), 123d);
    underlyingProvider.addValue(ViewProcessorTestEnvironment.getPrimitive2(), 456d);
    final MarketDataProvider marketDataProvider = new TestLiveMarketDataProvider("source", underlyingProvider);
    env.setMarketDataProvider(marketDataProvider);
    env.init();

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

    final ViewClient client = vp.createViewClient(ViewProcessorTestEnvironment.TEST_USER);
    final TestViewResultListener resultListener = new TestViewResultListener();
    client.setResultListener(resultListener);
    final EnumSet<ViewExecutionFlags> flags = ExecutionFlags.none().skipCycleOnNoMarketData().get();
    final ViewExecutionOptions executionOptions = ExecutionOptions.infinite(MarketData.live(), flags);
    client.attachToViewProcess(env.getViewDefinition().getUniqueId(), executionOptions);

    resultListener.assertViewDefinitionCompiled(TIMEOUT);

    final ViewProcessImpl viewProcess = env.getViewProcess(vp, client.getUniqueId());
    final ViewProcessWorker currentWorker = env.getCurrentWorker(viewProcess);
    final BorrowedThread recalcThread = ((SingleThreadViewProcessWorker) currentWorker).getThread();
    assertThreadReachesState(recalcThread, Thread.State.TIMED_WAITING);

    // Cycle 1
    currentWorker.triggerCycle();
    resultListener.assertCycleCompleted(TIMEOUT);

    ViewComputationResultModel result = client.getLatestResult();
    Map<String, Object> resultValues = extractResults(result);
    assertEquals(123d, resultValues.get(ViewProcessorTestEnvironment.getPrimitive1().getValueName()));
    assertEquals(456d, resultValues.get(ViewProcessorTestEnvironment.getPrimitive2().getValueName()));
   
    // Cycle 2
    underlyingProvider.removeValue(ViewProcessorTestEnvironment.getPrimitive1());
    underlyingProvider.removeValue(ViewProcessorTestEnvironment.getPrimitive2());
    currentWorker.triggerCycle();
    resultListener.assertCycleCompleted(TIMEOUT);
   
    result = client.getLatestResult();
    resultValues = extractResults(result);
    assertEquals(MissingOutput.SUPPRESSED, resultValues.get(ViewProcessorTestEnvironment.getPrimitive1().getValueName()));
    assertEquals(MissingOutput.SUPPRESSED, resultValues.get(ViewProcessorTestEnvironment.getPrimitive2().getValueName()));

    // Cycle 3
    underlyingProvider.addValue(ViewProcessorTestEnvironment.getPrimitive1(), 789d);
    underlyingProvider.addValue(ViewProcessorTestEnvironment.getPrimitive2(), 543d);
    currentWorker.triggerCycle();
    resultListener.assertCycleCompleted(TIMEOUT);

    result = client.getLatestResult();
    resultValues = extractResults(result);
    assertEquals(789d, resultValues.get(ViewProcessorTestEnvironment.getPrimitive1().getValueName()));
    assertEquals(543d, resultValues.get(ViewProcessorTestEnvironment.getPrimitive2().getValueName()));
   
    // Cycle 4
    underlyingProvider.removeValue(ViewProcessorTestEnvironment.getPrimitive1());
    currentWorker.triggerCycle();
    resultListener.assertCycleCompleted(TIMEOUT);

    result = client.getLatestResult();
    resultValues = extractResults(result);
View Full Code Here

  }

  @Test
  public void testDoNotWaitForMarketData() throws InterruptedException {
    final ViewProcessorTestEnvironment env = new ViewProcessorTestEnvironment();
    final InMemoryLKVMarketDataProvider underlyingProvider = new InMemoryLKVMarketDataProvider();
    final MarketDataProvider marketDataProvider = new TestLiveMarketDataProvider("source", underlyingProvider);
    env.setMarketDataProvider(marketDataProvider);
    env.init();

    final ViewProcessorImpl vp = env.getViewProcessor();
View Full Code Here

  }

  @Test
  public void testChangeMarketDataProviderBetweenCycles() throws InterruptedException {
    final ViewProcessorTestEnvironment env = new ViewProcessorTestEnvironment();
    final MarketDataProvider provider1 = new TestLiveMarketDataProvider(SOURCE_1_NAME, new InMemoryLKVMarketDataProvider());
    final MarketDataProvider provider2 = new TestLiveMarketDataProvider(SOURCE_2_NAME, new InMemoryLKVMarketDataProvider());
    final MarketDataProvider provider3 = new TestLiveMarketDataProvider(SOURCE_3_NAME, new InMemoryLKVMarketDataProvider(), new FixedMarketDataAvailabilityProvider());
    env.setMarketDataProviderResolver(new MockMarketDataProviderResolver(SOURCE_1_NAME, provider1, SOURCE_2_NAME, provider2, SOURCE_3_NAME, provider3));
    env.init();
    final ViewProcessorImpl vp = env.getViewProcessor();
    vp.start();
    final ViewClient client = vp.createViewClient(ViewProcessorTestEnvironment.TEST_USER);
View Full Code Here

  }

  @Test
  public void testChangeMarketDataProviderBetweenCyclesWithCycleFragmentCompletedCalls() throws InterruptedException {
    final ViewProcessorTestEnvironment env = new ViewProcessorTestEnvironment();
    final MarketDataProvider provider1 = new TestLiveMarketDataProvider(SOURCE_1_NAME, new InMemoryLKVMarketDataProvider());
    final MarketDataProvider provider2 = new TestLiveMarketDataProvider(SOURCE_2_NAME, new InMemoryLKVMarketDataProvider());
    final MarketDataProvider provider3 = new TestLiveMarketDataProvider(SOURCE_3_NAME, new InMemoryLKVMarketDataProvider(), new FixedMarketDataAvailabilityProvider());
    env.setMarketDataProviderResolver(new MockMarketDataProviderResolver(SOURCE_1_NAME, provider1, SOURCE_2_NAME, provider2, SOURCE_3_NAME, provider3));
    env.init();
    final ViewProcessorImpl vp = env.getViewProcessor();
    vp.start();
    final ViewClient client = vp.createViewClient(ViewProcessorTestEnvironment.TEST_USER);
View Full Code Here

TOP

Related Classes of com.opengamma.engine.marketdata.InMemoryLKVMarketDataProvider

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.