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 93696964dd..782fdd5f56 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 @@ -443,6 +443,14 @@ public interface ActiveMQServerLogger extends BasicLogger { @Message(id = 221082, value = "Initializing metrics plugin {0} with properties: {1}", format = Message.Format.MESSAGE_FORMAT) void initializingMetricsPlugin(String clazz, String properties); + @LogMessage(level = Logger.Level.INFO) + @Message(id = 221083, value = "ignoring quorum vote as max cluster size is {0}.", format = Message.Format.MESSAGE_FORMAT) + void ignoringQuorumVote(int maxClusterSize); + + @LogMessage(level = Logger.Level.INFO) + @Message(id = 221084, value = "Requested {0} quorum votes", format = Message.Format.MESSAGE_FORMAT) + void requestedQuorumVotes(int vote); + @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) 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 7fc5a525b2..11be907282 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 @@ -189,7 +189,7 @@ public final class QuorumManager implements ClusterTopologyListener, ActiveMQCom int voteTimeout, TimeUnit voteTimeoutUnit) { Objects.requireNonNull(nodeID, "nodeID"); - Objects.requireNonNull(nodeID, "liveConnector"); + Objects.requireNonNull(liveConnector, "liveConnector"); if (!started) { throw new IllegalStateException("QuorumManager must start first"); } @@ -199,15 +199,18 @@ public final class QuorumManager implements ClusterTopologyListener, ActiveMQCom } private boolean awaitVoteComplete(QuorumVoteServerConnect quorumVote, int voteTimeout, TimeUnit voteTimeoutUnit) { + final int maxClusterSize = this.maxClusterSize; vote(quorumVote); - - try { - quorumVote.await(voteTimeout, voteTimeoutUnit); - } catch (InterruptedException interruption) { - // No-op. The best the quorum can do now is to return the latest number it has - ActiveMQServerLogger.LOGGER.quorumVoteAwaitInterrupted(); + if (maxClusterSize > 1) { + try { + quorumVote.await(voteTimeout, voteTimeoutUnit); + } catch (InterruptedException interruption) { + // No-op. The best the quorum can do now is to return the latest number it has + ActiveMQServerLogger.LOGGER.quorumVoteAwaitInterrupted(); + } + } else { + ActiveMQServerLogger.LOGGER.ignoringQuorumVote(maxClusterSize); } - voteComplete(quorumVote); return quorumVote.getDecision(); @@ -246,8 +249,10 @@ public final class QuorumManager implements ClusterTopologyListener, ActiveMQCom runnables.add(voteRunnable); } } - if (runnables.size() > 0) { - voteRunnables.put(quorumVote, new VoteRunnableHolder(quorumVote, runnables, runnables.size())); + final int votes = runnables.size(); + ActiveMQServerLogger.LOGGER.requestedQuorumVotes(votes); + if (votes > 0) { + voteRunnables.put(quorumVote, new VoteRunnableHolder(quorumVote, runnables, votes)); for (VoteRunnable runnable : runnables) { executor.submit(runnable);