Search in sources :

Example 6 with GetReplicationMetricsRequest

use of org.apache.hadoop.hive.metastore.api.GetReplicationMetricsRequest in project hive by apache.

the class TestReplicationMetrics method testGetMetricsByScheduleId.

@Test
public void testGetMetricsByScheduleId() throws Exception {
    ObjectStore objStore = new ObjectStore();
    objStore.setConf(metaStore.getConf());
    objStore.deleteReplicationMetrics(0);
    ReplicationMetricList replicationMetricList = new ReplicationMetricList();
    List<ReplicationMetrics> replicationMetrics = new ArrayList<>();
    replicationMetrics.add(createReplicationMetric("repl1", 1L));
    replicationMetrics.add(createReplicationMetric("repl1", 2L));
    replicationMetricList.setReplicationMetricList(replicationMetrics);
    objStore.addReplicationMetrics(replicationMetricList);
    Thread.sleep(1000);
    replicationMetrics = new ArrayList<>();
    replicationMetrics.add(createReplicationMetric("repl2", 3L));
    replicationMetrics.add(createReplicationMetric("repl2", 4L));
    replicationMetricList.setReplicationMetricList(replicationMetrics);
    objStore.addReplicationMetrics(replicationMetricList);
    Thread.sleep(1000);
    GetReplicationMetricsRequest getReplicationMetricsRequest = new GetReplicationMetricsRequest();
    getReplicationMetricsRequest.setScheduledExecutionId(1L);
    ReplicationMetricList actualList = client.getReplicationMetrics(getReplicationMetricsRequest);
    assertEquals(1, actualList.getReplicationMetricListSize());
    List<ReplicationMetrics> actualMetrics = actualList.getReplicationMetricList();
    // Ordering should be descending
    ReplicationMetrics actualMetric0 = actualMetrics.get(0);
    assertEquals("repl1", actualMetric0.getPolicy());
    assertEquals(1L, actualMetric0.getScheduledExecutionId());
    assertEquals(1, actualMetric0.getDumpExecutionId());
    assertEquals("metadata", actualMetric0.getMetadata());
    assertEquals("progress", actualMetric0.getProgress());
    // Update progress
    replicationMetrics = new ArrayList<>();
    replicationMetrics.add(updateReplicationMetric("repl1", 1L, "progress1"));
    replicationMetricList.setReplicationMetricList(replicationMetrics);
    objStore.addReplicationMetrics(replicationMetricList);
    Thread.sleep(1000);
    // get the metrics again
    getReplicationMetricsRequest = new GetReplicationMetricsRequest();
    getReplicationMetricsRequest.setScheduledExecutionId(1L);
    actualList = client.getReplicationMetrics(getReplicationMetricsRequest);
    assertEquals(1, actualList.getReplicationMetricListSize());
    actualMetrics = actualList.getReplicationMetricList();
    // Ordering should be descending
    actualMetric0 = actualMetrics.get(0);
    assertEquals("repl1", actualMetric0.getPolicy());
    assertEquals(1L, actualMetric0.getScheduledExecutionId());
    assertEquals(1, actualMetric0.getDumpExecutionId());
    assertEquals("metadata", actualMetric0.getMetadata());
    assertEquals("progress1", actualMetric0.getProgress());
}
Also used : GetReplicationMetricsRequest(org.apache.hadoop.hive.metastore.api.GetReplicationMetricsRequest) ObjectStore(org.apache.hadoop.hive.metastore.ObjectStore) ReplicationMetricList(org.apache.hadoop.hive.metastore.api.ReplicationMetricList) ReplicationMetrics(org.apache.hadoop.hive.metastore.api.ReplicationMetrics) ArrayList(java.util.ArrayList) Test(org.junit.Test) MetastoreUnitTest(org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest)

Aggregations

GetReplicationMetricsRequest (org.apache.hadoop.hive.metastore.api.GetReplicationMetricsRequest)6 ReplicationMetricList (org.apache.hadoop.hive.metastore.api.ReplicationMetricList)6 Test (org.junit.Test)6 ReplicationMetrics (org.apache.hadoop.hive.metastore.api.ReplicationMetrics)5 ArrayList (java.util.ArrayList)4 ObjectStore (org.apache.hadoop.hive.metastore.ObjectStore)4 MetastoreUnitTest (org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest)4 HashMap (java.util.HashMap)2 ReplStatsTracker (org.apache.hadoop.hive.ql.exec.repl.ReplStatsTracker)2 SnapshotUtils (org.apache.hadoop.hive.ql.exec.repl.util.SnapshotUtils)2 IncrementalDumpMetricCollector (org.apache.hadoop.hive.ql.parse.repl.dump.metric.IncrementalDumpMetricCollector)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 BootstrapDumpMetricCollector (org.apache.hadoop.hive.ql.parse.repl.dump.metric.BootstrapDumpMetricCollector)1 Metadata (org.apache.hadoop.hive.ql.parse.repl.metric.event.Metadata)1 Metric (org.apache.hadoop.hive.ql.parse.repl.metric.event.Metric)1 Progress (org.apache.hadoop.hive.ql.parse.repl.metric.event.Progress)1 ProgressMapper (org.apache.hadoop.hive.ql.parse.repl.metric.event.ProgressMapper)1 ReplicationMetric (org.apache.hadoop.hive.ql.parse.repl.metric.event.ReplicationMetric)1 Stage (org.apache.hadoop.hive.ql.parse.repl.metric.event.Stage)1 StageMapper (org.apache.hadoop.hive.ql.parse.repl.metric.event.StageMapper)1