/** * 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(); }
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()); } }
/** * * @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 public Observable<EdgeScope> getEdgesToEntities( final Observable<ApplicationScope> appScopes, final Optional<String> edgeType, final Optional<Edge> lastEdge) { return appScopes.flatMap( applicationScope -> { final GraphManager gm = graphManagerFactory.createEdgeManager( applicationScope ); return edgesObservable.edgesFromSourceDescending( gm, applicationScope.getApplication(), edgeType, lastEdge ) .map( edge -> new EdgeScope(applicationScope, edge )); } ); } }
@Override public long getCollectionSize(final ApplicationScope applicationScope, final String collectionName) { return getSize(applicationScope, CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(), collectionName)); }
public IndexLocationStrategy getIndexLocationStrategy( final ApplicationScope applicationScope){ if(CpNamingUtils.getManagementApplicationId().equals(applicationScope.getApplication())){ return new ManagementIndexLocationStrategy(clusterFig,cassandraFig,indexFig,coreIndexFig); } return new ApplicationIndexLocationStrategy(clusterFig,cassandraFig,indexFig,applicationScope, applicationLocatorBucketStrategy); }
@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); }
@Override public long getApplicationSize(ApplicationScope applicationScope) { final IndexLocationStrategy indexLocationStrategy = indexLocationStrategyFactory.getIndexLocationStrategy(applicationScope); EntityIndex entityIndex = entityIndexFactory.createEntityIndex(indexLocationStrategy); GraphManager graphManager = graphManagerFactory.createEdgeManager(applicationScope); Long sum = ObservableTimer.time( MathObservable.sumLong( graphManager.getEdgeTypesFromSource(new SimpleSearchEdgeType(applicationScope.getApplication(), CpNamingUtils.EDGE_COLL_PREFIX, Optional.<String>absent())) .map(type -> CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(), type)) .map(edge -> entityIndex.getTotalEntitySizeInBytes(edge)) ), sumTimer).toBlocking().last(); return sum.longValue(); }
@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<RowKeyType>, DirectedEdge> columnFamily, final ApplicationScope scope, final RowKeyType 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 );
@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 void call( final ApplicationScope id ) { applicationIds.remove( id.getApplication().getUuid() ); assertEquals("Correct application type expected" , Application.ENTITY_TYPE, id.getApplication().getType() ); } } ).toBlocking().lastOrDefault( null );
@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 );