use of com.palantir.atlasdb.table.description.TableDefinition in project atlasdb by palantir.
the class CassandraKeyValueServiceTableCreationIntegrationTest method testCreateTableCanRestoreLostMetadata.
@Test
public void testCreateTableCanRestoreLostMetadata() {
// setup a basic table
TableReference missingMetadataTable = TableReference.createFromFullyQualifiedName("test.metadata_missing");
byte[] initialMetadata = new TableDefinition() {
{
rowName();
rowComponent("blob", ValueType.BLOB);
columns();
column("bar", "b", ValueType.BLOB);
conflictHandler(ConflictHandler.IGNORE_ALL);
sweepStrategy(TableMetadataPersistence.SweepStrategy.NOTHING);
}
}.toTableMetadata().persistToBytes();
kvs.createTable(missingMetadataTable, initialMetadata);
// retrieve the metadata and see that it's the same as what we just put in
byte[] existingMetadata = kvs.getMetadataForTable(missingMetadataTable);
assertThat(initialMetadata, is(existingMetadata));
// Directly get and delete the metadata (`get` necessary to get the fake timestamp putMetadataForTables used)
Cell cell = Cell.create(missingMetadataTable.getQualifiedName().getBytes(StandardCharsets.UTF_8), "m".getBytes(StandardCharsets.UTF_8));
Value persistedMetadata = Iterables.getLast(kvs.get(AtlasDbConstants.DEFAULT_METADATA_TABLE, ImmutableMap.of(cell, Long.MAX_VALUE)).values());
kvs.delete(AtlasDbConstants.DEFAULT_METADATA_TABLE, ImmutableMultimap.of(cell, persistedMetadata.getTimestamp()));
// pretend we started up again and did a createTable() for our existing table, that no longer has metadata
kvs.createTable(missingMetadataTable, initialMetadata);
// retrieve the metadata again and see that it's the same as what we just put in
existingMetadata = kvs.getMetadataForTable(missingMetadataTable);
assertThat(initialMetadata, is(existingMetadata));
}
use of com.palantir.atlasdb.table.description.TableDefinition in project atlasdb by palantir.
the class CassandraKeyValueServiceTableCreationIntegrationTest method testGetMetadataCaseInsensitive.
@Test
public void testGetMetadataCaseInsensitive() {
// Make two casewise-different references to the "same" table
TableReference caseSensitiveTable = TableReference.createFromFullyQualifiedName("test.cased_table");
TableReference wackyCasedTable = TableReference.createFromFullyQualifiedName("test.CaSeD_TaBlE");
byte[] initialMetadata = new TableDefinition() {
{
rowName();
rowComponent("blob", ValueType.BLOB);
columns();
column("bar", "b", ValueType.BLOB);
conflictHandler(ConflictHandler.IGNORE_ALL);
sweepStrategy(TableMetadataPersistence.SweepStrategy.NOTHING);
}
}.toTableMetadata().persistToBytes();
kvs.createTable(caseSensitiveTable, initialMetadata);
// retrieve the metadata and see that it's the same as what we just put in
byte[] existingMetadata = kvs.getMetadataForTable(caseSensitiveTable);
assertThat(initialMetadata, is(existingMetadata));
// retrieve same metadata with a wacky cased version of the "same" name
existingMetadata = kvs.getMetadataForTable(wackyCasedTable);
assertThat(initialMetadata, is(existingMetadata));
kvs.dropTable(caseSensitiveTable);
}
Aggregations