Package com.opengamma.engine.calcnode

Examples of com.opengamma.engine.calcnode.JobDispatcher


    assertNull(dispatcher.pollResult());
  }

  @Test(expectedExceptions = IllegalStateException.class)
  public void testDuplicateStart() {
    final PlanExecutor executor = new PlanExecutor(createCycle(new JobDispatcher()), createPlan());
    executor.start();
    executor.start();
  }
View Full Code Here


    executor.start();
  }

  public void testCancelStoppingJobs() {
    final AtomicBoolean canceled = new AtomicBoolean();
    final JobDispatcher dispatcher = new JobDispatcher() {
      @Override
      public Cancelable dispatchJob(final CalculationJob job, final JobResultReceiver receiver) {
        return new Cancelable() {
          @Override
          public boolean cancel(final boolean mayInterruptIfRunning) {
View Full Code Here

  }

  public void testCancelDuringDispatch() {
    final Cancelable handle = Mockito.mock(Cancelable.class);
    final AtomicReference<PlanExecutor> executor = new AtomicReference<PlanExecutor>();
    final JobDispatcher dispatcher = new JobDispatcher() {
      @Override
      public Cancelable dispatchJob(final CalculationJob job, final JobResultReceiver receiver) {
        executor.get().cancel(true);
        return handle;
      }
View Full Code Here

    assertFalse(executor.cancel(true));
    assertFalse(executor.isCancelled());
  }

  public void testCancelBeforeJobSubmission() {
    final JobDispatcher dispatcher = Mockito.mock(JobDispatcher.class);
    final PlanExecutor executor = new PlanExecutor(createCycle(dispatcher), createPlan()) {
      @Override
      protected void submitExecutableJobs() {
        cancel(true);
        super.submitExecutableJobs();
View Full Code Here

  // Timeout is set just in case "get" decides to block
  @Test(timeOut = 5000, expectedExceptions = CancellationException.class)
  public void testCancelDuringGet() throws Throwable {
    final ExecutorService threads = Executors.newSingleThreadExecutor();
    try {
      final PlanExecutor executor = new PlanExecutor(createCycle(new JobDispatcher()), createPlan());
      executor.start();
      threads.submit(new Runnable() {
        @Override
        public void run() {
          executor.cancel(true);
View Full Code Here

  // Timeout is set just in case "get" decides to block
  @Test(timeOut = 5000, expectedExceptions = CancellationException.class)
  public void testCancelDuringGetWithTimeout() throws Throwable {
    final ExecutorService threads = Executors.newSingleThreadExecutor();
    try {
      final PlanExecutor executor = new PlanExecutor(createCycle(new JobDispatcher()), createPlan());
      executor.start();
      threads.submit(new Runnable() {
        @Override
        public void run() {
          executor.cancel(true);
View Full Code Here

      threads.awaitTermination(3, TimeUnit.SECONDS);
    }
  }

  public void testToString() {
    final PlanExecutor executor = new PlanExecutor(createCycle(new JobDispatcher()), createPlan());
    assertEquals(executor.toString(), "ExecutingGraph-Default for TEST-CYCLE");
  }
View Full Code Here

    final MockPositionSource positionSource = new MockPositionSource();
    compilationContext.setRawComputationTargetResolver(new DefaultComputationTargetResolver(securitySource, positionSource));
    final ViewComputationCacheSource computationCacheSource = new InMemoryViewComputationCacheSource(FudgeContext.GLOBAL_DEFAULT);
    final FunctionInvocationStatisticsGatherer functionInvocationStatistics = new DiscardingInvocationStatisticsGatherer();
    final FunctionExecutionContext executionContext = new FunctionExecutionContext();
    final JobDispatcher jobDispatcher = new JobDispatcher(new LocalNodeJobInvoker(new SimpleCalculationNode(computationCacheSource, compilationService, executionContext, "node",
        Executors.newCachedThreadPool(), functionInvocationStatistics, new CalculationNodeLogEventListener(new ThreadLocalLogEventListener()))));
    final ViewPermissionProvider viewPermissionProvider = new DefaultViewPermissionProvider();
    final GraphExecutorStatisticsGathererProvider graphExecutorStatisticsProvider = new DiscardingGraphStatisticsGathererProvider();
    final ViewDefinition viewDefinition = new ViewDefinition("TestView", UserPrincipal.getTestUser());
    viewDefinition.addViewCalculationConfiguration(new ViewCalculationConfiguration(viewDefinition, "default"));
View Full Code Here

public class MultipleNodeExecutorTunerTest {

  public void testJobDispatcher() {
    final MultipleNodeExecutorFactory factory = Mockito.mock(MultipleNodeExecutorFactory.class);
    final MultipleNodeExecutorTuner tuner = new MultipleNodeExecutorTuner(factory);
    final JobDispatcher dispatcher = Mockito.mock(JobDispatcher.class);
    final Map<String, Collection<Capability>> capabilities = new HashMap<String, Collection<Capability>>();
    Mockito.when(dispatcher.getAllCapabilities()).thenReturn(capabilities);
    tuner.setJobDispatcher(dispatcher);
    tuner.run();
    Mockito.verifyZeroInteractions(factory);
    capabilities.put("A", Arrays.asList(Capability.instanceOf("Foo")));
    capabilities.put("B", Arrays.asList(Capability.instanceOf("Bar")));
View Full Code Here

  }

  @Test
  public void registerInvokerWithJobPending() {
    s_logger.info("registerInvokerWithJobPending");
    final JobDispatcher jobDispatcher = new JobDispatcher();
    final TestJobResultReceiver result = new TestJobResultReceiver();
    final CalculationJob job = createTestJob();
    jobDispatcher.dispatchJob(job, result);
    assertNull(result.getResult());
    final TestJobInvoker jobInvoker = new TestJobInvoker("Test");
    jobDispatcher.registerJobInvoker(jobInvoker);
    final CalculationJobResult jobResult = result.waitForResult(TIMEOUT);
    assertNotNull(jobResult);
    assertEquals(job.getSpecification(), jobResult.getSpecification());
    assertNull(jobInvoker._callback);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.calcnode.JobDispatcher

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.