Nicer failure message when node should not connect to another in nodes API
There are cases where nodes should not connect to another node. For example, client nodes do not connect to other client nodes. When executing a nodes level API, we should have a nicer failure indicating that, and not log it by default, as its not a real failure
This commit is contained in:
parent
9d0fc76f54
commit
56fa5458e6
|
@ -163,6 +163,8 @@ public abstract class TransportNodesOperationAction<Request extends NodesOperati
|
||||||
} else {
|
} else {
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
onFailure(idx, nodeId, new NoSuchNodeException(nodeId));
|
onFailure(idx, nodeId, new NoSuchNodeException(nodeId));
|
||||||
|
} else if (!clusterService.localNode().shouldConnectTo(node)) {
|
||||||
|
onFailure(idx, nodeId, new NodeShouldNotConnectException(clusterService.localNode(), node));
|
||||||
} else {
|
} else {
|
||||||
NodeRequest nodeRequest = newNodeRequest(nodeId, request);
|
NodeRequest nodeRequest = newNodeRequest(nodeId, request);
|
||||||
transportService.sendRequest(node, transportNodeAction, nodeRequest, transportRequestOptions, new BaseTransportResponseHandler<NodeResponse>() {
|
transportService.sendRequest(node, transportNodeAction, nodeRequest, transportRequestOptions, new BaseTransportResponseHandler<NodeResponse>() {
|
||||||
|
@ -202,7 +204,7 @@ public abstract class TransportNodesOperationAction<Request extends NodesOperati
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onFailure(int idx, String nodeId, Throwable t) {
|
private void onFailure(int idx, String nodeId, Throwable t) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled() && !(t instanceof NodeShouldNotConnectException)) {
|
||||||
logger.debug("failed to execute on node [{}]", t, nodeId);
|
logger.debug("failed to execute on node [{}]", t, nodeId);
|
||||||
}
|
}
|
||||||
if (accumulateExceptions()) {
|
if (accumulateExceptions()) {
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* Licensed to Elasticsearch under one or more contributor
|
||||||
|
* license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright
|
||||||
|
* ownership. Elasticsearch licenses this file to you under
|
||||||
|
* the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
* not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.elasticsearch.transport;
|
||||||
|
|
||||||
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public class NodeShouldNotConnectException extends NodeNotConnectedException {
|
||||||
|
|
||||||
|
public NodeShouldNotConnectException(DiscoveryNode fromNode, DiscoveryNode node) {
|
||||||
|
super(node, "node should not connect from [" + fromNode + "]");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue