Source:
<code>public void init() { EmbeddedCacheManager cacheManager; try { File cacheConfigFile = new File(configPath.toFile(), CACHE_CONFIGURATION); if (cacheConfigFile.exists()) { cacheManager = new DefaultCacheManager(cacheConfigFile.getPath()); } else { cacheManager = new DefaultCacheManager(InventoryConfig.class.getResourceAsStream("/" + CACHE_CONFIGURATION)); } resource = cacheManager.getCache(RESOURCE_CACHE_NAME); if (resource == null) { log.errorInventoryCacheNotFound(); throw new IllegalStateException("Inventory backend resource cache is not found"); } queryResource = Search.getQueryFactory(resource); if (queryResource == null) { log.errorInventoryCacheNotFound(); throw new IllegalStateException("Inventory query factory for resource cache is not found"); } resourceType = cacheManager.getCache(RESOURCE_TYPE_CACHE_NAME); if (resourceType == null) { log.errorInventoryCacheNotFound(); throw new IllegalStateException("Inventory backend resource_type cache is not found"); } queryResourceType = Search.getQueryFactory(resourceType); if (queryResourceType == null) { log.errorInventoryCacheNotFound(); throw new IllegalStateException("Inventory query factory for resource_type cache is not found"); } if (ispnReindex) { log.infoStartInventoryReindex(); long startReindex = System.currentTimeMillis(); SearchManager searchResourceManager = Search.getSearchManager(resource); <START> searchResourceManager.getMassIndexer().start(); <END> SearchManager searchResourceTypeManager = Search.getSearchManager(resourceType); searchResourceTypeManager.getMassIndexer().start(); long stopReindex = System.currentTimeMillis(); log.infoStopInventoryReindex((stopReindex - startReindex)); } log.infoInventoryAppStarted(); } catch (IOException e) { log.errorInventoryCacheConfigurationNotFound(e); } }</code><technical_language>If a time-consuming operation, a benefit run in parallel</technical_language>

Target:
public void init() { EmbeddedCacheManager cacheManager; try { File cacheConfigFile = new File(configPath.toFile(), CACHE_CONFIGURATION); if (cacheConfigFile.exists()) { cacheManager = new DefaultCacheManager(cacheConfigFile.getPath()); } else { cacheManager = new DefaultCacheManager(InventoryConfig.class.getResourceAsStream("/" + CACHE_CONFIGURATION)); } resource = cacheManager.getCache(RESOURCE_CACHE_NAME); if (resource == null) { log.errorInventoryCacheNotFound(); throw new IllegalStateException("Inventory backend resource cache is not found"); } queryResource = Search.getQueryFactory(resource); if (queryResource == null) { log.errorInventoryCacheNotFound(); throw new IllegalStateException("Inventory query factory for resource cache is not found"); } resourceType = cacheManager.getCache(RESOURCE_TYPE_CACHE_NAME); if (resourceType == null) { log.errorInventoryCacheNotFound(); throw new IllegalStateException("Inventory backend resource_type cache is not found"); } queryResourceType = Search.getQueryFactory(resourceType); if (queryResourceType == null) { log.errorInventoryCacheNotFound(); throw new IllegalStateException("Inventory query factory for resource_type cache is not found"); } if (ispnReindex) { log.infoStartInventoryReindex(); long startReindex = System.currentTimeMillis(); SearchManager searchResourceManager = Search.getSearchManager(resource); CompletableFuture<Void> reindexResource = searchResourceManager.getMassIndexer().startAsync(); SearchManager searchResourceTypeManager = Search.getSearchManager(resourceType); CompletableFuture<Void> reindexResourceType = searchResourceTypeManager.getMassIndexer().startAsync(); CompletableFuture.allOf(reindexResource, reindexResourceType).get(); long stopReindex = System.currentTimeMillis(); log.infoStopInventoryReindex((stopReindex - startReindex)); } log.infoInventoryAppStarted(); } catch (IOException e) { log.errorInventoryCacheConfigurationNotFound(e); } catch (Exception e) { log.errorReindexingCaches(e); } }