Search in sources :

Example 1 with HCatNotificationEvent

use of org.apache.hive.hcatalog.api.HCatNotificationEvent in project hive by apache.

the class TestReplicationTask method testCreate.

@Test
public static void testCreate() throws HCatException {
    Table t = new Table();
    t.setDbName("testdb");
    t.setTableName("testtable");
    NotificationEvent event = new NotificationEvent(0, (int) System.currentTimeMillis(), HCatConstants.HCAT_CREATE_TABLE_EVENT, msgFactory.buildCreateTableMessage(t).toString());
    event.setDbName(t.getDbName());
    event.setTableName(t.getTableName());
    ReplicationTask.resetFactory(null);
    ReplicationTask rtask = ReplicationTask.create(HCatClient.create(new HiveConf()), new HCatNotificationEvent(event));
    assertTrue("Provided factory instantiation should yield CreateTableReplicationTask", rtask instanceof CreateTableReplicationTask);
    ReplicationTask.resetFactory(NoopFactory.class);
    rtask = ReplicationTask.create(HCatClient.create(new HiveConf()), new HCatNotificationEvent(event));
    assertTrue("Provided factory instantiation should yield NoopReplicationTask", rtask instanceof NoopReplicationTask);
    ReplicationTask.resetFactory(null);
}
Also used : Table(org.apache.hadoop.hive.metastore.api.Table) CreateTableReplicationTask(org.apache.hive.hcatalog.api.repl.exim.CreateTableReplicationTask) CreateTableReplicationTask(org.apache.hive.hcatalog.api.repl.exim.CreateTableReplicationTask) HCatNotificationEvent(org.apache.hive.hcatalog.api.HCatNotificationEvent) NotificationEvent(org.apache.hadoop.hive.metastore.api.NotificationEvent) HiveConf(org.apache.hadoop.hive.conf.HiveConf) HCatNotificationEvent(org.apache.hive.hcatalog.api.HCatNotificationEvent) Test(org.junit.Test)

Example 2 with HCatNotificationEvent

use of org.apache.hive.hcatalog.api.HCatNotificationEvent in project hive by apache.

the class TestEximReplicationTasks method testCreateTable.

@Test
public void testCreateTable() throws IOException {
    Table t = new Table();
    t.setDbName("testdb");
    t.setTableName("testtable");
    NotificationEvent event = new NotificationEvent(getEventId(), getTime(), HCatConstants.HCAT_CREATE_TABLE_EVENT, msgFactory.buildCreateTableMessage(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());
    verifyCreateTableReplicationTask(rtask);
}
Also used : Table(org.apache.hadoop.hive.metastore.api.Table) NoopReplicationTask(org.apache.hive.hcatalog.api.repl.NoopReplicationTask) ReplicationTask(org.apache.hive.hcatalog.api.repl.ReplicationTask) HCatNotificationEvent(org.apache.hive.hcatalog.api.HCatNotificationEvent) NotificationEvent(org.apache.hadoop.hive.metastore.api.NotificationEvent) HCatNotificationEvent(org.apache.hive.hcatalog.api.HCatNotificationEvent) Test(org.junit.Test)

Example 3 with HCatNotificationEvent

use of org.apache.hive.hcatalog.api.HCatNotificationEvent in project hive by apache.

the class TestEximReplicationTasks method testInsert.

@Test
public void testInsert() 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"));
    List<String> files = Arrays.asList("/tmp/test123");
    NotificationEvent event = new NotificationEvent(getEventId(), getTime(), HCatConstants.HCAT_INSERT_EVENT, msgFactory.buildInsertMessage(t.getDbName(), t.getTableName(), getPtnDesc(t, p), files).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());
    verifyInsertReplicationTask(rtask, t, p);
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) Table(org.apache.hadoop.hive.metastore.api.Table) NoopReplicationTask(org.apache.hive.hcatalog.api.repl.NoopReplicationTask) ReplicationTask(org.apache.hive.hcatalog.api.repl.ReplicationTask) FieldSchema(org.apache.hadoop.hive.metastore.api.FieldSchema) HCatNotificationEvent(org.apache.hive.hcatalog.api.HCatNotificationEvent) NotificationEvent(org.apache.hadoop.hive.metastore.api.NotificationEvent) HCatNotificationEvent(org.apache.hive.hcatalog.api.HCatNotificationEvent) Test(org.junit.Test)

Example 4 with HCatNotificationEvent

use of org.apache.hive.hcatalog.api.HCatNotificationEvent in project hive by apache.

the class TestEximReplicationTasks method testDropTable.

@Test
public void testDropTable() throws IOException {
    Table t = new Table();
    t.setDbName("testdb");
    t.setTableName("testtable");
    NotificationEvent event = new NotificationEvent(getEventId(), getTime(), HCatConstants.HCAT_DROP_TABLE_EVENT, msgFactory.buildDropTableMessage(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());
    verifyDropTableReplicationTask(rtask);
}
Also used : Table(org.apache.hadoop.hive.metastore.api.Table) NoopReplicationTask(org.apache.hive.hcatalog.api.repl.NoopReplicationTask) ReplicationTask(org.apache.hive.hcatalog.api.repl.ReplicationTask) HCatNotificationEvent(org.apache.hive.hcatalog.api.HCatNotificationEvent) NotificationEvent(org.apache.hadoop.hive.metastore.api.NotificationEvent) HCatNotificationEvent(org.apache.hive.hcatalog.api.HCatNotificationEvent) Test(org.junit.Test)

Example 5 with HCatNotificationEvent

use of org.apache.hive.hcatalog.api.HCatNotificationEvent in project hive by apache.

the class TestEximReplicationTasks method testAlterPartition.

@Test
public void testAlterPartition() 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_ALTER_PARTITION_EVENT, msgFactory.buildAlterPartitionMessage(t, p, p).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());
    verifyAlterPartitionReplicationTask(rtask, t, p);
}
Also used : Partition(org.apache.hadoop.hive.metastore.api.Partition) Table(org.apache.hadoop.hive.metastore.api.Table) NoopReplicationTask(org.apache.hive.hcatalog.api.repl.NoopReplicationTask) ReplicationTask(org.apache.hive.hcatalog.api.repl.ReplicationTask) FieldSchema(org.apache.hadoop.hive.metastore.api.FieldSchema) HCatNotificationEvent(org.apache.hive.hcatalog.api.HCatNotificationEvent) NotificationEvent(org.apache.hadoop.hive.metastore.api.NotificationEvent) HCatNotificationEvent(org.apache.hive.hcatalog.api.HCatNotificationEvent) Test(org.junit.Test)

Aggregations

HCatNotificationEvent (org.apache.hive.hcatalog.api.HCatNotificationEvent)11 NotificationEvent (org.apache.hadoop.hive.metastore.api.NotificationEvent)10 Test (org.junit.Test)10 NoopReplicationTask (org.apache.hive.hcatalog.api.repl.NoopReplicationTask)9 ReplicationTask (org.apache.hive.hcatalog.api.repl.ReplicationTask)9 Table (org.apache.hadoop.hive.metastore.api.Table)8 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)4 Partition (org.apache.hadoop.hive.metastore.api.Partition)4 Database (org.apache.hadoop.hive.metastore.api.Database)2 ArrayList (java.util.ArrayList)1 HiveConf (org.apache.hadoop.hive.conf.HiveConf)1 CreateTableReplicationTask (org.apache.hive.hcatalog.api.repl.exim.CreateTableReplicationTask)1