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); }
private BackendQueueProcessor createDelegateQueueProcessor(IndexManager indexManager, WorkerBuildContext context) { return BackendFactory.createBackend( delegateBackendName, indexManager, context, properties ); }
/** * @param indexManager the index manager * @param buildContext context giving access to required meta data * @param properties all configuration properties * @return A new {@link BackendQueueProcessor} for the given index manager. */ public static BackendQueueProcessor createBackend(IndexManager indexManager, WorkerBuildContext buildContext, Properties properties) { IndexManagerGroupHolder groupHolder = getGroupHolder( indexManager, buildContext ); Backend backend = groupHolder.getOrCreateBackend( indexManager.getIndexName(), properties, buildContext ); return backend.createQueueProcessor( indexManager, buildContext ); } /**
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); }
/** * @param indexManager the index manager * @param buildContext context giving access to required meta data * @param properties all configuration properties * @return A new {@link BackendQueueProcessor} for the given index manager. */ public static BackendQueueProcessor createBackend(IndexManager indexManager, WorkerBuildContext buildContext, Properties properties) { IndexManagerGroupHolder groupHolder = getGroupHolder( indexManager, buildContext ); Backend backend = groupHolder.getOrCreateBackend( indexManager.getIndexName(), properties, buildContext ); return backend.createQueueProcessor( indexManager, buildContext ); } /**
@Override public void initialize(String indexName, Properties properties, Similarity similarity, WorkerBuildContext context) { this.serviceManager = context.getServiceManager(); this.indexName = getIndexName( indexName, properties ); try ( ServiceReference<ConfigurationPropertiesProvider> propertiesProvider = serviceManager.requestReference( ConfigurationPropertiesProvider.class ) ) { this.indexManagementStrategy = getIndexManagementStrategy( propertiesProvider.get().getProperties() ); this.indexManagementWaitTimeout = getIndexManagementWaitTimeout( propertiesProvider.get().getProperties() ); } this.actualIndexName = IndexNameNormalizer.getElasticsearchIndexName( this.indexName ); this.similarity = similarity; this.backend = BackendFactory.createBackend( this, context, properties ); }
public ExclusiveIndexWorkspaceImpl(DirectoryBasedIndexManager indexManager, WorkerBuildContext context, Properties cfg) { super( indexManager, context, cfg ); boolean async = ! BackendFactory.isConfiguredAsSync( cfg ); if ( async ) { int commitInterval = PropertiesParseHelper.extractFlushInterval( indexManager.getIndexName(), cfg ); ErrorHandler errorHandler = context.getErrorHandler(); commitPolicy = new ScheduledCommitPolicy( writerHolder, indexManager.getIndexName(), commitInterval, errorHandler ); } else { commitPolicy = new PerChangeSetCommitPolicy( writerHolder ); } }
/** * @param backendName the name of the backend to be created * @param indexManager the index manager * @param buildContext context giving access to required meta data * @param properties all configuration properties * @return A new {@link BackendQueueProcessor} for the given index manager. */ public static BackendQueueProcessor createBackend(String backendName, IndexManager indexManager, WorkerBuildContext buildContext, Properties properties) { IndexManagerGroupHolder groupHolder = getGroupHolder( indexManager, buildContext ); Backend backend = groupHolder.getOrCreateBackend( backendName, indexManager.getIndexName(), properties, buildContext ); return backend.createQueueProcessor( indexManager, buildContext ); }
public ExclusiveIndexWorkspaceImpl(DirectoryBasedIndexManager indexManager, WorkerBuildContext context, Properties cfg) { super( indexManager, context, cfg ); boolean async = ! BackendFactory.isConfiguredAsSync( cfg ); if ( async ) { int commitInterval = PropertiesParseHelper.extractFlushInterval( indexManager.getIndexName(), cfg ); ErrorHandler errorHandler = context.getErrorHandler(); commitPolicy = new ScheduledCommitPolicy( writerHolder, indexManager.getIndexName(), commitInterval, errorHandler ); } else { commitPolicy = new PerChangeSetCommitPolicy( writerHolder ); } }
/** * @param backendName the name of the backend to be created * @param indexManager the index manager * @param buildContext context giving access to required meta data * @param properties all configuration properties * @return A new {@link BackendQueueProcessor} for the given index manager. */ public static BackendQueueProcessor createBackend(String backendName, IndexManager indexManager, WorkerBuildContext buildContext, Properties properties) { IndexManagerGroupHolder groupHolder = getGroupHolder( indexManager, buildContext ); Backend backend = groupHolder.getOrCreateBackend( backendName, indexManager.getIndexName(), properties, buildContext ); return backend.createQueueProcessor( indexManager, buildContext ); }
@Override public void initialize(Properties properties, WorkerBuildContext context) { this.properties = properties; serviceManager = context.getServiceManager(); /* * This service in particular must be started eagerly, because it sets up * the message consumers, allowing slaves to send messages to the master. * Note that slaves may create index managers before the master, * in particular when dynamic sharding is used. */ messageSender = serviceManager.requestService( MessageSenderService.class ); luceneWorkSerializer = serviceManager.requestService( LuceneWorkSerializer.class ); masterNodeSelector = serviceManager.requestService( NodeSelectorService.class ); sync = BackendFactory.isConfiguredAsSync( properties ); Properties jgroupsProperties = new MaskedProperty( properties, JGROUPS_CONFIGURATION_SPACE ); block = ConfigurationParseHelper.getBooleanValue( jgroupsProperties, BLOCK_WAITING_ACK, sync ); messageTimeout = ConfigurationParseHelper.getLongValue( jgroupsProperties, MESSAGE_TIMEOUT_MS, DEFAULT_MESSAGE_TIMEOUT ); delegateBackendName = ConfigurationParseHelper.getString( jgroupsProperties, DELEGATE_BACKEND, "local" ); }
public void initialize(Properties props, WorkerBuildContext context, IndexManager indexManager) { sync = BackendFactory.isConfiguredAsSync( props ); if ( workspaceOverride == null ) { workspaceOverride = WorkspaceFactory.createWorkspace( (DirectoryBasedIndexManager) indexManager, context, props ); } resources = new LuceneBackendResources( context, (DirectoryBasedIndexManager) indexManager, props, workspaceOverride ); streamWorker = new LuceneBackendTaskStreamer( resources ); String indexName = indexManager.getIndexName(); if ( sync ) { final SyncWorkProcessor batchSyncProcessor = new SyncWorkProcessor( resources, indexName ); batchSyncProcessor.start(); log.luceneBackendInitializedSynchronously( indexName ); workProcessor = batchSyncProcessor; } else { workProcessor = new AsyncWorkProcessor( resources ); log.luceneBackendInitializedAsynchronously( indexName ); } }
public void initialize(Properties props, WorkerBuildContext context, IndexManager indexManager) { sync = BackendFactory.isConfiguredAsSync( props ); if ( workspaceOverride == null ) { workspaceOverride = WorkspaceFactory.createWorkspace( (DirectoryBasedIndexManager) indexManager, context, props ); } resources = new LuceneBackendResources( context, (DirectoryBasedIndexManager) indexManager, props, workspaceOverride ); streamWorker = new LuceneBackendTaskStreamer( resources ); String indexName = indexManager.getIndexName(); if ( sync ) { final SyncWorkProcessor batchSyncProcessor = new SyncWorkProcessor( resources, indexName ); batchSyncProcessor.start(); log.luceneBackendInitializedSynchronously( indexName ); workProcessor = batchSyncProcessor; } else { workProcessor = new AsyncWorkProcessor( resources ); log.luceneBackendInitializedAsynchronously( indexName ); } }
@Override public void initialize(String directoryProviderName, Properties properties, BuildContext context) { this.directoryProviderName = directoryProviderName; this.serviceManager = context.getServiceManager(); this.cacheManager = serviceManager.requestService(CacheManagerService.class).getEmbeddedCacheManager(); metadataCacheName = InfinispanIntegration.getMetadataCacheName(properties); dataCacheName = InfinispanIntegration.getDataCacheName(properties); lockingCacheName = InfinispanIntegration.getLockingCacheName(properties); //Let it return null if it's not set, so that we can avoid applying any override. chunkSize = ConfigurationParseHelper.getIntValue(properties, "chunk_size"); writeFileListAsync = getWriteFileListAsync(properties); //Only override the default Infinispan LockDirectory if an explicit option is set: if (configurationExplicitlySetsLockFactory(properties)) { Path verifiedIndexDir = null; if (isNativeLockingStrategy(properties)) { verifiedIndexDir = DirectoryHelper.getVerifiedIndexPath( directoryProviderName, properties, true ); } indexWriterLockFactory = getLockFactory(verifiedIndexDir, properties); } this.isAsync = !BackendFactory.isConfiguredAsSync(properties); }
this.actualIndexName = ElasticsearchIndexNameNormalizer.getElasticsearchIndexName( overriddenIndexName ); this.refreshAfterWrite = getRefreshAfterWrite( properties ); this.sync = BackendFactory.isConfiguredAsSync( properties );
this.actualIndexName = ElasticsearchIndexNameNormalizer.getElasticsearchIndexName( overriddenIndexName ); this.refreshAfterWrite = getRefreshAfterWrite( properties ); this.sync = BackendFactory.isConfiguredAsSync( properties );
@Override public void initialize(String indexName, Properties properties, Similarity similarity, WorkerBuildContext buildContext) { ServiceManager serviceManager = buildContext.getServiceManager(); ComponentRegistryService componentRegistryService = serviceManager.requestService(ComponentRegistryService.class); ComponentRegistry componentRegistry = componentRegistryService.getComponentRegistry(); transactionHelper = new TransactionHelper(componentRegistry.getComponent(TransactionManager.class)); shardId = this.extractShardName(indexName); Transaction tx = transactionHelper.suspendTxIfExists(); try { super.initialize(indexName, properties, similarity, buildContext); } finally { transactionHelper.resume(tx); } RpcManager rpcManager = componentRegistry.getComponent(RpcManager.class); cache = componentRegistry.getComponent(Cache.class); keyTransformationHandler = componentRegistry.getComponent(QueryInterceptor.class).getKeyTransformationHandler(); shardAllocatorManager = componentRegistry.getComponent(ShardAllocatorManager.class); searchIntegrator = componentRegistry.getComponent(SearchIntegrator.class); isAsync = !BackendFactory.isConfiguredAsSync(properties); localShardAddress = new ShardAddress(shardId, rpcManager != null ? rpcManager.getAddress() : LocalModeAddress.INSTANCE); ExecutorService asyncExecutor = componentRegistry.getComponent(ExecutorService.class, ASYNC_OPERATIONS_EXECUTOR); luceneWorkDispatcher = new LuceneWorkDispatcher(this, rpcManager); workPartitioner = new WorkPartitioner(this, shardAllocatorManager); AffinityErrorHandler errorHandler = (AffinityErrorHandler) searchIntegrator.getErrorHandler(); errorHandler.initialize(rpcManager, asyncExecutor); cache.addListener(this); }
@Override public void initialize(String indexName, Properties properties, Similarity similarity, WorkerBuildContext buildContext) { ServiceManager serviceManager = buildContext.getServiceManager(); ComponentRegistryService componentRegistryService = serviceManager.requestService(ComponentRegistryService.class); ComponentRegistry componentRegistry = componentRegistryService.getComponentRegistry(); transactionHelper = new TransactionHelper(componentRegistry.getComponent(TransactionManager.class)); shardId = this.extractShardName(indexName); Transaction tx = transactionHelper.suspendTxIfExists(); try { super.initialize(indexName, properties, similarity, buildContext); } finally { transactionHelper.resume(tx); } RpcManager rpcManager = componentRegistry.getComponent(RpcManager.class); cache = componentRegistry.getComponent(Cache.class); keyTransformationHandler = componentRegistry.getComponent(QueryInterceptor.class).getKeyTransformationHandler(); shardAllocatorManager = componentRegistry.getComponent(ShardAllocatorManager.class); searchIntegrator = componentRegistry.getComponent(SearchIntegrator.class); isAsync = !BackendFactory.isConfiguredAsSync(properties); localShardAddress = new ShardAddress(shardId, rpcManager != null ? rpcManager.getAddress() : LocalModeAddress.INSTANCE); ExecutorService asyncExecutor = componentRegistry.getComponent(ExecutorService.class, ASYNC_OPERATIONS_EXECUTOR); luceneWorkDispatcher = new LuceneWorkDispatcher(this, rpcManager); workPartitioner = new WorkPartitioner(this, shardAllocatorManager); AffinityErrorHandler errorHandler = (AffinityErrorHandler) searchIntegrator.getErrorHandler(); errorHandler.initialize(rpcManager, asyncExecutor); cache.addListener(this); }