public static boolean checkKeyBelongsToPartition(int nodeId,
                                                     byte[] key,
                                                     HashMap<Integer, List<Integer>> replicaToPartitionList,
                                                     Cluster cluster,
                                                     StoreDefinition storeDef) {
        boolean checkResult = false;
        if(storeDef.getRoutingStrategyType().equals(RoutingStrategyType.TO_ALL_STRATEGY)
           || storeDef.getRoutingStrategyType()
                      .equals(RoutingStrategyType.TO_ALL_LOCAL_PREF_STRATEGY)) {
            checkResult = true;
        } else {
            List<Integer> keyPartitions = new RoutingStrategyFactory().updateRoutingStrategy(storeDef,
                                                                                             cluster)
                                                                      .getPartitionList(key);
            List<Integer> nodePartitions = cluster.getNodeById(nodeId).getPartitionIds();
            checkResult = StoreRoutingPlan.checkKeyBelongsToPartition(keyPartitions,
                                                                      nodePartitions,
                                                                      replicaToPartitionList);
        }
        return checkResult;
    }
public static boolean checkKeyBelongsToPartition ( int nodeId , byte [ ] key , HashMap < Integer , List < Integer > > replicaToPartitionList , Cluster cluster , StoreDefinition storeDef ) { boolean checkResult = false ; if ( storeDef . getRoutingStrategyType ( ) . equals ( RoutingStrategyType . TO_ALL_STRATEGY ) || storeDef . getRoutingStrategyType ( ) . equals ( RoutingStrategyType . TO_ALL_LOCAL_PREF_STRATEGY ) ) { checkResult = true ; } else { List < Integer > keyPartitions = new RoutingStrategyFactory ( ) . updateRoutingStrategy ( storeDef , cluster ) . getPartitionList ( key ) ; List < Integer > nodePartitions = cluster . getNodeById ( nodeId ) . getPartitionIds ( ) ; checkResult = StoreRoutingPlan . checkKeyBelongsToPartition ( keyPartitions , nodePartitions , replicaToPartitionList ) ; } return checkResult ; }
Check that the key belongs to one of the partitions in the map of replica
type to partitions

@param nodeId Node on which this is running ( generally stealer node )
@param key The key to check
@param replicaToPartitionList Mapping of replica type to partition list
@param cluster Cluster metadata
@param storeDef The store definition
@return Returns a boolean to indicate if this belongs to the map