ARTEMIS-4384 Moving Cluster verify under verify group
With this you would access the same functionality as ./artemis check cluster
This commit is contained in:
parent
bbe23b24ad
commit
4b8c7199e7
|
@ -51,7 +51,6 @@ import org.apache.activemq.artemis.cli.commands.messages.Transfer;
|
||||||
import org.apache.activemq.artemis.cli.commands.messages.perf.PerfGroup;
|
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.queue.QueueGroup;
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.DataGroup;
|
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.tools.journal.PerfJournal;
|
||||||
import org.apache.activemq.artemis.cli.commands.user.UserGroup;
|
import org.apache.activemq.artemis.cli.commands.user.UserGroup;
|
||||||
import org.apache.activemq.artemis.dto.ManagementContextDTO;
|
import org.apache.activemq.artemis.dto.ManagementContextDTO;
|
||||||
|
@ -301,8 +300,6 @@ public class Artemis implements Runnable {
|
||||||
commandLine.addSubcommand(new Upgrade());
|
commandLine.addSubcommand(new Upgrade());
|
||||||
}
|
}
|
||||||
|
|
||||||
commandLine.addSubcommand(new ClusterGroup(commandLine));
|
|
||||||
|
|
||||||
return commandLine;
|
return commandLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.apache.activemq.artemis.cli.commands.HelpAction;
|
||||||
import picocli.CommandLine;
|
import picocli.CommandLine;
|
||||||
import picocli.CommandLine.Command;
|
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 {
|
public class CheckGroup implements Runnable {
|
||||||
|
|
||||||
CommandLine commandLine;
|
CommandLine commandLine;
|
||||||
|
|
|
@ -15,14 +15,14 @@
|
||||||
* limitations under the License.
|
* 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.ActionContext;
|
||||||
import org.apache.activemq.artemis.cli.commands.messages.ConnectionAbstract;
|
import org.apache.activemq.artemis.cli.commands.messages.ConnectionAbstract;
|
||||||
import picocli.CommandLine;
|
import picocli.CommandLine;
|
||||||
|
|
||||||
@CommandLine.Command(name = "verify", description = "Verify if all the nodes match the same topology.")
|
@CommandLine.Command(name = "cluster", description = "Verify if all the nodes on the cluster match the same topology and time configuration.")
|
||||||
public class Verify extends ConnectionAbstract {
|
public class ClusterCheck extends ConnectionAbstract {
|
||||||
|
|
||||||
@CommandLine.Option(names = "--variance", description = "Allowed variance in milliseconds before considered a failure. (default=1000)")
|
@CommandLine.Option(names = "--variance", description = "Allowed variance in milliseconds before considered a failure. (default=1000)")
|
||||||
public long variance = 1000;
|
public long variance = 1000;
|
||||||
|
@ -33,7 +33,7 @@ public class Verify extends ConnectionAbstract {
|
||||||
|
|
||||||
createConnectionFactory();
|
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);
|
return clusterVerifier.verify(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,7 +15,7 @@
|
||||||
* limitations under the License.
|
* 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.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -31,7 +31,7 @@ import org.apache.activemq.artemis.json.JsonArray;
|
||||||
import org.apache.activemq.artemis.json.JsonObject;
|
import org.apache.activemq.artemis.json.JsonObject;
|
||||||
import org.apache.activemq.artemis.json.JsonString;
|
import org.apache.activemq.artemis.json.JsonString;
|
||||||
|
|
||||||
public class ClusterVerifier implements AutoCloseable {
|
public class ClusterNodeVerifier implements AutoCloseable {
|
||||||
|
|
||||||
final String uri, user, password;
|
final String uri, user, password;
|
||||||
|
|
||||||
|
@ -39,11 +39,11 @@ public class ClusterVerifier implements AutoCloseable {
|
||||||
|
|
||||||
final long allowedVariance;
|
final long allowedVariance;
|
||||||
|
|
||||||
public ClusterVerifier(String uri, String user, String password) {
|
public ClusterNodeVerifier(String uri, String user, String password) {
|
||||||
this(uri, user, password, 1000);
|
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.uri = uri;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
|
@ -56,7 +56,7 @@ public class ClusterVerifier implements AutoCloseable {
|
||||||
simpleManagement.close();
|
simpleManagement.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClusterVerifier open() throws Exception {
|
public ClusterNodeVerifier open() throws Exception {
|
||||||
simpleManagement.open();
|
simpleManagement.open();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
|
@ -1,38 +0,0 @@
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.activemq.artemis.cli.commands.tools.cluster;
|
|
||||||
|
|
||||||
import org.apache.activemq.artemis.cli.commands.HelpAction;
|
|
||||||
import picocli.CommandLine;
|
|
||||||
import picocli.CommandLine.Command;
|
|
||||||
|
|
||||||
@Command(name = "cluster", description = "use 'help cluster' for sub commands list", subcommands = {Verify.class})
|
|
||||||
public class ClusterGroup implements Runnable {
|
|
||||||
|
|
||||||
CommandLine commandLine;
|
|
||||||
|
|
||||||
public ClusterGroup(CommandLine commandLine) {
|
|
||||||
this.commandLine = commandLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
HelpAction.help(commandLine, "cluster");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -22,7 +22,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.api.core.JsonUtil;
|
import org.apache.activemq.artemis.api.core.JsonUtil;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
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.JsonArray;
|
||||||
import org.apache.commons.lang3.NotImplementedException;
|
import org.apache.commons.lang3.NotImplementedException;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@ -47,10 +47,10 @@ public class ClusterVerifyTest {
|
||||||
// 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: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: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"}] [
|
// 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
|
@Override
|
||||||
protected void verifyTime(ActionContext context,
|
protected void verifyTime(ActionContext context,
|
||||||
Map<String, ClusterVerifier.TopologyItem> mainTopology,
|
Map<String, ClusterNodeVerifier.TopologyItem> mainTopology,
|
||||||
AtomicBoolean verificationResult,
|
AtomicBoolean verificationResult,
|
||||||
boolean supportTime) {
|
boolean supportTime) {
|
||||||
// not doing it
|
// not doing it
|
||||||
|
@ -112,7 +112,7 @@ public class ClusterVerifyTest {
|
||||||
// The server is not clustered, and listTopology will return []
|
// The server is not clustered, and listTopology will return []
|
||||||
@Test
|
@Test
|
||||||
public void testReadEmpty() throws Exception {
|
public void testReadEmpty() throws Exception {
|
||||||
ClusterVerifier fakeVerifier = new ClusterVerifier("fake", "a", "b") {
|
ClusterNodeVerifier fakeVerifier = new ClusterNodeVerifier("fake", "a", "b") {
|
||||||
@Override
|
@Override
|
||||||
protected void verifyTime(ActionContext context,
|
protected void verifyTime(ActionContext context,
|
||||||
Map<String, TopologyItem> mainTopology,
|
Map<String, TopologyItem> mainTopology,
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.lang.invoke.MethodHandles;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.api.core.management.SimpleManagement;
|
import org.apache.activemq.artemis.api.core.management.SimpleManagement;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
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.JsonArray;
|
||||||
import org.apache.activemq.artemis.json.JsonObject;
|
import org.apache.activemq.artemis.json.JsonObject;
|
||||||
import org.apache.activemq.artemis.json.JsonString;
|
import org.apache.activemq.artemis.json.JsonString;
|
||||||
|
@ -134,7 +134,7 @@ public class TopologyCheckTest extends SmokeTestBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ClusterVerifier clusterVerifier = new ClusterVerifier(uris[validNodes[0]], "admin", "admin");
|
ClusterNodeVerifier clusterVerifier = new ClusterNodeVerifier(uris[validNodes[0]], "admin", "admin");
|
||||||
Assert.assertTrue(clusterVerifier.verify(new ActionContext()));
|
Assert.assertTrue(clusterVerifier.verify(new ActionContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue