Commit db122355 authored by Florian Fittkau's avatar Florian Fittkau

fixed string record not coming in tcpconnector

parent 939a8f8b
......@@ -23,7 +23,7 @@ import explorviz.live_trace_processing.writer.IStringRecordSender;
import explorviz.live_trace_processing.writer.IWriter;
public class TCPConnector extends AbstractSink implements IWriter, IStringRecordSender,
IRecordSender {
IRecordSender {
private URL providerURL;
private SocketChannel socketChannel;
......@@ -94,7 +94,8 @@ IRecordSender {
}
serializableRecord.putIntoByteBuffer(buffer, stringRegistry, this);
} else if (record instanceof TimedPeriodRecord) {
send(buffer);
// send(buffer);
// this the end of timedperiodrecords - master has own
} else if (record instanceof TerminateRecord) {
terminate();
}
......
......@@ -355,31 +355,64 @@ class TCPReaderOneClient extends Thread {
}
private boolean readInTraceRecordChunks(final ByteBuffer buffer) {
if (buffer.remaining() >= (4 + 4)) {
int recordAmountNowComming = buffer.getInt();
final int bytesComming = buffer.getInt();
if (buffer.remaining() >= 1) {
final byte clazzId = buffer.get();
if (buffer.remaining() >= bytesComming) {
while (recordAmountNowComming > 0) {
try {
currentlyOpenTrace.getTraceEvents().add(
AbstractEventRecord.createFromByteBuffer(buffer, stringRegistry));
} catch (final IdNotAvailableException e) {
// should not happen
e.printStackTrace();
if (clazzId == (byte) 0) {
if (buffer.remaining() >= (4 + 4)) {
int recordAmountNowComming = buffer.getInt();
final int bytesComming = buffer.getInt();
if (buffer.remaining() >= bytesComming) {
while (recordAmountNowComming > 0) {
try {
currentlyOpenTrace.getTraceEvents().add(
AbstractEventRecord.createFromByteBuffer(buffer,
stringRegistry));
} catch (final IdNotAvailableException e) {
// should not happen
e.printStackTrace();
}
recordAmountNowComming--;
}
if (currentlyOpenTrace.getTraceEvents().size() == currentlyOpenTrace
.getEventsLength()) {
putInQueue(currentlyOpenTrace);
currentlyOpenTrace = null;
return true;
}
} else {
buffer.position(buffer.position() - 4 - 4 - 1);
buffer.compact();
return false;
}
recordAmountNowComming--;
}
} else if (clazzId == StringRegistryRecord.CLAZZ_ID) {
int mapId = 0;
int stringLength = 0;
if (buffer.remaining() >= 8) {
mapId = buffer.getInt();
stringLength = buffer.getInt();
} else {
buffer.position(buffer.position() - 1);
buffer.compact();
return false;
}
if (buffer.remaining() >= stringLength) {
final byte[] stringByteArray = new byte[stringLength];
buffer.get(stringByteArray);
stringRegistry.putStringRecord(mapId, new String(stringByteArray));
if (currentlyOpenTrace.getTraceEvents().size() == currentlyOpenTrace
.getEventsLength()) {
putInQueue(currentlyOpenTrace);
currentlyOpenTrace = null;
return true;
checkWaitingMessages();
} else {
buffer.position(buffer.position() - 9);
buffer.compact();
return false;
}
} else {
buffer.position(buffer.position() - 4 - 4);
buffer.compact();
}
} else {
buffer.compact();
......
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