activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andytay...@apache.org
Subject [1/2] activemq-artemis git commit: ARTEMIS-1302 make quorum voting more transparent
Date Mon, 24 Jul 2017 09:17:08 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master f138bc528 -> f74976488


ARTEMIS-1302 make quorum voting more transparent


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/59841b88
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/59841b88
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/59841b88

Branch: refs/heads/master
Commit: 59841b887220a64a2273a98e0fc23078564b1314
Parents: f138bc5
Author: Justin Bertram <jbertram@apache.org>
Authored: Fri Jul 21 19:38:33 2017 -0500
Committer: Justin Bertram <jbertram@apache.org>
Committed: Fri Jul 21 19:39:06 2017 -0500

----------------------------------------------------------------------
 .../core/impl/wireformat/QuorumVoteMessage.java | 16 +++++++
 .../core/server/ActiveMQServerLogger.java       | 48 ++++++++++++++++++++
 .../core/server/cluster/ClusterControl.java     |  5 +-
 .../core/server/cluster/ClusterController.java  |  2 +
 .../core/server/cluster/qourum/BooleanVote.java |  6 ++-
 .../server/cluster/qourum/QuorumManager.java    |  2 +
 .../cluster/qourum/QuorumVoteServerConnect.java | 11 +++--
 .../cluster/qourum/ServerConnectVote.java       |  5 ++
 .../qourum/SharedNothingBackupQuorum.java       |  2 +
 .../core/server/impl/ColocatedActivation.java   |  5 ++
 .../server/impl/ServerConnectVoteHandler.java   |  3 ++
 11 files changed, 100 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/59841b88/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/QuorumVoteMessage.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/QuorumVoteMessage.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/QuorumVoteMessage.java
index 5c030ae..2f4e024 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/QuorumVoteMessage.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/wireformat/QuorumVoteMessage.java
@@ -67,4 +67,20 @@ public class QuorumVoteMessage extends PacketImpl {
    public void decode(QuorumVoteHandler voteHandler) {
       vote = voteHandler.decode(voteBuffer);
    }
+
+
+   @Override
+   public String toString() {
+      StringBuffer buff = new StringBuffer(getParentString());
+      buff.append("]");
+      return buff.toString();
+   }
+
+   @Override
+   public String getParentString() {
+      StringBuffer buff = new StringBuffer(super.getParentString());
+      buff.append(", vote=" + vote);
+      buff.append(", handler=" + handler);
+      return buff.toString();
+   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/59841b88/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
index 431302f..f930f02 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
@@ -346,6 +346,54 @@ public interface ActiveMQServerLogger extends BasicLogger {
    @Message(id = 221059, value = "Deleting old data directory {0} as the max folders is set
to 0", format = Message.Format.MESSAGE_FORMAT)
    void backupDeletingData(String oldPath);
 
+   @LogMessage(level = Logger.Level.INFO)
+   @Message(id = 221060, value = "Sending quorum vote request to {0}: {1}", format = Message.Format.MESSAGE_FORMAT)
+   void sendingQuorumVoteRequest(String remoteAddress, String vote);
+
+   @LogMessage(level = Logger.Level.INFO)
+   @Message(id = 221061, value = "Received quorum vote response from {0}: {1}", format =
Message.Format.MESSAGE_FORMAT)
+   void receivedQuorumVoteResponse(String remoteAddress, String vote);
+
+   @LogMessage(level = Logger.Level.INFO)
+   @Message(id = 221062, value = "Received quorum vote request: {0}", format = Message.Format.MESSAGE_FORMAT)
+   void receivedQuorumVoteRequest(String vote);
+
+   @LogMessage(level = Logger.Level.INFO)
+   @Message(id = 221063, value = "Sending quorum vote response: {0}", format = Message.Format.MESSAGE_FORMAT)
+   void sendingQuorumVoteResponse(String vote);
+
+   @LogMessage(level = Logger.Level.INFO)
+   @Message(id = 221064, value = "Node {0} found in cluster topology", format = Message.Format.MESSAGE_FORMAT)
+   void nodeFoundInClusterTopology(String nodeId);
+
+   @LogMessage(level = Logger.Level.INFO)
+   @Message(id = 221065, value = "Node {0} not found in cluster topology", format = Message.Format.MESSAGE_FORMAT)
+   void nodeNotFoundInClusterTopology(String nodeId);
+
+   @LogMessage(level = Logger.Level.INFO)
+   @Message(id = 221066, value = "Initiating quorum vote: {0}", format = Message.Format.MESSAGE_FORMAT)
+   void initiatingQuorumVote(SimpleString vote);
+
+   @LogMessage(level = Logger.Level.INFO)
+   @Message(id = 221067, value = "Waiting {0} {1} for quorum vote results.", format = Message.Format.MESSAGE_FORMAT)
+   void waitingForQuorumVoteResults(int timeout, String unit);
+
+   @LogMessage(level = Logger.Level.INFO)
+   @Message(id = 221068, value = "Received all quorum votes.", format = Message.Format.MESSAGE_FORMAT)
+   void receivedAllQuorumVotes();
+
+   @LogMessage(level = Logger.Level.INFO)
+   @Message(id = 221069, value = "Timeout waiting for quorum vote responses.", format = Message.Format.MESSAGE_FORMAT)
+   void timeoutWaitingForQuorumVoteResponses();
+
+   @LogMessage(level = Logger.Level.INFO)
+   @Message(id = 221070, value = "Restarting as backup based on quorum vote results.", format
= Message.Format.MESSAGE_FORMAT)
+   void restartingAsBackupBasedOnQuorumVoteResults();
+
+   @LogMessage(level = Logger.Level.INFO)
+   @Message(id = 221071, value = "Failing over based on quorum vote results.", format = Message.Format.MESSAGE_FORMAT)
+   void failingOverBasedOnQuorumVoteResults();
+
    @LogMessage(level = Logger.Level.WARN)
    @Message(id = 222000, value = "ActiveMQServer is being finalized and has not been stopped.
Please remember to stop the server before letting it go out of scope",
       format = Message.Format.MESSAGE_FORMAT)

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/59841b88/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterControl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterControl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterControl.java
index b37b9d5..07f0fc2 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterControl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterControl.java
@@ -159,10 +159,13 @@ public class ClusterControl implements AutoCloseable {
 
    public Vote sendQuorumVote(SimpleString handler, Vote vote) {
       try {
+         ActiveMQServerLogger.LOGGER.sendingQuorumVoteRequest(getSessionFactory().getConnection().getRemoteAddress(),
vote.toString());
          QuorumVoteReplyMessage replyMessage = (QuorumVoteReplyMessage) clusterChannel.sendBlocking(new
QuorumVoteMessage(handler, vote), PacketImpl.QUORUM_VOTE_REPLY);
          QuorumVoteHandler voteHandler = server.getClusterManager().getQuorumManager().getVoteHandler(replyMessage.getHandler());
          replyMessage.decodeRest(voteHandler);
-         return replyMessage.getVote();
+         Vote voteResponse = replyMessage.getVote();
+         ActiveMQServerLogger.LOGGER.receivedQuorumVoteResponse(getSessionFactory().getConnection().getRemoteAddress(),
voteResponse.toString());
+         return voteResponse;
       } catch (ActiveMQException e) {
          return null;
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/59841b88/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java
index b0d0232..464e945 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java
@@ -379,7 +379,9 @@ public class ClusterController implements ActiveMQComponent {
                QuorumVoteMessage quorumVoteMessage = (QuorumVoteMessage) packet;
                QuorumVoteHandler voteHandler = quorumManager.getVoteHandler(quorumVoteMessage.getHandler());
                quorumVoteMessage.decode(voteHandler);
+               ActiveMQServerLogger.LOGGER.receivedQuorumVoteRequest(quorumVoteMessage.getVote().toString());
                Vote vote = quorumManager.vote(quorumVoteMessage.getHandler(), quorumVoteMessage.getVote());
+               ActiveMQServerLogger.LOGGER.sendingQuorumVoteResponse(vote.toString());
                clusterChannel.send(new QuorumVoteReplyMessage(quorumVoteMessage.getHandler(),
vote));
             } else if (packet.getType() == PacketImpl.SCALEDOWN_ANNOUNCEMENT) {
                ScaleDownAnnounceMessage message = (ScaleDownAnnounceMessage) packet;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/59841b88/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/BooleanVote.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/BooleanVote.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/BooleanVote.java
index 5d61566..90f55ed 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/BooleanVote.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/BooleanVote.java
@@ -25,7 +25,7 @@ import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
  */
 public class BooleanVote extends Vote<Boolean> {
 
-   private boolean vote;
+   protected boolean vote;
 
    public BooleanVote(boolean vote) {
       this.vote = vote;
@@ -56,4 +56,8 @@ public class BooleanVote extends Vote<Boolean> {
       vote = buff.readBoolean();
    }
 
+   @Override
+   public String toString() {
+      return "BooleanVote [vote=" + vote + "]";
+   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/59841b88/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumManager.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumManager.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumManager.java
index dad772b..f8b3908 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumManager.java
@@ -29,6 +29,7 @@ import org.apache.activemq.artemis.api.core.client.ClusterTopologyListener;
 import org.apache.activemq.artemis.api.core.client.TopologyMember;
 import org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl;
 import org.apache.activemq.artemis.core.server.ActiveMQComponent;
+import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.cluster.ClusterControl;
 import org.apache.activemq.artemis.core.server.cluster.ClusterController;
 
@@ -181,6 +182,7 @@ public final class QuorumManager implements ClusterTopologyListener, ActiveMQCom
          if (!started)
             return;
          //send a vote to each node
+         ActiveMQServerLogger.LOGGER.initiatingQuorumVote(quorumVote.getName());
          for (TopologyMemberImpl tm : clusterController.getDefaultClusterTopology().getMembers())
{
             //but not ourselves
             if (!tm.getNodeId().equals(clusterController.getNodeID().toString())) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/59841b88/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java
index a189155..f6c608e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java
@@ -21,13 +21,14 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.client.impl.Topology;
+import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 
 /**
- * A Qourum Vote for deciding if a replicated backup should become live.
+ * A Quorum Vote for deciding if a replicated backup should become live.
  */
 public class QuorumVoteServerConnect extends QuorumVote<ServerConnectVote, Boolean>
{
 
-   public static final SimpleString LIVE_FAILOVER_VOTE = new SimpleString("LIVE_FAILOVER_VOTE");
+   public static final SimpleString LIVE_FAILOVER_VOTE = new SimpleString("LiveFailoverQuorumVote");
    private final CountDownLatch latch;
    private final String targetNodeId;
 
@@ -123,6 +124,10 @@ public class QuorumVoteServerConnect extends QuorumVote<ServerConnectVote,
Boole
    }
 
    public void await(int latchTimeout, TimeUnit unit) throws InterruptedException {
-      latch.await(latchTimeout, unit);
+      ActiveMQServerLogger.LOGGER.waitingForQuorumVoteResults(latchTimeout, unit.toString().toLowerCase());
+      if (latch.await(latchTimeout, unit))
+         ActiveMQServerLogger.LOGGER.receivedAllQuorumVotes();
+      else
+         ActiveMQServerLogger.LOGGER.timeoutWaitingForQuorumVoteResponses();
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/59841b88/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/ServerConnectVote.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/ServerConnectVote.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/ServerConnectVote.java
index a6e472f..9f108e0 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/ServerConnectVote.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/ServerConnectVote.java
@@ -63,4 +63,9 @@ public class ServerConnectVote extends BooleanVote {
    public String getNodeId() {
       return nodeId;
    }
+
+   @Override
+   public String toString() {
+      return "ServerConnectVote [nodeId=" + nodeId + ", vote=" + vote + "]";
+   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/59841b88/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java
index d7bd27e..330b53a 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java
@@ -102,9 +102,11 @@ public class SharedNothingBackupQuorum implements Quorum, SessionFailureListener
          }
          if (!isLiveDown()) {
             //lost connection but don't know if live is down so restart as backup as we can't
replicate any more
+            ActiveMQServerLogger.LOGGER.restartingAsBackupBasedOnQuorumVoteResults();
             signal = BACKUP_ACTIVATION.FAILURE_REPLICATING;
          } else {
             // live is assumed to be down, backup fails-over
+            ActiveMQServerLogger.LOGGER.failingOverBasedOnQuorumVoteResults();
             signal = BACKUP_ACTIVATION.FAIL_OVER;
          }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/59841b88/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ColocatedActivation.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ColocatedActivation.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ColocatedActivation.java
index 73770e5..aa75775 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ColocatedActivation.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ColocatedActivation.java
@@ -278,5 +278,10 @@ public class ColocatedActivation extends LiveActivation {
       public Pair<String, Integer> getVote() {
          return new Pair<>(nodeID, backupsSize);
       }
+
+      @Override
+      public String toString() {
+         return "RequestBackupVote [backupsSize=" + backupsSize + ", nodeID=" + nodeID +
", backupAvailable=" + backupAvailable + "]";
+      }
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/59841b88/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConnectVoteHandler.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConnectVoteHandler.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConnectVoteHandler.java
index 8460357..ef0438a 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConnectVoteHandler.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConnectVoteHandler.java
@@ -19,6 +19,7 @@ package org.apache.activemq.artemis.core.server.impl;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl;
+import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.cluster.qourum.QuorumVoteHandler;
 import org.apache.activemq.artemis.core.server.cluster.qourum.QuorumVoteServerConnect;
 import org.apache.activemq.artemis.core.server.cluster.qourum.ServerConnectVote;
@@ -37,8 +38,10 @@ public class ServerConnectVoteHandler implements QuorumVoteHandler {
       String nodeid = serverConnectVote.getNodeId();
       TopologyMemberImpl member = server.getClusterManager().getDefaultConnection(null).getTopology().getMember(nodeid);
       if (member != null && member.getLive() != null) {
+         ActiveMQServerLogger.LOGGER.nodeFoundInClusterTopology(nodeid);
          return new ServerConnectVote(nodeid, false);
       }
+      ActiveMQServerLogger.LOGGER.nodeNotFoundInClusterTopology(nodeid);
       return new ServerConnectVote(nodeid, true);
    }
 


Mime
View raw message