/** * Validate the organization scope */ public static void validateApplicationScope( final ApplicationScope scope ) { Preconditions.checkNotNull( scope, "organization scope is required" ); verifyIdentity( scope.getApplication() ); }
public static String getType( ApplicationScope applicationScope, String type ) { StringBuilder sb = new StringBuilder(); idString( sb, APPID_NAME, applicationScope.getApplication() ); sb.append( FIELD_SEPERATOR ); sb.append( ENTITY_TYPE_NAME).append("(" ).append( type ).append( ")" ); return sb.toString(); }
/** * * @param indexFig config * @param aliasPrefix alias prefix, e.g. app_id etc.. */ public ApplicationIndexAlias(IndexFig indexFig, ApplicationScope applicationScope, String aliasPrefix) { this.writeAlias = aliasPrefix + "_" + applicationScope.getApplication().getUuid() + "_write_" + indexFig.getAliasPostfix(); this.readAlias = aliasPrefix + "_" + applicationScope.getApplication().getUuid() + "_read_" + indexFig.getAliasPostfix(); }
@Override void writeEdge( final MutationBatch batch, final MultiTenantColumnFamily<ScopedRowKey<RowKey>, DirectedEdge> columnFamily, final ApplicationScope scope, final RowKey rowKey, final DirectedEdge edge, final Shard shard, final boolean isDeleted ) { batch.withRow( columnFamily, ScopedRowKey.fromKey( scope.getApplication(), rowKey ) ).putColumn( edge, isDeleted ); } }.createBatch( scope, shards, timestamp );
@Override void writeEdge( final MutationBatch batch, final MultiTenantColumnFamily<ScopedRowKey<RowKey>, DirectedEdge> columnFamily, final ApplicationScope scope, final RowKey rowKey, final DirectedEdge edge, final Shard shard, final boolean isDeleted ) { batch.withRow( columnFamily, ScopedRowKey.fromKey( scope.getApplication(), rowKey ) ).deleteColumn( edge ); } }.createBatch( scope, shards, timestamp );
@Override void writeEdge( final MutationBatch batch, final MultiTenantColumnFamily<ScopedRowKey<RowKey>, DirectedEdge> columnFamily, final ApplicationScope scope, final RowKey rowKey, final DirectedEdge edge, final Shard shard, final boolean isDeleted ) { batch.withRow( columnFamily, ScopedRowKey.fromKey( scope.getApplication(), rowKey ) ).deleteColumn( edge ); } }.createBatch( scope, shards, timestamp );
@Override public void queueInitializeApplicationIndex( final ApplicationScope applicationScope) { IndexLocationStrategy indexLocationStrategy = indexLocationStrategyFactory.getIndexLocationStrategy( applicationScope); if (logger.isTraceEnabled()) { logger.trace("Offering InitializeApplicationIndexEvent for {}:{}", applicationScope.getApplication().getUuid(), applicationScope.getApplication().getType()); } offerTopic( new InitializeApplicationIndexEvent( queueFig.getPrimaryRegion(), new ReplicatedIndexLocationStrategy( indexLocationStrategy ) ), AsyncEventQueueType.REGULAR); }
@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 ); }
@Override public long getCollectionSize(final UUID applicationId, final String collectionName) { AggregationService aggregationService = aggregationServiceFactory.getAggregationService(); ApplicationScope applicationScope =CpNamingUtils.getApplicationScope(applicationId); return aggregationService.getSize(applicationScope, CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(), collectionName)); }
@Override void writeEdge( final MutationBatch batch, final MultiTenantColumnFamily<ScopedRowKey<RowKeyType>, DirectedEdge> columnFamily, final ApplicationScope scope, final RowKeyType rowKey, final DirectedEdge edge, final Shard shard, final boolean isDeleted ) { batch.withRow( columnFamilies.getTargetNodeSourceTypeCfName(), ScopedRowKey.fromKey( scope.getApplication(), rowKey ) ) .putColumn( edge, isDeleted ); } }.createBatch( scope, shards, timestamp );
/** * Get the map manager for uuid mapping */ private MapManager getMapManagerForTypes( ApplicationScope applicationScope) { Id mapOwner = new SimpleId( applicationScope.getApplication().getUuid(), TYPE_APPLICATION ); final MapScope ms = CpNamingUtils.getEntityTypeMapScope(mapOwner); MapManager mm = mapManagerFactory.createMapManager(ms); return mm; } }
@Override void writeEdge( final MutationBatch batch, final MultiTenantColumnFamily<ScopedRowKey<RowKeyType>, DirectedEdge> columnFamily, final ApplicationScope scope, final RowKeyType rowKey, final DirectedEdge edge, final Shard shard, final boolean isDeleted ) { batch.withRow( columnFamilies.getTargetNodeSourceTypeCfName(), ScopedRowKey.fromKey( scope.getApplication(), rowKey ) ) .deleteColumn( edge ); } }.createBatch( scope, shards, timestamp );
@Override void writeEdge( final MutationBatch batch, final MultiTenantColumnFamily<ScopedRowKey<EdgeRowKey>, Long> columnFamily, final ApplicationScope scope, final EdgeRowKey rowKey, final Long column, final Shard shard, final boolean isDeleted ) { batch.withRow( columnFamilies.getGraphEdgeVersions(), ScopedRowKey.fromKey( scope.getApplication(), rowKey ) ) .deleteColumn( column ); } }.createBatch( scope, shards, timestamp );
@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 mockApp() { this.scope = mock( ApplicationScope.class ); Id orgId = mock( Id.class ); when( orgId.getType() ).thenReturn( "organization" ); when( orgId.getUuid() ).thenReturn( UUIDGenerator.newTimeUUID() ); when( this.scope.getApplication() ).thenReturn( orgId ); }
@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 ); }
@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 ); serialization = getSerializationImpl(); }
/** * Do the write on the correct row for the entity id with the operation */ private MutationBatch doWrite( final ApplicationScope applicationScope, final Id entityId, final UUID version, final RowOp op ) { final MutationBatch batch = keyspace.prepareMutationBatch(); final Id applicationId = applicationScope.getApplication(); final ScopedRowKey<Id> rowKey = ScopedRowKey.fromKey( applicationId, entityId ); final long timestamp = version.timestamp(); op.doOp( batch.withRow( CF_ENTITY_DATA, rowKey ).setTimestamp( timestamp ) ); return batch; }
@Override public MutationBatch delete( final ApplicationScope scope, final Id node, final long timestamp ) { ValidationUtils.validateApplicationScope( scope ); ValidationUtils.verifyIdentity( node ); GraphValidation.validateTimestamp( timestamp, "timestamp" ); MutationBatch batch = keyspace.prepareMutationBatch().withConsistencyLevel( fig.getWriteCL() ); batch.withRow( GRAPH_DELETE, ScopedRowKey.fromKey( scope.getApplication(), node ) ).setTimestamp( timestamp ) .deleteColumn( COLUMN_NAME ); return batch; }