use of com.tuplejump.stargate.lucene.BasicIndexer in project stargate-core by tuplejump.
the class PerVNodeIndexContainer method updateIndexers.
@Override
public void updateIndexers(Collection<Range<Token>> ranges) {
writeLock.lock();
Boolean isInfoLoggingEnabled = logger.isInfoEnabled();
try {
if (indexers.isEmpty()) {
if (isInfoLoggingEnabled) {
logger.info("Adding VNode indexers");
}
for (Range<Token> range : ranges) {
String rangeStr = range.left.toString();
AtomicLong records = Stargate.getInstance().getAtomicLong(INDEX_RECORDS + "-" + indexName + "-" + rangeStr);
Indexer indexer = new BasicIndexer(records, analyzer, keyspace, cf, indexName, rangeStr);
indexers.put(range, indexer);
if (isInfoLoggingEnabled) {
logger.info("Added VNode indexers for range {}", range);
}
}
} else {
if (isInfoLoggingEnabled) {
logger.info("Change in VNode indexers");
}
HashMap<Range<Token>, Indexer> indexersToRemove = new HashMap<>(indexers);
for (Range<Token> range : ranges) {
indexersToRemove.remove(range);
}
for (Map.Entry<Range<Token>, Indexer> entry : indexersToRemove.entrySet()) {
if (isInfoLoggingEnabled) {
logger.info("Removing indexer for range {}", entry.getKey());
}
Indexer indexer = indexers.remove(entry.getKey());
indexer.removeIndex();
if (isInfoLoggingEnabled) {
logger.info("Removed indexer for range {}", entry.getKey());
}
}
}
} finally {
writeLock.unlock();
}
}
use of com.tuplejump.stargate.lucene.BasicIndexer in project stargate-core by tuplejump.
the class MonolithIndexContainer method updateIndexers.
@Override
public void updateIndexers(Collection<Range<Token>> ranges) {
if (indexer == null) {
if (logger.isInfoEnabled()) {
logger.info("Adding Monolith indexer");
}
String rangeStr = "allVNodes";
AtomicLong records = Stargate.getInstance().getAtomicLong(INDEX_RECORDS + "-" + indexName + "-" + rangeStr);
indexer = new BasicIndexer(records, analyzer, keyspace, cf, indexName, rangeStr);
}
}
Aggregations