@Override protected GraphNode generateData( final EntityIdScope entityIdScope ) { return new GraphNode(entityIdScope.getApplicationScope(), entityIdScope.getId()); } }
public void indexBatch(final List<EdgeScope> edges, final long updatedSince, AsyncEventQueueType queueType) { final List<EntityIndexEvent> batch = new ArrayList<>(); edges.forEach(e -> { //change to id scope to avoid serialization issues batch.add(new EntityIndexEvent(queueFig.getPrimaryRegion(), new EntityIdScope(e.getApplicationScope(), e.getEdge().getTargetNode()), updatedSince)); }); if (logger.isTraceEnabled()) { logger.trace("Offering batch of EntityIndexEvent of size {}", batch.size()); } offerBatch( batch, queueType ); }
.map(entityIdScope -> ((EntityIdScope) entityIdScope).getId()) .filter(id -> { final String type = InflectionUtils.pluralize(((Id) id).getType());
private IndexOperationMessage handleEntityDelete(final LegacyQueueMessage message) { Preconditions.checkNotNull(message, "Queue Message cannot be null for handleEntityDelete"); final AsyncEvent event = (AsyncEvent) message.getBody(); Preconditions.checkNotNull( message, "QueueMessage Body cannot be null for handleEntityDelete" ); Preconditions.checkArgument( event instanceof EntityDeleteEvent, String.format( "Event Type for handleEntityDelete must be ENTITY_DELETE, got %s", event.getClass() ) ); final EntityDeleteEvent entityDeleteEvent = ( EntityDeleteEvent ) event; final ApplicationScope applicationScope = entityDeleteEvent.getEntityIdScope().getApplicationScope(); final Id entityId = entityDeleteEvent.getEntityIdScope().getId(); final boolean isCollectionDelete = entityDeleteEvent.isCollectionDelete(); final long updatedBefore = entityDeleteEvent.getUpdatedBefore(); if (logger.isDebugEnabled()) { logger.debug("Deleting entity id from index in app scope {} with entityId {}, isCollectionDelete {}, updatedBefore {}", applicationScope, entityId, isCollectionDelete, updatedBefore); } return eventBuilder.buildEntityDelete( applicationScope, entityId, isCollectionDelete, updatedBefore ); }
@Override public void queueEntityDelete(final ApplicationScope applicationScope, final Id entityId) { if (logger.isTraceEnabled()) { logger.trace("Offering EntityDeleteEvent for {}:{}", entityId.getUuid(), entityId.getType()); } // sent in region (not offerTopic) as the delete IO happens in-region, then queues a multi-region de-index op offer( new EntityDeleteEvent(queueFig.getPrimaryRegion(), new EntityIdScope( applicationScope, entityId ) ), AsyncEventQueueType.DELETE , null); }
public IndexOperationMessage handleDeIndexOldVersionEvent ( final DeIndexOldVersionsEvent deIndexOldVersionsEvent){ final ApplicationScope applicationScope = deIndexOldVersionsEvent.getEntityIdScope().getApplicationScope(); final Id entityId = deIndexOldVersionsEvent.getEntityIdScope().getId(); final UUID markedVersion = deIndexOldVersionsEvent.getMarkedVersion(); // default this observable's return to empty index operation message if nothing is emitted return eventBuilder.deIndexOldVersions( applicationScope, entityId, markedVersion ) .toBlocking().lastOrDefault(new IndexOperationMessage()); }
public void deleteBatch(final List<EdgeScope> edges, final long updatedBefore, AsyncEventQueueType queueType) { final List<EntityDeleteEvent> batch = new ArrayList<>(); edges.forEach(e -> { //change to id scope to avoid serialization issues batch.add(new EntityDeleteEvent(queueFig.getPrimaryRegion(), new EntityIdScope(e.getApplicationScope(), e.getEdge().getTargetNode()), true, updatedBefore)); }); offerBatch(batch, queueType); }
private IndexOperationMessage handleEntityIndexUpdate(final LegacyQueueMessage message) { Preconditions.checkNotNull( message, "Queue Message cannot be null for handleEntityIndexUpdate" ); final AsyncEvent event = ( AsyncEvent ) message.getBody(); Preconditions.checkNotNull(message, "QueueMessage Body cannot be null for handleEntityIndexUpdate"); Preconditions.checkArgument(event instanceof EntityIndexEvent, String.format("Event Type for handleEntityIndexUpdate must be ENTITY_INDEX, got %s", event.getClass())); final EntityIndexEvent entityIndexEvent = (EntityIndexEvent) event; //process the entity immediately //only process the same version, otherwise ignore final EntityIdScope entityIdScope = entityIndexEvent.getEntityIdScope(); final ApplicationScope applicationScope = entityIdScope.getApplicationScope(); final Id entityId = entityIdScope.getId(); final long updatedAfter = entityIndexEvent.getUpdatedAfter(); final EntityIndexOperation entityIndexOperation = new EntityIndexOperation( applicationScope, entityId, updatedAfter); // default this observable's return to empty index operation message if nothing is emitted return eventBuilder.buildEntityIndex( entityIndexOperation ) .toBlocking().lastOrDefault(new IndexOperationMessage()); }
@Override public Observable<EntityIdScope> getEntities( final Observable<ApplicationScope> appScopes ) { return appScopes.flatMap( applicationScope -> { final GraphManager gm = graphManagerFactory.createEdgeManager( applicationScope ); final Id applicationId = applicationScope.getApplication(); //load all nodes that are targets of our application node. I.E. // entities that have been saved final Observable<Id> entityNodes = targetIdObservable.getTargetNodes( gm, applicationId ); //create our application node to emit since it's an entity as well final Observable<Id> applicationNode = Observable.just( applicationId ); //merge both the specified application node and the entity node // so they all get used return Observable.merge( applicationNode, entityNodes ). map( id -> new EntityIdScope( applicationScope, id ) ); } ); }
final ApplicationScope applicationScope = entityIdScope.getApplicationScope(); final Id entityId = entityIdScope.getId();
@Override public void queueDeIndexOldVersion(final ApplicationScope applicationScope, final Id entityId, UUID markedVersion) { // queue the de-index of old versions to the topic so cleanup happens in all regions if (logger.isTraceEnabled()) { logger.trace("Offering DeIndexOldVersionsEvent for app {} {}:{}", applicationScope.getApplication().getUuid(), entityId.getUuid(), entityId.getType()); } offerTopic( new DeIndexOldVersionsEvent( queueFig.getPrimaryRegion(), new EntityIdScope( applicationScope, entityId), markedVersion), AsyncEventQueueType.DELETE ); }
@Override public void call( final EntityIdScope entityIdScope ) { assertNotNull(entityIdScope); assertNotNull(entityIdScope.getApplicationScope()); assertNotNull(entityIdScope.getId()); // we should only emit each node once final Id id = entityIdScope.getId(); if ( id.getType().equals( type1 ) ) { boolean removed = type1Identities.remove(id); assertTrue( "Element(a:"+counter.incrementAndGet()+") should be present on removal",type1Identities.size() ==0 || removed); } else if ( id.getType().equals( type2 ) ) { boolean removed = type2Identities.remove(id ); assertTrue( "Element(b:"+counter.incrementAndGet()+") should be present on removal",type2Identities.size() ==0 || removed ); } } } ).toBlocking().lastOrDefault( null );
@Override public void queueEntityIndexUpdate(final ApplicationScope applicationScope, final Entity entity, long updatedAfter, QueueIndexingStrategy queueIndexingStrategy) { if (logger.isTraceEnabled()) { logger.trace("Offering EntityIndexEvent for {}:{}", entity.getId().getUuid(), entity.getId().getType()); } EntityIndexEvent event = new EntityIndexEvent(queueFig.getPrimaryRegion(), new EntityIdScope(applicationScope, entity.getId()), updatedAfter); offer(event, queueIndexingStrategy); }
final ApplicationScope currentScope = entityIdScope.getApplicationScope(); migration.from.loadAscendingHistory( currentScope, entityIdScope.getId(), startTime, 100 );
Observable.just( new EntityIdScope( scope, entity1.getId() ), new EntityIdScope( scope, entity2.getId() ) );