@Test void cancelsTargetedRequestIfNodeListEmpty() { Locator locator = new KeyValueLocator(); Request<?> request = mock(CarrierBucketConfigRequest.class); locator.dispatch(request, Collections.emptyList(), null, null); verify(request, times(1)).cancel(CancellationReason.TARGET_NODE_REMOVED); }
@Override public void dispatch(final Request<? extends Response> request, final List<Node> nodes, final ClusterConfig config, final CoreContext ctx) { if (request instanceof TargetedRequest) { dispatchTargeted((TargetedRequest) request, nodes, ctx); } else { KeyValueRequest r = (KeyValueRequest) request; String bucket = r.bucket(); BucketConfig bucketConfig = config.bucketConfig(bucket); if (bucketConfig == null) { RetryOrchestrator.maybeRetry(ctx, request, ctx.core().configurationProvider().bucketConfigLoadInProgress() ? RetryReason.BUCKET_OPEN_IN_PROGRESS : RetryReason.BUCKET_NOT_AVAILABLE); return; } if (bucketConfig instanceof CouchbaseBucketConfig) { couchbaseBucket(r, nodes, (CouchbaseBucketConfig) bucketConfig, ctx); } else if (bucketConfig instanceof MemcachedBucketConfig) { memcacheBucket(r, nodes, (MemcachedBucketConfig) bucketConfig, ctx); } else { throw new IllegalStateException("Unsupported Bucket Type: " + bucketConfig + " for request " + request); } } }
KeyValueLocator implements Locator { @Override public void dispatch(final Request<? extends Response> request, final List<Node> nodes, final ClusterConfig config, final CoreContext ctx) { if (request instanceof TargetedRequest) { dispatchTargeted((TargetedRequest) request, nodes, ctx); } else { KeyValueRequest r = (KeyValueRequest) request; String bucket = r.bucket(); BucketConfig bucketConfig = config.bucketConfig(bucket); if (bucketConfig == null) { RetryOrchestrator.maybeRetry(ctx, request, ctx.core().configurationProvider().bucketConfigLoadInProgress() ? RetryReason.BUCKET_OPEN_IN_PROGRESS : RetryReason.BUCKET_NOT_AVAILABLE); return; } if (bucketConfig instanceof CouchbaseBucketConfig) { couchbaseBucket(r, nodes, (CouchbaseBucketConfig) bucketConfig, ctx); } else if (bucketConfig instanceof MemcachedBucketConfig) { memcacheBucket(r, nodes, (MemcachedBucketConfig) bucketConfig, ctx); } else { throw new IllegalStateException("Unsupported Bucket Type: " + bucketConfig + " for request " + request); } } } }
KeyValueLocator implements Locator { @Override public void dispatch(final Request<? extends Response> request, final List<Node> nodes, final ClusterConfig config, final CoreContext ctx) { if (request instanceof TargetedRequest) { dispatchTargeted((TargetedRequest) request, nodes, ctx); } else { KeyValueRequest r = (KeyValueRequest) request; String bucket = r.bucket(); BucketConfig bucketConfig = config.bucketConfig(bucket); if (bucketConfig == null) { RetryOrchestrator.maybeRetry(ctx, request, ctx.core().configurationProvider().bucketConfigLoadInProgress() ? RetryReason.BUCKET_OPEN_IN_PROGRESS : RetryReason.BUCKET_NOT_AVAILABLE); return; } if (bucketConfig instanceof CouchbaseBucketConfig) { couchbaseBucket(r, nodes, (CouchbaseBucketConfig) bucketConfig, ctx); } else if (bucketConfig instanceof MemcachedBucketConfig) { memcacheBucket(r, nodes, (MemcachedBucketConfig) bucketConfig, ctx); } else { throw new IllegalStateException("Unsupported Bucket Type: " + bucketConfig + " for request " + request); } } }  }
KeyValueLocator implements Locator { @Override public void dispatch(final Request<? extends Response> request, final List<Node> nodes, final ClusterConfig config, final CoreContext ctx) { if (request instanceof TargetedRequest) { dispatchTargeted((TargetedRequest) request, nodes, ctx); } else { KeyValueRequest r = (KeyValueRequest) request; String bucket = r.bucket(); BucketConfig bucketConfig = config.bucketConfig(bucket); if (bucketConfig == null) { RetryOrchestrator.maybeRetry(ctx, request, ctx.core().configurationProvider().bucketConfigLoadInProgress() ? RetryReason.BUCKET_OPEN_IN_PROGRESS : RetryReason.BUCKET_NOT_AVAILABLE); return; } if (bucketConfig instanceof CouchbaseBucketConfig) { couchbaseBucket(r, nodes, (CouchbaseBucketConfig) bucketConfig, ctx); } else if (bucketConfig instanceof MemcachedBucketConfig) { memcacheBucket(r, nodes, (MemcachedBucketConfig) bucketConfig, ctx); } else { throw new IllegalStateException("Unsupported Bucket Type: " + bucketConfig + " for request " + request); } } }  @Override void dispatch(final Request<? extends Response> request, final List<Node> nodes,
                       final ClusterConfig config, final CoreContext ctx); static int partitionForKey(final byte[] id, final int numPartitions); }
KeyValueLocator implements Locator { @Override public void dispatch(final Request<? extends Response> request, final List<Node> nodes, final ClusterConfig config, final CoreContext ctx) { if (request instanceof TargetedRequest) { dispatchTargeted((TargetedRequest) request, nodes, ctx); } else { KeyValueRequest r = (KeyValueRequest) request; String bucket = r.bucket(); BucketConfig bucketConfig = config.bucketConfig(bucket); if (bucketConfig == null) { RetryOrchestrator.maybeRetry(ctx, request, ctx.core().configurationProvider().bucketConfigLoadInProgress() ? RetryReason.BUCKET_OPEN_IN_PROGRESS : RetryReason.BUCKET_NOT_AVAILABLE); return; } if (bucketConfig instanceof CouchbaseBucketConfig) { couchbaseBucket(r, nodes, (CouchbaseBucketConfig) bucketConfig, ctx); } else if (bucketConfig instanceof MemcachedBucketConfig) { memcacheBucket(r, nodes, (MemcachedBucketConfig) bucketConfig, ctx); } else { throw new IllegalStateException("Unsupported Bucket Type: " + bucketConfig + " for request " + request); } } }  @Override void dispatch(final Request<? extends Response> request, final List<Node> nodes,
                       final ClusterConfig config, final CoreContext ctx); static int partitionForKey(final byte[] id, final int numPartitions);  }