[NO ISSUE][OTH] Introduce Whispered Messages
- user model changes: no
- storage format changes: no
- interface changes: yes
Details:
- Add whispered flag to IMessage API.
- Log whispered messages as trace rather than info level
to avoid filling the info log with high frequency messages.
Change-Id: I5c24205f5c25bf9f6aa245e8f1200b046390a915
Reviewed-on: https://asterix-gerrit.ics.uci.edu/3220
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
diff --git a/asterixdb/asterix-active/src/main/java/org/apache/asterix/active/message/ActiveStatsResponse.java b/asterixdb/asterix-active/src/main/java/org/apache/asterix/active/message/ActiveStatsResponse.java
index 8738a06..63f68a7 100644
--- a/asterixdb/asterix-active/src/main/java/org/apache/asterix/active/message/ActiveStatsResponse.java
+++ b/asterixdb/asterix-active/src/main/java/org/apache/asterix/active/message/ActiveStatsResponse.java
@@ -74,4 +74,8 @@
broker.respond(reqId, this);
}
+ @Override
+ public boolean isWhispered() {
+ return true;
+ }
}
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/messaging/CCMessageBroker.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/messaging/CCMessageBroker.java
index 5f42d7a..623a0be 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/messaging/CCMessageBroker.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/messaging/CCMessageBroker.java
@@ -40,6 +40,7 @@
import org.apache.hyracks.control.cc.ClusterControllerService;
import org.apache.hyracks.control.cc.NodeControllerState;
import org.apache.hyracks.control.cc.cluster.INodeManager;
+import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -59,9 +60,7 @@
@Override
public void receivedMessage(IMessage message, String nodeId) throws Exception {
ICcAddressedMessage msg = (ICcAddressedMessage) message;
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("Received message: " + msg);
- }
+ IMessage.logMessage(LOGGER, message);
ICcApplicationContext appCtx = (ICcApplicationContext) ccs.getApplicationContext();
msg.handle(appCtx);
}
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/messaging/NCMessageBroker.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/messaging/NCMessageBroker.java
index e4fe4f3..26f6524 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/messaging/NCMessageBroker.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/messaging/NCMessageBroker.java
@@ -92,9 +92,7 @@
@Override
public void receivedMessage(IMessage message, String nodeId) throws Exception {
INcAddressedMessage absMessage = (INcAddressedMessage) message;
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("Received message: " + absMessage);
- }
+ IMessage.logMessage(LOGGER, message);
ncs.getExecutor().submit(() -> {
try {
absMessage.handle(appContext);
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/messages/IMessage.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/messages/IMessage.java
index 2f5a873..94e08d7 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/messages/IMessage.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/messages/IMessage.java
@@ -20,6 +20,22 @@
import java.io.Serializable;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+
public interface IMessage extends Serializable {
+ /**
+ * @return true if the message is whispered, otherwise false.
+ */
+ default boolean isWhispered() {
+ return false;
+ }
+
+ static void logMessage(Logger logger, IMessage msg) {
+ final Level logLevel = msg.isWhispered() ? Level.TRACE : Level.INFO;
+ if (logger.isEnabled(logLevel)) {
+ logger.info("Received message: {}", msg);
+ }
+ }
}
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/messages/IMessageBroker.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/messages/IMessageBroker.java
index 8aaa563..2de734f 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/messages/IMessageBroker.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/messages/IMessageBroker.java
@@ -20,6 +20,5 @@
public interface IMessageBroker {
- public void receivedMessage(IMessage message, String nodeId) throws Exception;
-
+ void receivedMessage(IMessage message, String nodeId) throws Exception;
}