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;
}
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;
}
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);
}
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());
}
}
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());
}
Aggregations