Search in sources :

Example 1 with MessageSerializer

use of org.apache.hadoop.hive.metastore.messaging.MessageSerializer in project hive by apache.

the class DbNotificationListener method onAddPartition.

/**
 * @param partitionEvent partition event
 * @throws MetaException
 */
@Override
public void onAddPartition(AddPartitionEvent partitionEvent) throws MetaException {
    Table t = partitionEvent.getTable();
    PartitionFilesIterator fileIter = MetaStoreUtils.isExternalTable(t) ? null : new PartitionFilesIterator(partitionEvent.getPartitionIterator(), t);
    EventMessage msg = MessageBuilder.getInstance().buildAddPartitionMessage(t, partitionEvent.getPartitionIterator(), fileIter);
    MessageSerializer serializer = msgEncoder.getSerializer();
    NotificationEvent event = new NotificationEvent(0, now(), EventType.ADD_PARTITION.toString(), serializer.serialize(msg));
    event.setCatName(t.isSetCatName() ? t.getCatName() : DEFAULT_CATALOG_NAME);
    event.setDbName(t.getDbName());
    event.setTableName(t.getTableName());
    process(event, partitionEvent);
}
Also used : Table(org.apache.hadoop.hive.metastore.api.Table) EventMessage(org.apache.hadoop.hive.metastore.messaging.EventMessage) MessageSerializer(org.apache.hadoop.hive.metastore.messaging.MessageSerializer) NotificationEvent(org.apache.hadoop.hive.metastore.api.NotificationEvent)

Example 2 with MessageSerializer

use of org.apache.hadoop.hive.metastore.messaging.MessageSerializer in project hive by apache.

the class TestReplicationMetricCollector method testReplStatsTrackerLimit.

@Test
public void testReplStatsTrackerLimit() {
    MessageSerializer serializer = MessageFactory.getDefaultInstanceForReplMetrics(conf).getSerializer();
    ReplStatsTracker repl = new ReplStatsTracker(10);
    // Check for k=10
    generateStatsString(10, repl);
    String replStatsTracker = repl.toString();
    String gzipSerialized = serializer.serialize(replStatsTracker);
    assertTrue("ReplStat string is " + gzipSerialized.length(), gzipSerialized.length() < ReplStatsTracker.RM_PROGRESS_LENGTH);
    // Check for k=5
    repl = new ReplStatsTracker(5);
    generateStatsString(5, repl);
    replStatsTracker = repl.toString();
    gzipSerialized = serializer.serialize(replStatsTracker);
    assertTrue("ReplStat string is " + gzipSerialized.length(), gzipSerialized.length() < ReplStatsTracker.RM_PROGRESS_LENGTH);
    // Check for k=2 & check NaN values doesn't get messed up due to formatter
    repl = new ReplStatsTracker(2);
    generateStatsString(2, repl);
    assertTrue(repl.toString().contains("NaN"));
}
Also used : ReplStatsTracker(org.apache.hadoop.hive.ql.exec.repl.ReplStatsTracker) MessageSerializer(org.apache.hadoop.hive.metastore.messaging.MessageSerializer) Test(org.junit.Test)

Aggregations

MessageSerializer (org.apache.hadoop.hive.metastore.messaging.MessageSerializer)2 NotificationEvent (org.apache.hadoop.hive.metastore.api.NotificationEvent)1 Table (org.apache.hadoop.hive.metastore.api.Table)1 EventMessage (org.apache.hadoop.hive.metastore.messaging.EventMessage)1 ReplStatsTracker (org.apache.hadoop.hive.ql.exec.repl.ReplStatsTracker)1 Test (org.junit.Test)1