Bladeren bron

HADOOP-4925. Make Chukwa sender properties configurable. Contributed by Ari Rabkin.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.20@732649 13f79535-47bb-0310-9956-ffa450edef68
Christopher Douglas 16 jaren geleden
bovenliggende
commit
9346ca1464

+ 3 - 0
CHANGES.txt

@@ -523,6 +523,9 @@ Release 0.20.0 - Unreleased
     HADOOP-4916. Make user/location of Chukwa installation configurable by an
     external properties file. (Eric Yang via cdouglas)
 
+    HADOOP-4925. Make Chukwa sender properties configurable. (Ari Rabkin via
+    cdouglas)
+
 Release 0.19.1 - Unreleased
 
   IMPROVEMENTS

+ 18 - 0
src/contrib/chukwa/conf/chukwa-agent-conf.xml.template

@@ -41,4 +41,22 @@
     <value>5000</value>
     <description>the frequency interval for the agent to do checkpoints, in milliseconds</description>
   </property>
+
+  <property>
+    <name>chukwaAgent.sender.fastRetries</name>
+    <value>4</value>
+    <description>the number of post attempts to make to a single collector, before marking it failed</description>
+  </property>
+
+  <property>
+    <name>chukwaAgent.collector.retries</name>
+    <value>144000</value>
+    <description>the number of attempts to find a working collector</description>
+  </property>
+
+  <property>
+    <name>chukwaAgent.collector.retryInterval</name>
+    <value>20000</value>
+    <description>the number of milliseconds to wait between searches for a collector</description>
+  </property>
 </configuration>

+ 1 - 1
src/contrib/chukwa/src/java/org/apache/hadoop/chukwa/datacollection/connector/http/HttpConnector.java

@@ -112,7 +112,7 @@ public class HttpConnector implements Connector, Runnable  {
 					"conf/collectors file", e);
 		}
 
-		connectorClient = new ChukwaHttpSender();
+		connectorClient = new ChukwaHttpSender(agent.getConfiguration());
 
 		if (argDestination != null) 
 		{

+ 8 - 4
src/contrib/chukwa/src/java/org/apache/hadoop/chukwa/datacollection/sender/ChukwaHttpSender.java

@@ -40,6 +40,7 @@ import org.apache.commons.httpclient.methods.RequestEntity;
 import org.apache.commons.httpclient.params.HttpMethodParams;
 import org.apache.hadoop.chukwa.Chunk;
 import org.apache.hadoop.chukwa.datacollection.adaptor.Adaptor;
+import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.io.DataOutputBuffer;
 import org.apache.log4j.Logger;
 
@@ -52,9 +53,9 @@ import org.apache.log4j.Logger;
  * <p> Will wait forever for collectors to come up. </p>
  */
 public class ChukwaHttpSender implements ChukwaSender{
-  static final int MAX_RETRIES_PER_COLLECTOR = 4; //fast retries, in http client
-  static final int SENDER_RETRIES = 14440; 
-  static final int WAIT_FOR_COLLECTOR_REBOOT = 20 * 1000; 
+  final int MAX_RETRIES_PER_COLLECTOR ; //fast retries, in http client
+  final int SENDER_RETRIES; 
+  final int WAIT_FOR_COLLECTOR_REBOOT; 
     //FIXME: this should really correspond to the timer in RetryListOfCollectors
   
   static Logger log = Logger.getLogger(ChukwaHttpSender.class);
@@ -114,12 +115,15 @@ public class ChukwaHttpSender implements ChukwaSender{
     }
   }
 
-  public ChukwaHttpSender(){
+  public ChukwaHttpSender(Configuration c){
     //setup default collector
     ArrayList<String> tmp = new ArrayList<String>();
     this.collectors = tmp.iterator();
     log.info("added a single collector to collector list in ConnectorClient constructor, it's hasNext is now: " + collectors.hasNext());
 
+    MAX_RETRIES_PER_COLLECTOR = c.getInt("chukwaAgent.sender.fastRetries", 4);
+    SENDER_RETRIES= c.getInt("chukwaAgent.sender.retries", 144000);
+    WAIT_FOR_COLLECTOR_REBOOT= c.getInt("chukwaAgent.sender.retryInterval", 20*1000);
   }
   
   /**