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