public int getOpenSessionsCount() { return cliService != null ? cliService.getSessionManager().getOpenSessionCount() : 0; }
public synchronized void closeSession(SessionHandle sessionHandle) throws HiveSQLException { HiveSession session = handleToSession.remove(sessionHandle); if (session == null) { throw new HiveSQLException("Session does not exist: " + sessionHandle); } LOG.info("Session closed, " + sessionHandle + ", current sessions:" + getOpenSessionCount()); closeSessionInternal(session); }
@Override public void process(WatchedEvent event) { super.process(event); if (event.getType().equals(Watcher.Event.EventType.NodeDeleted)) { // If there are no more active client sessions, stop the server if (cliService.getSessionManager().getOpenSessionCount() == 0) { LOG.warn("This instance of HiveServer2 has been removed from the list of server " + "instances available for dynamic service discovery. " + "The last client session has ended - will shutdown now."); HiveServer2.this.stop(); } } } }
private void closeSessionInternal(HiveSession session) throws HiveSQLException { try { session.close(); } finally { decrementConnections(session); // Shutdown HiveServer2 if it has been deregistered from ZooKeeper and has no active sessions if (!(hiveServer2 == null) && (hiveConf.getBoolVar(ConfVars.HIVE_SERVER2_SUPPORT_DYNAMIC_SERVICE_DISCOVERY)) && (hiveServer2.isDeregisteredWithZooKeeper())) { // Asynchronously shutdown this instance of HiveServer2, // if there are no active client sessions if (getOpenSessionCount() == 0) { LOG.info("This instance of HiveServer2 has been removed from the list of server " + "instances available for dynamic service discovery. " + "The last client session has ended - will shutdown now."); Thread shutdownThread = new Thread() { @Override public void run() { hiveServer2.stop(); } }; shutdownThread.start(); } } } }
+ ", current sessions:" + getOpenSessionCount()); return session;
public int getOpenSessionsCount() { return cliService != null ? cliService.getSessionManager().getOpenSessionCount() : 0; }
@Override public void process(WatchedEvent event) { if (event.getType().equals(Watcher.Event.EventType.NodeDeleted)) { if (znode != null) { try { znode.close(); LOG.warn("This HiveServer2 instance is now de-registered from ZooKeeper. " + "The server will be shut down after the last client sesssion completes."); } catch (IOException e) { LOG.error("Failed to close the persistent ephemeral znode", e); } finally { HiveServer2.this.setRegisteredWithZooKeeper(false); // If there are no more active client sessions, stop the server if (cliService.getSessionManager().getOpenSessionCount() == 0) { LOG.warn("This instance of HiveServer2 has been removed from the list of server " + "instances available for dynamic service discovery. " + "The last client session has ended - will shutdown now."); HiveServer2.this.stop(); } } } } } }
@Override public void process(WatchedEvent event) { if (event.getType().equals(Watcher.Event.EventType.NodeDeleted)) { if (znode != null) { try { znode.close(); LOG.warn("This HiveServer2 instance is now de-registered from ZooKeeper. " + "The server will be shut down after the last client session completes."); } catch (IOException e) { LOG.error("Failed to close the persistent ephemeral znode", e); } finally { HiveServer2.this.setDeregisteredWithZooKeeper(true); // If there are no more active client sessions, stop the server if (cliService.getSessionManager().getOpenSessionCount() == 0) { LOG.warn("This instance of HiveServer2 has been removed from the list of server " + "instances available for dynamic service discovery. " + "The last client session has ended - will shutdown now."); HiveServer2.this.stop(); } } } } } }
@Override public void process(WatchedEvent event) { if (event.getType().equals(Watcher.Event.EventType.NodeDeleted)) { if (znode != null) { try { znode.close(); LOG.warn("This HiveServer2 instance is now de-registered from ZooKeeper. " + "The server will be shut down after the last client sesssion completes."); } catch (IOException e) { LOG.error("Failed to close the persistent ephemeral znode", e); } finally { HiveServer2.this.setRegisteredWithZooKeeper(false); // If there are no more active client sessions, stop the server if (cliService.getSessionManager().getOpenSessionCount() == 0) { LOG.warn("This instance of HiveServer2 has been removed from the list of server " + "instances available for dynamic service discovery. " + "The last client session has ended - will shutdown now."); HiveServer2.this.stop(); } } } } } }
private void closeHiveSessions() { LOG.info("Closing all open hive sessions."); if (cliService != null && cliService.getSessionManager().getOpenSessionCount() > 0) { try { for (HiveSession session : cliService.getSessionManager().getSessions()) { cliService.getSessionManager().closeSession(session.getSessionHandle()); } LOG.info("Closed all open hive sessions"); } catch (HiveSQLException e) { LOG.error("Unable to close all open sessions.", e); } } }
public synchronized void closeSession(SessionHandle sessionHandle) throws HiveSQLException { HiveSession session = handleToSession.remove(sessionHandle); if (session == null) { throw new HiveSQLException("Session does not exist: " + sessionHandle); } LOG.info("Session closed, " + sessionHandle + ", current sessions:" + getOpenSessionCount()); try { session.close(); } finally { decrementConnections(session); // Shutdown HiveServer2 if it has been deregistered from ZooKeeper and has no active sessions if (!(hiveServer2 == null) && (hiveConf.getBoolVar(ConfVars.HIVE_SERVER2_SUPPORT_DYNAMIC_SERVICE_DISCOVERY)) && (hiveServer2.isDeregisteredWithZooKeeper())) { // Asynchronously shutdown this instance of HiveServer2, // if there are no active client sessions if (getOpenSessionCount() == 0) { LOG.info("This instance of HiveServer2 has been removed from the list of server " + "instances available for dynamic service discovery. " + "The last client session has ended - will shutdown now."); Thread shutdownThread = new Thread() { @Override public void run() { hiveServer2.stop(); } }; shutdownThread.start(); } } } }
public void closeSession(SessionHandle sessionHandle) throws HiveSQLException { HiveSession session = handleToSession.remove(sessionHandle); if (session == null) { throw new HiveSQLException("Session does not exist!"); } try { session.close(); } finally { // Shutdown HiveServer2 if it has been deregistered from ZooKeeper and has no active sessions if (!(hiveServer2 == null) && (hiveConf.getBoolVar(ConfVars.HIVE_SERVER2_SUPPORT_DYNAMIC_SERVICE_DISCOVERY)) && (!hiveServer2.isRegisteredWithZooKeeper())) { // Asynchronously shutdown this instance of HiveServer2, // if there are no active client sessions if (getOpenSessionCount() == 0) { LOG.info("This instance of HiveServer2 has been removed from the list of server " + "instances available for dynamic service discovery. " + "The last client session has ended - will shutdown now."); Thread shutdownThread = new Thread() { @Override public void run() { hiveServer2.stop(); } }; shutdownThread.start(); } } } }
public void closeSession(SessionHandle sessionHandle) throws HiveSQLException { HiveSession session = handleToSession.remove(sessionHandle); if (session == null) { throw new HiveSQLException("Session does not exist!"); } try { session.close(); } finally { // Shutdown HiveServer2 if it has been deregistered from ZooKeeper and has no active sessions if (!(hiveServer2 == null) && (hiveConf.getBoolVar(ConfVars.HIVE_SERVER2_SUPPORT_DYNAMIC_SERVICE_DISCOVERY)) && (!hiveServer2.isRegisteredWithZooKeeper())) { // Asynchronously shutdown this instance of HiveServer2, // if there are no active client sessions if (getOpenSessionCount() == 0) { LOG.info("This instance of HiveServer2 has been removed from the list of server " + "instances available for dynamic service discovery. " + "The last client session has ended - will shutdown now."); Thread shutdownThread = new Thread() { @Override public void run() { hiveServer2.stop(); } }; shutdownThread.start(); } } } }
LOG.info("Session opened, " + session.getSessionHandle() + ", current sessions:" + getOpenSessionCount()); return session;