Search in sources :

Example 1 with MReplicationMetrics

use of org.apache.hadoop.hive.metastore.model.MReplicationMetrics 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 2 with MReplicationMetrics

use of org.apache.hadoop.hive.metastore.model.MReplicationMetrics 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 3 with MReplicationMetrics

use of org.apache.hadoop.hive.metastore.model.MReplicationMetrics 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

ArrayList (java.util.ArrayList)3 ReplicationMetrics (org.apache.hadoop.hive.metastore.api.ReplicationMetrics)3 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 ReplicationMetricList (org.apache.hadoop.hive.metastore.api.ReplicationMetricList)2 MStringList (org.apache.hadoop.hive.metastore.model.MStringList)2 JDOObjectNotFoundException (javax.jdo.JDOObjectNotFoundException)1