@Override
 public void forceEverything() {
   indexingService.flushAll();
   labelScanStore.force();
   for (IndexImplementation index : indexProviders.values()) {
     index.force();
   }
   neoStore.flush();
 }
Esempio n. 2
0
  private Pair<Map<String, String>, Boolean /*true=needs to be set*/> findIndexConfig(
      Class<? extends PropertyContainer> cls,
      String indexName,
      Map<String, String> suppliedConfig,
      Map<?, ?> dbConfig) {
    // Check stored config (has this index been created previously?)
    Map<String, String> storedConfig = indexStore.get(cls, indexName);
    if (storedConfig != null && suppliedConfig == null) {
      // Fill in "provider" if not already filled in, backwards compatibility issue
      Map<String, String> newConfig =
          injectDefaultProviderIfMissing(cls, indexName, dbConfig, storedConfig);
      if (newConfig != storedConfig) {
        indexStore.set(cls, indexName, newConfig);
      }
      return Pair.of(newConfig, Boolean.FALSE);
    }

    Map<String, String> configToUse = suppliedConfig;

    // Check db config properties for provider
    String provider = null;
    IndexImplementation indexProvider = null;
    if (configToUse == null) {
      provider = getDefaultProvider(indexName, dbConfig);
      configToUse = MapUtil.stringMap(PROVIDER, provider);
    } else {
      provider = configToUse.get(PROVIDER);
      provider = provider == null ? getDefaultProvider(indexName, dbConfig) : provider;
    }
    indexProvider = getIndexProvider(provider);
    configToUse = indexProvider.fillInDefaults(configToUse);
    configToUse = injectDefaultProviderIfMissing(cls, indexName, dbConfig, configToUse);

    // Do they match (stored vs. supplied)?
    if (storedConfig != null) {
      assertConfigMatches(indexProvider, indexName, storedConfig, suppliedConfig);
      // Fill in "provider" if not already filled in, backwards compatibility issue
      Map<String, String> newConfig =
          injectDefaultProviderIfMissing(cls, indexName, dbConfig, storedConfig);
      if (newConfig != storedConfig) {
        indexStore.set(cls, indexName, newConfig);
      }
      configToUse = newConfig;
    }

    boolean needsToBeSet = !indexStore.has(cls, indexName);
    return Pair.of(Collections.unmodifiableMap(configToUse), needsToBeSet);
  }
Esempio n. 3
0
 private void assertConfigMatches(
     IndexImplementation indexProvider,
     String indexName,
     Map<String, String> storedConfig,
     Map<String, String> suppliedConfig) {
   if (suppliedConfig != null && !indexProvider.configMatches(storedConfig, suppliedConfig)) {
     throw new IllegalArgumentException(
         "Supplied index configuration:\n"
             + suppliedConfig
             + "\ndoesn't match stored config in a valid way:\n"
             + storedConfig
             + "\nfor '"
             + indexName
             + "'");
   }
 }