Search in sources :

Example 1 with ModulesBuilder

use of org.elasticsearch.common.inject.ModulesBuilder in project crate by crate.

the class SysNodesExpressionsTest method prepare.

@Before
public void prepare() throws Exception {
    MonitorModule monitorModule = new MonitorModule(NODE_SETTINGS);
    monitorModule.addExtendedNodeInfoType("dummy", DummyExtendedNodeInfo.class);
    injector = new ModulesBuilder().add(new TestModule(true), monitorModule, new SysNodeExpressionModule()).createInjector();
    resolver = injector.getInstance(NodeSysExpression.class);
}
Also used : NodeSysExpression(io.crate.operation.reference.sys.node.local.NodeSysExpression) MonitorModule(io.crate.monitor.MonitorModule) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) SysNodeExpressionModule(io.crate.operation.reference.sys.node.local.SysNodeExpressionModule) Before(org.junit.Before)

Example 2 with ModulesBuilder

use of org.elasticsearch.common.inject.ModulesBuilder in project crate by crate.

the class GroupingBytesRefCollectorBenchmark method createGroupingCollector.

@Setup
public void createGroupingCollector() {
    Functions functions = new ModulesBuilder().add(new AggregationImplModule()).createInjector().getInstance(Functions.class);
    groupByMinCollector = createGroupByMinBytesRefCollector(functions);
    List<BytesRef> keys = new ArrayList<>(Locale.getISOCountries().length);
    for (String s : Locale.getISOCountries()) {
        keys.add(new BytesRef(s));
    }
    rows = new ArrayList<>(20_000_000);
    for (int i = 0; i < 20_000_000; i++) {
        rows.add(new Row1(keys.get(i % keys.size())));
    }
}
Also used : ArrayList(java.util.ArrayList) Functions(io.crate.metadata.Functions) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) BytesRef(org.apache.lucene.util.BytesRef) AggregationImplModule(io.crate.operation.aggregation.impl.AggregationImplModule)

Example 3 with ModulesBuilder

use of org.elasticsearch.common.inject.ModulesBuilder in project crate by crate.

the class SigarExtendedNodeInfoTest method prepare.

@Before
public void prepare() throws Exception {
    NodeEnvironment nodeEnvironment = mock(NodeEnvironment.class);
    when(nodeEnvironment.hasNodeFile()).thenReturn(true);
    Path tempDir = createTempDir();
    NodeEnvironment.NodePath[] dataLocations = new NodeEnvironment.NodePath[] { new NodeEnvironment.NodePath(tempDir, mock(Environment.class)) };
    when(nodeEnvironment.nodePaths()).thenReturn(dataLocations);
    NodeEnvironmentModule nodeEnvironmentModule = new NodeEnvironmentModule(nodeEnvironment);
    MonitorModule monitorModule = new MonitorModule(NODE_SETTINGS);
    monitorModule.addExtendedNodeInfoType(SigarPlugin.NODE_INFO_EXTENDED_TYPE, SigarExtendedNodeInfo.class);
    Injector injector = new ModulesBuilder().add(new SettingsModule(NODE_SETTINGS), monitorModule, nodeEnvironmentModule, new SigarModule(new SigarService(NODE_SETTINGS))).createInjector();
    extendedNodeInfo = injector.getInstance(ExtendedNodeInfo.class);
}
Also used : Path(java.nio.file.Path) NodeEnvironment(org.elasticsearch.env.NodeEnvironment) Injector(org.elasticsearch.common.inject.Injector) SettingsModule(org.elasticsearch.common.settings.SettingsModule) SigarModule(io.crate.module.SigarModule) Environment(org.elasticsearch.env.Environment) NodeEnvironment(org.elasticsearch.env.NodeEnvironment) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) NodeEnvironmentModule(org.elasticsearch.env.NodeEnvironmentModule) Before(org.junit.Before)

Example 4 with ModulesBuilder

use of org.elasticsearch.common.inject.ModulesBuilder in project elasticsearch-skywalker by jprante.

the class SkywalkerTests method test.

@Test
public void test() {
    Settings settings = ImmutableSettings.settingsBuilder().build();
    Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings)), new IndicesAnalysisModule()).createInjector();
    ActionModule actionModule = new ActionModule(true);
    RestModule restModule = new RestModule(settings);
    SkywalkerPlugin plugin = new SkywalkerPlugin();
    plugin.onModule(actionModule);
    plugin.onModule(restModule);
}
Also used : IndicesAnalysisModule(org.elasticsearch.indices.analysis.IndicesAnalysisModule) RestModule(org.elasticsearch.rest.RestModule) EnvironmentModule(org.elasticsearch.env.EnvironmentModule) Injector(org.elasticsearch.common.inject.Injector) ActionModule(org.elasticsearch.action.ActionModule) SettingsModule(org.elasticsearch.common.settings.SettingsModule) Environment(org.elasticsearch.env.Environment) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) Settings(org.elasticsearch.common.settings.Settings) ImmutableSettings(org.elasticsearch.common.settings.ImmutableSettings) Test(org.testng.annotations.Test)

Example 5 with ModulesBuilder

use of org.elasticsearch.common.inject.ModulesBuilder in project crate by crate.

the class AggregateCollectorBenchmark method setup.

@Setup
public void setup() {
    InputCollectExpression inExpr0 = new InputCollectExpression(0);
    Functions functions = new ModulesBuilder().add(new AggregationImplModule()).createInjector().getInstance(Functions.class);
    SumAggregation<?> sumAggregation = (SumAggregation<?>) functions.getQualified(Signature.aggregate(SumAggregation.NAME, DataTypes.INTEGER.getTypeSignature(), DataTypes.LONG.getTypeSignature()), List.of(DataTypes.INTEGER), DataTypes.INTEGER);
    var memoryManager = new OnHeapMemoryManager(bytes -> {
    });
    collector = new AggregateCollector(Collections.singletonList(inExpr0), RamAccounting.NO_ACCOUNTING, memoryManager, Version.CURRENT, AggregateMode.ITER_FINAL, new AggregationFunction[] { sumAggregation }, Version.CURRENT, new Input[][] { { inExpr0 } }, new Input[] { Literal.BOOLEAN_TRUE });
}
Also used : Input(io.crate.data.Input) InputCollectExpression(io.crate.execution.engine.collect.InputCollectExpression) OnHeapMemoryManager(io.crate.memory.OnHeapMemoryManager) SumAggregation(io.crate.execution.engine.aggregation.impl.SumAggregation) Functions(io.crate.metadata.Functions) ModulesBuilder(org.elasticsearch.common.inject.ModulesBuilder) AggregationImplModule(io.crate.execution.engine.aggregation.impl.AggregationImplModule) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

ModulesBuilder (org.elasticsearch.common.inject.ModulesBuilder)14 Functions (io.crate.metadata.Functions)7 Injector (org.elasticsearch.common.inject.Injector)5 OnHeapMemoryManager (io.crate.memory.OnHeapMemoryManager)4 SettingsModule (org.elasticsearch.common.settings.SettingsModule)4 Setup (org.openjdk.jmh.annotations.Setup)4 Input (io.crate.data.Input)3 Row1 (io.crate.data.Row1)3 AggregationImplModule (io.crate.execution.engine.aggregation.impl.AggregationImplModule)3 InputCollectExpression (io.crate.execution.engine.collect.InputCollectExpression)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 List (java.util.List)3 TimeUnit (java.util.concurrent.TimeUnit)3 RamAccounting (io.crate.breaker.RamAccounting)2 Row (io.crate.data.Row)2 SumAggregation (io.crate.execution.engine.aggregation.impl.SumAggregation)2 AggregateMode (io.crate.expression.symbol.AggregateMode)2 Literal (io.crate.expression.symbol.Literal)2 Signature (io.crate.metadata.functions.Signature)2