You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2010/11/06 21:55:06 UTC

svn commit: r1032138 - in /activemq/activemq-apollo/trunk: apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ apollo-cli/ apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/ apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/co...

Author: chirino
Date: Sat Nov  6 20:55:05 2010
New Revision: 1032138

URL: http://svn.apache.org/viewvc?rev=1032138&view=rev
Log:
Better debug broker setup. (logging)

Added:
    activemq/activemq-apollo/trunk/apollo-cli/src/test/
    activemq/activemq-apollo/trunk/apollo-cli/src/test/resources/
    activemq/activemq-apollo/trunk/apollo-cli/src/test/resources/log4j.properties   (contents, props changed)
      - copied, changed from r1032137, activemq/activemq-apollo/trunk/apollo-stomp/src/main/resources/log4j.properties
    activemq/activemq-apollo/trunk/apollo-cli/src/test/scala/
    activemq/activemq-apollo/trunk/apollo-cli/src/test/scala/org/
    activemq/activemq-apollo/trunk/apollo-cli/src/test/scala/org/apache/
    activemq/activemq-apollo/trunk/apollo-cli/src/test/scala/org/apache/activemq/
    activemq/activemq-apollo/trunk/apollo-cli/src/test/scala/org/apache/activemq/apollo/
    activemq/activemq-apollo/trunk/apollo-cli/src/test/scala/org/apache/activemq/apollo/cli/
    activemq/activemq-apollo/trunk/apollo-cli/src/test/scala/org/apache/activemq/apollo/cli/TestApollo.scala
Removed:
    activemq/activemq-apollo/trunk/apollo-stomp/src/main/resources/log4j.properties
    activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/StompBroker.scala
Modified:
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Delivery.scala
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Queue.scala
    activemq/activemq-apollo/trunk/apollo-cli/pom.xml
    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/Run.scala

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Delivery.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Delivery.scala?rev=1032138&r1=1032137&r2=1032138&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Delivery.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Delivery.scala Sat Nov  6 20:55:05 2010
@@ -22,13 +22,17 @@ import org.fusesource.hawtbuf._
 import protocol.Protocol
 import org.apache.activemq.apollo.filter.Filterable
 import org.apache.activemq.apollo.store.{StoreUOW, MessageRecord}
+import org.apache.activemq.apollo.util.{Log, Logging}
+
+object DeliveryProducer extends Log
 
 /**
  * A producer which sends Delivery objects to a delivery consumer.
  *
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
-trait DeliveryProducer {
+trait DeliveryProducer extends Logging {
+  override protected def log:Log = DeliveryProducer
 
   def dispatchQueue:DispatchQueue
 
@@ -36,7 +40,7 @@ trait DeliveryProducer {
 
   def collocate(value:DispatchQueue):Unit = {
     if( value.getTargetQueue ne dispatchQueue.getTargetQueue ) {
-      println(dispatchQueue.getLabel+" co-locating with: "+value.getLabel);
+      info(dispatchQueue.getLabel+" co-locating with "+value.getLabel);
       this.dispatchQueue.setTargetQueue(value.getTargetQueue)
     }
   }

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Queue.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Queue.scala?rev=1032138&r1=1032137&r2=1032138&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Queue.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Queue.scala Sat Nov  6 20:55:05 2010
@@ -92,7 +92,7 @@ class Queue(val host: VirtualHost, var i
    * Subscribers that consume slower than this rate per seconds will be considered
    * slow.  Once a consumer is considered slow, we may switch to disk spooling.
    */
-  var tune_slow_subscription_rate = 2*1024*1024
+  var tune_slow_subscription_rate = 500*1024
 
   /**
    * The number of milliseconds between slow consumer checks.
@@ -593,7 +593,7 @@ class Queue(val host: VirtualHost, var i
 
   def collocate(value:DispatchQueue):Unit = {
     if( value.getTargetQueue ne dispatchQueue.getTargetQueue ) {
-      debug(dispatchQueue.getLabel+" co-locating with: "+value.getLabel);
+      info(dispatchQueue.getLabel+" co-locating with "+value.getLabel);
       this.dispatchQueue.setTargetQueue(value.getTargetQueue)
     }
   }

Modified: activemq/activemq-apollo/trunk/apollo-cli/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/pom.xml?rev=1032138&r1=1032137&r2=1032138&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-cli/pom.xml Sat Nov  6 20:55:05 2010
@@ -23,6 +23,7 @@
       <scope>compile</scope>
       <version>${scala-version}</version>
     </dependency>
+
     <dependency>
       <groupId>org.scala-lang</groupId>
       <artifactId>scala-compiler</artifactId>
@@ -35,37 +36,6 @@
       <groupId>org.apache.activemq</groupId>
       <artifactId>apollo-broker</artifactId>
       <version>1.0-SNAPSHOT</version>
-    </dependency>
-
-    <!-- Optional Modules -->
-    <dependency>
-      <groupId>org.apache.activemq</groupId>
-      <artifactId>apollo-web</artifactId>
-      <version>1.0-SNAPSHOT</version>
-      <optional>true</optional>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.activemq</groupId>
-      <artifactId>apollo-stomp</artifactId>
-      <version>1.0-SNAPSHOT</version>
-      <optional>true</optional>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.activemq</groupId>
-      <artifactId>apollo-hawtdb</artifactId>
-      <version>1.0-SNAPSHOT</version>
-      <optional>true</optional>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.activemq</groupId>
-      <artifactId>apollo-cassandra</artifactId>
-      <version>1.0-SNAPSHOT</version>
-      <optional>true</optional>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.activemq</groupId>
-      <artifactId>apollo-bdb</artifactId>
-      <version>1.0-SNAPSHOT</version>
       <optional>true</optional>
     </dependency>
 
@@ -89,11 +59,56 @@
       <version>${karaf-version}</version>
     </dependency>
 
+    <!-- Testing Dependencies -->
+    <dependency>
+      <groupId>org.scalatest</groupId>
+      <artifactId>scalatest</artifactId>
+      <version>${scalatest-version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+      <version>${junit-version}</version>
+    </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
       <version>${slf4j-version}</version>
-      <optional>true</optional>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- Optional Modules -->
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>apollo-web</artifactId>
+      <version>1.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>apollo-stomp</artifactId>
+      <version>1.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>apollo-hawtdb</artifactId>
+      <version>1.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>apollo-cassandra</artifactId>
+      <version>1.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>apollo-bdb</artifactId>
+      <version>1.0-SNAPSHOT</version>
+      <scope>test</scope>
     </dependency>
 
   </dependencies>

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=1032138&r1=1032137&r2=1032138&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 Sat Nov  6 20:55:05 2010
@@ -25,6 +25,12 @@ import jline.Terminal
 import org.fusesource.jansi.Ansi
 import java.io.{OutputStream, PrintStream, InputStream}
 
+/**
+ * <p>
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
 object Apollo {
   def main(args: Array[String]) = {
     Ansi.ansi()

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=1032138&r1=1032137&r2=1032138&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 Sat Nov  6 20:55:05 2010
@@ -30,15 +30,15 @@ import org.mortbay.jetty.nio.SelectChann
 import org.mortbay.jetty.webapp.WebAppContext
 import org.apache.commons.logging.LogFactory
 import org.apache.activemq.apollo.broker.{BrokerRegistry, Broker, ConfigStore, FileConfigStore}
-import org.apache.activemq.apollo.util.ServiceControl
 import org.fusesource.hawtdispatch._
 import Helper._
+import org.apache.activemq.apollo.util.{Logging, ServiceControl}
 
 /**
  * The apollo create command
  */
 @command(scope="apollo", name = "run", description = "runs the broker instance")
-class Run extends Action {
+class Run extends Action with Logging {
 
   @option(name = "--port", description = "The port of the http based administration service")
   var port: Int = 8080
@@ -52,11 +52,8 @@ class Run extends Action {
   @option(name = "--tmp", description = "A temp directory.")
   var tmp: File = _
 
-
   def execute(session: CommandSession):AnyRef = {
 
-    def println(value:Any) = session.getConsole.println(value)
-
     try {
 
       val base = system_dir("apollo.base")
@@ -85,13 +82,11 @@ class Run extends Action {
         tmp.mkdirs
       }
 
-      println("========================================================================")
-      println("Apollo Broker Service Starting");
-      println("========================================================================")
-      println("")
+      info("Apollo Broker Service Starting");
 
       // Load the configs and start the brokers up.
-      println("Loading configurations from '%s'.".format(conf));
+      info("log4j configured using '%s'.", getClass.getClassLoader.getResource("log4j.properties") );
+      info("Loading configurations from '%s'.", conf);
       val store = new FileConfigStore
       store.file = conf
       ConfigStore() = store
@@ -101,12 +96,12 @@ class Run extends Action {
             store.getBroker(id, true).foreach{ config=>
               // Only start the broker up if it's enabled..
               if( config.enabled ) {
-                println("Starting broker '%s'...".format(config.id));
+                info("Starting broker '%s'...".format(config.id));
                 val broker = new Broker()
                 broker.config = config
                 BrokerRegistry.add(config.id, broker)
                 broker.start(^{
-                  println("Broker '%s' started.".format(config.id));
+                  info("Broker '%s' started.".format(config.id));
                 })
               }
             }
@@ -116,7 +111,7 @@ class Run extends Action {
 
 
       // Start up the admin interface...
-      println("Starting administration interface...");
+      info("Starting administration interface...");
       var server = new Server
 
       var connector = new SelectChannelConnector
@@ -138,7 +133,7 @@ class Run extends Action {
 
       val localPort = connector.getLocalPort
       def url = "http://localhost:" + localPort + prefix
-      println("Administration interface available at: "+bold(url))
+      info("Administration interface available at: "+bold(url))
 
       if(java.lang.Boolean.getBoolean("hawtdispatch.profile")) {
         monitor_hawtdispatch
@@ -146,7 +141,7 @@ class Run extends Action {
 
     } catch {
       case x:Helper.Failure=>
-        println(ansi.a(INTENSITY_BOLD).fg(RED).a("ERROR: ").reset.a(x.getMessage))
+        error(x.getMessage)
     }
     null
   }
@@ -170,10 +165,7 @@ class Run extends Action {
           }
 
           if( !m.isEmpty ) {
-            println("-- hawtdispatch metrics -----------------------")
-            m.foreach{ metric=>
-              println(metric)
-            }
+            info("-- hawtdispatch metrics -----------------------\n"+m.mkString("\n"))
           }
         }
       }

Copied: activemq/activemq-apollo/trunk/apollo-cli/src/test/resources/log4j.properties (from r1032137, activemq/activemq-apollo/trunk/apollo-stomp/src/main/resources/log4j.properties)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/test/resources/log4j.properties?p2=activemq/activemq-apollo/trunk/apollo-cli/src/test/resources/log4j.properties&p1=activemq/activemq-apollo/trunk/apollo-stomp/src/main/resources/log4j.properties&r1=1032137&r2=1032138&rev=1032138&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/main/resources/log4j.properties (original)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/test/resources/log4j.properties Sat Nov  6 20:55:05 2010
@@ -5,9 +5,9 @@
 ## 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.
@@ -16,21 +16,31 @@
 ## ---------------------------------------------------------------------------
 
 #
-# The logging properties used during tests..
+# Setup the default logging levels
 #
-log4j.rootLogger=WARN, console, file
-log4j.logger.org.apache.activemq=TRACE
-log4j.logger.org=TRACE
+log4j.rootLogger=WARN, console, logfile
+log4j.logger.org.apache.activemq.apollo=INFO
 
-# Console will only display warnnings
+#
+# Uncomment one of the following to enable debug logging
+#
+# log4j.logger.org.apache.activemq.apollo=DEBUG
+# log4j.logger.org.apache.activemq.apollo.broker=DEBUG
+# log4j.logger.org.apache.activemq.apollo.web=DEBUG
+# log4j.logger.org.apache.activemq.apollo.cli=DEBUG
+# log4j.logger.org.apache.activemq.apollo.store.hawtdb=DEBUG
+
+# Console Settings
 log4j.appender.console=org.apache.log4j.ConsoleAppender
 log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern=%-5p | %t | %m%n
+log4j.appender.console.layout.ConversionPattern=%-5p | %m%n
 log4j.appender.console.threshold=INFO
 
-# File appender will contain all info messages
-log4j.appender.file=org.apache.log4j.FileAppender
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern=%d | %-5p | %m | %c | %t%n
-log4j.appender.file.file=target/test.log
-log4j.appender.file.append=true
+# File Settings
+log4j.appender.logfile=org.apache.log4j.RollingFileAppender
+log4j.appender.logfile.file=${apollo.base}/log/apollo.log
+log4j.appender.logfile.maxFileSize=5MB
+log4j.appender.logfile.maxBackupIndex=5
+log4j.appender.logfile.append=true
+log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
+log4j.appender.logfile.layout.ConversionPattern=%d | %-5p | %m | %c | %t%n
\ No newline at end of file

Added: activemq/activemq-apollo/trunk/apollo-cli/src/test/scala/org/apache/activemq/apollo/cli/TestApollo.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/test/scala/org/apache/activemq/apollo/cli/TestApollo.scala?rev=1032138&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/test/scala/org/apache/activemq/apollo/cli/TestApollo.scala (added)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/test/scala/org/apache/activemq/apollo/cli/TestApollo.scala Sat Nov  6 20:55:05 2010
@@ -0,0 +1,38 @@
+/**
+ * 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
+
+import org.junit.Test;
+
+/**
+ * <p>
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+class TestApollo extends  {
+
+  @Test
+  def run:Unit = {
+    println("=======================")
+    println("Press Enter To Shutdown")
+    println("=======================")
+    new Apollo().run(Array("run"))
+    System.in.read
+  }
+
+}
\ No newline at end of file