org.apache.flume.api
Class LoadBalancingRpcClient

java.lang.Object
  extended by org.apache.flume.api.AbstractRpcClient
      extended by org.apache.flume.api.LoadBalancingRpcClient
All Implemented Interfaces:
RpcClient

public class LoadBalancingRpcClient
extends AbstractRpcClient

An implementation of RpcClient interface that uses NettyAvroRpcClient instances to load-balance the requests over many different hosts. This implementation supports a round-robin scheme or random scheme of doing load balancing over the various hosts. To specify round-robin scheme set the value of the configuration property load-balance-type to round_robin. Similarly, for random scheme this value should be set to random, and for a custom scheme the full class name of the class that implements the HostSelector interface.

This implementation also performs basic failover in case the randomly selected host is not available for receiving the event.


Nested Class Summary
static interface LoadBalancingRpcClient.HostSelector
           
 
Field Summary
 
Fields inherited from class org.apache.flume.api.AbstractRpcClient
batchSize, connectTimeout, requestTimeout
 
Constructor Summary
LoadBalancingRpcClient()
           
 
Method Summary
 void append(Event event)
          Send a single Event to the associated Flume source.
 void appendBatch(List<Event> events)
          Send a list of events to the associated Flume source.
 void close()
          Immediately closes the client so that it may no longer be used.
protected  void configure(Properties properties)
          Configure the client using the given properties object.
 boolean isActive()
          Returns true if this object appears to be in a usable state, and it returns false if this object is permanently disabled.
 
Methods inherited from class org.apache.flume.api.AbstractRpcClient
getBatchSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoadBalancingRpcClient

public LoadBalancingRpcClient()
Method Detail

append

public void append(Event event)
            throws EventDeliveryException
Description copied from interface: RpcClient

Send a single Event to the associated Flume source.

This method blocks until the RPC returns or until the request times out.

Note: If this method throws an EventDeliveryException, there is no way to recover and the application must invoke RpcClient.close() on this object to clean up system resources.

Specified by:
append in interface RpcClient
Specified by:
append in class AbstractRpcClient
Throws:
EventDeliveryException - when an error prevents event delivery.

appendBatch

public void appendBatch(List<Event> events)
                 throws EventDeliveryException
Description copied from interface: RpcClient

Send a list of events to the associated Flume source.

This method blocks until the RPC returns or until the request times out.

It is strongly recommended that the number of events in the List be no more than RpcClient.getBatchSize(). If it is more, multiple RPC calls will be required, and the likelihood of duplicate Events being stored will increase.

Note: If this method throws an EventDeliveryException, there is no way to recover and the application must invoke RpcClient.close() on this object to clean up system resources.

Specified by:
appendBatch in interface RpcClient
Specified by:
appendBatch in class AbstractRpcClient
Parameters:
events - List of events to send
Throws:
EventDeliveryException - when an error prevents event delivery.

isActive

public boolean isActive()
Description copied from interface: RpcClient

Returns true if this object appears to be in a usable state, and it returns false if this object is permanently disabled.

If this method returns false, an application must call RpcClient.close() on this object to clean up system resources.

Specified by:
isActive in interface RpcClient
Specified by:
isActive in class AbstractRpcClient

close

public void close()
           throws FlumeException
Description copied from interface: RpcClient

Immediately closes the client so that it may no longer be used.

Note: This method MUST be called by applications when they are done using the RPC client in order to clean up resources.

Multi-threaded applications may want to gracefully stop making RPC calls before calling close(). Otherwise, they risk getting EventDeliveryException thrown from their in-flight calls when the underlying connection is disabled.

Specified by:
close in interface RpcClient
Specified by:
close in class AbstractRpcClient
Throws:
FlumeException

configure

protected void configure(Properties properties)
                  throws FlumeException
Description copied from class: AbstractRpcClient
Configure the client using the given properties object.

Specified by:
configure in class AbstractRpcClient
Throws:
FlumeException - if the client can not be configured using this method, or if the client was already configured once.


Copyright © 2009-2015 Apache Software Foundation. All Rights Reserved.