final IndexTemplateMetaData template = templateBuilder.build();
clusterService.submitStateUpdateTask("create-index-template [" + request.name + "], cause [" + request.cause + "]", new ProcessedClusterStateUpdateTask() {
@Override public ClusterState execute(ClusterState currentState) {
if (request.create && currentState.metaData().templates().containsKey(request.name)) {
listener.onFailure(new IndexTemplateAlreadyExistsException(request.name));
return currentState;
}
MetaData.Builder builder = MetaData.builder().metaData(currentState.metaData())
.put(template);