5454@ InterfaceAudience .Public
5555public class NodeLocatorHelper {
5656
57+ private final ConfigurationProvider configProvider ;
5758 private final AtomicReference <BucketConfig > bucketConfig ;
5859
5960 private NodeLocatorHelper (final Bucket bucket ) {
60- ConfigurationProvider configProvider = bucket
61- .core ()
62- .<GetConfigProviderResponse >send (new GetConfigProviderRequest ())
63- .toBlocking ()
64- .single ()
65- .provider ();
61+ configProvider = bucket
62+ .core ()
63+ .<GetConfigProviderResponse >send (new GetConfigProviderRequest ())
64+ .toBlocking ()
65+ .single ()
66+ .provider ();
6667
67- bucketConfig = new AtomicReference <>(configProvider .config ().bucketConfig (bucket .name ()));
68+ bucketConfig = new AtomicReference <BucketConfig >(configProvider .config ().bucketConfig (bucket .name ()));
6869
6970 configProvider
7071 .configs ()
@@ -120,7 +121,7 @@ public List<InetAddress> replicaNodesForId(final String id) {
120121
121122 if (config instanceof CouchbaseBucketConfig ) {
122123 CouchbaseBucketConfig cbc = (CouchbaseBucketConfig ) config ;
123- List <InetAddress > replicas = new ArrayList <>();
124+ List <InetAddress > replicas = new ArrayList <InetAddress >();
124125 for (int i = 1 ; i <= cbc .numberOfReplicas (); i ++) {
125126 replicas .add (replicaNodeForId (id , i ));
126127 }
@@ -130,31 +131,6 @@ public List<InetAddress> replicaNodesForId(final String id) {
130131 }
131132 }
132133
133- /**
134- * Returns all target replica nodes {@link InetAddress} which are currently available on the bucket.
135- *
136- * @param id the document ID to check.
137- * @return the list of nodes for the given document ID.
138- */
139- public List <InetAddress > availableReplicaNodesForId (final String id ) {
140- BucketConfig config = bucketConfig .get ();
141-
142- if (config instanceof CouchbaseBucketConfig ) {
143- CouchbaseBucketConfig cbc = (CouchbaseBucketConfig ) config ;
144- List <InetAddress > replicas = new ArrayList <>();
145- for (int i = 1 ; i <= cbc .numberOfReplicas (); i ++) {
146- try {
147- replicas .add (replicaNodeForId (id , i ));
148- } catch (IllegalStateException ex ) {
149- // We ignore -1 and -2 vbuckets on purpose.
150- }
151- }
152- return replicas ;
153- } else {
154- throw new UnsupportedOperationException ("Bucket type not supported: " + config .getClass ().getName ());
155- }
156- }
157-
158134 /**
159135 * Returns the target replica node {@link InetAddress} for a given document ID and replica number on the bucket.
160136 *
@@ -195,7 +171,7 @@ public InetAddress replicaNodeForId(final String id, int replicaNum) {
195171 * @return all currently known nodes.
196172 */
197173 public List <InetAddress > nodes () {
198- List <InetAddress > allNodes = new ArrayList <>();
174+ List <InetAddress > allNodes = new ArrayList <InetAddress >();
199175 BucketConfig config = bucketConfig .get ();
200176 for (NodeInfo nodeInfo : config .nodes ()) {
201177 try {
0 commit comments