dlmarion commented on code in PR #5745:
URL: https://github.com/apache/accumulo/pull/5745#discussion_r2222758448
##########
server/base/src/main/java/org/apache/accumulo/server/util/Admin.java:
##########
@@ -563,18 +552,69 @@ private static void stopServer(final ClientContext
context, final boolean tablet
client -> client.shutdown(TraceUtil.traceInfo(), context.rpcCreds(),
tabletServersToo));
}
- // Visible for tests
- public static void signalGracefulShutdown(final ClientContext context,
String address) {
+ private static void stopServers(final ServerContext context, List<String>
servers,
+ final boolean force)
+ throws AccumuloException, AccumuloSecurityException,
InterruptedException, KeeperException {
+ List<String> hostOnly = new ArrayList<>();
+ Set<HostAndPort> hostAndPort = new TreeSet<>();
+
+ for (var server : servers) {
+ if (server.contains(":")) {
+ hostAndPort.add(HostAndPort.fromString(server));
+ } else {
+ hostOnly.add(server);
+ }
+ }
+
+ if (!hostOnly.isEmpty()) {
+ // The old impl of this command with the old behavior
+ stopTabletServer(context, hostOnly, force);
+ }
+
+ if (!hostAndPort.isEmpty()) {
+ // New behavior for this command when ports are present, supports more
than just tservers. Is
+ // also async.
+ if (force) {
+ ZooZap.Opts opts = new ZooZap.Opts();
+ var zk = context.getZooReaderWriter();
+ var iid = context.getInstanceID();
+
+ String tserversPath = Constants.ZROOT + "/" + iid +
Constants.ZTSERVERS;
+ ZooZap.removeLocks(zk, tserversPath, hostAndPort::contains, opts);
+ String compactorsBasepath = Constants.ZROOT + "/" + iid +
Constants.ZCOMPACTORS;
+ ZooZap.removeGroupedLocks(zk, compactorsBasepath, rg -> true,
hostAndPort::contains, opts);
+ String sserversPath = Constants.ZROOT + "/" + iid +
Constants.ZSSERVERS;
+ ZooZap.removeGroupedLocks(zk, sserversPath, rg -> true,
hostAndPort::contains, opts);
+
+ String managerLockPath = Constants.ZROOT + "/" + iid +
Constants.ZMANAGER_LOCK;
+ ZooZap.removeSingletonLock(zk, managerLockPath, hostAndPort::contains,
opts);
+ String gcLockPath = Constants.ZROOT + "/" + iid + Constants.ZGC_LOCK;
+ ZooZap.removeSingletonLock(zk, gcLockPath, hostAndPort::contains,
opts);
+ String monitorLockPath = Constants.ZROOT + "/" + iid +
Constants.ZMONITOR_LOCK;
+ ZooZap.removeSingletonLock(zk, monitorLockPath, hostAndPort::contains,
opts);
+ } else {
+ for (var server : hostAndPort) {
+ signalGracefulShutdown(context, server);
+ }
+ }
+ }
+ }
- Objects.requireNonNull(address, "address not set");
- final HostAndPort hp = HostAndPort.fromString(address);
+ // Visible for tests
+ public static void signalGracefulShutdown(final ClientContext context,
HostAndPort hp) {
+ Objects.requireNonNull(hp, "address not set");
ServerProcessService.Client client = null;
try {
client =
ThriftClientTypes.SERVER_PROCESS.getServerProcessConnection(context, log,
hp.getHost(), hp.getPort());
+ if (client == null) {
Review Comment:
In main, might be able to use `ClientContext.getServerPaths()` to find all
servers running on the host that have locks in ZK.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]