Search in sources :

Example 1 with SlowOperationDTO

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

the class LocalOperationStatsImpl method toJson.

@Override
public JsonObject toJson() {
    JsonObject root = new JsonObject();
    root.add("maxVisibleSlowOperationCount", maxVisibleSlowOperationCount);
    JsonArray slowOperationArray = new JsonArray();
    int logCount = 0;
    for (SlowOperationDTO slowOperation : slowOperations) {
        if (logCount++ < maxVisibleSlowOperationCount) {
            slowOperationArray.add(slowOperation.toJson());
        }
    }
    root.add("slowOperations", slowOperationArray);
    root.add("creationTime", creationTime);
    return root;
}
Also used : JsonArray(com.eclipsesource.json.JsonArray) JsonObject(com.eclipsesource.json.JsonObject) SlowOperationDTO(com.hazelcast.internal.management.dto.SlowOperationDTO)

Example 2 with SlowOperationDTO

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

the class LocalOperationStatsImpl method toJson.

@Override
public JsonObject toJson() {
    JsonObject root = new JsonObject();
    root.add("maxVisibleSlowOperationCount", maxVisibleSlowOperationCount);
    JsonArray slowOperationArray = new JsonArray();
    int logCount = 0;
    for (SlowOperationDTO slowOperation : slowOperations) {
        if (logCount++ < maxVisibleSlowOperationCount) {
            slowOperationArray.add(slowOperation.toJson());
        }
    }
    root.add("slowOperations", slowOperationArray);
    root.add("creationTime", creationTime);
    return root;
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) JsonObject(com.hazelcast.internal.json.JsonObject) SlowOperationDTO(com.hazelcast.internal.management.dto.SlowOperationDTO)

Example 3 with SlowOperationDTO

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

the class LocalOperationStatsImpl method fromJson.

@Override
public void fromJson(JsonObject json) {
    maxVisibleSlowOperationCount = getLong(json, "maxVisibleSlowOperationCount", Long.MAX_VALUE);
    for (JsonValue jsonValue : getArray(json, "slowOperations")) {
        SlowOperationDTO slowOperationDTO = new SlowOperationDTO();
        slowOperationDTO.fromJson(jsonValue.asObject());
        slowOperations.add(slowOperationDTO);
    }
    creationTime = getLong(json, "creationTime", -1L);
}
Also used : JsonValue(com.eclipsesource.json.JsonValue) SlowOperationDTO(com.hazelcast.internal.management.dto.SlowOperationDTO)

Example 4 with SlowOperationDTO

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

the class LocalOperationStatsImplTest method assertEqualsSlowOperationDTOs.

static void assertEqualsSlowOperationDTOs(List<SlowOperationDTO> slowOperations1, List<SlowOperationDTO> slowOperations2) {
    if (slowOperations1 == null) {
        assertNull(slowOperations2);
    } else {
        assertNotNull(slowOperations2);
    }
    assertEquals(slowOperations1.size(), slowOperations2.size());
    Iterator<SlowOperationDTO> iterator = slowOperations2.iterator();
    for (SlowOperationDTO slowOperationDTO1 : slowOperations1) {
        SlowOperationDTO slowOperationDTO2 = iterator.next();
        assertEquals(slowOperationDTO1.operation, slowOperationDTO2.operation);
        assertEquals(slowOperationDTO1.stackTrace, slowOperationDTO2.stackTrace);
        assertEquals(slowOperationDTO1.totalInvocations, slowOperationDTO2.totalInvocations);
        assertEquals(slowOperationDTO1.invocations.size(), slowOperationDTO2.invocations.size());
    }
}
Also used : SlowOperationDTO(com.hazelcast.internal.management.dto.SlowOperationDTO)

Example 5 with SlowOperationDTO

use of com.hazelcast.internal.management.dto.SlowOperationDTO 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)

Aggregations

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