Search in sources :

Example 6 with ReplicationTask

use of org.apache.hive.hcatalog.api.repl.ReplicationTask 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);
}
Also used : NoopReplicationTask(org.apache.hive.hcatalog.api.repl.NoopReplicationTask) ReplicationTask(org.apache.hive.hcatalog.api.repl.ReplicationTask) Database(org.apache.hadoop.hive.metastore.api.Database) 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 7 with ReplicationTask

use of org.apache.hive.hcatalog.api.repl.ReplicationTask 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);
}
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 8 with ReplicationTask

use of org.apache.hive.hcatalog.api.repl.ReplicationTask 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);
}
Also used : NoopReplicationTask(org.apache.hive.hcatalog.api.repl.NoopReplicationTask) ReplicationTask(org.apache.hive.hcatalog.api.repl.ReplicationTask) Database(org.apache.hadoop.hive.metastore.api.Database) 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 9 with ReplicationTask

use of org.apache.hive.hcatalog.api.repl.ReplicationTask 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);
}
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 10 with ReplicationTask

use of org.apache.hive.hcatalog.api.repl.ReplicationTask 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);
}
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) ArrayList(java.util.ArrayList) 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

NotificationEvent (org.apache.hadoop.hive.metastore.api.NotificationEvent)10 ReplicationTask (org.apache.hive.hcatalog.api.repl.ReplicationTask)10 Test (org.junit.Test)10 HCatNotificationEvent (org.apache.hive.hcatalog.api.HCatNotificationEvent)9 NoopReplicationTask (org.apache.hive.hcatalog.api.repl.NoopReplicationTask)9 Table (org.apache.hadoop.hive.metastore.api.Table)7 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)4 Partition (org.apache.hadoop.hive.metastore.api.Partition)4 ArrayList (java.util.ArrayList)2 Database (org.apache.hadoop.hive.metastore.api.Database)2 Function (com.google.common.base.Function)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Nullable (javax.annotation.Nullable)1 Configuration (org.apache.hadoop.conf.Configuration)1 IMetaStoreClient (org.apache.hadoop.hive.metastore.IMetaStoreClient)1 Command (org.apache.hive.hcatalog.api.repl.Command)1 StagingDirectoryProvider (org.apache.hive.hcatalog.api.repl.StagingDirectoryProvider)1