Search in sources :

Example 1 with OpenSearchSecurityException

use of org.opensearch.OpenSearchSecurityException in project OpenSearch by opensearch-project.

the class TaskCancellationService method setBanOnNodes.

private void setBanOnNodes(String reason, boolean waitForCompletion, CancellableTask task, Collection<DiscoveryNode> childNodes, ActionListener<Void> listener) {
    if (childNodes.isEmpty()) {
        listener.onResponse(null);
        return;
    }
    final TaskId taskId = new TaskId(localNodeId(), task.getId());
    logger.trace("cancelling child tasks of [{}] on child nodes {}", taskId, childNodes);
    GroupedActionListener<Void> groupedListener = new GroupedActionListener<>(ActionListener.map(listener, r -> null), childNodes.size());
    final BanParentTaskRequest banRequest = BanParentTaskRequest.createSetBanParentTaskRequest(taskId, reason, waitForCompletion);
    for (DiscoveryNode node : childNodes) {
        transportService.sendRequest(node, BAN_PARENT_ACTION_NAME, banRequest, new EmptyTransportResponseHandler(ThreadPool.Names.SAME) {

            @Override
            public void handleResponse(TransportResponse.Empty response) {
                logger.trace("sent ban for tasks with the parent [{}] to the node [{}]", taskId, node);
                groupedListener.onResponse(null);
            }

            @Override
            public void handleException(TransportException exp) {
                assert ExceptionsHelper.unwrapCause(exp) instanceof OpenSearchSecurityException == false;
                logger.warn("Cannot send ban for tasks with the parent [{}] to the node [{}]", taskId, node);
                groupedListener.onFailure(exp);
            }
        });
    }
}
Also used : StreamInput(org.opensearch.common.io.stream.StreamInput) TransportRequestHandler(org.opensearch.transport.TransportRequestHandler) EmptyTransportResponseHandler(org.opensearch.transport.EmptyTransportResponseHandler) TransportChannel(org.opensearch.transport.TransportChannel) TransportRequest(org.opensearch.transport.TransportRequest) ThreadPool(org.opensearch.threadpool.ThreadPool) Collection(java.util.Collection) ExceptionsHelper(org.opensearch.ExceptionsHelper) StreamOutput(org.opensearch.common.io.stream.StreamOutput) IOException(java.io.IOException) TransportResponse(org.opensearch.transport.TransportResponse) TransportService(org.opensearch.transport.TransportService) OpenSearchSecurityException(org.opensearch.OpenSearchSecurityException) GroupedActionListener(org.opensearch.action.support.GroupedActionListener) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) List(java.util.List) Logger(org.apache.logging.log4j.Logger) LegacyESVersion(org.opensearch.LegacyESVersion) StepListener(org.opensearch.action.StepListener) ActionListener(org.opensearch.action.ActionListener) ChannelActionListener(org.opensearch.action.support.ChannelActionListener) LogManager(org.apache.logging.log4j.LogManager) TransportException(org.opensearch.transport.TransportException) OpenSearchSecurityException(org.opensearch.OpenSearchSecurityException) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) TransportResponse(org.opensearch.transport.TransportResponse) TransportException(org.opensearch.transport.TransportException) GroupedActionListener(org.opensearch.action.support.GroupedActionListener) EmptyTransportResponseHandler(org.opensearch.transport.EmptyTransportResponseHandler)

Example 2 with OpenSearchSecurityException

use of org.opensearch.OpenSearchSecurityException in project OpenSearch by opensearch-project.

the class TaskCancellationService method removeBanOnNodes.

private void removeBanOnNodes(CancellableTask task, Collection<DiscoveryNode> childNodes) {
    final BanParentTaskRequest request = BanParentTaskRequest.createRemoveBanParentTaskRequest(new TaskId(localNodeId(), task.getId()));
    for (DiscoveryNode node : childNodes) {
        logger.trace("Sending remove ban for tasks with the parent [{}] to the node [{}]", request.parentTaskId, node);
        transportService.sendRequest(node, BAN_PARENT_ACTION_NAME, request, new EmptyTransportResponseHandler(ThreadPool.Names.SAME) {

            @Override
            public void handleException(TransportException exp) {
                assert ExceptionsHelper.unwrapCause(exp) instanceof OpenSearchSecurityException == false;
                logger.info("failed to remove the parent ban for task {} on node {}", request.parentTaskId, node);
            }
        });
    }
}
Also used : OpenSearchSecurityException(org.opensearch.OpenSearchSecurityException) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) EmptyTransportResponseHandler(org.opensearch.transport.EmptyTransportResponseHandler) TransportException(org.opensearch.transport.TransportException)

Aggregations

OpenSearchSecurityException (org.opensearch.OpenSearchSecurityException)2 DiscoveryNode (org.opensearch.cluster.node.DiscoveryNode)2 EmptyTransportResponseHandler (org.opensearch.transport.EmptyTransportResponseHandler)2 TransportException (org.opensearch.transport.TransportException)2 IOException (java.io.IOException)1 Collection (java.util.Collection)1 List (java.util.List)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 ExceptionsHelper (org.opensearch.ExceptionsHelper)1 LegacyESVersion (org.opensearch.LegacyESVersion)1 ActionListener (org.opensearch.action.ActionListener)1 StepListener (org.opensearch.action.StepListener)1 ChannelActionListener (org.opensearch.action.support.ChannelActionListener)1 GroupedActionListener (org.opensearch.action.support.GroupedActionListener)1 StreamInput (org.opensearch.common.io.stream.StreamInput)1 StreamOutput (org.opensearch.common.io.stream.StreamOutput)1 ThreadPool (org.opensearch.threadpool.ThreadPool)1 TransportChannel (org.opensearch.transport.TransportChannel)1 TransportRequest (org.opensearch.transport.TransportRequest)1