Commit e54d394f authored by Florian Fittkau's avatar Florian Fittkau

WiP tcpconnector...

parent 83f07347
......@@ -19,19 +19,20 @@ import explorviz.live_trace_processing.record.ISerializableRecord;
import explorviz.live_trace_processing.record.misc.StringRegistryRecord;
import explorviz.live_trace_processing.record.misc.TerminateRecord;
import explorviz.live_trace_processing.record.misc.TimedPeriodRecord;
import explorviz.live_trace_processing.record.trace.Trace;
import explorviz.live_trace_processing.writer.IRecordSender;
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;
private final StringRegistry stringRegistry = new StringRegistry(this);
private final ByteBuffer buffer = ByteBuffer.allocate(Constants.SENDING_BUFFER_SIZE);
private final ByteBuffer buffer = ByteBuffer.allocateDirect(Constants.SENDING_BUFFER_SIZE);
private volatile boolean shouldDisconnect = false;
......@@ -83,8 +84,8 @@ public class TCPConnector extends AbstractSink implements IWriter, IStringRecord
@Override
protected void processRecord(final IRecord record) {
System.out.println(record);
if (record instanceof ISerializableRecord) {
if (record instanceof Trace) {
System.out.println(record);
final ISerializableRecord serializableRecord = (ISerializableRecord) record;
if (buffer.remaining() < serializableRecord.getRecordSizeInBytes()) {
send(buffer);
......@@ -93,9 +94,7 @@ public class TCPConnector extends AbstractSink implements IWriter, IStringRecord
}
serializableRecord.putIntoByteBuffer(buffer, stringRegistry, this);
} else if (record instanceof TimedPeriodRecord) {
if (buffer.hasRemaining()) {
send(buffer);
}
send(buffer);
} else if (record instanceof TerminateRecord) {
terminate();
}
......
......@@ -69,7 +69,7 @@ class TCPReaderOneClient extends Thread {
@Override
public void run() {
final ByteBuffer buffer = ByteBuffer.allocateDirect(8 * 1024 * 1024);
final ByteBuffer buffer = ByteBuffer.allocateDirect(16 * 1024 * 1024);
try {
String remoteAddress = "";
if (socketChannel.isConnected()) {
......
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