@Override protected ScopedRowKey<Id> createKey( final Id applicationId, final Id entityId ) { final ScopedRowKey<Id> rowKey = ScopedRowKey.fromKey( applicationId, entityId ); return rowKey; }
public List<ScopedRowKey<R>> getRowKeys() { if(logger.isTraceEnabled()) { logger.trace("Shards: {}", shards); } List<ScopedRowKey<R>> rowKeys = new ArrayList<>(shards.size()); for(Shard shard : shards){ final ScopedRowKey< R> rowKey = ScopedRowKey .fromKey( scope.getApplication(), generateRowKey(shard.getShardIndex() ) ); rowKeys.add( rowKey ); } if(logger.isTraceEnabled()) { logger.trace("Resulting Shards: {}", rowKeys); } return rowKeys; }
@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 );
@Override protected ScopedRowKey<CollectionPrefixedKey<Id>> createKey( final Id applicationId, final Id entityId ) { final Id ownerId = applicationId; final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( entityId.getType() ); final CollectionPrefixedKey<Id> collectionPrefixedKey = new CollectionPrefixedKey<>( collectionName, ownerId, entityId ); final ScopedRowKey<CollectionPrefixedKey<Id>> rowKey = ScopedRowKey.fromKey( applicationId, collectionPrefixedKey ); return rowKey; }
@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 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 ) ) .putColumn( column, 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( columnFamilies.getSourceNodeTargetTypeCfName(), 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 );
@Override public void setVersion(final String pluginName, final int version ) { final ScopedRowKey<String> rowKey = ScopedRowKey.fromKey( STATIC_ID, pluginName); try { keyspace.prepareColumnMutation( CF_MIGRATION_INFO, rowKey, COLUMN_VERSION ).putValue( version, null ) .execute(); } catch ( ConnectionException e ) { throw new DataMigrationException( "Unable to save status", e ); } }
@Override public void setStatusCode(final String pluginName, final int status ) { final ScopedRowKey<String> rowKey = ScopedRowKey.fromKey( STATIC_ID, pluginName); try { keyspace.prepareColumnMutation( CF_MIGRATION_INFO, rowKey, COLUMN_STATUS_CODE ).putValue( status, null ) .execute(); } catch ( ConnectionException e ) { throw new DataMigrationException( "Unable to save status", e ); } }
@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 public void setStatusMessage(final String pluginName, final String message ) { final ScopedRowKey<String> rowKey = ScopedRowKey.fromKey( STATIC_ID, pluginName); try { keyspace.prepareColumnMutation( CF_MIGRATION_INFO, rowKey, COL_STATUS_MESSAGE ).putValue( message, null ) .execute(); } catch ( ConnectionException e ) { throw new DataMigrationException( "Unable to save status", e ); } }
@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 );
/** * 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 removeShardMeta( final ApplicationScope scope, final Shard shard, final DirectedEdgeMeta metaData) { ValidationUtils.validateApplicationScope( scope ); GraphValidation.valiateShard( shard ); GraphValidation.validateDirectedEdgeMeta( metaData ); final ScopedRowKey rowKey = ScopedRowKey.fromKey( scope.getApplication(), metaData ); final MutationBatch batch = keyspace.prepareMutationBatch(); // write the row with a current timestamp so we can ensure that it's persisted with updated shard meta long batchTimestamp = System.currentTimeMillis(); batch.withTimestamp(batchTimestamp).withRow( EDGE_SHARDS, rowKey ) .deleteColumn( shard.getShardIndex() ).setTimestamp(batchTimestamp); return batch; }
@Override public MutationBatch mark( 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 ) .putColumn( COLUMN_NAME, 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; }