Skip to content
Snippets Groups Projects
Commit 46f635cb authored by Florian Fittkau's avatar Florian Fittkau
Browse files

working towards instance counting

parent e728407e
No related branches found
No related tags found
No related merge requests found
......@@ -5,10 +5,10 @@ import java.util.List;
import explorviz.live_trace_processing.Constants;
import explorviz.live_trace_processing.reader.TimeProvider;
import explorviz.live_trace_processing.record.event.AbstractAfterEventRecord;
import explorviz.live_trace_processing.record.event.AbstractAfterFailedEventRecord;
import explorviz.live_trace_processing.record.event.AbstractBeforeEventRecord;
import explorviz.live_trace_processing.record.event.AbstractEventRecord;
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.BeforeOperationEventRecord;
import explorviz.live_trace_processing.record.trace.Trace;
class TraceReconstructionBuffer {
......@@ -28,14 +28,14 @@ class TraceReconstructionBuffer {
updatedInThisPeriod = true;
final int orderIndex = setMaxOrderIndex(event);
if (event instanceof BeforeOperationEventRecord) {
if (event instanceof AbstractBeforeEventRecord) {
if (orderIndex == 0) {
closeable = true;
}
openEvents++;
} else if (event instanceof AfterOperationEventRecord) {
} else if (event instanceof AbstractAfterFailedEventRecord) {
openEvents--;
} else if (event instanceof AfterFailedOperationEventRecord) {
} else if (event instanceof AbstractAfterEventRecord) {
openEvents--;
}
......
......@@ -15,6 +15,9 @@ import explorviz.live_trace_processing.StringRegistry;
import explorviz.live_trace_processing.filter.RecordArrayEvent;
import explorviz.live_trace_processing.record.IRecord;
import explorviz.live_trace_processing.record.event.AbstractEventRecord;
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.BeforeConstructorEventRecord;
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.BeforeOperationEventRecord;
......@@ -194,6 +197,36 @@ public class TCPReaderOneClient extends Thread implements IPeriodicTimeSignalRec
break;
}
case BeforeConstructorEventRecord.CLAZZ_ID: {
if (buffer.remaining() >= BeforeConstructorEventRecord.COMPRESSED_BYTE_LENGTH) {
readInBeforeConstructorEvent(buffer);
} else {
buffer.position(buffer.position() - 1);
buffer.compact();
return;
}
break;
}
case AfterFailedConstructorEventRecord.CLAZZ_ID: {
if (buffer.remaining() >= AfterFailedConstructorEventRecord.COMPRESSED_BYTE_LENGTH) {
readInAfterFailedConstructorEvent(buffer);
} else {
buffer.position(buffer.position() - 1);
buffer.compact();
return;
}
break;
}
case AfterConstructorEventRecord.CLAZZ_ID: {
if (buffer.remaining() >= AfterConstructorEventRecord.COMPRESSED_BYTE_LENGTH) {
readInAfterConstructorEvent(buffer);
} else {
buffer.position(buffer.position() - 1);
buffer.compact();
return;
}
break;
}
default: {
System.out.println("unknown class id " + clazzId + " at offset "
+ (buffer.position() - 1));
......@@ -224,13 +257,15 @@ public class TCPReaderOneClient extends Thread implements IPeriodicTimeSignalRec
final long timestamp = buffer.getLong();
final long traceId = buffer.getLong();
final int orderIndex = buffer.getInt();
final int objectId = buffer.getInt();
final int operationId = buffer.getInt();
try {
final String operation = stringRegistry.getStringFromId(operationId);
putInRingBuffer(new BeforeOperationEventRecord(timestamp, traceId, orderIndex,
operation, hostApplicationMetadata, new RuntimeStatisticInformation(timestamp)));
objectId, operation, hostApplicationMetadata, new RuntimeStatisticInformation(
timestamp)));
} catch (final IdNotAvailableException e) {
putInWaitingMessages(buffer,
BeforeOperationEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID);
......@@ -241,6 +276,7 @@ public class TCPReaderOneClient extends Thread implements IPeriodicTimeSignalRec
final long timestamp = buffer.getLong();
final long traceId = buffer.getLong();
final int orderIndex = buffer.getInt();
final int objectId = buffer.getInt();
final int operationId = buffer.getInt();
final int causeId = buffer.getInt();
......@@ -249,8 +285,8 @@ public class TCPReaderOneClient extends Thread implements IPeriodicTimeSignalRec
final String cause = stringRegistry.getStringFromId(causeId);
putInRingBuffer(new AfterFailedOperationEventRecord(timestamp, traceId, orderIndex,
operation, cause, hostApplicationMetadata, new RuntimeStatisticInformation(
timestamp)));
objectId, operation, cause, hostApplicationMetadata,
new RuntimeStatisticInformation(timestamp)));
} catch (final IdNotAvailableException e) {
putInWaitingMessages(buffer,
AfterFailedOperationEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID);
......@@ -261,12 +297,13 @@ public class TCPReaderOneClient extends Thread implements IPeriodicTimeSignalRec
final long timestamp = buffer.getLong();
final long traceId = buffer.getLong();
final int orderIndex = buffer.getInt();
final int objectId = buffer.getInt();
final int operationId = buffer.getInt();
try {
final String operation = stringRegistry.getStringFromId(operationId);
putInRingBuffer(new AfterOperationEventRecord(timestamp, traceId, orderIndex,
putInRingBuffer(new AfterOperationEventRecord(timestamp, traceId, orderIndex, objectId,
operation, hostApplicationMetadata, new RuntimeStatisticInformation(timestamp)));
} catch (final IdNotAvailableException e) {
putInWaitingMessages(buffer,
......@@ -284,6 +321,66 @@ public class TCPReaderOneClient extends Thread implements IPeriodicTimeSignalRec
hostApplicationMetadata));
}
private final void readInBeforeConstructorEvent(final ByteBuffer buffer) {
final long timestamp = buffer.getLong();
final long traceId = buffer.getLong();
final int orderIndex = buffer.getInt();
final int objectId = buffer.getInt();
final int operationId = buffer.getInt();
try {
final String operation = stringRegistry.getStringFromId(operationId);
putInRingBuffer(new BeforeConstructorEventRecord(timestamp, traceId, orderIndex,
objectId, operation, hostApplicationMetadata, new RuntimeStatisticInformation(
timestamp)));
} catch (final IdNotAvailableException e) {
putInWaitingMessages(buffer,
BeforeConstructorEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID);
}
}
private final void readInAfterFailedConstructorEvent(final ByteBuffer buffer) {
final long timestamp = buffer.getLong();
final long traceId = buffer.getLong();
final int orderIndex = buffer.getInt();
final int objectId = buffer.getInt();
final int operationId = buffer.getInt();
final int causeId = buffer.getInt();
try {
final String operation = stringRegistry.getStringFromId(operationId);
final String cause = stringRegistry.getStringFromId(causeId);
putInRingBuffer(new AfterFailedConstructorEventRecord(timestamp, traceId, orderIndex,
objectId, operation, cause, hostApplicationMetadata,
new RuntimeStatisticInformation(timestamp)));
} catch (final IdNotAvailableException e) {
putInWaitingMessages(buffer,
AfterFailedConstructorEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID);
}
}
private final void readInAfterConstructorEvent(final ByteBuffer buffer) {
final long timestamp = buffer.getLong();
final long traceId = buffer.getLong();
final int orderIndex = buffer.getInt();
final int objectId = buffer.getInt();
final int operationId = buffer.getInt();
try {
final String operation = stringRegistry.getStringFromId(operationId);
putInRingBuffer(new AfterConstructorEventRecord(timestamp, traceId, orderIndex,
objectId, operation, hostApplicationMetadata, new RuntimeStatisticInformation(
timestamp)));
} catch (final IdNotAvailableException e) {
putInWaitingMessages(buffer,
AfterConstructorEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID);
}
}
private final void putInWaitingMessages(final ByteBuffer buffer, final int length) {
final byte[] message = new byte[length];
buffer.position(buffer.position() - length);
......
......@@ -13,7 +13,7 @@ public class TraceReconstructionBufferTest {
@Test
public void testInsertEvent() throws Exception {
final TraceReconstructionBuffer traceReconstructionBuffer = new TraceReconstructionBuffer();
traceReconstructionBuffer.insertEvent(new BeforeOperationEventRecord(1000, 1, 0, "test",
traceReconstructionBuffer.insertEvent(new BeforeOperationEventRecord(1000, 1, 0, 0, "test",
new HostApplicationMetaDataRecord("testHost", "testApp"),
new RuntimeStatisticInformation(1000)));
assertTrue(true); // TODO
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment