use of org.apache.hive.hcatalog.api.repl.commands.ExportCommand in project hive by apache.
the class TestEximReplicationTasks method verifyInsertReplicationTask.
private static void verifyInsertReplicationTask(ReplicationTask rtask, Table table, Partition ptn) {
assertEquals(InsertReplicationTask.class, rtask.getClass());
assertEquals(true, rtask.needsStagingDirs());
assertEquals(false, rtask.isActionable());
rtask.withSrcStagingDirProvider(stagingDirectoryProvider).withDstStagingDirProvider(stagingDirectoryProvider).withDbNameMapping(debugMapping).withTableNameMapping(debugMapping);
assertEquals(true, rtask.isActionable());
List<? extends Command> srcCommands = Lists.newArrayList(rtask.getSrcWhCommands());
assertEquals(1, srcCommands.size());
assertEquals(ExportCommand.class, srcCommands.get(0).getClass());
ExportCommand exportCommand = getExpectedExportCommand(rtask, getPtnDesc(table, ptn), false);
CommandTestUtils.compareCommands(exportCommand, srcCommands.get(0), true);
List<? extends Command> dstCommands = Lists.newArrayList(rtask.getDstWhCommands());
assertEquals(1, dstCommands.size());
assertEquals(ImportCommand.class, dstCommands.get(0).getClass());
ImportCommand importCommand = getExpectedImportCommand(rtask, getPtnDesc(table, ptn), false);
CommandTestUtils.compareCommands(importCommand, dstCommands.get(0), true);
}
use of org.apache.hive.hcatalog.api.repl.commands.ExportCommand in project hive by apache.
the class TestEximReplicationTasks method verifyAddPartitionReplicationTask.
private static void verifyAddPartitionReplicationTask(ReplicationTask rtask, Table table, List<Partition> addedPtns) throws IOException {
assertEquals(AddPartitionReplicationTask.class, rtask.getClass());
assertEquals(true, rtask.needsStagingDirs());
assertEquals(false, rtask.isActionable());
rtask.withSrcStagingDirProvider(stagingDirectoryProvider).withDstStagingDirProvider(stagingDirectoryProvider).withDbNameMapping(debugMapping).withTableNameMapping(debugMapping);
assertEquals(true, rtask.isActionable());
List<? extends Command> srcCommands = Lists.newArrayList(rtask.getSrcWhCommands());
assertEquals(2, srcCommands.size());
assertEquals(ExportCommand.class, srcCommands.get(0).getClass());
assertEquals(ExportCommand.class, srcCommands.get(1).getClass());
ExportCommand exportCommand1 = getExpectedExportCommand(rtask, getPtnDesc(table, addedPtns.get(0)), false);
ExportCommand exportCommand2 = getExpectedExportCommand(rtask, getPtnDesc(table, addedPtns.get(1)), false);
CommandTestUtils.compareCommands(exportCommand1, srcCommands.get(0), true);
CommandTestUtils.compareCommands(exportCommand2, srcCommands.get(1), true);
List<? extends Command> dstCommands = Lists.newArrayList(rtask.getDstWhCommands());
assertEquals(2, dstCommands.size());
assertEquals(ImportCommand.class, dstCommands.get(0).getClass());
assertEquals(ImportCommand.class, dstCommands.get(1).getClass());
ImportCommand importCommand1 = getExpectedImportCommand(rtask, getPtnDesc(table, addedPtns.get(0)), false);
ImportCommand importCommand2 = getExpectedImportCommand(rtask, getPtnDesc(table, addedPtns.get(1)), false);
CommandTestUtils.compareCommands(importCommand1, dstCommands.get(0), true);
CommandTestUtils.compareCommands(importCommand2, dstCommands.get(1), true);
}
use of org.apache.hive.hcatalog.api.repl.commands.ExportCommand in project hive by apache.
the class TestEximReplicationTasks method verifyAlterPartitionReplicationTask.
private static void verifyAlterPartitionReplicationTask(ReplicationTask rtask, Table table, Partition ptn) {
assertEquals(AlterPartitionReplicationTask.class, rtask.getClass());
assertEquals(true, rtask.needsStagingDirs());
assertEquals(false, rtask.isActionable());
rtask.withSrcStagingDirProvider(stagingDirectoryProvider).withDstStagingDirProvider(stagingDirectoryProvider).withDbNameMapping(debugMapping).withTableNameMapping(debugMapping);
assertEquals(true, rtask.isActionable());
List<? extends Command> srcCommands = Lists.newArrayList(rtask.getSrcWhCommands());
assertEquals(1, srcCommands.size());
assertEquals(ExportCommand.class, srcCommands.get(0).getClass());
ExportCommand exportCommand = getExpectedExportCommand(rtask, getPtnDesc(table, ptn), true);
CommandTestUtils.compareCommands(exportCommand, srcCommands.get(0), true);
List<? extends Command> dstCommands = Lists.newArrayList(rtask.getDstWhCommands());
assertEquals(1, dstCommands.size());
assertEquals(ImportCommand.class, dstCommands.get(0).getClass());
ImportCommand importCommand = getExpectedImportCommand(rtask, getPtnDesc(table, ptn), true);
CommandTestUtils.compareCommands(importCommand, dstCommands.get(0), true);
}
use of org.apache.hive.hcatalog.api.repl.commands.ExportCommand in project hive by apache.
the class CreateTableReplicationTask method getSrcWhCommands.
public Iterable<? extends Command> getSrcWhCommands() {
verifyActionable();
final String dbName = createTableMessage.getDB();
final String tableName = createTableMessage.getTable();
return Collections.singletonList(new ExportCommand(dbName, tableName, null, srcStagingDirProvider.getStagingDirectory(ReplicationUtils.getUniqueKey(getEvent().getEventId(), dbName, tableName, null)), false, event.getEventId()));
}
use of org.apache.hive.hcatalog.api.repl.commands.ExportCommand in project hive by apache.
the class TestEximReplicationTasks method verifyCreateTableReplicationTask.
private static void verifyCreateTableReplicationTask(ReplicationTask rtask) throws IOException {
assertEquals(CreateTableReplicationTask.class, rtask.getClass());
assertEquals(true, rtask.needsStagingDirs());
assertEquals(false, rtask.isActionable());
rtask.withSrcStagingDirProvider(stagingDirectoryProvider).withDstStagingDirProvider(stagingDirectoryProvider).withDbNameMapping(debugMapping).withTableNameMapping(debugMapping);
assertEquals(true, rtask.isActionable());
List<? extends Command> srcCommands = Lists.newArrayList(rtask.getSrcWhCommands());
assertEquals(1, srcCommands.size());
assertEquals(ExportCommand.class, srcCommands.get(0).getClass());
ExportCommand exportCommand = getExpectedExportCommand(rtask, null, false);
assertEquals(ReplicationUtils.serializeCommand(exportCommand), ReplicationUtils.serializeCommand(srcCommands.get(0)));
List<? extends Command> dstCommands = Lists.newArrayList(rtask.getDstWhCommands());
assertEquals(1, dstCommands.size());
assertEquals(ImportCommand.class, dstCommands.get(0).getClass());
ImportCommand importCommand = getExpectedImportCommand(rtask, null, false);
assertEquals(ReplicationUtils.serializeCommand(importCommand), ReplicationUtils.serializeCommand(dstCommands.get(0)));
}
Aggregations