Commit 037a87ec authored by Florian Fittkau's avatar Florian Fittkau

jdbc monitoring

parent e36eaf0f
...@@ -18,6 +18,9 @@ import explorviz.live_trace_processing.record.IRecord; ...@@ -18,6 +18,9 @@ import explorviz.live_trace_processing.record.IRecord;
import explorviz.live_trace_processing.record.event.constructor.AfterConstructorEventRecord; import explorviz.live_trace_processing.record.event.constructor.AfterConstructorEventRecord;
import explorviz.live_trace_processing.record.event.constructor.AfterFailedConstructorEventRecord; import explorviz.live_trace_processing.record.event.constructor.AfterFailedConstructorEventRecord;
import explorviz.live_trace_processing.record.event.constructor.BeforeConstructorEventRecord; import explorviz.live_trace_processing.record.event.constructor.BeforeConstructorEventRecord;
import explorviz.live_trace_processing.record.event.jdbc.AfterFailedJDBCOperationEventRecord;
import explorviz.live_trace_processing.record.event.jdbc.AfterJDBCOperationEventRecord;
import explorviz.live_trace_processing.record.event.jdbc.BeforeJDBCOperationEventRecord;
import explorviz.live_trace_processing.record.event.normal.AfterFailedOperationEventRecord; import explorviz.live_trace_processing.record.event.normal.AfterFailedOperationEventRecord;
import explorviz.live_trace_processing.record.event.normal.AfterOperationEventRecord; import explorviz.live_trace_processing.record.event.normal.AfterOperationEventRecord;
import explorviz.live_trace_processing.record.event.normal.BeforeOperationEventRecord; import explorviz.live_trace_processing.record.event.normal.BeforeOperationEventRecord;
...@@ -278,6 +281,34 @@ class TCPReaderOneClient implements Runnable { ...@@ -278,6 +281,34 @@ class TCPReaderOneClient implements Runnable {
buffer.compact(); buffer.compact();
return; return;
} }
case BeforeJDBCOperationEventRecord.CLAZZ_ID: {
if (buffer.remaining() >= BeforeJDBCOperationEventRecord.COMPRESSED_BYTE_LENGTH) {
readInBeforeJDBCOperationEvent(buffer);
break;
}
buffer.position(buffer.position() - 1);
buffer.compact();
return;
}
case AfterFailedJDBCOperationEventRecord.CLAZZ_ID: {
if (buffer.remaining() >= AfterFailedJDBCOperationEventRecord.COMPRESSED_BYTE_LENGTH) {
readInAfterFailedJDBCOperationEvent(buffer);
break;
}
buffer.position(buffer.position() - 1);
buffer.compact();
return;
}
case AfterJDBCOperationEventRecord.CLAZZ_ID: {
if (buffer.remaining() >= AfterJDBCOperationEventRecord.COMPRESSED_BYTE_LENGTH) {
readInAfterJDBCOperationEvent(buffer);
break;
}
buffer.position(buffer.position() - 1);
buffer.compact();
return;
}
case BeforeOperationEventRecord.CLAZZ_ID_FROM_WORKER: { case BeforeOperationEventRecord.CLAZZ_ID_FROM_WORKER: {
if (buffer.remaining() >= 4) { if (buffer.remaining() >= 4) {
final int recordSize = buffer.getInt(); final int recordSize = buffer.getInt();
...@@ -901,6 +932,66 @@ class TCPReaderOneClient implements Runnable { ...@@ -901,6 +932,66 @@ class TCPReaderOneClient implements Runnable {
hostApplicationMetadata)); hostApplicationMetadata));
} }
private final void readInBeforeJDBCOperationEvent(final ByteBuffer buffer) {
final long traceId = buffer.getLong();
final int orderIndex = buffer.getInt();
final int objectId = buffer.getInt();
final int operationId = buffer.getInt();
final int clazzId = buffer.getInt();
final int interfaceId = buffer.getInt();
final int sqlStatementId = buffer.getInt();
try {
final String operation = stringRegistry.getStringFromId(operationId);
final String clazz = stringRegistry.getStringFromId(clazzId);
final String implementedInterface = stringRegistry.getStringFromId(interfaceId);
final String sqlStatement = stringRegistry.getStringFromId(sqlStatementId);
putInQueue(new BeforeJDBCOperationEventRecord(traceId, orderIndex, objectId, operation,
clazz, implementedInterface, sqlStatement, hostApplicationMetadata));
} catch (final IdNotAvailableException e) {
putInWaitingMessages(buffer, BeforeJDBCOperationEventRecord.COMPRESSED_BYTE_LENGTH + 1);
}
}
private final void readInAfterFailedJDBCOperationEvent(final ByteBuffer buffer) {
final long timestamp = buffer.getLong();
final long traceId = buffer.getLong();
final int orderIndex = buffer.getInt();
final int causeId = buffer.getInt();
try {
final String cause = stringRegistry.getStringFromId(causeId);
putInQueue(new AfterFailedJDBCOperationEventRecord(timestamp, traceId, orderIndex,
cause, hostApplicationMetadata));
} catch (final IdNotAvailableException e) {
putInWaitingMessages(buffer,
AfterFailedJDBCOperationEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID);
}
}
private final void readInAfterJDBCOperationEvent(final ByteBuffer buffer) {
final long timestamp = buffer.getLong();
final long traceId = buffer.getLong();
final int orderIndex = buffer.getInt();
final int formattedReturnValueId = buffer.getInt();
try {
final String formattedReturnValue = stringRegistry
.getStringFromId(formattedReturnValueId);
putInQueue(new AfterJDBCOperationEventRecord(timestamp, traceId, orderIndex,
formattedReturnValue, hostApplicationMetadata));
} catch (final IdNotAvailableException e) {
putInWaitingMessages(buffer,
AfterJDBCOperationEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID);
}
}
private final void putInWaitingMessages(final ByteBuffer buffer, final int length) { private final void putInWaitingMessages(final ByteBuffer buffer, final int length) {
final byte[] message = new byte[length]; final byte[] message = new byte[length];
buffer.position(buffer.position() - length); buffer.position(buffer.position() - length);
...@@ -968,6 +1059,15 @@ class TCPReaderOneClient implements Runnable { ...@@ -968,6 +1059,15 @@ class TCPReaderOneClient implements Runnable {
case AfterReceivedRemoteCallRecord.CLAZZ_ID: case AfterReceivedRemoteCallRecord.CLAZZ_ID:
readInAfterReceivedRemoteCallEvent(buffer); readInAfterReceivedRemoteCallEvent(buffer);
break; break;
case BeforeJDBCOperationEventRecord.CLAZZ_ID:
readInBeforeJDBCOperationEvent(buffer);
break;
case AfterFailedJDBCOperationEventRecord.CLAZZ_ID:
readInAfterFailedJDBCOperationEvent(buffer);
break;
case AfterJDBCOperationEventRecord.CLAZZ_ID:
readInAfterJDBCOperationEvent(buffer);
break;
default: default:
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment