Author: ataylor
Date: 2010-11-26 04:46:11 -0500 (Fri, 26 Nov 2010)
New Revision: 9928
Added:
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/build.bat
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/build.sh
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/build.xml
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/client-jndi.properties
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/hornetq-beans.xml
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/hornetq-configuration.xml
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/hornetq-jms.xml
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/hornetq-users.xml
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/client-jndi.properties
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/hornetq-beans.xml
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/hornetq-configuration.xml
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/hornetq-jms.xml
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/hornetq-users.xml
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/client-jndi.properties
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/hornetq-beans.xml
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/hornetq-configuration.xml
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/hornetq-jms.xml
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/hornetq-users.xml
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/src/
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/src/org/
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/src/org/hornetq/
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/src/org/hornetq/jms/
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/src/org/hornetq/jms/example/
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/src/org/hornetq/jms/example/MultipleFailoverExample.java
Modified:
branches/2_2_0_HA_Improvements_preMerge/examples/common/build.xml
branches/2_2_0_HA_Improvements_preMerge/examples/common/src/org/hornetq/common/example/HornetQExample.java
branches/2_2_0_HA_Improvements_preMerge/examples/common/src/org/hornetq/common/example/SpawnedVMSupport.java
branches/2_2_0_HA_Improvements_preMerge/examples/jms/hornetq-jms-examples.iml
branches/2_2_0_HA_Improvements_preMerge/src/main/org/hornetq/core/server/impl/FileLockNodeManager.java
Log:
added multiple failover example
Modified: branches/2_2_0_HA_Improvements_preMerge/examples/common/build.xml
===================================================================
--- branches/2_2_0_HA_Improvements_preMerge/examples/common/build.xml 2010-11-25 08:14:27
UTC (rev 9927)
+++ branches/2_2_0_HA_Improvements_preMerge/examples/common/build.xml 2010-11-26 09:46:11
UTC (rev 9928)
@@ -146,6 +146,7 @@
<jvmarg value="-Dhornetq.example.server.args=${server.args}"/>
<jvmarg
value="-Dhornetq.example.logserveroutput=${hornetq.example.logserveroutput}"/>
<jvmarg
value="-Dhornetq.example.runServer=${hornetq.example.runServer}"/>
+ <!--<jvmarg value="-Dserver1=true"/>-->
<arg line="${hornetq.example.beans.file}"/>
<sysproperty key="java.library.path"
value="${java.library.path}${path.separator}${aio.library.path}"/>
<classpath refid="client.classpath"/>
Modified:
branches/2_2_0_HA_Improvements_preMerge/examples/common/src/org/hornetq/common/example/HornetQExample.java
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/common/src/org/hornetq/common/example/HornetQExample.java 2010-11-25
08:14:27 UTC (rev 9927)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/common/src/org/hornetq/common/example/HornetQExample.java 2010-11-26
09:46:11 UTC (rev 9928)
@@ -141,6 +141,8 @@
{
String config = configs[index];
HornetQExample.log.info("starting server with config '" + config +
"' " + "logServerOutput " + logServerOutput);
+ String debugProp = System.getProperty("server" + index);
+ boolean debugServer= "true".equals(debugProp);
servers[index] = SpawnedVMSupport.spawnVM(serverClasspath,
"HornetQServer_" + index,
SpawnedHornetQServer.class.getName(),
@@ -149,6 +151,7 @@
"STARTED::",
"FAILED::",
config,
+ debugServer,
"hornetq-beans.xml");
}
Modified:
branches/2_2_0_HA_Improvements_preMerge/examples/common/src/org/hornetq/common/example/SpawnedVMSupport.java
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/common/src/org/hornetq/common/example/SpawnedVMSupport.java 2010-11-25
08:14:27 UTC (rev 9927)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/common/src/org/hornetq/common/example/SpawnedVMSupport.java 2010-11-26
09:46:11 UTC (rev 9928)
@@ -55,6 +55,7 @@
success,
failure,
configDir,
+ false,
args);
}
@@ -66,6 +67,7 @@
final String success,
final String failure,
final String configDir,
+ boolean debug,
final String... args) throws Exception
{
StringBuffer sb = new StringBuffer();
@@ -98,6 +100,10 @@
libPath = "\"" + libPath + "\"";
}
sb.append("-Djava.library.path=").append(libPath).append(" ");
+ if(debug)
+ {
+ sb.append("-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 ");
+ }
sb.append(className).append(' ');
Modified: branches/2_2_0_HA_Improvements_preMerge/examples/jms/hornetq-jms-examples.iml
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/jms/hornetq-jms-examples.iml 2010-11-25
08:14:27 UTC (rev 9927)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/hornetq-jms-examples.iml 2010-11-26
09:46:11 UTC (rev 9928)
@@ -68,6 +68,7 @@
<sourceFolder url="file://$MODULE_DIR$/send-acknowledgements/src"
isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/static-selector-jms/src"
isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/transaction-failover/src"
isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/multiple-failover/src"
isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/browser/build" />
<excludeFolder url="file://$MODULE_DIR$/browser/logs" />
<excludeFolder url="file://$MODULE_DIR$/browser/server0/build" />
Added: branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/build.bat
===================================================================
--- branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/build.bat
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/build.bat 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,13 @@
+@echo off
+
+set "OVERRIDE_ANT_HOME=..\..\..\tools\ant"
+
+if exist "..\..\..\src\bin\build.bat" (
+ rem running from TRUNK
+ call ..\..\..\src\bin\build.bat %*
+) else (
+ rem running from the distro
+ call ..\..\..\bin\build.bat %*
+)
+
+set "OVERRIDE_ANT_HOME="
Added: branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/build.sh
===================================================================
--- branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/build.sh
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/build.sh 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+OVERRIDE_ANT_HOME=../../../tools/ant
+export OVERRIDE_ANT_HOME
+
+if [ -f "../../../src/bin/build.sh" ]; then
+ # running from TRUNK
+ ../../../src/bin/build.sh "$@"
+else
+ # running from the distro
+ ../../../bin/build.sh "$@"
+fi
+
+
+
Property changes on:
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/build.sh
___________________________________________________________________
Name: svn:executable
+ *
Added: branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/build.xml
===================================================================
--- branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/build.xml
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/build.xml 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2009 Red Hat, Inc.
+ ~ Red Hat 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.
+ -->
+
+<!DOCTYPE project [
+ <!ENTITY libraries SYSTEM "../../../thirdparty/libraries.ent">
+ ]>
+
+<project default="run" name="HornetQ JMS Non-transaction Multiple
Failover Example">
+
+ <import file="../../common/build.xml"/>
+
+ <target name="run" depends="delete-files">
+ <antcall target="runExample">
+ <param name="example.classname"
value="org.hornetq.jms.example.MultipleFailoverExample"/>
+ <param name="hornetq.example.beans.file" value="server0
server1 server2"/>
+ </antcall>
+ </target>
+
+ <target name="runRemote" depends="delete-files">
+ <antcall target="runExample">
+ <param name="example.classname"
value="org.hornetq.jms.example.MultipleFailoverExample"/>
+ <param name="hornetq.example.runServer"
value="false"/>
+ </antcall>
+ </target>
+
+ <target name="delete-files" depends="clean">
+ <delete file="./server0/KILL_ME"/>
+ <delete file="./server1/KILL_ME"/>
+ <delete file="./server2/KILL_ME"/>
+ </target>
+
+</project>
Added:
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/client-jndi.properties
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/client-jndi.properties
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/client-jndi.properties 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
Added:
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/hornetq-beans.xml
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/hornetq-beans.xml
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/hornetq-beans.xml 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Copyright 2009 Red Hat, Inc.
+ ~ Red Hat 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.
+ -->
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Naming" class="org.jnp.server.NamingBeanImpl"/>
+
+ <!-- JNDI server. Disable this if you don't want JNDI -->
+ <bean name="JNDIServer" class="org.jnp.server.Main">
+ <property name="namingInfo">
+ <inject bean="Naming"/>
+ </property>
+ <property name="port">1099</property>
+ <property name="bindAddress">localhost</property>
+ <property name="rmiPort">1098</property>
+ <property name="rmiBindAddress">localhost</property>
+ </bean>
+
+ <!-- MBean server -->
+ <bean name="MBeanServer"
class="javax.management.MBeanServer">
+ <constructor factoryClass="java.lang.management.ManagementFactory"
+ factoryMethod="getPlatformMBeanServer"/>
+ </bean>
+
+ <!-- The core configuration -->
+ <bean name="Configuration"
class="org.hornetq.core.config.impl.FileConfiguration"/>
+
+ <!-- The security manager -->
+ <bean name="HornetQSecurityManager"
class="org.hornetq.spi.core.security.HornetQSecurityManagerImpl">
+ <start ignored="true"/>
+ <stop ignored="true"/>
+ </bean>
+
+ <!-- The core server -->
+ <bean name="HornetQServer"
class="org.hornetq.core.server.impl.HornetQServerImpl">
+ <constructor>
+ <parameter>
+ <inject bean="Configuration"/>
+ </parameter>
+ <parameter>
+ <inject bean="MBeanServer"/>
+ </parameter>
+ <parameter>
+ <inject bean="HornetQSecurityManager"/>
+ </parameter>
+ </constructor>
+ <start ignored="true"/>
+ <stop ignored="true"/>
+ </bean>
+
+ <!-- The JMS server -->
+ <bean name="JMSServerManager"
class="org.hornetq.jms.server.impl.JMSServerManagerImpl">
+ <constructor>
+ <parameter>
+ <inject bean="HornetQServer"/>
+ </parameter>
+ </constructor>
+ </bean>
+
+</deployment>
Added:
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/hornetq-configuration.xml
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/hornetq-configuration.xml
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/hornetq-configuration.xml 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,63 @@
+<configuration xmlns="urn:hornetq"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq
/schema/hornetq-configuration.xsd">
+
+ <clustered>true</clustered>
+
+ <shared-store>true</shared-store>
+ <!-- Connectors -->
+
+ <connectors>
+ <connector name="netty-connector">
+
<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
+ <param key="port" value="5445"/>
+ </connector>
+ </connectors>
+
+ <!-- Acceptors -->
+ <acceptors>
+ <acceptor name="netty-acceptor">
+
<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
+ <param key="port" value="5445"/>
+ </acceptor>
+ </acceptors>
+
+ <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>netty-connector</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>60000</refresh-timeout>
+ </discovery-group>
+ </discovery-groups>
+
+ <cluster-connections>
+ <cluster-connection name="my-cluster">
+ <address>jms</address>
+ <connector-ref>netty-connector</connector-ref>
+ <discovery-group-ref discovery-group-name="dg-group1"/>
+ </cluster-connection>
+ </cluster-connections>
+ <!-- Other config -->
+
+ <security-settings>
+ <!--security for example queue-->
+ <security-setting match="jms.queue.exampleQueue">
+ <permission type="createDurableQueue" roles="guest"/>
+ <permission type="deleteDurableQueue" roles="guest"/>
+ <permission type="createNonDurableQueue"
roles="guest"/>
+ <permission type="deleteNonDurableQueue"
roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security-setting>
+ </security-settings>
+
+</configuration>
Added:
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/hornetq-jms.xml
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/hornetq-jms.xml
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/hornetq-jms.xml 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,34 @@
+<configuration xmlns="urn:hornetq"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
+ <!--the connection factory used by the example-->
+ <connection-factory name="ConnectionFactory">
+ <connectors>
+ <connector-ref connector-name="netty-connector"/>
+ </connectors>
+
+ <entries>
+ <entry name="ConnectionFactory"/>
+ </entries>
+
+ <ha>true</ha>
+ <!-- Pause 1 second between connect attempts -->
+ <retry-interval>1000</retry-interval>
+
+ <!-- Multiply subsequent reconnect pauses by this multiplier. This can be used
to
+ implement an exponential back-off. For our purposes we just set to 1.0 so each
reconnect
+ pause is the same length -->
+ <retry-interval-multiplier>1.0</retry-interval-multiplier>
+
+ <!-- Try reconnecting an unlimited number of times (-1 means
"unlimited") -->
+ <reconnect-attempts>-1</reconnect-attempts>
+
+ </connection-factory>
+
+ <!--the queue used by the example-->
+ <queue name="exampleQueue">
+ <entry name="/queue/exampleQueue"/>
+ <durable>true</durable>
+ </queue>
+
+</configuration>
Added:
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/hornetq-users.xml
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/hornetq-users.xml
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server0/hornetq-users.xml 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,7 @@
+<configuration xmlns="urn:hornetq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-users.xsd">
+ <!-- the default user. this is used where username is null-->
+ <defaultuser name="guest" password="guest">
+ <role name="guest"/>
+ </defaultuser>
+</configuration>
\ No newline at end of file
Added:
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/client-jndi.properties
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/client-jndi.properties
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/client-jndi.properties 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:2099
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
Added:
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/hornetq-beans.xml
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/hornetq-beans.xml
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/hornetq-beans.xml 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Copyright 2009 Red Hat, Inc.
+ ~ Red Hat 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.
+ -->
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Naming" class="org.jnp.server.NamingBeanImpl"/>
+
+ <!-- JNDI server. Disable this if you don't want JNDI -->
+ <bean name="JNDIServer" class="org.jnp.server.Main">
+ <property name="namingInfo">
+ <inject bean="Naming"/>
+ </property>
+ <property name="port">2099</property>
+ <property name="bindAddress">localhost</property>
+ <property name="rmiPort">2098</property>
+ <property name="rmiBindAddress">localhost</property>
+ </bean>
+
+ <!-- MBean server -->
+ <bean name="MBeanServer"
class="javax.management.MBeanServer">
+ <constructor factoryClass="java.lang.management.ManagementFactory"
+ factoryMethod="getPlatformMBeanServer"/>
+ </bean>
+
+ <!-- The core configuration -->
+ <bean name="Configuration"
class="org.hornetq.core.config.impl.FileConfiguration"/>
+
+ <!-- The security manager -->
+ <bean name="HornetQSecurityManager"
class="org.hornetq.spi.core.security.HornetQSecurityManagerImpl">
+ <start ignored="true"/>
+ <stop ignored="true"/>
+ </bean>
+
+ <!-- The core server -->
+ <bean name="HornetQServer"
class="org.hornetq.core.server.impl.HornetQServerImpl">
+ <constructor>
+ <parameter>
+ <inject bean="Configuration"/>
+ </parameter>
+ <parameter>
+ <inject bean="MBeanServer"/>
+ </parameter>
+ <parameter>
+ <inject bean="HornetQSecurityManager"/>
+ </parameter>
+ </constructor>
+ <start ignored="true"/>
+ <stop ignored="true"/>
+ </bean>
+
+ <!-- The JMS server -->
+ <bean name="JMSServerManager"
class="org.hornetq.jms.server.impl.JMSServerManagerImpl">
+ <constructor>
+ <parameter>
+ <inject bean="HornetQServer"/>
+ </parameter>
+ </constructor>
+ </bean>
+
+</deployment>
Added:
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/hornetq-configuration.xml
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/hornetq-configuration.xml
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/hornetq-configuration.xml 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,71 @@
+<configuration xmlns="urn:hornetq"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq
../../../src/schema/hornetq-configuration.xsd">
+
+ <clustered>true</clustered>
+
+ <backup>true</backup>
+
+ <shared-store>true</shared-store>
+
+ <!-- Connectors -->
+
+ <connectors>
+ <connector name="netty-connector">
+
<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
+ <param key="port" value="5446"/>
+ </connector>
+ </connectors>
+
+ <!-- Acceptors -->
+ <acceptors>
+ <acceptor name="netty-acceptor">
+
<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
+ <param key="port" value="5446"/>
+ </acceptor>
+ </acceptors>
+
+ <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>netty-connector</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>60000</refresh-timeout>
+ </discovery-group>
+ </discovery-groups>
+
+ <cluster-connections>
+ <cluster-connection name="my-cluster">
+ <address>jms</address>
+ <connector-ref>netty-connector</connector-ref>
+ <discovery-group-ref discovery-group-name="dg-group1"/>
+ </cluster-connection>
+ </cluster-connections>
+ <!-- Other config -->
+
+
<large-messages-directory>../server0/data/large-messages</large-messages-directory>
+ <bindings-directory>../server0/data/bindings</bindings-directory>
+ <journal-directory>../server0/data/journal</journal-directory>
+ <paging-directory>../server0/data/paging</paging-directory>
+
+ <security-settings>
+ <!--security for example queue-->
+ <security-setting match="jms.queue.exampleQueue">
+ <permission type="createDurableQueue" roles="guest"/>
+ <permission type="deleteDurableQueue" roles="guest"/>
+ <permission type="createNonDurableQueue"
roles="guest"/>
+ <permission type="deleteNonDurableQueue"
roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security-setting>
+ </security-settings>
+
+</configuration>
Added:
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/hornetq-jms.xml
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/hornetq-jms.xml
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/hornetq-jms.xml 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,33 @@
+<configuration xmlns="urn:hornetq"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
+ <!--the connection factory used by the example-->
+ <connection-factory name="ConnectionFactory">
+ <connectors>
+ <connector-ref connector-name="netty-connector"
backup-connector-name="backup-connector"/>
+ </connectors>
+
+ <entries>
+ <entry name="ConnectionFactory"/>
+ </entries>
+
+ <ha>true</ha>
+ <!-- Pause 1 second between connect attempts -->
+ <retry-interval>1000</retry-interval>
+
+ <!-- Multiply subsequent reconnect pauses by this multiplier. This can be used
to
+ implement an exponential back-off. For our purposes we just set to 1.0 so each
reconnect
+ pause is the same length -->
+ <retry-interval-multiplier>1.0</retry-interval-multiplier>
+
+ <!-- Try reconnecting an unlimited number of times (-1 means
"unlimited") -->
+ <reconnect-attempts>-1</reconnect-attempts>
+ </connection-factory>
+
+ <!--the queue used by the example-->
+ <queue name="exampleQueue">
+ <entry name="/queue/exampleQueue"/>
+ <durable>true</durable>
+ </queue>
+
+</configuration>
Added:
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/hornetq-users.xml
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/hornetq-users.xml
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server1/hornetq-users.xml 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,7 @@
+<configuration xmlns="urn:hornetq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-users.xsd">
+ <!-- the default user. this is used where username is null-->
+ <defaultuser name="guest" password="guest">
+ <role name="guest"/>
+ </defaultuser>
+</configuration>
\ No newline at end of file
Added:
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/client-jndi.properties
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/client-jndi.properties
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/client-jndi.properties 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,16 @@
+#
+# Copyright 2009 Red Hat, Inc.
+# Red Hat 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.
+#
+
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:3099
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
Added:
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/hornetq-beans.xml
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/hornetq-beans.xml
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/hornetq-beans.xml 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Copyright 2009 Red Hat, Inc.
+ ~ Red Hat 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.
+ -->
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Naming" class="org.jnp.server.NamingBeanImpl"/>
+
+ <!-- JNDI server. Disable this if you don't want JNDI -->
+ <bean name="JNDIServer" class="org.jnp.server.Main">
+ <property name="namingInfo">
+ <inject bean="Naming"/>
+ </property>
+ <property name="port">3099</property>
+ <property name="bindAddress">localhost</property>
+ <property name="rmiPort">3098</property>
+ <property name="rmiBindAddress">localhost</property>
+ </bean>
+
+ <!-- MBean server -->
+ <bean name="MBeanServer"
class="javax.management.MBeanServer">
+ <constructor factoryClass="java.lang.management.ManagementFactory"
+ factoryMethod="getPlatformMBeanServer"/>
+ </bean>
+
+ <!-- The core configuration -->
+ <bean name="Configuration"
class="org.hornetq.core.config.impl.FileConfiguration"/>
+
+ <!-- The security manager -->
+ <bean name="HornetQSecurityManager"
class="org.hornetq.spi.core.security.HornetQSecurityManagerImpl">
+ <start ignored="true"/>
+ <stop ignored="true"/>
+ </bean>
+
+ <!-- The core server -->
+ <bean name="HornetQServer"
class="org.hornetq.core.server.impl.HornetQServerImpl">
+ <constructor>
+ <parameter>
+ <inject bean="Configuration"/>
+ </parameter>
+ <parameter>
+ <inject bean="MBeanServer"/>
+ </parameter>
+ <parameter>
+ <inject bean="HornetQSecurityManager"/>
+ </parameter>
+ </constructor>
+ <start ignored="true"/>
+ <stop ignored="true"/>
+ </bean>
+
+ <!-- The JMS server -->
+ <bean name="JMSServerManager"
class="org.hornetq.jms.server.impl.JMSServerManagerImpl">
+ <constructor>
+ <parameter>
+ <inject bean="HornetQServer"/>
+ </parameter>
+ </constructor>
+ </bean>
+
+</deployment>
Added:
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/hornetq-configuration.xml
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/hornetq-configuration.xml
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/hornetq-configuration.xml 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,83 @@
+<!--
+ ~ Copyright 2009 Red Hat, Inc.
+ ~ Red Hat 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:hornetq"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq
../../../src/schema/hornetq-configuration.xsd">
+ <!-- Connectors -->
+
+ <clustered>true</clustered>
+
+ <backup>true</backup>
+
+ <shared-store>true</shared-store>
+
+ <connectors>
+ <connector name="netty-connector">
+
<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
+ <param key="port" value="5447"/>
+ </connector>
+ </connectors>
+
+ <!-- Acceptors -->
+ <acceptors>
+ <acceptor name="netty-acceptor">
+
<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
+ <param key="port" value="5447"/>
+ </acceptor>
+ </acceptors>
+
+ <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>netty-connector</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>60000</refresh-timeout>
+ </discovery-group>
+ </discovery-groups>
+
+ <cluster-connections>
+ <cluster-connection name="my-cluster">
+ <address>jms</address>
+ <connector-ref>netty-connector</connector-ref>
+ <discovery-group-ref discovery-group-name="dg-group1"/>
+ </cluster-connection>
+ </cluster-connections>
+
+
<large-messages-directory>../server0/data/large-messages</large-messages-directory>
+ <bindings-directory>../server0/data/bindings</bindings-directory>
+ <journal-directory>../server0/data/journal</journal-directory>
+ <paging-directory>../server0/data/paging</paging-directory>
+ <!-- Other config -->
+
+ <security-settings>
+ <!--security for example queue-->
+ <security-setting match="jms.queue.exampleQueue">
+ <permission type="createDurableQueue" roles="guest"/>
+ <permission type="deleteDurableQueue" roles="guest"/>
+ <permission type="createNonDurableQueue"
roles="guest"/>
+ <permission type="deleteNonDurableQueue"
roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security-setting>
+ </security-settings>
+
+</configuration>
Added:
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/hornetq-jms.xml
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/hornetq-jms.xml
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/hornetq-jms.xml 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,33 @@
+<configuration xmlns="urn:hornetq"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
+ <!--the connection factory used by the example-->
+ <connection-factory name="ConnectionFactory">
+ <connectors>
+ <connector-ref connector-name="netty-connector"
backup-connector-name="backup-connector"/>
+ </connectors>
+
+ <entries>
+ <entry name="ConnectionFactory"/>
+ </entries>
+
+ <ha>true</ha>
+ <!-- Pause 1 second between connect attempts -->
+ <retry-interval>1000</retry-interval>
+
+ <!-- Multiply subsequent reconnect pauses by this multiplier. This can be used
to
+ implement an exponential back-off. For our purposes we just set to 1.0 so each
reconnect
+ pause is the same length -->
+ <retry-interval-multiplier>1.0</retry-interval-multiplier>
+
+ <!-- Try reconnecting an unlimited number of times (-1 means
"unlimited") -->
+ <reconnect-attempts>-1</reconnect-attempts>
+ </connection-factory>
+
+ <!--the queue used by the example-->
+ <queue name="exampleQueue">
+ <entry name="/queue/exampleQueue"/>
+ <durable>true</durable>
+ </queue>
+
+</configuration>
Added:
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/hornetq-users.xml
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/hornetq-users.xml
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/server2/hornetq-users.xml 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,7 @@
+<configuration xmlns="urn:hornetq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-users.xsd">
+ <!-- the default user. this is used where username is null-->
+ <defaultuser name="guest" password="guest">
+ <role name="guest"/>
+ </defaultuser>
+</configuration>
\ No newline at end of file
Added:
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/src/org/hornetq/jms/example/MultipleFailoverExample.java
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/src/org/hornetq/jms/example/MultipleFailoverExample.java
(rev 0)
+++
branches/2_2_0_HA_Improvements_preMerge/examples/jms/multiple-failover/src/org/hornetq/jms/example/MultipleFailoverExample.java 2010-11-26
09:46:11 UTC (rev 9928)
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat 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.hornetq.jms.example;
+
+import org.hornetq.common.example.HornetQExample;
+import org.hornetq.jms.client.HornetQConnection;
+
+import javax.jms.*;
+import javax.naming.InitialContext;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.com">Andy Taylor</a>
+ * Date: Nov 4, 2010
+ * Time: 10:51:45 AM
+ */
+public class MultipleFailoverExample extends HornetQExample
+{
+ public static void main(final String[] args)
+ {
+ new MultipleFailoverExample().run(args);
+ }
+
+ @Override
+ public boolean runExample() throws Exception
+ {
+ Thread.sleep(10000);
+ final int numMessages = 30;
+
+ Connection connection = null;
+
+ InitialContext initialContext = null;
+
+ try
+ {
+ // Step 1. Get an initial context for looking up JNDI from the server #1
+ initialContext = getContext(0);
+
+ // Step 2. Look up the JMS resources from JNDI
+ Queue queue = (Queue)initialContext.lookup("/queue/exampleQueue");
+ ConnectionFactory connectionFactory =
(ConnectionFactory)initialContext.lookup("/ConnectionFactory");
+
+ // Step 3. Create a JMS Connection
+ connection = connectionFactory.createConnection();
+
+ // Step 4. Create a *non-transacted* JMS Session with client acknwoledgement
+ Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+
+ // Step 5. Start the connection to ensure delivery occurs
+ connection.start();
+
+ // Step 6. Create a JMS MessageProducer and a MessageConsumer
+ MessageProducer producer = session.createProducer(queue);
+ MessageConsumer consumer = session.createConsumer(queue);
+
+ // Step 7. Send some messages to server #1, the live server
+ for (int i = 0; i < numMessages; i++)
+ {
+ TextMessage message = session.createTextMessage("This is text message
" + i);
+ producer.send(message);
+ System.out.println("Sent message: " + message.getText());
+ }
+
+ // Step 8. Receive and acknowledge a third of the sent messages
+ TextMessage message0 = null;
+ for (int i = 0; i < numMessages / 3; i++)
+ {
+ message0 = (TextMessage)consumer.receive(5000);
+ System.out.println("Got message: " + message0.getText());
+ }
+ message0.acknowledge();
+
+ // Step 9. Receive the rest third of the sent messages but *do not* acknowledge
them yet
+ for (int i = numMessages / 3; i < numMessages; i++)
+ {
+ message0 = (TextMessage)consumer.receive(5000);
+ System.out.println("Got message: " + message0.getText());
+ }
+
+ // Step 10. Crash server #1, the live server, and wait a little while to make
sure
+ // it has really crashed
+ killServer(0);
+
+ // Step 11. Acknowledging the 2nd half of the sent messages will fail as
failover to the
+ // backup server has occurred
+ try
+ {
+ message0.acknowledge();
+ }
+ catch (JMSException e)
+ {
+ System.err.println("Got exception while acknowledging message: " +
e.getMessage());
+ }
+
+ // Step 12. Consume again the 2nd half of the messages again. Note that they are
not considered as redelivered.
+ for (int i = numMessages / 3; i < numMessages; i++)
+ {
+ message0 = (TextMessage)consumer.receive(5000);
+ System.out.printf("Got message: %s (redelivered?: %s)\n",
message0.getText(), message0.getJMSRedelivered());
+ }
+ message0.acknowledge();
+
+ return true;
+ }
+ finally
+ {
+ // Step 13. Be sure to close our resources!
+
+ if (connection != null)
+ {
+ connection.close();
+ }
+
+ if (initialContext != null)
+ {
+ initialContext.close();
+ }
+ }
+ }
+}
Modified:
branches/2_2_0_HA_Improvements_preMerge/src/main/org/hornetq/core/server/impl/FileLockNodeManager.java
===================================================================
---
branches/2_2_0_HA_Improvements_preMerge/src/main/org/hornetq/core/server/impl/FileLockNodeManager.java 2010-11-25
08:14:27 UTC (rev 9927)
+++
branches/2_2_0_HA_Improvements_preMerge/src/main/org/hornetq/core/server/impl/FileLockNodeManager.java 2010-11-26
09:46:11 UTC (rev 9928)
@@ -34,7 +34,7 @@
{
private static final Logger log = Logger.getLogger(FileLockNodeManager.class);
- private final String SERVER_LOCK_NAME = "server.lock";
+ private static final String SERVER_LOCK_NAME = "server.lock";
private static final String ACCESS_MODE = "rw";
@@ -126,16 +126,16 @@
{
do
{
- while (getState() == NOT_STARTED)
+ byte state = getState();
+ while (state == NOT_STARTED || state == 0)
{
- log.info("awaiting live node startup");
+ log.info("awaiting live node startup state='" + state +
"'");
Thread.sleep(2000);
+ state = getState();
}
liveLock = channel.lock(LIVE_LOCK_POS, 1, false);
-
- byte state = getState();
-
+ state = getState();
if (state == PAUSED)
{
liveLock.release();
@@ -162,7 +162,6 @@
log.info("Waiting to become backup node");
backupLock = channel.lock(BACKUP_LOCK_POS, LOCK_LENGTH, false);
-
log.info("** got backup lock");
readNodeId();