protected void executeBatch(final int targetVersion, final MutationBatch batch, final ProgressObserver po, final AtomicLong count, com.datastax.driver.core.BatchStatement uniqueBatch) { try { batch.execute(); session.execute(uniqueBatch); po.update( targetVersion, "Finished copying " + count + " entities to the new format" ); } catch ( ConnectionException e ) { po.failed( targetVersion, "Failed to execute mutation in cassandra" ); throw new DataMigrationException( "Unable to migrate batches ", e ); } }
@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 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 ); } }
if ( entityMigration.supports( version ) ) { if ( migrationToExecute != null ) { throw new DataMigrationException( "Two migrations attempted to migration the same version, this is not allowed. Class '" + migrationToExecute.getClass().getName() + "' and class '" + entityMigration
@Override public int getSystemVersion() { try { return keyspace.prepareQuery( CF_MIGRATION_INFO ).getKey( LEGACY_ROW_KEY ).getColumn( COLUMN_VERSION ) .execute().getResult().getIntegerValue(); } //swallow, it doesn't exist catch ( NotFoundException nfe ) { return 0; } catch ( ConnectionException e ) { throw new DataMigrationException( "Unable to retrieve status", e ); } }
@Override public String getStatusMessage(final String pluginName) { final ScopedRowKey<String> rowKey = ScopedRowKey.fromKey( STATIC_ID, pluginName); try { return keyspace.prepareQuery( CF_MIGRATION_INFO ).getKey( rowKey ).getColumn( COL_STATUS_MESSAGE ) .execute().getResult().getStringValue(); } //swallow, it doesn't exist catch ( NotFoundException nfe ) { return null; } catch ( ConnectionException e ) { throw new DataMigrationException( "Unable to retrieve status", e ); } }
@Override public int getStatusCode(final String pluginName) { final ScopedRowKey<String> rowKey = ScopedRowKey.fromKey( STATIC_ID, pluginName); try { return keyspace.prepareQuery( CF_MIGRATION_INFO ).getKey( rowKey ).getColumn( COLUMN_STATUS_CODE ) .execute().getResult().getIntegerValue(); } //swallow, it doesn't exist catch ( NotFoundException nfe ) { return 0; } catch ( ConnectionException e ) { throw new DataMigrationException( "Unable to retrieve status", e ); } }