Search in sources :

Example 6 with ImportCommand

use of org.apache.hive.hcatalog.api.repl.commands.ImportCommand 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);
}
Also used : ImportCommand(org.apache.hive.hcatalog.api.repl.commands.ImportCommand) ExportCommand(org.apache.hive.hcatalog.api.repl.commands.ExportCommand)

Example 7 with ImportCommand

use of org.apache.hive.hcatalog.api.repl.commands.ImportCommand 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);
}
Also used : ImportCommand(org.apache.hive.hcatalog.api.repl.commands.ImportCommand) ExportCommand(org.apache.hive.hcatalog.api.repl.commands.ExportCommand)

Example 8 with ImportCommand

use of org.apache.hive.hcatalog.api.repl.commands.ImportCommand 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)));
}
Also used : ImportCommand(org.apache.hive.hcatalog.api.repl.commands.ImportCommand) ExportCommand(org.apache.hive.hcatalog.api.repl.commands.ExportCommand)

Example 9 with ImportCommand

use of org.apache.hive.hcatalog.api.repl.commands.ImportCommand in project hive by apache.

the class TestEximReplicationTasks method verifyAlterTableReplicationTask.

private static void verifyAlterTableReplicationTask(ReplicationTask rtask) throws IOException {
    assertEquals(AlterTableReplicationTask.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, true);
    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, true);
    assertEquals(ReplicationUtils.serializeCommand(importCommand), ReplicationUtils.serializeCommand(dstCommands.get(0)));
}
Also used : ImportCommand(org.apache.hive.hcatalog.api.repl.commands.ImportCommand) ExportCommand(org.apache.hive.hcatalog.api.repl.commands.ExportCommand)

Example 10 with ImportCommand

use of org.apache.hive.hcatalog.api.repl.commands.ImportCommand in project hive by apache.

the class AlterTableReplicationTask method getDstWhCommands.

public Iterable<? extends Command> getDstWhCommands() {
    verifyActionable();
    final String dbName = alterTableMessage.getDB();
    final String tableName = alterTableMessage.getTable();
    return Collections.singletonList(new ImportCommand(ReplicationUtils.mapIfMapAvailable(dbName, dbNameMapping), ReplicationUtils.mapIfMapAvailable(tableName, tableNameMapping), null, dstStagingDirProvider.getStagingDirectory(ReplicationUtils.getUniqueKey(getEvent().getEventId(), // Note - important to retain the same key as the export
    dbName, tableName, null)), true, event.getEventId()));
}
Also used : ImportCommand(org.apache.hive.hcatalog.api.repl.commands.ImportCommand)

Aggregations

ImportCommand (org.apache.hive.hcatalog.api.repl.commands.ImportCommand)10 ExportCommand (org.apache.hive.hcatalog.api.repl.commands.ExportCommand)6 Map (java.util.Map)1 Command (org.apache.hive.hcatalog.api.repl.Command)1 NoopCommand (org.apache.hive.hcatalog.api.repl.commands.NoopCommand)1