Search in sources :

Example 41 with ISE

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());
}
Also used : CancellationException(java.util.concurrent.CancellationException) ISE(io.druid.java.util.common.ISE) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Example 42 with ISE

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());
}
Also used : CancellationException(java.util.concurrent.CancellationException) ISE(io.druid.java.util.common.ISE) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Example 43 with ISE

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);
}
Also used : RandomAccessFile(java.io.RandomAccessFile) ISE(io.druid.java.util.common.ISE) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 44 with ISE

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);
            }
        }
    }));
}
Also used : ISE(io.druid.java.util.common.ISE) ServiceDiscovery(org.apache.curator.x.discovery.ServiceDiscovery) Predicate(com.google.common.base.Predicate) Test(org.junit.Test)

Example 45 with ISE

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());
        }
    }
}
Also used : Stopwatch(com.google.common.base.Stopwatch) ISE(io.druid.java.util.common.ISE) Timing(org.apache.curator.test.Timing)

Aggregations

ISE (io.druid.java.util.common.ISE)158 IOException (java.io.IOException)37 Map (java.util.Map)23 Test (org.junit.Test)21 File (java.io.File)20 List (java.util.List)19 DateTime (org.joda.time.DateTime)18 ArrayList (java.util.ArrayList)17 DataSegment (io.druid.timeline.DataSegment)15 Interval (org.joda.time.Interval)15 Function (com.google.common.base.Function)14 TimeoutException (java.util.concurrent.TimeoutException)12 IAE (io.druid.java.util.common.IAE)10 HashMap (java.util.HashMap)10 ExecutionException (java.util.concurrent.ExecutionException)10 Stopwatch (com.google.common.base.Stopwatch)9 DimensionSpec (io.druid.query.dimension.DimensionSpec)9 ImmutableMap (com.google.common.collect.ImmutableMap)8 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)8 AggregatorFactory (io.druid.query.aggregation.AggregatorFactory)8