Package net.anotheria.moskito.core.predefined

Examples of net.anotheria.moskito.core.predefined.ServiceStats


    //in this case we don't have anything in the Registry.
    IProducerRegistryAPI registry = new ProducerRegistryAPIFactory().createProducerRegistryAPI();
    OnDemandStatsProducer<ServiceStats> producer = (OnDemandStatsProducer<ServiceStats>)registry.getProducer("SimpleService-1");
    assertNotNull(producer);
    ServiceStats methodStats = producer.getStats("doSomethingMethod");
    assertEquals(10, methodStats.getTotalRequests());

  }
View Full Code Here


    //in this case we don't have anything in the Registry.
    IProducerRegistryAPI registry = new ProducerRegistryAPIFactory().createProducerRegistryAPI();
    OnDemandStatsProducer<ServiceStats> producer = (OnDemandStatsProducer<ServiceStats>)registry.getProducer("SimpleService");
    assertNotNull(producer);
    ServiceStats methodStats = producer.getStats("doSomethingMethod");
    assertEquals(10, methodStats.getTotalRequests());

  }
View Full Code Here

    OnDemandStatsProducer<ServiceStats> producer = getProducer(pjp, aProducerId, aCategory, aSubsystem, false, FACTORY);
    String producerId = producer.getProducerId();

    String caseName = pjp.getSignature().getName();
    ServiceStats defaultStats = producer.getDefaultStats();
    ServiceStats methodStats = producer.getStats(caseName);

    final Object[] args = pjp.getArgs();
    final String method = pjp.getSignature().getName();
    defaultStats.addRequest();
    if (methodStats != null) {
      methodStats.addRequest();
    }
    TracedCall aRunningTrace = RunningTraceContainer.getCurrentlyTracedCall();
    TraceStep currentStep = null;
    CurrentlyTracedCall currentTrace = aRunningTrace.callTraced() ? (CurrentlyTracedCall) aRunningTrace : null;
    if (currentTrace != null) {
      StringBuilder call = new StringBuilder(producerId).append('.').append(method).append("(");
      if (args != null && args.length > 0) {
        for (int i = 0; i < args.length; i++) {
          call.append(args[i]);
          if (i < args.length - 1) {
            call.append(", ");
          }
        }
      }
      call.append(")");
      currentStep = currentTrace.startStep(call.toString(), producer);
    }
    long startTime = System.nanoTime();
    Object ret = null;
    try {
      ret = pjp.proceed();
      return ret;
    } catch (InvocationTargetException e) {
      defaultStats.notifyError();
      if (methodStats != null) {
        methodStats.notifyError();
      }
      //System.out.println("exception of class: "+e.getCause()+" is thrown");
      if (currentStep != null) {
        currentStep.setAborted();
      }
      throw e.getCause();
    } catch (Throwable t) {
      defaultStats.notifyError();
      if (methodStats != null) {
        methodStats.notifyError();
      }
      if (currentStep != null) {
        currentStep.setAborted();
      }
      throw t;
    } finally {
      long exTime = System.nanoTime() - startTime;
      defaultStats.addExecutionTime(exTime);
      if (methodStats != null) {
        methodStats.addExecutionTime(exTime);
      }
      defaultStats.notifyRequestFinished();
      if (methodStats != null) {
        methodStats.notifyRequestFinished();
      }
      if (currentStep != null) {
        currentStep.setDuration(exTime);
        try {
          currentStep.appendToCall(" = " + ret);
View Full Code Here

    for (int i=0; i<10; i++){
      process.methodWhichIsPartiallyMonitored();
    }

    //now we check
    ServiceStats stats = ((OnDemandStatsProducer<ServiceStats>)(new ProducerRegistryAPIFactory().createProducerRegistryAPI().getProducer("complexprocess"))).getStats("methodWhichIsPartiallyMonitored");
    assertNotNull(stats);
    assertEquals(10, stats.getTotalRequests());
  }
View Full Code Here

      process.methodWithMultipleComplexSubprocesses();
    }

    OnDemandStatsProducer<ServiceStats> producer = (OnDemandStatsProducer<ServiceStats>)(new ProducerRegistryAPIFactory().createProducerRegistryAPI().getProducer("complexprocess"));
    //now we check
    ServiceStats phase1 = producer.getStats("phase1");
    ServiceStats phase2 = producer.getStats("phase2");
    ServiceStats phase3 = producer.getStats("phase3");
    assertNotNull(phase1);
    assertNotNull(phase2);
    assertNotNull(phase3);

    assertEquals(10, phase1.getTotalRequests());

    //called thrice per request
    assertEquals(30, phase2.getTotalRequests());
    //called twice per request
    assertEquals(20, phase3.getTotalRequests());
  }
View Full Code Here

    //you don't have to do this, as your data will probably show up in webui or logs or whatever configured.
    IProducerRegistryAPI registryAPI = new ProducerRegistryAPIFactory().createProducerRegistryAPI();
    OnDemandStatsProducer<ServiceStats> producer = (OnDemandStatsProducer<ServiceStats>)registryAPI.getProducer("MonitoredClass");
    assertNotNull(producer);

    ServiceStats firstMethodStats = producer.getStats("firstMethod");
    assertNotNull(firstMethodStats);
    assertEquals(100, firstMethodStats.getTotalRequests());

    ServiceStats secondMethodStats = producer.getStats("secondMethod");
    assertNotNull(secondMethodStats);
    assertEquals(100, secondMethodStats.getTotalRequests());

    //the cumulated stats should contain both
    ServiceStats cumulatedStats = producer.getDefaultStats();
    assertNotNull(cumulatedStats);
    assertEquals(200, cumulatedStats.getTotalRequests());


    //now ensure that the doNotMonitorMe is not being monitored.
    //we can't call getStats("doNotMonitorMe") directly, because onDemandStatsProducer would create it on the fly, instead we iterate ober exising stats
    for (ServiceStats stats : producer.getStats()){
View Full Code Here

    IProducerRegistryAPI registryAPI = new ProducerRegistryAPIFactory().createProducerRegistryAPI();
    OnDemandStatsProducer<ServiceStats> producer = (OnDemandStatsProducer<ServiceStats>)registryAPI.getProducer("ClassWithMonitoredMethod");
    assertNotNull(producer);

    //the firstMethod is monitored and should therefor produce stats.
    ServiceStats firstMethodStats = producer.getStats("firstMethod");
    assertNotNull(firstMethodStats);
    assertEquals(100, firstMethodStats.getTotalRequests());

    //a way to prove that secondMethod is not count, is to count:
    assertEquals(2, producer.getStats().size());


    //the secondMethodStats is NOT monitored and should therefor produce stats.
    ServiceStats secondMethodStats = producer.getStats("secondMethod");
    //even not monitored, the stats object will be created on the fly.
    assertNotNull(secondMethodStats);
    //but there will be no data.
    assertEquals(0, secondMethodStats.getTotalRequests());

    //the cumulated stats should contain only firstmethod, therefore 100
    ServiceStats cumulatedStats = producer.getDefaultStats();
    assertNotNull(cumulatedStats);
    assertEquals(100, cumulatedStats.getTotalRequests());



  }
View Full Code Here

TOP

Related Classes of net.anotheria.moskito.core.predefined.ServiceStats

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.