private IndexingManager() { try { registry = Utils.getRegistryService().getRegistry(CarbonConstants.REGISTRY_SYSTEM_USERNAME); registryConfig = RegistryConfigLoader.getInstance(); indexer = new AsyncIndexer(); } catch (RegistryException e) { log.error("Could not initialize registry for indexing", e); } }
/** * Method for get the pre-defined Indexer matches for the resource mediaType. Reads the registry * configurations for indexing in Registry.xml and check for Indexer with mediaType provided. * * @param mimeType mediaType * @return Indexer */ public Indexer getIndexerForMediaType(String mimeType) { if (mimeType != null) { for (Map.Entry<String, Indexer> entry : registryConfig.getIndexerMap().entrySet()) { if (Pattern.matches(entry.getKey(), mimeType)) { return entry.getValue(); } } } return null; }
public boolean canIndex(String path) { if (patterns == null) { patterns = registryConfig.getExclusionPatterns(); } for (Pattern pattern : patterns) { if (pattern.matcher(path).matches()) { return false; } } return true; }
public synchronized void startIndexing() { stopIndexing(); // stop executors if they are already running, otherwise they will never stop if (registryConfig.IsStartIndexing()) { submittingExecutor = Executors.newSingleThreadScheduledExecutor(); submittingExecutor.scheduleWithFixedDelay( new ResourceSubmitter(this), getStartingDelayInSecs(), getIndexingFreqInSecs(), TimeUnit.SECONDS); indexingExecutor = Executors.newSingleThreadScheduledExecutor(); indexingExecutor.scheduleWithFixedDelay( indexer, getStartingDelayInSecs(), getIndexingFreqInSecs(), TimeUnit.SECONDS); readLastAccessTime(); } }
/** * This is to get the indexing worker thread pool size. * * @return pool size */ public int getIndexerPoolSize() { return registryConfig.getIndexerPoolSize(); }
public long getBatchSize() { return registryConfig.getBatchSize(); }
public String getLastAccessTimeLocation() { return registryConfig.getLastAccessTimeLocation(); }
public long getIndexingFreqInSecs() { return registryConfig.getIndexingFreqInSecs(); }
public long getStartingDelayInSecs() { return registryConfig.getStartingDelayInSecs(); }