incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r1380997 - in /incubator/ambari/branches/AMBARI-666: ./ ambari-project/ ambari-project/src/ ambari-project/src/main/ ambari-project/src/main/assemblies/ ambari-server/ ambari-server/src/main/assemblies/ ambari-server/src/main/java/org/apach...
Date Wed, 05 Sep 2012 05:26:13 GMT
Author: mahadev
Date: Wed Sep  5 05:26:12 2012
New Revision: 1380997

URL: http://svn.apache.org/viewvc?rev=1380997&view=rev
Log:
AMBARI-698. Add a simple server and artifact generation to run a server with a simple api
check. (mahadev)

Added:
    incubator/ambari/branches/AMBARI-666/ambari-project/src/
    incubator/ambari/branches/AMBARI-666/ambari-project/src/main/
    incubator/ambari/branches/AMBARI-666/ambari-project/src/main/assemblies/
    incubator/ambari/branches/AMBARI-666/ambari-project/src/main/assemblies/empty.xml
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/assemblies/
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/assemblies/server.xml
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/rest/
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/rest/resources/
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/rest/resources/HealthCheck.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
Modified:
    incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
    incubator/ambari/branches/AMBARI-666/ambari-project/pom.xml
    incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml
    incubator/ambari/branches/AMBARI-666/pom.xml

Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1380997&r1=1380996&r2=1380997&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Wed Sep  5 05:26:12 2012
@@ -12,6 +12,9 @@ AMBARI-666 branch (unreleased changes)
 
   NEW FEATURES
 
+  AMBARI-698. Add a simple server and artifact generation to run a server with
+  a simple api check. (mahadev)
+
   AMBARI-697. Ambari Web (browser-based UI) skeleton. (Jaimin Jetly and yusaku)
 
   AMBARI-695. More basic class restructuring for new design. (hitesh)

Modified: incubator/ambari/branches/AMBARI-666/ambari-project/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-project/pom.xml?rev=1380997&r1=1380996&r2=1380997&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-project/pom.xml (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-project/pom.xml Wed Sep  5 05:26:12 2012
@@ -12,10 +12,7 @@
   See the License for the specific language governing permissions and
   limitations under the License. See accompanying LICENSE file.
 -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
-                      http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0                       http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>org.apache.ambari</groupId>
@@ -28,7 +25,6 @@
   <description>Apache Ambari Project POM</description>
   <name>Apache Ambari Project POM</name>
   <packaging>pom</packaging>
-
   <pluginRepositories>
     <pluginRepository>
       <id>maven2-repository.dev.java.net</id>
@@ -42,7 +38,44 @@
       <url>http://download.java.net/maven/glassfish/</url>
     </pluginRepository>
   </pluginRepositories>
-
+  <profiles>
+    <profile>
+      <id>dist</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-javadoc-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>module-javadocs</id>
+                <phase>package</phase>
+                <goals>
+                  <goal>jar</goal>
+                </goals>
+                <configuration>
+                  <destDir>${project.build.directory}</destDir>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-source-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>ambari-java-sources</id>
+                <phase>package</phase>
+                <goals>
+                  <goal>jar-no-fork</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+       </plugins>
+      </build>
+    </profile>
+  </profiles>
   <dependencyManagement>
     <dependencies>
       <dependency>
@@ -120,7 +153,7 @@
         <artifactId>jersey-test-framework-external</artifactId>
         <version>1.8</version>
       </dependency>
-          <dependency>
+      <dependency>
         <groupId>log4j</groupId>
         <artifactId>log4j</artifactId>
         <version>1.2.15</version>

Added: incubator/ambari/branches/AMBARI-666/ambari-project/src/main/assemblies/empty.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-project/src/main/assemblies/empty.xml?rev=1380997&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-project/src/main/assemblies/empty.xml (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-project/src/main/assemblies/empty.xml Wed
Sep  5 05:26:12 2012
@@ -0,0 +1,21 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+       http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<assembly>
+    <id>empty</id>
+    <formats/>
+</assembly>

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml?rev=1380997&r1=1380996&r2=1380997&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/pom.xml Wed Sep  5 05:26:12 2012
@@ -1,16 +1,15 @@
 <?xml version="1.0"?>
-<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
-  license agreements. See the NOTICE file distributed with this work for additional
-  information regarding copyright ownership. The ASF licenses this file to
-  You under the Apache License, Version 2.0 (the "License"); you may not use
-  this file except in compliance with the License. You may obtain a copy of
-  the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
-  by applicable law or agreed to in writing, software distributed under the
-  License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
-  OF ANY KIND, either express or implied. See the License for the specific
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor 
+  license agreements. See the NOTICE file distributed with this work for additional 
+  information regarding copyright ownership. The ASF licenses this file to 
+  You under the Apache License, Version 2.0 (the "License"); you may not use 
+  this file except in compliance with the License. You may obtain a copy of 
+  the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
+  by applicable law or agreed to in writing, software distributed under the 
+  License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
+  OF ANY KIND, either express or implied. See the License for the specific 
   language governing permissions and limitations under the License. -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <parent>
     <groupId>org.apache.ambari</groupId>
     <artifactId>ambari-project</artifactId>
@@ -25,15 +24,62 @@
   <version>0.10.0-SNAPSHOT</version>
   <description>Ambari Server</description>
   <build>
-    <resources>
-      <resource>
-        <directory>src/main/resources</directory>
-      </resource>
-    </resources>
     <plugins>
       <plugin>
         <artifactId>maven-assembly-plugin</artifactId>
+        <configuration>
+          <descriptors>
+            <descriptor>src/main/assemblies/server.xml</descriptor>
+          </descriptors>
+        </configuration>
+        <executions>
+          <execution>
+            <id>build-tarball</id>
+            <phase>package</phase>
+            <goals>
+              <goal>single</goal>
+            </goals>
+          </execution>
+        </executions>
       </plugin>
+      <!--
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>1.6</version>
+        <configuration>
+          <createDependencyReducedPom>true
+            </createDependencyReducedPom>
+          <filters>
+            <filter>
+              <artifact>*:*</artifact>
+              <excludes>
+                <exclude>META-INF/*.SF</exclude>
+                <exclude>META-INF/*.DSA</exclude>
+                <exclude>META-INF/*.RSA</exclude>
+              </excludes>
+            </filter>
+          </filters>
+        </configuration>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <transformers>
+                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+                  <mainClass>org.apache.ambari.server.controller.AmbariController
+                    </mainClass>
+                </transformer>
+              </transformers>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      -->
     </plugins>
   </build>
   <profiles>

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/assemblies/server.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/assemblies/server.xml?rev=1380997&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/assemblies/server.xml (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/assemblies/server.xml Wed
Sep  5 05:26:12 2012
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+       http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<assembly>
+  <id>dist</id>
+  <formats>
+    <format>dir</format>
+    <format>tar.gz</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <files>
+    <file>
+      <source>${project.build.directory}/${artifact.artifactId}-${artifact.version}.jar</source>
+      <outputDirectory>ambari-server-${project.version}/lib</outputDirectory>
+    </file>
+  </files>
+  <fileSets>
+    <!-- Distro files, readme, licenses, etc -->
+    <fileSet>
+      <directory>${basedir}/../</directory>
+      <outputDirectory>ambari-server-${project.version}/</outputDirectory>
+      <includes>
+        <include>*.txt</include>
+      </includes>
+    </fileSet>
+    <!--
+    <fileSet>
+      <directory>${basedir}/src/main/bin</directory>
+      <outputDirectory>ambari-server-${project.version}/bin</outputDirectory>
+      <includes>
+        <include>*</include>
+      </includes>
+      <fileMode>0755</fileMode>
+    </fileSet>
+    -->
+  </fileSets>
+  <dependencySets>
+    <dependencySet>
+      <outputDirectory>ambari-server-${project.version}/lib</outputDirectory>
+      <unpack>false</unpack>
+      <scope>compile</scope>
+    </dependencySet>
+  </dependencySets>
+</assembly>

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/rest/resources/HealthCheck.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/rest/resources/HealthCheck.java?rev=1380997&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/rest/resources/HealthCheck.java
(added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/controller/rest/resources/HealthCheck.java
Wed Sep  5 05:26:12 2012
@@ -0,0 +1,38 @@
+package org.apache.ambari.controller.rest.resources;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+/**
+ * A simple POJO to do a health check on the server to see if its running
+ * or not
+ */
+
+@Path("/check")
+public class HealthCheck {
+  private static final String status = "RUNNING";
+  // This method is called if TEXT_PLAIN is request
+  @GET
+  @Produces(MediaType.TEXT_PLAIN)
+  public String plainTextCheck() {
+    return status;
+  }
+
+  // This method is called if XML is request
+  @GET
+  @Produces(MediaType.TEXT_XML)
+  public String xmlCheck() {
+    return "<?xml version=\"1.0\"?>" + "<status> " + status + "</status>";
+  }
+
+  // This method is called if HTML is request
+  @GET
+  @Produces(MediaType.TEXT_HTML)
+  public String  htmlCheck() {
+    return "<html> " + "<title>" + "Status" + "</title>"
+        + "<body><h1>" + status + "</body></h1>" + "</html>
";
+  }
+} 
+

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java?rev=1380997&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
(added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
Wed Sep  5 05:26:12 2012
@@ -0,0 +1,94 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.ambari.server.controller;
+
+
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.DefaultServlet;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Singleton;
+import com.sun.jersey.spi.container.servlet.ServletContainer;
+
+@Singleton
+public class AmbariServer {
+ private static Log LOG = LogFactory.getLog(AmbariServer.class);
+ public static int CONTROLLER_PORT = 4080;
+ private Server server = null;
+ public volatile boolean running = true; // true while controller runs
+ 
+ public void run() {
+   server = new Server(CONTROLLER_PORT);
+
+   try {
+     Context root = new Context(server, "/", Context.SESSIONS);
+     ServletHolder rootServlet = root.addServlet(DefaultServlet.class, "/");
+     rootServlet.setInitOrder(1);
+     
+     ServletHolder sh = new ServletHolder(ServletContainer.class);
+     sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass", 
+       "com.sun.jersey.api.core.PackagesResourceConfig");
+     sh.setInitParameter("com.sun.jersey.config.property.packages", 
+       "org.apache.ambari.controller.rest.resources");
+     root.addServlet(sh, "/api/*");
+     sh.setInitOrder(2);
+
+     server.setStopAtShutdown(true);
+     
+     /*
+      * Start the server after controller state is recovered.
+      */
+     server.start();
+     LOG.info("Started Server");
+     server.join();
+     LOG.info("Joined the Server");
+   } catch (Exception e) {
+     LOG.error("Error in the server", e);
+     
+   }
+ }
+ 
+ public void stop() throws Exception {
+   try {
+     server.stop();
+   } catch (Exception e) {
+     LOG.error("Error stopping the server", e);
+   }
+ }
+
+ public static void main(String[] args) throws IOException {
+   Injector injector = Guice.createInjector(new ControllerModule());
+   try {
+     LOG.info("Getting the controller");
+     AmbariServer server = injector.getInstance(AmbariServer.class);
+     if (server != null) {
+       server.run();
+     }
+   } catch(Throwable t) {
+     LOG.error("Failed to run the Ambari Server", t);
+   }
+ }
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java?rev=1380997&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
(added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
Wed Sep  5 05:26:12 2012
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.controller;
+import com.google.inject.AbstractModule;
+
+/**
+ * Used for injection purposes.
+ *
+ */
+public class ControllerModule extends AbstractModule {
+
+  @Override
+  protected void configure() {
+  }
+}

Modified: incubator/ambari/branches/AMBARI-666/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/pom.xml?rev=1380997&r1=1380996&r2=1380997&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/pom.xml (original)
+++ incubator/ambari/branches/AMBARI-666/pom.xml Wed Sep  5 05:26:12 2012
@@ -23,7 +23,6 @@
   <name>ambari</name>
   <version>0.10.0-SNAPSHOT</version>
   <description>Ambari</description>
-  
   <pluginRepositories>
     <pluginRepository>
       <id>maven2-repository.dev.java.net</id>
@@ -37,11 +36,21 @@
       <url>http://download.java.net/maven/glassfish/</url>
     </pluginRepository>
   </pluginRepositories>
-
   <modules>
     <module>ambari-project</module>
     <module>ambari-server</module>
     <module>ambari-agent</module>
   </modules>
-
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <configuration>
+          <descriptors>
+            <descriptor>ambari-project/src/main/assemblies/empty.xml</descriptor>
+          </descriptors>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 </project>



Mime
View raw message