@Test( expected = NullPointerException.class ) public void loadParamEntityId() throws ConnectionException { logEntryStrategy .load( new ApplicationScopeImpl( new SimpleId( "organization" ) ), null, UUIDGenerator.newTimeUUID() ); }
@Override public VersionSet load( final ApplicationScope collectionScope, final Collection<Id> entityIds, final UUID maxVersion ) { Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); Preconditions.checkNotNull( entityIds, "entityIds is required" ); Preconditions.checkArgument( entityIds.size() > 0, "You must specify an Id" ); Preconditions.checkNotNull( maxVersion, "maxVersion is required" ); Preconditions.checkArgument( entityIds.size() <= fig.getMaxLoadSize(), "requested size cannot be over configured maximum" ); final Id applicationId = collectionScope.getApplication(); final List<ScopedRowKey<K>> rowKeys = new ArrayList<>( entityIds.size() ); for ( final Id entityId : entityIds ) { final ScopedRowKey<K> rowKey = createKey( applicationId, entityId ); rowKeys.add( rowKey ); } final Iterator<Row<ScopedRowKey<K>, UUID>> latestEntityColumns; try { latestEntityColumns = keyspace.prepareQuery( CF_ENTITY_LOG ).getKeySlice( rowKeys ) .withColumnRange( maxVersion, null, false, 1 ).execute().getResult() .iterator(); } catch ( ConnectionException e ) { throw new CollectionRuntimeException( null, collectionScope, "An error occurred connecting to cassandra", e ); } final VersionSetImpl versionResults = new VersionSetImpl( entityIds.size() ); while ( latestEntityColumns.hasNext() ) { final Row<ScopedRowKey<K>, UUID> row = latestEntityColumns.next(); final ColumnList<UUID> columns = row.getColumns(); if ( columns.size() == 0 ) { continue; } final Id entityId = getEntityIdFromKey( row.getKey() ); final Column<UUID> column = columns.getColumnByIndex( 0 ); final UUID version = column.getName(); final StageStatus stageStatus = column.getValue( SER ); final MvccLogEntry logEntry = new MvccLogEntryImpl( entityId, version, stageStatus.stage, stageStatus.state ); versionResults.addEntry( logEntry ); } return versionResults; }
MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerializationStrategy { @Override public VersionSet load( final ApplicationScope collectionScope, final Collection<Id> entityIds, final UUID maxVersion ) { Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); Preconditions.checkNotNull( entityIds, "entityIds is required" ); Preconditions.checkArgument( entityIds.size() > 0, "You must specify an Id" ); Preconditions.checkNotNull( maxVersion, "maxVersion is required" ); Preconditions.checkArgument( entityIds.size() <= fig.getMaxLoadSize(), "requested size cannot be over configured maximum" ); final Id applicationId = collectionScope.getApplication(); final List<ScopedRowKey<K>> rowKeys = new ArrayList<>( entityIds.size() ); for ( final Id entityId : entityIds ) { final ScopedRowKey<K> rowKey = createKey( applicationId, entityId ); rowKeys.add( rowKey ); } final Iterator<Row<ScopedRowKey<K>, UUID>> latestEntityColumns; try { latestEntityColumns = keyspace.prepareQuery( CF_ENTITY_LOG ).getKeySlice( rowKeys ) .withColumnRange( maxVersion, null, false, 1 ).execute().getResult() .iterator(); } catch ( ConnectionException e ) { throw new CollectionRuntimeException( null, collectionScope, "An error occurred connecting to cassandra", e ); } final VersionSetImpl versionResults = new VersionSetImpl( entityIds.size() ); while ( latestEntityColumns.hasNext() ) { final Row<ScopedRowKey<K>, UUID> row = latestEntityColumns.next(); final ColumnList<UUID> columns = row.getColumns(); if ( columns.size() == 0 ) { continue; } final Id entityId = getEntityIdFromKey( row.getKey() ); final Column<UUID> column = columns.getColumnByIndex( 0 ); final UUID version = column.getName(); final StageStatus stageStatus = column.getValue( SER ); final MvccLogEntry logEntry = new MvccLogEntryImpl( entityId, version, stageStatus.stage, stageStatus.state ); versionResults.addEntry( logEntry ); } return versionResults; } }
MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerializationStrategy { @Override public VersionSet load( final ApplicationScope collectionScope, final Collection<Id> entityIds, final UUID maxVersion ) { Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); Preconditions.checkNotNull( entityIds, "entityIds is required" ); Preconditions.checkArgument( entityIds.size() > 0, "You must specify an Id" ); Preconditions.checkNotNull( maxVersion, "maxVersion is required" ); Preconditions.checkArgument( entityIds.size() <= fig.getMaxLoadSize(), "requested size cannot be over configured maximum" ); final Id applicationId = collectionScope.getApplication(); final List<ScopedRowKey<K>> rowKeys = new ArrayList<>( entityIds.size() ); for ( final Id entityId : entityIds ) { final ScopedRowKey<K> rowKey = createKey( applicationId, entityId ); rowKeys.add( rowKey ); } final Iterator<Row<ScopedRowKey<K>, UUID>> latestEntityColumns; try { latestEntityColumns = keyspace.prepareQuery( CF_ENTITY_LOG ).getKeySlice( rowKeys ) .withColumnRange( maxVersion, null, false, 1 ).execute().getResult() .iterator(); } catch ( ConnectionException e ) { throw new CollectionRuntimeException( null, collectionScope, "An error occurred connecting to cassandra", e ); } final VersionSetImpl versionResults = new VersionSetImpl( entityIds.size() ); while ( latestEntityColumns.hasNext() ) { final Row<ScopedRowKey<K>, UUID> row = latestEntityColumns.next(); final ColumnList<UUID> columns = row.getColumns(); if ( columns.size() == 0 ) { continue; } final Id entityId = getEntityIdFromKey( row.getKey() ); final Column<UUID> column = columns.getColumnByIndex( 0 ); final UUID version = column.getName(); final StageStatus stageStatus = column.getValue( SER ); final MvccLogEntry logEntry = new MvccLogEntryImpl( entityId, version, stageStatus.stage, stageStatus.state ); versionResults.addEntry( logEntry ); } return versionResults; } MvccLogEntrySerializationStrategyImpl( final Keyspace keyspace, final SerializationFig fig ); }
MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerializationStrategy { @Override public VersionSet load( final ApplicationScope collectionScope, final Collection<Id> entityIds, final UUID maxVersion ) { Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); Preconditions.checkNotNull( entityIds, "entityIds is required" ); Preconditions.checkArgument( entityIds.size() > 0, "You must specify an Id" ); Preconditions.checkNotNull( maxVersion, "maxVersion is required" ); Preconditions.checkArgument( entityIds.size() <= fig.getMaxLoadSize(), "requested size cannot be over configured maximum" ); final Id applicationId = collectionScope.getApplication(); final List<ScopedRowKey<K>> rowKeys = new ArrayList<>( entityIds.size() ); for ( final Id entityId : entityIds ) { final ScopedRowKey<K> rowKey = createKey( applicationId, entityId ); rowKeys.add( rowKey ); } final Iterator<Row<ScopedRowKey<K>, UUID>> latestEntityColumns; try { latestEntityColumns = keyspace.prepareQuery( CF_ENTITY_LOG ).getKeySlice( rowKeys ) .withColumnRange( maxVersion, null, false, 1 ).execute().getResult() .iterator(); } catch ( ConnectionException e ) { throw new CollectionRuntimeException( null, collectionScope, "An error occurred connecting to cassandra", e ); } final VersionSetImpl versionResults = new VersionSetImpl( entityIds.size() ); while ( latestEntityColumns.hasNext() ) { final Row<ScopedRowKey<K>, UUID> row = latestEntityColumns.next(); final ColumnList<UUID> columns = row.getColumns(); if ( columns.size() == 0 ) { continue; } final Id entityId = getEntityIdFromKey( row.getKey() ); final Column<UUID> column = columns.getColumnByIndex( 0 ); final UUID version = column.getName(); final StageStatus stageStatus = column.getValue( SER ); final MvccLogEntry logEntry = new MvccLogEntryImpl( entityId, version, stageStatus.stage, stageStatus.state ); versionResults.addEntry( logEntry ); } return versionResults; } MvccLogEntrySerializationStrategyImpl( final Keyspace keyspace, final SerializationFig fig ); @Override MutationBatch write( final ApplicationScope collectionScope, final MvccLogEntry entry ); @Override VersionSet load( final ApplicationScope collectionScope, final Collection<Id> entityIds,
                            final UUID maxVersion ); @Override List<MvccLogEntry> load( final ApplicationScope collectionScope, final Id entityId, final UUID version,
                                    final int maxSize ); @Override List<MvccLogEntry> loadReversed( final ApplicationScope applicationScope, final Id entityId,
                                            final UUID minVersion, final int maxSize ); @Override MutationBatch delete( final ApplicationScope context, final Id entityId, final UUID version ); }
MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerializationStrategy { @Override public VersionSet load( final ApplicationScope collectionScope, final Collection<Id> entityIds, final UUID maxVersion ) { Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); Preconditions.checkNotNull( entityIds, "entityIds is required" ); Preconditions.checkArgument( entityIds.size() > 0, "You must specify an Id" ); Preconditions.checkNotNull( maxVersion, "maxVersion is required" ); Preconditions.checkArgument( entityIds.size() <= fig.getMaxLoadSize(), "requested size cannot be over configured maximum" ); final Id applicationId = collectionScope.getApplication(); final List<ScopedRowKey<K>> rowKeys = new ArrayList<>( entityIds.size() ); for ( final Id entityId : entityIds ) { final ScopedRowKey<K> rowKey = createKey( applicationId, entityId ); rowKeys.add( rowKey ); } final Iterator<Row<ScopedRowKey<K>, UUID>> latestEntityColumns; try { latestEntityColumns = keyspace.prepareQuery( CF_ENTITY_LOG ).getKeySlice( rowKeys ) .withColumnRange( maxVersion, null, false, 1 ).execute().getResult() .iterator(); } catch ( ConnectionException e ) { throw new CollectionRuntimeException( null, collectionScope, "An error occurred connecting to cassandra", e ); } final VersionSetImpl versionResults = new VersionSetImpl( entityIds.size() ); while ( latestEntityColumns.hasNext() ) { final Row<ScopedRowKey<K>, UUID> row = latestEntityColumns.next(); final ColumnList<UUID> columns = row.getColumns(); if ( columns.size() == 0 ) { continue; } final Id entityId = getEntityIdFromKey( row.getKey() ); final Column<UUID> column = columns.getColumnByIndex( 0 ); final UUID version = column.getName(); final StageStatus stageStatus = column.getValue( SER ); final MvccLogEntry logEntry = new MvccLogEntryImpl( entityId, version, stageStatus.stage, stageStatus.state ); versionResults.addEntry( logEntry ); } return versionResults; } MvccLogEntrySerializationStrategyImpl( final Keyspace keyspace, final SerializationFig fig ); @Override MutationBatch write( final ApplicationScope collectionScope, final MvccLogEntry entry ); @Override VersionSet load( final ApplicationScope collectionScope, final Collection<Id> entityIds,
                            final UUID maxVersion ); @Override List<MvccLogEntry> load( final ApplicationScope collectionScope, final Id entityId, final UUID version,
                                    final int maxSize ); @Override List<MvccLogEntry> loadReversed( final ApplicationScope applicationScope, final Id entityId,
                                            final UUID minVersion, final int maxSize ); @Override MutationBatch delete( final ApplicationScope context, final Id entityId, final UUID version );  }