소스 검색

AMBARI-788. Fix server and agent startup for end to end testing. (mahadev)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/AMBARI-666@1393236 13f79535-47bb-0310-9956-ffa450edef68
Mahadev Konar 12 년 전
부모
커밋
61678ba443

+ 2 - 0
AMBARI-666-CHANGES.txt

@@ -12,6 +12,8 @@ AMBARI-666 branch (unreleased changes)
 
   NEW FEATURES
 
+  AMBARI-788. Fix server and agent startup for end to end testing. (mahadev)
+
   AMBARI-785. Action response unit test. (jitendra)
 
   AMBARI-783. Fix guice injection in the server. (mahadev)

+ 5 - 3
ambari-agent/src/main/python/ambari_agent/AmbariConfig.py

@@ -25,8 +25,10 @@ import StringIO
 
 config = ConfigParser.RawConfigParser()
 content = """
+
 [server]
-url=http://localhost:4080
+url=https://localhost:4080
+secured_url=https://localhost:8443
 
 [agent]
 prefix=/tmp/ambari
@@ -43,9 +45,9 @@ maxretries=2
 sleepBetweenRetries=1
 
 [security]
-keysdir="/tmp/"
+keysdir=/tmp/ambari-agent
 server_crt=ca.crt
-passphrase_env_name=AMBARI_PASSPHRASE
+passphrase_env_var_name=AMBARI_PASSPHRASE
 """
 s = StringIO.StringIO(content)
 config.readfp(s)

+ 21 - 9
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java

@@ -54,7 +54,10 @@ public class AmbariServer {
   private static Log LOG = LogFactory.getLog(AmbariServer.class);
   public static int CLIENT_ONE_WAY = 4080;
   public static int CLIENT_TWO_WAY = 8443;
+  public static int CLIENT_API_PORT = 8080;
   private Server server = null;
+  private Server serverForAgent = null;
+  
   public volatile boolean running = true; // true while controller runs
 
   final String WEB_APP_DIR = "webapp";
@@ -72,8 +75,9 @@ public class AmbariServer {
   Injector injector;
 
   public void run() {
-    server = new Server();
-
+    server = new Server(CLIENT_API_PORT);
+    serverForAgent = new Server();
+  
     try {
       ClassPathXmlApplicationContext parentSpringAppContext = 
           new ClassPathXmlApplicationContext();
@@ -102,11 +106,17 @@ public class AmbariServer {
 
       certMan.initRootCert();
       Context root =
-//              new Context(webAppContext, "/", Context.SESSIONS);
               webAppContext;
+      
+      Context agentroot =
+                       new Context(serverForAgent, "/", Context.SESSIONS);
 
       ServletHolder rootServlet = root.addServlet(DefaultServlet.class, "/");
       rootServlet.setInitOrder(1);
+      
+      /* Configure default servlet for agent server */
+      rootServlet = agentroot.addServlet(DefaultServlet.class, "/");
+      rootServlet.setInitOrder(1);
 
       root.addFilter(SecurityFilter.class, "/*", 1);
       //Secured connector for 2-way auth
@@ -142,8 +152,8 @@ public class AmbariServer {
 
 
 
-      server.addConnector(sslConnectorOneWay);
-      server.addConnector(sslConnectorTwoWay);
+      serverForAgent.addConnector(sslConnectorOneWay);
+      serverForAgent.addConnector(sslConnectorTwoWay);
 
       ServletHolder sh = new ServletHolder(ServletContainer.class);
       sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
@@ -158,7 +168,7 @@ public class AmbariServer {
               "com.sun.jersey.api.core.PackagesResourceConfig");
       agent.setInitParameter("com.sun.jersey.config.property.packages",
               "org.apache.ambari.server.agent.rest");
-      root.addServlet(agent, "/agent/*");
+      agentroot.addServlet(agent, "/agent/*");
       agent.setInitOrder(3);
 
       ServletHolder cert = new ServletHolder(ServletContainer.class);
@@ -166,7 +176,7 @@ public class AmbariServer {
               "com.sun.jersey.api.core.PackagesResourceConfig");
       cert.setInitParameter("com.sun.jersey.config.property.packages",
               "org.apache.ambari.server.security.unsecured.rest");
-      root.addServlet(cert, "/cert/*");
+      agentroot.addServlet(cert, "/cert/*");
       cert.setInitOrder(4);
 
       ServletHolder certs = new ServletHolder(ServletContainer.class);
@@ -174,7 +184,7 @@ public class AmbariServer {
         "com.sun.jersey.api.core.PackagesResourceConfig");
       certs.setInitParameter("com.sun.jersey.config.property.packages",
         "org.apache.ambari.server.security.unsecured.rest");
-      root.addServlet(cert, "/certs/*");
+      agentroot.addServlet(cert, "/certs/*");
       certs.setInitOrder(5);
 
       ServletHolder resources = new ServletHolder(ServletContainer.class);
@@ -186,12 +196,14 @@ public class AmbariServer {
       resources.setInitOrder(6);
 
       server.setStopAtShutdown(true);
-
+      serverForAgent.setStopAtShutdown(true);
       springAppContext.start();
       /*
        * Start the server after controller state is recovered.
        */
       server.start();
+      serverForAgent.start();
+      
       LOG.info("Started Server");
       server.join();
       LOG.info("Joined the Server");

+ 0 - 2
ambari-server/src/main/java/org/apache/ambari/server/security/SignMessage.java

@@ -24,8 +24,6 @@ import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 
-
-
 /**
  *
  * Sign certificate request data model.

+ 2 - 1
ambari-server/src/main/java/org/apache/ambari/server/security/unsecured/rest/CertificateSign.java

@@ -58,7 +58,8 @@ public class CertificateSign {
   @POST
   @Consumes(MediaType.APPLICATION_JSON)
   @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
-  public SignCertResponse signAgentCrt(@PathParam("hostName") String hostname,SignMessage message, @Context HttpServletRequest req) {
+  public SignCertResponse signAgentCrt(@PathParam("hostName") String hostname,
+      SignMessage message, @Context HttpServletRequest req) {
 	  SignCertResponse response = new SignCertResponse();
 	  String signedCa;
 	  signedCa = certMan.signAgentCrt(hostname, message.getCsr(), message.getPassphrase());