|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cassandra.db.migration.Migration
public abstract class Migration
A migration represents a single metadata mutation (cf dropped, added, etc.). Migrations can be applied locally, or serialized and sent to another machine where it can be applied there. Each migration has a version represented by a TimeUUID that can be used to look up both the Migration itself (see getLocalMigrations) as well as a serialization of the Keyspace definition that was modified. There are three parts to a migration (think of it as a schema update): 1. data is written to the schema cf. 2. the migration is serialized to the migrations cf. 3. updated models are applied to the cassandra instance. Since steps 1, 2 and 3 are not committed atomically, care should be taken to ensure that a node/cluster is reasonably quiescent with regard to the keyspace or columnfamily whose schema is being modified. Each class that extends Migration is required to implement a no arg constructor, which will be used to inflate the object from it's serialized form.
Field Summary | |
---|---|
protected boolean |
clientMode
|
static byte[] |
LAST_MIGRATION_KEY
|
protected java.util.UUID |
lastVersion
|
static java.lang.String |
MIGRATIONS_CF
|
static byte[] |
MIGRATIONS_KEY
|
protected java.util.UUID |
newVersion
|
protected RowMutation |
rm
|
static java.lang.String |
SCHEMA_CF
|
Constructor Summary | |
---|---|
protected |
Migration()
Subclasses must have a matching constructor |
Method Summary | |
---|---|
void |
announce()
|
void |
apply()
apply changes |
void |
beforeApplyModels()
override this to perform logic before writing the migration or applying it. |
static Migration |
deserialize(byte[] bytes)
|
static java.util.UUID |
getLastMigrationId()
|
static java.util.Collection<IColumn> |
getLocalMigrations(java.util.UUID start,
java.util.UUID end)
load serialized migrations. |
java.util.UUID |
getVersion()
|
byte[] |
serialize()
|
abstract void |
subdeflate(org.apache.cassandra.db.migration.avro.Migration mi)
Deflate this Migration into an Avro object. |
abstract void |
subinflate(org.apache.cassandra.db.migration.avro.Migration mi)
Inflate this Migration from an Avro object: called after the required no-arg constructor. |
static byte[] |
toUTF8Bytes(java.util.UUID version)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String MIGRATIONS_CF
public static final java.lang.String SCHEMA_CF
public static final byte[] MIGRATIONS_KEY
public static final byte[] LAST_MIGRATION_KEY
protected RowMutation rm
protected java.util.UUID newVersion
protected java.util.UUID lastVersion
protected transient boolean clientMode
Constructor Detail |
---|
protected Migration()
Method Detail |
---|
public void beforeApplyModels()
public final void apply() throws java.io.IOException, ConfigurationException
java.io.IOException
ConfigurationException
public final void announce()
public static java.util.UUID getLastMigrationId()
public abstract void subdeflate(org.apache.cassandra.db.migration.avro.Migration mi)
public abstract void subinflate(org.apache.cassandra.db.migration.avro.Migration mi)
public java.util.UUID getVersion()
public byte[] serialize() throws java.io.IOException
java.io.IOException
public static Migration deserialize(byte[] bytes) throws java.io.IOException
java.io.IOException
public static java.util.Collection<IColumn> getLocalMigrations(java.util.UUID start, java.util.UUID end)
public static byte[] toUTF8Bytes(java.util.UUID version)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |