Search in sources :

Example 1 with MetricsLoader

use of org.apache.servicecomb.foundation.metrics.publish.MetricsLoader in project incubator-servicecomb-java-chassis by apache.

the class TestMonitorManager method setup.

@BeforeClass
public static void setup() throws InterruptedException {
    System.getProperties().setProperty(MetricsConfig.METRICS_WINDOW_TIME, "2000");
    // ==========================================================================
    // fun1 is a PRODUCER invocation call 2 time and all is completed
    // two time success
    EventBus.getInstance().triggerEvent(new InvocationStartedEvent("fun1", InvocationType.PRODUCER, System.nanoTime()));
    EventBus.getInstance().triggerEvent(new InvocationStartExecutionEvent("fun1"));
    EventBus.getInstance().triggerEvent(new InvocationFinishedEvent("fun1", InvocationType.PRODUCER, TimeUnit.MILLISECONDS.toNanos(100), TimeUnit.MILLISECONDS.toNanos(200), TimeUnit.MILLISECONDS.toNanos(300), 200));
    EventBus.getInstance().triggerEvent(new InvocationStartedEvent("fun1", InvocationType.PRODUCER, System.nanoTime()));
    EventBus.getInstance().triggerEvent(new InvocationStartExecutionEvent("fun1"));
    EventBus.getInstance().triggerEvent(new InvocationFinishedEvent("fun1", InvocationType.PRODUCER, TimeUnit.MILLISECONDS.toNanos(300), TimeUnit.MILLISECONDS.toNanos(400), TimeUnit.MILLISECONDS.toNanos(700), 200));
    EventBus.getInstance().triggerEvent(new InvocationStartedEvent("fun1", InvocationType.PRODUCER, System.nanoTime()));
    EventBus.getInstance().triggerEvent(new InvocationStartExecutionEvent("fun1"));
    EventBus.getInstance().triggerEvent(new InvocationFinishedEvent("fun1", InvocationType.PRODUCER, TimeUnit.MILLISECONDS.toNanos(300), TimeUnit.MILLISECONDS.toNanos(400), TimeUnit.MILLISECONDS.toNanos(700), 500));
    // ==========================================================================
    // fun2 is a CONSUMER invocation call once and completed
    EventBus.getInstance().triggerEvent(new InvocationFinishedEvent("fun2", InvocationType.CONSUMER, 0, 0, TimeUnit.MILLISECONDS.toNanos(300), 200));
    // ==========================================================================
    // fun3 is a PRODUCER invocation call uncompleted
    EventBus.getInstance().triggerEvent(new InvocationStartedEvent("fun3", InvocationType.PRODUCER, System.nanoTime()));
    EventBus.getInstance().triggerEvent(new InvocationStartExecutionEvent("fun3"));
    // ==========================================================================
    // fun4 is a PRODUCER call only started and no processing start and finished
    EventBus.getInstance().triggerEvent(new InvocationStartedEvent("fun4", InvocationType.PRODUCER, System.nanoTime()));
    Map<String, Double> metrics = MonitorManager.getInstance().measure();
    currentWindowMetricsLoader = new MetricsLoader(metrics);
    // sim at lease one window time
    Thread.sleep(2000);
    metrics = MonitorManager.getInstance().measure();
    nextWindowMetricsLoader = new MetricsLoader(metrics);
}
Also used : InvocationFinishedEvent(org.apache.servicecomb.core.metrics.InvocationFinishedEvent) InvocationStartExecutionEvent(org.apache.servicecomb.core.metrics.InvocationStartExecutionEvent) MetricsLoader(org.apache.servicecomb.foundation.metrics.publish.MetricsLoader) InvocationStartedEvent(org.apache.servicecomb.core.metrics.InvocationStartedEvent) BeforeClass(org.junit.BeforeClass)

Aggregations

InvocationFinishedEvent (org.apache.servicecomb.core.metrics.InvocationFinishedEvent)1 InvocationStartExecutionEvent (org.apache.servicecomb.core.metrics.InvocationStartExecutionEvent)1 InvocationStartedEvent (org.apache.servicecomb.core.metrics.InvocationStartedEvent)1 MetricsLoader (org.apache.servicecomb.foundation.metrics.publish.MetricsLoader)1 BeforeClass (org.junit.BeforeClass)1