Package com.opengamma.engine.calcnode.stats

Examples of com.opengamma.engine.calcnode.stats.FunctionInvocationStatisticsSender


  private FunctionCosts _cost = new FunctionCosts ();
 
  @Test(timeOut = 3_000L)
  public void testBasicBehaviour () {
    final AtomicInteger messages = new AtomicInteger ();
    final FunctionInvocationStatisticsSender sender = new FunctionInvocationStatisticsSender ();
    final FunctionInvocationStatisticsReceiver receiver = new FunctionInvocationStatisticsReceiver (_cost);
    sender.setExecutorService(Executors.newCachedThreadPool ());
    sender.setFudgeMessageSender(new FudgeMessageSender () {

      @Override
      public FudgeContext getFudgeContext() {
        return FudgeContext.GLOBAL_DEFAULT;
      }

      @Override
      public void send(final FudgeMsg message) {
        messages.incrementAndGet ();
        s_logger.debug ("Received {}", message);
        receiver.messageReceived(getFudgeContext (), new FudgeMsgEnvelope (message));
      }
     
    });
    sender.setUpdatePeriod(Duration.ofSeconds(1));
    long t = System.nanoTime ();
    for (int i = 0; i < 100; i++) {
      sender.functionInvoked("A", "1", 1, 2.0, 3.0, 4.0);
      sender.functionInvoked("A", "2", 1, 2.0, 3.0, 4.0);
      sender.functionInvoked("A", "1", 1, 2.0, 3.0, 4.0);
      try {
        Thread.sleep (20);
      } catch (InterruptedException e) {
      }
    }
    sender.functionInvoked ("A", "3", 300, 300 * 4.0, 300 * 5.0, 300 * 6.0);
    t = (System.nanoTime () - t) / 1000000000;
    sender.flush ();
    if ((messages.get () < t) || (messages.get () > t + 2)) {
      Assert.fail ("Unexpected number of messages (" + messages.get () + ") from " + t + "s execution");
    }
    assertEquals (2.0, _cost.getStatistics ("A", "1").getInvocationCost (), 1e-5);
    assertEquals (3.0, _cost.getStatistics ("A", "1").getDataInputCost (), 1e-5);
View Full Code Here


  public void simpleInvocation() {
    final IdentifierMap identifierMap = new InMemoryIdentifierMap ();
    final DirectFudgeConnection conduit = new DirectFudgeConnection(s_fudgeContext);
    final CollectingFudgeMessageReceiver messages = new CollectingFudgeMessageReceiver();
    conduit.getEnd2().setFudgeMessageReceiver(messages);
    final RemoteNodeClient client = new RemoteNodeClient(conduit.getEnd1(), new CompiledFunctionService (new InMemoryFunctionRepository (), new CachingFunctionRepositoryCompiler(), new FunctionCompilationContext ()), new InMemoryIdentifierMap (), new FunctionInvocationStatisticsSender ());
    final SimpleCalculationNode node = new TestCalculationNode();
    assertEquals(0, messages.getMessages().size());
    client.addNode(node);
    assertEquals(0, messages.getMessages().size());
    client.start();
View Full Code Here

  public void isAlive () {
    final IdentifierMap identifierMap = new InMemoryIdentifierMap ();
    final DirectFudgeConnection conduit = new DirectFudgeConnection(s_fudgeContext);
    final CollectingFudgeMessageReceiver messages = new CollectingFudgeMessageReceiver();
    conduit.getEnd2().setFudgeMessageReceiver(messages);
    final RemoteNodeClient client = new RemoteNodeClient(conduit.getEnd1(), new CompiledFunctionService (new InMemoryFunctionRepository (), new CachingFunctionRepositoryCompiler(), new FunctionCompilationContext ()), new InMemoryIdentifierMap (), new FunctionInvocationStatisticsSender ());
    client.start();
    assertEquals(1, messages.getMessages().size());
    final FudgeMsgEnvelope readyMsgEnvelope = messages.getMessages().get(0);
    messages.clear();
    final FudgeDeserializer dcontext = new FudgeDeserializer(s_fudgeContext);
View Full Code Here

  public void errorInvocation() {
    final IdentifierMap identifierMap = new InMemoryIdentifierMap ();
    final DirectFudgeConnection conduit = new DirectFudgeConnection(s_fudgeContext);
    final CollectingFudgeMessageReceiver messages = new CollectingFudgeMessageReceiver();
    conduit.getEnd2().setFudgeMessageReceiver(messages);
    final RemoteNodeClient client = new RemoteNodeClient(conduit.getEnd1(), new CompiledFunctionService (new InMemoryFunctionRepository (), new CachingFunctionRepositoryCompiler(), new FunctionCompilationContext ()), new InMemoryIdentifierMap (), new FunctionInvocationStatisticsSender ());
    final SimpleCalculationNode failingNode = new TestCalculationNode() {
     
      @Override
      public CalculationJobResult executeJob(CalculationJob job) {
        throw new OpenGammaRuntimeException ("Remote node not working");
View Full Code Here

TOP

Related Classes of com.opengamma.engine.calcnode.stats.FunctionInvocationStatisticsSender

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.