use of org.apache.hadoop.hive.ql.parse.repl.metric.event.Stage in project hive by apache.
the class TestScheduledReplicationScenarios method generateLoadStages.
private List<Stage> generateLoadStages(boolean isBootstrap) {
List<Stage> stages = new ArrayList<>();
// Ranger
Stage rangerDump = new Stage("RANGER_LOAD", Status.SUCCESS, 0);
Metric rangerMetric = new Metric(ReplUtils.MetricName.POLICIES.name(), 0);
rangerDump.addMetric(rangerMetric);
stages.add(rangerDump);
// Atlas
Stage atlasDump = new Stage("ATLAS_LOAD", Status.SUCCESS, 0);
Metric atlasMetric = new Metric(ReplUtils.MetricName.ENTITIES.name(), 0);
atlasDump.addMetric(atlasMetric);
stages.add(atlasDump);
// Hive
Stage replDump = new Stage("REPL_LOAD", Status.SUCCESS, 0);
if (isBootstrap) {
Metric hiveMetric = new Metric(ReplUtils.MetricName.TABLES.name(), 1);
hiveMetric.setCurrentCount(1);
replDump.addMetric(hiveMetric);
hiveMetric = new Metric(ReplUtils.MetricName.FUNCTIONS.name(), 0);
replDump.addMetric(hiveMetric);
} else {
Metric hiveMetric = new Metric(ReplUtils.MetricName.EVENTS.name(), 1);
hiveMetric.setCurrentCount(1);
replDump.addMetric(hiveMetric);
}
stages.add(replDump);
return stages;
}
use of org.apache.hadoop.hive.ql.parse.repl.metric.event.Stage in project hive by apache.
the class ReplicationMetricCollector method reportStageStart.
public void reportStageStart(String stageName, Map<String, Long> metricMap) throws SemanticException {
if (isEnabled) {
LOG.debug("Stage Started {}, {}, {}", stageName, metricMap.size(), metricMap);
Progress progress = replicationMetric.getProgress();
progress.setStatus(Status.IN_PROGRESS);
Stage stage = new Stage(stageName, Status.IN_PROGRESS, getCurrentTimeInMillis());
for (Map.Entry<String, Long> metric : metricMap.entrySet()) {
stage.addMetric(new Metric(metric.getKey(), metric.getValue()));
}
progress.addStage(stage);
replicationMetric.setProgress(progress);
metricCollector.addMetric(replicationMetric);
}
}
use of org.apache.hadoop.hive.ql.parse.repl.metric.event.Stage in project hive by apache.
the class ReplicationMetricCollector method reportStageEnd.
public void reportStageEnd(String stageName, Status status, long lastReplId, SnapshotUtils.ReplSnapshotCount replSnapshotCount, ReplStatsTracker replStatsTracker) throws SemanticException {
unRegisterMBeanSafe();
if (isEnabled) {
LOG.debug("Stage ended {}, {}, {}", stageName, status, lastReplId);
Progress progress = replicationMetric.getProgress();
Stage stage = progress.getStageByName(stageName);
if (stage == null) {
stage = new Stage(stageName, status, -1L);
}
stage.setStatus(status);
stage.setEndTime(getCurrentTimeInMillis());
stage.setReplSnapshotsCount(replSnapshotCount);
if (replStatsTracker != null && !(replStatsTracker instanceof NoOpReplStatsTracker)) {
String replStatString = replStatsTracker.toString();
LOG.info("Replication Statistics are: {}", replStatString);
stage.setReplStats(replStatString);
}
progress.addStage(stage);
replicationMetric.setProgress(progress);
Metadata metadata = replicationMetric.getMetadata();
metadata.setLastReplId(lastReplId);
replicationMetric.setMetadata(metadata);
metricCollector.addMetric(replicationMetric);
if (Status.FAILED == status || Status.FAILED_ADMIN == status) {
reportEnd(status);
}
}
}
use of org.apache.hadoop.hive.ql.parse.repl.metric.event.Stage in project hive by apache.
the class ReplicationMetricCollector method reportStageProgress.
public void reportStageProgress(String stageName, String metricName, long count) throws SemanticException {
if (isEnabled) {
LOG.debug("Stage progress {}, {}, {}", stageName, metricName, count);
Progress progress = replicationMetric.getProgress();
Stage stage = progress.getStageByName(stageName);
Metric metric = stage.getMetricByName(metricName);
metric.setCurrentCount(metric.getCurrentCount() + count);
if (metric.getCurrentCount() > metric.getTotalCount()) {
metric.setTotalCount(metric.getCurrentCount());
}
stage.addMetric(metric);
replicationMetric.setProgress(progress);
metricCollector.addMetric(replicationMetric);
}
}
use of org.apache.hadoop.hive.ql.parse.repl.metric.event.Stage in project hive by apache.
the class ReplicationMetricCollector method reportStageEnd.
public void reportStageEnd(String stageName, Status status) throws SemanticException {
unRegisterMBeanSafe();
if (isEnabled) {
LOG.debug("Stage Ended {}, {}", stageName, status);
Progress progress = replicationMetric.getProgress();
Stage stage = progress.getStageByName(stageName);
if (stage == null) {
stage = new Stage(stageName, status, -1L);
}
stage.setStatus(status);
stage.setEndTime(getCurrentTimeInMillis());
progress.addStage(stage);
replicationMetric.setProgress(progress);
metricCollector.addMetric(replicationMetric);
if (Status.FAILED == status || Status.FAILED_ADMIN == status) {
reportEnd(status);
}
}
}
Aggregations