ctubbsii commented on code in PR #6104:
URL: https://github.com/apache/accumulo/pull/6104#discussion_r2748017993
##########
core/src/main/java/org/apache/accumulo/core/util/compaction/ExternalCompactionUtil.java:
##########
@@ -112,6 +113,26 @@ public static Optional<HostAndPort>
findCompactionCoordinator(ClientContext cont
.map(sld -> sld.getAddress(ThriftService.COORDINATOR));
}
+ /**
+ * @param context client context
+ * @return CompactionCoordinator Thrift client, user has the responsibility
to call
+ * {@code ThriftUtil.returnClient(coordinatorClient, context);}
+ */
+ public static CompactionCoordinatorService.Client
getCoordinatorClient(ClientContext context) {
+ var coordinatorHost =
ExternalCompactionUtil.findCompactionCoordinator(context);
+ if (coordinatorHost.isEmpty()) {
+ throw new IllegalStateException("Unable to find coordinator. Check that
it is running.");
+ }
+ HostAndPort address = coordinatorHost.orElseThrow();
+ CompactionCoordinatorService.Client coordinatorClient;
+ try {
+ coordinatorClient = ThriftUtil.getClient(ThriftClientTypes.COORDINATOR,
address, context);
+ } catch (Exception e) {
Review Comment:
This exception catch block should be more narrow.
##########
server/base/src/main/java/org/apache/accumulo/server/util/CancelCompaction.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * 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
+ *
+ * https://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.accumulo.server.util;
+
+import org.apache.accumulo.core.compaction.thrift.CompactionCoordinatorService;
+import org.apache.accumulo.core.metadata.schema.ExternalCompactionId;
+import org.apache.accumulo.core.rpc.ThriftUtil;
+import org.apache.accumulo.core.trace.TraceUtil;
+import org.apache.accumulo.core.util.compaction.ExternalCompactionUtil;
+import org.apache.accumulo.server.ServerContext;
+import org.apache.accumulo.server.cli.ServerUtilOpts;
+import org.apache.accumulo.start.spi.KeywordExecutable;
+
+import com.beust.jcommander.JCommander;
+import com.beust.jcommander.Parameter;
+import com.beust.jcommander.Parameters;
+import com.google.auto.service.AutoService;
+
+@AutoService(KeywordExecutable.class)
+public class CancelCompaction implements KeywordExecutable {
+
+ @Parameters(commandNames = "cancel",
+ commandDescription = "cancel the external compaction with given ECID")
+ static class CancelCommand {
+ @Parameter(names = "-ecid", description = "<ecid>", required = true)
+ String ecid;
+ }
+
+ @Override
+ public String keyword() {
+ return "cancel-compaction";
Review Comment:
It would probably be good to have compaction related stuff together, either
in the same group, like one named "compaction" or having a common prefix, like
"compaction-cancel" instead of "cancel-compaction".
--
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]