You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jb...@apache.org on 2015/05/04 17:30:35 UTC
[04/11] activemq-artemis git commit: Moving artemis-tools to
artemis-cli and improving the tooling
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis-service
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis-service b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis-service
new file mode 100755
index 0000000..7a53901
--- /dev/null
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis-service
@@ -0,0 +1,154 @@
+#!/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.
+
+service=`basename "$0"`
+
+#
+# Discover the ARTEMIS_INSTANCE from the location of this script.
+#
+if [ -z "$ARTEMIS_INSTANCE" ] ; then
+
+ ## resolve links - $0 may be a link to ActiveMQ's home
+ PRG="$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
+
+ ARTEMIS_INSTANCE=`dirname "$PRG"`
+ cd "$saveddir"
+
+ # make it fully qualified
+ ARTEMIS_INSTANCE=`cd "$ARTEMIS_INSTANCE/.." && pwd`
+ export ARTEMIS_INSTANCE
+
+fi
+
+PID_FILE="${ARTEMIS_INSTANCE}/data/artemis.pid"
+
+if [ ! -d "${ARTEMIS_INSTANCE}/data/" ]; then
+ mkdir "${ARTEMIS_INSTANCE}/data/"
+fi
+
+status() {
+ if [ -f "${PID_FILE}" ] ; then
+ pid=`cat "${PID_FILE}"`
+ # check to see if it's gone...
+ ps -p ${pid} > /dev/null
+ if [ $? -eq 0 ] ; then
+ return 0
+ else
+ rm "${PID_FILE}"
+ return 3
+ fi
+ fi
+ return 3
+}
+
+stop() {
+ if [ -f "${PID_FILE}" ] ; then
+ pid=`cat "${PID_FILE}"`
+ kill $@ ${pid} > /dev/null
+ fi
+ for i in 1 2 3 4 5 ; do
+ status
+ if [ $? -ne 0 ] ; then
+ return 0
+ fi
+ sleep 1
+ done
+ echo "Could not stop process ${pid}"
+ return 1
+}
+
+start() {
+
+ status
+ if [ $? -eq 0 ] ; then
+ echo "Already running."
+ return 1
+ fi
+
+ nohup ${ARTEMIS_INSTANCE}/bin/artemis run > /dev/null 2> /dev/null &
+
+ echo $! > "${PID_FILE}"
+
+ # check to see if stays up...
+ sleep 1
+ status
+ if [ $? -ne 0 ] ; then
+ echo "Could not start ${service}"
+ return 1
+ fi
+ echo "${service} is now running (${pid})"
+ return 0
+}
+
+case $1 in
+ start)
+ echo "Starting ${service}"
+ start
+ exit $?
+ ;;
+
+ force-stop)
+ echo "Forcibly Stopping ${service}"
+ stop -9
+ exit $?
+ ;;
+
+ stop)
+ echo "Gracefully Stopping ${service}"
+ stop
+ exit $?
+ ;;
+
+ restart)
+ echo "Restarting ${service}"
+ stop
+ start
+ exit $?
+ ;;
+
+ status)
+ status
+ rc=$?
+ if [ $rc -eq 0 ] ; then
+ echo "${service} is running (${pid})"
+ else
+ echo "${service} is stopped"
+ fi
+ exit $rc
+ ;;
+
+ *)
+ echo "Usage: $0 {start|stop|restart|force-stop|status}" >&2
+ exit 2
+ ;;
+esac
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis-service.xml
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis-service.xml b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis-service.xml
new file mode 100644
index 0000000..a39d16f
--- /dev/null
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis-service.xml
@@ -0,0 +1,59 @@
+<!--
+
+ 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.
+
+-->
+
+<service>
+ <id>armetis-${host}</id>
+ <name>ActiveMQ Artemis: ${host}</name>
+ <description>Apache ActiveMQ Artemis is a reliable messaging broker</description>
+
+ <logpath>${artemis.instance}\log</logpath>
+ <logmode>roll</logmode>
+
+ <executable>"${java.home}\bin\java.exe"</executable>
+ <argument>-XX:+UseParallelGC</argument>
+ <argument>-XX:+AggressiveOpts</argument>
+ <argument>-XX:+UseFastAccessorMethods</argument>
+ <argument>-Xms512M</argument>
+ <argument>-Xmx1024M</argument>
+
+ <!-- Cluster Properties: Used to pass arguments to ActiveMQ which can be referenced in broker.xml
+ <argument>-Dartemis.remoting.default.port=61617</argument>
+ <argument>-Dartemis.remoting.amqp.port=5673</argument>
+ <argument>-Dartemis.remoting.stomp.port=61614</argument>
+ <argument>-Dartemis.remoting.hornetq.port=5446</argument>
+ -->
+
+ <argument>-classpath</argument>
+ <argument>"${artemis.home}\lib\artemis-boot.jar"</argument>
+ <argument>"-artemis.home=${artemis.home}"</argument>
+ <argument>"-artemis.instance=${artemis.instance}"</argument>
+ <argument>"-Ddata.dir=${artemis.instance}/data"</argument>
+ <argument>-Djava.util.logging.manager=org.jboss.logmanager.LogManager</argument>
+ <argument>"-Dlogging.configuration=file:${artemis.instance}\etc\logging.properties"</argument>
+
+
+ <!-- Debug args: Uncomment to enable debug
+ <argument>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005</argument>
+ -->
+
+ <argument>Armetis</argument>
+
+ <argument>run</argument>
+
+</service>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis.cmd
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis.cmd b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis.cmd
new file mode 100755
index 0000000..5e8f500
--- /dev/null
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis.cmd
@@ -0,0 +1,76 @@
+@echo off
+rem Licensed to the Apache Software Foundation (ASF) under one
+rem or more contributor license agreements. See the NOTICE file
+rem distributed with this work for additional information
+rem regarding copyright ownership. The ASF licenses this file
+rem to you under the Apache License, Version 2.0 (the
+rem "License"); you may not use this file except in compliance
+rem with 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,
+rem software distributed under the License is distributed on an
+rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+rem KIND, either express or implied. See the License for the
+rem specific language governing permissions and limitations
+rem under the License.
+
+setlocal
+
+if NOT "%ARTEMIS_INSTANCE%"=="" goto CHECK_ARTEMIS_INSTANCE
+PUSHD .
+CD %~dp0..
+set ARTEMIS_INSTANCE=%CD%
+POPD
+
+:CHECK_ARTEMIS_INSTANCE
+if exist "%ARTEMIS_INSTANCE%\bin\activemq.cmd" goto CHECK_JAVA
+
+:NO_HOME
+echo ARTEMIS_INSTANCE environment variable is set incorrectly. Please set ARTEMIS_INSTANCE.
+goto END
+
+:CHECK_JAVA
+set _JAVACMD=%JAVACMD%
+
+if "%JAVA_HOME%" == "" goto NO_JAVA_HOME
+if not exist "%JAVA_HOME%\bin\java.exe" goto NO_JAVA_HOME
+if "%_JAVACMD%" == "" set _JAVACMD=%JAVA_HOME%\bin\java.exe
+goto RUN_JAVA
+
+:NO_JAVA_HOME
+if "%_JAVACMD%" == "" set _JAVACMD=java.exe
+echo.
+echo Warning: JAVA_HOME environment variable is not set.
+echo.
+
+:RUN_JAVA
+
+rem "Set Defaults."
+set JAVA_ARGS=-XX:+UseParallelGC -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms512M -Xmx1024M
+set ARTEMIS_LOGGING_CONF=file:%ARTEMIS_INSTANCE%\etc\logging.properties
+set ARTEMIS_DATA_DIR=%ARTEMIS_INSTANCE%\data
+set ARTEMIS_LOG_MANAGER=org.jboss.logmanager.LogManager
+
+rem "Load Profile Config"
+call "%ARTEMIS_INSTANCE%\etc\artemis.profile.cmd" %*
+
+rem "Create full JVM Args"
+set JVM_ARGS=%JAVA_ARGS%
+if not "%ARTEMIS_CLUSTER_PROPS%"=="" set JVM_ARGS=%JVM_ARGS% %ARTEMIS_CLUSTER_PROPS%
+set JVM_ARGS=%JVM_ARGS% -classpath "%ARTEMIS_HOME%\lib\artemis-boot.jar"
+set JVM_ARGS=%JVM_ARGS% -Dartemis.home="%ARTEMIS_HOME%"
+set JVM_ARGS=%JVM_ARGS% -Dartemis.instance="%ARTEMIS_INSTANCE%"
+set JVM_ARGS=%JVM_ARGS% -Ddata.dir="%ARTEMIS_DATA_DIR%"
+set JVM_ARGS=%JVM_ARGS% -Djava.util.logging.manager="%ARTEMIS_LOG_MANAGER%"
+set JVM_ARGS=%JVM_ARGS% -Dlogging.configuration="%ARTEMIS_LOGGING_CONF%"
+if not "%DEBUG_ARGS%"=="" set JVM_ARGS=%JVM_ARGS% %DEBUG_ARGS%
+
+"%_JAVACMD%" %JVM_ARGS% org.apache.activemq.artemis.boot.Artemis %*
+
+:END
+endlocal
+GOTO :EOF
+
+:EOF
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis-roles.properties
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis-roles.properties b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis-roles.properties
new file mode 100644
index 0000000..4e2d44c
--- /dev/null
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis-roles.properties
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis-users.properties
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis-users.properties b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis-users.properties
new file mode 100644
index 0000000..4e2d44c
--- /dev/null
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis-users.properties
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile
new file mode 100644
index 0000000..889a0a9
--- /dev/null
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile
@@ -0,0 +1,27 @@
+# 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.
+
+ARTEMIS_HOME='${artemis.home}'
+
+# Cluster Properties: Used to pass arguments to ActiveMQ which can be referenced in broker.xml
+#ARTEMIS_CLUSTER_PROPS="-Dactivemq.remoting.default.port=61617 -Dactivemq.remoting.amqp.port=5673 -Dactivemq.remoting.stomp.port=61614 -Dactivemq.remoting.hornetq.port=5446"
+
+# Java Opts
+#JAVA_ARGS="-XX:+UseParallelGC -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms512M -Xmx1024M"
+
+# Debug args: Uncomment to enable debug
+#DEBUG_ARGS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile.cmd
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile.cmd b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile.cmd
new file mode 100644
index 0000000..450ba79
--- /dev/null
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/artemis.profile.cmd
@@ -0,0 +1,27 @@
+rem Licensed to the Apache Software Foundation (ASF) under one
+rem or more contributor license agreements. See the NOTICE file
+rem distributed with this work for additional information
+rem regarding copyright ownership. The ASF licenses this file
+rem to you under the Apache License, Version 2.0 (the
+rem "License"); you may not use this file except in compliance
+rem with 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,
+rem software distributed under the License is distributed on an
+rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+rem KIND, either express or implied. See the License for the
+rem specific language governing permissions and limitations
+rem under the License.
+
+set ARTEMIS_HOME=${artemis.home}
+
+rem Cluster Properties: Used to pass arguments to ActiveMQ which can be referenced in broker.xml
+rem set ARTEMIS_CLUSTER_PROPS=-Dactivemq.remoting.default.port=61617 -Dactivemq.remoting.amqp.port=5673 -Dactivemq.remoting.stomp.port=61614 -Dactivemq.remoting.hornetq.port=5446
+
+rem Java Opts
+rem set JAVA_ARGS=-XX:+UseParallelGC -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms512M -Xmx1024M
+
+rem Debug args: Uncomment to enable debug
+rem set DEBUG_ARGS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/bootstrap.xml
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/bootstrap.xml b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/bootstrap.xml
new file mode 100644
index 0000000..21d174f
--- /dev/null
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/bootstrap.xml
@@ -0,0 +1,34 @@
+<?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 xmlns="http://activemq.org/schema">
+
+ <basic-security
+ users="file:${artemis.instance}/etc/artemis-users.properties"
+ roles="file:${artemis.instance}/etc/artemis-roles.properties"
+ default-user="guest"
+ />
+
+ <server configuration="file:${artemis.instance}/etc/broker.xml"/>
+
+ <web bind="http://localhost:8161" path="web">
+ <app url="jolokia" war="jolokia-war-1.2.3.war"/>
+ </web>
+
+</broker>
+
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml
new file mode 100644
index 0000000..35ca9c6
--- /dev/null
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml
@@ -0,0 +1,81 @@
+<?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.
+-->
+
+<configuration xmlns="urn:activemq"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
+ <jms xmlns="urn:activemq:jms">
+ <queue name="DLQ"/>
+ <queue name="ExpiryQueue"/>
+ </jms>
+ <core xmlns="urn:activemq:core">
+ <paging-directory>${data.dir:../data}/paging</paging-directory>
+
+ <bindings-directory>${data.dir:../data}/bindings</bindings-directory>
+
+ <journal-directory>${data.dir:../data}/journal</journal-directory>
+
+ <journal-min-files>10</journal-min-files>
+
+ <large-messages-directory>${data.dir:../data}/large-messages</large-messages-directory>
+
+ <connectors>
+ <!-- Default Connector. Returned to clients during broadcast and distributed around cluster. See broadcast and discovery-groups -->
+ <connector name="activemq">tcp://${activemq.remoting.default.host:localhost}:${activemq.remoting.default.port:61616}</connector>
+ </connectors>
+
+ <acceptors>
+ <!-- Default ActiveMQ Acceptor. Multi-protocol adapter. Currently supports Core, OpenWire, Stomp and AMQP. -->
+ <acceptor name="activemq">tcp://${activemq.remoting.default.host:localhost}:${activemq.remoting.default.port:61616}</acceptor>
+
+ <!-- AMQP Acceptor. Listens on default AMQP port for AMQP traffic.-->
+ <acceptor name="amqp">tcp://${activemq.remoting.amqp.host:localhost}:${activemq.remoting.amqp.port:5672}?protocols=AMQP</acceptor>
+
+ <!-- STOMP Acceptor. -->
+ <acceptor name="stomp">tcp://${activemq.remoting.stomp.host:localhost}:${activemq.remoting.stomp.port:61613}?protocols=STOMP</acceptor>
+
+ <!-- HornetQ Compatibility Acceptor. Enables ActiveMQ Core and STOMP for legacy HornetQ clients. -->
+ <acceptor name="hornetq">tcp://${activemq.remoting.hornetq.host:localhost}:${activemq.remoting.hornetq.port:5445}?protocols=CORE,STOMP</acceptor>
+ </acceptors>
+
+ ${cluster.settings}${replicated.settings}${shared-store.settings}
+
+ <security-settings>
+ <security-setting match="#">
+ <permission type="createNonDurableQueue" roles="guest"/>
+ <permission type="deleteNonDurableQueue" roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security-setting>
+ </security-settings>
+
+ <address-settings>
+ <!--default for catch all-->
+ <address-setting match="#">
+ <dead-letter-address>jms.queue.DLQ</dead-letter-address>
+ <expiry-address>jms.queue.ExpiryQueue</expiry-address>
+ <redelivery-delay>0</redelivery-delay>
+ <max-size-bytes>10485760</max-size-bytes>
+ <message-counter-history-day-limit>10</message-counter-history-day-limit>
+ <address-full-policy>BLOCK</address-full-policy>
+ </address-setting>
+ </address-settings>
+ </core>
+</configuration>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/cluster-settings.txt
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/cluster-settings.txt b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/cluster-settings.txt
new file mode 100644
index 0000000..7d9229c
--- /dev/null
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/cluster-settings.txt
@@ -0,0 +1,25 @@
+
+ <broadcast-groups>
+ <broadcast-group name="bg-group1">
+ <group-address>231.7.7.7</group-address>
+ <group-port>9876</group-port>
+ <broadcast-period>5000</broadcast-period>
+ <connector-ref>activemq</connector-ref>
+ </broadcast-group>
+ </broadcast-groups>
+
+ <discovery-groups>
+ <discovery-group name="dg-group1">
+ <group-address>231.7.7.7</group-address>
+ <group-port>9876</group-port>
+ <refresh-timeout>10000</refresh-timeout>
+ </discovery-group>
+ </discovery-groups>
+
+ <cluster-connections>
+ <cluster-connection name="my-cluster">
+ <address>jms</address>
+ <connector-ref>activemq</connector-ref>
+ <discovery-group-ref discovery-group-name="dg-group1"/>
+ </cluster-connection>
+ </cluster-connections>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/logging.properties
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/logging.properties b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/logging.properties
new file mode 100644
index 0000000..084b74c
--- /dev/null
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/logging.properties
@@ -0,0 +1,51 @@
+#
+# 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.
+#
+
+# Additional logger names to configure (root logger is always configured)
+# Root logger option
+loggers=org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.journal,org.apache.activemq.artemis.jms.server,org.apache.activemq.artemis.integration.bootstrap
+
+# Root logger level
+logger.level=INFO
+# ActiveMQ logger levels
+logger.org.apache.activemq.artemis.core.server.level=INFO
+logger.org.apache.activemq.artemis.journal.level=INFO
+logger.org.apache.activemq.artemis.utils.level=INFO
+logger.org.apache.activemq.artemis.jms.level=INFO
+logger.org.apache.activemq.artemis.integration.bootstrap.level=INFO
+# Root logger handlers
+logger.handlers=FILE,CONSOLE
+
+# Console handler configuration
+handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
+handler.CONSOLE.properties=autoFlush
+handler.CONSOLE.level=DEBUG
+handler.CONSOLE.autoFlush=true
+handler.CONSOLE.formatter=PATTERN
+
+# File handler configuration
+handler.FILE=org.jboss.logmanager.handlers.FileHandler
+handler.FILE.level=DEBUG
+handler.FILE.properties=autoFlush,fileName
+handler.FILE.autoFlush=true
+handler.FILE.fileName=${artemis.instance}/log/activemq.log
+handler.FILE.formatter=PATTERN
+
+# Formatter pattern configuration
+formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
+formatter.PATTERN.properties=pattern
+formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/replicated-settings.txt
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/replicated-settings.txt b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/replicated-settings.txt
new file mode 100644
index 0000000..db9faa0
--- /dev/null
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/replicated-settings.txt
@@ -0,0 +1,6 @@
+
+ <ha-policy>
+ <replication>
+ <master/>
+ </replication>
+ </ha-policy>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/shared-store-settings.txt
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/shared-store-settings.txt b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/shared-store-settings.txt
new file mode 100644
index 0000000..5901938
--- /dev/null
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/shared-store-settings.txt
@@ -0,0 +1,6 @@
+
+ <ha-policy>
+ <shared-store>
+ <master/>
+ </shared-store>
+ </ha-policy>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/test/java/org/apache/activemq/artemis/test/FileBrokerTest.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/test/java/org/apache/activemq/artemis/test/FileBrokerTest.java b/artemis-cli/src/test/java/org/apache/activemq/artemis/test/FileBrokerTest.java
new file mode 100644
index 0000000..def9e4a
--- /dev/null
+++ b/artemis-cli/src/test/java/org/apache/activemq/artemis/test/FileBrokerTest.java
@@ -0,0 +1,81 @@
+/**
+ * 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.artemis.test;
+
+import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
+import org.apache.activemq.artemis.dto.ServerDTO;
+import org.apache.activemq.artemis.integration.FileBroker;
+import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
+import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManagerImpl;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FileBrokerTest
+{
+ @Test
+ public void startWithJMS() throws Exception
+ {
+ ServerDTO serverDTO = new ServerDTO();
+ serverDTO.configuration = "broker.xml";
+ FileBroker broker = null;
+ try
+ {
+ broker = new FileBroker(serverDTO, new ActiveMQSecurityManagerImpl());
+ broker.start();
+ JMSServerManagerImpl jmsServerManager = (JMSServerManagerImpl) broker.getComponents().get("jms");
+ Assert.assertNotNull(jmsServerManager);
+ Assert.assertTrue(jmsServerManager.isStarted());
+ //this tells us the jms server is activated
+ Assert.assertTrue(jmsServerManager.getJMSStorageManager().isStarted());
+ ActiveMQServerImpl activeMQServer = (ActiveMQServerImpl) broker.getComponents().get("core");
+ Assert.assertNotNull(activeMQServer);
+ Assert.assertTrue(activeMQServer.isStarted());
+ Assert.assertTrue(broker.isStarted());
+ }
+ finally
+ {
+ if (broker != null)
+ {
+ broker.stop();
+ }
+ }
+ }
+
+ @Test
+ public void startWithoutJMS() throws Exception
+ {
+ ServerDTO serverDTO = new ServerDTO();
+ serverDTO.configuration = "broker-nojms.xml";
+ FileBroker broker = null;
+ try
+ {
+ broker = new FileBroker(serverDTO, new ActiveMQSecurityManagerImpl());
+ broker.start();
+ JMSServerManagerImpl jmsServerManager = (JMSServerManagerImpl) broker.getComponents().get("jms");
+ Assert.assertNull(jmsServerManager);
+ ActiveMQServerImpl activeMQServer = (ActiveMQServerImpl) broker.getComponents().get("core");
+ Assert.assertNotNull(activeMQServer);
+ Assert.assertTrue(activeMQServer.isStarted());
+ Assert.assertTrue(broker.isStarted());
+ }
+ finally
+ {
+ assert broker != null;
+ broker.stop();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/test/resources/broker-nojms.xml
----------------------------------------------------------------------
diff --git a/artemis-cli/src/test/resources/broker-nojms.xml b/artemis-cli/src/test/resources/broker-nojms.xml
new file mode 100644
index 0000000..c4cbd62
--- /dev/null
+++ b/artemis-cli/src/test/resources/broker-nojms.xml
@@ -0,0 +1,73 @@
+<?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.
+-->
+
+<configuration xmlns="urn:activemq">
+ <core xmlns="urn:activemq:core">
+ <paging-directory>${data.dir:../data}/paging</paging-directory>
+
+ <bindings-directory>${data.dir:../data}/bindings</bindings-directory>
+
+ <journal-directory>${data.dir:../data}/journal</journal-directory>
+
+ <journal-min-files>10</journal-min-files>
+
+ <large-messages-directory>${data.dir:../data}/large-messages</large-messages-directory>
+
+ <connectors>
+ <!-- Default Connector. Returned to clients during broadcast and distributed around cluster. See broadcast and discovery-groups -->
+ <connector name="activemq">tcp://${activemq.remoting.default.host:localhost}:${activemq.remoting.default.port:61616}</connector>
+ </connectors>
+
+ <acceptors>
+ <!-- Default ActiveMQ Acceptor. Multi-protocol adapter. Currently supports Core, OpenWire, Stomp and AMQP. -->
+ <acceptor name="activemq">tcp://${activemq.remoting.default.host:localhost}:${activemq.remoting.default.port:61616}</acceptor>
+
+ <!-- AMQP Acceptor. Listens on default AMQP port for AMQP traffic.-->
+ <acceptor name="amqp">tcp://${activemq.remoting.amqp.host:localhost}:${activemq.remoting.amqp.port:5672}?protocols=AMQP</acceptor>
+
+ <!-- STOMP Acceptor. -->
+ <acceptor name="stomp">tcp://${activemq.remoting.stomp.host:localhost}:${activemq.remoting.stomp.port:61613}?protocols=STOMP</acceptor>
+
+ <!-- HornetQ Compatibility Acceptor. Enables ActiveMQ Core and STOMP for legacy HornetQ clients. -->
+ <acceptor name="hornetq">tcp://${activemq.remoting.hornetq.host:localhost}:${activemq.remoting.hornetq.port:5445}?protocols=CORE,STOMP</acceptor>
+ </acceptors>
+
+ <security-settings>
+ <security-setting match="#">
+ <permission type="createNonDurableQueue" roles="guest"/>
+ <permission type="deleteNonDurableQueue" roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security-setting>
+ </security-settings>
+
+ <address-settings>
+ <!--default for catch all-->
+ <address-setting match="#">
+ <dead-letter-address>jms.queue.DLQ</dead-letter-address>
+ <expiry-address>jms.queue.ExpiryQueue</expiry-address>
+ <redelivery-delay>0</redelivery-delay>
+ <max-size-bytes>10485760</max-size-bytes>
+ <message-counter-history-day-limit>10</message-counter-history-day-limit>
+ <address-full-policy>BLOCK</address-full-policy>
+ </address-setting>
+ </address-settings>
+ </core>
+</configuration>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-cli/src/test/resources/broker.xml
----------------------------------------------------------------------
diff --git a/artemis-cli/src/test/resources/broker.xml b/artemis-cli/src/test/resources/broker.xml
new file mode 100644
index 0000000..219c0b2
--- /dev/null
+++ b/artemis-cli/src/test/resources/broker.xml
@@ -0,0 +1,77 @@
+<?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.
+-->
+
+<configuration xmlns="urn:activemq">
+ <jms xmlns="urn:activemq:jms">
+ <queue name="DLQ"/>
+ <queue name="ExpiryQueue"/>
+ </jms>
+ <core xmlns="urn:activemq:core">
+ <paging-directory>${data.dir:../data}/paging</paging-directory>
+
+ <bindings-directory>${data.dir:../data}/bindings</bindings-directory>
+
+ <journal-directory>${data.dir:../data}/journal</journal-directory>
+
+ <journal-min-files>10</journal-min-files>
+
+ <large-messages-directory>${data.dir:../data}/large-messages</large-messages-directory>
+
+ <connectors>
+ <!-- Default Connector. Returned to clients during broadcast and distributed around cluster. See broadcast and discovery-groups -->
+ <connector name="activemq">tcp://${activemq.remoting.default.host:localhost}:${activemq.remoting.default.port:61616}</connector>
+ </connectors>
+
+ <acceptors>
+ <!-- Default ActiveMQ Acceptor. Multi-protocol adapter. Currently supports Core, OpenWire, Stomp and AMQP. -->
+ <acceptor name="activemq">tcp://${activemq.remoting.default.host:localhost}:${activemq.remoting.default.port:61616}</acceptor>
+
+ <!-- AMQP Acceptor. Listens on default AMQP port for AMQP traffic.-->
+ <acceptor name="amqp">tcp://${activemq.remoting.amqp.host:localhost}:${activemq.remoting.amqp.port:5672}?protocols=AMQP</acceptor>
+
+ <!-- STOMP Acceptor. -->
+ <acceptor name="stomp">tcp://${activemq.remoting.stomp.host:localhost}:${activemq.remoting.stomp.port:61613}?protocols=STOMP</acceptor>
+
+ <!-- HornetQ Compatibility Acceptor. Enables ActiveMQ Core and STOMP for legacy HornetQ clients. -->
+ <acceptor name="hornetq">tcp://${activemq.remoting.hornetq.host:localhost}:${activemq.remoting.hornetq.port:5445}?protocols=CORE,STOMP</acceptor>
+ </acceptors>
+
+ <security-settings>
+ <security-setting match="#">
+ <permission type="createNonDurableQueue" roles="guest"/>
+ <permission type="deleteNonDurableQueue" roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security-setting>
+ </security-settings>
+
+ <address-settings>
+ <!--default for catch all-->
+ <address-setting match="#">
+ <dead-letter-address>jms.queue.DLQ</dead-letter-address>
+ <expiry-address>jms.queue.ExpiryQueue</expiry-address>
+ <redelivery-delay>0</redelivery-delay>
+ <max-size-bytes>10485760</max-size-bytes>
+ <message-counter-history-day-limit>10</message-counter-history-day-limit>
+ <address-full-policy>BLOCK</address-full-policy>
+ </address-setting>
+ </address-settings>
+ </core>
+</configuration>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-distribution/pom.xml
----------------------------------------------------------------------
diff --git a/artemis-distribution/pom.xml b/artemis-distribution/pom.xml
index 9fd1670..d9879c4 100644
--- a/artemis-distribution/pom.xml
+++ b/artemis-distribution/pom.xml
@@ -54,7 +54,7 @@
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
- <artifactId>artemis-bootstrap</artifactId>
+ <artifactId>artemis-cli</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -69,11 +69,6 @@
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
- <artifactId>artemis-tools</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
<artifactId>artemis-ra</artifactId>
<version>${project.version}</version>
</dependency>
@@ -132,7 +127,6 @@
<artifactId>artemis-website</artifactId>
<version>${project.version}</version>
</dependency>
-
<!-- dependencies -->
<dependency>
<groupId>org.jboss.logmanager</groupId>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-distribution/src/main/assembly/dep.xml
----------------------------------------------------------------------
diff --git a/artemis-distribution/src/main/assembly/dep.xml b/artemis-distribution/src/main/assembly/dep.xml
index 1ca9844..bd8e60b 100644
--- a/artemis-distribution/src/main/assembly/dep.xml
+++ b/artemis-distribution/src/main/assembly/dep.xml
@@ -47,7 +47,7 @@
<includes>
<!-- modules -->
- <include>org.apache.activemq:artemis-bootstrap</include>
+ <include>org.apache.activemq:artemis-cli</include>
<include>org.apache.activemq:artemis-commons</include>
<include>org.apache.activemq:artemis-core-client</include>
<include>org.apache.activemq:artemis-dto</include>
@@ -63,7 +63,6 @@
<include>org.apache.activemq:artemis-selector</include>
<include>org.apache.activemq:artemis-server</include>
<include>org.apache.activemq:artemis-service-extensions</include>
- <include>org.apache.activemq:artemis-tools</include>
<include>org.apache.activemq:artemis-web</include>
<include>org.apache.activemq.rest:artemis-rest</include>
<!-- dependencies -->
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java
index fa1e170..30a003a 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/DescribeJournal.java
@@ -85,6 +85,26 @@ import static org.apache.activemq.artemis.core.persistence.impl.journal.JournalR
*/
public final class DescribeJournal
{
+
+ private final List<RecordInfo> records;
+ private final List<PreparedTransactionInfo> preparedTransactions;
+
+ public DescribeJournal(List<RecordInfo> records, List<PreparedTransactionInfo> preparedTransactions)
+ {
+ this.records = records;
+ this.preparedTransactions = preparedTransactions;
+ }
+
+ public List<RecordInfo> getRecords()
+ {
+ return records;
+ }
+
+ public List<PreparedTransactionInfo> getPreparedTransactions()
+ {
+ return preparedTransactions;
+ }
+
public static void describeBindingsJournal(final String bindingsDir) throws Exception
{
@@ -94,7 +114,7 @@ public final class DescribeJournal
describeJournal(bindingsFF, bindings, bindingsDir);
}
- public static void describeMessagesJournal(final String messagesDir) throws Exception
+ public static DescribeJournal describeMessagesJournal(final String messagesDir) throws Exception
{
SequentialFileFactory messagesFF = new NIOSequentialFileFactory(messagesDir, null);
@@ -111,7 +131,7 @@ public final class DescribeJournal
"amq",
1);
- describeJournal(messagesFF, messagesJournal, messagesDir);
+ return describeJournal(messagesFF, messagesJournal, messagesDir);
}
/**
@@ -119,7 +139,7 @@ public final class DescribeJournal
* @param journal
* @throws Exception
*/
- private static void describeJournal(SequentialFileFactory fileFactory, JournalImpl journal, final String path) throws Exception
+ private static DescribeJournal describeJournal(SequentialFileFactory fileFactory, JournalImpl journal, final String path) throws Exception
{
List<JournalFile> files = journal.orderFiles();
@@ -417,6 +437,8 @@ public final class DescribeJournal
}
journal.stop();
+
+ return new DescribeJournal(records, preparedTransactions);
}
protected static void printCounters(final PrintStream out, final Map<Long, PageSubscriptionCounterImpl> counters)
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-tools/pom.xml
----------------------------------------------------------------------
diff --git a/artemis-tools/pom.xml b/artemis-tools/pom.xml
deleted file mode 100644
index d221401..0000000
--- a/artemis-tools/pom.xml
+++ /dev/null
@@ -1,90 +0,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.
--->
-<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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-pom</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>artemis-tools</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ Artemis Tools</name>
-
- <dependencies>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-processor</artifactId>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-server</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-jms-server</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <properties>
- <activemq.basedir>${project.basedir}/..</activemq.basedir>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <mainClass>org.apache.activemq.artemis.tools.Main</mainClass>
- </manifest>
- </archive>
- <descriptorRefs>
- <descriptorRef>jar-with-dependencies</descriptorRef>
- </descriptorRefs>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>release</id>
- </profile>
- </profiles>
-
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/ActiveMQToolsLogger.java
----------------------------------------------------------------------
diff --git a/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/ActiveMQToolsLogger.java b/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/ActiveMQToolsLogger.java
deleted file mode 100644
index 9646049..0000000
--- a/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/ActiveMQToolsLogger.java
+++ /dev/null
@@ -1,44 +0,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.
- */
-package org.apache.activemq.artemis.tools;
-
-import org.jboss.logging.BasicLogger;
-import org.jboss.logging.Logger;
-import org.jboss.logging.annotations.MessageLogger;
-
-/**
- * Logger Code 24
- *
- * each message id must be 6 digits long starting with 10, the 3rd digit donates the level so
- *
- * INF0 1
- * WARN 2
- * DEBUG 3
- * ERROR 4
- * TRACE 5
- * FATAL 6
- *
- * so an INFO message would be 241000 to 241999
- */
-@MessageLogger(projectCode = "AMQ")
-public interface ActiveMQToolsLogger extends BasicLogger
-{
- /**
- * The default logger.
- */
- ActiveMQToolsLogger LOGGER = Logger.getMessageLogger(ActiveMQToolsLogger.class, ActiveMQToolsLogger.class.getPackage().getName());
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/DataTool.java
----------------------------------------------------------------------
diff --git a/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/DataTool.java b/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/DataTool.java
deleted file mode 100644
index 58a6b1e..0000000
--- a/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/DataTool.java
+++ /dev/null
@@ -1,231 +0,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.
- */
-package org.apache.activemq.artemis.tools;
-
-import java.io.File;
-import java.util.ArrayList;
-
-import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
-import org.apache.activemq.artemis.core.journal.SequentialFileFactory;
-import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
-import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory;
-
-public class DataTool
-{
-
- private static final String BINDING_TYPE = "binding";
- private static final String JOURNAL_TYPE = "journal";
- private static final String JMS_TYPE = "jms";
-
-
- private static final String ROLLBACK = "rollback";
-
- private static final String DELETE = "delete";
-
- public void process(String[] arg)
- {
- if (arg.length < 5)
- {
- printUsage();
- System.exit(-1);
- }
-
- String type = arg[1];
- String directoryName = arg[2];
- String sizeStr = arg[3];
-
- long sizeLong;
-
- if (!type.equals(BINDING_TYPE) && !type.equals(JOURNAL_TYPE))
- {
- System.err.println("Invalid type: " + type);
- printUsage();
- System.exit(-1);
- }
-
- File directory = new File(directoryName);
- if (!directory.exists() || !directory.isDirectory())
- {
- System.err.println("Invalid directory " + directoryName);
- printUsage();
- System.exit(-1);
- }
-
- try
- {
- sizeLong = Long.parseLong(sizeStr);
-
- if (sizeLong <= 0)
- {
- System.err.println("Invalid size " + sizeLong);
- printUsage();
- System.exit(-1);
- }
- }
- catch (Throwable e)
- {
- System.err.println("Error converting journal size: " + e.getMessage() + " couldn't convert size " + sizeStr);
- printUsage();
- System.exit(-1);
- }
-
- final String journalName;
- final String exension;
-
- if (type.equals(JOURNAL_TYPE))
- {
- journalName = "activemq-data";
- exension = "amq";
- }
- else if (type.equals(BINDING_TYPE))
- {
- journalName = "activemq-bindings";
- exension = "bindings";
- }
- else if (type.equals(JMS_TYPE))
- {
- journalName = "activemq-jms";
- exension = "jms";
- }
- else
- {
- printUsage();
- System.exit(-1);
- return; // dumb compiler don't know System.exit interrupts the execution, some variables wouldn't be init
- }
-
- SequentialFileFactory messagesFF = new NIOSequentialFileFactory(directoryName, null);
-
- // Will use only default values. The load function should adapt to anything different
- ConfigurationImpl defaultValues = new ConfigurationImpl();
-
- try
- {
- ArrayList<Long> txsToRollback = new ArrayList<Long>();
-
- ArrayList<Long> idsToDelete = new ArrayList<Long>();
-
-
- ArrayList<Long> listInUse = null;
-
- for (int i = 4; i < arg.length; i++)
- {
- String str = arg[i];
- if (str.equals(DELETE))
- {
- listInUse = idsToDelete;
- }
- else if (str.equals(ROLLBACK))
- {
- listInUse = txsToRollback;
- }
- else
- {
- try
- {
- if (listInUse == null)
- {
- System.err.println("You must specify either " + DELETE + " or " + ROLLBACK + " as a command for the IDs you're using");
- printUsage();
- System.exit(-1);
- }
-
- long id = Long.parseLong(str);
- listInUse.add(id);
- }
- catch (Throwable e)
- {
- System.err.println("Error converting id " + str + " as a recordID");
- printUsage();
- System.exit(-1);
- }
-
- }
- }
-
- JournalImpl messagesJournal = new JournalImpl(defaultValues.getJournalFileSize(),
- defaultValues.getJournalMinFiles(),
- 0,
- 0,
- messagesFF,
- journalName,
- exension,
- 1);
-
- messagesJournal.start();
-
- messagesJournal.loadInternalOnly();
-
-
- for (long tx : txsToRollback)
- {
- System.out.println("Rolling back " + tx);
-
- try
- {
- messagesJournal.appendRollbackRecord(tx, true);
- }
- catch (Throwable e)
- {
- e.printStackTrace();
- }
- }
-
-
- for (long id : idsToDelete)
- {
- System.out.println("Deleting record " + id);
-
- try
- {
- messagesJournal.appendDeleteRecord(id, true);
- }
- catch (Throwable e)
- {
- e.printStackTrace();
- }
- }
-
- messagesJournal.stop();
-
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
-
- public void printUsage()
- {
- for (int i = 0; i < 10; i++)
- {
- System.err.println();
- }
- System.err.println(Main.USAGE + " binding|journal <directory> <size> [rollback | delete] record1,record2..recordN");
- System.err.println();
- System.err.println("Example:");
- System.err.println("say you wanted to rollback a prepared TXID=100, and you want to remove records 300, 301, 302:");
- System.err.println(Main.USAGE + " journal /tmp/your-folder 10485760 rollback 100 delete 300 301 302");
- System.err.println();
- System.err.println(".. and you can specify as many rollback and delete you like");
- for (int i = 0; i < 10; i++)
- {
- System.err.println();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/ExportJournal.java
----------------------------------------------------------------------
diff --git a/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/ExportJournal.java b/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/ExportJournal.java
deleted file mode 100644
index d2c9339..0000000
--- a/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/ExportJournal.java
+++ /dev/null
@@ -1,224 +0,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.
- */
-package org.apache.activemq.artemis.tools;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.PrintStream;
-import java.util.List;
-
-import org.apache.activemq.artemis.core.journal.RecordInfo;
-import org.apache.activemq.artemis.core.journal.SequentialFileFactory;
-import org.apache.activemq.artemis.core.journal.impl.JournalFile;
-import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
-import org.apache.activemq.artemis.core.journal.impl.JournalReaderCallback;
-import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory;
-import org.apache.activemq.artemis.utils.Base64;
-
-/**
- * Use this class to export the journal data. You can use it as a main class or through its static method {@link #exportJournal(String, String, String, int, int, String)}
- * <p/>
- * If you use the main method, use it as <JournalDirectory> <JournalPrefix> <FileExtension> <MinFiles> <FileSize> <FileOutput>
- * <p/>
- * Example: java -cp activemq-tools*-jar-with-dependencies.jar export-journal /journalDir activemq-data amq 2 10485760 /tmp/export.dat
- */
-public class ExportJournal
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void process(final String[] arg)
- {
- if (arg.length != 6)
- {
- for (int i = 0; i < arg.length; i++)
- {
- System.out.println("arg[" + i + "] = " + arg[i]);
- }
- printUsage();
- System.exit(-1);
- }
-
- try
- {
- exportJournal(arg[1], arg[2], arg[3], 2, Integer.parseInt(arg[4]), arg[5]);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- }
-
- public static void exportJournal(final String directory,
- final String journalPrefix,
- final String journalSuffix,
- final int minFiles,
- final int fileSize,
- final String fileOutput) throws Exception
- {
-
- FileOutputStream fileOut = new FileOutputStream(new File(fileOutput));
-
- BufferedOutputStream buffOut = new BufferedOutputStream(fileOut);
-
- PrintStream out = new PrintStream(buffOut);
-
- exportJournal(directory, journalPrefix, journalSuffix, minFiles, fileSize, out);
-
- out.close();
- }
-
- public static void exportJournal(final String directory,
- final String journalPrefix,
- final String journalSuffix,
- final int minFiles,
- final int fileSize,
- final PrintStream out) throws Exception
- {
- NIOSequentialFileFactory nio = new NIOSequentialFileFactory(directory, null);
-
- JournalImpl journal = new JournalImpl(fileSize, minFiles, 0, 0, nio, journalPrefix, journalSuffix, 1);
-
- List<JournalFile> files = journal.orderFiles();
-
- for (JournalFile file : files)
- {
- out.println("#File," + file);
-
- exportJournalFile(out, nio, file);
- }
- }
-
- /**
- * @param out
- * @param fileFactory
- * @param file
- * @throws Exception
- */
- public static void exportJournalFile(final PrintStream out,
- final SequentialFileFactory fileFactory,
- final JournalFile file) throws Exception
- {
- JournalImpl.readJournalFile(fileFactory, file, new JournalReaderCallback()
- {
-
- public void onReadUpdateRecordTX(final long transactionID, final RecordInfo recordInfo) throws Exception
- {
- out.println("operation@UpdateTX,txID@" + transactionID + "," + describeRecord(recordInfo));
- }
-
- public void onReadUpdateRecord(final RecordInfo recordInfo) throws Exception
- {
- out.println("operation@Update," + describeRecord(recordInfo));
- }
-
- public void onReadRollbackRecord(final long transactionID) throws Exception
- {
- out.println("operation@Rollback,txID@" + transactionID);
- }
-
- public void onReadPrepareRecord(final long transactionID, final byte[] extraData, final int numberOfRecords) throws Exception
- {
- out.println("operation@Prepare,txID@" + transactionID +
- ",numberOfRecords@" +
- numberOfRecords +
- ",extraData@" +
- encode(extraData));
- }
-
- public void onReadDeleteRecordTX(final long transactionID, final RecordInfo recordInfo) throws Exception
- {
- out.println("operation@DeleteRecordTX,txID@" + transactionID +
- "," +
- describeRecord(recordInfo));
- }
-
- public void onReadDeleteRecord(final long recordID) throws Exception
- {
- out.println("operation@DeleteRecord,id@" + recordID);
- }
-
- public void onReadCommitRecord(final long transactionID, final int numberOfRecords) throws Exception
- {
- out.println("operation@Commit,txID@" + transactionID + ",numberOfRecords@" + numberOfRecords);
- }
-
- public void onReadAddRecordTX(final long transactionID, final RecordInfo recordInfo) throws Exception
- {
- out.println("operation@AddRecordTX,txID@" + transactionID + "," + describeRecord(recordInfo));
- }
-
- public void onReadAddRecord(final RecordInfo recordInfo) throws Exception
- {
- out.println("operation@AddRecord," + describeRecord(recordInfo));
- }
-
- public void markAsDataFile(final JournalFile file)
- {
- }
- });
- }
-
- private static String describeRecord(final RecordInfo recordInfo)
- {
- return "id@" + recordInfo.id +
- ",userRecordType@" +
- recordInfo.userRecordType +
- ",length@" +
- recordInfo.data.length +
- ",isUpdate@" +
- recordInfo.isUpdate +
- ",compactCount@" +
- recordInfo.compactCount +
- ",data@" +
- encode(recordInfo.data);
- }
-
- private static String encode(final byte[] data)
- {
- return Base64.encodeBytes(data, 0, data.length, Base64.DONT_BREAK_LINES | Base64.URL_SAFE);
- }
-
-
- public void printUsage()
- {
- for (int i = 0; i < 10; i++)
- {
- System.err.println();
- }
- System.err.println("This method will export the journal at low level record.");
- System.err.println();
- System.err.println(Main.USAGE + " export-journal <JournalDirectory> <JournalPrefix> <FileExtension> <FileSize> <FileOutput>");
- System.err.println();
- for (int i = 0; i < 10; i++)
- {
- System.err.println();
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/ImportJournal.java
----------------------------------------------------------------------
diff --git a/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/ImportJournal.java b/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/ImportJournal.java
deleted file mode 100644
index b1d0284..0000000
--- a/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/ImportJournal.java
+++ /dev/null
@@ -1,412 +0,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.
- */
-package org.apache.activemq.artemis.tools;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.activemq.artemis.core.journal.RecordInfo;
-import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
-import org.apache.activemq.artemis.core.journal.impl.JournalRecord;
-import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory;
-import org.apache.activemq.artemis.utils.Base64;
-
-/**
- * Use this class to import the journal data from a listed file. You can use it as a main class or
- * through its native method
- * {@link #importJournal(String, String, String, int, int, String)}
- * <p>
- * If you use the main method, use its arguments as:
- *
- * <pre>
- * JournalDirectory JournalPrefix FileExtension MinFiles FileSize FileOutput
- * </pre>
- * <p>
- * Example:
- *
- * <pre>
- * java -cp activemq-core.jar org.apache.activemq.artemis.core.journal.impl.ExportJournal /journalDir activemq-data amq 2 10485760 /tmp/export.dat
- * </pre>
- */
-public class ImportJournal
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
-
- public void process(final String[] arg)
- {
- for (int i = 0; i < arg.length; i++)
- {
- System.out.println("arg[" + i + "] = " + arg[i]);
- }
- if (arg.length != 6)
- {
- for (int i = 0; i < arg.length; i++)
- {
- System.out.println("arg[" + i + "] = " + arg[i]);
- }
- printUsage();
- System.exit(-1);
- }
-
- try
- {
- importJournal(arg[1], arg[2], arg[3], 2, Integer.parseInt(arg[4]), arg[5]);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- }
-
- public static void importJournal(final String directory,
- final String journalPrefix,
- final String journalSuffix,
- final int minFiles,
- final int fileSize,
- final String fileInput) throws Exception
- {
- FileInputStream fileInputStream = new FileInputStream(new File(fileInput));
- importJournal(directory, journalPrefix, journalSuffix, minFiles, fileSize, fileInputStream);
-
- }
-
- public static void importJournal(final String directory,
- final String journalPrefix,
- final String journalSuffix,
- final int minFiles,
- final int fileSize,
- final InputStream stream) throws Exception
- {
- Reader reader = new InputStreamReader(stream);
- importJournal(directory, journalPrefix, journalSuffix, minFiles, fileSize, reader);
- }
-
- public static void importJournal(final String directory,
- final String journalPrefix,
- final String journalSuffix,
- final int minFiles,
- final int fileSize,
- final Reader reader) throws Exception
- {
-
- File journalDir = new File(directory);
-
- if (!journalDir.exists())
- {
- if (!journalDir.mkdirs())
- System.err.println("Could not create directory " + directory);
- }
-
- NIOSequentialFileFactory nio = new NIOSequentialFileFactory(directory, null);
-
- JournalImpl journal = new JournalImpl(fileSize, minFiles, 0, 0, nio, journalPrefix, journalSuffix, 1);
-
- if (journal.orderFiles().size() != 0)
- {
- throw new IllegalStateException("Import needs to create a brand new journal");
- }
-
- journal.start();
-
- // The journal is empty, as we checked already. Calling load just to initialize the internal data
- journal.loadInternalOnly();
-
- BufferedReader buffReader = new BufferedReader(reader);
-
- String line;
-
- HashMap<Long, AtomicInteger> txCounters = new HashMap<Long, AtomicInteger>();
-
- long lineNumber = 0;
-
- Map<Long, JournalRecord> journalRecords = journal.getRecords();
-
- while ((line = buffReader.readLine()) != null)
- {
- lineNumber++;
- String[] splitLine = line.split(",");
- if (splitLine[0].equals("#File"))
- {
- txCounters.clear();
- continue;
- }
-
- Properties lineProperties = parseLine(splitLine);
-
- String operation = null;
- try
- {
- operation = lineProperties.getProperty("operation");
-
- if (operation.equals("AddRecord"))
- {
- RecordInfo info = parseRecord(lineProperties);
- journal.appendAddRecord(info.id, info.userRecordType, info.data, false);
- }
- else if (operation.equals("AddRecordTX"))
- {
- long txID = parseLong("txID", lineProperties);
- AtomicInteger counter = getCounter(txID, txCounters);
- counter.incrementAndGet();
- RecordInfo info = parseRecord(lineProperties);
- journal.appendAddRecordTransactional(txID, info.id, info.userRecordType, info.data);
- }
- else if (operation.equals("AddRecordTX"))
- {
- long txID = parseLong("txID", lineProperties);
- AtomicInteger counter = getCounter(txID, txCounters);
- counter.incrementAndGet();
- RecordInfo info = parseRecord(lineProperties);
- journal.appendAddRecordTransactional(txID, info.id, info.userRecordType, info.data);
- }
- else if (operation.equals("UpdateTX"))
- {
- long txID = parseLong("txID", lineProperties);
- AtomicInteger counter = getCounter(txID, txCounters);
- counter.incrementAndGet();
- RecordInfo info = parseRecord(lineProperties);
- journal.appendUpdateRecordTransactional(txID, info.id, info.userRecordType, info.data);
- }
- else if (operation.equals("Update"))
- {
- RecordInfo info = parseRecord(lineProperties);
- journal.appendUpdateRecord(info.id, info.userRecordType, info.data, false);
- }
- else if (operation.equals("DeleteRecord"))
- {
- long id = parseLong("id", lineProperties);
-
- // If not found it means the append/update records were reclaimed already
- if (journalRecords.get(id) != null)
- {
- journal.appendDeleteRecord(id, false);
- }
- }
- else if (operation.equals("DeleteRecordTX"))
- {
- long txID = parseLong("txID", lineProperties);
- long id = parseLong("id", lineProperties);
- AtomicInteger counter = getCounter(txID, txCounters);
- counter.incrementAndGet();
-
- // If not found it means the append/update records were reclaimed already
- if (journalRecords.get(id) != null)
- {
- journal.appendDeleteRecordTransactional(txID, id);
- }
- }
- else if (operation.equals("Prepare"))
- {
- long txID = parseLong("txID", lineProperties);
- int numberOfRecords = parseInt("numberOfRecords", lineProperties);
- AtomicInteger counter = getCounter(txID, txCounters);
- byte[] data = parseEncoding("extraData", lineProperties);
-
- if (counter.get() == numberOfRecords)
- {
- journal.appendPrepareRecord(txID, data, false);
- }
- else
- {
- System.err.println("Transaction " + txID +
- " at line " +
- lineNumber +
- " is incomplete. The prepare record expected " +
- numberOfRecords +
- " while the import only had " +
- counter);
- }
- }
- else if (operation.equals("Commit"))
- {
- long txID = parseLong("txID", lineProperties);
- int numberOfRecords = parseInt("numberOfRecords", lineProperties);
- AtomicInteger counter = getCounter(txID, txCounters);
- if (counter.get() == numberOfRecords)
- {
- journal.appendCommitRecord(txID, false);
- }
- else
- {
- System.err.println("Transaction " + txID +
- " at line " +
- lineNumber +
- " is incomplete. The commit record expected " +
- numberOfRecords +
- " while the import only had " +
- counter);
- }
- }
- else if (operation.equals("Rollback"))
- {
- long txID = parseLong("txID", lineProperties);
- journal.appendRollbackRecord(txID, false);
- }
- else
- {
- System.err.println("Invalid operation " + operation + " at line " + lineNumber);
- }
- }
- catch (Exception ex)
- {
- System.err.println("Error at line " + lineNumber + ", operation=" + operation + " msg = " + ex.getMessage());
- }
- }
-
- journal.stop();
- }
-
- protected static AtomicInteger getCounter(final Long txID, final Map<Long, AtomicInteger> txCounters)
- {
-
- AtomicInteger counter = txCounters.get(txID);
- if (counter == null)
- {
- counter = new AtomicInteger(0);
- txCounters.put(txID, counter);
- }
-
- return counter;
- }
-
- protected static RecordInfo parseRecord(final Properties properties) throws Exception
- {
- long id = parseLong("id", properties);
- byte userRecordType = parseByte("userRecordType", properties);
- boolean isUpdate = parseBoolean("isUpdate", properties);
- byte[] data = parseEncoding("data", properties);
- return new RecordInfo(id, userRecordType, data, isUpdate, (short)0);
- }
-
- private static byte[] parseEncoding(final String name, final Properties properties) throws Exception
- {
- String value = parseString(name, properties);
-
- return decode(value);
- }
-
- /**
- * @param properties
- * @return
- */
- private static int parseInt(final String name, final Properties properties) throws Exception
- {
- String value = parseString(name, properties);
-
- return Integer.parseInt(value);
- }
-
- private static long parseLong(final String name, final Properties properties) throws Exception
- {
- String value = parseString(name, properties);
-
- return Long.parseLong(value);
- }
-
- private static boolean parseBoolean(final String name, final Properties properties) throws Exception
- {
- String value = parseString(name, properties);
-
- return Boolean.parseBoolean(value);
- }
-
- private static byte parseByte(final String name, final Properties properties) throws Exception
- {
- String value = parseString(name, properties);
-
- return Byte.parseByte(value);
- }
-
- /**
- * @param name
- * @param properties
- * @return
- * @throws Exception
- */
- private static String parseString(final String name, final Properties properties) throws Exception
- {
- String value = properties.getProperty(name);
-
- if (value == null)
- {
- throw new Exception("property " + name + " not found");
- }
- return value;
- }
-
- protected static Properties parseLine(final String[] splitLine)
- {
- Properties properties = new Properties();
-
- for (String el : splitLine)
- {
- String[] tuple = el.split("@");
- if (tuple.length == 2)
- {
- properties.put(tuple[0], tuple[1]);
- }
- else
- {
- properties.put(tuple[0], tuple[0]);
- }
- }
-
- return properties;
- }
-
- private static byte[] decode(final String data)
- {
- return Base64.decode(data, Base64.DONT_BREAK_LINES | Base64.URL_SAFE);
- }
-
-
- public void printUsage()
- {
- for (int i = 0; i < 10; i++)
- {
- System.err.println();
- }
- System.err.println("This method will export the journal at low level record.");
- System.err.println();
- System.err.println(Main.USAGE + " import-journal <JournalDirectory> <JournalPrefix> <FileExtension> <FileSize> <FileInput>");
- System.err.println();
- for (int i = 0; i < 10; i++)
- {
- System.err.println();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ea3370b3/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/Main.java
----------------------------------------------------------------------
diff --git a/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/Main.java b/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/Main.java
deleted file mode 100644
index c239b15..0000000
--- a/artemis-tools/src/main/java/org/apache/activemq/artemis/tools/Main.java
+++ /dev/null
@@ -1,127 +0,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.
- */
-package org.apache.activemq.artemis.tools;
-
-public class Main
-{
- public static final String USAGE = "Use: java -jar " + getJarName();
- private static final String IMPORT = "import";
- private static final String EXPORT = "export";
- private static final String PRINT_DATA = "print-data";
- private static final String PRINT_PAGES = "print-pages";
- private static final String DATA_TOOL = "data-tool";
- private static final String TRANSFER = "transfer-queue";
- private static final String EXPORT_JOURNAL = "export-journal";
- private static final String IMPORT_JOURNAL = "import-journal";
- private static final String OPTIONS = " [" + IMPORT + "|" + EXPORT + "|" + PRINT_DATA + "|" + PRINT_PAGES + "|" + DATA_TOOL + "|" + TRANSFER + "|" + EXPORT_JOURNAL + "|" + IMPORT_JOURNAL + "]";
-
- public static void main(String[] arg) throws Exception
- {
- if (arg.length == 0)
- {
- System.out.println(USAGE + OPTIONS);
- System.exit(-1);
- }
-
-
- if (IMPORT_JOURNAL.equals(arg[0]))
- {
- ImportJournal tool = new ImportJournal();
- tool.process(arg);
- }
- else if (EXPORT_JOURNAL.equals(arg[0]))
- {
- ExportJournal tool = new ExportJournal();
- tool.process(arg);
- }
- else if (TRANSFER.equals(arg[0]))
- {
- TransferQueue tool = new TransferQueue();
- tool.process(arg);
- }
- else if (DATA_TOOL.equals(arg[0]))
- {
- DataTool dataTool = new DataTool();
- dataTool.process(arg);
- }
- else if (EXPORT.equals(arg[0]))
- {
- if (arg.length != 5)
- {
- System.out.println(USAGE + " " + EXPORT + " <bindings-directory> <journal-directory> <paging-directory> <large-messages-directory>");
- System.exit(-1);
- }
- else
- {
- XmlDataExporter xmlDataExporter = new XmlDataExporter(System.out, arg[1], arg[2], arg[3], arg[4]);
- xmlDataExporter.writeXMLData();
- }
- }
- else if (IMPORT.equals(arg[0]))
- {
- if (arg.length != 6)
- {
- System.out.println(USAGE + " " + IMPORT + " <input-file> <host> <port> <transactional> <application-server-compatibility>");
- System.exit(-1);
- }
- else
- {
- XmlDataImporter xmlDataImporter = new XmlDataImporter(arg[1], arg[2], arg[3], Boolean.parseBoolean(arg[4]), Boolean.parseBoolean(arg[5]));
- xmlDataImporter.processXml();
- }
- }
- else if (PRINT_DATA.equals(arg[0]))
- {
- if (arg.length != 3)
- {
- System.err.println(USAGE + " " + PRINT_DATA + " <bindings-directory> <journal-directory>");
- System.exit(-1);
- }
-
- PrintData.printData(arg[1], arg[2]);
- }
- else if (PRINT_PAGES.equals(arg[0]))
- {
- if (arg.length != 3)
- {
- System.err.println(USAGE + " " + PRINT_PAGES + " <paging-directory> <journal-directory>");
- System.exit(-1);
- }
-
- PrintPages.printPages(arg[1], arg[2]);
- }
- else
- {
- System.out.println(USAGE + OPTIONS);
- }
- }
-
- protected static String getJarName()
- {
- try
- {
- Class klass = Main.class;
- String url = klass.getResource('/' + klass.getName().replace('.', '/') + ".class").toString();
- String jarName = url.substring(0, url.lastIndexOf('!'));
- return jarName.substring(jarName.lastIndexOf('/') + 1);
- }
- catch (Throwable e)
- {
- return "tool-jar-name.jar";
- }
- }
-}
\ No newline at end of file