public List<LuceneIndex> getIndexes(String regionPath) { List<LuceneIndex> indexes = new ArrayList(); for (LuceneIndex index : getAllIndexes()) { if (index.getRegionPath().equals(regionPath)) { indexes.add(index); } } return Collections.unmodifiableList(indexes); }
private String getMonitorKey(LuceneIndex index) { return index.getRegionPath() + "_" + index.getName(); }
public LuceneIndexMetrics[] listIndexMetrics(String regionPath) { if (!regionPath.startsWith(Region.SEPARATOR)) { regionPath = Region.SEPARATOR + regionPath; } List<LuceneIndexMetrics> indexMetrics = new ArrayList(); for (LuceneIndex index : this.service.getAllIndexes()) { if (index.getRegionPath().equals(regionPath)) { indexMetrics.add(getIndexMetrics(index)); } } return indexMetrics.toArray(new LuceneIndexMetrics[indexMetrics.size()]); }
private void removeFromIndexMap(LuceneIndex index) { indexMap.remove(getUniqueIndexName(index.getName(), index.getRegionPath())); }
private void registerIndex(LuceneIndex index) { String regionAndIndex = getUniqueIndexName(index.getName(), index.getRegionPath()); if (hasIndexBeenDestroyed(regionAndIndex)) { ((InternalLuceneIndex) index).destroy(true); throw new LuceneIndexDestroyedException(index.getName(), index.getRegionPath()); } else { if (!indexMap.containsKey(regionAndIndex)) { indexMap.put(regionAndIndex, index); } definedIndexMap.remove(regionAndIndex); } }
protected void destroyIndexes(String regionPath, boolean initiator) { if (!regionPath.startsWith("/")) { regionPath = "/" + regionPath; } List<LuceneIndexImpl> indexesToDestroy = new ArrayList<>(); for (LuceneIndex index : getAllIndexes()) { if (index.getRegionPath().equals(regionPath)) { LuceneIndexImpl indexImpl = (LuceneIndexImpl) index; indexImpl.destroy(initiator); indexesToDestroy.add(indexImpl); } } // If list is empty throw an exception; otherwise iterate and destroy the defined index if (indexesToDestroy.isEmpty()) { throw new IllegalArgumentException( String.format("No Lucene indexes were found in region %s", regionPath)); } else { for (LuceneIndex index : indexesToDestroy) { removeFromIndexMap(index); logger.info(String.format("Destroyed Lucene index %s from %s region %s", index.getName(), "initialized", regionPath)); } } }
protected LuceneIndexMetrics getIndexMetrics(LuceneIndex index) { int queryExecutions = getStatistic(StatsKey.QUERIES).intValue(); long queryExecutionTime = getStatistic(StatsKey.QUERY_TIME).longValue(); long queryRateAverageLatencyValue = this.queryRateAverageLatency.getAverageLatency(); int queryExecutionsInProgress = getStatistic(StatsKey.QUERIES_IN_PROGRESS).intValue(); long queryExecutionTotalHits = getStatistic(StatsKey.QUERIES_TOTAL_HITS).longValue(); int updates = getStatistic(StatsKey.UPDATES).intValue(); long updateTime = getStatistic(StatsKey.UPDATE_TIME).longValue(); long updateRateAverageLatencyValue = this.updateRateAverageLatency.getAverageLatency(); int updatesInProgress = getStatistic(StatsKey.UPDATES_IN_PROGRESS).intValue(); int commits = getStatistic(StatsKey.COMMITS).intValue(); long commitTime = getStatistic(StatsKey.COMMIT_TIME).longValue(); long commitRateAverageLatencyValue = this.commitRateAverageLatency.getAverageLatency(); int commitsInProgress = getStatistic(StatsKey.COMMITS_IN_PROGRESS).intValue(); int documents = getStatistic(StatsKey.DOCUMENTS).intValue(); return new LuceneIndexMetrics(index.getRegionPath(), index.getName(), queryExecutions, queryExecutionTime, queryRateAverageLatencyValue, queryExecutionsInProgress, queryExecutionTotalHits, updates, updateTime, updateRateAverageLatencyValue, updatesInProgress, commits, commitTime, commitRateAverageLatencyValue, commitsInProgress, documents); } }
public LuceneIndexStatsMonitor(LuceneIndex index) { super(LUCENE_SERVICE_MXBEAN_MONITOR_PREFIX + index.getRegionPath() + "_" + index.getName()); addStatisticsToMonitor(((LuceneIndexImpl) index).getIndexStats().getStats()); configureMetrics(); }
when(mockLuceneIndex.getLuceneSerializer()).thenAnswer(in -> luceneSerializerReference.get()); when(mockLuceneIndex.getName()).thenReturn(indexName); when(mockLuceneIndex.getRegionPath()).thenReturn(regionPath);
/** * @inheritDoc */ @Override @SuppressWarnings("all") public void destroy() throws Exception { LuceneIndex luceneIndex = getObject(); if (isLuceneIndexDestroyable(luceneIndex)) { resolveLuceneService().destroyIndex(luceneIndex.getName(), luceneIndex.getRegionPath()); } }
/** * @inheritDoc */ @Override @SuppressWarnings("all") public void destroy() throws Exception { LuceneIndex luceneIndex = getObject(); if (isLuceneIndexDestroyable(luceneIndex)) { resolveLuceneService().destroyIndex(luceneIndex.getName(), luceneIndex.getRegionPath()); } }