use of org.apache.hadoop.hive.ql.lockmgr.HiveLockMode in project hive by apache.
the class MoveTask method acquireLockForFileMove.
private LocalTableLock acquireLockForFileMove(LoadTableDesc loadTableWork) throws HiveException {
LockFileMoveMode mode = LockFileMoveMode.fromConf(conf);
if (mode == LockFileMoveMode.NONE) {
return new LocalTableLock();
}
if (mode == LockFileMoveMode.DP && loadTableWork.getDPCtx() == null) {
return new LocalTableLock();
}
WriteEntity output = context.getLoadTableOutputMap().get(loadTableWork);
List<HiveLockObj> lockObjects = context.getOutputLockObjects().get(output);
if (lockObjects == null) {
return new LocalTableLock();
}
TableDesc table = loadTableWork.getTable();
if (table == null) {
return new LocalTableLock();
}
Hive db = getHive();
Table baseTable = db.getTable(loadTableWork.getTable().getTableName());
HiveLockObject.HiveLockObjectData lockData = new HiveLockObject.HiveLockObjectData(queryPlan.getQueryId(), String.valueOf(System.currentTimeMillis()), "IMPLICIT", queryPlan.getQueryStr(), conf);
HiveLockObject lock = new HiveLockObject(baseTable, lockData);
for (HiveLockObj hiveLockObj : lockObjects) {
if (Arrays.equals(hiveLockObj.getObj().getPaths(), lock.getPaths())) {
HiveLockMode l = hiveLockObj.getMode();
if (l == HiveLockMode.EXCLUSIVE || l == HiveLockMode.SEMI_SHARED) {
// no need to lock ; already owns a more powerful one
return new LocalTableLock();
}
}
}
return new LocalTableLock(lock);
}
Aggregations