@Override public String toString(){ return "DirectedEdge{ uuid="+id.getUuid()+", type="+id.getType()+", timestamp="+timestamp+" }"; } }
@Override public void invalidate(CacheScope scope) { invalidateCQL(scope); logger.debug("Invalidated scope {}", scope.getApplication().getUuid()); }
public int getBucket(ApplicationScope applicationScope){ //potentially add offset to remove old buckets //if set is 1-5 then +5 would change range to 6-10 return indexBucketOffset + bucketLocator.getCurrentBucket(applicationScope.getApplication().getUuid().toString()); } }
@Override protected ByteBuffer getPartitionKey(Id applicationId, String entityType, String fieldType, String fieldName, Object fieldValue ){ return serializeKey(applicationId.getUuid(), applicationId.getType(), entityType, fieldType, fieldName, fieldValue); }
@Override protected ByteBuffer getPartitionKey(Id applicationId, String entityType, String fieldType, String fieldName, Object fieldValue ){ return serializeKey(applicationId.getUuid(), applicationId.getType(), entityType, fieldType, fieldName, fieldValue); }
private Iterable<EntityRef> getEntityRefsForUniqueProperty( String collName, String propName, String alias ) throws Exception { final Id id = getIdForUniqueEntityField( collName, propName, alias ); if ( id == null ) { return Collections.emptyList(); } return Collections.<EntityRef>singleton( new SimpleEntityRef( id.getType(), id.getUuid() ) ); }
@Override public Observable<Id> mark(final Id entityId, String region) { Preconditions.checkNotNull( entityId, "Entity id is required in this stage" ); Preconditions.checkNotNull( entityId.getUuid(), "Entity id is required in this stage" ); Preconditions.checkNotNull( entityId.getType(), "Entity type is required in this stage" ); Observable<Id> o = Observable.just( new CollectionIoEvent<>( applicationScope, entityId, region ) ) .map( markStart ).doOnNext( markCommit ).compose( uniqueCleanup ).map( entityEvent -> entityEvent.getEvent().getId() ); return ObservableTimer.time( o, deleteTimer ); }
@Override public void funnel( final Id from, final PrimitiveSink into ) { final UUID id = from.getUuid(); final String type = from.getType(); into.putLong( id.getMostSignificantBits() ); into.putLong( id.getLeastSignificantBits() ); into.putString( type, StringHashUtils.UTF8 ); } };
@Override public void queueNewEdge(final ApplicationScope applicationScope, final Id entityId, final Edge newEdge, QueueIndexingStrategy queueIndexingStrategy) { if (logger.isTraceEnabled()) { logger.trace("Offering EdgeIndexEvent for edge type {} entity {}:{}", newEdge.getType(), entityId.getUuid(), entityId.getType()); } offer( new EdgeIndexEvent( queueFig.getPrimaryRegion(), applicationScope, entityId, newEdge ), queueIndexingStrategy); }
@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); }
@Before public void setup() { scope = mock( ApplicationScope.class ); Id orgId = mock( Id.class ); when( orgId.getType() ).thenReturn( "organization" ); when( orgId.getUuid() ).thenReturn( ORG_ID ); when( scope.getApplication() ).thenReturn( orgId ); }
/** Incorrect fields */ private static MvccEntity wrongUuidType() { final Id id = mock( Id.class ); when( id.getUuid() ).thenReturn( UUIDGenerator.newTimeUUID() ); when( id.getType() ).thenReturn( "test" ); final MvccEntity entity = mock( MvccEntity.class ); when( entity.getId() ).thenReturn( id ); when( entity.getVersion() ).thenReturn( UUID.randomUUID() ); return entity; }
private static MvccEntity invalidId() { final Id id = mock( Id.class ); when( id.getUuid() ).thenReturn( UUIDGenerator.newTimeUUID() ); when( id.getType() ).thenReturn( "" ); final MvccEntity entity = mock( MvccEntity.class ); when( entity.getId() ).thenReturn( id ); when( entity.getVersion() ).thenReturn( UUID.randomUUID() ); return entity; }
@Before public void setup() { scope = mock( ApplicationScope.class ); Id orgId = mock( Id.class ); when( orgId.getType() ).thenReturn( "organization" ); when( orgId.getUuid() ).thenReturn( UUIDGenerator.newTimeUUID() ); when( scope.getApplication() ).thenReturn( orgId ); }
@Before public void setup() { scope = mock( ApplicationScope.class ); Id orgId = mock( Id.class ); when( orgId.getType() ).thenReturn( "organization" ); when( orgId.getUuid() ).thenReturn( UUIDGenerator.newTimeUUID() ); when( scope.getApplication() ).thenReturn( orgId ); }
@Before public void setup() { scope = mock( ApplicationScope.class ); Id orgId = mock( Id.class ); when( orgId.getType() ).thenReturn( "organization" ); when( orgId.getUuid() ).thenReturn( UUIDGenerator.newTimeUUID() ); when( scope.getApplication() ).thenReturn( orgId ); }
public Entity convertMvccEntityToEntity( org.apache.usergrid.persistence.model.entity.Entity entity){ if(entity == null) { return null; } Class clazz = Schema.getDefaultSchema().getEntityClass(entity.getId().getType()); Entity oldFormatEntity = EntityFactory.newEntity(entity.getId().getUuid(), entity.getId().getType(), clazz); oldFormatEntity.setProperties(CpEntityMapUtils.toMap(entity)); return oldFormatEntity; }
@Test public void testEntityType() { final ApplicationScopeImpl applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) ); final Id id = new SimpleId( "id" ); final String output = IndexingUtils.getType( applicationScope, id ); final String expected = "appId(" + applicationScope.getApplication().getUuid() + ",application).entityType(" + id.getType() + ")"; assertEquals( output, expected ); } }