Skip to content
Snippets Groups Projects
Commit fe022edc authored by Lars Erik Blümke's avatar Lars Erik Blümke
Browse files

AMQP reader test still unfinished

parent 86d47cde
No related branches found
No related tags found
No related merge requests found
...@@ -162,16 +162,20 @@ public final class AMQPReaderLogicModule { ...@@ -162,16 +162,20 @@ public final class AMQPReaderLogicModule {
final ByteBuffer buffer = ByteBuffer.wrap(body); final ByteBuffer buffer = ByteBuffer.wrap(body);
final byte recordType = buffer.get(); final byte recordType = buffer.get();
System.out.println("RecordType" + recordType);
// Dispatch to the appropriate handlers // Dispatch to the appropriate handlers
switch (recordType) { switch (recordType) {
case REGISTRY_RECORD_ID: case REGISTRY_RECORD_ID:
System.out.println("Registry Record detected");
this.registryRecordHandler.enqueueRegistryRecord(buffer); this.registryRecordHandler.enqueueRegistryRecord(buffer);
break; break;
case REGULAR_RECORD_ID: case REGULAR_RECORD_ID:
System.out.println("Regualar Record detected");
this.regularRecordHandler.enqueueRegularRecord(buffer); this.regularRecordHandler.enqueueRegularRecord(buffer);
break; break;
default: default:
System.out.println("Unknown Record detected");
this.log.error(String.format("Unknown record type: %02x", recordType)); this.log.error(String.format("Unknown record type: %02x", recordType));
break; break;
} }
......
...@@ -6,6 +6,7 @@ import java.io.ByteArrayOutputStream; ...@@ -6,6 +6,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.nio.ByteBuffer;
import java.security.KeyManagementException; import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.LinkedList; import java.util.LinkedList;
...@@ -22,12 +23,16 @@ import com.rabbitmq.client.ConnectionFactory; ...@@ -22,12 +23,16 @@ import com.rabbitmq.client.ConnectionFactory;
import kieker.common.logging.Log; import kieker.common.logging.Log;
import kieker.common.logging.LogFactory; import kieker.common.logging.LogFactory;
import kieker.common.record.IMonitoringRecord; import kieker.common.record.IMonitoringRecord;
import kieker.common.record.misc.RegistryRecord;
import kieker.common.record.system.CPUUtilizationRecord; import kieker.common.record.system.CPUUtilizationRecord;
import kieker.common.util.registry.ILookup;
import kieker.common.util.registry.Lookup;
public class AMQPReaderTest { public class AMQPReaderTest {
private AMQPReader amqpReader; private AMQPReader amqpReader;
private CPUUtilizationRecord record; private CPUUtilizationRecord record;
private RegistryRecord registryRecord;
// AMQPReader constructor arguments // AMQPReader constructor arguments
private final String uri = "amqp://guest:guest@localhost"; // See the amqp uri scheme documentation for detailed information about uri structure private final String uri = "amqp://guest:guest@localhost"; // See the amqp uri scheme documentation for detailed information about uri structure
...@@ -56,6 +61,7 @@ public class AMQPReaderTest { ...@@ -56,6 +61,7 @@ public class AMQPReaderTest {
public void initializeAMQPReader() { public void initializeAMQPReader() {
amqpReader = new AMQPReader(uri, queueName, heartbeat, log); amqpReader = new AMQPReader(uri, queueName, heartbeat, log);
record = new CPUUtilizationRecord(timestamp, hostname, cpuID, user, system, wait, nice, irq, totalUtilisation, idle); record = new CPUUtilizationRecord(timestamp, hostname, cpuID, user, system, wait, nice, irq, totalUtilisation, idle);
registryRecord = new RegistryRecord(0xFFFFFFFF, "holla");
} }
@Test @Test
...@@ -67,8 +73,12 @@ public class AMQPReaderTest { ...@@ -67,8 +73,12 @@ public class AMQPReaderTest {
channel = connection.createChannel(); channel = connection.createChannel();
channel.queueDeclare(queueName, false, false, false, null); channel.queueDeclare(queueName, false, false, false, null);
ILookup<String> stringRegistry = new Lookup<String>();
// Sending the test record as a byte array // Sending the test record as a byte array
channel.basicPublish("", queueName, null, serialize(record)); ByteBuffer buffer = ByteBuffer.allocate(1000);
registryRecord.writeBytes(buffer, stringRegistry);
System.out.println("RecordType before sending " + buffer.get() + buffer.get() + buffer.get());
// channel.basicPublish("", queueName, null, buffer);
System.out.println("Sent record"); System.out.println("Sent record");
channel.close(); channel.close();
......
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