dlmarion commented on code in PR #5775:
URL: https://github.com/apache/accumulo/pull/5775#discussion_r2252140782


##########
core/src/main/java/org/apache/accumulo/core/rpc/clients/TServerClient.java:
##########
@@ -60,16 +63,39 @@
 public interface TServerClient<C extends TServiceClient> {
 
   static final String DEBUG_HOST = "org.apache.accumulo.client.rpc.debug.host";
+  static final String DEBUG_RG = "org.apache.accumulo.client.rpc.debug.group";
 
-  Pair<String,C> getThriftServerConnection(ClientContext context, boolean 
preferCachedConnections)
-      throws TTransportException;
+  Pair<String,C> getThriftServerConnection(ClientContext context, boolean 
preferCachedConnections,
+      ResourceGroupId rgid) throws TTransportException;
 
   default Pair<String,C> getThriftServerConnection(Logger LOG, 
ThriftClientTypes<C> type,
       ClientContext context, boolean preferCachedConnections, AtomicBoolean 
warned,
-      ThriftService service) throws TTransportException {
+      ThriftService service, ResourceGroupId rgid) throws TTransportException {
     checkArgument(context != null, "context is null");
 
     final String debugHost = System.getProperty(DEBUG_HOST, null);
+    final String debugRG = System.getProperty(DEBUG_RG, null);
+
+    if (debugHost != null && debugRG != null) {
+      LOG.warn("System properties {} and {} are both set. If set incorrectly 
then"
+          + " this client may not find a server to connect to.", DEBUG_HOST, 
DEBUG_RG);
+    }
+
+    ResourceGroupPredicate rgp = rgid == ResourceGroupId.ANY ? r -> true : r 
-> r.equals(rgid);
+    if (debugRG != null && !rgid.canonical().equals(debugRG)) {
+      if (type == ThriftClientTypes.CLIENT || type == 
ThriftClientTypes.COMPACTOR
+          || type == ThriftClientTypes.SERVER_PROCESS || type == 
ThriftClientTypes.TABLET_INGEST
+          || type == ThriftClientTypes.TABLET_MGMT || type == 
ThriftClientTypes.TABLET_SCAN
+          || type == ThriftClientTypes.TABLET_SERVER) {
+        LOG.debug("System property '{}' set to '{}' overriding group argument 
'{}'", DEBUG_RG,
+            debugRG, rgid);
+        rgp = r -> r.canonical().equals(debugRG);
+      } else {
+        LOG.debug(
+            "System property '{}' set to '{}' but ignored when making RPCs to 
management servers",
+            DEBUG_RG, debugRG);
+      }
+    }

Review Comment:
   I don't think we should change the predicate for API calls that go to the 
management servers. Those servers are in the `default` resource group and can't 
be changed. I think the debug system property should only affect calls that 
will end up going to the worker server processes. For example, if someone is in 
the shell with the debug property set and does `config -s`, then it will fail 
because setting configuration properties is done via the Manager API.
   



-- 
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]

Reply via email to