use of alluxio.master.table.Table in project alluxio by Alluxio.
the class TableMasterJournalIntegrationTest method journalTransformDb.
@Test
public void journalTransformDb() throws Exception {
LocalAlluxioCluster mCluster = sClusterResource.get();
TableMaster tableMaster = mCluster.getLocalAlluxioMaster().getMasterProcess().getMaster(TableMaster.class);
LocalAlluxioJobCluster jobCluster = new LocalAlluxioJobCluster();
jobCluster.start();
JobMaster jobMaster = jobCluster.getMaster().getJobMaster();
genTable(1, 2, true);
tableMaster.attachDatabase(TestUdbFactory.TYPE, "connect", DB_NAME, DB_NAME, Collections.emptyMap(), false);
List<String> tables = tableMaster.getAllTables(DB_NAME);
assertFalse(tables.isEmpty());
// all partitions are not transformed, so baselayout is the same as layout
String tableName = tables.get(0);
assertTrue(tableMaster.getTable(DB_NAME, tableName).getPartitions().stream().allMatch(partition -> partition.getBaseLayout() == partition.getLayout()));
long jobid = tableMaster.transformTable(DB_NAME, tableName, null);
assertNotEquals(0, jobid);
JobTestUtils.waitForJobStatus(jobMaster, jobid, ImmutableSet.of(Status.COMPLETED, Status.CANCELED, Status.FAILED));
final JobInfo status = jobMaster.getStatus(jobid);
assertEquals("", status.getErrorMessage());
assertEquals(Status.COMPLETED, status.getStatus());
HeartbeatScheduler.execute(HeartbeatContext.MASTER_TABLE_TRANSFORMATION_MONITOR);
// all partitions are transformed, so baselayout should be different as layout
assertTrue(tableMaster.getTable(DB_NAME, tableName).getPartitions().stream().allMatch(partition -> partition.getBaseLayout() != partition.getLayout()));
restartMaster();
genTable(1, 4, true);
TableMaster tableMasterRestart = mCluster.getLocalAlluxioMaster().getMasterProcess().getMaster(TableMaster.class);
Table table = tableMaster.getTable(DB_NAME, tableName);
// all partitions remain transformed
assertTrue(tableMaster.getTable(DB_NAME, tableName).getPartitions().stream().allMatch(partition -> partition.getBaseLayout() != partition.getLayout()));
tableMasterRestart.syncDatabase(DB_NAME);
// The first two partitions should remain transformed, the new partitions are not transformed
assertTrue(tableMaster.getTable(DB_NAME, tableName).getPartitions().stream().allMatch(partition -> (partition.getSpec().endsWith("0") || partition.getSpec().endsWith("1")) == (partition.getBaseLayout() != partition.getLayout())));
}
use of alluxio.master.table.Table in project alluxio by Alluxio.
the class TableMasterJournalIntegrationTest method journalAttachDb.
@Test
public void journalAttachDb() throws Exception {
LocalAlluxioCluster mCluster = sClusterResource.get();
TableMaster tableMaster = mCluster.getLocalAlluxioMaster().getMasterProcess().getMaster(TableMaster.class);
try {
tableMaster.getDatabase(DB_NAME);
fail();
} catch (IOException e) {
assertEquals("Database " + DB_NAME + " does not exist", e.getMessage());
}
genTable(1, 2, true);
tableMaster.attachDatabase(TestUdbFactory.TYPE, "connect", DB_NAME, DB_NAME, Collections.emptyMap(), false);
assertEquals(DB_NAME, tableMaster.getDatabase(DB_NAME).getDbName());
List<String> oldTableNames = tableMaster.getAllTables(DB_NAME);
Table tableOld = tableMaster.getTable(DB_NAME, oldTableNames.get(0));
restartMaster();
// Update Udb, the table should stay the same, until we detach / reattach
genTable(2, 2, true);
TableMaster tableMasterRestart = mCluster.getLocalAlluxioMaster().getMasterProcess().getMaster(TableMaster.class);
List<String> newTableNames = tableMaster.getAllTables(DB_NAME);
assertEquals(oldTableNames, newTableNames);
Table tableNew = tableMasterRestart.getTable(DB_NAME, newTableNames.get(0));
assertEquals(tableOld.getName(), tableNew.getName());
}
Aggregations