All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.query.affinity.ShardDistributionFactory Maven / Gradle / Ivy

package org.infinispan.query.affinity;

import org.infinispan.distribution.ch.ConsistentHash;

/**
 * Factory for {@link ShardDistribution} instances.
 * @since 9.0
 */
final class ShardDistributionFactory {

   private ShardDistributionFactory() {
   }

   public static ShardDistribution build(Integer numShards, int nSegments, ConsistentHash consistentHash) {
      int shards = numShards == null ? nSegments : numShards;
      if (consistentHash != null) {
         return shards == nSegments ? new PerSegmentShardDistribution(consistentHash) :
               new FixedShardsDistribution(consistentHash, shards);
      } else {
         return new LocalModeShardDistribution(nSegments, shards);
      }

   }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy