org.elasticsearch.common.inject.multibindings.MapBinder Java Examples

The following examples show how to use org.elasticsearch.common.inject.multibindings.MapBinder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlobShardExpressionModule.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
    MapBinder<ReferenceIdent, BlobShardReferenceImplementation> binder = MapBinder
            .newMapBinder(binder(), ReferenceIdent.class, BlobShardReferenceImplementation.class);
    if (settings.getAsBoolean(BlobIndices.SETTING_INDEX_BLOBS_ENABLED, false)){

        binder.addBinding(SysShardsTableInfo.ReferenceIdents.ID).to(BlobShardIdExpression.class).asEagerSingleton();
        binder.addBinding(SysShardsTableInfo.ReferenceIdents.NUM_DOCS).to(BlobShardNumDocsExpression.class).asEagerSingleton();
        binder.addBinding(SysShardsTableInfo.ReferenceIdents.PRIMARY).to(BlobShardPrimaryExpression.class).asEagerSingleton();
        binder.addBinding(SysShardsTableInfo.ReferenceIdents.RELOCATING_NODE).to(BlobShardRelocatingNodeExpression.class).asEagerSingleton();
        binder.addBinding(SysShardsTableInfo.ReferenceIdents.SCHEMA_NAME).to(BlobShardSchemaNameExpression.class).asEagerSingleton();
        binder.addBinding(SysShardsTableInfo.ReferenceIdents.SIZE).to(BlobShardSizeExpression.class).asEagerSingleton();
        binder.addBinding(SysShardsTableInfo.ReferenceIdents.STATE).to(BlobShardStateExpression.class).asEagerSingleton();
        binder.addBinding(SysShardsTableInfo.ReferenceIdents.ROUTING_STATE).to(BlobShardRoutingStateExpression.class).asEagerSingleton();
        binder.addBinding(SysShardsTableInfo.ReferenceIdents.TABLE_NAME).to(BlobShardTableNameExpression.class).asEagerSingleton();
        binder.addBinding(SysShardsTableInfo.ReferenceIdents.PARTITION_IDENT).to(BlobShardPartitionIdentExpression.class).asEagerSingleton();
        binder.addBinding(SysShardsTableInfo.ReferenceIdents.ORPHAN_PARTITION).to(BlobShardPartitionOrphanedExpression.class).asEagerSingleton();
    }
}
 
Example #2
Source File: SysShardExpressionModule.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
    MapBinder<ReferenceIdent, ShardReferenceImplementation> b = MapBinder
            .newMapBinder(binder(), ReferenceIdent.class, ShardReferenceImplementation.class);

    b.addBinding(SysShardsTableInfo.ReferenceIdents.ID).to(ShardIdExpression.class).asEagerSingleton();
    b.addBinding(SysShardsTableInfo.ReferenceIdents.SIZE).to(ShardSizeExpression.class).asEagerSingleton();
    b.addBinding(SysShardsTableInfo.ReferenceIdents.NUM_DOCS).to(ShardNumDocsExpression.class).asEagerSingleton();
    b.addBinding(SysShardsTableInfo.ReferenceIdents.PRIMARY).to(ShardPrimaryExpression.class).asEagerSingleton();
    b.addBinding(SysShardsTableInfo.ReferenceIdents.STATE).to(ShardStateExpression.class).asEagerSingleton();
    b.addBinding(SysShardsTableInfo.ReferenceIdents.ROUTING_STATE).to(ShardRoutingStateExpression.class).asEagerSingleton();
    b.addBinding(SysShardsTableInfo.ReferenceIdents.RELOCATING_NODE).to(ShardRelocatingNodeExpression.class).asEagerSingleton();
    b.addBinding(SysShardsTableInfo.ReferenceIdents.TABLE_NAME).to(ShardTableNameExpression.class).asEagerSingleton();
    b.addBinding(SysShardsTableInfo.ReferenceIdents.SCHEMA_NAME).to(ShardSchemaNameExpression.class).asEagerSingleton();
    b.addBinding(SysShardsTableInfo.ReferenceIdents.PARTITION_IDENT).to(ShardPartitionIdentExpression.class).asEagerSingleton();
    b.addBinding(SysShardsTableInfo.ReferenceIdents.ORPHAN_PARTITION).to(ShardPartitionOrphanedExpression.class).asEagerSingleton();
}
 
Example #3
Source File: ActionModule.java    From crate with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
    bind(DestructiveOperations.class).toInstance(destructiveOperations);

    // register GenericAction -> transportAction Map used by NodeClient
    @SuppressWarnings("rawtypes")
    MapBinder<GenericAction, TransportAction> transportActionsBinder
            = MapBinder.newMapBinder(binder(), GenericAction.class, TransportAction.class);
    for (ActionHandler<?, ?> action : actions.values()) {
        // bind the action as eager singleton, so the map binder one will reuse it
        bind(action.getTransportAction()).asEagerSingleton();
        transportActionsBinder.addBinding(action.getAction()).to(action.getTransportAction()).asEagerSingleton();
        for (Class<?> supportAction : action.getSupportTransportActions()) {
            bind(supportAction).asEagerSingleton();
        }
    }
}
 
Example #4
Source File: RepositoriesModule.java    From crate with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
    bind(RepositoriesService.class).asEagerSingleton();
    bind(SnapshotsService.class).asEagerSingleton();
    bind(SnapshotShardsService.class).asEagerSingleton();
    bind(RestoreService.class).asEagerSingleton();
    MapBinder<String, Repository.Factory> typesBinder = MapBinder.newMapBinder(binder(), String.class, Repository.Factory.class);
    repositoryTypes.forEach((k, v) -> typesBinder.addBinding(k).toInstance(v));

    MapBinder<String, TypeSettings> typeSettingsBinder = MapBinder.newMapBinder(
        binder(),
        String.class,
        TypeSettings.class);
    for (var e : repositoryTypes.entrySet()) {
        String repoScheme = e.getKey();
        var repoSettings = e.getValue().settings();
        typeSettingsBinder.addBinding(repoScheme).toInstance(repoSettings);
    }
}
 
Example #5
Source File: ReindexModule.java    From elasticsearch-inout-plugin with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
    bind(TransportReindexAction.class).asEagerSingleton();

    bind(ReindexParser.class).asEagerSingleton();

    MapBinder<GenericAction, TransportAction> transportActionsBinder =
            MapBinder.newMapBinder(
                    binder(), GenericAction.class, TransportAction.class);

    transportActionsBinder.addBinding(ReindexAction.INSTANCE).to(
            TransportReindexAction.class).asEagerSingleton();

    MapBinder<String, GenericAction> actionsBinder = MapBinder
            .newMapBinder(binder(), String.class, GenericAction.class);
    actionsBinder.addBinding(ReindexAction.NAME).toInstance(
            ReindexAction.INSTANCE);

}
 
Example #6
Source File: ScriptModule.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
    MapBinder<String, NativeScriptFactory> scriptsBinder
            = MapBinder.newMapBinder(binder(), String.class, NativeScriptFactory.class);
    for (Map.Entry<String, Class<? extends NativeScriptFactory>> entry : scripts.entrySet()) {
        scriptsBinder.addBinding(entry.getKey()).to(entry.getValue()).asEagerSingleton();
    }

    Multibinder<ScriptEngineService> multibinder = Multibinder.newSetBinder(binder(), ScriptEngineService.class);
    multibinder.addBinding().to(NativeScriptEngineService.class);
    
    try {
        Class.forName("com.github.mustachejava.Mustache");
        multibinder.addBinding().to(MustacheScriptEngineService.class).asEagerSingleton();
    } catch (Throwable t) {
        Loggers.getLogger(ScriptService.class, settings).debug("failed to load mustache", t);
    }

    for (Class<? extends ScriptEngineService> scriptEngine : scriptEngines) {
        multibinder.addBinding().to(scriptEngine).asEagerSingleton();
    }

    bind(ScriptContextRegistry.class).toInstance(new ScriptContextRegistry(customScriptContexts));
    bind(ScriptService.class).asEagerSingleton();
}
 
Example #7
Source File: ExtensionPoint.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
protected void bindExtensions(Binder binder) {
    MapBinder<K, V> mapBinder = MapBinder.newMapBinder(binder, keyType, valueType);
    for (Map.Entry<K, V> entry : map.entrySet()) {
        mapBinder.addBinding(entry.getKey()).toInstance(entry.getValue());
    }
}
 
Example #8
Source File: SysNodeChecksModule.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    bind(SysNodeChecks.class).asEagerSingleton();

    MapBinder<Integer, SysNodeCheck> b = MapBinder.newMapBinder(binder(), Integer.class, SysNodeCheck.class);

    // Node checks ordered by ID. New ID must be max ID + 1 and must not be reused.
    b.addBinding(RecoveryExpectedNodesSysCheck.ID).to(RecoveryExpectedNodesSysCheck.class);
    b.addBinding(RecoveryAfterNodesSysCheck.ID).to(RecoveryAfterNodesSysCheck.class);
    b.addBinding(RecoveryAfterTimeSysCheck.ID).to(RecoveryAfterTimeSysCheck.class);
    b.addBinding(HighDiskWatermarkNodesSysCheck.ID).to(HighDiskWatermarkNodesSysCheck.class);
    b.addBinding(LowDiskWatermarkNodesSysCheck.ID).to(LowDiskWatermarkNodesSysCheck.class);
    b.addBinding(FloodStageDiskWatermarkNodesSysCheck.ID).to(FloodStageDiskWatermarkNodesSysCheck.class);
}
 
Example #9
Source File: AbstractFunctionModule.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    configureFunctions();

    implementationsBinder = MapBinder.newMapBinder(
        binder(),
        new TypeLiteral<FunctionName>() {},
        new TypeLiteral<List<FunctionProvider>>() {});
    for (Map.Entry<FunctionName, List<FunctionProvider>> entry : functionImplementations.entrySet()) {
        implementationsBinder.addBinding(entry.getKey()).toProvider(entry::getValue);
    }

    // clear registration maps
    functionImplementations = null;
}
 
Example #10
Source File: MetaDataSysModule.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    schemaBinder = MapBinder.newMapBinder(binder(), String.class, SchemaInfo.class);
    schemaBinder.addBinding(SysSchemaInfo.NAME).to(SysSchemaInfo.class).asEagerSingleton();
    bind(TableHealthService.class).asEagerSingleton();
    bind(SysTableDefinitions.class).asEagerSingleton();
}
 
Example #11
Source File: FileCollectModule.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    MapBinder<String, FileInputFactory> binder = MapBinder.newMapBinder(binder(), String.class, FileInputFactory.class);

    binder.addBinding(LocalFsFileInputFactory.NAME).to(LocalFsFileInputFactory.class).asEagerSingleton();
    binder.addBinding(S3FileInputFactory.NAME).to(S3FileInputFactory.class).asEagerSingleton();
}
 
Example #12
Source File: ExportModule.java    From elasticsearch-inout-plugin with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    bind(TransportExportAction.class).asEagerSingleton();

    bind(ExportParser.class).asEagerSingleton();
    bind(Exporter.class).asEagerSingleton();

    MapBinder<GenericAction, TransportAction> transportActionsBinder = MapBinder.newMapBinder(binder(), GenericAction.class, TransportAction.class);

    transportActionsBinder.addBinding(ExportAction.INSTANCE).to(TransportExportAction.class).asEagerSingleton();

    MapBinder<String, GenericAction> actionsBinder = MapBinder.newMapBinder(binder(), String.class, GenericAction.class);
    actionsBinder.addBinding(ExportAction.NAME).toInstance(ExportAction.INSTANCE);
}
 
Example #13
Source File: SearchIntoModule.java    From elasticsearch-inout-plugin with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    bind(TransportSearchIntoAction.class).asEagerSingleton();

    bind(SearchIntoParser.class).asEagerSingleton();

    MapBinder<GenericAction, TransportAction> transportActionsBinder =
            MapBinder.newMapBinder(
                    binder(), GenericAction.class, TransportAction.class);

    transportActionsBinder.addBinding(SearchIntoAction.INSTANCE).to(
            TransportSearchIntoAction.class).asEagerSingleton();

    MapBinder<String, GenericAction> actionsBinder = MapBinder
            .newMapBinder(binder(), String.class, GenericAction.class);
    actionsBinder.addBinding(SearchIntoAction.NAME).toInstance(
            SearchIntoAction.INSTANCE);


    MapBinder<String, WriterCollectorFactory> collectorBinder
            = MapBinder.newMapBinder(binder(),
            String.class, WriterCollectorFactory.class);

    collectorBinder.addBinding(BulkWriterCollector.NAME).toProvider(
            FactoryProvider
                    .newFactory(WriterCollectorFactory.class,
                            BulkWriterCollector.class));


}
 
Example #14
Source File: ImportModule.java    From elasticsearch-inout-plugin with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    bind(TransportImportAction.class).asEagerSingleton();

    bind(ImportParser.class).asEagerSingleton();
    bind(Importer.class).asEagerSingleton();

    MapBinder<GenericAction, TransportAction> transportActionsBinder = MapBinder.newMapBinder(binder(), GenericAction.class, TransportAction.class);
    transportActionsBinder.addBinding(ImportAction.INSTANCE).to(TransportImportAction.class).asEagerSingleton();

    MapBinder<String, GenericAction> actionsBinder = MapBinder.newMapBinder(binder(), String.class, GenericAction.class);
    actionsBinder.addBinding(ImportAction.NAME).toInstance(ImportAction.INSTANCE);

}
 
Example #15
Source File: FileCollectModule.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    MapBinder<String, FileInputFactory> binder = MapBinder.newMapBinder(binder(), String.class, FileInputFactory.class);

    binder.addBinding(LocalFsFileInputFactory.NAME).to(LocalFsFileInputFactory.class).asEagerSingleton();
    binder.addBinding(S3FileInputFactory.NAME).to(S3FileInputFactory.class).asEagerSingleton();
}
 
Example #16
Source File: ExtensionPoint.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
protected final void bindExtensions(Binder binder) {
    MapBinder<String, T> parserMapBinder = MapBinder.newMapBinder(binder, String.class, extensionClass);
    for (Map.Entry<String, Class<? extends T>> clazz : extensions.entrySet()) {
        parserMapBinder.addBinding(clazz.getKey()).to(clazz.getValue());
    }
}
 
Example #17
Source File: PredicateModule.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    functionBinder = MapBinder.newMapBinder(binder(), FunctionIdent.class, FunctionImplementation.class);
    resolverBinder = MapBinder.newMapBinder(binder(), String.class, DynamicFunctionResolver.class);
    IsNullPredicate.register(this);
    NotPredicate.register(this);
    MatchPredicate.register(this);
}
 
Example #18
Source File: TableFunctionModule.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    Unnest.register(this);
    MapBinder<String,TableFunctionImplementation> functionBinder =
            MapBinder.newMapBinder(binder(), String.class, TableFunctionImplementation.class);

    for (Map.Entry<String, TableFunctionImplementation> entry : functions.entrySet()) {
        functionBinder.addBinding(entry.getKey()).toInstance(entry.getValue());
    }
    functions.clear();
    functions = null;
}
 
Example #19
Source File: SysClusterExpressionModule.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    MapBinder<ReferenceIdent, ReferenceImplementation> b = MapBinder
            .newMapBinder(binder(), ReferenceIdent.class, ReferenceImplementation.class);

    b.addBinding(clusterIdent(ClusterIdExpression.NAME)).to(
            ClusterIdExpression.class).asEagerSingleton();
    b.addBinding(clusterIdent(ClusterNameExpression.NAME)).to(
            ClusterNameExpression.class).asEagerSingleton();
    b.addBinding(clusterIdent(ClusterMasterNodeExpression.NAME)).to(
            ClusterMasterNodeExpression.class).asEagerSingleton();
    b.addBinding(clusterIdent(ClusterSettingsExpression.NAME)).to(
            ClusterSettingsExpression.class).asEagerSingleton();
}
 
Example #20
Source File: RepositorySettingsModule.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    typeSettingsBinder = MapBinder.newMapBinder(binder(), String.class, TypeSettings.class);
    typeSettingsBinder.addBinding(FS).toInstance(FS_SETTINGS);
    typeSettingsBinder.addBinding(URL).toInstance(URL_SETTINGS);
    typeSettingsBinder.addBinding(HDFS).toInstance(HDFS_SETTINGS);
    typeSettingsBinder.addBinding(S3).toInstance(S3_SETTINGS);
}
 
Example #21
Source File: MetaDataInformationModule.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
protected void configure() {
    schemaBinder = MapBinder.newMapBinder(binder(), String.class, SchemaInfo.class);
    schemaBinder.addBinding(InformationSchemaInfo.NAME).to(InformationSchemaInfo.class).asEagerSingleton();
}
 
Example #22
Source File: MetaDataBlobModule.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
protected void configure() {
    schemaBinder = MapBinder.newMapBinder(binder(), String.class, SchemaInfo.class);
    schemaBinder.addBinding(BlobSchemaInfo.NAME).to(BlobSchemaInfo.class).asEagerSingleton();
}
 
Example #23
Source File: PgCatalogModule.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
protected void configure() {
    schemaBinder = MapBinder.newMapBinder(binder(), String.class, SchemaInfo.class);
    schemaBinder.addBinding(PgCatalogSchemaInfo.NAME).to(PgCatalogSchemaInfo.class).asEagerSingleton();
    bind(PgCatalogTableDefinitions.class).asEagerSingleton();
}
 
Example #24
Source File: MetaDataModule.java    From crate with Apache License 2.0 4 votes vote down vote up
private void bindSchemas() {
    MapBinder.newMapBinder(binder(), String.class, SchemaInfo.class);
    bind(Schemas.class).asEagerSingleton();
}
 
Example #25
Source File: MetaDataInformationModule.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
protected void configure() {
    schemaBinder = MapBinder.newMapBinder(binder(), String.class, SchemaInfo.class);
    schemaBinder.addBinding(InformationSchemaInfo.NAME).to(InformationSchemaInfo.class).asEagerSingleton();
    bind(InformationSchemaTableDefinitions.class).asEagerSingleton();
}
 
Example #26
Source File: SysNodeExpressionModule.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
protected void configure() {
    refBinder = MapBinder.newMapBinder(binder(), ReferenceIdent.class, ReferenceImplementation.class);
    bind(NodeSysExpression.class).asEagerSingleton();
}
 
Example #27
Source File: MetaDataDocModule.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
protected void configure() {
    schemaBinder = MapBinder.newMapBinder(binder(), String.class, SchemaInfo.class);
    schemaBinder.addBinding(Schemas.DEFAULT_SCHEMA_NAME).to(DocSchemaInfo.class).asEagerSingleton();
}
 
Example #28
Source File: MetaDataModule.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
protected void bindReferences() {
    referenceBinder = MapBinder.newMapBinder(binder(), ReferenceIdent.class, ReferenceImplementation.class);
    bind(NestedReferenceResolver.class).to(GlobalReferenceResolver.class).asEagerSingleton();
}
 
Example #29
Source File: MetaDataModule.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
protected void bindFunctions() {
    functionBinder = MapBinder.newMapBinder(binder(), FunctionIdent.class, FunctionImplementation.class);
    MapBinder.newMapBinder(binder(), String.class, DynamicFunctionResolver.class);
    MapBinder.newMapBinder(binder(), String.class, TableFunctionImplementation.class);
    bind(Functions.class).asEagerSingleton();
}
 
Example #30
Source File: MetaDataModule.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
protected void bindSchemas() {
    schemaBinder = MapBinder.newMapBinder(binder(), String.class, SchemaInfo.class);
    bind(Schemas.class).to(ReferenceInfos.class).asEagerSingleton();
}