Author: rgoers
Date: Sun Apr 28 06:06:04 2013
New Revision: 1476720
URL: http://svn.apache.org/r1476720
Log:
LOG4J2-224 - The FlumeAppender failed to start if the Flume RPCClient could not
connect to any Flume agents.
Modified:
logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAvroManager.java
logging/log4j/log4j2/trunk/src/changes/changes.xml
Modified:
logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAvroManager.java
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAvroManager.java?rev=1476720&r1=1476719&r2=1476720&view=diff
==============================================================================
---
logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAvroManager.java
(original)
+++
logging/log4j/log4j2/trunk/flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAvroManager.java
Sun Apr 28 06:06:04 2013
@@ -173,37 +173,42 @@ public class FlumeAvroManager extends Ab
*/
private RpcClient connect(final Agent[] agents, int retries, int
connectTimeout, int requestTimeout) {
- Properties props = new Properties();
+ try {
+ Properties props = new Properties();
- props.put("client.type", agents.length > 1 ? "default_failover" :
"default");
+ props.put("client.type", agents.length > 1 ? "default_failover" :
"default");
- int count = 1;
- StringBuilder sb = new StringBuilder();
- for (Agent agent : agents) {
- if (sb.length() > 0) {
- sb.append(" ");
- }
- String hostName = "host" + count++;
- props.put("hosts." + hostName, agent.getHost() + ":" +
agent.getPort());
- sb.append(hostName);
- }
- props.put("hosts", sb.toString());
- if (batchSize > 0) {
- props.put("batch-size", Integer.toString(batchSize));
- }
- if (retries > 1) {
- if (retries > MAX_RECONNECTS) {
- retries = MAX_RECONNECTS;
+ int count = 1;
+ StringBuilder sb = new StringBuilder();
+ for (Agent agent : agents) {
+ if (sb.length() > 0) {
+ sb.append(" ");
+ }
+ String hostName = "host" + count++;
+ props.put("hosts." + hostName, agent.getHost() + ":" +
agent.getPort());
+ sb.append(hostName);
}
- props.put("max-attempts", Integer.toString(retries *
agents.length));
- }
- if (requestTimeout >= 1000) {
- props.put("request-timeout", Integer.toString(requestTimeout));
- }
- if (connectTimeout >= 1000) {
- props.put("connect-timeout", Integer.toString(connectTimeout));
+ props.put("hosts", sb.toString());
+ if (batchSize > 0) {
+ props.put("batch-size", Integer.toString(batchSize));
+ }
+ if (retries > 1) {
+ if (retries > MAX_RECONNECTS) {
+ retries = MAX_RECONNECTS;
+ }
+ props.put("max-attempts", Integer.toString(retries *
agents.length));
+ }
+ if (requestTimeout >= 1000) {
+ props.put("request-timeout", Integer.toString(requestTimeout));
+ }
+ if (connectTimeout >= 1000) {
+ props.put("connect-timeout", Integer.toString(connectTimeout));
+ }
+ return RpcClientFactory.getInstance(props);
+ } catch (Exception ex) {
+ LOGGER.error("Unable to create Flume RPCClient: {}",
ex.getMessage());
+ return null;
}
- return RpcClientFactory.getInstance(props);
}
@Override
Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL:
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1476720&r1=1476719&r2=1476720&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Sun Apr 28 06:06:04 2013
@@ -23,6 +23,9 @@
<body>
<release version="2.0-beta6" date="@TBD@" description="Bug fixes and
enhancements">
+ <action issue="LOG4J2-224" dev="rgoers" type="fix">
+ The FlumeAppender failed to start if the Flume RPCClient could not
connect to any Flume agents.
+ </action>
<action issue="LOG4J2-223" dev="rgoers" type="fix">
Fix LoggerContext start and stop to eliminate IllegalStateException
and NoClassDefFound errors.
</action>