use of io.airlift.units.Duration in project presto by prestodb.
the class TestSplitConcurrencyController method testRapidAdjustForQuickSplits.
@Test
public void testRapidAdjustForQuickSplits() {
SplitConcurrencyController controller = new SplitConcurrencyController(10, new Duration(1, SECONDS));
for (int i = 0; i < 9; i++) {
controller.update(MILLISECONDS.toNanos(200), 1, 10 - i);
controller.splitFinished(MILLISECONDS.toNanos(100), 1, 10 - i);
assertEquals(controller.getTargetConcurrency(), 10 - i - 1);
}
controller.update(SECONDS.toNanos(30), 0, 1);
for (int i = 0; i < 10; i++) {
controller.update(SECONDS.toNanos(200), 0, i + 1);
controller.splitFinished(MILLISECONDS.toNanos(100), 0, i + 1);
assertEquals(controller.getTargetConcurrency(), i + 2);
}
}
use of io.airlift.units.Duration in project presto by prestodb.
the class TestServerConfig method testExplicitPropertyMappings.
@Test
public void testExplicitPropertyMappings() {
Map<String, String> properties = new ImmutableMap.Builder<String, String>().put("coordinator", "false").put("presto.version", "test").put("datasources", "jmx").put("http.include-exception-in-response", "false").put("shutdown.grace-period", "5m").build();
ServerConfig expected = new ServerConfig().setCoordinator(false).setPrestoVersion("test").setDataSources("jmx").setIncludeExceptionInResponse(false).setGracePeriod(new Duration(5, MINUTES));
assertFullMapping(properties, expected);
}
use of io.airlift.units.Duration in project presto by prestodb.
the class TestBackoff method testMaxFailureInterval.
@Test
public void testMaxFailureInterval() {
TestingTicker ticker = new TestingTicker();
Backoff backoff = new Backoff(new Duration(5, SECONDS), new Duration(15, SECONDS), ticker, new Duration(10, MILLISECONDS));
ticker.increment(10, MICROSECONDS);
ticker.increment(6, SECONDS);
assertTrue(backoff.failure());
assertEquals(backoff.getFailureCount(), 1);
assertEquals(backoff.getTimeSinceLastSuccess().roundTo(SECONDS), 6);
backoff.success();
// Check that we will tolerate failures for longer than the min, if the query has been running that long
ticker.increment(6, SECONDS);
assertFalse(backoff.failure());
assertEquals(backoff.getFailureCount(), 1);
assertEquals(backoff.getTimeSinceLastSuccess().roundTo(SECONDS), 6);
ticker.increment(1, SECONDS);
// Check that we won't tolerate failures for longer than the query has been running
assertTrue(backoff.failure());
assertEquals(backoff.getFailureCount(), 2);
assertEquals(backoff.getTimeSinceLastSuccess().roundTo(SECONDS), 7);
ticker.increment(20, SECONDS);
backoff.success();
ticker.increment(20, SECONDS);
// Check that we won't tolerate failures for longer than the max, even if the query has been running for a long time
assertTrue(backoff.failure());
assertEquals(backoff.getFailureCount(), 1);
assertEquals(backoff.getTimeSinceLastSuccess().roundTo(SECONDS), 20);
}
use of io.airlift.units.Duration in project presto by prestodb.
the class TestBackoff method testStartRequest.
@Test
public void testStartRequest() {
TestingTicker ticker = new TestingTicker();
Backoff backoff = new Backoff(new Duration(15, SECONDS), new Duration(15, SECONDS), ticker, new Duration(10, MILLISECONDS));
ticker.increment(10, MICROSECONDS);
assertEquals(backoff.getFailureCount(), 0);
assertEquals(backoff.getTimeSinceLastSuccess().roundTo(SECONDS), 0);
ticker.increment(14, SECONDS);
backoff.startRequest();
ticker.increment(14, SECONDS);
assertFalse(backoff.failure());
assertEquals(backoff.getFailureCount(), 1);
assertEquals(backoff.getTimeSinceLastSuccess().roundTo(SECONDS), 28);
ticker.increment(1, SECONDS);
assertTrue(backoff.failure());
assertEquals(backoff.getFailureCount(), 2);
assertEquals(backoff.getTimeSinceLastSuccess().roundTo(SECONDS), 29);
}
use of io.airlift.units.Duration in project presto by prestodb.
the class TestHttpRemoteTask method testRemoteTaskMismatch.
// This timeout should never be reached because a daemon thread in test should fail the test and do proper cleanup.
@Test(timeOut = 30000)
public void testRemoteTaskMismatch() throws InterruptedException, ExecutionException {
Duration idleTimeout = new Duration(3, SECONDS);
Duration failTimeout = new Duration(20, SECONDS);
JsonCodec<TaskStatus> taskStatusCodec = JsonCodec.jsonCodec(TaskStatus.class);
JsonCodec<TaskInfo> taskInfoCodec = JsonCodec.jsonCodec(TaskInfo.class);
TaskManagerConfig taskManagerConfig = new TaskManagerConfig();
// Shorten status refresh wait and info update interval so that we can have a shorter test timeout
taskManagerConfig.setStatusRefreshMaxWait(new Duration(idleTimeout.roundTo(MILLISECONDS) / 100, MILLISECONDS));
taskManagerConfig.setInfoUpdateInterval(new Duration(idleTimeout.roundTo(MILLISECONDS) / 10, MILLISECONDS));
AtomicLong lastActivityNanos = new AtomicLong(System.nanoTime());
HttpProcessor httpProcessor = new HttpProcessor(taskStatusCodec, taskInfoCodec, lastActivityNanos);
TestingHttpClient testingHttpClient = new TestingHttpClient(httpProcessor);
HttpRemoteTaskFactory httpRemoteTaskFactory = new HttpRemoteTaskFactory(new QueryManagerConfig(), taskManagerConfig, testingHttpClient, new TestSqlTaskManager.MockLocationFactory(), taskStatusCodec, taskInfoCodec, JsonCodec.jsonCodec(TaskUpdateRequest.class), new RemoteTaskStats());
RemoteTask remoteTask = httpRemoteTaskFactory.createRemoteTask(TEST_SESSION, new TaskId("test", 1, 2), new PrestoNode("node-id", URI.create("http://192.0.1.2"), new NodeVersion("version"), false), TaskTestUtils.PLAN_FRAGMENT, ImmutableMultimap.of(), createInitialEmptyOutputBuffers(OutputBuffers.BufferType.BROADCAST), new NodeTaskMap.PartitionedSplitCountTracker(i -> {
}), true);
httpProcessor.setInitialTaskInfo(remoteTask.getTaskInfo());
remoteTask.start();
CompletableFuture<Void> testComplete = new CompletableFuture<>();
asyncRun(idleTimeout.roundTo(MILLISECONDS), failTimeout.roundTo(MILLISECONDS), lastActivityNanos, () -> testComplete.complete(null), (message, cause) -> testComplete.completeExceptionally(new AssertionError(message, cause)));
testComplete.get();
httpRemoteTaskFactory.stop();
assertTrue(remoteTask.getTaskStatus().getState().isDone(), format("TaskStatus is not in a done state: %s", remoteTask.getTaskStatus()));
assertEquals(getOnlyElement(remoteTask.getTaskStatus().getFailures()).getErrorCode(), REMOTE_TASK_MISMATCH.toErrorCode());
assertTrue(remoteTask.getTaskInfo().getTaskStatus().getState().isDone(), format("TaskInfo is not in a done state: %s", remoteTask.getTaskInfo()));
}
Aggregations