private static int calculateNodeId ( int partitionId , BinaryRequest request , CouchbaseBucketConfig config ) { boolean useFastForward = request . retryCount ( ) > 0 && config . hasFastForwardMap ( ) ; if ( request instanceof ReplicaGetRequest ) { return config . nodeIndexForReplica ( partitionId , ( ( ReplicaGetRequest ) request ) . replica ( ) - 1 , useFastForward ) ; } else if ( request instanceof ObserveRequest && ( ( ObserveRequest ) request ) . replica ( ) > 0 ) { return config . nodeIndexForReplica ( partitionId , ( ( ObserveRequest ) request ) . replica ( ) - 1 , useFastForward ) ; } else if ( request instanceof ObserveSeqnoRequest && ( ( ObserveSeqnoRequest ) request ) . replica ( ) > 0 ) { return config . nodeIndexForReplica ( partitionId , ( ( ObserveSeqnoRequest ) request ) . replica ( ) - 1 , useFastForward ) ; } else { return config . nodeIndexForMaster ( partitionId , useFastForward ) ; } }
Helper method to calculate the node if for the given partition and request type .