Search in sources :

Example 1 with Stage

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;
}
Also used : ArrayList(java.util.ArrayList) 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)

Example 2 with Stage

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);
    }
}
Also used : Progress(org.apache.hadoop.hive.ql.parse.repl.metric.event.Progress) 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) Map(java.util.Map)

Example 3 with Stage

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);
        }
    }
}
Also used : Progress(org.apache.hadoop.hive.ql.parse.repl.metric.event.Progress) NoOpReplStatsTracker(org.apache.hadoop.hive.ql.exec.repl.NoOpReplStatsTracker) Metadata(org.apache.hadoop.hive.ql.parse.repl.metric.event.Metadata) Stage(org.apache.hadoop.hive.ql.parse.repl.metric.event.Stage)

Example 4 with Stage

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);
    }
}
Also used : Progress(org.apache.hadoop.hive.ql.parse.repl.metric.event.Progress) 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)

Example 5 with Stage

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);
        }
    }
}
Also used : Progress(org.apache.hadoop.hive.ql.parse.repl.metric.event.Progress) Stage(org.apache.hadoop.hive.ql.parse.repl.metric.event.Stage)

Aggregations

Stage (org.apache.hadoop.hive.ql.parse.repl.metric.event.Stage)18 ReplicationMetric (org.apache.hadoop.hive.ql.parse.repl.metric.event.ReplicationMetric)16 Metric (org.apache.hadoop.hive.ql.parse.repl.metric.event.Metric)12 Progress (org.apache.hadoop.hive.ql.parse.repl.metric.event.Progress)12 Metadata (org.apache.hadoop.hive.ql.parse.repl.metric.event.Metadata)9 SnapshotUtils (org.apache.hadoop.hive.ql.exec.repl.util.SnapshotUtils)8 Test (org.junit.Test)8 HashMap (java.util.HashMap)6 ReplStatsTracker (org.apache.hadoop.hive.ql.exec.repl.ReplStatsTracker)6 IncrementalDumpMetricCollector (org.apache.hadoop.hive.ql.parse.repl.dump.metric.IncrementalDumpMetricCollector)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 BootstrapDumpMetricCollector (org.apache.hadoop.hive.ql.parse.repl.dump.metric.BootstrapDumpMetricCollector)2 BootstrapLoadMetricCollector (org.apache.hadoop.hive.ql.parse.repl.load.metric.BootstrapLoadMetricCollector)2 IncrementalLoadMetricCollector (org.apache.hadoop.hive.ql.parse.repl.load.metric.IncrementalLoadMetricCollector)2 MetricCollector (org.apache.hadoop.hive.ql.parse.repl.metric.MetricCollector)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Path (org.apache.hadoop.fs.Path)1 FsPermission (org.apache.hadoop.fs.permission.FsPermission)1 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)1