Search in sources :

Example 1 with ImportCommand

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

the class AddPartitionReplicationTask method getDstWhCommands.

public Iterable<? extends Command> getDstWhCommands() {
    verifyActionable();
    if (addPartitionMessage.getPartitions().isEmpty()) {
        return Collections.singletonList(new NoopCommand(event.getEventId()));
    }
    final String dstDbName = ReplicationUtils.mapIfMapAvailable(addPartitionMessage.getDB(), dbNameMapping);
    final String dstTableName = ReplicationUtils.mapIfMapAvailable(addPartitionMessage.getTable(), tableNameMapping);
    return Iterables.transform(addPartitionMessage.getPartitions(), new Function<Map<String, String>, Command>() {

        @Override
        public Command apply(@Nullable Map<String, String> ptnDesc) {
            return new ImportCommand(dstDbName, dstTableName, ptnDesc, dstStagingDirProvider.getStagingDirectory(ReplicationUtils.getUniqueKey(getEvent().getEventId(), // Note - important to retain the same key as the export
            addPartitionMessage.getDB(), addPartitionMessage.getTable(), ptnDesc)), false, event.getEventId());
        }
    });
}
Also used : ImportCommand(org.apache.hive.hcatalog.api.repl.commands.ImportCommand) Command(org.apache.hive.hcatalog.api.repl.Command) NoopCommand(org.apache.hive.hcatalog.api.repl.commands.NoopCommand) ImportCommand(org.apache.hive.hcatalog.api.repl.commands.ImportCommand) ExportCommand(org.apache.hive.hcatalog.api.repl.commands.ExportCommand) NoopCommand(org.apache.hive.hcatalog.api.repl.commands.NoopCommand) Map(java.util.Map)

Example 2 with ImportCommand

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

the class AlterPartitionReplicationTask method getDstWhCommands.

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

Example 3 with ImportCommand

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

the class CreateTableReplicationTask method getDstWhCommands.

public Iterable<? extends Command> getDstWhCommands() {
    verifyActionable();
    final String dbName = createTableMessage.getDB();
    final String tableName = createTableMessage.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)), false, event.getEventId()));
}
Also used : ImportCommand(org.apache.hive.hcatalog.api.repl.commands.ImportCommand)

Example 4 with ImportCommand

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

the class InsertReplicationTask method getDstWhCommands.

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

Example 5 with ImportCommand

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

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