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 void verifyDropTableReplicationTask(ReplicationTask rtask) throws IOException { assertEquals(DropTableReplicationTask.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(DropTableCommand.class, dstCommands.get(0).getClass()); DropTableCommand dropTableCommand = new DropTableCommand( debugMapping.apply(rtask.getEvent().getDbName()), debugMapping.apply(rtask.getEvent().getTableName()), true, rtask.getEvent().getEventId()); assertEquals(ReplicationUtils.serializeCommand(dropTableCommand), ReplicationUtils.serializeCommand(dstCommands.get(0))); }
private static void verifyDropPartitionReplicationTask(ReplicationTask rtask, Table table, Partition ptn) { assertEquals(DropPartitionReplicationTask.class, rtask.getClass()); assertEquals(false, rtask.needsStagingDirs()); assertEquals(true, rtask.isActionable()); rtask .withDbNameMapping(debugMapping) .withTableNameMapping(debugMapping); assertEquals(true,rtask.isActionable()); for (Command c : rtask.getSrcWhCommands()){ assertEquals(NoopCommand.class, c.getClass()); } List<? extends Command> dstCommands = Lists.newArrayList(rtask.getDstWhCommands()); assertEquals(1,dstCommands.size()); assertEquals(DropPartitionCommand.class, dstCommands.get(0).getClass()); DropPartitionCommand dropPartitionCommand = new DropPartitionCommand( debugMapping.apply(rtask.getEvent().getDbName()), debugMapping.apply(rtask.getEvent().getTableName()), getPtnDesc(table,ptn), true, rtask.getEvent().getEventId() ); CommandTestUtils.compareCommands(dropPartitionCommand, dstCommands.get(0), true); }
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() ); }
for(HCatNotificationEvent n : notifs){ LOG.info("notif from dblistener:" + n.getEventId() + ":" + n.getEventTime() + ",t:" + n.getEventType() + ",o:" + n.getDbName() + "." + n.getTableName()); HCatNotificationEvent n = task.getEvent(); LOG.info("notif from tasks:" + n.getEventId() + ":" + n.getEventTime() + ",t:" + n.getEventType() + ",o:" + n.getDbName() + "." + n.getTableName() + ",s:" + n.getEventScope()); LOG.info("task :" + task.getClass().getName());
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() ); }