本文整理汇总了Java中io.airlift.units.DataSize.Unit.BYTE属性的典型用法代码示例。如果您正苦于以下问题:Java Unit.BYTE属性的具体用法?Java Unit.BYTE怎么用?Java Unit.BYTE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类io.airlift.units.DataSize.Unit
的用法示例。
在下文中一共展示了Unit.BYTE属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: duplicate
@Override
public OperatorFactory duplicate()
{
return new HashAggregationOperatorFactory(
operatorId,
planNodeId,
groupByTypes,
groupByChannels,
step,
accumulatorFactories,
maskChannel,
hashChannel,
expectedGroups,
new DataSize(maxPartialMemory, Unit.BYTE));
}
示例2: testClose
@Test
public void testClose()
throws Exception
{
DataSize maxResponseSize = new DataSize(1, Unit.BYTE);
MockExchangeRequestProcessor processor = new MockExchangeRequestProcessor(maxResponseSize);
URI location = URI.create("http://localhost:8080");
processor.addPage(location, createPage(1));
processor.addPage(location, createPage(2));
processor.addPage(location, createPage(3));
@SuppressWarnings("resource")
ExchangeClient exchangeClient = new ExchangeClient(blockEncodingManager, new DataSize(1, Unit.BYTE), maxResponseSize, 1, new Duration(1, TimeUnit.MINUTES), new TestingHttpClient(processor, newCachedThreadPool(daemonThreadsNamed("test-%s"))), executor, deltaMemoryInBytes -> { });
exchangeClient.addLocation(location);
exchangeClient.noMoreLocations();
// fetch a page
assertEquals(exchangeClient.isClosed(), false);
assertPageEquals(exchangeClient.getNextPage(new Duration(1, TimeUnit.SECONDS)), createPage(1));
// close client while pages are still available
exchangeClient.close();
assertEquals(exchangeClient.isClosed(), true);
assertNull(exchangeClient.getNextPage(new Duration(0, TimeUnit.SECONDS)));
assertEquals(exchangeClient.getStatus().getBufferedPages(), 0);
assertEquals(exchangeClient.getStatus().getBufferedBytes(), 0);
// client should have sent only 2 requests: one to get all pages and once to get the done signal
PageBufferClientStatus clientStatus = exchangeClient.getStatus().getPageBufferClientStatuses().get(0);
assertEquals(clientStatus.getUri(), location);
assertEquals(clientStatus.getState(), "closed", "status");
assertEquals(clientStatus.getHttpRequestState(), "not scheduled", "httpRequestState");
}
示例3: testBufferLimit
@Test
public void testBufferLimit()
throws Exception
{
DataSize maxResponseSize = new DataSize(1, Unit.BYTE);
MockExchangeRequestProcessor processor = new MockExchangeRequestProcessor(maxResponseSize);
URI location = URI.create("http://localhost:8080");
// add a pages
processor.addPage(location, createPage(1));
processor.addPage(location, createPage(2));
processor.addPage(location, createPage(3));
processor.setComplete(location);
@SuppressWarnings("resource")
ExchangeClient exchangeClient = new ExchangeClient(blockEncodingManager, new DataSize(1, Unit.BYTE), maxResponseSize, 1, new Duration(1, TimeUnit.MINUTES), new TestingHttpClient(processor, newCachedThreadPool(daemonThreadsNamed("test-%s"))), executor, deltaMemoryInBytes -> { });
exchangeClient.addLocation(location);
exchangeClient.noMoreLocations();
assertEquals(exchangeClient.isClosed(), false);
long start = System.nanoTime();
// start fetching pages
exchangeClient.scheduleRequestIfNecessary();
// wait for a page to be fetched
do {
// there is no thread coordination here, so sleep is the best we can do
assertLessThan(Duration.nanosSince(start), new Duration(5, TimeUnit.SECONDS));
sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
}
while (exchangeClient.getStatus().getBufferedPages() == 0);
// client should have sent a single request for a single page
assertEquals(exchangeClient.getStatus().getBufferedPages(), 1);
assertTrue(exchangeClient.getStatus().getBufferedBytes() > 0);
assertStatus(exchangeClient.getStatus().getPageBufferClientStatuses().get(0), location, "queued", 1, 1, 1, "not scheduled");
// remove the page and wait for the client to fetch another page
assertPageEquals(exchangeClient.getNextPage(new Duration(0, TimeUnit.SECONDS)), createPage(1));
do {
assertLessThan(Duration.nanosSince(start), new Duration(5, TimeUnit.SECONDS));
sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
}
while (exchangeClient.getStatus().getBufferedPages() == 0);
// client should have sent a single request for a single page
assertStatus(exchangeClient.getStatus().getPageBufferClientStatuses().get(0), location, "queued", 2, 2, 2, "not scheduled");
assertEquals(exchangeClient.getStatus().getBufferedPages(), 1);
assertTrue(exchangeClient.getStatus().getBufferedBytes() > 0);
// remove the page and wait for the client to fetch another page
assertPageEquals(exchangeClient.getNextPage(new Duration(0, TimeUnit.SECONDS)), createPage(2));
do {
assertLessThan(Duration.nanosSince(start), new Duration(5, TimeUnit.SECONDS));
sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
}
while (exchangeClient.getStatus().getBufferedPages() == 0);
// client should have sent a single request for a single page
assertStatus(exchangeClient.getStatus().getPageBufferClientStatuses().get(0), location, "queued", 3, 3, 3, "not scheduled");
assertEquals(exchangeClient.getStatus().getBufferedPages(), 1);
assertTrue(exchangeClient.getStatus().getBufferedBytes() > 0);
// remove last page
assertPageEquals(exchangeClient.getNextPage(new Duration(1, TimeUnit.SECONDS)), createPage(3));
// wait for client to decide there are no more pages
assertNull(exchangeClient.getNextPage(new Duration(1, TimeUnit.SECONDS)));
assertEquals(exchangeClient.getStatus().getBufferedPages(), 0);
assertTrue(exchangeClient.getStatus().getBufferedBytes() == 0);
assertEquals(exchangeClient.isClosed(), true);
assertStatus(exchangeClient.getStatus().getPageBufferClientStatuses().get(0), location, "closed", 3, 5, 5, "not scheduled");
}