@Override public Integer getValue() { long sum = 0; long currentTime = System.currentTimeMillis(); for (HiveSession s : getSessions()) { if (s.getNoOperationTime() == 0L) { sum += currentTime - s.getLastAccessTime(); } } // in case of an overflow return -1 return (int) sum != sum ? -1 : (int) sum; } };
&& (!checkOperation || session.getNoOperationTime() > sessionTimeout)) { SessionHandle handle = session.getSessionHandle(); LOG.warn("Session " + handle + " is Timed-out (last access : " +
@Test public void testSessionImplWithUGI() throws Exception { HiveConf hiveConf = new HiveConf(); hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER.getDefaultValue()); hiveConf.setVar(HiveConf.ConfVars.HIVE_SESSION_IMPL_WITH_UGI_CLASSNAME, SampleHiveSessionImplWithUGI.class.getName()); hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_SERVER2_ENABLE_DOAS, true); CLIService cliService = new CLIService(null, true); cliService.init(hiveConf); ThriftBinaryCLIService service = new ThriftBinaryCLIService(cliService, null); service.init(hiveConf); ThriftCLIServiceClient client = new ThriftCLIServiceClient(service); SessionHandle sessionHandle = null; sessionHandle = client.openSession("tom", "password"); assertEquals(SampleHiveSessionImplWithUGI.class.getName(), service.getHiveConf().getVar(HiveConf.ConfVars.HIVE_SESSION_IMPL_WITH_UGI_CLASSNAME)); HiveSession session = cliService.getSessionManager().getSession(sessionHandle); assertEquals(SampleHiveSessionImplWithUGI.MAGIC_RETURN_VALUE, session.getNoOperationTime()); client.closeSession(sessionHandle); }
@Test public void testSessionImpl() throws Exception { HiveConf hiveConf = new HiveConf(); hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER.getDefaultValue()); hiveConf.setVar(HiveConf.ConfVars.HIVE_SESSION_IMPL_CLASSNAME, SampleHiveSessionImpl.class.getName()); hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_SERVER2_ENABLE_DOAS, false); CLIService cliService = new CLIService(null, true); cliService.init(hiveConf); ThriftBinaryCLIService service = new ThriftBinaryCLIService(cliService, null); service.init(hiveConf); ThriftCLIServiceClient client = new ThriftCLIServiceClient(service); SessionHandle sessionHandle = null; sessionHandle = client.openSession("tom", "password"); assertEquals(SampleHiveSessionImpl.class.getName(), service.getHiveConf().getVar(HiveConf.ConfVars.HIVE_SESSION_IMPL_CLASSNAME)); HiveSession session = cliService.getSessionManager().getSession(sessionHandle); assertEquals(SampleHiveSessionImpl.MAGIC_RETURN_VALUE, session.getNoOperationTime()); client.closeSession(sessionHandle); }
@Override public Integer getValue() { long sum = 0; long currentTime = System.currentTimeMillis(); for (HiveSession s : getSessions()) { if (s.getNoOperationTime() == 0L) { sum += currentTime - s.getLastAccessTime(); } } // in case of an overflow return -1 return (int) sum != sum ? -1 : (int) sum; } };
@Override public void run() { for (sleepInterval(interval); !shutdown; sleepInterval(interval)) { long current = System.currentTimeMillis(); for (HiveSession session : new ArrayList<HiveSession>(handleToSession.values())) { if (sessionTimeout > 0 && session.getLastAccessTime() + sessionTimeout <= current && (!checkOperation || session.getNoOperationTime() > sessionTimeout)) { SessionHandle handle = session.getSessionHandle(); LOG.warn("Session " + handle + " is Timed-out (last access : " + new Date(session.getLastAccessTime()) + ") and will be closed"); try { closeSession(handle); } catch (HiveSQLException e) { LOG.warn("Exception is thrown closing session " + handle, e); } } else { session.closeExpiredOperations(); } } } }
@Override public void run() { for (sleepInterval(interval); !shutdown; sleepInterval(interval)) { long current = System.currentTimeMillis(); for (HiveSession session : new ArrayList<HiveSession>(handleToSession.values())) { if (sessionTimeout > 0 && session.getLastAccessTime() + sessionTimeout <= current && (!checkOperation || session.getNoOperationTime() > sessionTimeout)) { SessionHandle handle = session.getSessionHandle(); LOG.warn("Session " + handle + " is Timed-out (last access : " + new Date(session.getLastAccessTime()) + ") and will be closed"); try { closeSession(handle); } catch (HiveSQLException e) { LOG.warn("Exception is thrown closing session " + handle, e); } } else { session.closeExpiredOperations(); } } } }
@Override public void run() { for (sleepInterval(interval); !shutdown; sleepInterval(interval)) { long current = System.currentTimeMillis(); for (HiveSession session : new ArrayList<HiveSession>(handleToSession.values())) { if (sessionTimeout > 0 && session.getLastAccessTime() + sessionTimeout <= current && (!checkOperation || session.getNoOperationTime() > sessionTimeout)) { SessionHandle handle = session.getSessionHandle(); LOG.warn("Session " + handle + " is Timed-out (last access : " + new Date(session.getLastAccessTime()) + ") and will be closed"); try { closeSession(handle); } catch (HiveSQLException e) { LOG.warn("Exception is thrown closing session " + handle, e); } } else { session.closeExpiredOperations(); } } } }
@Override public void run() { for (sleepInterval(interval); !shutdown; sleepInterval(interval)) { long current = System.currentTimeMillis(); for (HiveSession session : new ArrayList<HiveSession>(handleToSession.values())) { if (sessionTimeout > 0 && session.getLastAccessTime() + sessionTimeout <= current && (!checkOperation || session.getNoOperationTime() > sessionTimeout)) { SessionHandle handle = session.getSessionHandle(); LOG.warn("Session " + handle + " is Timed-out (last access : " + new Date(session.getLastAccessTime()) + ") and will be closed"); try { closeSession(handle); } catch (HiveSQLException e) { LOG.warn("Exception is thrown closing session " + handle, e); } } else { session.closeExpiredOperations(); } } } }
&& (!checkOperation || session.getNoOperationTime() > sessionTimeout)) { SessionHandle handle = session.getSessionHandle(); LOG.warn("Session " + handle + " is Timed-out (last access : " +