ClusteredSwitchingBackend(Properties props, ComponentRegistry componentsRegistry, String indexName, LocalBackendFactory factory, IndexLockController indexlock) { this.indexName = indexName; this.factory = factory; this.indexlock = indexlock; this.rpcManager = componentsRegistry.getComponent(RpcManager.class); this.cacheName = componentsRegistry.getCacheName(); if (rpcManager == null) { throw new IllegalStateException("This Cache is not clustered! The switching backend should not be used for local caches"); } this.localAddress = rpcManager.getAddress(); this.currentBackend = new LazyInitializingBackend(this); this.async = !BackendFactory.isConfiguredAsSync(props); }
ClusteredSwitchingBackend(Properties props, ComponentRegistry componentsRegistry, String indexName, LocalBackendFactory factory, IndexLockController indexlock) { this.indexName = indexName; this.factory = factory; this.indexlock = indexlock; this.rpcManager = componentsRegistry.getComponent(RpcManager.class); this.cacheName = componentsRegistry.getCacheName(); if (rpcManager == null) { throw new IllegalStateException("This Cache is not clustered! The switching backend should not be used for local caches"); } this.localAddress = rpcManager.getAddress(); this.currentBackend = new LazyInitializingBackend(this); this.async = !BackendFactory.isConfiguredAsSync(props); }
@Override public void initialize(Properties properties, BuildContext buildContext) { ServiceManager serviceManager = buildContext.getServiceManager(); ComponentRegistryService componentRegistryService = serviceManager.requestService(ComponentRegistryService.class); this.componentRegistry = componentRegistryService.getComponentRegistry(); CacheManagerService cacheManagerService = serviceManager.requestService(CacheManagerService.class); EmbeddedCacheManager embeddedCacheManager = cacheManagerService.getEmbeddedCacheManager(); rpcManager = componentRegistry.getComponent(RpcManager.class); String cacheName = componentRegistry.getCacheName(); ClusteringConfiguration clusteringConfiguration = embeddedCacheManager.getCacheConfiguration(cacheName).clustering(); int numberOfShards = getNumberOfShards(properties); shardAllocatorManager = this.componentRegistry.getComponent(ShardAllocatorManager.class); shardAllocatorManager.initialize(numberOfShards, clusteringConfiguration.hash().numSegments()); if (log.isDebugEnabled()) { log.debugf("Initializing ShardIdProvider with %d shards", numberOfShards); } }
@Override public void initialize(Properties properties, BuildContext buildContext) { ServiceManager serviceManager = buildContext.getServiceManager(); ComponentRegistryService componentRegistryService = serviceManager.requestService(ComponentRegistryService.class); this.componentRegistry = componentRegistryService.getComponentRegistry(); CacheManagerService cacheManagerService = serviceManager.requestService(CacheManagerService.class); EmbeddedCacheManager embeddedCacheManager = cacheManagerService.getEmbeddedCacheManager(); rpcManager = componentRegistry.getComponent(RpcManager.class); String cacheName = componentRegistry.getCacheName(); ClusteringConfiguration clusteringConfiguration = embeddedCacheManager.getCacheConfiguration(cacheName).clustering(); Integer numberOfShards = getNumberOfShards(properties); shardAllocatorManager = this.componentRegistry.getComponent(ShardAllocatorManager.class); shardAllocatorManager.initialize(numberOfShards, clusteringConfiguration.hash().numSegments()); if (log.isDebugEnabled()) { log.debugf("Initializing ShardIdProvider with %d shards", numberOfShards); } }