예제 #1
0
  public IndexService(
      IndexSettings indexSettings,
      NodeEnvironment nodeEnv,
      SimilarityService similarityService,
      ShardStoreDeleter shardStoreDeleter,
      AnalysisRegistry registry,
      @Nullable EngineFactory engineFactory,
      NodeServicesProvider nodeServicesProvider,
      QueryCache queryCache,
      IndexStore indexStore,
      IndexEventListener eventListener,
      IndexModule.IndexSearcherWrapperFactory wrapperFactory,
      MapperRegistry mapperRegistry,
      IndexingOperationListener... listenersIn)
      throws IOException {
    super(indexSettings);
    this.indexSettings = indexSettings;
    this.analysisService = registry.build(indexSettings);
    this.similarityService = similarityService;
    this.mapperService =
        new MapperService(
            indexSettings,
            analysisService,
            similarityService,
            mapperRegistry,
            IndexService.this::getQueryShardContext);
    this.indexFieldData =
        new IndexFieldDataService(
            indexSettings,
            nodeServicesProvider.getIndicesFieldDataCache(),
            nodeServicesProvider.getCircuitBreakerService(),
            mapperService);
    this.shardStoreDeleter = shardStoreDeleter;
    this.eventListener = eventListener;
    this.nodeEnv = nodeEnv;
    this.nodeServicesProvider = nodeServicesProvider;
    this.indexStore = indexStore;
    indexFieldData.setListener(new FieldDataCacheListener(this));
    this.bitsetFilterCache =
        new BitsetFilterCache(
            indexSettings, nodeServicesProvider.getWarmer(), new BitsetCacheListener(this));
    this.indexCache = new IndexCache(indexSettings, queryCache, bitsetFilterCache);
    this.engineFactory = engineFactory;
    // initialize this last -- otherwise if the wrapper requires any other member to be non-null we
    // fail with an NPE
    this.searcherWrapper = wrapperFactory.newWrapper(this);
    this.slowLog = new IndexingSlowLog(indexSettings.getSettings());

    // Add our slowLog to the incoming IndexingOperationListeners:
    this.listeners = new IndexingOperationListener[1 + listenersIn.length];
    this.listeners[0] = slowLog;
    System.arraycopy(listenersIn, 0, this.listeners, 1, listenersIn.length);
    // kick off async ops for the first shard in this index
    if (this.indexSettings.getTranslogSyncInterval().millis() != 0) {
      this.fsyncTask = new AsyncTranslogFSync(this);
    } else {
      this.fsyncTask = null;
    }
    this.refreshTask = new AsyncRefreshTask(this);
  }
예제 #2
0
 public IndexService(
     IndexSettings indexSettings,
     NodeEnvironment nodeEnv,
     SimilarityService similarityService,
     ShardStoreDeleter shardStoreDeleter,
     AnalysisRegistry registry,
     @Nullable EngineFactory engineFactory,
     NodeServicesProvider nodeServicesProvider,
     QueryCache queryCache,
     IndexStore indexStore,
     IndexEventListener eventListener,
     IndexModule.IndexSearcherWrapperFactory wrapperFactory,
     MapperRegistry mapperRegistry,
     IndicesFieldDataCache indicesFieldDataCache,
     List<SearchOperationListener> searchOperationListeners,
     List<IndexingOperationListener> indexingOperationListeners)
     throws IOException {
   super(indexSettings);
   this.indexSettings = indexSettings;
   this.analysisService = registry.build(indexSettings);
   this.similarityService = similarityService;
   this.mapperService =
       new MapperService(
           indexSettings,
           analysisService,
           similarityService,
           mapperRegistry,
           IndexService.this::newQueryShardContext);
   this.indexFieldData =
       new IndexFieldDataService(
           indexSettings,
           indicesFieldDataCache,
           nodeServicesProvider.getCircuitBreakerService(),
           mapperService);
   this.shardStoreDeleter = shardStoreDeleter;
   this.bigArrays = nodeServicesProvider.getBigArrays();
   this.threadPool = nodeServicesProvider.getThreadPool();
   this.eventListener = eventListener;
   this.nodeEnv = nodeEnv;
   this.nodeServicesProvider = nodeServicesProvider;
   this.indexStore = indexStore;
   indexFieldData.setListener(new FieldDataCacheListener(this));
   this.bitsetFilterCache = new BitsetFilterCache(indexSettings, new BitsetCacheListener(this));
   this.warmer =
       new IndexWarmer(
           indexSettings.getSettings(), threadPool, bitsetFilterCache.createListener(threadPool));
   this.indexCache = new IndexCache(indexSettings, queryCache, bitsetFilterCache);
   this.engineFactory = engineFactory;
   // initialize this last -- otherwise if the wrapper requires any other member to be non-null we
   // fail with an NPE
   this.searcherWrapper = wrapperFactory.newWrapper(this);
   this.indexingOperationListeners = Collections.unmodifiableList(indexingOperationListeners);
   this.searchOperationListeners = Collections.unmodifiableList(searchOperationListeners);
   // kick off async ops for the first shard in this index
   this.refreshTask = new AsyncRefreshTask(this);
   rescheduleFsyncTask(indexSettings.getTranslogDurability());
 }