Skip to content

Commit

Permalink
ARTEMIS-4384 Moving Cluster verify under verify group
Browse files Browse the repository at this point in the history
With this you would access the same functionality as ./artemis check cluster
  • Loading branch information
clebertsuconic committed Sep 8, 2023
1 parent bbe23b2 commit 4b8c719
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import org.apache.activemq.artemis.cli.commands.messages.perf.PerfGroup;
import org.apache.activemq.artemis.cli.commands.queue.QueueGroup;
import org.apache.activemq.artemis.cli.commands.tools.DataGroup;
import org.apache.activemq.artemis.cli.commands.tools.cluster.ClusterGroup;
import org.apache.activemq.artemis.cli.commands.tools.journal.PerfJournal;
import org.apache.activemq.artemis.cli.commands.user.UserGroup;
import org.apache.activemq.artemis.dto.ManagementContextDTO;
Expand Down Expand Up @@ -301,8 +300,6 @@ public static CommandLine buildCommand(boolean includeInstanceCommands, boolean
commandLine.addSubcommand(new Upgrade());
}

commandLine.addSubcommand(new ClusterGroup(commandLine));

return commandLine;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import picocli.CommandLine;
import picocli.CommandLine.Command;

@Command(name = "check", description = "use 'help check' for sub commands list", subcommands = {NodeCheck.class, QueueCheck.class})
@Command(name = "check", description = "use 'help check' for sub commands list", subcommands = {NodeCheck.class, QueueCheck.class, ClusterCheck.class})
public class CheckGroup implements Runnable {

CommandLine commandLine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
* limitations under the License.
*/

package org.apache.activemq.artemis.cli.commands.tools.cluster;
package org.apache.activemq.artemis.cli.commands.check;

import org.apache.activemq.artemis.cli.commands.ActionContext;
import org.apache.activemq.artemis.cli.commands.messages.ConnectionAbstract;
import picocli.CommandLine;

@CommandLine.Command(name = "verify", description = "Verify if all the nodes match the same topology.")
public class Verify extends ConnectionAbstract {
@CommandLine.Command(name = "cluster", description = "Verify if all the nodes on the cluster match the same topology and time configuration.")
public class ClusterCheck extends ConnectionAbstract {

@CommandLine.Option(names = "--variance", description = "Allowed variance in milliseconds before considered a failure. (default=1000)")
public long variance = 1000;
Expand All @@ -33,8 +33,8 @@ public Object execute(ActionContext context) throws Exception {

createConnectionFactory();

try (ClusterVerifier clusterVerifier = new ClusterVerifier(brokerURL, user, password, variance).open()) {
try (ClusterNodeVerifier clusterVerifier = new ClusterNodeVerifier(brokerURL, user, password, variance).open()) {
return clusterVerifier.verify(context);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.activemq.artemis.cli.commands.tools.cluster;
package org.apache.activemq.artemis.cli.commands.check;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
Expand All @@ -31,19 +31,19 @@
import org.apache.activemq.artemis.json.JsonObject;
import org.apache.activemq.artemis.json.JsonString;

public class ClusterVerifier implements AutoCloseable {
public class ClusterNodeVerifier implements AutoCloseable {

final String uri, user, password;

final SimpleManagement simpleManagement;

final long allowedVariance;

public ClusterVerifier(String uri, String user, String password) {
public ClusterNodeVerifier(String uri, String user, String password) {
this(uri, user, password, 1000);
}

public ClusterVerifier(String uri, String user, String password, long variance) {
public ClusterNodeVerifier(String uri, String user, String password, long variance) {
this.uri = uri;
this.user = user;
this.password = password;
Expand All @@ -56,7 +56,7 @@ public void close() throws Exception {
simpleManagement.close();
}

public ClusterVerifier open() throws Exception {
public ClusterNodeVerifier open() throws Exception {
simpleManagement.open();
return this;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import org.apache.activemq.artemis.api.core.JsonUtil;
import org.apache.activemq.artemis.cli.commands.ActionContext;
import org.apache.activemq.artemis.cli.commands.tools.cluster.ClusterVerifier;
import org.apache.activemq.artemis.cli.commands.check.ClusterNodeVerifier;
import org.apache.activemq.artemis.json.JsonArray;
import org.apache.commons.lang3.NotImplementedException;
import org.junit.Assert;
Expand All @@ -47,10 +47,10 @@ private void internalVerify(boolean fail) throws Exception {
// A:1 topology:[{"nodeID":"A1","live":"A:1", "backup":"B:1"}, {"nodeID":"A2","live":"A:2", "backup":"B:2"}, {"nodeID":"A3","live":"A:3", "backup":"B:3"}]
// A:2 topology:[{"nodeID":"A1","live":"A:1"}, {"nodeID":"A2","live":"A:2"}, {"nodeID":"A3","live":"A:3"}]
// A:3 topology:[{"nodeID":"A1","live":"A:1", "backup":"B:1"}, {"nodeID":"A2","live":"A:2", "backup":"B:2"}] [
ClusterVerifier fakeVerifier = new ClusterVerifier("fake", "a", "b") {
ClusterNodeVerifier fakeVerifier = new ClusterNodeVerifier("fake", "a", "b") {
@Override
protected void verifyTime(ActionContext context,
Map<String, ClusterVerifier.TopologyItem> mainTopology,
Map<String, ClusterNodeVerifier.TopologyItem> mainTopology,
AtomicBoolean verificationResult,
boolean supportTime) {
// not doing it
Expand Down Expand Up @@ -112,7 +112,7 @@ protected JsonArray fetchTopology(String uri) throws Exception {
// The server is not clustered, and listTopology will return []
@Test
public void testReadEmpty() throws Exception {
ClusterVerifier fakeVerifier = new ClusterVerifier("fake", "a", "b") {
ClusterNodeVerifier fakeVerifier = new ClusterNodeVerifier("fake", "a", "b") {
@Override
protected void verifyTime(ActionContext context,
Map<String, TopologyItem> mainTopology,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import org.apache.activemq.artemis.api.core.management.SimpleManagement;
import org.apache.activemq.artemis.cli.commands.ActionContext;
import org.apache.activemq.artemis.cli.commands.tools.cluster.ClusterVerifier;
import org.apache.activemq.artemis.cli.commands.check.ClusterNodeVerifier;
import org.apache.activemq.artemis.json.JsonArray;
import org.apache.activemq.artemis.json.JsonObject;
import org.apache.activemq.artemis.json.JsonString;
Expand Down Expand Up @@ -134,7 +134,7 @@ private void validateTopology(String[] uris, String[] nodeIDs, int... validNodes
}
}

ClusterVerifier clusterVerifier = new ClusterVerifier(uris[validNodes[0]], "admin", "admin");
ClusterNodeVerifier clusterVerifier = new ClusterNodeVerifier(uris[validNodes[0]], "admin", "admin");
Assert.assertTrue(clusterVerifier.verify(new ActionContext()));
}

Expand Down

0 comments on commit 4b8c719

Please sign in to comment.