Search in sources :

Example 1 with SlowOperationInvocationDTO

use of com.hazelcast.internal.management.dto.SlowOperationInvocationDTO in project hazelcast by hazelcast.

the class LocalOperationStatsImplTest method testSerialization.

@Test
public void testSerialization() {
    Config config = new Config();
    config.setProperty(GroupProperty.MC_MAX_VISIBLE_SLOW_OPERATION_COUNT.getName(), "127");
    SlowOperationInvocationDTO slowOperationInvocationDTO = new SlowOperationInvocationDTO();
    slowOperationInvocationDTO.id = 12345;
    slowOperationInvocationDTO.durationMs = 15000;
    slowOperationInvocationDTO.startedAt = 12381912;
    slowOperationInvocationDTO.operationDetails = "TestOperationDetails";
    List<SlowOperationInvocationDTO> invocationList = new ArrayList<SlowOperationInvocationDTO>();
    invocationList.add(slowOperationInvocationDTO);
    SlowOperationDTO slowOperationDTO = new SlowOperationDTO();
    slowOperationDTO.operation = "TestOperation";
    slowOperationDTO.stackTrace = "stackTrace";
    slowOperationDTO.totalInvocations = 4;
    slowOperationDTO.invocations = invocationList;
    HazelcastInstance hazelcastInstance = createHazelcastInstance(config);
    Node node = getNode(hazelcastInstance);
    LocalOperationStatsImpl localOperationStats = new LocalOperationStatsImpl(node);
    localOperationStats.getSlowOperations().add(slowOperationDTO);
    LocalOperationStatsImpl deserialized = new LocalOperationStatsImpl();
    deserialized.fromJson(localOperationStats.toJson());
    assertEquals(localOperationStats.getCreationTime(), deserialized.getCreationTime());
    assertEquals(localOperationStats.getMaxVisibleSlowOperationCount(), deserialized.getMaxVisibleSlowOperationCount());
    assertEqualsSlowOperationDTOs(localOperationStats.getSlowOperations(), deserialized.getSlowOperations());
}
Also used : SlowOperationInvocationDTO(com.hazelcast.internal.management.dto.SlowOperationInvocationDTO) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) Node(com.hazelcast.instance.Node) ArrayList(java.util.ArrayList) SlowOperationDTO(com.hazelcast.internal.management.dto.SlowOperationDTO) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with SlowOperationInvocationDTO

use of com.hazelcast.internal.management.dto.SlowOperationInvocationDTO in project hazelcast by hazelcast.

the class SlowOperationDetector_JsonTest method testJSON.

@Test
public void testJSON() throws InterruptedException {
    final String operationDetails = "FakeOperation(id=255, partitionId=2)";
    Object operation = new Object() {

        @Override
        public String toString() {
            return operationDetails;
        }
    };
    String stackTrace = "stackTrace";
    int id = 5;
    int durationMs = 4444;
    long nowMillis = System.currentTimeMillis();
    long nowNanos = System.nanoTime();
    long durationNanos = TimeUnit.MILLISECONDS.toNanos(durationMs);
    SlowOperationLog log = new SlowOperationLog(stackTrace, operation);
    log.totalInvocations.incrementAndGet();
    log.getOrCreate(id, operationDetails, durationNanos, nowNanos, nowMillis);
    JsonObject json = log.createDTO().toJson();
    logger.finest(json.toString());
    SlowOperationDTO slowOperationDTO = new SlowOperationDTO();
    slowOperationDTO.fromJson(json);
    assertTrue(format("Expected operation '%s' to contain inner class", slowOperationDTO.operation), slowOperationDTO.operation.contains("SlowOperationDetector_JsonTest$1"));
    assertEqualsStringFormat("Expected stack trace '%s', but was '%s'", stackTrace, slowOperationDTO.stackTrace);
    assertEqualsStringFormat("Expected totalInvocations '%d', but was '%d'", 1, slowOperationDTO.totalInvocations);
    assertEqualsStringFormat("Expected invocations.size() '%d', but was '%d'", 1, slowOperationDTO.invocations.size());
    SlowOperationInvocationDTO invocationDTO = slowOperationDTO.invocations.get(0);
    assertEqualsStringFormat("Expected id '%d', but was '%d'", id, invocationDTO.id);
    assertEqualsStringFormat("Expected details '%s', but was '%s'", operationDetails, invocationDTO.operationDetails);
    assertEqualsStringFormat("Expected startedAt '%d', but was '%d'", nowMillis - durationMs, invocationDTO.startedAt);
    assertEqualsStringFormat("Expected durationMs '%d', but was '%d'", durationMs, invocationDTO.durationMs);
}
Also used : SlowOperationInvocationDTO(com.hazelcast.internal.management.dto.SlowOperationInvocationDTO) JsonObject(com.eclipsesource.json.JsonObject) JsonObject(com.eclipsesource.json.JsonObject) SlowOperationDTO(com.hazelcast.internal.management.dto.SlowOperationDTO) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 3 with SlowOperationInvocationDTO

use of com.hazelcast.internal.management.dto.SlowOperationInvocationDTO in project hazelcast by hazelcast.

the class SlowOperationPlugin method renderInvocations.

private void renderInvocations(DiagnosticsLogWriter writer, SlowOperationDTO slowOperation) {
    writer.startSection("slowInvocations");
    for (SlowOperationInvocationDTO invocation : slowOperation.invocations) {
        writer.writeKeyValueEntry("startedAt", invocation.startedAt);
        writer.writeKeyValueEntry("durationNs", invocation.durationMs);
        writer.writeKeyValueEntry("operationDetails", invocation.operationDetails);
    }
    writer.endSection();
}
Also used : SlowOperationInvocationDTO(com.hazelcast.internal.management.dto.SlowOperationInvocationDTO)

Aggregations

SlowOperationInvocationDTO (com.hazelcast.internal.management.dto.SlowOperationInvocationDTO)3 SlowOperationDTO (com.hazelcast.internal.management.dto.SlowOperationDTO)2 Test (org.junit.Test)2 JsonObject (com.eclipsesource.json.JsonObject)1 Config (com.hazelcast.config.Config)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 Node (com.hazelcast.instance.Node)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 SlowTest (com.hazelcast.test.annotation.SlowTest)1 ArrayList (java.util.ArrayList)1