Search in sources :

Example 76 with Duration

use of io.airlift.units.Duration in project presto by prestodb.

the class QueryStateMachine method recordDoneStats.

private void recordDoneStats() {
    Duration durationSinceCreation = nanosSince(createNanos).convertToMostSuccinctTimeUnit();
    queuedTime.compareAndSet(null, durationSinceCreation);
    totalPlanningStartNanos.compareAndSet(null, tickerNanos());
    totalPlanningTime.compareAndSet(null, nanosSince(totalPlanningStartNanos.get()));
    DateTime now = DateTime.now();
    executionStartTime.compareAndSet(null, now);
    finishingStartNanos.compareAndSet(null, tickerNanos());
    finishingTime.compareAndSet(null, nanosSince(finishingStartNanos.get()));
    endTime.compareAndSet(null, now);
    endNanos.compareAndSet(0, tickerNanos());
}
Also used : Duration(io.airlift.units.Duration) DateTime(org.joda.time.DateTime)

Example 77 with Duration

use of io.airlift.units.Duration in project presto by prestodb.

the class QueryStateMachine method transitionToRunning.

public boolean transitionToRunning() {
    Duration durationSinceCreation = nanosSince(createNanos).convertToMostSuccinctTimeUnit();
    queuedTime.compareAndSet(null, durationSinceCreation);
    totalPlanningStartNanos.compareAndSet(null, tickerNanos());
    totalPlanningTime.compareAndSet(null, nanosSince(totalPlanningStartNanos.get()));
    executionStartTime.compareAndSet(null, DateTime.now());
    return queryState.setIf(RUNNING, currentState -> currentState != RUNNING && currentState != FINISHING && !currentState.isDone());
}
Also used : Duration(io.airlift.units.Duration)

Example 78 with Duration

use of io.airlift.units.Duration in project presto by prestodb.

the class SqlQueryExecution method getTotalCpuTime.

@Override
public Duration getTotalCpuTime() {
    SqlQueryScheduler scheduler = queryScheduler.get();
    Optional<QueryInfo> finalQueryInfo = stateMachine.getFinalQueryInfo();
    if (finalQueryInfo.isPresent()) {
        return finalQueryInfo.get().getQueryStats().getTotalCpuTime();
    }
    if (scheduler == null) {
        return new Duration(0, SECONDS);
    }
    return scheduler.getTotalCpuTime();
}
Also used : SqlQueryScheduler(com.facebook.presto.execution.scheduler.SqlQueryScheduler) Duration(io.airlift.units.Duration)

Example 79 with Duration

use of io.airlift.units.Duration in project presto by prestodb.

the class Backoff method getTimeSinceLastSuccess.

public synchronized Duration getTimeSinceLastSuccess() {
    long lastSuccessfulRequest = this.lastSuccessTime;
    long value = ticker.read() - lastSuccessfulRequest;
    return new Duration(value, NANOSECONDS).convertToMostSuccinctTimeUnit();
}
Also used : Duration(io.airlift.units.Duration)

Example 80 with Duration

use of io.airlift.units.Duration in project presto by prestodb.

the class TestMemoryManagerConfig method testExplicitPropertyMappings.

@Test
public void testExplicitPropertyMappings() {
    Map<String, String> properties = new ImmutableMap.Builder<String, String>().put("query.low-memory-killer.enabled", "true").put("query.low-memory-killer.delay", "20s").put("query.max-memory", "2GB").build();
    MemoryManagerConfig expected = new MemoryManagerConfig().setKillOnOutOfMemory(true).setKillOnOutOfMemoryDelay(new Duration(20, SECONDS)).setMaxQueryMemory(new DataSize(2, GIGABYTE));
    assertFullMapping(properties, expected);
}
Also used : DataSize(io.airlift.units.DataSize) Duration(io.airlift.units.Duration) Test(org.testng.annotations.Test)

Aggregations

Duration (io.airlift.units.Duration)124 Test (org.testng.annotations.Test)66 DataSize (io.airlift.units.DataSize)35 URI (java.net.URI)12 TestingHttpClient (io.airlift.http.client.testing.TestingHttpClient)11 Session (com.facebook.presto.Session)9 DateTime (org.joda.time.DateTime)9 ImmutableMap (com.google.common.collect.ImmutableMap)8 ImmutableSet (com.google.common.collect.ImmutableSet)8 TestingTicker (io.airlift.testing.TestingTicker)8 List (java.util.List)8 PrestoException (com.facebook.presto.spi.PrestoException)7 ImmutableList (com.google.common.collect.ImmutableList)7 File (java.io.File)6 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)5 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)5 CyclicBarrier (java.util.concurrent.CyclicBarrier)5 Produces (javax.ws.rs.Produces)5 Type (com.facebook.presto.spi.type.Type)4 IOException (java.io.IOException)4