Search in sources :

Example 21 with ReplicationMetric

use of org.apache.hadoop.hive.ql.parse.repl.metric.event.ReplicationMetric in project hive by apache.

the class TestScheduledReplicationScenarios method checkMetrics.

private void checkMetrics(List<ReplicationMetric> expectedReplicationMetrics, List<ReplicationMetric> actualMetrics) {
    Assert.assertEquals(expectedReplicationMetrics.size(), actualMetrics.size());
    int metricCounter = 0;
    for (ReplicationMetric actualMetric : actualMetrics) {
        for (ReplicationMetric expecMetric : expectedReplicationMetrics) {
            if (actualMetric.getPolicy().equalsIgnoreCase(expecMetric.getPolicy())) {
                Assert.assertEquals(expecMetric.getDumpExecutionId(), actualMetric.getDumpExecutionId());
                Assert.assertEquals(expecMetric.getMetadata().getDbName(), actualMetric.getMetadata().getDbName());
                Assert.assertEquals(expecMetric.getMetadata().getLastReplId(), actualMetric.getMetadata().getLastReplId());
                Assert.assertEquals(expecMetric.getMetadata().getStagingDir(), actualMetric.getMetadata().getStagingDir());
                Assert.assertEquals(expecMetric.getMetadata().getReplicationType(), actualMetric.getMetadata().getReplicationType());
                Assert.assertEquals(expecMetric.getProgress().getStatus(), actualMetric.getProgress().getStatus());
                Assert.assertEquals(expecMetric.getProgress().getStages().size(), actualMetric.getProgress().getStages().size());
                List<Stage> expectedStages = expecMetric.getProgress().getStages();
                List<Stage> actualStages = actualMetric.getProgress().getStages();
                int counter = 0;
                for (Stage actualStage : actualStages) {
                    for (Stage expeStage : expectedStages) {
                        if (actualStage.getName().equalsIgnoreCase(expeStage.getName())) {
                            Assert.assertEquals(expeStage.getStatus(), actualStage.getStatus());
                            Assert.assertEquals(expeStage.getMetrics().size(), actualStage.getMetrics().size());
                            for (Metric actMetric : actualStage.getMetrics()) {
                                for (Metric expMetric : expeStage.getMetrics()) {
                                    if (actMetric.getName().equalsIgnoreCase(expMetric.getName())) {
                                        Assert.assertEquals(expMetric.getTotalCount(), actMetric.getTotalCount());
                                        Assert.assertEquals(expMetric.getCurrentCount(), actMetric.getCurrentCount());
                                    }
                                }
                            }
                            counter++;
                            if (counter == actualStages.size()) {
                                break;
                            }
                        }
                    }
                }
                metricCounter++;
                if (metricCounter == actualMetrics.size()) {
                    break;
                }
            }
        }
    }
}
Also used : 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) ReplicationMetric(org.apache.hadoop.hive.ql.parse.repl.metric.event.ReplicationMetric)

Aggregations

ReplicationMetric (org.apache.hadoop.hive.ql.parse.repl.metric.event.ReplicationMetric)21 Stage (org.apache.hadoop.hive.ql.parse.repl.metric.event.Stage)14 Progress (org.apache.hadoop.hive.ql.parse.repl.metric.event.Progress)12 Test (org.junit.Test)12 Metric (org.apache.hadoop.hive.ql.parse.repl.metric.event.Metric)10 HashMap (java.util.HashMap)8 SnapshotUtils (org.apache.hadoop.hive.ql.exec.repl.util.SnapshotUtils)8 Metadata (org.apache.hadoop.hive.ql.parse.repl.metric.event.Metadata)8 ReplStatsTracker (org.apache.hadoop.hive.ql.exec.repl.ReplStatsTracker)6 BootstrapDumpMetricCollector (org.apache.hadoop.hive.ql.parse.repl.dump.metric.BootstrapDumpMetricCollector)5 IncrementalDumpMetricCollector (org.apache.hadoop.hive.ql.parse.repl.dump.metric.IncrementalDumpMetricCollector)4 Path (org.apache.hadoop.fs.Path)3 BootstrapLoadMetricCollector (org.apache.hadoop.hive.ql.parse.repl.load.metric.BootstrapLoadMetricCollector)3 IncrementalLoadMetricCollector (org.apache.hadoop.hive.ql.parse.repl.load.metric.IncrementalLoadMetricCollector)3 Map (java.util.Map)2 MetricCollector (org.apache.hadoop.hive.ql.parse.repl.metric.MetricCollector)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 FileSystem (org.apache.hadoop.fs.FileSystem)1