From d05ebcdfae2db6af3720b1976906dead549e81a8 Mon Sep 17 00:00:00 2001
From: Florian Fittkau <ffi@informatik.uni-kiel.de>
Date: Wed, 18 Dec 2013 00:02:09 +0100
Subject: [PATCH] read in remote bridge record

---
 .../reader/TCPReaderOneClient.java            | 38 +++++++++++++++++--
 1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/src/explorviz/live_trace_processing/reader/TCPReaderOneClient.java b/src/explorviz/live_trace_processing/reader/TCPReaderOneClient.java
index 734ad7d..f94a158 100644
--- a/src/explorviz/live_trace_processing/reader/TCPReaderOneClient.java
+++ b/src/explorviz/live_trace_processing/reader/TCPReaderOneClient.java
@@ -21,6 +21,7 @@ import explorviz.live_trace_processing.record.event.constructor.BeforeConstructo
 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.event.remote.RemoteCallBridgeRecord;
 import explorviz.live_trace_processing.record.event.statics.AfterFailedStaticOperationEventRecord;
 import explorviz.live_trace_processing.record.event.statics.AfterStaticOperationEventRecord;
 import explorviz.live_trace_processing.record.event.statics.BeforeStaticOperationEventRecord;
@@ -219,6 +220,15 @@ public class TCPReaderOneClient extends Thread implements IPeriodicTimeSignalRec
 					buffer.compact();
 					return;
 				}
+				case RemoteCallBridgeRecord.CLAZZ_ID: {
+					if (buffer.remaining() >= RemoteCallBridgeRecord.COMPRESSED_BYTE_LENGTH) {
+						readInRemoteCallBridgeEvent(buffer);
+						break;
+					}
+					buffer.position(buffer.position() - 1);
+					buffer.compact();
+					return;
+				}
 				case BeforeStaticOperationEventRecord.CLAZZ_ID: {
 					if (buffer.remaining() >= BeforeStaticOperationEventRecord.COMPRESSED_BYTE_LENGTH) {
 						readInBeforeStaticOperationEvent(buffer);
@@ -348,10 +358,8 @@ public class TCPReaderOneClient extends Thread implements IPeriodicTimeSignalRec
 		final int causeId = buffer.getInt();
 
 		try {
-			final String cause = stringRegistry.getStringFromId(causeId);
-
 			putInRingBuffer(new AfterFailedConstructorEventRecord(timestamp, traceId, orderIndex,
-					cause, hostApplicationMetadata));
+					stringRegistry.getStringFromId(causeId), hostApplicationMetadata));
 		} catch (final IdNotAvailableException e) {
 			putInWaitingMessages(buffer,
 					AfterFailedConstructorEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID);
@@ -367,6 +375,27 @@ public class TCPReaderOneClient extends Thread implements IPeriodicTimeSignalRec
 				hostApplicationMetadata));
 	}
 
+	private final void readInRemoteCallBridgeEvent(final ByteBuffer buffer) {
+		final int callerHost = buffer.getInt();
+		final int callerApplication = buffer.getInt();
+		final long callerTraceId = buffer.getLong();
+		final int callerOrderIndex = buffer.getInt();
+
+		final long timestamp = buffer.getLong();
+		final long traceId = buffer.getLong();
+		final int orderIndex = buffer.getInt();
+
+		try {
+			putInRingBuffer(new RemoteCallBridgeRecord(timestamp,
+					stringRegistry.getStringFromId(callerHost),
+					stringRegistry.getStringFromId(callerApplication), callerTraceId,
+					callerOrderIndex, traceId, orderIndex, hostApplicationMetadata));
+		} catch (final IdNotAvailableException e) {
+			putInWaitingMessages(buffer,
+					RemoteCallBridgeRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID);
+		}
+	}
+
 	private final void readInBeforeStaticOperationEvent(final ByteBuffer buffer) {
 		final long timestamp = buffer.getLong();
 		final long traceId = buffer.getLong();
@@ -449,6 +478,9 @@ public class TCPReaderOneClient extends Thread implements IPeriodicTimeSignalRec
 				case AfterConstructorEventRecord.CLAZZ_ID:
 					readInAfterConstructorEvent(buffer);
 					break;
+				case RemoteCallBridgeRecord.CLAZZ_ID:
+					readInRemoteCallBridgeEvent(buffer);
+					break;
 				case BeforeStaticOperationEventRecord.CLAZZ_ID:
 					readInBeforeStaticOperationEvent(buffer);
 					break;
-- 
GitLab