use of org.apache.hive.hcatalog.api.HCatNotificationEvent in project hive by apache.
the class TestEximReplicationTasks method testDropDb.
@Test
public void testDropDb() throws IOException {
Database db = new Database();
db.setName("testdb");
NotificationEvent event = new NotificationEvent(getEventId(), getTime(), HCatConstants.HCAT_DROP_DATABASE_EVENT, msgFactory.buildCreateDatabaseMessage(db).toString());
event.setDbName(db.getName());
HCatNotificationEvent hev = new HCatNotificationEvent(event);
ReplicationTask rtask = ReplicationTask.create(client, hev);
assertEquals(hev.toString(), rtask.getEvent().toString());
verifyDropDbReplicationTask(rtask);
}
use of org.apache.hive.hcatalog.api.HCatNotificationEvent in project hive by apache.
the class TestEximReplicationTasks method testDropPartition.
@Test
public void testDropPartition() throws HCatException {
Table t = new Table();
t.setDbName("testdb");
t.setTableName("testtable");
List<FieldSchema> pkeys = HCatSchemaUtils.getFieldSchemas(HCatSchemaUtils.getHCatSchema("a:int,b:string").getFields());
t.setPartitionKeys(pkeys);
Partition p = createPtn(t, Arrays.asList("102", "lmn"));
NotificationEvent event = new NotificationEvent(getEventId(), getTime(), HCatConstants.HCAT_DROP_PARTITION_EVENT, msgFactory.buildDropPartitionMessage(t, Collections.singletonList(p).iterator()).toString());
event.setDbName(t.getDbName());
event.setTableName(t.getTableName());
HCatNotificationEvent hev = new HCatNotificationEvent(event);
ReplicationTask rtask = ReplicationTask.create(client, hev);
assertEquals(hev.toString(), rtask.getEvent().toString());
verifyDropPartitionReplicationTask(rtask, t, p);
}
use of org.apache.hive.hcatalog.api.HCatNotificationEvent in project hive by apache.
the class TestEximReplicationTasks method testCreateDb.
@Test
public void testCreateDb() {
Database db = new Database();
db.setName("testdb");
NotificationEvent event = new NotificationEvent(getEventId(), getTime(), HCatConstants.HCAT_CREATE_DATABASE_EVENT, msgFactory.buildCreateDatabaseMessage(db).toString());
event.setDbName(db.getName());
HCatNotificationEvent hev = new HCatNotificationEvent(event);
ReplicationTask rtask = ReplicationTask.create(client, hev);
assertEquals(hev.toString(), rtask.getEvent().toString());
// CREATE DB currently replicated as Noop.
verifyCreateDbReplicationTask(rtask);
}
use of org.apache.hive.hcatalog.api.HCatNotificationEvent in project hive by apache.
the class TestEximReplicationTasks method testAlterTable.
@Test
public void testAlterTable() throws IOException {
Table t = new Table();
t.setDbName("testdb");
t.setTableName("testtable");
NotificationEvent event = new NotificationEvent(getEventId(), getTime(), HCatConstants.HCAT_ALTER_TABLE_EVENT, msgFactory.buildAlterTableMessage(t, t).toString());
event.setDbName(t.getDbName());
event.setTableName(t.getTableName());
HCatNotificationEvent hev = new HCatNotificationEvent(event);
ReplicationTask rtask = ReplicationTask.create(client, hev);
assertEquals(hev.toString(), rtask.getEvent().toString());
verifyAlterTableReplicationTask(rtask);
}
use of org.apache.hive.hcatalog.api.HCatNotificationEvent in project hive by apache.
the class TestEximReplicationTasks method testAddPartition.
@Test
public void testAddPartition() throws IOException {
Table t = new Table();
t.setDbName("testdb");
t.setTableName("testtable");
List<FieldSchema> pkeys = HCatSchemaUtils.getFieldSchemas(HCatSchemaUtils.getHCatSchema("a:int,b:string").getFields());
t.setPartitionKeys(pkeys);
List<Partition> addedPtns = new ArrayList<Partition>();
addedPtns.add(createPtn(t, Arrays.asList("120", "abc")));
addedPtns.add(createPtn(t, Arrays.asList("201", "xyz")));
NotificationEvent event = new NotificationEvent(getEventId(), getTime(), HCatConstants.HCAT_ADD_PARTITION_EVENT, msgFactory.buildAddPartitionMessage(t, addedPtns.iterator()).toString());
event.setDbName(t.getDbName());
event.setTableName(t.getTableName());
HCatNotificationEvent hev = new HCatNotificationEvent(event);
ReplicationTask rtask = ReplicationTask.create(client, hev);
assertEquals(hev.toString(), rtask.getEvent().toString());
verifyAddPartitionReplicationTask(rtask, t, addedPtns);
}
Aggregations