Examples of ViewProcessWorker


Examples of com.opengamma.engine.view.worker.ViewProcessWorker

    // 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);
    }
    assertTrue(executor.wasInterrupted());
  }
View Full Code Here

Examples of com.opengamma.engine.view.worker.ViewProcessWorker

        .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());

    vp.stop();
  }
View Full Code Here

Examples of com.opengamma.engine.view.worker.ViewProcessWorker

    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());

    vp.stop();
  }
View Full Code Here

Examples of com.opengamma.engine.view.worker.ViewProcessWorker

  }

  private void waitForCompletionAndShutdown(final ViewProcessorImpl vp, final ViewClient client, final ViewProcessorTestEnvironment env) throws InterruptedException {
    client.waitForCompletion();
    // Note: notification of client completion happens before the client computation thread terminates and performs its postRunCycle - must wait for this to happen
    final ViewProcessWorker worker = env.getCurrentWorker(env.getViewProcess(vp, client.getUniqueId()));
    client.shutdown();
    worker.join();
  }
View Full Code Here

Examples of com.opengamma.engine.view.worker.ViewProcessWorker

        ExecutionFlags.none().runAsFastAsPossible().get());
    client.attachToViewProcess(env.getViewDefinition().getUniqueId(), executionOptions);
    listener.awaitCycles(10 * Timeout.standardTimeoutMillis());

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

    client.shutdown();
    worker.join();

    assertEquals(0, vp.getViewCycleManager().getResourceCount());
  }
View Full Code Here

Examples of com.opengamma.engine.view.worker.ViewProcessWorker

   * @deprecated There should be a better way to do this in the market data layer but PLAT-3908 is a problem.
   * This method will be removed once it's fixed
   */
  @Deprecated
  public void forceGraphRebuild() {
    ViewProcessWorker worker = getWorker();
    if (worker != null) {
      worker.forceGraphRebuild();
    }
  }
View Full Code Here

Examples of com.opengamma.engine.view.worker.ViewProcessWorker

  }

  private void viewDefinitionChanged() {
    final ViewDefinition viewDefinition = getProcessContext().getConfigSource().getConfig(ViewDefinition.class, getDefinitionId());
    _currentViewDefinition = viewDefinition;
    ViewProcessWorker worker = getWorker();
    if (worker != null) {
      worker.updateViewDefinition(viewDefinition);
    }
  }
View Full Code Here

Examples of com.opengamma.engine.view.worker.ViewProcessWorker

      }
    }
  }

  public void triggerCycle() {
    final ViewProcessWorker worker = getWorker();
    if (worker != null) {
      worker.triggerCycle();
    }
  }
View Full Code Here

Examples of com.opengamma.engine.view.worker.ViewProcessWorker

  @Override
  public void suspend() {
    // Caller MUST NOT hold the semaphore
    s_logger.info("Suspending view process {}", getUniqueId());
    lock();
    final ViewProcessWorker worker = getWorker();
    if (worker != null) {
      s_logger.debug("Suspending calculation job");
      setWorker(null);
      worker.terminate();
      try {
        s_logger.debug("Waiting for calculation thread(s) to finish");
        worker.join();
      } catch (final InterruptedException e) {
        s_logger.warn("Interrupted waiting for calculation thread(s)");
        throw new OpenGammaRuntimeException("Couldn't suspend view process", e);
      }
    }
View Full Code Here

Examples of com.opengamma.engine.view.worker.ViewProcessWorker

      getProcessContext().getConfigSource().changeManager().addChangeListener(_viewDefinitionChangeListener);
    }
    final ViewDefinition viewDefinition = getLatestViewDefinition();
    boolean rollback = true;
    try {
      final ViewProcessWorker worker = getProcessContext().getViewProcessWorkerFactory().createWorker(this, getExecutionOptions(), viewDefinition);
      setWorker(worker);
      rollback = false;
    } catch (final Exception e) {
      s_logger.error("Failed to start computation job for view process " + toString(), e);
      throw new OpenGammaRuntimeException("Failed to start computation job for view process " + toString(), e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.