Search in sources :

Example 26 with Metrics

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;
    }
}
Also used : Metrics(org.apache.hadoop.hive.common.metrics.common.Metrics) CodahaleMetrics(org.apache.hadoop.hive.common.metrics.metrics2.CodahaleMetrics)

Example 27 with Metrics

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);
}
Also used : Metrics(org.apache.hadoop.hive.common.metrics.common.Metrics) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) ArrayList(java.util.ArrayList) SessionHandle(org.apache.hive.service.cli.SessionHandle) Date(java.util.Date)

Example 28 with Metrics

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();
    }
}
Also used : Metrics(org.apache.hadoop.hive.common.metrics.common.Metrics)

Example 29 with Metrics

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;
}
Also used : Metrics(org.apache.hadoop.hive.common.metrics.common.Metrics) SQLException(java.sql.SQLException) HiveSQLException(org.apache.hive.service.cli.HiveSQLException)

Aggregations

Metrics (org.apache.hadoop.hive.common.metrics.common.Metrics)29 ArrayList (java.util.ArrayList)7 IOException (java.io.IOException)6 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)5 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 MetricsFactory (org.apache.hadoop.hive.common.metrics.common.MetricsFactory)3 LockException (org.apache.hadoop.hive.ql.lockmgr.LockException)3 PerfLogger (org.apache.hadoop.hive.ql.log.PerfLogger)3 ThreadFactoryWithGarbageCleanup (org.apache.hive.service.server.ThreadFactoryWithGarbageCleanup)3 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)3 TProtocol (org.apache.thrift.protocol.TProtocol)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 SQLException (java.sql.SQLException)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 ExecutorService (java.util.concurrent.ExecutorService)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)2 MetricsScope (org.apache.hadoop.hive.common.metrics.common.MetricsScope)2