use of io.druid.java.util.common.ISE in project druid by druid-io.
the class QueryInterruptedExceptionTest method testErrorCode.
@Test
public void testErrorCode() {
Assert.assertEquals("Query cancelled", new QueryInterruptedException(new QueryInterruptedException(new CancellationException())).getErrorCode());
Assert.assertEquals("Query cancelled", new QueryInterruptedException(new CancellationException()).getErrorCode());
Assert.assertEquals("Query interrupted", new QueryInterruptedException(new InterruptedException()).getErrorCode());
Assert.assertEquals("Query timeout", new QueryInterruptedException(new TimeoutException()).getErrorCode());
Assert.assertEquals("Unknown exception", new QueryInterruptedException(null).getErrorCode());
Assert.assertEquals("Unknown exception", new QueryInterruptedException(new ISE("Something bad!")).getErrorCode());
Assert.assertEquals("Resource limit exceeded", new QueryInterruptedException(new ResourceLimitExceededException("too many!")).getErrorCode());
Assert.assertEquals("Unknown exception", new QueryInterruptedException(new QueryInterruptedException(new ISE("Something bad!"))).getErrorCode());
}
use of io.druid.java.util.common.ISE in project druid by druid-io.
the class QueryInterruptedExceptionTest method testErrorClass.
@Test
public void testErrorClass() {
Assert.assertEquals("java.util.concurrent.CancellationException", new QueryInterruptedException(new QueryInterruptedException(new CancellationException())).getErrorClass());
Assert.assertEquals("java.util.concurrent.CancellationException", new QueryInterruptedException(new CancellationException()).getErrorClass());
Assert.assertEquals("java.lang.InterruptedException", new QueryInterruptedException(new InterruptedException()).getErrorClass());
Assert.assertEquals("java.util.concurrent.TimeoutException", new QueryInterruptedException(new TimeoutException()).getErrorClass());
Assert.assertEquals("io.druid.query.ResourceLimitExceededException", new QueryInterruptedException(new ResourceLimitExceededException("too many!")).getErrorClass());
Assert.assertEquals(null, new QueryInterruptedException(null).getErrorClass());
Assert.assertEquals("io.druid.java.util.common.ISE", new QueryInterruptedException(new ISE("Something bad!")).getErrorClass());
Assert.assertEquals("io.druid.java.util.common.ISE", new QueryInterruptedException(new QueryInterruptedException(new ISE("Something bad!"))).getErrorClass());
}
use of io.druid.java.util.common.ISE in project druid by druid-io.
the class GenericIndexedWriter method bagSizePower.
/**
* Tries to get best value split(number of elements in each value file) which can be expressed as power of 2.
*
* @return Returns the size of value file splits as power of 2.
*
* @throws IOException
*/
private int bagSizePower() throws IOException {
long avgObjectSize = (valuesOut.getCount() + numWritten - 1) / numWritten;
File f = ioPeon.getFile(makeFilename("headerLong"));
Preconditions.checkNotNull(f, "header file missing.");
try (RandomAccessFile headerFile = new RandomAccessFile(f, "r")) {
for (int i = 31; i >= 0; --i) {
if ((1L << i) * avgObjectSize <= fileSizeLimit) {
if (actuallyFits(i, headerFile)) {
return i;
}
}
}
}
throw new ISE("no value split found with fileSizeLimit [%d], avgObjectSize [%d] while serializing [%s]", fileSizeLimit, avgObjectSize, filenameBase);
}
use of io.druid.java.util.common.ISE in project druid by druid-io.
the class ServiceAnnouncerTest method testServiceAnnouncement.
@Test
public void testServiceAnnouncement() throws Exception {
curator.start();
curator.blockUntilConnected();
List<String> serviceNames = ImmutableList.of("druid/overlord", "druid/coordinator", "druid/firehose/tranquility_test-50-0000-0000");
final ServiceDiscovery serviceDiscovery = createAndAnnounceServices(serviceNames);
Assert.assertTrue(Iterators.all(serviceNames.iterator(), new Predicate<String>() {
@Override
public boolean apply(String input) {
try {
return serviceDiscovery.queryForInstances(input.replaceAll("/", ":")).size() == 1;
} catch (Exception e) {
throw new ISE("Something went wrong while finding instance with name [%s] in Service Discovery", input);
}
}
}));
}
use of io.druid.java.util.common.ISE in project druid by druid-io.
the class BatchServerInventoryViewTest method waitForUpdateEvents.
private void waitForUpdateEvents(int count) throws Exception {
final Timing forWaitingTiming = timing.forWaiting();
Stopwatch stopwatch = Stopwatch.createStarted();
while (inventoryUpdateCounter.get() != count) {
Thread.sleep(100);
if (stopwatch.elapsed(TimeUnit.MILLISECONDS) > forWaitingTiming.milliseconds()) {
throw new ISE("BatchServerInventoryView is not updating counter expected[%d] value[%d]", count, inventoryUpdateCounter.get());
}
}
}
Aggregations