Search in sources :

Example 1 with BasicIndexer

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();
    }
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) Indexer(com.tuplejump.stargate.lucene.Indexer) BasicIndexer(com.tuplejump.stargate.lucene.BasicIndexer) BasicIndexer(com.tuplejump.stargate.lucene.BasicIndexer) Token(org.apache.cassandra.dht.Token) Range(org.apache.cassandra.dht.Range)

Example 2 with BasicIndexer

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);
    }
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) BasicIndexer(com.tuplejump.stargate.lucene.BasicIndexer)

Aggregations

BasicIndexer (com.tuplejump.stargate.lucene.BasicIndexer)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Indexer (com.tuplejump.stargate.lucene.Indexer)1 Range (org.apache.cassandra.dht.Range)1 Token (org.apache.cassandra.dht.Token)1