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();
}
}
}
Aggregations