Skip to content
Snippets Groups Projects
Commit 5574fcae authored by phillu's avatar phillu
Browse files

added log statements

parent 89f424ec
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,9 @@ import java.nio.channels.ServerSocketChannel;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.RingBuffer;
import com.lmax.disruptor.dsl.Disruptor;
......@@ -17,6 +20,9 @@ import explorviz.live_trace_processing.filter.RecordArrayEventFactory;
import explorviz.live_trace_processing.filter.reconstruction.ITraceReconstruction;
public final class TCPReader {
private static final Logger LOG = LoggerFactory.getLogger(TCPReader.class);
private final int listeningPort;
private boolean active = true;
......@@ -50,12 +56,12 @@ public final class TCPReader {
threads.add(thread);
}
} catch (final IOException ex) {
System.out.println("Error in read() " + ex.getMessage());
LOG.info("Error in read() " + ex.getMessage());
} finally {
try {
serversocket.close();
} catch (final IOException e) {
System.out.println("Error in read()" + e.getMessage());
LOG.info("Error in read()" + e.getMessage());
}
}
}
......@@ -63,11 +69,11 @@ public final class TCPReader {
private final void open() throws IOException {
serversocket = ServerSocketChannel.open();
serversocket.socket().bind(new InetSocketAddress(listeningPort));
System.out.println("listening on port " + listeningPort);
LOG.info("Listening on port " + listeningPort);
}
public final void terminate(final boolean error) {
System.out.println("Shutdown of TCPReader requested.");
LOG.info("Shutdown of TCPReader requested.");
active = false;
// for (final TCPReaderOneClient thread : threads) {
// thread.terminate();
......
......@@ -7,6 +7,9 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.lmax.disruptor.RingBuffer;
import explorviz.live_trace_processing.Constants;
......@@ -34,6 +37,9 @@ import explorviz.live_trace_processing.record.trace.HostApplicationMetaDataRecor
import explorviz.live_trace_processing.record.trace.Trace;
public class TCPReaderOneClient extends Thread implements IPeriodicTimeSignalReceiver {
private static final Logger LOG = LoggerFactory.getLogger(TCPReaderOneClient.class);
private HostApplicationMetaDataRecord hostApplicationMetadata;
private final StringRegistry stringRegistry = new StringRegistry(null);
......@@ -58,12 +64,15 @@ public class TCPReaderOneClient extends Thread implements IPeriodicTimeSignalRec
public void run() {
final ByteBuffer buffer = ByteBuffer.allocateDirect(2 * 1024 * 1024);
try {
if(socketChannel.isConnected()) {
LOG.info("Client " + socketChannel.getRemoteAddress() + " connected.");
}
while ((socketChannel.read(buffer)) != -1) {
buffer.flip();
messagesfromByteArray(buffer);
}
} catch (final IOException ex) {
System.out.println("Error in read() " + ex.getMessage());
LOG.info("Error in read() " + ex.getMessage());
// TODO cancel timer???
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment