本文整理汇总了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();
}
});
}
示例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);
}
});
}
示例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);
}
});
}
示例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();
}
});
}