Search in sources :

Example 1 with ProfilingDataLog

use of com.evolveum.midpoint.util.aspect.ProfilingDataLog in project midpoint by Evolveum.

the class ProfilingTest method prof_03_profManagerRequestTest.

@Test
public void prof_03_profManagerRequestTest() {
    ProfilingDataManager manager = ProfilingDataManager.getInstance();
    ProfilingDataLog event1 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", FASTEST_METHOD_EST, System.currentTimeMillis());
    ProfilingDataLog event2 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", MIDDLE_METHOD_EST, System.currentTimeMillis());
    ProfilingDataLog event3 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", SLOWEST_METHOD_EST, System.currentTimeMillis());
    //WHEN - adding 3 custom events
    manager.prepareRequestProfilingEvent(event1);
    manager.prepareRequestProfilingEvent(event2);
    manager.prepareRequestProfilingEvent(event3);
    Map<String, MethodUsageStatistics> perfMap = manager.getPerformanceMap();
    //THEN
    assertSame(1, perfMap.keySet().size());
    assertSame(3, perfMap.get(REQUEST_FILTER_TEST_URI).getSlowestMethodList().size());
    //Here, we are testing, if ProfilingEventList - slowestMethodMap is ordered correctly - we must use this
    //strange approach, because testNG somehow thinks, that long 5000 != long 5000
    boolean first = false;
    boolean second = false;
    boolean third = false;
    if (SLOWEST_METHOD_EST == perfMap.get(REQUEST_FILTER_TEST_URI).getSlowestMethodList().get(0).getEstimatedTime())
        first = true;
    if (MIDDLE_METHOD_EST == perfMap.get(REQUEST_FILTER_TEST_URI).getSlowestMethodList().get(1).getEstimatedTime())
        second = true;
    if (FASTEST_METHOD_EST == perfMap.get(REQUEST_FILTER_TEST_URI).getSlowestMethodList().get(2).getEstimatedTime())
        third = true;
    assertSame(true, first);
    assertSame(true, second);
    assertSame(true, third);
    boolean max = false;
    boolean min = false;
    boolean mean = false;
    if (SLOWEST_METHOD_EST == perfMap.get(REQUEST_FILTER_TEST_URI).getMax())
        max = true;
    if (FASTEST_METHOD_EST == perfMap.get(REQUEST_FILTER_TEST_URI).getMin())
        min = true;
    long meanVal = (FASTEST_METHOD_EST + MIDDLE_METHOD_EST + SLOWEST_METHOD_EST) / 3;
    if (meanVal == perfMap.get(REQUEST_FILTER_TEST_URI).getMean())
        mean = true;
    assertSame(true, max);
    assertSame(true, min);
    assertSame(true, mean);
}
Also used : ProfilingDataManager(com.evolveum.midpoint.util.aspect.ProfilingDataManager) MethodUsageStatistics(com.evolveum.midpoint.util.aspect.MethodUsageStatistics) ProfilingDataLog(com.evolveum.midpoint.util.aspect.ProfilingDataLog) Test(org.testng.annotations.Test)

Example 2 with ProfilingDataLog

use of com.evolveum.midpoint.util.aspect.ProfilingDataLog in project midpoint by Evolveum.

the class ProfilingTest method prof_04_testMaxEventsInList.

@Test
public void prof_04_testMaxEventsInList() {
    //Here, we create 7 events
    ProfilingDataManager manager = ProfilingDataManager.getInstance();
    ProfilingDataLog event1 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", FASTEST_METHOD_EST, System.currentTimeMillis());
    ProfilingDataLog event2 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", MIDDLE_METHOD_EST, System.currentTimeMillis());
    ProfilingDataLog event3 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", SLOWEST_METHOD_EST, System.currentTimeMillis());
    ProfilingDataLog event4 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", SLOWEST_METHOD_EST, System.currentTimeMillis());
    ProfilingDataLog event5 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", SLOWEST_METHOD_EST, System.currentTimeMillis());
    ProfilingDataLog event6 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", SLOWEST_METHOD_EST, System.currentTimeMillis());
    ProfilingDataLog event7 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", SLOWEST_METHOD_EST, System.currentTimeMillis());
    manager.prepareRequestProfilingEvent(event1);
    manager.prepareRequestProfilingEvent(event2);
    manager.prepareRequestProfilingEvent(event3);
    manager.prepareRequestProfilingEvent(event4);
    manager.prepareRequestProfilingEvent(event5);
    manager.prepareRequestProfilingEvent(event6);
    manager.prepareRequestProfilingEvent(event7);
    //Only 5 slowest requests should be saved in methodList
    assertNotSame(7, manager.getPerformanceMap().get(REQUEST_FILTER_TEST_URI).getSlowestMethodList().size());
}
Also used : ProfilingDataManager(com.evolveum.midpoint.util.aspect.ProfilingDataManager) ProfilingDataLog(com.evolveum.midpoint.util.aspect.ProfilingDataLog) Test(org.testng.annotations.Test)

Example 3 with ProfilingDataLog

use of com.evolveum.midpoint.util.aspect.ProfilingDataLog in project midpoint by Evolveum.

the class MidPointProfilingServletFilter method prepareRequestProfilingEvent.

private void prepareRequestProfilingEvent(ServletRequest request, long elapsed, String uri) {
    String info = ((HttpServletRequest) request).getMethod();
    String sessionId = ((HttpServletRequest) request).getRequestedSessionId();
    ProfilingDataLog event = new ProfilingDataLog(info, uri, sessionId, elapsed, System.currentTimeMillis());
    ProfilingDataManager.getInstance().prepareRequestProfilingEvent(event);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ProfilingDataLog(com.evolveum.midpoint.util.aspect.ProfilingDataLog)

Aggregations

ProfilingDataLog (com.evolveum.midpoint.util.aspect.ProfilingDataLog)3 ProfilingDataManager (com.evolveum.midpoint.util.aspect.ProfilingDataManager)2 Test (org.testng.annotations.Test)2 MethodUsageStatistics (com.evolveum.midpoint.util.aspect.MethodUsageStatistics)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1