Search in sources :

Example 11 with ReplicationMetrics

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

the class ObjectStore method addReplicationMetrics.

@Override
public void addReplicationMetrics(ReplicationMetricList replicationMetricList) {
    boolean commited = false;
    try {
        openTransaction();
        List<MReplicationMetrics> mReplicationMetricsList = new ArrayList<>();
        for (ReplicationMetrics replicationMetric : replicationMetricList.getReplicationMetricList()) {
            MReplicationMetrics mReplicationMetrics;
            try {
                mReplicationMetrics = pm.getObjectById(MReplicationMetrics.class, replicationMetric.getScheduledExecutionId());
            } catch (JDOObjectNotFoundException e) {
                mReplicationMetrics = new MReplicationMetrics();
                mReplicationMetrics.setDumpExecutionId(replicationMetric.getDumpExecutionId());
                mReplicationMetrics.setScheduledExecutionId(replicationMetric.getScheduledExecutionId());
                mReplicationMetrics.setPolicy(replicationMetric.getPolicy());
                mReplicationMetrics.setStartTime((int) (System.currentTimeMillis() / 1000));
            }
            if (!StringUtils.isEmpty(replicationMetric.getMetadata())) {
                if (replicationMetric.getMetadata().length() > RM_METADATA_COL_WIDTH) {
                    mReplicationMetrics.setProgress("RM_Metadata limit exceeded to " + replicationMetric.getMetadata().length());
                } else {
                    mReplicationMetrics.setMetadata(replicationMetric.getMetadata());
                }
            }
            if (!StringUtils.isEmpty(replicationMetric.getProgress())) {
                // Check for the limit of RM_PROGRESS Column.
                if ((dbType.isORACLE() && replicationMetric.getProgress().length() > ORACLE_DB_MAX_COL_WIDTH) || replicationMetric.getProgress().length() > RM_PROGRESS_COL_WIDTH) {
                    mReplicationMetrics.setProgress("RM_Progress limit exceeded to " + replicationMetric.getProgress().length());
                } else {
                    mReplicationMetrics.setProgress(replicationMetric.getProgress());
                }
            }
            mReplicationMetrics.setMessageFormat(replicationMetric.getMessageFormat());
            mReplicationMetricsList.add(mReplicationMetrics);
        }
        pm.makePersistentAll(mReplicationMetricsList);
        commited = commitTransaction();
    } finally {
        if (!commited) {
            rollbackTransaction();
        }
    }
}
Also used : JDOObjectNotFoundException(javax.jdo.JDOObjectNotFoundException) 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)

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