incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1220925 - in /incubator/lcf/trunk: ./ framework/ framework/example-multiprocess/ framework/multiprocess-jetty-runner/ framework/multiprocess-jetty-runner/src/ framework/multiprocess-jetty-runner/src/main/ framework/multiprocess-jetty-runne...
Date Mon, 19 Dec 2011 20:05:05 GMT
Author: kwright
Date: Mon Dec 19 20:05:04 2011
New Revision: 1220925

URL: http://svn.apache.org/viewvc?rev=1220925&view=rev
Log:
Fix for CONNECTORS-332.  Provide scripts and jars for running the MCF web applications in
multiprocess mode on top of Jetty.

Added:
    incubator/lcf/trunk/framework/example-multiprocess/setclasspath.bat   (with props)
    incubator/lcf/trunk/framework/example-multiprocess/start-webapps.bat   (with props)
    incubator/lcf/trunk/framework/example-multiprocess/start-webapps.sh   (with props)
    incubator/lcf/trunk/framework/multiprocess-jetty-runner/
    incubator/lcf/trunk/framework/multiprocess-jetty-runner/src/
    incubator/lcf/trunk/framework/multiprocess-jetty-runner/src/main/
    incubator/lcf/trunk/framework/multiprocess-jetty-runner/src/main/java/
    incubator/lcf/trunk/framework/multiprocess-jetty-runner/src/main/java/org/
    incubator/lcf/trunk/framework/multiprocess-jetty-runner/src/main/java/org/apache/
    incubator/lcf/trunk/framework/multiprocess-jetty-runner/src/main/java/org/apache/manifoldcf/
    incubator/lcf/trunk/framework/multiprocess-jetty-runner/src/main/java/org/apache/manifoldcf/multiprocessjettyrunner/
    incubator/lcf/trunk/framework/multiprocess-jetty-runner/src/main/java/org/apache/manifoldcf/multiprocessjettyrunner/MCFMultiprocessJettyRunner.java
  (with props)
Modified:
    incubator/lcf/trunk/CHANGES.txt
    incubator/lcf/trunk/framework/build.xml
    incubator/lcf/trunk/site/src/documentation/content/xdocs/how-to-build-and-deploy.xml

Modified: incubator/lcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/CHANGES.txt?rev=1220925&r1=1220924&r2=1220925&view=diff
==============================================================================
--- incubator/lcf/trunk/CHANGES.txt (original)
+++ incubator/lcf/trunk/CHANGES.txt Mon Dec 19 20:05:04 2011
@@ -3,6 +3,10 @@ $Id$
 
 ======================= 0.5-dev =====================
 
+CONNECTORS-332: Provide a way of running the web applications on jetty
+from within the multiprocess example.
+(Karl Wright)
+
 CONNECTORS-324: Maven build broken
 (Piergiorgio Lucidi)
 

Modified: incubator/lcf/trunk/framework/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/build.xml?rev=1220925&r1=1220924&r2=1220925&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/build.xml (original)
+++ incubator/lcf/trunk/framework/build.xml Mon Dec 19 20:05:04 2011
@@ -40,6 +40,7 @@
             <fileset dir="ui-core/src/main/java" includes="**/*.java"/>
             <fileset dir="script-engine/src/main/java" includes="**/*.java"/>
             <fileset dir="jetty-runner/src/main/java" includes="**/*.java"/>
+            <fileset dir="multiprocess-jetty-runner/src/main/java" includes="**/*.java"/>
         </javadoc>
     </target>
     
@@ -105,6 +106,17 @@
         </javac>
     </target>
 
+    <target name="compile-multiprocess-jetty-runner" depends="compile-core,compile-agents">
+        <mkdir dir="build/multiprocess-jetty-runner/classes"/>
+        <javac srcdir="multiprocess-jetty-runner/src/main/java" destdir="build/multiprocess-jetty-runner/classes"
target="1.5" source="1.5" debug="true" debuglevel="lines,vars,source">
+            <classpath>
+                 <fileset dir="lib"> 
+                    <include name="jetty*.jar"/> 
+                </fileset>
+            </classpath>
+        </javac>
+    </target>
+
     <target name="compile-script-engine" depends="compile-core">
         <mkdir dir="build/script-engine/classes"/>
         <javac srcdir="script-engine/src/main/java" destdir="build/script-engine/classes"
target="1.5" source="1.5" debug="true" debuglevel="lines,vars,source">
@@ -208,6 +220,11 @@
         <jar destfile="build/jar/mcf-jetty-runner.jar" basedir="build/jetty-runner/classes"/>
     </target>
 
+    <target name="jar-multiprocess-jetty-runner" depends="compile-multiprocess-jetty-runner">
+        <mkdir dir="build/jar"/>
+        <jar destfile="build/jar/mcf-multiprocess-jetty-runner.jar" basedir="build/multiprocess-jetty-runner/classes"/>
+    </target>
+
     <target name="jar-script-engine" depends="compile-script-engine">
         <mkdir dir="build/jar"/>
         <jar destfile="build/jar/mcf-script-engine.jar" basedir="build/script-engine/classes"/>
@@ -400,7 +417,8 @@
         </copy>
     </target>
 
-    <target name="multi-process-example" depends="multi-wars,multi-processes">
+    <target name="multi-process-example" depends="jar-multiprocess-jetty-runner,multi-wars,multi-processes">
+        <mkdir dir="dist/multiprocess-example"/>
         <copy todir="dist/multiprocess-example">
             <fileset dir="example-multiprocess">
                 <include name="properties.xml"/>
@@ -409,6 +427,16 @@
                 <include name="*.bat"/>
             </fileset>
         </copy>
+        <mkdir dir="dist/multiprocess-example/lib"/>
+        <copy todir="dist/multiprocess-example/lib">
+            <fileset dir="build/jar">
+                <include name="mcf-multiprocess-jetty-runner.jar"/>
+            </fileset>
+            <fileset dir="lib">
+                <include name="jetty*.jar"/>
+                <include name="servlet-api*.jar"/>
+            </fileset>
+        </copy>
         <mkdir dir="dist/multiprocess-example/logs"/>
     </target>
     

Added: incubator/lcf/trunk/framework/example-multiprocess/setclasspath.bat
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/example-multiprocess/setclasspath.bat?rev=1220925&view=auto
==============================================================================
--- incubator/lcf/trunk/framework/example-multiprocess/setclasspath.bat (added)
+++ incubator/lcf/trunk/framework/example-multiprocess/setclasspath.bat Mon Dec 19 20:05:04
2011
@@ -0,0 +1,16 @@
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements.  See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License.  You may obtain a copy of the License at
+rem
+rem     http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+
+set CLASSPATH=%CLASSPATH%;.\lib\%1

Propchange: incubator/lcf/trunk/framework/example-multiprocess/setclasspath.bat
------------------------------------------------------------------------------
    svn:eol-style = CRLF

Propchange: incubator/lcf/trunk/framework/example-multiprocess/setclasspath.bat
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lcf/trunk/framework/example-multiprocess/start-webapps.bat
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/example-multiprocess/start-webapps.bat?rev=1220925&view=auto
==============================================================================
--- incubator/lcf/trunk/framework/example-multiprocess/start-webapps.bat (added)
+++ incubator/lcf/trunk/framework/example-multiprocess/start-webapps.bat Mon Dec 19 20:05:04
2011
@@ -0,0 +1,28 @@
+@echo off
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements.  See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License.  You may obtain a copy of the License at
+rem
+rem     http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+
+rem check that JAVA_HOME is set, and that the current directory is correct
+if not exist "%JAVA_HOME%\bin\java.exe" goto nojavahome
+
+set CLASSPATH=.
+for %%f in (lib/*) do call setclasspath.bat %%f
+rem invoke java with the jetty class
+"%JAVA_HOME%\bin\java" -cp "%CLASSPATH%" org.apache.manifoldcf.multiprocessjettyrunner.MCFMultiprocessJettyRunner
+goto done
+:nojavahome
+echo Environment variable JAVA_HOME is not set properly.
+goto done
+:done

Propchange: incubator/lcf/trunk/framework/example-multiprocess/start-webapps.bat
------------------------------------------------------------------------------
    svn:eol-style = CRLF

Propchange: incubator/lcf/trunk/framework/example-multiprocess/start-webapps.bat
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lcf/trunk/framework/example-multiprocess/start-webapps.sh
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/example-multiprocess/start-webapps.sh?rev=1220925&view=auto
==============================================================================
--- incubator/lcf/trunk/framework/example-multiprocess/start-webapps.sh (added)
+++ incubator/lcf/trunk/framework/example-multiprocess/start-webapps.sh Mon Dec 19 20:05:04
2011
@@ -0,0 +1,42 @@
+#!/bin/bash -e
+
+# 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.
+
+if [[ $OSTYPE == "cygwin" ]] ; then
+    PATHSEP=";"
+else
+    PATHSEP=":"
+fi
+
+#Make sure environment variables are properly set
+if [ -e "$JAVA_HOME"/bin/java ] ; then
+
+    CLASSPATH=""
+    for filename in $(ls -1 ./lib) ; do
+        if [ -n "$CLASSPATH" ] ; then
+            CLASSPATH="$CLASSPATH""$PATHSEP"./lib/"$filename"
+        else
+            CLASSPATH=./lib/"$filename"
+        fi
+    done
+
+    "%JAVA_HOME%"/bin/java -cp "$CLASSPATH" org.apache.manifoldcf.multiprocessjettyrunner.MCFMultiprocessJettyRunner
+    exit $?
+        
+else
+    echo "Environment variable JAVA_HOME is not properly set." 1>&2
+    exit 1
+fi

Propchange: incubator/lcf/trunk/framework/example-multiprocess/start-webapps.sh
------------------------------------------------------------------------------
    svn:eol-style = LF

Propchange: incubator/lcf/trunk/framework/example-multiprocess/start-webapps.sh
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lcf/trunk/framework/multiprocess-jetty-runner/src/main/java/org/apache/manifoldcf/multiprocessjettyrunner/MCFMultiprocessJettyRunner.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/multiprocess-jetty-runner/src/main/java/org/apache/manifoldcf/multiprocessjettyrunner/MCFMultiprocessJettyRunner.java?rev=1220925&view=auto
==============================================================================
--- incubator/lcf/trunk/framework/multiprocess-jetty-runner/src/main/java/org/apache/manifoldcf/multiprocessjettyrunner/MCFMultiprocessJettyRunner.java
(added)
+++ incubator/lcf/trunk/framework/multiprocess-jetty-runner/src/main/java/org/apache/manifoldcf/multiprocessjettyrunner/MCFMultiprocessJettyRunner.java
Mon Dec 19 20:05:04 2011
@@ -0,0 +1,154 @@
+/**
+ * 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.manifoldcf.multiprocessjettyrunner;
+
+import java.io.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.webapp.WebAppContext;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.FilterHolder;
+import org.mortbay.log.Logger;
+
+/**
+ * Run ManifoldCF with jetty.
+ * 
+ */
+public class MCFMultiprocessJettyRunner
+{
+
+  public static final String _rcsid = "@(#)$Id$";
+
+  protected Server server;
+  
+  public MCFMultiprocessJettyRunner( int port, String crawlerWarPath, String authorityServiceWarPath,
String apiWarPath )
+  {
+    server = new Server( port );    
+    server.setStopAtShutdown( true );
+    
+    // Initialize the servlets
+    WebAppContext lcfCrawlerUI = new WebAppContext(crawlerWarPath,"/mcf-crawler-ui");
+    // This will cause jetty to ignore all of the framework and jdbc jars in the war, which
is what we want.
+    lcfCrawlerUI.setParentLoaderPriority(false);
+    server.addHandler(lcfCrawlerUI);
+    WebAppContext lcfAuthorityService = new WebAppContext(authorityServiceWarPath,"/mcf-authority-service");
+    // This will cause jetty to ignore all of the framework and jdbc jars in the war, which
is what we want.
+    lcfAuthorityService.setParentLoaderPriority(false);
+    server.addHandler(lcfAuthorityService);
+    WebAppContext lcfApi = new WebAppContext(apiWarPath,"/mcf-api-service");
+    lcfApi.setParentLoaderPriority(false);
+    server.addHandler(lcfApi);
+  }
+
+  public void start()
+    throws Exception
+  {
+    if(!server.isRunning() )
+    {
+      server.start();
+    }
+  }
+
+  public void stop()
+    throws Exception
+  {
+    if( server.isRunning() )
+    {
+      server.stop();
+      server.join();
+    }
+  }
+
+  /**
+   * A main class that starts jetty with mcf wars
+   */
+  public static void main( String[] args )
+  {
+    if (args.length != 4 && args.length != 1 && args.length != 0)
+    {
+      System.err.println("Usage: MCFMultiprocessJettyRunner [<port> [<crawler-war-path>
<authority-service-war-path> <api-war-path>]]");
+      System.exit(1);
+    }
+
+    int jettyPort = 8345;
+    if (args.length > 0)
+    {
+      try
+      {
+        jettyPort = Integer.parseInt(args[0]);
+      }
+      catch (NumberFormatException e)
+      {
+        e.printStackTrace(System.err);
+        System.exit(1);
+      }
+    }
+    
+    String crawlerWarPath = "web/war/mcf-crawler-ui.war";
+    String authorityserviceWarPath = "web/war/mcf-authority-service.war";
+    String apiWarPath = "web/war/mcf-api-service.war";
+    if (args.length == 4)
+    {
+      crawlerWarPath = args[1];
+      authorityserviceWarPath = args[2];
+      apiWarPath = args[3];
+    }
+    
+    // Ready to begin in earnest...  Set the system-wide properties to point to the current
properties file.
+    if (System.getProperty("org.apache.manifoldcf.configfile") == null)
+    	System.setProperty("org.apache.manifoldcf.configfile","./properties.xml");
+    try
+    {
+      System.err.println("Starting jetty...");
+      
+      // Create a jetty instance
+      MCFMultiprocessJettyRunner jetty = new MCFMultiprocessJettyRunner(jettyPort,crawlerWarPath,authorityserviceWarPath,apiWarPath);
+      // This will register a shutdown hook as well.
+      jetty.start();
+
+      System.err.println("Jetty started.");
+      
+      // Go to sleep until interrupted.
+      while (true)
+      {
+        try
+        {
+          Thread.sleep(5000);
+          continue;
+        }
+        catch (InterruptedException e)
+        {
+          break;
+        }
+      }
+    }
+    catch (Exception e)
+    {
+      e.printStackTrace(System.err);
+      System.exit(1);
+    }
+  }
+  
+}
+
+

Propchange: incubator/lcf/trunk/framework/multiprocess-jetty-runner/src/main/java/org/apache/manifoldcf/multiprocessjettyrunner/MCFMultiprocessJettyRunner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/trunk/framework/multiprocess-jetty-runner/src/main/java/org/apache/manifoldcf/multiprocessjettyrunner/MCFMultiprocessJettyRunner.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/lcf/trunk/site/src/documentation/content/xdocs/how-to-build-and-deploy.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/site/src/documentation/content/xdocs/how-to-build-and-deploy.xml?rev=1220925&r1=1220924&r2=1220925&view=diff
==============================================================================
--- incubator/lcf/trunk/site/src/documentation/content/xdocs/how-to-build-and-deploy.xml (original)
+++ incubator/lcf/trunk/site/src/documentation/content/xdocs/how-to-build-and-deploy.xml Mon
Dec 19 20:05:04 2011
@@ -115,6 +115,7 @@
           <tr><td><em>logs</em></td><td>where the ManifoldCF
logs get written to</td></tr>
           <tr><td><em>start-database[.sh|.bat]</em></td><td>script
to start the HSQLDB database</td></tr>
           <tr><td><em>initialize[.sh|.bat]</em></td><td>script
to create the database instance, create all database tables, and register connectors</td></tr>
+          <tr><td><em>start-webapps[.sh|.bat]</em></td><td>script
to start Jetty with the ManifoldCF web applications deployed</td></tr>
           <tr><td><em>start-agents[.sh|.bat]</em></td><td>script
to start the agents process</td></tr>
           <tr><td><em>stop-agents[.sh|.bat]</em></td><td>script
to stop a running agents process cleanly</td></tr>
           <tr><td><em>lock-clean[.sh|.bat]</em></td><td>script
to clean up dirty locks (run only when all webapps and processes are stopped)</td></tr>



Mime
View raw message