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());
}
}
}
use of io.druid.java.util.common.ISE in project druid by druid-io.
the class NamedIntrospectionHandler method testConcurrencyStartStopChaos.
@Test(timeout = 10000L)
public void testConcurrencyStartStopChaos() throws Exception {
// Don't want to exercise snapshot here
final LookupReferencesManager manager = new LookupReferencesManager(new LookupConfig(null), mapper);
final Runnable chaosStart = new Runnable() {
@Override
public void run() {
manager.start();
}
};
final Runnable chaosStop = new Runnable() {
@Override
public void run() {
manager.stop();
}
};
final CountDownLatch runnableStartBarrier = new CountDownLatch(1);
final Random random = new Random(478137498L);
final int numUpdates = 100000;
final int numNamespaces = 100;
final CountDownLatch runnablesFinishedBarrier = new CountDownLatch(numUpdates);
final List<Runnable> runnables = new ArrayList<>(numUpdates);
final Map<String, Integer> maxNumber = new HashMap<>();
for (int i = 1; i <= numUpdates; ++i) {
final boolean shouldStart = random.nextInt(10) == 1;
final boolean shouldClose = random.nextInt(10) == 1;
final String name = Integer.toString(random.nextInt(numNamespaces));
final int position = i;
final LookupExtractorFactory lookupExtractorFactory = new LookupExtractorFactory() {
@Override
public boolean start() {
return shouldStart;
}
@Override
public boolean close() {
return shouldClose;
}
@Override
public boolean replaces(@Nullable LookupExtractorFactory other) {
if (other == null) {
return true;
}
final NamedIntrospectionHandler introspectionHandler = (NamedIntrospectionHandler) other.getIntrospectHandler();
return position > introspectionHandler.position;
}
@Nullable
@Override
public LookupIntrospectHandler getIntrospectHandler() {
return new NamedIntrospectionHandler(position);
}
@Override
public String toString() {
return String.format("TestFactroy position %d", position);
}
@Override
public LookupExtractor get() {
return null;
}
};
if (random.nextFloat() < 0.001) {
if (random.nextBoolean()) {
runnables.add(chaosStart);
} else {
runnables.add(chaosStop);
}
} else {
if (shouldStart && (!maxNumber.containsKey(name) || maxNumber.get(name) < position)) {
maxNumber.put(name, position);
}
runnables.add(new LookupUpdatingRunnable(name, lookupExtractorFactory, runnableStartBarrier, manager));
}
}
////// Add some CHAOS!
Collections.shuffle(runnables, random);
final Runnable decrementFinished = new Runnable() {
@Override
public void run() {
runnablesFinishedBarrier.countDown();
}
};
for (Runnable runnable : runnables) {
executorService.submit(runnable).addListener(decrementFinished, MoreExecutors.sameThreadExecutor());
}
runnableStartBarrier.countDown();
do {
for (String name : maxNumber.keySet()) {
final LookupExtractorFactory factory;
try {
factory = manager.get(name);
} catch (ISE e) {
continue;
}
if (null == factory) {
continue;
}
final NamedIntrospectionHandler introspectionHandler = (NamedIntrospectionHandler) factory.getIntrospectHandler();
Assert.assertTrue(introspectionHandler.position >= 0);
}
} while (runnablesFinishedBarrier.getCount() > 0);
}
use of io.druid.java.util.common.ISE in project druid by druid-io.
the class RealtimeManagerTest method testRunV2.
@Test
public void testRunV2() throws Exception {
realtimeManager2.start();
Stopwatch stopwatch = Stopwatch.createStarted();
while (realtimeManager2.getMetrics("testV2").processed() != 1) {
Thread.sleep(100);
if (stopwatch.elapsed(TimeUnit.MILLISECONDS) > 1000) {
throw new ISE("Realtime manager should have completed processing 2 events!");
}
}
Assert.assertEquals(1, realtimeManager2.getMetrics("testV2").processed());
Assert.assertEquals(1, realtimeManager2.getMetrics("testV2").thrownAway());
Assert.assertEquals(2, realtimeManager2.getMetrics("testV2").unparseable());
Assert.assertTrue(plumber2.isStartedJob());
Assert.assertTrue(plumber2.isFinishedJob());
Assert.assertEquals(0, plumber2.getPersistCount());
}
use of io.druid.java.util.common.ISE in project druid by druid-io.
the class RowSignature method getRelDataType.
/**
* Returns a Calcite RelDataType corresponding to this row signature.
*
* @param typeFactory factory for type construction
*
* @return Calcite row type
*/
public RelDataType getRelDataType(final RelDataTypeFactory typeFactory) {
final RelDataTypeFactory.FieldInfoBuilder builder = typeFactory.builder();
for (final String columnName : columnNames) {
final ValueType columnType = getColumnType(columnName);
final RelDataType type;
if (Column.TIME_COLUMN_NAME.equals(columnName)) {
type = typeFactory.createSqlType(SqlTypeName.TIMESTAMP);
} else {
switch(columnType) {
case STRING:
// Note that there is no attempt here to handle multi-value in any special way. Maybe one day...
type = typeFactory.createTypeWithCharsetAndCollation(typeFactory.createSqlType(SqlTypeName.VARCHAR), Calcites.defaultCharset(), SqlCollation.IMPLICIT);
break;
case LONG:
type = typeFactory.createSqlType(SqlTypeName.BIGINT);
break;
case FLOAT:
type = typeFactory.createSqlType(SqlTypeName.FLOAT);
break;
case COMPLEX:
// Loses information about exactly what kind of complex column this is.
type = typeFactory.createSqlType(SqlTypeName.OTHER);
break;
default:
throw new ISE("WTF?! valueType[%s] not translatable?", columnType);
}
}
builder.add(columnName, type);
}
return builder.build();
}
Aggregations