Search in sources :

Example 6 with ReplicationMetrics

use of org.apache.hadoop.hive.metastore.api.ReplicationMetrics in project hive by apache.

the class TestReplicationMetrics method testGetMetricsByScheduleId.

@Test
public void testGetMetricsByScheduleId() throws Exception {
    ObjectStore objStore = new ObjectStore();
    objStore.setConf(metaStore.getConf());
    objStore.deleteReplicationMetrics(0);
    ReplicationMetricList replicationMetricList = new ReplicationMetricList();
    List<ReplicationMetrics> replicationMetrics = new ArrayList<>();
    replicationMetrics.add(createReplicationMetric("repl1", 1L));
    replicationMetrics.add(createReplicationMetric("repl1", 2L));
    replicationMetricList.setReplicationMetricList(replicationMetrics);
    objStore.addReplicationMetrics(replicationMetricList);
    Thread.sleep(1000);
    replicationMetrics = new ArrayList<>();
    replicationMetrics.add(createReplicationMetric("repl2", 3L));
    replicationMetrics.add(createReplicationMetric("repl2", 4L));
    replicationMetricList.setReplicationMetricList(replicationMetrics);
    objStore.addReplicationMetrics(replicationMetricList);
    Thread.sleep(1000);
    GetReplicationMetricsRequest getReplicationMetricsRequest = new GetReplicationMetricsRequest();
    getReplicationMetricsRequest.setScheduledExecutionId(1L);
    ReplicationMetricList actualList = client.getReplicationMetrics(getReplicationMetricsRequest);
    assertEquals(1, actualList.getReplicationMetricListSize());
    List<ReplicationMetrics> actualMetrics = actualList.getReplicationMetricList();
    // Ordering should be descending
    ReplicationMetrics actualMetric0 = actualMetrics.get(0);
    assertEquals("repl1", actualMetric0.getPolicy());
    assertEquals(1L, actualMetric0.getScheduledExecutionId());
    assertEquals(1, actualMetric0.getDumpExecutionId());
    assertEquals("metadata", actualMetric0.getMetadata());
    assertEquals("progress", actualMetric0.getProgress());
    // Update progress
    replicationMetrics = new ArrayList<>();
    replicationMetrics.add(updateReplicationMetric("repl1", 1L, "progress1"));
    replicationMetricList.setReplicationMetricList(replicationMetrics);
    objStore.addReplicationMetrics(replicationMetricList);
    Thread.sleep(1000);
    // get the metrics again
    getReplicationMetricsRequest = new GetReplicationMetricsRequest();
    getReplicationMetricsRequest.setScheduledExecutionId(1L);
    actualList = client.getReplicationMetrics(getReplicationMetricsRequest);
    assertEquals(1, actualList.getReplicationMetricListSize());
    actualMetrics = actualList.getReplicationMetricList();
    // Ordering should be descending
    actualMetric0 = actualMetrics.get(0);
    assertEquals("repl1", actualMetric0.getPolicy());
    assertEquals(1L, actualMetric0.getScheduledExecutionId());
    assertEquals(1, actualMetric0.getDumpExecutionId());
    assertEquals("metadata", actualMetric0.getMetadata());
    assertEquals("progress1", actualMetric0.getProgress());
}
Also used : GetReplicationMetricsRequest(org.apache.hadoop.hive.metastore.api.GetReplicationMetricsRequest) ObjectStore(org.apache.hadoop.hive.metastore.ObjectStore) ReplicationMetricList(org.apache.hadoop.hive.metastore.api.ReplicationMetricList) ReplicationMetrics(org.apache.hadoop.hive.metastore.api.ReplicationMetrics) ArrayList(java.util.ArrayList) Test(org.junit.Test) MetastoreUnitTest(org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest)

Example 7 with ReplicationMetrics

use of org.apache.hadoop.hive.metastore.api.ReplicationMetrics in project hive by apache.

the class TestReplicationMetrics method updateReplicationMetric.

private ReplicationMetrics updateReplicationMetric(String policyName, Long scheduleId, String progress) {
    ReplicationMetrics replicationMetrics = new ReplicationMetrics();
    replicationMetrics.setPolicy(policyName);
    replicationMetrics.setScheduledExecutionId(scheduleId);
    replicationMetrics.setProgress(progress);
    return replicationMetrics;
}
Also used : ReplicationMetrics(org.apache.hadoop.hive.metastore.api.ReplicationMetrics)

Example 8 with ReplicationMetrics

use of org.apache.hadoop.hive.metastore.api.ReplicationMetrics in project hive by apache.

the class ObjectStore method getMReplicationMetrics.

private ReplicationMetricList getMReplicationMetrics(long scheduledExecutionId) {
    ReplicationMetricList ret = new ReplicationMetricList();
    if (scheduledExecutionId < 0) {
        return ret;
    }
    try (QueryWrapper query = new QueryWrapper(pm.newQuery(MReplicationMetrics.class, "scheduledExecutionId == scheduledExecutionIdParam"))) {
        query.declareParameters("java.lang.Long scheduledExecutionIdParam");
        query.setOrdering("scheduledExecutionId descending");
        List<MReplicationMetrics> list = (List<MReplicationMetrics>) query.execute(scheduledExecutionId);
        List<ReplicationMetrics> returnList = new ArrayList<>();
        for (MReplicationMetrics mReplicationMetric : list) {
            pm.retrieve(mReplicationMetric);
            returnList.add(MReplicationMetrics.toThrift(mReplicationMetric));
        }
        ret.setReplicationMetricList(returnList);
        return ret;
    }
}
Also used : ReplicationMetricList(org.apache.hadoop.hive.metastore.api.ReplicationMetricList) ReplicationMetrics(org.apache.hadoop.hive.metastore.api.ReplicationMetrics) MReplicationMetrics(org.apache.hadoop.hive.metastore.model.MReplicationMetrics) MReplicationMetrics(org.apache.hadoop.hive.metastore.model.MReplicationMetrics) ArrayList(java.util.ArrayList) ValidWriteIdList(org.apache.hadoop.hive.common.ValidWriteIdList) ReplicationMetricList(org.apache.hadoop.hive.metastore.api.ReplicationMetricList) LinkedList(java.util.LinkedList) MStringList(org.apache.hadoop.hive.metastore.model.MStringList) ArrayList(java.util.ArrayList) ValidReaderWriteIdList(org.apache.hadoop.hive.common.ValidReaderWriteIdList) List(java.util.List)

Example 9 with ReplicationMetrics

use of org.apache.hadoop.hive.metastore.api.ReplicationMetrics in project hive by apache.

the class ObjectStore method getMReplicationMetrics.

private ReplicationMetricList getMReplicationMetrics(String policy) {
    ReplicationMetricList ret = new ReplicationMetricList();
    if (StringUtils.isEmpty(policy)) {
        return ret;
    }
    try (QueryWrapper query = new QueryWrapper(pm.newQuery(MReplicationMetrics.class, "policy == policyParam"))) {
        query.declareParameters("java.lang.String policyParam");
        query.setOrdering("scheduledExecutionId descending");
        List<MReplicationMetrics> list = (List<MReplicationMetrics>) query.execute(policy);
        List<ReplicationMetrics> returnList = new ArrayList<>();
        for (MReplicationMetrics mReplicationMetric : list) {
            pm.retrieve(mReplicationMetric);
            returnList.add(MReplicationMetrics.toThrift(mReplicationMetric));
        }
        ret.setReplicationMetricList(returnList);
        return ret;
    }
}
Also used : ReplicationMetricList(org.apache.hadoop.hive.metastore.api.ReplicationMetricList) ReplicationMetrics(org.apache.hadoop.hive.metastore.api.ReplicationMetrics) MReplicationMetrics(org.apache.hadoop.hive.metastore.model.MReplicationMetrics) MReplicationMetrics(org.apache.hadoop.hive.metastore.model.MReplicationMetrics) ArrayList(java.util.ArrayList) ValidWriteIdList(org.apache.hadoop.hive.common.ValidWriteIdList) ReplicationMetricList(org.apache.hadoop.hive.metastore.api.ReplicationMetricList) LinkedList(java.util.LinkedList) MStringList(org.apache.hadoop.hive.metastore.model.MStringList) ArrayList(java.util.ArrayList) ValidReaderWriteIdList(org.apache.hadoop.hive.common.ValidReaderWriteIdList) List(java.util.List)

Example 10 with ReplicationMetrics

use of org.apache.hadoop.hive.metastore.api.ReplicationMetrics in project hive by apache.

the class MReplicationMetrics method toThrift.

public static ReplicationMetrics toThrift(MReplicationMetrics mReplicationMetric) {
    ReplicationMetrics ret = new ReplicationMetrics();
    ret.setScheduledExecutionId(mReplicationMetric.scheduledExecutionId);
    ret.setPolicy(mReplicationMetric.policy);
    ret.setMetadata(mReplicationMetric.metadata);
    ret.setProgress(mReplicationMetric.progress);
    ret.setDumpExecutionId(mReplicationMetric.dumpExecutionId);
    ret.setMessageFormat(mReplicationMetric.messageFormat);
    return ret;
}
Also used : ReplicationMetrics(org.apache.hadoop.hive.metastore.api.ReplicationMetrics)

Aggregations

ReplicationMetrics (org.apache.hadoop.hive.metastore.api.ReplicationMetrics)11 ArrayList (java.util.ArrayList)7 ReplicationMetricList (org.apache.hadoop.hive.metastore.api.ReplicationMetricList)7 GetReplicationMetricsRequest (org.apache.hadoop.hive.metastore.api.GetReplicationMetricsRequest)5 Test (org.junit.Test)5 ObjectStore (org.apache.hadoop.hive.metastore.ObjectStore)4 MetastoreUnitTest (org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest)4 MReplicationMetrics (org.apache.hadoop.hive.metastore.model.MReplicationMetrics)3 LinkedList (java.util.LinkedList)2 List (java.util.List)2 ValidReaderWriteIdList (org.apache.hadoop.hive.common.ValidReaderWriteIdList)2 ValidWriteIdList (org.apache.hadoop.hive.common.ValidWriteIdList)2 MStringList (org.apache.hadoop.hive.metastore.model.MStringList)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 HashMap (java.util.HashMap)1 JDOObjectNotFoundException (javax.jdo.JDOObjectNotFoundException)1 ReplStatsTracker (org.apache.hadoop.hive.ql.exec.repl.ReplStatsTracker)1 SnapshotUtils (org.apache.hadoop.hive.ql.exec.repl.util.SnapshotUtils)1 BootstrapDumpMetricCollector (org.apache.hadoop.hive.ql.parse.repl.dump.metric.BootstrapDumpMetricCollector)1 IncrementalDumpMetricCollector (org.apache.hadoop.hive.ql.parse.repl.dump.metric.IncrementalDumpMetricCollector)1