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