use of com.couchbase.client.core.cnc.events.io.NotMyVbucketReceivedEvent in project couchbase-jvm-clients by couchbase.
the class KeyValueMessageHandler method handleNotMyVbucket.
/**
* Helper method to handle a "not my vbucket" response.
*
* @param request the request to retry.
* @param response the response to extract the config from, potentially.
*/
private void handleNotMyVbucket(final KeyValueRequest<Response> request, final ByteBuf response) {
request.indicateRejectedWithNotMyVbucket();
eventBus.publish(new NotMyVbucketReceivedEvent(ioContext, request.partition()));
final String origin = request.context().lastDispatchedTo() != null ? request.context().lastDispatchedTo().hostname() : null;
RetryOrchestrator.maybeRetry(ioContext, request, RetryReason.KV_NOT_MY_VBUCKET);
body(response).map(b -> b.toString(UTF_8).trim()).filter(c -> c.startsWith("{")).ifPresent(c -> ioContext.core().configurationProvider().proposeBucketConfig(new ProposedBucketConfigContext(request.bucket(), c, origin)));
}
Aggregations