Package com.opengamma.engine.calcnode

Examples of com.opengamma.engine.calcnode.MaximumJobItemExecutionWatchdog$Action


      Collections.<ValueSpecification>emptySet(), Collections.<ValueSpecification>emptySet(), ExecutionLogMode.INDICATORS);

  public void testNoAlert() throws Exception {
    final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
    try {
      final MaximumJobItemExecutionWatchdog watchdog = new MaximumJobItemExecutionWatchdog();
      watchdog.setMaxJobItemExecutionTime(Timeout.standardTimeoutMillis() / 2);
      watchdog.setScheduler(scheduler);
      final CyclicBarrier barrier = new CyclicBarrier(2);
      (new Thread() {
        @Override
        public void run() {
          try {
            barrier.await(Timeout.standardTimeoutMillis(), TimeUnit.MILLISECONDS);
            barrier.reset();
            watchdog.jobExecutionStarted(JOB);
            watchdog.jobExecutionStopped();
            barrier.await(Timeout.standardTimeoutMillis() * 2, TimeUnit.MILLISECONDS);
            watchdog.jobExecutionStarted(JOB);
            watchdog.jobExecutionStopped();
          } catch (final Exception e) {
            throw new OpenGammaRuntimeException("exception", e);
          }
        }
      }).start();
      barrier.await(Timeout.standardTimeoutMillis(), TimeUnit.MILLISECONDS);
      Thread.sleep(Timeout.standardTimeoutMillis());
      // Watchdog should have run while the thread is alive, but not executing anything
      assertTrue(watchdog.areThreadsAlive());
      barrier.await(Timeout.standardTimeoutMillis(), TimeUnit.MILLISECONDS);
      Thread.sleep(Timeout.standardTimeoutMillis());
      // Watchdog should have run with the thread dead
      assertFalse(watchdog.areThreadsAlive());
    } finally {
      scheduler.shutdown();
    }
  }
View Full Code Here


  }

  public void testAlert() throws Exception {
    final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
    try {
      final MaximumJobItemExecutionWatchdog watchdog = new MaximumJobItemExecutionWatchdog();
      watchdog.setMaxJobItemExecutionTime(Timeout.standardTimeoutMillis() / 2);
      watchdog.setScheduler(scheduler);
      final AtomicReference<InterruptedException> caught = new AtomicReference<InterruptedException>();
      final CyclicBarrier barrier = new CyclicBarrier(2);
      (new Thread() {
        @Override
        public void run() {
          try {
            watchdog.jobExecutionStarted(JOB);
            barrier.await(Timeout.standardTimeoutMillis(), TimeUnit.MILLISECONDS);
            Thread.sleep(Timeout.standardTimeoutMillis() * 3);
          } catch (final InterruptedException e) {
            caught.set(e);
          } catch (final Exception e) {
            throw new OpenGammaRuntimeException("exception", e);
          }
        }
      }).start();
      barrier.await(Timeout.standardTimeoutMillis(), TimeUnit.MILLISECONDS);
      assertTrue(watchdog.areThreadsAlive());
      Thread.sleep(Timeout.standardTimeoutMillis());
      // Watchdog will have fired and the default action will have interrupted the thread
      assertFalse(watchdog.areThreadsAlive());
      assertNotNull(caught.get());
    } finally {
      scheduler.shutdown();
    }
  }
View Full Code Here

    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put(sb.toString(), "");
    parameters.put("huuhaa", "");

    Action action = new SimpleAction();
    parametersInterceptor.setParameters(action, stack, parameters);
    assertEquals(1, actual.size());
  }
View Full Code Here

    public void testNoParametersAction() throws Exception {
        ParametersInterceptor interceptor = new ParametersInterceptor();
        interceptor.init();

        MockActionInvocation mai = new MockActionInvocation();
        Action action = new NoParametersAction();
        mai.setAction(action);

        interceptor.doIntercept(mai);
        interceptor.destroy();
    }
View Full Code Here

        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("user.address.city", "London");
        parameters.put("user.name", "Superman");

        Action action = new SimpleAction();
        pi.setParameters(action, stack, parameters);

        assertEquals("ordered should be false by default", false, pi.isOrdered());
        assertEquals(2, actual.size());
        assertEquals("London", actual.get("user.address.city"));
View Full Code Here

        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("user.address.city", "London");
        parameters.put("user.address['postal']", "QJR387");
        parameters.put("user.name", "Superman");

        Action action = new SimpleAction();
        pi.setParameters(action, stack, parameters);

        assertEquals(true, pi.isOrdered());
        assertEquals(3, actual.size());
        assertEquals("London", actual.get("user.address.city"));
View Full Code Here

        sac.registerSingleton("proxyFactory", BeanNameAutoProxyCreator.class, values);

        sac.refresh();

        ActionConfig actionConfig = new ActionConfig.Builder("", "", SimpleAction.class.getName()).build();
        Action action = (Action) objectFactory.buildBean(actionConfig.getClassName(), null);

        assertNotNull("Bean should not be null", action);
        System.out.println("Action class is: " + action.getClass().getName());
        assertTrue("Action should have been advised", action instanceof Advised);
    }
View Full Code Here

        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put(sb.toString(), "");
        parameters.put("huuhaa", "");

        Action action = new SimpleAction();
        parametersInterceptor.setParameters(action, stack, parameters);
        assertEquals(1, actual.size());
    }
View Full Code Here

    public void testNoParametersAction() throws Exception {
        ParametersInterceptor interceptor = new ParametersInterceptor();
        interceptor.init();

        MockActionInvocation mai = new MockActionInvocation();
        Action action = new NoParametersAction();
        mai.setAction(action);

        interceptor.doIntercept(mai);
        interceptor.destroy();
    }
View Full Code Here

        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("user.address.city", "London");
        parameters.put("user.name", "Superman");

        Action action = new SimpleAction();
        pi.setParameters(action, stack, parameters);

        assertEquals("ordered should be false by default", false, pi.isOrdered());
        assertEquals(2, actual.size());
        assertEquals("London", actual.get("user.address.city"));
View Full Code Here

TOP

Related Classes of com.opengamma.engine.calcnode.MaximumJobItemExecutionWatchdog$Action

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.