Mubarak Seyed created FLUME-1306:
------------------------------------

             Summary: LoadBalancingRpcClient should catch exception for invalid 
RpcClient and failover to valid one
                 Key: FLUME-1306
                 URL: https://issues.apache.org/jira/browse/FLUME-1306
             Project: Flume
          Issue Type: Bug
            Reporter: Mubarak Seyed
            Assignee: Mubarak Seyed


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.

{code}
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)
{code}

The proposed fix would be moving {{RpcClient client = getClient(host)}} inside 
{{try}} block

{code}
@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");
    }
  }
{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to