use of com.google.common.collect.ImmutableList in project crate by crate.
the class TransportExecutorDDLTest method testClusterUpdateSettingsTask.
@Test
public void testClusterUpdateSettingsTask() throws Exception {
final String persistentSetting = "stats.enabled";
final String transientSetting = "bulk.request_timeout";
// Update persistent only
Map<String, List<Expression>> persistentSettings = new HashMap<String, List<Expression>>() {
{
put(persistentSetting, ImmutableList.<Expression>of(Literal.fromObject(true)));
}
};
ESClusterUpdateSettingsPlan node = new ESClusterUpdateSettingsPlan(UUID.randomUUID(), persistentSettings);
Bucket objects = executePlan(node);
assertThat(objects, contains(isRow(1L)));
assertEquals("true", client().admin().cluster().prepareState().execute().actionGet().getState().metaData().persistentSettings().get(persistentSetting));
// Update transient only
Map<String, List<Expression>> transientSettings = new HashMap<String, List<Expression>>() {
{
put(transientSetting, ImmutableList.<Expression>of(Literal.fromObject("123s")));
}
};
node = new ESClusterUpdateSettingsPlan(UUID.randomUUID(), ImmutableMap.<String, List<Expression>>of(), transientSettings);
objects = executePlan(node);
assertThat(objects, contains(isRow(1L)));
assertEquals("123000ms", client().admin().cluster().prepareState().execute().actionGet().getState().metaData().transientSettings().get(transientSetting));
// Update persistent & transient
persistentSettings = new HashMap<String, List<Expression>>() {
{
put(persistentSetting, ImmutableList.<Expression>of(Literal.fromObject(false)));
}
};
transientSettings = new HashMap<String, List<Expression>>() {
{
put(transientSetting, ImmutableList.<Expression>of(Literal.fromObject("243s")));
}
};
node = new ESClusterUpdateSettingsPlan(UUID.randomUUID(), persistentSettings, transientSettings);
objects = executePlan(node);
MetaData md = client().admin().cluster().prepareState().execute().actionGet().getState().metaData();
assertThat(objects, contains(isRow(1L)));
assertEquals("false", md.persistentSettings().get(persistentSetting));
assertEquals("243000ms", md.transientSettings().get(transientSetting));
}
use of com.google.common.collect.ImmutableList in project crate by crate.
the class ESClusterUpdateSettingsTaskTest method testUpdateMultipleSettingsWithParameters.
@Test
public void testUpdateMultipleSettingsWithParameters() throws Exception {
Map<String, List<Expression>> settings = new HashMap<String, List<Expression>>() {
{
put("stats.operations_log_size", ImmutableList.<Expression>of(new ParameterExpression(1)));
put("stats.jobs_log_size", ImmutableList.<Expression>of(new ParameterExpression(2)));
}
};
Settings expected = Settings.builder().put("stats.operations_log_size", 10).put("stats.jobs_log_size", 25).build();
assertThat(ESClusterUpdateSettingsTask.buildSettingsFrom(settings, new RowN(new Object[] { 10, 25 })), is(expected));
}
use of com.google.common.collect.ImmutableList in project druid by druid-io.
the class TimestampGroupByAggregationTest method constructorFeeder.
@Parameterized.Parameters(name = "{index}: Test for {0}, config = {1}")
public static Iterable<Object[]> constructorFeeder() {
final List<Object[]> constructors = Lists.newArrayList();
final List<List<Object>> partialConstructors = ImmutableList.<List<Object>>of(ImmutableList.<Object>of("timeMin", "tmin", "time_min", TimestampMinAggregatorFactory.class, DateTime.parse("2011-01-12T01:00:00.000Z")), ImmutableList.<Object>of("timeMax", "tmax", "time_max", TimestampMaxAggregatorFactory.class, DateTime.parse("2011-01-31T01:00:00.000Z")));
for (final List<Object> partialConstructor : partialConstructors) {
for (GroupByQueryConfig config : GroupByQueryRunnerTest.testConfigs()) {
final List<Object> constructor = Lists.newArrayList(partialConstructor);
constructor.add(config);
constructors.add(constructor.toArray());
}
}
return constructors;
}
use of com.google.common.collect.ImmutableList in project druid by druid-io.
the class RealtimePlumberSchoolTest method testDimOrderInheritanceHelper.
private void testDimOrderInheritanceHelper(final Object commitMetadata) throws Exception {
List<List<String>> expectedDims = ImmutableList.<List<String>>of(ImmutableList.of("dimD"), ImmutableList.of("dimC"), ImmutableList.of("dimA"), ImmutableList.of("dimB"), ImmutableList.of("dimE"), ImmutableList.of("dimD", "dimC", "dimA", "dimB", "dimE"));
QueryableIndex qindex;
FireHydrant hydrant;
Map<Long, Sink> sinks;
RealtimePlumber plumber = (RealtimePlumber) realtimePlumberSchool.findPlumber(schema2, tuningConfig, metrics);
Assert.assertNull(plumber.startJob());
final CountDownLatch doneSignal = new CountDownLatch(1);
final Committer committer = new Committer() {
@Override
public Object getMetadata() {
return commitMetadata;
}
@Override
public void run() {
doneSignal.countDown();
}
};
plumber.add(getTestInputRowFull("1970-01-01", ImmutableList.of("dimD"), ImmutableList.of("1")), Suppliers.ofInstance(committer));
plumber.add(getTestInputRowFull("1970-01-01", ImmutableList.of("dimC"), ImmutableList.of("1")), Suppliers.ofInstance(committer));
plumber.add(getTestInputRowFull("1970-01-01", ImmutableList.of("dimA"), ImmutableList.of("1")), Suppliers.ofInstance(committer));
plumber.add(getTestInputRowFull("1970-01-01", ImmutableList.of("dimB"), ImmutableList.of("1")), Suppliers.ofInstance(committer));
plumber.add(getTestInputRowFull("1970-01-01", ImmutableList.of("dimE"), ImmutableList.of("1")), Suppliers.ofInstance(committer));
plumber.add(getTestInputRowFull("1970-01-01", ImmutableList.of("dimA", "dimB", "dimC", "dimD", "dimE"), ImmutableList.of("1")), Suppliers.ofInstance(committer));
plumber.persist(committer);
doneSignal.await();
plumber.getSinks().clear();
plumber.finishJob();
RealtimePlumber restoredPlumber = (RealtimePlumber) realtimePlumberSchool.findPlumber(schema2, tuningConfig, metrics);
restoredPlumber.bootstrapSinksFromDisk();
sinks = restoredPlumber.getSinks();
Assert.assertEquals(1, sinks.size());
List<FireHydrant> hydrants = Lists.newArrayList(sinks.get(0L));
for (int i = 0; i < hydrants.size(); i++) {
hydrant = hydrants.get(i);
qindex = hydrant.getSegment().asQueryableIndex();
Assert.assertEquals(i, hydrant.getCount());
Assert.assertEquals(expectedDims.get(i), ImmutableList.copyOf(qindex.getAvailableDimensions()));
}
}
use of com.google.common.collect.ImmutableList in project druid by druid-io.
the class SpecificSegmentQueryRunnerTest method testRetry.
@Test
public void testRetry() throws Exception {
final ObjectMapper mapper = new DefaultObjectMapper();
SegmentDescriptor descriptor = new SegmentDescriptor(new Interval("2012-01-01T00:00:00Z/P1D"), "version", 0);
final SpecificSegmentQueryRunner queryRunner = new SpecificSegmentQueryRunner(new QueryRunner() {
@Override
public Sequence run(Query query, Map responseContext) {
return new Sequence() {
@Override
public Object accumulate(Object initValue, Accumulator accumulator) {
throw new SegmentMissingException("FAILSAUCE");
}
@Override
public Yielder<Object> toYielder(Object initValue, YieldingAccumulator accumulator) {
throw new SegmentMissingException("FAILSAUCE");
}
};
}
}, new SpecificSegmentSpec(descriptor));
// from accumulate
Map<String, Object> responseContext = Maps.newHashMap();
TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("foo").granularity(Granularities.ALL).intervals(ImmutableList.of(new Interval("2012-01-01T00:00:00Z/P1D"))).aggregators(ImmutableList.<AggregatorFactory>of(new CountAggregatorFactory("rows"))).build();
Sequence results = queryRunner.run(query, responseContext);
Sequences.toList(results, Lists.newArrayList());
validate(mapper, descriptor, responseContext);
// from toYielder
responseContext = Maps.newHashMap();
results = queryRunner.run(query, responseContext);
results.toYielder(null, new YieldingAccumulator() {
final List lists = Lists.newArrayList();
@Override
public Object accumulate(Object accumulated, Object in) {
lists.add(in);
return in;
}
});
validate(mapper, descriptor, responseContext);
}
Aggregations