use of org.apache.hadoop.hive.common.metrics.common.Metrics in project hive by apache.
the class WmPoolMetrics method destroy.
public void destroy() {
ms.unregisterSource(sourceName);
ms = null;
if (codahaleGaugeNames != null) {
Metrics metrics = MetricsFactory.getInstance();
for (String chgName : codahaleGaugeNames) {
metrics.removeGauge(chgName);
}
codahaleGaugeNames = null;
}
}
use of org.apache.hadoop.hive.common.metrics.common.Metrics in project hive by apache.
the class SessionManager method startTimeoutChecker.
private void startTimeoutChecker() {
// minimum 3 seconds
final long interval = Math.max(checkInterval, 3000l);
final Runnable timeoutChecker = new Runnable() {
@Override
public void run() {
sleepFor(interval);
while (!shutdown) {
long current = System.currentTimeMillis();
for (HiveSession session : new ArrayList<HiveSession>(handleToSession.values())) {
if (shutdown) {
break;
}
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);
} finally {
Metrics metrics = MetricsFactory.getInstance();
if (metrics != null) {
metrics.incrementCounter(MetricsConstant.HS2_ABANDONED_SESSIONS);
}
}
} else {
session.closeExpiredOperations();
}
}
sleepFor(interval);
}
}
private void sleepFor(long interval) {
synchronized (timeoutCheckerLock) {
try {
timeoutCheckerLock.wait(interval);
} catch (InterruptedException e) {
// Ignore, and break.
}
}
}
};
backgroundOperationPool.execute(timeoutChecker);
}
use of org.apache.hadoop.hive.common.metrics.common.Metrics in project hive by apache.
the class Operation method run.
public void run() throws HiveSQLException {
beforeRun();
try {
Metrics metrics = MetricsFactory.getInstance();
if (metrics != null) {
metrics.incrementCounter(MetricsConstant.OPEN_OPERATIONS);
}
runInternal();
} finally {
afterRun();
}
}
use of org.apache.hadoop.hive.common.metrics.common.Metrics in project hive by apache.
the class OperationManager method removeTimedOutOperation.
private Operation removeTimedOutOperation(OperationHandle operationHandle) {
Operation operation = handleToOperation.get(operationHandle);
if (operation != null && operation.isTimedOut(System.currentTimeMillis())) {
LOG.info("Operation is timed out,operation=" + operation.getHandle() + ",state=" + operation.getState().toString());
Metrics metrics = MetricsFactory.getInstance();
if (metrics != null) {
try {
metrics.decrementCounter(MetricsConstant.OPEN_OPERATIONS);
} catch (Exception e) {
LOG.warn("Error decrementing open_operations metric, reported values may be incorrect", e);
}
}
return removeOperation(operationHandle);
}
return null;
}
Aggregations