use of org.apache.hadoop.hive.ql.parse.repl.load.metric.BootstrapLoadMetricCollector in project hive by apache.
the class TestReplicationScenarios method getReplLoadRootTask.
private Task getReplLoadRootTask(String sourceDb, String replicadb, boolean isIncrementalDump, Tuple tuple) throws Throwable {
HiveConf confTemp = driverMirror.getConf();
Path loadPath = new Path(tuple.dumpLocation, ReplUtils.REPL_HIVE_BASE_DIR);
ReplicationMetricCollector metricCollector;
if (isIncrementalDump) {
metricCollector = new IncrementalLoadMetricCollector(replicadb, tuple.dumpLocation, 0, confTemp);
} else {
metricCollector = new BootstrapLoadMetricCollector(replicadb, tuple.dumpLocation, 0, confTemp);
}
/* When 'hive.repl.retain.custom.db.locations.on.target' is enabled, the first iteration of repl load would
run only database creation task, and only in next iteration of Repl Load Task execution, remaining tasks will be
executed. Hence disabling this to perform the test on task optimization. */
confTemp.setBoolVar(HiveConf.ConfVars.REPL_RETAIN_CUSTOM_LOCATIONS_FOR_DB_ON_TARGET, false);
ReplLoadWork replLoadWork = new ReplLoadWork(confTemp, loadPath.toString(), sourceDb, replicadb, null, null, isIncrementalDump, Long.valueOf(tuple.lastReplId), 0L, metricCollector, false);
Task replLoadTask = TaskFactory.get(replLoadWork, confTemp);
replLoadTask.initialize(null, null, new TaskQueue(driver.getContext()), driver.getContext());
replLoadTask.executeTask(null);
Hive.closeCurrent();
return replLoadWork.getRootTask();
}
use of org.apache.hadoop.hive.ql.parse.repl.load.metric.BootstrapLoadMetricCollector in project hive by apache.
the class TestReplicationMetricCollector method testSuccessBootstrapLoadMetrics.
@Test
public void testSuccessBootstrapLoadMetrics() throws Exception {
ReplicationMetricCollector bootstrapLoadMetricCollector = new BootstrapLoadMetricCollector("db", "dummyDir", 1, conf);
Map<String, Long> metricMap = new HashMap<>();
metricMap.put(ReplUtils.MetricName.TABLES.name(), (long) 10);
metricMap.put(ReplUtils.MetricName.FUNCTIONS.name(), (long) 1);
bootstrapLoadMetricCollector.reportStageStart("dump", metricMap);
bootstrapLoadMetricCollector.reportStageProgress("dump", ReplUtils.MetricName.TABLES.name(), 1);
List<ReplicationMetric> actualMetrics = MetricCollector.getInstance().getMetrics();
Assert.assertEquals(1, actualMetrics.size());
bootstrapLoadMetricCollector.reportStageProgress("dump", ReplUtils.MetricName.TABLES.name(), 2);
bootstrapLoadMetricCollector.reportStageProgress("dump", ReplUtils.MetricName.FUNCTIONS.name(), 1);
actualMetrics = MetricCollector.getInstance().getMetrics();
Assert.assertEquals(1, actualMetrics.size());
bootstrapLoadMetricCollector.reportStageEnd("dump", Status.SUCCESS, 10, new SnapshotUtils.ReplSnapshotCount(), new ReplStatsTracker(0));
bootstrapLoadMetricCollector.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", 1, expectedMetadata);
expectedMetric.setProgress(expectedProgress);
checkSuccess(actualMetrics.get(0), expectedMetric, "dump", Arrays.asList(ReplUtils.MetricName.TABLES.name(), ReplUtils.MetricName.FUNCTIONS.name()));
}
use of org.apache.hadoop.hive.ql.parse.repl.load.metric.BootstrapLoadMetricCollector in project hive by apache.
the class TestReplicationMetricUpdateOnFailure method testReplLoadRecoverableMissingStage.
@Test
public void testReplLoadRecoverableMissingStage() throws Exception {
String dumpDir = TEST_PATH + Path.SEPARATOR + testName.getMethodName();
MetricCollector.getInstance().deinit();
BootstrapLoadMetricCollector metricCollector = new BootstrapLoadMetricCollector(null, TEST_PATH, 0, conf);
ReplLoadWork replLoadWork = Mockito.mock(ReplLoadWork.class);
Mockito.when(replLoadWork.getTargetDatabase()).thenReturn("dummy");
Mockito.when(replLoadWork.getDumpDirectory()).thenReturn(new Path(dumpDir + Path.SEPARATOR + "test").toString());
Mockito.when(replLoadWork.getMetricCollector()).thenReturn(metricCollector);
Mockito.when(replLoadWork.getRootTask()).thenThrow(recoverableException);
Task replLoadTask = TaskFactory.get(replLoadWork, conf);
// ensure stages are missing initially and execute without reporting start metrics
Assert.assertEquals(0, MetricCollector.getInstance().getMetrics().size());
Assert.assertThrows(RuntimeException.class, () -> replLoadTask.execute());
performRecoverableChecks("REPL_LOAD");
}
Aggregations