use of alluxio.master.table.TableMaster 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.TableMaster 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());
}
use of alluxio.master.table.TableMaster in project alluxio by Alluxio.
the class TableMasterJournalIntegrationTest method journalSync.
@Test
public void journalSync() throws Exception {
LocalAlluxioCluster mCluster = sClusterResource.get();
TableMaster tableMaster = mCluster.getLocalAlluxioMaster().getMasterProcess().getMaster(TableMaster.class);
genTable(1, 2, true);
tableMaster.attachDatabase(TestUdbFactory.TYPE, "connect", DB_NAME, DB_NAME, Collections.emptyMap(), false);
checkDb(tableMaster, DB_NAME, TestDatabase.sTestDbInfo);
DatabaseInfo oldInfo = TestDatabase.sTestDbInfo;
DatabaseInfo newInfo = new DatabaseInfo("test2://test2", "newowner", PrincipalType.ROLE, "newcomment", ImmutableMap.of("key", "value"));
checkTable(tableMaster, DB_NAME, 1, 2);
checkTable(tableMaster, DB_NAME, 1, 2);
assertEquals(TestDatabase.getTableName(0), tableMaster.getAllTables(DB_NAME).get(0));
assertEquals(1, tableMaster.getAllTables(DB_NAME).size());
assertEquals(2, tableMaster.getTable(DB_NAME, TestDatabase.getTableName(0)).getPartitions().size());
// Update Udb, the table should stay the same, until we sync
genTable(2, 3, true);
tableMaster.syncDatabase(DB_NAME);
checkTable(tableMaster, DB_NAME, 2, 3);
// Drop a table to create a 'remove_table' entry
genTable(1, 10, true);
tableMaster.syncDatabase(DB_NAME);
checkTable(tableMaster, DB_NAME, 1, 10);
restartMaster();
TableMaster tableMasterRestart = mCluster.getLocalAlluxioMaster().getMasterProcess().getMaster(TableMaster.class);
TestDatabase.sTestDbInfo = newInfo;
checkDb(tableMasterRestart, DB_NAME, oldInfo);
tableMasterRestart.syncDatabase(DB_NAME);
checkDb(tableMasterRestart, DB_NAME, newInfo);
checkTable(tableMasterRestart, DB_NAME, 1, 10);
}
use of alluxio.master.table.TableMaster in project alluxio by Alluxio.
the class TableMasterJournalIntegrationTest method journalDetachDb.
@Test
public void journalDetachDb() throws Exception {
LocalAlluxioCluster mCluster = sClusterResource.get();
TableMaster tableMaster = mCluster.getLocalAlluxioMaster().getMasterProcess().getMaster(TableMaster.class);
genTable(1, 2, true);
tableMaster.attachDatabase(TestUdbFactory.TYPE, "connect", DB_NAME, DB_NAME, Collections.emptyMap(), false);
tableMaster.detachDatabase(DB_NAME);
assertTrue(tableMaster.getAllDatabases().isEmpty());
genTable(2, 2, true);
restartMaster();
TableMaster tableMasterRestart = mCluster.getLocalAlluxioMaster().getMasterProcess().getMaster(TableMaster.class);
assertTrue(tableMasterRestart.getAllDatabases().isEmpty());
}
Aggregations