public class LoadBalancingLog4jAppender extends Log4jAppender
Hosts : A space separated list of host:port of the first hop at which Flume (through an AvroSource) is listening for events.
Selector : Selection mechanism. Must be either ROUND_ROBIN, RANDOM or custom FQDN to class that inherits from LoadBalancingSelector. If empty defaults to ROUND_ROBIN
The appender also takes the following optional parameters:MaxBackoff : A long value representing the maximum amount of time in milliseconds the Load balancing client will backoff from a node that has failed to consume an event
A sample log4j properties file which appends to a source would look like:log4j.appender.out2 = org.apache.flume.clients.log4jappender.LoadBalancingLog4jAppender log4j.appender.out2.Hosts = fooflumesource.com:25430 barflumesource.com:25430 log4j.appender.out2.Selector = RANDOM log4j.logger.org.apache.flume.clients.log4jappender = DEBUG,out2
log4j.appender.out2 = org.apache.flume.clients.log4jappender.LoadBalancingLog4jAppender log4j.appender.out2.Hosts = fooflumesource.com:25430 barflumesource.com:25430 log4j.appender.out2.Selector = ROUND_ROBIN log4j.appender.out2.MaxBackoff = 60000 log4j.logger.org.apache.flume.clients.log4jappender = DEBUG,out2
Note: Change the last line to the package of the class(es), that will do the appending.For example if classes from the package com.bar.foo are appending, the last line would be:
log4j.logger.com.bar.foo = DEBUG,out2
Constructor and Description |
---|
LoadBalancingLog4jAppender() |
Modifier and Type | Method and Description |
---|---|
void |
activateOptions()
Activate the options set using setHosts(), setSelector
and setMaxBackoff
|
void |
append(org.apache.log4j.spi.LoggingEvent event)
Append the LoggingEvent, to send to the first Flume hop.
|
void |
setHosts(String hostNames) |
void |
setMaxBackoff(String maxBackoff) |
void |
setSelector(String selector) |
close, getTimeout, getUnsafeMode, initializeClientAddress, populateAvroHeaders, requiresLayout, setAvroReflectionEnabled, setAvroSchemaUrl, setHostname, setPort, setTimeout, setUnsafeMode
public void setHosts(String hostNames)
public void setSelector(String selector)
public void setMaxBackoff(String maxBackoff)
public void append(org.apache.log4j.spi.LoggingEvent event)
Log4jAppender
append
in class Log4jAppender
event
- The LoggingEvent to be appended to the flume.public void activateOptions() throws FlumeException
activateOptions
in interface org.apache.log4j.spi.OptionHandler
activateOptions
in class Log4jAppender
FlumeException
- if the LoadBalancingRpcClient cannot be instantiated.Copyright © 2009–2019 Apache Software Foundation. All rights reserved.