Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
also log primary machine of each request and go back to 1/10 sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
taivop committed Dec 18, 2016
1 parent f9f5e18 commit 385b309
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion resources/log4j2.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ appender.REQUEST_CSV.name = REQUEST_CSV
appender.REQUEST_CSV.fileName = log/request.log
appender.REQUEST_CSV.layout.type = PatternLayout
appender.REQUEST_CSV.layout.pattern = %m%n
appender.REQUEST_CSV.layout.header = type,flag,timeCreated,timeEnqueued,timeDequeued,timeForwarded,timeReceived,timeReturned%n
appender.REQUEST_CSV.layout.header = type,flag,primaryMachine,timeCreated,timeEnqueued,timeDequeued,timeForwarded,timeReceived,timeReturned%n

# Loggers

Expand Down
2 changes: 1 addition & 1 deletion scripts/test_local.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

NUM_CLIENTS=180
NUM_CLIENTS=10

LOG_DIR=tmp/local
mkdir -p $LOG_DIR
Expand Down
1 change: 1 addition & 0 deletions src/main/java/asl/LoadBalancer.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ private void handleRequest(Request request, SelectionKey selectionKey) {

Integer primaryMachine = hasher.getPrimaryMachine(request.getKey());
MiddlewareComponent mc = middlewareComponents.get(primaryMachine);
request.primaryMachine = primaryMachine;

ByteBuffer buffer = request.getBuffer();
buffer.limit(numBytesRead.get(selectionKey));
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/asl/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ public class Request {
private static final Logger log = LogManager.getLogger(Request.class);
private static final Logger csvLog = LogManager.getLogger("request_csv");

public static final int LOG_SAMPLING_FREQUENCY = 1;
public static final int LOG_SAMPLING_FREQUENCY = 10;

private RequestType type;
private ByteBuffer buffer;
private ByteBuffer responseBuffer;
private String key;
private String stringRepresentation;
private SelectionKey selectionKey;
public Integer primaryMachine = -1;

private long timeCreated;
private long timeEnqueued;
Expand Down Expand Up @@ -280,8 +281,8 @@ public static ResponseFlag getResponseFlag(ByteBuffer buffer) {
*/
public void logTimestamps() {
if(shouldLog) {
csvLog.info(String.format("%s,%s,%d,%d,%d,%d,%d,%d",
type, responseFlag, timeCreated, timeEnqueued, timeDequeued, timeForwarded, timeReceived, timeReturned));
csvLog.info(String.format("%s,%s,%d,%d,%d,%d,%d,%d,%d",
type, responseFlag, primaryMachine, timeCreated, timeEnqueued, timeDequeued, timeForwarded, timeReceived, timeReturned));
}
}

Expand Down

0 comments on commit 385b309

Please sign in to comment.