Description
It appears from test that if we provide invalid host address as one of the host address in the host list, LoadBalancingRpcClient should catch exception for invalid RpcClient and failover to next in the host list.
ERROR org.apache.flume.api.NettyAvroRpcClient - RPC connection error : java.io.IOException: Error connecting to xxxxx-xxxxx.xxxx.xxxxx.xxxx:xxxx at org.apache.avro.ipc.NettyTransceiver.getChannel(NettyTransceiver.java:249) at org.apache.avro.ipc.NettyTransceiver.<init>(NettyTransceiver.java:198) at org.apache.avro.ipc.NettyTransceiver.<init>(NettyTransceiver.java:147) at org.apache.flume.api.NettyAvroRpcClient.connect(NettyAvroRpcClient.java:118) at org.apache.flume.api.NettyAvroRpcClient.connect(NettyAvroRpcClient.java:107) at org.apache.flume.api.NettyAvroRpcClient.configure(NettyAvroRpcClient.java:446) at org.apache.flume.api.RpcClientFactory.getInstance(RpcClientFactory.java:83) at org.apache.flume.api.LoadBalancingRpcClient.createClient(LoadBalancingRpcClient.java:190) at org.apache.flume.api.LoadBalancingRpcClient.getClient(LoadBalancingRpcClient.java:173) at org.apache.flume.api.LoadBalancingRpcClient.append(LoadBalancingRpcClient.java:69)
The proposed fix would be moving RpcClient client = getClient(host) inside try block
@Override public void append(Event event) throws EventDeliveryException { boolean eventSent = false; Iterator<HostInfo> it = selector.createHostIterator(); while (it.hasNext()) { HostInfo host = it.next(); try { RpcClient client = getClient(host); client.append(event); eventSent = true; break; } catch (Exception ex) { LOGGER.warn("Failed to send event to host " + host, ex); } } if (!eventSent) { throw new EventDeliveryException("Unable to send event to any host"); } }