Search in sources :

Example 6 with BootstrapDumpMetricCollector

use of org.apache.hadoop.hive.ql.parse.repl.dump.metric.BootstrapDumpMetricCollector in project hive by apache.

the class TestReplicationMetricCollector method testSuccessBootstrapDumpMetrics.

@Test
public void testSuccessBootstrapDumpMetrics() throws Exception {
    ReplicationMetricCollector bootstrapDumpMetricCollector = new BootstrapDumpMetricCollector("db", "dummyDir", conf);
    Map<String, Long> metricMap = new HashMap<>();
    metricMap.put(ReplUtils.MetricName.TABLES.name(), (long) 10);
    metricMap.put(ReplUtils.MetricName.FUNCTIONS.name(), (long) 1);
    bootstrapDumpMetricCollector.reportStageStart("dump", metricMap);
    bootstrapDumpMetricCollector.reportStageProgress("dump", ReplUtils.MetricName.TABLES.name(), 1);
    List<ReplicationMetric> actualMetrics = MetricCollector.getInstance().getMetrics();
    Assert.assertEquals(1, actualMetrics.size());
    bootstrapDumpMetricCollector.reportStageProgress("dump", ReplUtils.MetricName.TABLES.name(), 2);
    bootstrapDumpMetricCollector.reportStageProgress("dump", ReplUtils.MetricName.FUNCTIONS.name(), 1);
    actualMetrics = MetricCollector.getInstance().getMetrics();
    Assert.assertEquals(1, actualMetrics.size());
    bootstrapDumpMetricCollector.reportStageEnd("dump", Status.SUCCESS, 10, new SnapshotUtils.ReplSnapshotCount(), new ReplStatsTracker(0));
    bootstrapDumpMetricCollector.reportEnd(Status.SUCCESS);
    actualMetrics = MetricCollector.getInstance().getMetrics();
    Assert.assertEquals(1, actualMetrics.size());
    Metadata expectedMetadata = new Metadata("db", Metadata.ReplicationType.BOOTSTRAP, "dummyDir");
    expectedMetadata.setLastReplId(10);
    Progress expectedProgress = new Progress();
    expectedProgress.setStatus(Status.SUCCESS);
    Stage dumpStage = new Stage("dump", Status.SUCCESS, 0);
    dumpStage.setEndTime(0);
    Metric expectedTableMetric = new Metric(ReplUtils.MetricName.TABLES.name(), 10);
    expectedTableMetric.setCurrentCount(3);
    Metric expectedFuncMetric = new Metric(ReplUtils.MetricName.FUNCTIONS.name(), 1);
    expectedFuncMetric.setCurrentCount(1);
    dumpStage.addMetric(expectedTableMetric);
    dumpStage.addMetric(expectedFuncMetric);
    expectedProgress.addStage(dumpStage);
    ReplicationMetric expectedMetric = new ReplicationMetric(1, "repl", 0, expectedMetadata);
    expectedMetric.setProgress(expectedProgress);
    checkSuccess(actualMetrics.get(0), expectedMetric, "dump", Arrays.asList(ReplUtils.MetricName.TABLES.name(), ReplUtils.MetricName.FUNCTIONS.name()));
}
Also used : BootstrapDumpMetricCollector(org.apache.hadoop.hive.ql.parse.repl.dump.metric.BootstrapDumpMetricCollector) ReplStatsTracker(org.apache.hadoop.hive.ql.exec.repl.ReplStatsTracker) Progress(org.apache.hadoop.hive.ql.parse.repl.metric.event.Progress) HashMap(java.util.HashMap) Metadata(org.apache.hadoop.hive.ql.parse.repl.metric.event.Metadata) ReplicationMetric(org.apache.hadoop.hive.ql.parse.repl.metric.event.ReplicationMetric) SnapshotUtils(org.apache.hadoop.hive.ql.exec.repl.util.SnapshotUtils) Stage(org.apache.hadoop.hive.ql.parse.repl.metric.event.Stage) Metric(org.apache.hadoop.hive.ql.parse.repl.metric.event.Metric) ReplicationMetric(org.apache.hadoop.hive.ql.parse.repl.metric.event.ReplicationMetric) Test(org.junit.Test)

Example 7 with BootstrapDumpMetricCollector

use of org.apache.hadoop.hive.ql.parse.repl.dump.metric.BootstrapDumpMetricCollector in project hive by apache.

the class TestReplicationMetricUpdateOnFailure method testReplDumpRecoverableMissingStage.

@Test
public void testReplDumpRecoverableMissingStage() throws Exception {
    String dumpDir = TEST_PATH + Path.SEPARATOR + testName.getMethodName();
    MetricCollector.getInstance().deinit();
    BootstrapDumpMetricCollector metricCollector = new BootstrapDumpMetricCollector(null, TEST_PATH, conf);
    ReplDumpWork replDumpWork = Mockito.mock(ReplDumpWork.class);
    Mockito.when(replDumpWork.getMetricCollector()).thenReturn(metricCollector);
    Mockito.when(replDumpWork.getCurrentDumpPath()).thenReturn(new Path(dumpDir));
    Mockito.when(replDumpWork.dataCopyIteratorsInitialized()).thenThrow(recoverableException);
    Task<ReplDumpWork> replDumpTask = TaskFactory.get(replDumpWork, conf);
    // ensure stages are missing initially and execute without reporting start metrics
    Assert.assertEquals(0, MetricCollector.getInstance().getMetrics().size());
    Assert.assertThrows(RuntimeException.class, () -> replDumpTask.execute());
    performRecoverableChecks("REPL_DUMP");
}
Also used : BootstrapDumpMetricCollector(org.apache.hadoop.hive.ql.parse.repl.dump.metric.BootstrapDumpMetricCollector) Path(org.apache.hadoop.fs.Path) ReplDumpWork(org.apache.hadoop.hive.ql.exec.repl.ReplDumpWork) Test(org.junit.Test)

Aggregations

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