public static ConsistentHashFactory pickConsistentHashFactory ( GlobalConfiguration globalConfiguration , Configuration configuration ) { ConsistentHashFactory factory = configuration . clustering ( ) . hash ( ) . consistentHashFactory ( ) ; if ( factory == null ) { CacheMode cacheMode = configuration . clustering ( ) . cacheMode ( ) ; if ( cacheMode . isClustered ( ) ) { if ( cacheMode . isDistributed ( ) ) { if ( globalConfiguration . transport ( ) . hasTopologyInfo ( ) ) { factory = new TopologyAwareSyncConsistentHashFactory ( ) ; } else { factory = new SyncConsistentHashFactory ( ) ; } } else if ( cacheMode . isReplicated ( ) || cacheMode . isInvalidation ( ) ) { factory = new SyncReplicatedConsistentHashFactory ( ) ; } else if ( cacheMode . isScattered ( ) ) { factory = new ScatteredConsistentHashFactory ( ) ; } else { throw new CacheException ( "Unexpected cache mode: " + cacheMode ) ; } } } return factory ; }
If no ConsistentHashFactory was explicitly configured we choose a suitable one based on cache mode .