private static void errorObservables(int nodeId, BinaryRequest request, String name, CoreEnvironment env,
        RingBuffer<ResponseEvent> responseBuffer) {
        if (nodeId == DefaultCouchbaseBucketConfig.PARTITION_NOT_EXISTENT) {
            if (request instanceof ReplicaGetRequest) {
                request.observable().onError(new ReplicaNotConfiguredException("Replica number "
                        + ((ReplicaGetRequest) request).replica() + " not configured for bucket " + name, null));
                return;
            } else if (request instanceof ObserveRequest) {
                request.observable().onError(new ReplicaNotConfiguredException("Replica number "
                        + ((ObserveRequest) request).replica() + " not configured for bucket " + name, ((ObserveRequest) request).cas()));
                return;
            } else if (request instanceof ObserveSeqnoRequest) {
                request.observable().onError(new ReplicaNotConfiguredException("Replica number "
                        + ((ObserveSeqnoRequest) request).replica() + " not configured for bucket " + name, ((ObserveSeqnoRequest) request).cas()));
                return;
            }

            RetryHelper.retryOrCancel(env, request, responseBuffer);
            return;
        }

        if (nodeId == -1) {
            if (request instanceof ObserveRequest) {
                request.observable().onError(new ReplicaNotAvailableException("Replica number "
                        + ((ObserveRequest) request).replica() + " not available for bucket " + name,
                    ((ObserveRequest) request).cas()));
                return;
            } else if (request instanceof ReplicaGetRequest) {
                request.observable().onError(new ReplicaNotAvailableException("Replica number "
                        + ((ReplicaGetRequest) request).replica() + " not available for bucket " + name, null));
                return;
            } else if (request instanceof ObserveSeqnoRequest) {
                request.observable().onError(new ReplicaNotAvailableException("Replica number "
                        + ((ObserveSeqnoRequest) request).replica() + " not available for bucket " + name, ((ObserveSeqnoRequest) request).cas()));
                return;
            }

            RetryHelper.retryOrCancel(env, request, responseBuffer);
            return;
        }

        throw new IllegalStateException("Unknown NodeId: " + nodeId + ", request: " + request);
    }
private static void errorObservables ( int nodeId , BinaryRequest request , String name , CoreEnvironment env , RingBuffer < ResponseEvent > responseBuffer ) { if ( nodeId == DefaultCouchbaseBucketConfig . PARTITION_NOT_EXISTENT ) { if ( request instanceof ReplicaGetRequest ) { request . observable ( ) . onError ( new ReplicaNotConfiguredException ( "Replica number " + ( ( ReplicaGetRequest ) request ) . replica ( ) + " not configured for bucket " + name , null ) ) ; return ; } else if ( request instanceof ObserveRequest ) { request . observable ( ) . onError ( new ReplicaNotConfiguredException ( "Replica number " + ( ( ObserveRequest ) request ) . replica ( ) + " not configured for bucket " + name , ( ( ObserveRequest ) request ) . cas ( ) ) ) ; return ; } else if ( request instanceof ObserveSeqnoRequest ) { request . observable ( ) . onError ( new ReplicaNotConfiguredException ( "Replica number " + ( ( ObserveSeqnoRequest ) request ) . replica ( ) + " not configured for bucket " + name , ( ( ObserveSeqnoRequest ) request ) . cas ( ) ) ) ; return ; } RetryHelper . retryOrCancel ( env , request , responseBuffer ) ; return ; } if ( nodeId == - 1 ) { if ( request instanceof ObserveRequest ) { request . observable ( ) . onError ( new ReplicaNotAvailableException ( "Replica number " + ( ( ObserveRequest ) request ) . replica ( ) + " not available for bucket " + name , ( ( ObserveRequest ) request ) . cas ( ) ) ) ; return ; } else if ( request instanceof ReplicaGetRequest ) { request . observable ( ) . onError ( new ReplicaNotAvailableException ( "Replica number " + ( ( ReplicaGetRequest ) request ) . replica ( ) + " not available for bucket " + name , null ) ) ; return ; } else if ( request instanceof ObserveSeqnoRequest ) { request . observable ( ) . onError ( new ReplicaNotAvailableException ( "Replica number " + ( ( ObserveSeqnoRequest ) request ) . replica ( ) + " not available for bucket " + name , ( ( ObserveSeqnoRequest ) request ) . cas ( ) ) ) ; return ; } RetryHelper . retryOrCancel ( env , request , responseBuffer ) ; return ; } throw new IllegalStateException ( "Unknown NodeId: " + nodeId + ", request: " + request ) ; }
Fail observables because the partitions do not match up.

If the replica is not even available in the configuration (identified by a -2 node index),
it is clear that this replica is not configured. If a -1 is returned it is configured, but
currently not available (not enough nodes in the cluster, for example if a node is seen down,
after a failover, or during rebalance. Replica partitions in general take longer to heal than
active partitions, since they are sacrificed for application availability.

@param nodeId the current node id of the partition
@param request the request to error
@param name the name of the bucket