Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add trace logs for I/O messages

  • Loading branch information...
commit d33d26e4085893ff39809d4fae2e5bb97e7ea168 1 parent e390f07
@dgomezferro authored
View
2  src/main/java/com/yahoo/pasc/paxos/server/ServerConnection.java
@@ -31,4 +31,6 @@
public void run() throws IOException;
public void close() throws IOException;
+
+ public int getId();
}
View
52 src/main/java/com/yahoo/pasc/paxos/server/ServerHandler.java
@@ -18,7 +18,6 @@
import java.nio.channels.ClosedChannelException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
@@ -35,7 +34,6 @@
import com.yahoo.pasc.Message;
import com.yahoo.pasc.PascRuntime;
import com.yahoo.pasc.paxos.messages.Accept;
-import com.yahoo.pasc.paxos.messages.Bye;
import com.yahoo.pasc.paxos.messages.ControlMessage;
import com.yahoo.pasc.paxos.messages.DigestToSM;
import com.yahoo.pasc.paxos.messages.Execute;
@@ -44,7 +42,6 @@
import com.yahoo.pasc.paxos.messages.MessageType;
import com.yahoo.pasc.paxos.messages.PaxosMessage;
import com.yahoo.pasc.paxos.messages.PreReply;
-import com.yahoo.pasc.paxos.messages.ServerHello;
import com.yahoo.pasc.paxos.state.PaxosState;
import com.yahoo.pasc.paxos.statemachine.ControlHandler;
import com.yahoo.pasc.paxos.statemachine.Response;
@@ -87,7 +84,7 @@ public synchronized void channelConnected(ChannelHandlerContext ctx, ChannelStat
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
PaxosMessage message = (PaxosMessage) e.getMessage();
if (LOG.isTraceEnabled()) {
- LOG.trace("Message received {}", message);
+ LOG.trace("[{}] Message received {}", serverConnection.getId(), message);
}
if (message instanceof ControlMessage) {
if (controlHandler != null) {
@@ -120,7 +117,7 @@ public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Ex
return;
List<Message> toForward = new ArrayList<Message>();
if (LOG.isTraceEnabled()) {
- LOG.trace("Output messages {}", responses);
+ LOG.trace("[{}] Output messages {}", serverConnection.getId(), responses);
}
for (Message m : responses) {
if (m instanceof Execute) {
@@ -149,6 +146,9 @@ public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Ex
toForward.add(m);
}
}
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("[{}] Forwarding messages {}", serverConnection.getId(), toForward);
+ }
serverConnection.forward(toForward);
} finally {
hits[type.ordinal()]++;
@@ -175,25 +175,25 @@ public void releaseLeadership() {
leadershipQueue.add(new LeadershipChange(false));
}
- private class ThroughputMonitor implements Runnable {
- @Override
- public void run() {
- MessageType values [] = MessageType.values();
- while (true) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- return;
- }
- System.out.format("Memory usage: %d bytes\n", Runtime.getRuntime().totalMemory()
- - Runtime.getRuntime().freeMemory());
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < values.length; ++i) {
- sb.append(values[i].name()).append('\t').append(time[i] / (double) hits[i]).append('\t');
- }
- System.out.println(sb);
- System.out.println("MSGS/BATCH " + (requests / (double)accepts));
- }
- }
- }
+// private class ThroughputMonitor implements Runnable {
+// @Override
+// public void run() {
+// MessageType values [] = MessageType.values();
+// while (true) {
+// try {
+// Thread.sleep(1000);
+// } catch (InterruptedException e) {
+// return;
+// }
+// System.out.format("Memory usage: %d bytes\n", Runtime.getRuntime().totalMemory()
+// - Runtime.getRuntime().freeMemory());
+// StringBuilder sb = new StringBuilder();
+// for (int i = 0; i < values.length; ++i) {
+// sb.append(values[i].name()).append('\t').append(time[i] / (double) hits[i]).append('\t');
+// }
+// System.out.println(sb);
+// System.out.println("MSGS/BATCH " + (requests / (double)accepts));
+// }
+// }
+// }
}
View
6 src/main/java/com/yahoo/pasc/paxos/server/tcp/TcpServer.java
@@ -53,7 +53,6 @@
import com.yahoo.pasc.paxos.Barrier;
import com.yahoo.pasc.paxos.messages.AsyncMessage;
import com.yahoo.pasc.paxos.messages.Bye;
-import com.yahoo.pasc.paxos.messages.Hello;
import com.yahoo.pasc.paxos.messages.Prepared;
import com.yahoo.pasc.paxos.messages.Reply;
import com.yahoo.pasc.paxos.messages.ServerHello;
@@ -294,4 +293,9 @@ public void close() throws IOException {
serverChannels.close();
indexedServerChannels.clear();
}
+
+ @Override
+ public int getId() {
+ return id;
+ }
}
View
5 src/main/java/com/yahoo/pasc/paxos/server/udp/UdpServer.java
@@ -150,4 +150,9 @@ private void setupConnections() throws IOException {
public void close() throws IOException {
// TODO Auto-generated method stub
}
+ @Override
+ public int getId() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.