@Override public Command apply(@Nullable Map<String, String> ptnDesc) { return new DropPartitionCommand( dstDbName, dstTableName, ptnDesc, true, event.getEventId() ); } });
@Override public ReplicationTask next() { eventCount++; HCatNotificationEvent ev = batchIter.next(); pos = ev.getEventId(); return ReplicationTask.create(hcatClient,ev); }
public NoopReplicationTask(HCatNotificationEvent event) { super(event); noopReturn = new ArrayList<Command>(); noopReturn.add(new NoopCommand(event.getEventId())); }
public Iterable<? extends Command> getSrcWhCommands() { verifyActionable(); return Collections.singletonList(new NoopCommand(event.getEventId())); }
public Iterable<? extends Command> getSrcWhCommands() { verifyActionable(); return Collections.singletonList(new NoopCommand(event.getEventId())); }
public Iterable<? extends Command> getSrcWhCommands() { verifyActionable(); return Collections.singletonList(new NoopCommand(event.getEventId())); }
public Iterable<? extends Command> getDstWhCommands() { verifyActionable(); final String dstDbName = ReplicationUtils.mapIfMapAvailable(dropDatabaseMessage.getDB(), dbNameMapping); return Collections.singletonList(new DropDatabaseCommand(dstDbName, event.getEventId())); } }
@Override public Command apply(@Nullable Map<String, String> ptnDesc) { return new ImportCommand( dstDbName, dstTableName, ptnDesc, dstStagingDirProvider.getStagingDirectory( ReplicationUtils.getUniqueKey( getEvent().getEventId(), addPartitionMessage.getDB(), // Note - important to retain the same key as the export addPartitionMessage.getTable(), ptnDesc) ), false, event.getEventId() ); } });
public Iterable<? extends Command> getSrcWhCommands() { verifyActionable(); final String dbName = alterTableMessage.getDB(); final String tableName = alterTableMessage.getTable(); return Collections.singletonList(new ExportCommand( dbName, tableName, null, srcStagingDirProvider.getStagingDirectory( ReplicationUtils.getUniqueKey( getEvent().getEventId(), dbName, tableName, null) ), true, event.getEventId() )); }
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() )); }
@Override public Command apply(@Nullable Map<String, String> ptnDesc) { return new ExportCommand( addPartitionMessage.getDB(), addPartitionMessage.getTable(), ptnDesc, srcStagingDirProvider.getStagingDirectory( ReplicationUtils.getUniqueKey( getEvent().getEventId(), addPartitionMessage.getDB(), addPartitionMessage.getTable(), ptnDesc) ), false, event.getEventId() ); } });
public Iterable<? extends Command> getDstWhCommands() { verifyActionable(); final String dstDbName = ReplicationUtils.mapIfMapAvailable(dropTableMessage.getDB(), dbNameMapping); final String dstTableName = ReplicationUtils.mapIfMapAvailable(dropTableMessage.getTable(), tableNameMapping); return Collections.singletonList(new DropTableCommand(dstDbName, dstTableName, true, event.getEventId())); } }
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(), dbName, // Note - important to retain the same key as the export tableName, null) ), true, event.getEventId() )); } }
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(), dbName, // Note - important to retain the same key as the export tableName, null) ), false, event.getEventId() )); } }
public Iterable<? extends Command> getDstWhCommands() { verifyActionable(); final String dbName = insertMessage.getDB(); final String tableName = insertMessage.getTable(); final Map<String,String> ptnDesc = insertMessage.getPartitionKeyValues(); // Note : ptnDesc can be null or empty for non-ptn table return Collections.singletonList(new ImportCommand( ReplicationUtils.mapIfMapAvailable(dbName, dbNameMapping), ReplicationUtils.mapIfMapAvailable(tableName, tableNameMapping), ptnDesc, dstStagingDirProvider.getStagingDirectory( ReplicationUtils.getUniqueKey( getEvent().getEventId(), dbName, // Note - important to retain the same key as the export tableName, ptnDesc) ), false, event.getEventId() )); }
public Iterable<? extends Command> getSrcWhCommands() { verifyActionable(); return Collections.singletonList(new ExportCommand( alterPartitionMessage.getDB(), alterPartitionMessage.getTable(), alterPartitionMessage.getKeyValues(), srcStagingDirProvider.getStagingDirectory( ReplicationUtils.getUniqueKey( getEvent().getEventId(), alterPartitionMessage.getDB(), alterPartitionMessage.getTable(), alterPartitionMessage.getKeyValues()) ), true, event.getEventId() )); }
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(), alterPartitionMessage.getDB(), // Note - important to retain the same key as the export alterPartitionMessage.getTable(), alterPartitionMessage.getKeyValues()) ), true, event.getEventId() )); } }
private static ExportCommand getExpectedExportCommand(ReplicationTask rtask, Map<String, String> ptnDesc, boolean isMetadataOnly) { String dbName = rtask.getEvent().getDbName(); String tableName = rtask.getEvent().getTableName(); return new ExportCommand( dbName, tableName, ptnDesc, stagingDirectoryProvider.getStagingDirectory( ReplicationUtils.getUniqueKey( rtask.getEvent().getEventId(), dbName, tableName, ptnDesc) ), isMetadataOnly, rtask.getEvent().getEventId() ); }
private static void verifyDropDbReplicationTask(ReplicationTask rtask) throws IOException { assertEquals(DropDatabaseReplicationTask.class, rtask.getClass()); assertEquals(false, rtask.needsStagingDirs()); assertEquals(true, rtask.isActionable()); rtask .withDbNameMapping(debugMapping) .withTableNameMapping(debugMapping); for (Command c : rtask.getSrcWhCommands()){ assertEquals(NoopCommand.class, c.getClass()); } List<? extends Command> dstCommands = Lists.newArrayList(rtask.getDstWhCommands()); assertEquals(1,dstCommands.size()); assertEquals(DropDatabaseCommand.class, dstCommands.get(0).getClass()); DropDatabaseCommand dropDatabaseCommand = new DropDatabaseCommand( debugMapping.apply(rtask.getEvent().getDbName()), rtask.getEvent().getEventId()); assertEquals(ReplicationUtils.serializeCommand(dropDatabaseCommand), ReplicationUtils.serializeCommand(dstCommands.get(0))); }
private static ImportCommand getExpectedImportCommand(ReplicationTask rtask, Map<String,String> ptnDesc, boolean isMetadataOnly) { String dbName = rtask.getEvent().getDbName(); String tableName = rtask.getEvent().getTableName(); return new ImportCommand( ReplicationUtils.mapIfMapAvailable(dbName, debugMapping), ReplicationUtils.mapIfMapAvailable(tableName, debugMapping), ptnDesc, stagingDirectoryProvider.getStagingDirectory( ReplicationUtils.getUniqueKey( rtask.getEvent().getEventId(), dbName, tableName, ptnDesc) ), isMetadataOnly, rtask.getEvent().getEventId() ); }