Skip to content

Commit f794407

Browse files
author
Michael Nitschinger
committed
Revert "JCBC-1886: Allow to list the number of currently available replicas for a document ID."
This reverts commit 8df11ba. Reason for revert: <INSERT REASONING HERE> Change-Id: I1bd9aa3e32eedd3ae5bf3e9992bd41db04e284ef Reviewed-on: http://review.couchbase.org/c/couchbase-java-client/+/164248 Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com> Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
1 parent 8df11ba commit f794407

File tree

1 file changed

+10
-34
lines changed

1 file changed

+10
-34
lines changed

src/main/java/com/couchbase/client/java/util/NodeLocatorHelper.java

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,18 @@
5454
@InterfaceAudience.Public
5555
public 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

Comments
 (0)