Search in sources :

Example 6 with ImmutableList

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));
}
Also used : ESClusterUpdateSettingsPlan(io.crate.planner.node.ddl.ESClusterUpdateSettingsPlan) Expression(io.crate.sql.tree.Expression) Bucket(io.crate.data.Bucket) MetaData(org.elasticsearch.cluster.metadata.MetaData) ImmutableList(com.google.common.collect.ImmutableList) SQLTransportIntegrationTest(io.crate.integrationtests.SQLTransportIntegrationTest) Test(org.junit.Test)

Example 7 with ImmutableList

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));
}
Also used : RowN(io.crate.data.RowN) HashMap(java.util.HashMap) ParameterExpression(io.crate.sql.tree.ParameterExpression) Expression(io.crate.sql.tree.Expression) ParameterExpression(io.crate.sql.tree.ParameterExpression) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Settings(org.elasticsearch.common.settings.Settings) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 8 with ImmutableList

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;
}
Also used : GroupByQueryConfig(io.druid.query.groupby.GroupByQueryConfig) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList)

Example 9 with ImmutableList

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()));
    }
}
Also used : QueryableIndex(io.druid.segment.QueryableIndex) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) FireHydrant(io.druid.segment.realtime.FireHydrant) Committer(io.druid.data.input.Committer) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 10 with ImmutableList

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);
}
Also used : Accumulator(io.druid.java.util.common.guava.Accumulator) YieldingAccumulator(io.druid.java.util.common.guava.YieldingAccumulator) Yielder(io.druid.java.util.common.guava.Yielder) TimeseriesQuery(io.druid.query.timeseries.TimeseriesQuery) Query(io.druid.query.Query) TimeseriesQuery(io.druid.query.timeseries.TimeseriesQuery) SegmentMissingException(io.druid.segment.SegmentMissingException) Sequence(io.druid.java.util.common.guava.Sequence) YieldingAccumulator(io.druid.java.util.common.guava.YieldingAccumulator) AggregatorFactory(io.druid.query.aggregation.AggregatorFactory) CountAggregatorFactory(io.druid.query.aggregation.CountAggregatorFactory) QueryRunner(io.druid.query.QueryRunner) CountAggregatorFactory(io.druid.query.aggregation.CountAggregatorFactory) SegmentDescriptor(io.druid.query.SegmentDescriptor) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) Map(java.util.Map) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Interval(org.joda.time.Interval) Test(org.junit.Test)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)523 Path (java.nio.file.Path)128 List (java.util.List)105 SourcePath (com.facebook.buck.rules.SourcePath)91 Test (org.junit.Test)77 Step (com.facebook.buck.step.Step)76 ImmutableMap (com.google.common.collect.ImmutableMap)65 IOException (java.io.IOException)62 ArrayList (java.util.ArrayList)60 Map (java.util.Map)59 ExplicitBuildTargetSourcePath (com.facebook.buck.rules.ExplicitBuildTargetSourcePath)52 MakeCleanDirectoryStep (com.facebook.buck.step.fs.MakeCleanDirectoryStep)52 BuildTarget (com.facebook.buck.model.BuildTarget)47 MkdirStep (com.facebook.buck.step.fs.MkdirStep)39 ImmutableSet (com.google.common.collect.ImmutableSet)39 Arguments (com.spectralogic.ds3autogen.api.models.Arguments)38 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)36 HumanReadableException (com.facebook.buck.util.HumanReadableException)36 Optional (java.util.Optional)36 BuildRule (com.facebook.buck.rules.BuildRule)34