当前位置: 首页>>代码示例>>Java>>正文


Java ClusterService.submitStateUpdateTask方法代码示例

本文整理汇总了Java中org.elasticsearch.cluster.service.ClusterService.submitStateUpdateTask方法的典型用法代码示例。如果您正苦于以下问题:Java ClusterService.submitStateUpdateTask方法的具体用法?Java ClusterService.submitStateUpdateTask怎么用?Java ClusterService.submitStateUpdateTask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.cluster.service.ClusterService的用法示例。


在下文中一共展示了ClusterService.submitStateUpdateTask方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteStoredScript

import org.elasticsearch.cluster.service.ClusterService; //导入方法依赖的package包/类
public void deleteStoredScript(ClusterService clusterService, DeleteStoredScriptRequest request,
                               ActionListener<DeleteStoredScriptResponse> listener) {
    if (request.lang() != null && isLangSupported(request.lang()) == false) {
        throw new IllegalArgumentException("unable to delete stored script with unsupported lang [" + request.lang() +"]");
    }

    clusterService.submitStateUpdateTask("delete-script-" + request.id(),
        new AckedClusterStateUpdateTask<DeleteStoredScriptResponse>(request, listener) {

        @Override
        protected DeleteStoredScriptResponse newResponse(boolean acknowledged) {
            return new DeleteStoredScriptResponse(acknowledged);
        }

        @Override
        public ClusterState execute(ClusterState currentState) throws Exception {
            ScriptMetaData smd = currentState.metaData().custom(ScriptMetaData.TYPE);
            smd = ScriptMetaData.deleteStoredScript(smd, request.id(), request.lang());
            MetaData.Builder mdb = MetaData.builder(currentState.getMetaData()).putCustom(ScriptMetaData.TYPE, smd);

            return ClusterState.builder(currentState).metaData(mdb).build();
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:ScriptService.java

示例2: delete

import org.elasticsearch.cluster.service.ClusterService; //导入方法依赖的package包/类
/**
 * Deletes the pipeline specified by id in the request.
 */
public void delete(ClusterService clusterService, DeletePipelineRequest request, ActionListener<WritePipelineResponse> listener) {
    clusterService.submitStateUpdateTask("delete-pipeline-" + request.getId(),
            new AckedClusterStateUpdateTask<WritePipelineResponse>(request, listener) {

        @Override
        protected WritePipelineResponse newResponse(boolean acknowledged) {
            return new WritePipelineResponse(acknowledged);
        }

        @Override
        public ClusterState execute(ClusterState currentState) throws Exception {
            return innerDelete(request, currentState);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:PipelineStore.java

示例3: put

import org.elasticsearch.cluster.service.ClusterService; //导入方法依赖的package包/类
/**
 * Stores the specified pipeline definition in the request.
 */
public void put(ClusterService clusterService, Map<DiscoveryNode, IngestInfo> ingestInfos, PutPipelineRequest request,
                ActionListener<WritePipelineResponse> listener) throws Exception {
    // validates the pipeline and processor configuration before submitting a cluster update task:
    validatePipeline(ingestInfos, request);
    clusterService.submitStateUpdateTask("put-pipeline-" + request.getId(),
            new AckedClusterStateUpdateTask<WritePipelineResponse>(request, listener) {

        @Override
        protected WritePipelineResponse newResponse(boolean acknowledged) {
            return new WritePipelineResponse(acknowledged);
        }

        @Override
        public ClusterState execute(ClusterState currentState) throws Exception {
            return innerPut(request, currentState);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:PipelineStore.java

示例4: putStoredScript

import org.elasticsearch.cluster.service.ClusterService; //导入方法依赖的package包/类
public void putStoredScript(ClusterService clusterService, PutStoredScriptRequest request,
                            ActionListener<PutStoredScriptResponse> listener) {
    int max = SCRIPT_MAX_SIZE_IN_BYTES.get(settings);

    if (request.content().length() > max) {
        throw new IllegalArgumentException("exceeded max allowed stored script size in bytes [" + max + "] with size [" +
            request.content().length() + "] for script [" + request.id() + "]");
    }

    StoredScriptSource source = StoredScriptSource.parse(request.lang(), request.content(), request.xContentType());

    if (isLangSupported(source.getLang()) == false) {
        throw new IllegalArgumentException("unable to put stored script with unsupported lang [" + source.getLang() + "]");
    }

    try {
        ScriptEngineService scriptEngineService = getScriptEngineServiceForLang(source.getLang());

        if (isAnyScriptContextEnabled(source.getLang(), ScriptType.STORED)) {
            Object compiled = scriptEngineService.compile(request.id(), source.getCode(), Collections.emptyMap());

            if (compiled == null) {
                throw new IllegalArgumentException("failed to parse/compile stored script [" + request.id() + "]" +
                    (source.getCode() == null ? "" : " using code [" + source.getCode() + "]"));
            }
        } else {
            throw new IllegalArgumentException(
                "cannot put stored script [" + request.id() + "], stored scripts cannot be run under any context");
        }
    } catch (ScriptException good) {
        throw good;
    } catch (Exception exception) {
        throw new IllegalArgumentException("failed to parse/compile stored script [" + request.id() + "]", exception);
    }

    clusterService.submitStateUpdateTask("put-script-" + request.id(),
        new AckedClusterStateUpdateTask<PutStoredScriptResponse>(request, listener) {

        @Override
        protected PutStoredScriptResponse newResponse(boolean acknowledged) {
            return new PutStoredScriptResponse(acknowledged);
        }

        @Override
        public ClusterState execute(ClusterState currentState) throws Exception {
            ScriptMetaData smd = currentState.metaData().custom(ScriptMetaData.TYPE);
            smd = ScriptMetaData.putStoredScript(smd, request.id(), source);
            MetaData.Builder mdb = MetaData.builder(currentState.getMetaData()).putCustom(ScriptMetaData.TYPE, smd);

            return ClusterState.builder(currentState).metaData(mdb).build();
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:54,代码来源:ScriptService.java


注:本文中的org.elasticsearch.cluster.service.ClusterService.submitStateUpdateTask方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。