activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1027720 - in /activemq/activemq-apollo/trunk: apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/ apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/bin/ apollo-cli/src/main/resources/org/apache/active...
Date Tue, 26 Oct 2010 20:11:53 GMT
Author: chirino
Date: Tue Oct 26 20:11:52 2010
New Revision: 1027720

URL: http://svn.apache.org/viewvc?rev=1027720&view=rev
Log:
The broker distro is now purely a binary which you can then use 'apollo create' to create
an instance directory holding instance configuration and data.

Added:
    activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/
    activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/bin/
    activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/bin/apollo-broker
  (with props)
    activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/bin/apollo-broker.cmd
  (with props)
    activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/
    activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/apollo.xml
    activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/log4j.properties
      - copied, changed from r1027719, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/etc/log4j.properties
    activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Helper.scala
Removed:
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/etc/log4j.properties
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/log/apollo.log
Modified:
    activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/Apollo.scala
    activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala
    activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Run.scala
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo

Added: activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/bin/apollo-broker
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/bin/apollo-broker?rev=1027720&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/bin/apollo-broker
(added)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/bin/apollo-broker
Tue Oct 26 20:11:52 2010
@@ -0,0 +1,51 @@
+#!/bin/sh
+# ------------------------------------------------------------------------
+# 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 [ -z "$APOLLO_BASE" ] ; then
+
+  ## resolve links - $0 may be a link to apollo's home
+  PRG="$0"
+  progname=`basename "$0"`
+  saveddir=`pwd`
+
+  # need this for relative symlinks
+  dirname_prg=`dirname "$PRG"`
+  cd "$dirname_prg"
+
+  while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '.*/.*' > /dev/null; then
+    PRG="$link"
+    else
+    PRG=`dirname "$PRG"`"/$link"
+    fi
+  done
+
+  APOLLO_BASE=`dirname "$PRG"`
+  cd "$saveddir"
+
+  # make it fully qualified
+  APOLLO_BASE=`cd "$APOLLO_BASE/.." && pwd`
+  export APOLLO_BASE
+    
+fi
+
+
+exec apollo $@
+

Propchange: activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/bin/apollo-broker
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/bin/apollo-broker.cmd
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/bin/apollo-broker.cmd?rev=1027720&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/bin/apollo-broker.cmd
(added)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/bin/apollo-broker.cmd
Tue Oct 26 20:11:52 2010
@@ -0,0 +1,28 @@
+@echo off
+rem ------------------------------------------------------------------------
+rem
+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
+rem ------------------------------------------------------------------------
+
+setlocal
+
+if "%APOLLO_BASE"=="" set APOLLO_BASE=%~dp0..
+
+apollo %*
+
+:END
+endlocal

Propchange: activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/bin/apollo-broker.cmd
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/apollo.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/apollo.xml?rev=1027720&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/apollo.xml
(added)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/apollo.xml
Tue Oct 26 20:11:52 2010
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+  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.
+-->
+<broker basedir="./activemq-data/default" rev="1" enabled="true" id="default" xmlns="http://activemq.apache.org/schema/activemq/apollo">
+    <notes>
+      A default configuration
+    </notes>
+
+    <virtual-host purge-on-startup="false" auto-create-queues="true" enabled="true" id="default">
+        <host-name>localhost</host-name>
+        <hawtdb-store directory="${apollo.base}/data"/>
+    </virtual-host>
+
+    <connectors advertise="tcp://localhost:61613" protocol="multi" bind="tcp://0.0.0.0:61613"
enabled="true" id="default"/>
+
+</broker>

Copied: activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/log4j.properties
(from r1027719, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/etc/log4j.properties)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/log4j.properties?p2=activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/log4j.properties&p1=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/etc/log4j.properties&r1=1027719&r2=1027720&rev=1027720&view=diff
==============================================================================
    (empty)

Modified: activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/Apollo.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/Apollo.scala?rev=1027720&r1=1027719&r2=1027720&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/Apollo.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/Apollo.scala
Tue Oct 26 20:11:52 2010
@@ -57,20 +57,7 @@ class Apollo extends Main with Action {
       protected override def isPrintStackTraces = debug
       protected override def welcome = {
         val source = getClass().getResourceAsStream("banner.txt")
-        copy(source, session.getConsole())
-      }
-
-      def copy(in: InputStream, out: OutputStream): Long = {
-        var bytesCopied: Long = 0
-        val buffer = new Array[Byte](8192)
-        var bytes = in.read(buffer)
-        while (bytes >= 0) {
-          out.write(buffer, 0, bytes)
-          bytesCopied += bytes
-          bytes = in.read(buffer)
-        }
-
-        bytesCopied
+        commands.Helper.copy(source, session.getConsole())
       }
 
       protected override def setSessionProperties = {}
@@ -86,6 +73,4 @@ class Apollo extends Main with Action {
   }
 
 
-
-
 }
\ No newline at end of file

Modified: activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala?rev=1027720&r1=1027719&r2=1027720&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala
Tue Oct 26 20:11:52 2010
@@ -18,10 +18,11 @@ package org.apache.activemq.apollo.cli.c
 
 import org.apache.felix.gogo.commands.{Action, Option => option, Argument => argument,
Command => command}
 import org.osgi.service.command.CommandSession
-import java.io.File
 import org.fusesource.jansi.Ansi
 import org.fusesource.jansi.Ansi.Color._
 import org.fusesource.jansi.Ansi.Attribute._
+import Helper._
+import java.io.{FileOutputStream, File}
 
 /**
  * The apollo create command
@@ -32,18 +33,55 @@ class Create extends Action {
   @argument(name = "directory", description = "The instance directory to hold the broker's
configuration and data", index=0, required=true)
   var directory:File = _
 
+  @option(name = "--force", description = "Overwrite configuration at destination directory")
+  var force = false
+
   def execute(session: CommandSession) = {
 
     def println(value:Any) = session.getConsole.println(value)
-    def ansi= new Ansi()
-    def error(value:Any) = println(ansi.a(INTENSITY_BOLD).fg(RED).a("ERROR").reset.a(value.toString))
+    try {
+
+      val bin = directory / "bin"
+      bin.mkdirs
+
+      var target = bin / "apollo-broker"
+      write("bin/apollo-broker", target)
+      target.setExecutable(true)
+
+      target = bin / "apollo-broker.cmd"
+      write("bin/apollo-broker.cmd", target)
+
+      val etc = directory / "etc"
+      etc.mkdirs
+
+      target = etc / "log4j.properties"
+      write("etc/log4j.properties", target)
 
+      target = etc / "apollo.xml"
+      write("etc/apollo.xml", target)
 
-    if( directory.exists ) {
-      error("The directory '%s' already exists.".format(directory))
+      val data = directory / "data"
+      data.mkdirs
+      
+      val log = directory / "log"
+      log.mkdirs
+
+    } catch {
+      case x:Helper.Failure=>
+        println(ansi.a(INTENSITY_BOLD).fg(RED).a("ERROR: ").reset.a(x.getMessage))
     }
 
-    
+
     null
   }
+
+  def write(source:String, target:File) = {
+    if( target.exists && !force ) {
+      error("The file '%s' already exists.  Use --force to overwrite.".format(target))
+    }
+    val out = new FileOutputStream(target)
+    val in = getClass.getResourceAsStream(source)
+    copy(in, out)
+    close(out)
+  }
 }
\ No newline at end of file

Added: activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Helper.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Helper.scala?rev=1027720&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Helper.scala
(added)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Helper.scala
Tue Oct 26 20:11:52 2010
@@ -0,0 +1,80 @@
+/**
+ * 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.activemq.apollo.cli.commands
+
+import org.fusesource.jansi.Ansi
+import org.fusesource.jansi.Ansi.Attribute._
+import java.io.{OutputStream, InputStream, File}
+
+/**
+ * <p>
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+object Helper {
+
+  def ansi= new Ansi()
+
+  class Failure(msg:String) extends RuntimeException(msg)
+
+  def error(value:Any) = throw new Failure(value.toString)
+
+  def system_dir(name:String) = {
+    val base_value = System.getProperty(name)
+    if( base_value==null ) {
+      error("The the %s system property is not set.".format(name))
+    }
+    val file = new File(base_value)
+    if( !file.isDirectory  ) {
+      error("The the %s system property is not set to valid directory path %s".format(name,
base_value))
+    }
+    file
+  }
+
+
+  class RichFile(file:File) {
+    def / (path:String) = new File(file, path)
+  }
+  implicit def toRichFile(file:File):RichFile = new RichFile(file)
+
+  def bold(v:String) = ansi.a(INTENSITY_BOLD).a(v).reset
+
+
+  def copy(in: InputStream, out: OutputStream): Long = {
+    try {
+      var bytesCopied: Long = 0
+      val buffer = new Array[Byte](8192)
+      var bytes = in.read(buffer)
+      while (bytes >= 0) {
+        out.write(buffer, 0, bytes)
+        bytesCopied += bytes
+        bytes = in.read(buffer)
+      }
+      bytesCopied
+    } finally {
+      try { in.close  }  catch { case ignore =>  }
+    }
+  }
+
+  def close(out: OutputStream) = {
+    try { out.close  }  catch { case ignore =>  }
+  }
+
+}
+
+

Modified: activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Run.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Run.scala?rev=1027720&r1=1027719&r2=1027720&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Run.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Run.scala
Tue Oct 26 20:11:52 2010
@@ -32,7 +32,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.activemq.apollo.broker.{BrokerRegistry, Broker, ConfigStore, FileConfigStore}
 import org.apache.activemq.apollo.util.ServiceControl
 import org.fusesource.hawtdispatch.ScalaDispatch._
-
+import Helper._
 
 /**
  * The apollo create command
@@ -40,65 +40,45 @@ import org.fusesource.hawtdispatch.Scala
 @command(scope="apollo", name = "run", description = "runs the broker instance")
 class Run extends Action {
 
-  @option(name = "port", description = "The port of the http based administration service")
+  @option(name = "--port", description = "The port of the http based administration service")
   var port: Int = 8080
 
-  @option(name = "prefix", description = "The prefix path of the web application.")
+  @option(name = "--prefix", description = "The prefix path of the web application.")
   var prefix: String = "/"
 
-  @option(name = "conf", description = "The Apollo configuration file.")
+  @option(name = "--conf", description = "The Apollo configuration file.")
   var conf: File = _
 
-  @option(name = "tmp", description = "A temp directory.")
+  @option(name = "--tmp", description = "A temp directory.")
   var tmp: File = _
 
 
-  private def ansi= new Ansi()
-  private class Failure(msg:String) extends RuntimeException(msg)
-  private def error(value:Any) = throw new Failure(value.toString)
-  private def system_dir(name:String) = {
-    val base_value = System.getProperty(name)
-    if( base_value==null ) {
-      error("The the %s system property is not set.".format(name))
-    }
-    val file = new File(System.getProperty("apollo.base"))
-    if( !file.isDirectory  ) {
-      error("The the %s system property is not set to valid directory path %s".format(name,
base_value))
-    }
-    file
-  }
-
-
-  class RichFile(file:File) {
-    def / (path:String) = new File(file, path)
-  }
-  implicit def toRichFile(file:File):RichFile = new RichFile(file)
-
-  def bold(v:String) = ansi.a(INTENSITY_BOLD).a(v).reset
-
   def execute(session: CommandSession):AnyRef = {
 
     def println(value:Any) = session.getConsole.println(value)
 
     try {
+
       val home = system_dir("apollo.home")
       val base = system_dir("apollo.base")
 
+      if( conf == null ) {
+        conf = base / "etc" / "apollo.xml"
+      }
+
+      if( !conf.exists ) {
+        error("Configuration file'%s' does not exist.\n\nTry creating a broker instance using
the 'apollo create' command.".format(conf));
+      }
+
       val lib = home / "lib"
       val webapp = lib / lib.list.find( _.matches("""apollo-web-.+-slim.war""")).getOrElse(throw
new Failure("war file not found.") )
 
-      if( conf == null ) {
-        val etc = base / "etc"
-        etc.mkdirs
-        conf = etc / "apollo.xml"
-      }
 
       if( tmp == null ) {
         tmp = base / "tmp"
         tmp.mkdirs
       }
 
-
       println("========================================================================")
       println("Apollo Broker Service Starting");
       println("========================================================================")
@@ -152,7 +132,7 @@ class Run extends Action {
       println("Administration interface available at: "+bold(url))
 
     } catch {
-      case x:Failure=>
+      case x:Helper.Failure=>
         println(ansi.a(INTENSITY_BOLD).fg(RED).a("ERROR: ").reset.a(x.getMessage))
     }
     null

Modified: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo?rev=1027720&r1=1027719&r2=1027720&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo Tue Oct 26 20:11:52
2010
@@ -126,7 +126,7 @@ for f in "${APOLLO_HOME}/lib"/*.jar; do
   CLASSPATH="$CLASSPATH:$f"
 done
 
-JUL_CONFIG_FILE="${APOLLO_BASE}/etc/jul.properties"
+JUL_CONFIG_FILE="${APOLLO_HOME}/etc/jul.properties"
     
 # For Cygwin, switch paths to Windows format before running java
 if $cygwin; then



Mime
View raw message