|  | @@ -9,7 +9,6 @@ package org.elasticsearch.persistent;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import org.apache.logging.log4j.LogManager;
 | 
	
		
			
				|  |  |  import org.apache.logging.log4j.Logger;
 | 
	
		
			
				|  |  | -import org.elasticsearch.Version;
 | 
	
		
			
				|  |  |  import org.elasticsearch.action.ActionType;
 | 
	
		
			
				|  |  |  import org.elasticsearch.action.ActionListener;
 | 
	
		
			
				|  |  |  import org.elasticsearch.action.ActionRequest;
 | 
	
	
		
			
				|  | @@ -29,8 +28,6 @@ import org.elasticsearch.threadpool.ThreadPool;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.util.function.Predicate;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import static org.elasticsearch.persistent.CompletionPersistentTaskAction.LOCAL_ABORT_AVAILABLE_VERSION;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * This service is used by persistent tasks and allocated persistent tasks to communicate changes
 | 
	
		
			
				|  |  |   * to the master node so that the master can update the cluster state and can track of the states
 | 
	
	
		
			
				|  | @@ -71,18 +68,12 @@ public class PersistentTasksService {
 | 
	
		
			
				|  |  |       * At most one of {@code failure} and {@code localAbortReason} may be
 | 
	
		
			
				|  |  |       * provided. When both {@code failure} and {@code localAbortReason} are
 | 
	
		
			
				|  |  |       * {@code null}, the persistent task is considered as successfully completed.
 | 
	
		
			
				|  |  | -     * {@code localAbortReason} must not be provided unless all nodes in the cluster
 | 
	
		
			
				|  |  | -     * are on version {@link CompletionPersistentTaskAction#LOCAL_ABORT_AVAILABLE_VERSION}
 | 
	
		
			
				|  |  | -     * or higher.
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      public void sendCompletionRequest(final String taskId,
 | 
	
		
			
				|  |  |                                        final long taskAllocationId,
 | 
	
		
			
				|  |  |                                        final @Nullable Exception taskFailure,
 | 
	
		
			
				|  |  |                                        final @Nullable String localAbortReason,
 | 
	
		
			
				|  |  |                                        final ActionListener<PersistentTask<?>> listener) {
 | 
	
		
			
				|  |  | -        if (localAbortReason != null) {
 | 
	
		
			
				|  |  | -            validateLocalAbortSupported();
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  |          CompletionPersistentTaskAction.Request request =
 | 
	
		
			
				|  |  |              new CompletionPersistentTaskAction.Request(taskId, taskAllocationId, taskFailure, localAbortReason);
 | 
	
		
			
				|  |  |          execute(request, CompletionPersistentTaskAction.INSTANCE, listener);
 | 
	
	
		
			
				|  | @@ -125,31 +116,6 @@ public class PersistentTasksService {
 | 
	
		
			
				|  |  |          execute(request, RemovePersistentTaskAction.INSTANCE, listener);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    /**
 | 
	
		
			
				|  |  | -     * Is the cluster able to support locally aborting persistent tasks?
 | 
	
		
			
				|  |  | -     * This requires that every node in the cluster is on version
 | 
	
		
			
				|  |  | -     * {@link CompletionPersistentTaskAction#LOCAL_ABORT_AVAILABLE_VERSION}
 | 
	
		
			
				|  |  | -     * or above.
 | 
	
		
			
				|  |  | -     */
 | 
	
		
			
				|  |  | -    public boolean isLocalAbortSupported() {
 | 
	
		
			
				|  |  | -        return isLocalAbortSupported(clusterService.state());
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    public static boolean isLocalAbortSupported(ClusterState state) {
 | 
	
		
			
				|  |  | -        return state.nodes().getMinNodeVersion().onOrAfter(LOCAL_ABORT_AVAILABLE_VERSION);
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    /**
 | 
	
		
			
				|  |  | -     * Throw an exception if the cluster is not able locally abort persistent tasks.
 | 
	
		
			
				|  |  | -     */
 | 
	
		
			
				|  |  | -    public void validateLocalAbortSupported() {
 | 
	
		
			
				|  |  | -        Version minNodeVersion = clusterService.state().nodes().getMinNodeVersion();
 | 
	
		
			
				|  |  | -        if (minNodeVersion.before(LOCAL_ABORT_AVAILABLE_VERSION)) {
 | 
	
		
			
				|  |  | -            throw new IllegalStateException("attempt to abort a persistent task locally in a cluster that does not support this: "
 | 
	
		
			
				|  |  | -                + "minimum node version [" + minNodeVersion + "], version required [" + LOCAL_ABORT_AVAILABLE_VERSION + "]");
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * Executes an asynchronous persistent task action using the client.
 | 
	
		
			
				|  |  |       * <p>
 |