From d5baa4d6670478275360ef5d5e4bd57b0e995ee6 Mon Sep 17 00:00:00 2001
From: Christian Wulf <chw@informatik.uni-kiel.de>
Date: Sun, 17 Aug 2014 09:47:54 +0200
Subject: [PATCH] added different trace ids for the load balancer

---
 .../examples/kiekerdays/KiekerLoadDriver.java    | 16 +++++++++++++++-
 submodules/JCTools                               |  2 +-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/test/java/teetime/variant/methodcallWithPorts/examples/kiekerdays/KiekerLoadDriver.java b/src/test/java/teetime/variant/methodcallWithPorts/examples/kiekerdays/KiekerLoadDriver.java
index 5fffebe5..cc16735d 100644
--- a/src/test/java/teetime/variant/methodcallWithPorts/examples/kiekerdays/KiekerLoadDriver.java
+++ b/src/test/java/teetime/variant/methodcallWithPorts/examples/kiekerdays/KiekerLoadDriver.java
@@ -22,6 +22,8 @@ import teetime.variant.methodcallWithPorts.stage.kieker.Dir2RecordsFilter;
 import teetime.variant.methodcallWithPorts.stage.kieker.className.ClassNameRegistryRepository;
 
 import kieker.common.record.IMonitoringRecord;
+import kieker.common.record.flow.trace.TraceMetadata;
+import kieker.common.record.flow.trace.operation.AbstractOperationEvent;
 import kieker.common.util.registry.IMonitoringRecordReceiver;
 import kieker.common.util.registry.Registry;
 
@@ -126,6 +128,7 @@ public class KiekerLoadDriver {
 
 		final Registry<String> stringRegistry = new Registry<String>();
 		ByteBuffer recordBuffer = ByteBuffer.allocateDirect(Short.MAX_VALUE);
+		ByteBuffer duplicateBuffer = recordBuffer.duplicate();
 
 		RecordReceiver recordReceiver = new RecordReceiver(stringRegistry);
 		stringRegistry.setRecordReceiver(recordReceiver);
@@ -135,17 +138,26 @@ public class KiekerLoadDriver {
 			String hostname = "localhost";
 			int port = 10133;
 			System.out.println("Connecting to " + hostname + ":" + port);
+			long traceId = 0;
 
 			SocketChannel socketChannel = SocketChannel.open();
 			try {
 				socketChannel.connect(new InetSocketAddress(hostname, port));
 				for (int i = 0; i < runs; i++) {
 					for (IMonitoringRecord record : records) {
-						// TODO increase trace id
 						int clazzId = stringRegistry.get(record.getClass().getName());
 						recordBuffer.putInt(clazzId);
 						recordBuffer.putLong(record.getLoggingTimestamp());
+						duplicateBuffer.position(recordBuffer.position());
+						// AbstractOperationEvent writes (Long, Long traceId, ...)
 						record.writeBytes(recordBuffer, stringRegistry);
+
+						if (record instanceof AbstractOperationEvent) {
+							duplicateBuffer.getLong();
+							duplicateBuffer.putLong(traceId);
+						} else if (record instanceof TraceMetadata) {
+							duplicateBuffer.putLong(traceId);
+						}
 					}
 					recordBuffer.flip();
 					// System.out.println("position: " + recordBuffer.position());
@@ -159,6 +171,8 @@ public class KiekerLoadDriver {
 					}
 					// System.out.println("writtenBytes (record): " + writtenBytes);
 					recordBuffer.clear();
+					duplicateBuffer.clear();
+					traceId++;
 				}
 			} finally {
 				socketChannel.close();
diff --git a/submodules/JCTools b/submodules/JCTools
index 75998aa2..88e1e25f 160000
--- a/submodules/JCTools
+++ b/submodules/JCTools
@@ -1 +1 @@
-Subproject commit 75998aa20b7ec897ec321c1f94192de888f2dc6e
+Subproject commit 88e1e25f9519b250258c7e5ada30935975ab2d10
-- 
GitLab