@Override public String getSessionUser() { return hiveSession.getUserName(); }
private void decrementUserQueries(Metrics metrics) { String username = parentSession.getUserName(); if (username != null) { synchronized (userQueries) { AtomicInteger count = userQueries.get(username); if (count != null && count.decrementAndGet() <= 0) { metrics.decrementCounter(ACTIVE_SQL_USER); userQueries.remove(username); } } } }
private void incrementUserQueries(Metrics metrics) { String username = parentSession.getUserName(); if (username != null) { synchronized (userQueries) { AtomicInteger count = userQueries.get(username); if (count == null) { count = new AtomicInteger(0); AtomicInteger prev = userQueries.put(username, count); if (prev == null) { metrics.incrementCounter(ACTIVE_SQL_USER); } else { count = prev; } } count.incrementAndGet(); } } }
private boolean cancelOperation(Operation operation, boolean isAdmin, String errMsg) throws HiveSQLException { if (isAdmin || operation.getParentSession().getUserName().equals(SessionState.get() .getAuthenticator().getUserName())) { OperationHandle handle = operation.getHandle(); operationManager.cancelOperation(handle, errMsg); return true; } else { return false; } }
@Before public void setup() throws Exception { HiveConf conf = new HiveConf(); conf.setBoolVar(HiveConf.ConfVars.HIVE_SERVER2_METRICS_ENABLED, true); MetricsFactory.init(conf); HiveSession session = mock(HiveSession.class); when(session.getHiveConf()).thenReturn(conf); when(session.getSessionState()).thenReturn(mock(SessionState.class)); when(session.getUserName()).thenReturn("userName"); operation = new SQLOperation(session, "select * from dummy", Maps.<String, String>newHashMap(), false, 0L); metrics = (CodahaleMetrics) MetricsFactory.getInstance(); }
private void decrementConnections(final HiveSession session) { final String username = session.getUserName(); final String clientIpAddress = getOriginClientIpAddress(session.getIpAddress(), session.getForwardedAddresses()); if (trackConnectionsPerUser(username)) { connectionsCount.computeIfPresent(username, (k, v) -> v).decrement(); } if (trackConnectionsPerIpAddress(clientIpAddress)) { connectionsCount.computeIfPresent(clientIpAddress, (k, v) -> v).decrement(); } if (trackConnectionsPerUserIpAddress(username, clientIpAddress)) { connectionsCount.computeIfPresent(username + ":" + clientIpAddress, (k, v) -> v).decrement(); } }
setState(OperationState.RUNNING); try { driver = DriverFactory.newDriver(queryState, getParentSession().getUserName(), queryInfo);
public SQLOperation(HiveSession parentSession, String statement, Map<String, String> confOverlay, boolean runInBackground, long queryTimeout) { // TODO: call setRemoteUser in ExecuteStatementOperation or higher. super(parentSession, statement, confOverlay, runInBackground); this.runAsync = runInBackground; this.queryTimeout = queryTimeout; long timeout = HiveConf.getTimeVar(queryState.getConf(), HiveConf.ConfVars.HIVE_QUERY_TIMEOUT_SECONDS, TimeUnit.SECONDS); if (timeout > 0 && (queryTimeout <= 0 || timeout < queryTimeout)) { this.queryTimeout = timeout; } this.operationLogCleanupDelayMs = HiveConf.getTimeVar(queryState.getConf(), HiveConf.ConfVars.HIVE_SERVER2_OPERATION_LOG_CLEANUP_DELAY, TimeUnit.MILLISECONDS); setupSessionIO(parentSession.getSessionState()); queryInfo = new QueryInfo(getState().toString(), getParentSession().getUserName(), getExecutionEngine(), getHandle().getHandleIdentifier().toString()); Metrics metrics = MetricsFactory.getInstance(); if (metrics != null) { submittedQryScp = metrics.createScope(MetricsConstant.HS2_SUBMITTED_QURIES); } }
for (HiveSession hiveSession: hiveSessions) { if (!HttpServer.hasAccess(remoteUser, hiveSession.getUserName(), ctx, request)) { continue; out.print( hiveSession.getUserName() ); out.write("</td>\n <td>"); out.print( hiveSession.getIpAddress() );
@Override public String getSessionUser() { return hiveSession.getUserName(); }
@Override public String getSessionUser() { return hiveSession.getUserName(); }
@Override public String getSessionUser() { return hiveSession.getUserName(); }
@Override public String getSessionUser() { return hiveSession.getUserName(); }
@Override public String getSessionUser() { return hiveSession.getUserName(); }
private void decrementUserQueries(Metrics metrics) { String username = parentSession.getUserName(); if (username != null) { synchronized (userQueries) { AtomicInteger count = userQueries.get(username); if (count != null && count.decrementAndGet() <= 0) { metrics.decrementCounter(ACTIVE_SQL_USER); userQueries.remove(username); } } } }
private void incrementUserQueries(Metrics metrics) { String username = parentSession.getUserName(); if (username != null) { synchronized (userQueries) { AtomicInteger count = userQueries.get(username); if (count == null) { count = new AtomicInteger(0); AtomicInteger prev = userQueries.put(username, count); if (prev == null) { metrics.incrementCounter(ACTIVE_SQL_USER); } else { count = prev; } } count.incrementAndGet(); } } }
setState(OperationState.RUNNING); try { driver = DriverFactory.newDriver(queryState, getParentSession().getUserName(), queryInfo);
private void decrementConnections(final HiveSession session) { final String username = session.getUserName(); final String clientIpAddress = getOriginClientIpAddress(session.getIpAddress(), session.getForwardedAddresses()); if (trackConnectionsPerUser(username)) { connectionsCount.computeIfPresent(username, (k, v) -> v).decrement(); } if (trackConnectionsPerIpAddress(clientIpAddress)) { connectionsCount.computeIfPresent(clientIpAddress, (k, v) -> v).decrement(); } if (trackConnectionsPerUserIpAddress(username, clientIpAddress)) { connectionsCount.computeIfPresent(username + ":" + clientIpAddress, (k, v) -> v).decrement(); } }
driver = new Driver(sqlOperationConf, getParentSession().getUserName());
public SQLOperation(HiveSession parentSession, String statement, Map<String, String> confOverlay, boolean runInBackground, long queryTimeout) { // TODO: call setRemoteUser in ExecuteStatementOperation or higher. super(parentSession, statement, confOverlay, runInBackground); this.runAsync = runInBackground; this.queryTimeout = queryTimeout; long timeout = HiveConf.getTimeVar(queryState.getConf(), HiveConf.ConfVars.HIVE_QUERY_TIMEOUT_SECONDS, TimeUnit.SECONDS); if (timeout > 0 && (queryTimeout <= 0 || timeout < queryTimeout)) { this.queryTimeout = timeout; } this.operationLogCleanupDelayMs = HiveConf.getTimeVar(queryState.getConf(), HiveConf.ConfVars.HIVE_SERVER2_OPERATION_LOG_CLEANUP_DELAY, TimeUnit.MILLISECONDS); setupSessionIO(parentSession.getSessionState()); queryInfo = new QueryInfo(getState().toString(), getParentSession().getUserName(), getExecutionEngine(), getHandle().getHandleIdentifier().toString()); Metrics metrics = MetricsFactory.getInstance(); if (metrics != null) { submittedQryScp = metrics.createScope(MetricsConstant.HS2_SUBMITTED_QURIES); } }