yifan-c commented on code in PR #123:
URL: https://github.com/apache/cassandra-sidecar/pull/123#discussion_r1680504639


##########
src/main/java/org/apache/cassandra/sidecar/utils/InstanceMetadataFetcher.java:
##########
@@ -99,11 +103,32 @@ public CassandraAdapterDelegate delegate(int instanceId)
      * @throws IllegalStateException when there are no configured instances
      */
     public InstanceMetadata firstInstance()
+    {
+        ensureInstancesConfigured();
+        return instancesConfig.instances().get(0);
+    }
+
+    /**
+     * @return any instance from the list of configured instances
+     * @throws IllegalStateException when there are no configured instances
+     */
+    public InstanceMetadata anyInstance()

Review Comment:
   The idea of picking any instance is to avoid making a node hotter than 
others. Ideally, all callers of `firstInstance` should be replaced by 
`anyInstance`. 
   
   It is good of calling out the availability. Depending on the callsites, the 
requirement can differ. We can have an overload method that takes an optional 
filter parameter to remove the unwanted instances. For example, `public 
InstanceMetadata anyInstance(Predicate<InstanceMetadata> filter)`



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to