accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1424605 - in /accumulo/trunk/server/src/main/java/org/apache/accumulo/server: monitor/Monitor.java util/EmbeddedWebServer.java
Date Thu, 20 Dec 2012 17:45:18 GMT
Author: ecn
Date: Thu Dec 20 17:45:18 2012
New Revision: 1424605

URL: http://svn.apache.org/viewvc?rev=1424605&view=rev
Log:
ACCUMULO-746 bind to a given hostname; cleanup EmbeddedWebServer

Modified:
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/monitor/Monitor.java
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/util/EmbeddedWebServer.java

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/monitor/Monitor.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/monitor/Monitor.java?rev=1424605&r1=1424604&r2=1424605&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/monitor/Monitor.java (original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/monitor/Monitor.java Thu
Dec 20 17:45:18 2012
@@ -466,7 +466,7 @@ public class Monitor {
     int port = config.getConfiguration().getPort(Property.MONITOR_PORT);
     try {
       log.debug("Creating monitor on port " + port);
-      server = EmbeddedWebServer.create(port);
+      server = new EmbeddedWebServer(hostname, port);
     } catch (Throwable ex) {
       log.error("Unable to start embedded web server", ex);
       throw new RuntimeException(ex);

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/util/EmbeddedWebServer.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/util/EmbeddedWebServer.java?rev=1424605&r1=1424604&r2=1424605&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/util/EmbeddedWebServer.java
(original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/util/EmbeddedWebServer.java
Thu Dec 20 17:45:18 2012
@@ -29,91 +29,67 @@ import org.mortbay.jetty.servlet.Session
 
 public class EmbeddedWebServer {
   
-  public static EmbeddedWebServer create(int port) throws ClassNotFoundException {
-    return new EmbeddedWebServer6_1(port);
+  Server server = null;
+  SocketConnector sock;
+  ContextHandlerCollection handler;
+  Context root;
+  boolean usingSsl;
+  
+  public EmbeddedWebServer() {
+    this("0.0.0.0", 0);
   }
   
-  public static EmbeddedWebServer create() throws ClassNotFoundException {
-    return new EmbeddedWebServer6_1();
+  public EmbeddedWebServer(String host, int port) {
+    server = new Server();
+    handler = new ContextHandlerCollection();
+    root = new Context(handler, "/", new SessionHandler(), null, null, null);
+    
+    if (Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_KEYSTORE) == ""
+        || Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_KEYSTOREPASS) == ""
+        || Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_TRUSTSTORE) == ""
+        || Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_TRUSTSTOREPASS) == "")
{
+      sock = new SocketConnector();
+      usingSsl = false;
+    } else {
+      sock = new SslSocketConnector();
+      ((SslSocketConnector) sock).setKeystore(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_KEYSTORE));
+      ((SslSocketConnector) sock).setKeyPassword(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_KEYSTOREPASS));
+      ((SslSocketConnector) sock).setTruststore(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_TRUSTSTORE));
+      ((SslSocketConnector) sock).setTrustPassword(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_TRUSTSTOREPASS));
+      usingSsl = true;
+    }
+    sock.setHost(host);
+    sock.setPort(port);
   }
   
-  public void addServlet(Class<? extends HttpServlet> klass, String where) {}
+  public void addServlet(Class<? extends HttpServlet> klass, String where) {
+    root.addServlet(klass, where);
+  }
   
   public int getPort() {
-    return 0;
+    return sock.getLocalPort();
   }
   
-  public void start() {}
-  
-  public void stop() {}
-  
-  public boolean isUsingSsl() {
-    return false;
+  public void start() {
+    try {
+      server.addConnector(sock);
+      server.setHandler(handler);
+      server.start();
+    } catch (Exception e) {
+      stop();
+      throw new RuntimeException(e);
+    }
   }
   
-  static public class EmbeddedWebServer6_1 extends EmbeddedWebServer {
-    // 6.1
-    Server server = null;
-    SocketConnector sock;
-    ContextHandlerCollection handler;
-    Context root;
-    boolean usingSsl;
-    
-    public EmbeddedWebServer6_1() throws ClassNotFoundException {
-      this(0);
-    }
-    
-    public EmbeddedWebServer6_1(int port) {
-      server = new Server();
-      handler = new ContextHandlerCollection();
-      root = new Context(handler, "/", new SessionHandler(), null, null, null);
-      
-      if (Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_KEYSTORE) == ""
-          || Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_KEYSTOREPASS) == ""
-          || Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_TRUSTSTORE) == ""
-          || Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_TRUSTSTOREPASS) ==
"") {
-        sock = new SocketConnector();
-        usingSsl = false;
-      } else {
-        sock = new SslSocketConnector();
-        ((SslSocketConnector) sock).setKeystore(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_KEYSTORE));
-        ((SslSocketConnector) sock).setKeyPassword(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_KEYSTOREPASS));
-        ((SslSocketConnector) sock).setTruststore(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_TRUSTSTORE));
-        ((SslSocketConnector) sock).setTrustPassword(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_TRUSTSTOREPASS));
-        usingSsl = true;
-      }
-      sock.setPort(port);
-    }
-    
-    public void addServlet(Class<? extends HttpServlet> klass, String where) {
-      root.addServlet(klass, where);
-    }
-    
-    public int getPort() {
-      return sock.getLocalPort();
-    }
-    
-    public void start() {
-      try {
-        server.addConnector(sock);
-        server.setHandler(handler);
-        server.start();
-      } catch (Exception e) {
-        stop();
-        throw new RuntimeException(e);
-      }
-    }
-    
-    public void stop() {
-      try {
-        server.stop();
-      } catch (Exception e) {
-        throw new RuntimeException(e);
-      }
-    }
-    
-    public boolean isUsingSsl() {
-      return usingSsl;
+  public void stop() {
+    try {
+      server.stop();
+    } catch (Exception e) {
+      throw new RuntimeException(e);
     }
   }
+  
+  public boolean isUsingSsl() {
+    return usingSsl;
+  }
 }



Mime
View raw message