chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asrab...@apache.org
Subject svn commit: r889833 - in /hadoop/chukwa/trunk: CHANGES.txt src/java/org/apache/hadoop/chukwa/datacollection/agent/AgentControlSocketListener.java
Date Fri, 11 Dec 2009 22:03:54 GMT
Author: asrabkin
Date: Fri Dec 11 22:03:53 2009
New Revision: 889833

URL: http://svn.apache.org/viewvc?rev=889833&view=rev
Log:
CHUKWA-46. Ability to allow local-only control connections

Modified:
    hadoop/chukwa/trunk/CHANGES.txt
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/AgentControlSocketListener.java

Modified: hadoop/chukwa/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/CHANGES.txt?rev=889833&r1=889832&r2=889833&view=diff
==============================================================================
--- hadoop/chukwa/trunk/CHANGES.txt (original)
+++ hadoop/chukwa/trunk/CHANGES.txt Fri Dec 11 22:03:53 2009
@@ -4,6 +4,8 @@
 
   NEW FEATURES
 
+    CHUKWA-46. Ability to allow only local connections to agent control port. (asrabkin)
+
     CHUKWA-427. Automate FSM state calculation and load to database. (Eric Yang)
 
     CHUKWA-424. FSMBuilder driver script. (Jiaqi Tan via asrabkin)

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/AgentControlSocketListener.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/AgentControlSocketListener.java?rev=889833&r1=889832&r2=889833&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/AgentControlSocketListener.java
(original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/AgentControlSocketListener.java
Fri Dec 11 22:03:53 2009
@@ -25,11 +25,7 @@
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.PrintStream;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketException;
-import java.net.UnknownHostException;
+import java.net.*;
 import java.util.Map;
 import org.apache.hadoop.chukwa.datacollection.adaptor.Adaptor;
 import org.apache.hadoop.chukwa.datacollection.adaptor.AdaptorException;
@@ -53,6 +49,8 @@
   protected ServerSocket s = null;
   volatile boolean closing = false;
   static final String VERSION = "0.2.0-dev";
+  public boolean ALLOW_REMOTE = true;
+  public static final String REMOTE_ACCESS_OPT = "chukwaAgent.control.remote";
 
   private class ListenThread extends Thread {
     Socket connection;
@@ -207,6 +205,7 @@
     this.agent = agent;
     this.portno = agent.getConfiguration().getInt("chukwaAgent.control.port",
         9093);
+    this.ALLOW_REMOTE = agent.getConfiguration().getBoolean(REMOTE_ACCESS_OPT, ALLOW_REMOTE);
     log.info("AgentControlSocketListerner ask for port: " + portno);
     this.setName("control socket listener");
   }
@@ -262,7 +261,12 @@
   }
 
   public void tryToBind() throws IOException {
-    s = new ServerSocket(portno);
+    if(ALLOW_REMOTE)
+      s = new ServerSocket(portno);
+    else {
+      s = new ServerSocket();
+      s.bind(new InetSocketAddress(InetAddress.getByAddress(new byte[] {127,0,0,1}), portno));
+    }
     s.setReuseAddress(true);
     portno = s.getLocalPort();
     if (s.isBound())



Mime
View raw message