use of io.airlift.units.Duration in project presto by prestodb.
the class TestExchangeClient method testAddLocation.
@Test(timeOut = 10000)
public void testAddLocation() throws Exception {
DataSize maxResponseSize = new DataSize(10, Unit.MEGABYTE);
MockExchangeRequestProcessor processor = new MockExchangeRequestProcessor(maxResponseSize);
@SuppressWarnings("resource") ExchangeClient exchangeClient = new ExchangeClient(new DataSize(32, Unit.MEGABYTE), maxResponseSize, 1, new Duration(1, TimeUnit.MINUTES), new Duration(1, TimeUnit.MINUTES), new TestingHttpClient(processor, newCachedThreadPool(daemonThreadsNamed("test-%s"))), executor, deltaMemoryInBytes -> {
});
URI location1 = URI.create("http://localhost:8081/foo");
processor.addPage(location1, createPage(1));
processor.addPage(location1, createPage(2));
processor.addPage(location1, createPage(3));
processor.setComplete(location1);
exchangeClient.addLocation(location1);
assertEquals(exchangeClient.isClosed(), false);
assertPageEquals(exchangeClient.getNextPage(new Duration(1, TimeUnit.SECONDS)), createPage(1));
assertEquals(exchangeClient.isClosed(), false);
assertPageEquals(exchangeClient.getNextPage(new Duration(1, TimeUnit.SECONDS)), createPage(2));
assertEquals(exchangeClient.isClosed(), false);
assertPageEquals(exchangeClient.getNextPage(new Duration(1, TimeUnit.SECONDS)), createPage(3));
assertNull(exchangeClient.getNextPage(new Duration(10, MILLISECONDS)));
assertEquals(exchangeClient.isClosed(), false);
URI location2 = URI.create("http://localhost:8082/bar");
processor.addPage(location2, createPage(4));
processor.addPage(location2, createPage(5));
processor.addPage(location2, createPage(6));
processor.setComplete(location2);
exchangeClient.addLocation(location2);
assertEquals(exchangeClient.isClosed(), false);
assertPageEquals(exchangeClient.getNextPage(new Duration(1, TimeUnit.SECONDS)), createPage(4));
assertEquals(exchangeClient.isClosed(), false);
assertPageEquals(exchangeClient.getNextPage(new Duration(1, TimeUnit.SECONDS)), createPage(5));
assertEquals(exchangeClient.isClosed(), false);
assertPageEquals(exchangeClient.getNextPage(new Duration(1, TimeUnit.SECONDS)), createPage(6));
assertNull(exchangeClient.getNextPage(new Duration(10, MILLISECONDS)));
assertEquals(exchangeClient.isClosed(), false);
exchangeClient.noMoreLocations();
// receive a final GONE response, so just spin until it's closed or the test times out.
while (!exchangeClient.isClosed()) {
Thread.sleep(1);
}
ImmutableMap<URI, PageBufferClientStatus> statuses = uniqueIndex(exchangeClient.getStatus().getPageBufferClientStatuses(), PageBufferClientStatus::getUri);
assertStatus(statuses.get(location1), location1, "closed", 3, 3, 3, "not scheduled");
assertStatus(statuses.get(location2), location2, "closed", 3, 3, 3, "not scheduled");
}
use of io.airlift.units.Duration in project presto by prestodb.
the class TestExchangeOperator method setUp.
@SuppressWarnings("resource")
@BeforeClass
public void setUp() throws Exception {
executor = newScheduledThreadPool(4, daemonThreadsNamed("test-%s"));
httpClient = new TestingHttpClient(new HttpClientHandler(taskBuffers), executor);
exchangeClientSupplier = (systemMemoryUsageListener) -> new ExchangeClient(new DataSize(32, MEGABYTE), new DataSize(10, MEGABYTE), 3, new Duration(1, TimeUnit.MINUTES), new Duration(1, TimeUnit.MINUTES), httpClient, executor, systemMemoryUsageListener);
}
use of io.airlift.units.Duration in project presto by prestodb.
the class TestOperatorStats method testAddMergeable.
@Test
public void testAddMergeable() {
OperatorStats actual = MERGEABLE.add(MERGEABLE, MERGEABLE);
assertEquals(actual.getOperatorId(), 41);
assertEquals(actual.getOperatorType(), "test");
assertEquals(actual.getTotalDrivers(), 3 * 1);
assertEquals(actual.getAddInputCalls(), 3 * 2);
assertEquals(actual.getAddInputWall(), new Duration(3 * 3, NANOSECONDS));
assertEquals(actual.getAddInputCpu(), new Duration(3 * 4, NANOSECONDS));
assertEquals(actual.getAddInputUser(), new Duration(3 * 5, NANOSECONDS));
assertEquals(actual.getInputDataSize(), new DataSize(3 * 6, BYTE));
assertEquals(actual.getInputPositions(), 3 * 7);
assertEquals(actual.getSumSquaredInputPositions(), 3 * 8.0);
assertEquals(actual.getGetOutputCalls(), 3 * 9);
assertEquals(actual.getGetOutputWall(), new Duration(3 * 10, NANOSECONDS));
assertEquals(actual.getGetOutputCpu(), new Duration(3 * 11, NANOSECONDS));
assertEquals(actual.getGetOutputUser(), new Duration(3 * 12, NANOSECONDS));
assertEquals(actual.getOutputDataSize(), new DataSize(3 * 13, BYTE));
assertEquals(actual.getOutputPositions(), 3 * 14);
assertEquals(actual.getBlockedWall(), new Duration(3 * 15, NANOSECONDS));
assertEquals(actual.getFinishCalls(), 3 * 16);
assertEquals(actual.getFinishWall(), new Duration(3 * 17, NANOSECONDS));
assertEquals(actual.getFinishCpu(), new Duration(3 * 18, NANOSECONDS));
assertEquals(actual.getFinishUser(), new Duration(3 * 19, NANOSECONDS));
assertEquals(actual.getMemoryReservation(), new DataSize(3 * 20, BYTE));
assertEquals(actual.getSystemMemoryReservation(), new DataSize(3 * 21, BYTE));
assertEquals(actual.getInfo().getClass(), PartitionedOutputInfo.class);
assertEquals(((PartitionedOutputInfo) actual.getInfo()).getPagesAdded(), 3 * MERGEABLE_INFO.getPagesAdded());
}
use of io.airlift.units.Duration in project presto by prestodb.
the class TestOperatorStats method assertExpectedOperatorStats.
public static void assertExpectedOperatorStats(OperatorStats actual) {
assertEquals(actual.getOperatorId(), 41);
assertEquals(actual.getOperatorType(), "test");
assertEquals(actual.getTotalDrivers(), 1);
assertEquals(actual.getAddInputCalls(), 2);
assertEquals(actual.getAddInputWall(), new Duration(3, NANOSECONDS));
assertEquals(actual.getAddInputCpu(), new Duration(4, NANOSECONDS));
assertEquals(actual.getAddInputUser(), new Duration(5, NANOSECONDS));
assertEquals(actual.getInputDataSize(), new DataSize(6, BYTE));
assertEquals(actual.getInputPositions(), 7);
assertEquals(actual.getSumSquaredInputPositions(), 8.0);
assertEquals(actual.getGetOutputCalls(), 9);
assertEquals(actual.getGetOutputWall(), new Duration(10, NANOSECONDS));
assertEquals(actual.getGetOutputCpu(), new Duration(11, NANOSECONDS));
assertEquals(actual.getGetOutputUser(), new Duration(12, NANOSECONDS));
assertEquals(actual.getOutputDataSize(), new DataSize(13, BYTE));
assertEquals(actual.getOutputPositions(), 14);
assertEquals(actual.getBlockedWall(), new Duration(15, NANOSECONDS));
assertEquals(actual.getFinishCalls(), 16);
assertEquals(actual.getFinishWall(), new Duration(17, NANOSECONDS));
assertEquals(actual.getFinishCpu(), new Duration(18, NANOSECONDS));
assertEquals(actual.getFinishUser(), new Duration(19, NANOSECONDS));
assertEquals(actual.getMemoryReservation(), new DataSize(20, BYTE));
assertEquals(actual.getSystemMemoryReservation(), new DataSize(21, BYTE));
assertEquals(actual.getInfo().getClass(), ExchangeClientStatus.class);
assertEquals(((ExchangeClientStatus) actual.getInfo()).getAverageBytesPerRequest(), NON_MERGEABLE_INFO.getAverageBytesPerRequest());
}
use of io.airlift.units.Duration in project presto by prestodb.
the class TestPipelineStats method assertExpectedPipelineStats.
public static void assertExpectedPipelineStats(PipelineStats actual) {
assertEquals(actual.getFirstStartTime(), new DateTime(100, UTC));
assertEquals(actual.getLastStartTime(), new DateTime(101, UTC));
assertEquals(actual.getLastEndTime(), new DateTime(102, UTC));
assertEquals(actual.isInputPipeline(), true);
assertEquals(actual.isOutputPipeline(), false);
assertEquals(actual.getTotalDrivers(), 1);
assertEquals(actual.getQueuedDrivers(), 2);
assertEquals(actual.getQueuedPartitionedDrivers(), 1);
assertEquals(actual.getRunningDrivers(), 3);
assertEquals(actual.getRunningPartitionedDrivers(), 2);
assertEquals(actual.getCompletedDrivers(), 4);
assertEquals(actual.getMemoryReservation(), new DataSize(5, BYTE));
assertEquals(actual.getSystemMemoryReservation(), new DataSize(6, BYTE));
assertEquals(actual.getQueuedTime().getCount(), 7.0);
assertEquals(actual.getElapsedTime().getCount(), 8.0);
assertEquals(actual.getTotalScheduledTime(), new Duration(9, NANOSECONDS));
assertEquals(actual.getTotalCpuTime(), new Duration(10, NANOSECONDS));
assertEquals(actual.getTotalUserTime(), new Duration(11, NANOSECONDS));
assertEquals(actual.getTotalBlockedTime(), new Duration(12, NANOSECONDS));
assertEquals(actual.getRawInputDataSize(), new DataSize(13, BYTE));
assertEquals(actual.getRawInputPositions(), 14);
assertEquals(actual.getProcessedInputDataSize(), new DataSize(15, BYTE));
assertEquals(actual.getProcessedInputPositions(), 16);
assertEquals(actual.getOutputDataSize(), new DataSize(17, BYTE));
assertEquals(actual.getOutputPositions(), 18);
assertEquals(actual.getOperatorSummaries().size(), 1);
assertExpectedOperatorStats(actual.getOperatorSummaries().get(0));
assertEquals(actual.getDrivers().size(), 1);
assertExpectedDriverStats(actual.getDrivers().get(0));
}
Aggregations