Java Code Examples for io.airlift.stats.TimeStat#BlockTimer

The following examples show how to use io.airlift.stats.TimeStat#BlockTimer . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BackupOperationStats.java    From presto with Apache License 2.0 6 votes vote down vote up
public <V> V run(Supplier<V> supplier)
{
    try (TimeStat.BlockTimer ignored = time.time()) {
        V value = supplier.get();
        successes.update(1);
        return value;
    }
    catch (PrestoException e) {
        if (e.getErrorCode().equals(RAPTOR_BACKUP_NOT_FOUND.toErrorCode())) {
            successes.update(1);
        }
        else if (e.getErrorCode().equals(RAPTOR_BACKUP_TIMEOUT.toErrorCode())) {
            timeouts.update(1);
        }
        else {
            failures.update(1);
        }
        throw e;
    }
}
 
Example 2
Source File: JdbcApiStats.java    From presto with Apache License 2.0 5 votes vote down vote up
public <V, E extends Exception> V wrap(ThrowingCallable<V, E> callable)
        throws E
{
    try (TimeStat.BlockTimer ignored = time.time()) {
        return callable.call();
    }
    catch (Exception e) {
        failures.update(1);
        throw e;
    }
}
 
Example 3
Source File: JdbcApiStats.java    From presto with Apache License 2.0 5 votes vote down vote up
public <E extends Exception> void wrap(ThrowingRunnable<E> callable)
        throws E
{
    try (TimeStat.BlockTimer ignored = time.time()) {
        callable.run();
    }
    catch (Exception e) {
        failures.update(1);
        throw e;
    }
}
 
Example 4
Source File: HiveFileIterator.java    From presto with Apache License 2.0 5 votes vote down vote up
private Iterator<LocatedFileStatus> getLocatedFileStatusRemoteIterator(Path path)
{
    try (TimeStat.BlockTimer ignored = namenodeStats.getListLocatedStatus().time()) {
        if (ignoreAbsentPartitions && !exists(path)) {
            return emptyIterator();
        }
        return new FileStatusIterator(table, path, fileSystem, directoryLister, namenodeStats);
    }
}
 
Example 5
Source File: GlueMetastoreApiStats.java    From presto with Apache License 2.0 5 votes vote down vote up
public <V, E extends Exception> V call(ThrowingCallable<V, E> callable)
        throws E
{
    try (TimeStat.BlockTimer ignored = time.time()) {
        return callable.call();
    }
    catch (Exception e) {
        totalFailures.update(1);
        throw e;
    }
}
 
Example 6
Source File: ThriftMetastoreApiStats.java    From presto with Apache License 2.0 5 votes vote down vote up
public <V> Callable<V> wrap(Callable<V> callable)
{
    return () -> {
        try (TimeStat.BlockTimer ignored = time.time()) {
            return callable.call();
        }
        catch (Exception e) {
            if (e instanceof MetaException) {
                metastoreExceptions.update(1);
                // Need to throw here instead of falling through due to JDK-8059299
                totalFailures.update(1);
                throw e;
            }

            if (e instanceof TException) {
                if (e instanceof TBase) {
                    // This exception is an API response and not a server error
                    throw e;
                }

                thriftExceptions.update(1);
                // Need to throw here instead of falling through due to JDK-8059299
                totalFailures.update(1);
                throw e;
            }

            totalFailures.update(1);
            throw e;
        }
    };
}
 
Example 7
Source File: NamenodeStats.java    From presto with Apache License 2.0 4 votes vote down vote up
public TimeStat.BlockTimer time()
{
    return time.time();
}
 
Example 8
Source File: HiveFileIterator.java    From presto with Apache License 2.0 4 votes vote down vote up
private LocatedFileStatus getLocatedFileStatus(Iterator<LocatedFileStatus> iterator)
{
    try (TimeStat.BlockTimer ignored = namenodeStats.getRemoteIteratorNext().time()) {
        return iterator.next();
    }
}