public void ingest(IndexOperationMessage singleMessage) { this.indexRequests.addAll(singleMessage.getIndexRequests()); this.deIndexRequests.addAll(singleMessage.getDeIndexRequests()); } }
@Override public int size() { return container.getDeIndexRequests().size() + container.getIndexRequests().size(); } }
public Observable<IndexOperationMessage> put( IndexOperationMessage message ) { Preconditions.checkNotNull(message, "Message cannot be null"); indexSizeCounter.inc(message.getDeIndexRequests().size()); indexSizeCounter.inc(message.getIndexRequests().size()); return processBatch(message); }
/** * this method will call initialize for each message, since we are caching the entity indexes, * we don't worry about aggregating by app id * @param indexOperationMessage */ private void initializeEntityIndexes(final IndexOperationMessage indexOperationMessage) { // create a set so we can have a unique list of appIds for which we call createEntityIndex Set<UUID> appIds = new HashSet<>(); // loop through all indexRequests and add the appIds to the set indexOperationMessage.getIndexRequests().forEach(req -> { UUID appId = IndexingUtils.getApplicationIdFromIndexDocId(req.documentId); appIds.add(appId); }); // loop through all deindexRequests and add the appIds to the set indexOperationMessage.getDeIndexRequests().forEach(req -> { UUID appId = IndexingUtils.getApplicationIdFromIndexDocId(req.documentId); appIds.add(appId); }); // for each of the appIds in the unique set, call create entity index to ensure the aliases are created appIds.forEach(appId -> { ApplicationScope appScope = CpNamingUtils.getApplicationScope(appId); entityIndexFactory.createEntityIndex(indexLocationStrategyFactory.getIndexLocationStrategy(appScope)); } ); }
final Set<IndexOperation> indexOperationSet = batch.getIndexRequests(); final Set<DeIndexOperation> deIndexOperationSet = batch.getDeIndexRequests(); indexSizeCounter.dec(deIndexOperationSetSize); final Observable<IndexOperation> index = Observable.from(batch.getIndexRequests()); final Observable<DeIndexOperation> deIndex = Observable.from(batch.getDeIndexRequests());
@Test public void testSingleIndexFromSource() { final Entity entity = new Entity( createId( "test" ), UUIDGenerator.newTimeUUID() ); entity.setField( new StringField( "string", "foo" ) ); final Edge collectionEdge = createCollectionEdge( applicationScope.getApplication(), "tests", entity.getId() ); //write the edge graphManager.writeEdge( collectionEdge ).toBlocking().last(); //index the edge final Observable<IndexOperationMessage> indexed = indexService.indexEntity( applicationScope, entity ); //real users should never call to blocking, we're not sure what we'll get final IndexOperationMessage results = indexed.toBlocking().last(); indexProducer.put(results).subscribe(); final Set<IndexOperation> indexRequests = results.getIndexRequests(); //ensure our value made it to the index request final IndexOperation indexRequest = indexRequests.iterator().next(); assertNotNull( indexRequest ); }