protected void destruct() { if (lockMgr != null) { try { lockMgr.close(); } catch (LockException e) { // Not much I can do about it. LOG.warn("Got exception when closing lock manager " + e.getMessage()); } } }
@Override public HiveLockManager getLockManager() throws LockException { if (lockMgr == null) { boolean supportConcurrency = conf.getBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY); if (supportConcurrency) { String lockMgrName = conf.getVar(HiveConf.ConfVars.HIVE_LOCK_MANAGER); if ((lockMgrName == null) || (lockMgrName.isEmpty())) { throw new LockException(ErrorMsg.LOCKMGR_NOT_SPECIFIED.getMsg()); } try { LOG.info("Creating lock manager of type " + lockMgrName); lockMgr = (HiveLockManager) ReflectionUtils.newInstance(conf.getClassByName(lockMgrName), conf); lockMgr.setContext(new HiveLockManagerCtx(conf)); } catch (Exception e) { // set hiveLockMgr to null just in case this invalid manager got set to // next query's ctx. if (lockMgr != null) { try { lockMgr.close(); } catch (LockException e1) { // nothing can do here } lockMgr = null; } throw new LockException(ErrorMsg.LOCKMGR_NOT_INITIALIZED.getMsg() + e.getMessage()); } } else { LOG.info("Concurrency mode is disabled, not creating a lock manager"); return null; } } // Force a re-read of the configuration file. This is done because // different queries in the session may be using the same lock manager. lockMgr.refresh(); return lockMgr; }