From 385b309206ddbdc26b51dc183c1a912154009c35 Mon Sep 17 00:00:00 2001 From: taivop Date: Sun, 18 Dec 2016 15:40:34 +0100 Subject: [PATCH] also log primary machine of each request and go back to 1/10 sampling --- resources/log4j2.properties | 2 +- scripts/test_local.sh | 2 +- src/main/java/asl/LoadBalancer.java | 1 + src/main/java/asl/Request.java | 7 ++++--- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/resources/log4j2.properties b/resources/log4j2.properties index 0e53748..b28d102 100644 --- a/resources/log4j2.properties +++ b/resources/log4j2.properties @@ -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 diff --git a/scripts/test_local.sh b/scripts/test_local.sh index 01e940d..b22b648 100644 --- a/scripts/test_local.sh +++ b/scripts/test_local.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -NUM_CLIENTS=180 +NUM_CLIENTS=10 LOG_DIR=tmp/local mkdir -p $LOG_DIR diff --git a/src/main/java/asl/LoadBalancer.java b/src/main/java/asl/LoadBalancer.java index ce1db4a..b63ade0 100644 --- a/src/main/java/asl/LoadBalancer.java +++ b/src/main/java/asl/LoadBalancer.java @@ -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)); diff --git a/src/main/java/asl/Request.java b/src/main/java/asl/Request.java index 1c1011f..77b4476 100644 --- a/src/main/java/asl/Request.java +++ b/src/main/java/asl/Request.java @@ -18,7 +18,7 @@ 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; @@ -26,6 +26,7 @@ public class Request { private String key; private String stringRepresentation; private SelectionKey selectionKey; + public Integer primaryMachine = -1; private long timeCreated; private long timeEnqueued; @@ -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)); } }