JBoss hornetq SVN: r8988 - in trunk: src/main/org/hornetq/core/server and 7 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2010-03-28 22:53:39 -0400 (Sun, 28 Mar 2010)
New Revision: 8988
Added:
trunk/tests/src/org/hornetq/tests/integration/jms/cluster/ReplicatedJMSFailoverTest.java
Modified:
trunk/src/main/org/hornetq/core/replication/ReplicationEndpoint.java
trunk/src/main/org/hornetq/core/server/HornetQServer.java
trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
trunk/src/main/org/hornetq/jms/persistence/JMSStorageManager.java
trunk/src/main/org/hornetq/jms/persistence/impl/journal/JournalJMSStorageManagerImpl.java
trunk/src/main/org/hornetq/jms/persistence/impl/nullpm/NullJMSStorageManagerImpl.java
trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
trunk/tests/src/org/hornetq/tests/integration/jms/cluster/JMSFailoverTest.java
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java
Log:
Replication on JMS journal
Modified: trunk/src/main/org/hornetq/core/replication/ReplicationEndpoint.java
===================================================================
--- trunk/src/main/org/hornetq/core/replication/ReplicationEndpoint.java 2010-03-28 21:01:50 UTC (rev 8987)
+++ trunk/src/main/org/hornetq/core/replication/ReplicationEndpoint.java 2010-03-29 02:53:39 UTC (rev 8988)
@@ -14,6 +14,7 @@
package org.hornetq.core.replication;
import org.hornetq.api.core.HornetQException;
+import org.hornetq.core.journal.Journal;
import org.hornetq.core.journal.JournalLoadInformation;
import org.hornetq.core.protocol.core.Channel;
import org.hornetq.core.protocol.core.ChannelHandler;
@@ -35,4 +36,6 @@
void compareJournalInformation(JournalLoadInformation[] journalInformation) throws HornetQException;
+ void registerJournal(final byte id, final Journal journal);
+
}
Modified: trunk/src/main/org/hornetq/core/server/HornetQServer.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/HornetQServer.java 2010-03-28 21:01:50 UTC (rev 8987)
+++ trunk/src/main/org/hornetq/core/server/HornetQServer.java 2010-03-29 02:53:39 UTC (rev 8988)
@@ -26,6 +26,7 @@
import org.hornetq.core.protocol.core.Channel;
import org.hornetq.core.remoting.server.RemotingService;
import org.hornetq.core.replication.ReplicationEndpoint;
+import org.hornetq.core.replication.ReplicationManager;
import org.hornetq.core.security.Role;
import org.hornetq.core.server.cluster.ClusterManager;
import org.hornetq.core.server.group.GroupingHandler;
@@ -135,6 +136,10 @@
void setGroupingHandler(GroupingHandler groupingHandler);
GroupingHandler getGroupingHandler();
+
+ ReplicationEndpoint getReplicationEndpoint();
+
+ ReplicationManager getReplicationManager();
boolean checkActivate() throws Exception;
}
Modified: trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2010-03-28 21:01:50 UTC (rev 8987)
+++ trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2010-03-29 02:53:39 UTC (rev 8988)
@@ -750,15 +750,19 @@
return groupingHandler;
}
- // Public
- // ---------------------------------------------------------------------------------------
-
- /** For tests only */
public ReplicationEndpoint getReplicationEndpoint()
{
return replicationEndpoint;
}
+
+ public ReplicationManager getReplicationManager()
+ {
+ return replicationManager;
+ }
+ // Public
+ // ---------------------------------------------------------------------------------------
+
// Package protected
// ----------------------------------------------------------------------------
Modified: trunk/src/main/org/hornetq/jms/persistence/JMSStorageManager.java
===================================================================
--- trunk/src/main/org/hornetq/jms/persistence/JMSStorageManager.java 2010-03-28 21:01:50 UTC (rev 8987)
+++ trunk/src/main/org/hornetq/jms/persistence/JMSStorageManager.java 2010-03-29 02:53:39 UTC (rev 8988)
@@ -15,6 +15,7 @@
import java.util.List;
+import org.hornetq.core.replication.ReplicationEndpoint;
import org.hornetq.core.server.HornetQComponent;
import org.hornetq.jms.persistence.config.PersistedConnectionFactory;
import org.hornetq.jms.persistence.config.PersistedDestination;
@@ -40,7 +41,9 @@
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
-
+
+ void load() throws Exception;
+
void storeDestination(PersistedDestination destination) throws Exception;
void deleteDestination(PersistedType type, String name) throws Exception;
@@ -68,4 +71,11 @@
void deleteJNDI(PersistedType type, String name, String address) throws Exception;
void deleteJNDI(PersistedType type, String name) throws Exception;
+
+ /**
+ * Add the journal here to the replication endpoint
+ * @param replicationEndpoint
+ * @throws Exception
+ */
+ void installReplication(ReplicationEndpoint replicationEndpoint) throws Exception;
}
Modified: trunk/src/main/org/hornetq/jms/persistence/impl/journal/JournalJMSStorageManagerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/persistence/impl/journal/JournalJMSStorageManagerImpl.java 2010-03-28 21:01:50 UTC (rev 8987)
+++ trunk/src/main/org/hornetq/jms/persistence/impl/journal/JournalJMSStorageManagerImpl.java 2010-03-29 02:53:39 UTC (rev 8988)
@@ -22,7 +22,6 @@
import org.hornetq.api.core.HornetQBuffer;
import org.hornetq.api.core.HornetQBuffers;
import org.hornetq.api.core.Pair;
-import org.hornetq.api.core.SimpleString;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.journal.Journal;
import org.hornetq.core.journal.PreparedTransactionInfo;
@@ -30,6 +29,7 @@
import org.hornetq.core.journal.SequentialFileFactory;
import org.hornetq.core.journal.impl.JournalImpl;
import org.hornetq.core.journal.impl.NIOSequentialFileFactory;
+import org.hornetq.core.replication.ReplicationEndpoint;
import org.hornetq.core.replication.ReplicationManager;
import org.hornetq.core.replication.impl.ReplicatedJournal;
import org.hornetq.core.server.JournalType;
@@ -38,7 +38,6 @@
import org.hornetq.jms.persistence.config.PersistedDestination;
import org.hornetq.jms.persistence.config.PersistedJNDI;
import org.hornetq.jms.persistence.config.PersistedType;
-import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
import org.hornetq.utils.IDGenerator;
/**
@@ -290,27 +289,31 @@
jmsJournal.start();
- load();
-
started = true;
}
+
/* (non-Javadoc)
+ * @see org.hornetq.jms.persistence.JMSStorageManager#installReplication(org.hornetq.core.replication.ReplicationEndpoint)
+ */
+ public void installReplication(ReplicationEndpoint replicationEndpoint) throws Exception
+ {
+ jmsJournal.loadInternalOnly();
+ replicationEndpoint.registerJournal((byte)2, this.jmsJournal);
+ }
+
+
+ /* (non-Javadoc)
* @see org.hornetq.core.server.HornetQComponent#stop()
*/
public void stop() throws Exception
{
+ this.started = false;
jmsJournal.stop();
}
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- private void load() throws Exception
+ public void load() throws Exception
{
mapFactories.clear();
@@ -359,6 +362,13 @@
}
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+
private void checkAndCreateDir(final String dir, final boolean create)
{
File f = new File(dir);
@@ -380,6 +390,7 @@
}
+
// Inner classes -------------------------------------------------
}
Modified: trunk/src/main/org/hornetq/jms/persistence/impl/nullpm/NullJMSStorageManagerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/persistence/impl/nullpm/NullJMSStorageManagerImpl.java 2010-03-28 21:01:50 UTC (rev 8987)
+++ trunk/src/main/org/hornetq/jms/persistence/impl/nullpm/NullJMSStorageManagerImpl.java 2010-03-29 02:53:39 UTC (rev 8988)
@@ -16,6 +16,7 @@
import java.util.Collections;
import java.util.List;
+import org.hornetq.core.replication.ReplicationEndpoint;
import org.hornetq.jms.persistence.JMSStorageManager;
import org.hornetq.jms.persistence.config.PersistedConnectionFactory;
import org.hornetq.jms.persistence.config.PersistedDestination;
@@ -136,6 +137,20 @@
return Collections.emptyList();
}
+ /* (non-Javadoc)
+ * @see org.hornetq.jms.persistence.JMSStorageManager#installReplication(org.hornetq.core.replication.ReplicationEndpoint)
+ */
+ public void installReplication(ReplicationEndpoint replicationEndpoint) throws Exception
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.hornetq.jms.persistence.JMSStorageManager#load()
+ */
+ public void load() throws Exception
+ {
+ }
+
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
Modified: trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2010-03-28 21:01:50 UTC (rev 8987)
+++ trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2010-03-29 02:53:39 UTC (rev 8988)
@@ -13,7 +13,14 @@
package org.hornetq.jms.server.impl;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import javax.naming.Context;
import javax.naming.InitialContext;
@@ -33,7 +40,6 @@
import org.hornetq.core.deployers.impl.FileDeploymentManager;
import org.hornetq.core.deployers.impl.XmlDeployer;
import org.hornetq.core.logging.Logger;
-import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.BindingType;
import org.hornetq.core.security.Role;
@@ -125,12 +131,16 @@
{
this.server = server;
+ this.coreConfig = server.getConfiguration();
+
configFileName = null;
}
public JMSServerManagerImpl(final HornetQServer server, final String configFileName) throws Exception
{
this.server = server;
+
+ this.coreConfig = server.getConfiguration();
this.configFileName = configFileName;
}
@@ -138,6 +148,8 @@
public JMSServerManagerImpl(final HornetQServer server, final JMSConfiguration configuration) throws Exception
{
this.server = server;
+
+ this.coreConfig = server.getConfiguration();
configFileName = null;
@@ -213,9 +225,16 @@
deploymentManager = new FileDeploymentManager(server.getConfiguration().getFileDeployerScanPeriod());
server.registerActivateCallback(this);
-
+
server.start();
+
+ if (server.getReplicationEndpoint() != null)
+ {
+ createJournal();
+ storage.installReplication(server.getReplicationEndpoint());
+ }
+
started = true;
}
@@ -235,11 +254,18 @@
{
deploymentManager.stop();
}
+
+ // Storage could be null on a shared store backup server before initialization
+ if (storage != null)
+ {
+ storage.stop();
+ }
+
+ unbindJNDI(queueJNDI);
- // for (String destination : destinationBindings.keySet())
- // {
- // undeployDestination(destination);
- // }
+ unbindJNDI(topicJNDI);
+
+ unbindJNDI(connectionFactoryJNDI);
for (String connectionFactory : new HashSet<String>(connectionFactories.keySet()))
{
@@ -255,10 +281,14 @@
context.close();
}
- jmsManagementService.unregisterJMSServer();
-
- jmsManagementService.stop();
-
+ // it could be null if a backup
+ if (jmsManagementService != null)
+ {
+ jmsManagementService.unregisterJMSServer();
+
+ jmsManagementService.stop();
+ }
+
server.stop();
started = false;
@@ -1338,27 +1368,38 @@
}
/**
- * @param server
+ * @param param
*/
- private void initJournal() throws Exception
+ private void unbindJNDI(Map<String, List<String>> param)
{
- this.coreConfig = server.getConfiguration();
-
- if (storage == null)
+ for (List<String> elementList : param.values())
{
- if (coreConfig.isPersistenceEnabled())
+ for (String key : elementList)
{
- // TODO: replication
- storage = new JournalJMSStorageManagerImpl(new TimeAndCounterIDGenerator(), coreConfig, null);
+ try
+ {
+ context.unbind(key);
+ }
+ catch (Exception e)
+ {
+ log.warn("Impossible to unbind key " + key + " from JNDI");
+ }
}
- else
- {
- storage = new NullJMSStorageManagerImpl();
- }
}
+ }
- storage.start();
+ /**
+ * @param server
+ */
+ private void initJournal() throws Exception
+ {
+ this.coreConfig = server.getConfiguration();
+
+ createJournal();
+
+ storage.load();
+
List<PersistedConnectionFactory> cfs = storage.recoverConnectionFactories();
for (PersistedConnectionFactory cf : cfs)
@@ -1428,6 +1469,33 @@
}
}
+ /**
+ * @throws Exception
+ */
+ private void createJournal() throws Exception
+ {
+ if (storage == null)
+ {
+ if (coreConfig.isPersistenceEnabled())
+ {
+ storage = new JournalJMSStorageManagerImpl(new TimeAndCounterIDGenerator(), server.getConfiguration(), server.getReplicationManager());
+ }
+ else
+ {
+ storage = new NullJMSStorageManagerImpl();
+ }
+ }
+ else
+ {
+ if (storage.isStarted())
+ {
+ storage.stop();
+ }
+ }
+
+ storage.start();
+ }
+
private synchronized boolean removeFromJNDI(final Map<String, List<String>> jndiMap, final String name) throws Exception
{
checkInitialised();
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/cluster/JMSFailoverTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/cluster/JMSFailoverTest.java 2010-03-28 21:01:50 UTC (rev 8987)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/cluster/JMSFailoverTest.java 2010-03-29 02:53:39 UTC (rev 8988)
@@ -26,6 +26,7 @@
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
+import javax.naming.NamingException;
import junit.framework.Assert;
@@ -45,7 +46,10 @@
import org.hornetq.jms.client.HornetQConnectionFactory;
import org.hornetq.jms.client.HornetQDestination;
import org.hornetq.jms.client.HornetQSession;
+import org.hornetq.jms.server.JMSServerManager;
+import org.hornetq.jms.server.impl.JMSServerManagerImpl;
import org.hornetq.spi.core.protocol.RemotingConnection;
+import org.hornetq.tests.unit.util.InVMContext;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.UnitTestCase;
@@ -69,12 +73,24 @@
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
+
+ protected InVMContext ctx1 = new InVMContext();
+
+ protected InVMContext ctx2 = new InVMContext();
+
+ protected Configuration backupConf;
+
+ protected Configuration liveConf;
+
+ protected JMSServerManager liveJMSService;
- private HornetQServer liveService;
+ protected HornetQServer liveService;
+
+ protected JMSServerManager backupJMSService;
- private HornetQServer backupService;
+ protected HornetQServer backupService;
- private Map<String, Object> backupParams = new HashMap<String, Object>();
+ protected Map<String, Object> backupParams = new HashMap<String, Object>();
// Static --------------------------------------------------------
@@ -82,6 +98,63 @@
// Public --------------------------------------------------------
+ public void testCreateQueue() throws Exception
+ {
+ liveJMSService.createQueue("queue1", null, true, "/queue/queue1");
+ assertNotNull(ctx1.lookup("/queue/queue1"));
+ liveJMSService.stop();
+
+ Object obj = null;
+
+ try
+ {
+ obj = ctx1.lookup("/queue/queue1");
+ }
+ catch (NamingException expected)
+ {
+
+ }
+
+ assertNull(obj);
+
+ backupJMSService.stop();
+
+ backupConf.setBackup(false);
+
+ backupJMSService.start();
+
+ assertNotNull(ctx2.lookup("/queue/queue1"));
+ }
+
+
+ public void testCreateTopic() throws Exception
+ {
+ liveJMSService.createTopic("topic", "/topic/t1");
+ assertNotNull(ctx1.lookup("//topic/t1"));
+ liveJMSService.stop();
+
+ Object obj = null;
+
+ try
+ {
+ obj = ctx1.lookup("//topic/t1");
+ }
+ catch (NamingException expected)
+ {
+
+ }
+
+ assertNull(obj);
+
+ backupJMSService.stop();
+
+ backupConf.setBackup(false);
+
+ backupJMSService.start();
+
+ assertNotNull(ctx2.lookup("/topic/t1"));
+ }
+
public void testAutomaticFailover() throws Exception
{
HornetQConnectionFactory jbcf = (HornetQConnectionFactory) HornetQJMSClient.createConnectionFactory(new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory"),
@@ -258,7 +331,15 @@
{
super.setUp();
- Configuration backupConf = new ConfigurationImpl();
+ startServers();
+ }
+
+ /**
+ * @throws Exception
+ */
+ protected void startServers() throws Exception
+ {
+ backupConf = new ConfigurationImpl();
backupConf.setSecurityEnabled(false);
backupParams.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
backupConf.getAcceptorConfigurations()
@@ -271,9 +352,16 @@
backupConf.setPagingDirectory(getPageDir());
backupConf.setLargeMessagesDirectory(getLargeMessagesDir());
backupService = HornetQServers.newHornetQServer(backupConf, true);
- backupService.start();
- Configuration liveConf = new ConfigurationImpl();
+ backupJMSService = new JMSServerManagerImpl(backupService);
+
+ backupJMSService.setContext(ctx2);
+
+ backupJMSService.start();
+
+
+
+ liveConf = new ConfigurationImpl();
liveConf.setSecurityEnabled(false);
liveConf.getAcceptorConfigurations()
.add(new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory"));
@@ -285,19 +373,33 @@
liveConf.setLargeMessagesDirectory(getLargeMessagesDir());
liveService = HornetQServers.newHornetQServer(liveConf, true);
- liveService.start();
+
+ liveJMSService = new JMSServerManagerImpl(liveService);
+
+ liveJMSService.setContext(ctx1);
+
+ liveJMSService.start();
+
}
@Override
protected void tearDown() throws Exception
{
- backupService.stop();
+ backupJMSService.stop();
- liveService.stop();
+ liveJMSService.stop();
Assert.assertEquals(0, InVMRegistry.instance.size());
liveService = null;
+
+ liveJMSService = null;
+
+ backupJMSService = null;
+
+ ctx1 = null;
+
+ ctx2 = null;
backupService = null;
Added: trunk/tests/src/org/hornetq/tests/integration/jms/cluster/ReplicatedJMSFailoverTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/cluster/ReplicatedJMSFailoverTest.java (rev 0)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/cluster/ReplicatedJMSFailoverTest.java 2010-03-29 02:53:39 UTC (rev 8988)
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2010 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.tests.integration.jms.cluster;
+
+import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.core.config.impl.ConfigurationImpl;
+import org.hornetq.core.remoting.impl.invm.TransportConstants;
+import org.hornetq.core.server.HornetQServers;
+import org.hornetq.jms.server.impl.JMSServerManagerImpl;
+
+/**
+ * A ReplicatedJMSFailoverTest
+ *
+ * @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class ReplicatedJMSFailoverTest extends JMSFailoverTest
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+ /**
+ * @throws Exception
+ */
+ @Override
+ protected void startServers() throws Exception
+ {
+ backupConf = new ConfigurationImpl();
+ backupConf.setSecurityEnabled(false);
+ backupParams.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
+ backupConf.getAcceptorConfigurations()
+ .add(new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory", backupParams));
+ backupConf.setBackup(true);
+ backupConf.setSharedStore(false);
+ backupConf.setBindingsDirectory(getBindingsDir(0, true));
+ backupConf.setJournalMinFiles(2);
+ backupConf.setJournalDirectory(getJournalDir(0, true));
+ backupConf.setPagingDirectory(getPageDir(0, true));
+ backupConf.setLargeMessagesDirectory(getLargeMessagesDir(0, true));
+ backupService = HornetQServers.newHornetQServer(backupConf, true);
+
+ backupJMSService = new JMSServerManagerImpl(backupService);
+
+ backupJMSService.setContext(ctx2);
+
+ backupJMSService.start();
+
+
+
+ liveConf = new ConfigurationImpl();
+ liveConf.setSecurityEnabled(false);
+
+ liveConf.getConnectorConfigurations().put("toBackup", new TransportConfiguration(INVM_CONNECTOR_FACTORY, backupParams));
+ liveConf.setBackupConnectorName("toBackup");
+
+ liveConf.getAcceptorConfigurations()
+ .add(new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory"));
+ liveConf.setSharedStore(false);
+ liveConf.setBindingsDirectory(getBindingsDir(0, false));
+ liveConf.setJournalMinFiles(2);
+ liveConf.setJournalDirectory(getJournalDir(0, false));
+ liveConf.setPagingDirectory(getPageDir(0, false));
+ liveConf.setLargeMessagesDirectory(getLargeMessagesDir(0, false));
+
+ liveService = HornetQServers.newHornetQServer(liveConf, true);
+
+ liveJMSService = new JMSServerManagerImpl(liveService);
+
+ liveJMSService.setContext(ctx1);
+
+ liveJMSService.start();
+
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java 2010-03-28 21:01:50 UTC (rev 8987)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java 2010-03-29 02:53:39 UTC (rev 8988)
@@ -35,6 +35,7 @@
import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
import org.hornetq.core.remoting.impl.invm.TransportConstants;
+import org.hornetq.core.replication.ReplicationEndpoint;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
import org.hornetq.jms.client.HornetQConnectionFactory;
@@ -599,6 +600,20 @@
{
return false; //To change body of implemented methods use File | Settings | File Templates.
}
+
+ /* (non-Javadoc)
+ * @see org.hornetq.jms.persistence.JMSStorageManager#installReplication(org.hornetq.core.replication.ReplicationEndpoint)
+ */
+ public void installReplication(ReplicationEndpoint replicationEndpoint) throws Exception
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see org.hornetq.jms.persistence.JMSStorageManager#load()
+ */
+ public void load() throws Exception
+ {
+ }
}
}
\ No newline at end of file
15 years, 9 months
JBoss hornetq SVN: r8987 - trunk/src/main/org/hornetq/jms/management/impl.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2010-03-28 17:01:50 -0400 (Sun, 28 Mar 2010)
New Revision: 8987
Modified:
trunk/src/main/org/hornetq/jms/management/impl/JMSConnectionFactoryControlImpl.java
Log:
Fixing a typo
Modified: trunk/src/main/org/hornetq/jms/management/impl/JMSConnectionFactoryControlImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/management/impl/JMSConnectionFactoryControlImpl.java 2010-03-28 20:32:11 UTC (rev 8986)
+++ trunk/src/main/org/hornetq/jms/management/impl/JMSConnectionFactoryControlImpl.java 2010-03-28 21:01:50 UTC (rev 8987)
@@ -320,7 +320,7 @@
public void addJNDI(@Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndi) throws Exception
{
- jmsManager.addQueueToJndi(name, jndi);
+ jmsManager.addConnectionFactoryToJNDI(name, jndi);
}
public long getCallTimeout()
15 years, 9 months
JBoss hornetq SVN: r8986 - trunk/tests/src/org/hornetq/tests/integration/persistence.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2010-03-28 16:32:11 -0400 (Sun, 28 Mar 2010)
New Revision: 8986
Modified:
trunk/tests/src/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java
Log:
adding test
Modified: trunk/tests/src/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java 2010-03-28 20:16:02 UTC (rev 8985)
+++ trunk/tests/src/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java 2010-03-28 20:32:11 UTC (rev 8986)
@@ -67,14 +67,18 @@
{
createJMSStorage();
-
- String str[] = new String[5];
- for (int i = 0; i < 5; i++)
+
+ List<Pair<TransportConfiguration, TransportConfiguration>> transportConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
+
+ for (int i = 0 ; i < 5; i++)
{
- str[i] = "str" + i;
+ TransportConfiguration config1 = new TransportConfiguration("c1-" + i);
+ TransportConfiguration config2 = new TransportConfiguration("c2-" + i);
+ transportConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(config1, config2));
}
+
- ConnectionFactoryConfiguration config = new ConnectionFactoryConfigurationImpl("some-name", str);
+ ConnectionFactoryConfiguration config = new ConnectionFactoryConfigurationImpl("some-name", transportConfigs);
addSetting(new PersistedConnectionFactory(config));
@@ -87,12 +91,18 @@
assertEquals(1, cfs.size());
assertEquals("some-name", cfs.get(0).getName());
-
- assertEquals(5, cfs.get(0).getConfig().getBindings().length);
-
- for (int i = 0; i < 5; i++)
+
+ PersistedConnectionFactory cf1 = cfs.get(0);
+
+ assertEquals(5, cf1.getConfig().getConnectorConfigs().size());
+
+ int i = 0 ;
+ for (Pair<TransportConfiguration, TransportConfiguration> itemCf : cf1.getConfig().getConnectorConfigs())
{
- assertEquals("str" + i, cfs.get(0).getConfig().getBindings()[i]);
+
+ assertEquals(itemCf.a.toString(), "c1-" + i);
+ assertEquals(itemCf.b.toString(), "c2-" + i);
+ i++;
}
}
15 years, 9 months
JBoss hornetq SVN: r8985 - trunk/src/main/org/hornetq/jms/server/config/impl.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2010-03-28 16:16:02 -0400 (Sun, 28 Mar 2010)
New Revision: 8985
Modified:
trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java
Log:
tweak on persistence
Modified: trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java 2010-03-28 19:53:46 UTC (rev 8984)
+++ trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java 2010-03-28 20:16:02 UTC (rev 8985)
@@ -552,8 +552,6 @@
{
name = buffer.readSimpleString().toString();
- int nbindings = buffer.readInt();
-
discoveryGroupName = BufferHelper.readNullableSimpleStringAsString(buffer);
discoveryAddress = BufferHelper.readNullableSimpleStringAsString(buffer);
15 years, 9 months
JBoss hornetq SVN: r8984 - branches.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2010-03-28 15:53:46 -0400 (Sun, 28 Mar 2010)
New Revision: 8984
Removed:
branches/Clebert_TMP/
Log:
removing temporary branch
15 years, 9 months
JBoss hornetq SVN: r8983 - trunk/src/main/org/hornetq/jms/server/impl.
by do-not-reply@jboss.org
Author: ataylor
Date: 2010-03-27 15:06:47 -0400 (Sat, 27 Mar 2010)
New Revision: 8983
Modified:
trunk/src/main/org/hornetq/jms/server/impl/JMSServerConfigParserImpl.java
Log:
fixed jmsserverconfigparser
Modified: trunk/src/main/org/hornetq/jms/server/impl/JMSServerConfigParserImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/impl/JMSServerConfigParserImpl.java 2010-03-27 16:37:38 UTC (rev 8982)
+++ trunk/src/main/org/hornetq/jms/server/impl/JMSServerConfigParserImpl.java 2010-03-27 19:06:47 UTC (rev 8983)
@@ -364,15 +364,18 @@
ConnectionFactoryConfiguration cfConfig;
+ String[] strbindings = jndiBindings.toArray(new String[jndiBindings.size()]);
+
if (discoveryGroupName != null)
{
- cfConfig = new ConnectionFactoryConfigurationImpl(name);
+ cfConfig = new ConnectionFactoryConfigurationImpl(name,
+ strbindings);
cfConfig.setInitialWaitTimeout(discoveryInitialWaitTimeout);
cfConfig.setDiscoveryGroupName(discoveryGroupName);
}
else
{
- cfConfig = new ConnectionFactoryConfigurationImpl(name);
+ cfConfig = new ConnectionFactoryConfigurationImpl(name, strbindings);
cfConfig.setConnectorNames(connectorNames);
}
15 years, 9 months
JBoss hornetq SVN: r8982 - trunk/src/main/org/hornetq/jms/server/impl.
by do-not-reply@jboss.org
Author: ataylor
Date: 2010-03-27 12:37:38 -0400 (Sat, 27 Mar 2010)
New Revision: 8982
Modified:
trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
Log:
fixed jmsserver manager
Modified: trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2010-03-27 13:18:24 UTC (rev 8981)
+++ trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2010-03-27 16:37:38 UTC (rev 8982)
@@ -1310,7 +1310,7 @@
List<ConnectionFactoryConfiguration> connectionFactoryConfigurations = config.getConnectionFactoryConfigurations();
for (ConnectionFactoryConfiguration config : connectionFactoryConfigurations)
{
- createConnectionFactory(config);
+ createConnectionFactory(config, config.getBindings());
}
List<JMSQueueConfiguration> queueConfigs = config.getQueueConfigurations();
15 years, 9 months
JBoss hornetq SVN: r8981 - in trunk: tests/src/org/hornetq/tests/integration/persistence and 1 other directory.
by do-not-reply@jboss.org
Author: jmesnil
Date: 2010-03-27 09:18:24 -0400 (Sat, 27 Mar 2010)
New Revision: 8981
Added:
trunk/src/main/org/hornetq/jms/server/config/impl/TransportConfigurationEncodingSupport.java
trunk/tests/src/org/hornetq/tests/integration/persistence/TransportConfigurationEncodingSupportTest.java
Modified:
trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java
trunk/tests/src/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java
Log:
JMS Configuration persistence
* persist TransportConfiguration connectorConfigs from ConnectionFactoryConfigurationImpl
Modified: trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java 2010-03-27 12:41:58 UTC (rev 8980)
+++ trunk/src/main/org/hornetq/jms/server/config/impl/ConnectionFactoryConfigurationImpl.java 2010-03-27 13:18:24 UTC (rev 8981)
@@ -14,7 +14,6 @@
package org.hornetq.jms.server.config.impl;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import org.hornetq.api.core.HornetQBuffer;
@@ -574,6 +573,8 @@
connectorNames.add(new Pair<String, String>(a, b));
}
+ connectorConfigs = TransportConfigurationEncodingSupport.decodeConfigs(buffer);
+
clientID = BufferHelper.readNullableSimpleStringAsString(buffer);
discoveryRefreshTimeout = buffer.readLong();
@@ -659,6 +660,8 @@
}
}
+ TransportConfigurationEncodingSupport.encodeConfigs(buffer, connectorConfigs);
+
BufferHelper.writeAsNullableSimpleString(buffer, clientID);
buffer.writeLong(discoveryRefreshTimeout);
@@ -752,6 +755,8 @@
sizeOfConnectors() +
+ TransportConfigurationEncodingSupport.getEncodeSize(connectorConfigs) +
+
BufferHelper.sizeOfNullableSimpleString(clientID) +
DataConstants.SIZE_LONG + // discoveryRefreshTimeout
Added: trunk/src/main/org/hornetq/jms/server/config/impl/TransportConfigurationEncodingSupport.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/config/impl/TransportConfigurationEncodingSupport.java (rev 0)
+++ trunk/src/main/org/hornetq/jms/server/config/impl/TransportConfigurationEncodingSupport.java 2010-03-27 13:18:24 UTC (rev 8981)
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2010 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.server.config.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.api.core.Pair;
+import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.utils.BufferHelper;
+import org.hornetq.utils.DataConstants;
+
+/**
+ * A TransportConfigurationEncodingSupport
+ *
+ * @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
+ *
+ *
+ */
+public class TransportConfigurationEncodingSupport
+{
+ public static List<Pair<TransportConfiguration, TransportConfiguration>> decodeConfigs(HornetQBuffer buffer)
+ {
+ int size = buffer.readInt();
+ List<Pair<TransportConfiguration, TransportConfiguration>> configs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>(size);
+
+ for (int i = 0; i < size; i++)
+ {
+ TransportConfiguration live = decode(buffer);
+ boolean hasBackup = buffer.readBoolean();
+ TransportConfiguration backup = null;
+ if (hasBackup)
+ {
+ backup = decode(buffer);
+ }
+ configs.add(new Pair<TransportConfiguration, TransportConfiguration>(live, backup));
+ }
+
+ return configs;
+ }
+
+ public static TransportConfiguration decode(HornetQBuffer buffer)
+ {
+ String name = BufferHelper.readNullableSimpleStringAsString(buffer);
+ String factoryClassName = buffer.readSimpleString().toString();
+ int paramSize = buffer.readInt();
+ Map<String, Object> params = new HashMap<String, Object>();
+ for (int i = 0; i < paramSize; i++)
+ {
+ String key = buffer.readSimpleString().toString();
+ String value = buffer.readSimpleString().toString();
+ params.put(key, value);
+ }
+ TransportConfiguration config = new TransportConfiguration(factoryClassName, params, name);
+ return config;
+ }
+
+ public static void encodeConfigs(HornetQBuffer buffer,
+ List<Pair<TransportConfiguration, TransportConfiguration>> configs)
+ {
+ buffer.writeInt(configs == null ? 0 : configs.size());
+ if (configs != null)
+ {
+ for (Pair<TransportConfiguration, TransportConfiguration> pair : configs)
+ {
+ encode(buffer, pair.a);
+ boolean backup = (pair.b != null);
+ buffer.writeBoolean(backup);
+ if (backup)
+ {
+ encode(buffer, pair.b);
+ }
+ }
+ }
+ }
+
+ public static void encode(HornetQBuffer buffer, TransportConfiguration config)
+ {
+ BufferHelper.writeAsNullableSimpleString(buffer, config.getName());
+ BufferHelper.writeAsSimpleString(buffer, config.getFactoryClassName());
+ buffer.writeInt(config.getParams().size());
+ for (Entry<String, Object> param : config.getParams().entrySet())
+ {
+ BufferHelper.writeAsSimpleString(buffer, param.getKey());
+ BufferHelper.writeAsSimpleString(buffer, param.getValue().toString());
+ }
+ }
+
+ public static int getEncodeSize(TransportConfiguration config)
+ {
+ int size = BufferHelper.sizeOfNullableSimpleString(config.getName()) +
+ BufferHelper.sizeOfSimpleString(config.getFactoryClassName());
+
+ size += DataConstants.SIZE_INT; // number of params
+ for (Entry<String, Object> param : config.getParams().entrySet())
+ {
+ size += BufferHelper.sizeOfSimpleString(param.getKey());
+ size += BufferHelper.sizeOfSimpleString(param.getValue().toString());
+ }
+ return size;
+ }
+
+ public static int getEncodeSize(List<Pair<TransportConfiguration, TransportConfiguration>> configs)
+ {
+ int size = DataConstants.SIZE_INT; // number of configs;
+ if (configs != null)
+ {
+ for (Pair<TransportConfiguration, TransportConfiguration> pair : configs)
+ {
+ size += getEncodeSize(pair.a);
+ size += DataConstants.SIZE_BOOLEAN; // whether there is a backup config
+ if (pair.b != null)
+ {
+ size += getEncodeSize(pair.b);
+ }
+ }
+ }
+ return size;
+ }
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Modified: trunk/tests/src/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java 2010-03-27 12:41:58 UTC (rev 8980)
+++ trunk/tests/src/org/hornetq/tests/integration/persistence/JMSConnectionFactoryConfigurationStorageTest.java 2010-03-27 13:18:24 UTC (rev 8981)
@@ -13,15 +13,21 @@
package org.hornetq.tests.integration.persistence;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.hornetq.api.core.HornetQBuffer;
import org.hornetq.api.core.HornetQBuffers;
+import org.hornetq.api.core.Pair;
+import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.integration.transports.netty.NettyConnectorFactory;
+import org.hornetq.integration.transports.netty.TransportConstants;
import org.hornetq.jms.persistence.config.PersistedConnectionFactory;
import org.hornetq.jms.server.config.ConnectionFactoryConfiguration;
import org.hornetq.jms.server.config.impl.ConnectionFactoryConfigurationImpl;
+import org.hornetq.tests.util.RandomUtil;
/**
* A JMSConnectionFactoryConfigurationStorageTest
@@ -120,7 +126,61 @@
assertEquals(size, buffer.writerIndex());
}
+
+ public void testSettingsWithConnectorConfigs() throws Exception
+ {
+ createJMSStorage();
+
+ String str[] = new String[5];
+ for (int i = 0; i < 5; i++)
+ {
+ str[i] = "str" + i;
+ }
+
+ ConnectionFactoryConfiguration config = new ConnectionFactoryConfigurationImpl("some-name", str);
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration,TransportConfiguration>>();
+ Map<String, Object> liveParams = new HashMap<String, Object>();
+ liveParams.put(TransportConstants.PORT_PROP_NAME, 5665);
+ TransportConfiguration live1 = new TransportConfiguration(NettyConnectorFactory.class.getName(), liveParams );
+ Map<String, Object> backupParams = new HashMap<String, Object>();
+ backupParams.put(TransportConstants.PORT_PROP_NAME, 5775);
+ TransportConfiguration backup1 = new TransportConfiguration(NettyConnectorFactory.class.getName(), backupParams);
+ Map<String, Object> liveParams2 = new HashMap<String, Object>();
+ liveParams2.put(TransportConstants.PORT_PROP_NAME, 6665);
+ TransportConfiguration live2 = new TransportConfiguration(NettyConnectorFactory.class.getName(), liveParams2);
+
+ connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(live1, backup1));
+ connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(live2, null));
+
+ config.setConnectorConfigs(connectorConfigs );
+ List<Pair<String, String>> connectors = new ArrayList<Pair<String,String>>();
+ connectors.add(new Pair<String, String>(RandomUtil.randomString(), null));
+ config.setConnectorNames(connectors);
+ config.setCallTimeout(RandomUtil.randomPositiveLong());
+
+ addSetting(new PersistedConnectionFactory(config));
+
+ jmsJournal.stop();
+
+ createJMSStorage();
+
+ List<PersistedConnectionFactory> cfs = jmsJournal.recoverConnectionFactories();
+
+ assertEquals(1, cfs.size());
+
+ assertEquals("some-name", cfs.get(0).getName());
+
+ assertEquals(config.getCallTimeout(), cfs.get(0).getConfig().getCallTimeout());
+
+ assertEquals(5, cfs.get(0).getConfig().getBindings().length);
+
+ for (int i = 0; i < 5; i++)
+ {
+ assertEquals("str" + i, cfs.get(0).getConfig().getBindings()[i]);
+ }
+ }
+
/**
* @param journal
* @throws Exception
Added: trunk/tests/src/org/hornetq/tests/integration/persistence/TransportConfigurationEncodingSupportTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/persistence/TransportConfigurationEncodingSupportTest.java (rev 0)
+++ trunk/tests/src/org/hornetq/tests/integration/persistence/TransportConfigurationEncodingSupportTest.java 2010-03-27 13:18:24 UTC (rev 8981)
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2010 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.tests.integration.persistence;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hornetq.api.core.HornetQBuffer;
+import org.hornetq.api.core.HornetQBuffers;
+import org.hornetq.api.core.Pair;
+import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.integration.transports.netty.NettyConnectorFactory;
+import org.hornetq.integration.transports.netty.TransportConstants;
+import org.hornetq.jms.server.config.impl.TransportConfigurationEncodingSupport;
+import org.hornetq.tests.util.RandomUtil;
+
+import junit.framework.TestCase;
+
+/**
+ * A TransportConfigurationEncodingSupportTest
+ *
+ * @author jmesnil
+ *
+ *
+ */
+public class TransportConfigurationEncodingSupportTest extends TestCase
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testTransportConfiguration() throws Exception
+ {
+ Map<String, Object> params = new HashMap<String, Object>();
+ params.put(TransportConstants.PORT_PROP_NAME, 5665);
+ params.put(TransportConstants.HOST_PROP_NAME, RandomUtil.randomString());
+ TransportConfiguration config = new TransportConfiguration(NettyConnectorFactory.class.getName(), params);
+
+ HornetQBuffer buffer = HornetQBuffers.fixedBuffer(TransportConfigurationEncodingSupport.getEncodeSize(config));
+ TransportConfigurationEncodingSupport.encode(buffer, config);
+
+ assertEquals(buffer.capacity(), buffer.writerIndex());
+ buffer.readerIndex(0);
+
+ TransportConfiguration decoded = TransportConfigurationEncodingSupport.decode(buffer);
+ assertNotNull(decoded);
+
+ assertEquals(config.getName(), decoded.getName());
+ assertEquals(config.getFactoryClassName(), decoded.getFactoryClassName());
+ assertEquals(config.getParams().size(), decoded.getParams().size());
+ for (String key : config.getParams().keySet())
+ {
+ assertEquals(config.getParams().get(key).toString(), decoded.getParams().get(key).toString());
+ }
+ }
+
+ public void testTransportConfigurations() throws Exception
+ {
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
+ Map<String, Object> liveParams = new HashMap<String, Object>();
+ liveParams.put(TransportConstants.PORT_PROP_NAME, 5665);
+ TransportConfiguration live1 = new TransportConfiguration(NettyConnectorFactory.class.getName(), liveParams);
+ Map<String, Object> backupParams = new HashMap<String, Object>();
+ backupParams.put(TransportConstants.PORT_PROP_NAME, 5775);
+ TransportConfiguration backup1 = new TransportConfiguration(NettyConnectorFactory.class.getName(), backupParams);
+ Map<String, Object> liveParams2 = new HashMap<String, Object>();
+ liveParams2.put(TransportConstants.PORT_PROP_NAME, 6665);
+ TransportConfiguration live2 = new TransportConfiguration(NettyConnectorFactory.class.getName(), liveParams2);
+
+ connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(live1, backup1));
+ connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(live2, null));
+
+ HornetQBuffer buffer = HornetQBuffers.fixedBuffer(TransportConfigurationEncodingSupport.getEncodeSize(connectorConfigs));
+ TransportConfigurationEncodingSupport.encodeConfigs(buffer, connectorConfigs);
+
+ assertEquals(buffer.capacity(), buffer.writerIndex());
+ buffer.readerIndex(0);
+
+ List<Pair<TransportConfiguration, TransportConfiguration>> decodedConfigs = TransportConfigurationEncodingSupport.decodeConfigs(buffer);
+ assertNotNull(decodedConfigs);
+ assertEquals(2, decodedConfigs.size());
+
+ assertEquivalent(connectorConfigs.get(0).a, decodedConfigs.get(0).a);
+ assertEquivalent(connectorConfigs.get(0).b, decodedConfigs.get(0).b);
+ assertEquivalent(connectorConfigs.get(1).a, decodedConfigs.get(1).a);
+ assertNull(decodedConfigs.get(1).b);
+ }
+
+ // decoded TransportConfiguration have parameter values as String instead of primitive type
+ private static void assertEquivalent(TransportConfiguration expected, TransportConfiguration actual)
+ {
+ assertEquals(expected.getFactoryClassName(), actual.getFactoryClassName());
+ assertEquals(expected.getName(), actual.getName());
+ assertEquals(expected.getParams().size(), actual.getParams().size());
+ for (Map.Entry<String, Object> entry : expected.getParams().entrySet())
+ {
+ String key = entry.getKey();
+ assertEquals(expected.getParams().get(key).toString(), actual.getParams().get(key).toString());
+ }
+ }
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
15 years, 9 months
JBoss hornetq SVN: r8980 - in trunk: tests/src/org/hornetq/tests/integration/jms/server/management and 1 other directory.
by do-not-reply@jboss.org
Author: ataylor
Date: 2010-03-27 08:41:58 -0400 (Sat, 27 Mar 2010)
New Revision: 8980
Modified:
trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
Log:
tests with fixes
Modified: trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2010-03-27 10:52:12 UTC (rev 8979)
+++ trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2010-03-27 12:41:58 UTC (rev 8980)
@@ -33,6 +33,7 @@
import org.hornetq.core.deployers.impl.FileDeploymentManager;
import org.hornetq.core.deployers.impl.XmlDeployer;
import org.hornetq.core.logging.Logger;
+import org.hornetq.core.persistence.impl.journal.JournalStorageManager;
import org.hornetq.core.postoffice.Binding;
import org.hornetq.core.postoffice.BindingType;
import org.hornetq.core.security.Role;
@@ -62,10 +63,10 @@
/**
* A Deployer used to create and add to JNDI queues, topics and connection
* factories. Typically this would only be used in an app server env.
- *
+ * <p/>
* JMS Connection Factories & Destinations can be configured either
* using configuration files or using a JMSConfiguration object.
- *
+ * <p/>
* If configuration files are used, JMS resources are redeployed if the
* files content is changed.
* If a JMSConfiguration object is used, the JMS resources can not be
@@ -123,7 +124,7 @@
public JMSServerManagerImpl(final HornetQServer server) throws Exception
{
this.server = server;
-
+
configFileName = null;
}
@@ -143,6 +144,15 @@
config = configuration;
}
+ public JMSServerManagerImpl(HornetQServer server, String configFilename, JMSStorageManager storageManager)
+ {
+ this.server = server;
+
+ configFileName = null;
+
+ storage = storageManager;
+ }
+
// ActivateCallback implementation -------------------------------------
public synchronized void activated()
@@ -166,7 +176,7 @@
if (configFileName != null)
{
- jmsDeployer.setConfigFileNames(new String[] { configFileName });
+ jmsDeployer.setConfigFileNames(new String[]{configFileName});
}
jmsDeployer.start();
@@ -300,14 +310,14 @@
return server.getVersion().getFullVersion();
}
- public synchronized boolean createQueue(final String queueName, final String selectorString, final boolean durable, final String ... jndi) throws Exception
+ public synchronized boolean createQueue(final String queueName, final String selectorString, final boolean durable, final String... jndi) throws Exception
{
checkInitialised();
boolean added = internalCreateQueue(queueName, selectorString, durable);
storage.storeDestination(new PersistedDestination(PersistedType.Queue, queueName, selectorString, durable));
-
+
for (String jndiItem : jndi)
{
addQueueToJndi(queueName, jndiItem);
@@ -316,14 +326,14 @@
return added;
}
- public synchronized boolean createTopic(final String topicName, final String ... jndi) throws Exception
+ public synchronized boolean createTopic(final String topicName, final String... jndi) throws Exception
{
checkInitialised();
boolean added = internalCreateTopic(topicName);
storage.storeDestination(new PersistedDestination(PersistedType.Topic, topicName));
-
+
for (String jndiItem : jndi)
{
addTopicToJndi(topicName, jndiItem);
@@ -335,7 +345,7 @@
public boolean addTopicToJndi(final String topicName, final String jndiBinding) throws Exception
{
checkInitialised();
-
+
HornetQDestination destination = topics.get(topicName);
if (destination == null)
{
@@ -354,28 +364,27 @@
}
return added;
}
-
+
public List<String> getJNDIOnQueue(String queue)
{
return getJNDIList(queueJNDI, queue);
}
-
+
public List<String> getJNDIOnTopic(String topic)
{
return getJNDIList(topicJNDI, topic);
}
-
+
public List<String> getJNDIOnConnectionFactory(String factoryName)
{
return getJNDIList(connectionFactoryJNDI, factoryName);
}
-
public boolean addQueueToJndi(final String queueName, final String jndiBinding) throws Exception
{
checkInitialised();
-
+
HornetQDestination destination = queues.get(queueName);
if (destination == null)
{
@@ -399,7 +408,7 @@
checkInitialised();
HornetQConnectionFactory factory = connectionFactories.get(name);
- if(factory == null)
+ if (factory == null)
{
throw new IllegalArgumentException("Factory does not exist");
}
@@ -415,62 +424,67 @@
/* (non-Javadoc)
* @see org.hornetq.jms.server.JMSServerManager#removeQueueFromJNDI(java.lang.String, java.lang.String)
*/
+
public boolean removeQueueFromJNDI(String name, String jndi) throws Exception
{
checkInitialised();
-
+
removeFromJNDI(queueJNDI, name, jndi);
-
+
storage.deleteJNDI(PersistedType.Queue, name, jndi);
-
+
return true;
}
/* (non-Javadoc)
* @see org.hornetq.jms.server.JMSServerManager#removeQueueFromJNDI(java.lang.String, java.lang.String)
*/
+
public boolean removeQueueFromJNDI(String name) throws Exception
{
checkInitialised();
-
+
removeFromJNDI(queueJNDI, name);
-
+
storage.deleteJNDI(PersistedType.Queue, name);
-
+
return true;
}
/* (non-Javadoc)
* @see org.hornetq.jms.server.JMSServerManager#removeTopicFromJNDI(java.lang.String, java.lang.String)
*/
+
public boolean removeTopicFromJNDI(String name, String jndi) throws Exception
{
checkInitialised();
-
+
removeFromJNDI(topicJNDI, name, jndi);
-
+
storage.deleteJNDI(PersistedType.Topic, name, jndi);
-
+
return true;
}
-
+
/* (non-Javadoc)
- * @see org.hornetq.jms.server.JMSServerManager#removeTopicFromJNDI(java.lang.String, java.lang.String)
- */
+ * @see org.hornetq.jms.server.JMSServerManager#removeTopicFromJNDI(java.lang.String, java.lang.String)
+ */
+
public boolean removeTopicFromJNDI(String name) throws Exception
{
checkInitialised();
-
+
removeFromJNDI(topicJNDI, name);
-
+
storage.deleteJNDI(PersistedType.Topic, name);
-
+
return true;
}
/* (non-Javadoc)
* @see org.hornetq.jms.server.JMSServerManager#removeConnectionFactoryFromJNDI(java.lang.String, java.lang.String)
*/
+
public boolean removeConnectionFactoryFromJNDI(String name, String jndi) throws Exception
{
checkInitialised();
@@ -485,6 +499,7 @@
/* (non-Javadoc)
* @see org.hornetq.jms.server.JMSServerManager#removeConnectionFactoryFromJNDI(java.lang.String, java.lang.String)
*/
+
public boolean removeConnectionFactoryFromJNDI(String name) throws Exception
{
checkInitialised();
@@ -495,22 +510,22 @@
return true;
}
-
+
public synchronized boolean destroyQueue(final String name) throws Exception
{
checkInitialised();
-
+
removeFromJNDI(queueJNDI, name);
-
+
queues.remove(name);
queueJNDI.remove(name);
-
+
jmsManagementService.unregisterQueue(name);
-
+
server.getHornetQServerControl().destroyQueue(HornetQDestination.createQueueAddressFromName(name).toString());
-
+
storage.deleteDestination(PersistedType.Queue, name);
return true;
@@ -519,16 +534,16 @@
public synchronized boolean destroyTopic(final String name) throws Exception
{
checkInitialised();
-
+
removeFromJNDI(topicJNDI, name);
topics.remove(name);
topicJNDI.remove(name);
jmsManagementService.unregisterTopic(name);
-
- AddressControl addressControl = (AddressControl)server.getManagementService()
- .getResource(ResourceNames.CORE_ADDRESS + HornetQDestination.createTopicAddressFromName(name));
+
+ AddressControl addressControl = (AddressControl) server.getManagementService()
+ .getResource(ResourceNames.CORE_ADDRESS + HornetQDestination.createTopicAddressFromName(name));
if (addressControl != null)
{
for (String queueName : addressControl.getQueueNames())
@@ -537,9 +552,9 @@
if (binding == null)
{
log.warn("Queue " + queueName +
- " doesn't exist on the topic " +
- name +
- ". It was deleted manually probably.");
+ " doesn't exist on the topic " +
+ name +
+ ". It was deleted manually probably.");
continue;
}
@@ -556,7 +571,7 @@
public synchronized void createConnectionFactory(final String name,
final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
- String ... jndiBindings) throws Exception
+ String... jndiBindings) throws Exception
{
checkInitialised();
HornetQConnectionFactory cf = connectionFactories.get(name);
@@ -570,7 +585,7 @@
public synchronized void createConnectionFactory(final String name,
final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
final String clientID,
- String ... jndiBindings) throws Exception
+ String... jndiBindings) throws Exception
{
checkInitialised();
HornetQConnectionFactory cf = connectionFactories.get(name);
@@ -612,7 +627,7 @@
final int reconnectAttempts,
final boolean failoverOnServerShutdown,
final String groupId,
- String ... jndiBindings) throws Exception
+ String... jndiBindings) throws Exception
{
checkInitialised();
HornetQConnectionFactory cf = connectionFactories.get(name);
@@ -684,7 +699,7 @@
final int reconnectAttempts,
final boolean failoverOnServerShutdown,
final String groupId,
- final String ... jndiBindings) throws Exception
+ final String... jndiBindings) throws Exception
{
checkInitialised();
HornetQConnectionFactory cf = connectionFactories.get(name);
@@ -727,7 +742,7 @@
public synchronized void createConnectionFactory(final String name,
final String discoveryAddress,
final int discoveryPort,
- final String ... jndiBindings) throws Exception
+ final String... jndiBindings) throws Exception
{
checkInitialised();
HornetQConnectionFactory cf = connectionFactories.get(name);
@@ -743,7 +758,7 @@
final String discoveryAddress,
final int discoveryPort,
final String clientID,
- final String ... jndiBindings) throws Exception
+ final String... jndiBindings) throws Exception
{
checkInitialised();
@@ -768,44 +783,44 @@
}
private HornetQConnectionFactory internalCreateConnectionFactory(final String name,
- final String discoveryAddress,
- final int discoveryPort,
- final String clientID,
- final long discoveryRefreshTimeout,
- final long clientFailureCheckPeriod,
- final long connectionTTL,
- final long callTimeout,
- final boolean cacheLargeMessagesClient,
- final int minLargeMessageSize,
- final int consumerWindowSize,
- final int consumerMaxRate,
- final int confirmationWindowSize,
- final int producerWindowSize,
- final int producerMaxRate,
- final boolean blockOnAcknowledge,
- final boolean blockOnDurableSend,
- final boolean blockOnNonDurableSend,
- final boolean autoGroup,
- final boolean preAcknowledge,
- final String loadBalancingPolicyClassName,
- final int transactionBatchSize,
- final int dupsOKBatchSize,
- final long initialWaitTimeout,
- final boolean useGlobalPools,
- final int scheduledThreadPoolMaxSize,
- final int threadPoolMaxSize,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final long maxRetryInterval,
- final int reconnectAttempts,
- final boolean failoverOnServerShutdown,
- final String groupId) throws Exception
+ final String discoveryAddress,
+ final int discoveryPort,
+ final String clientID,
+ final long discoveryRefreshTimeout,
+ final long clientFailureCheckPeriod,
+ final long connectionTTL,
+ final long callTimeout,
+ final boolean cacheLargeMessagesClient,
+ final int minLargeMessageSize,
+ final int consumerWindowSize,
+ final int consumerMaxRate,
+ final int confirmationWindowSize,
+ final int producerWindowSize,
+ final int producerMaxRate,
+ final boolean blockOnAcknowledge,
+ final boolean blockOnDurableSend,
+ final boolean blockOnNonDurableSend,
+ final boolean autoGroup,
+ final boolean preAcknowledge,
+ final String loadBalancingPolicyClassName,
+ final int transactionBatchSize,
+ final int dupsOKBatchSize,
+ final long initialWaitTimeout,
+ final boolean useGlobalPools,
+ final int scheduledThreadPoolMaxSize,
+ final int threadPoolMaxSize,
+ final long retryInterval,
+ final double retryIntervalMultiplier,
+ final long maxRetryInterval,
+ final int reconnectAttempts,
+ final boolean failoverOnServerShutdown,
+ final String groupId) throws Exception
{
checkInitialised();
HornetQConnectionFactory cf = connectionFactories.get(name);
if (cf == null)
{
- cf = (HornetQConnectionFactory)HornetQJMSClient.createConnectionFactory(discoveryAddress, discoveryPort);
+ cf = (HornetQConnectionFactory) HornetQJMSClient.createConnectionFactory(discoveryAddress, discoveryPort);
cf.setClientID(clientID);
cf.setDiscoveryRefreshTimeout(discoveryRefreshTimeout);
cf.setClientFailureCheckPeriod(clientFailureCheckPeriod);
@@ -841,75 +856,74 @@
}
private HornetQConnectionFactory internalCreateConnectionFactory(final String name,
- final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
- final String clientID,
- final long clientFailureCheckPeriod,
- final long connectionTTL,
- final long callTimeout,
- final boolean cacheLargeMessagesClient,
- final int minLargeMessageSize,
- final int consumerWindowSize,
- final int consumerMaxRate,
- final int confirmationWindowSize,
- final int producerWindowSize,
- final int producerMaxRate,
- final boolean blockOnAcknowledge,
- final boolean blockOnDurableSend,
- final boolean blockOnNonDurableSend,
- final boolean autoGroup,
- final boolean preAcknowledge,
- final String loadBalancingPolicyClassName,
- final int transactionBatchSize,
- final int dupsOKBatchSize,
- final boolean useGlobalPools,
- final int scheduledThreadPoolMaxSize,
- final int threadPoolMaxSize,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final long maxRetryInterval,
- final int reconnectAttempts,
- final boolean failoverOnServerShutdown,
- final String groupId) throws Exception
- {
- checkInitialised();
- HornetQConnectionFactory cf = connectionFactories.get(name);
- if (cf == null)
- {
- cf = (HornetQConnectionFactory)HornetQJMSClient.createConnectionFactory(connectorConfigs);
- cf.setClientID(clientID);
- cf.setClientFailureCheckPeriod(clientFailureCheckPeriod);
- cf.setConnectionTTL(connectionTTL);
- cf.setCallTimeout(callTimeout);
- cf.setCacheLargeMessagesClient(cacheLargeMessagesClient);
- cf.setMinLargeMessageSize(minLargeMessageSize);
- cf.setConsumerWindowSize(consumerWindowSize);
- cf.setConsumerMaxRate(consumerMaxRate);
- cf.setConfirmationWindowSize(confirmationWindowSize);
- cf.setProducerWindowSize(producerWindowSize);
- cf.setProducerMaxRate(producerMaxRate);
- cf.setBlockOnAcknowledge(blockOnAcknowledge);
- cf.setBlockOnDurableSend(blockOnDurableSend);
- cf.setBlockOnNonDurableSend(blockOnNonDurableSend);
- cf.setAutoGroup(autoGroup);
- cf.setPreAcknowledge(preAcknowledge);
- cf.setConnectionLoadBalancingPolicyClassName(loadBalancingPolicyClassName);
- cf.setTransactionBatchSize(transactionBatchSize);
- cf.setDupsOKBatchSize(dupsOKBatchSize);
- cf.setUseGlobalPools(useGlobalPools);
- cf.setScheduledThreadPoolMaxSize(scheduledThreadPoolMaxSize);
- cf.setThreadPoolMaxSize(threadPoolMaxSize);
- cf.setRetryInterval(retryInterval);
- cf.setRetryIntervalMultiplier(retryIntervalMultiplier);
- cf.setMaxRetryInterval(maxRetryInterval);
- cf.setReconnectAttempts(reconnectAttempts);
- cf.setFailoverOnServerShutdown(failoverOnServerShutdown);
- cf.setGroupID(groupId);
- }
- return cf;
- }
+ final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ final String clientID,
+ final long clientFailureCheckPeriod,
+ final long connectionTTL,
+ final long callTimeout,
+ final boolean cacheLargeMessagesClient,
+ final int minLargeMessageSize,
+ final int consumerWindowSize,
+ final int consumerMaxRate,
+ final int confirmationWindowSize,
+ final int producerWindowSize,
+ final int producerMaxRate,
+ final boolean blockOnAcknowledge,
+ final boolean blockOnDurableSend,
+ final boolean blockOnNonDurableSend,
+ final boolean autoGroup,
+ final boolean preAcknowledge,
+ final String loadBalancingPolicyClassName,
+ final int transactionBatchSize,
+ final int dupsOKBatchSize,
+ final boolean useGlobalPools,
+ final int scheduledThreadPoolMaxSize,
+ final int threadPoolMaxSize,
+ final long retryInterval,
+ final double retryIntervalMultiplier,
+ final long maxRetryInterval,
+ final int reconnectAttempts,
+ final boolean failoverOnServerShutdown,
+ final String groupId) throws Exception
+ {
+ checkInitialised();
+ HornetQConnectionFactory cf = connectionFactories.get(name);
+ if (cf == null)
+ {
+ cf = (HornetQConnectionFactory) HornetQJMSClient.createConnectionFactory(connectorConfigs);
+ cf.setClientID(clientID);
+ cf.setClientFailureCheckPeriod(clientFailureCheckPeriod);
+ cf.setConnectionTTL(connectionTTL);
+ cf.setCallTimeout(callTimeout);
+ cf.setCacheLargeMessagesClient(cacheLargeMessagesClient);
+ cf.setMinLargeMessageSize(minLargeMessageSize);
+ cf.setConsumerWindowSize(consumerWindowSize);
+ cf.setConsumerMaxRate(consumerMaxRate);
+ cf.setConfirmationWindowSize(confirmationWindowSize);
+ cf.setProducerWindowSize(producerWindowSize);
+ cf.setProducerMaxRate(producerMaxRate);
+ cf.setBlockOnAcknowledge(blockOnAcknowledge);
+ cf.setBlockOnDurableSend(blockOnDurableSend);
+ cf.setBlockOnNonDurableSend(blockOnNonDurableSend);
+ cf.setAutoGroup(autoGroup);
+ cf.setPreAcknowledge(preAcknowledge);
+ cf.setConnectionLoadBalancingPolicyClassName(loadBalancingPolicyClassName);
+ cf.setTransactionBatchSize(transactionBatchSize);
+ cf.setDupsOKBatchSize(dupsOKBatchSize);
+ cf.setUseGlobalPools(useGlobalPools);
+ cf.setScheduledThreadPoolMaxSize(scheduledThreadPoolMaxSize);
+ cf.setThreadPoolMaxSize(threadPoolMaxSize);
+ cf.setRetryInterval(retryInterval);
+ cf.setRetryIntervalMultiplier(retryIntervalMultiplier);
+ cf.setMaxRetryInterval(maxRetryInterval);
+ cf.setReconnectAttempts(reconnectAttempts);
+ cf.setFailoverOnServerShutdown(failoverOnServerShutdown);
+ cf.setGroupID(groupId);
+ }
+ return cf;
+ }
-
private List<String> getJNDIList(final Map<String, List<String>> map, final String name)
{
List<String> result = map.get(name);
@@ -936,10 +950,10 @@
}
server.getHornetQServerControl().deployQueue(hqQueue.getAddress(),
- hqQueue.getAddress(),
- coreFilterString,
- durable);
-
+ hqQueue.getAddress(),
+ coreFilterString,
+ durable);
+
queues.put(queueName, hqQueue);
jmsManagementService.registerQueue(hqQueue);
@@ -948,8 +962,9 @@
}
/**
- * Performs the internal creation without activating any storage.
+ * Performs the internal creation without activating any storage.
* The storage load will call this method
+ *
* @param topicName
* @return
* @throws Exception
@@ -962,9 +977,9 @@
// does not exist - otherwise we would not be able to distinguish from a non existent topic and one with no
// subscriptions - core has no notion of a topic
server.getHornetQServerControl().deployQueue(hqTopic.getAddress(),
- hqTopic.getAddress(),
- JMSServerManagerImpl.REJECT_FILTER,
- true);
+ hqTopic.getAddress(),
+ JMSServerManagerImpl.REJECT_FILTER,
+ true);
topics.put(topicName, hqTopic);
@@ -984,81 +999,86 @@
List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = lookupConnectors(cfConfig);
lookupDiscovery(cfConfig);
-
+ HornetQConnectionFactory cf;
if (cfConfig.getDiscoveryAddress() != null)
{
- return internalCreateConnectionFactory(cfConfig.getName(),
- cfConfig.getDiscoveryAddress(),
- cfConfig.getDiscoveryPort(),
- cfConfig.getClientID(),
- cfConfig.getDiscoveryRefreshTimeout(),
- cfConfig.getClientFailureCheckPeriod(),
- cfConfig.getConnectionTTL(),
- cfConfig.getCallTimeout(),
- cfConfig.isCacheLargeMessagesClient(),
- cfConfig.getMinLargeMessageSize(),
- cfConfig.getConsumerWindowSize(),
- cfConfig.getConsumerMaxRate(),
- cfConfig.getConfirmationWindowSize(),
- cfConfig.getProducerWindowSize(),
- cfConfig.getProducerMaxRate(),
- cfConfig.isBlockOnAcknowledge(),
- cfConfig.isBlockOnDurableSend(),
- cfConfig.isBlockOnNonDurableSend(),
- cfConfig.isAutoGroup(),
- cfConfig.isPreAcknowledge(),
- cfConfig.getLoadBalancingPolicyClassName(),
- cfConfig.getTransactionBatchSize(),
- cfConfig.getDupsOKBatchSize(),
- cfConfig.getInitialWaitTimeout(),
- cfConfig.isUseGlobalPools(),
- cfConfig.getScheduledThreadPoolMaxSize(),
- cfConfig.getThreadPoolMaxSize(),
- cfConfig.getRetryInterval(),
- cfConfig.getRetryIntervalMultiplier(),
- cfConfig.getMaxRetryInterval(),
- cfConfig.getReconnectAttempts(),
- cfConfig.isFailoverOnServerShutdown(),
- cfConfig.getGroupID());
+ cf = internalCreateConnectionFactory(cfConfig.getName(),
+ cfConfig.getDiscoveryAddress(),
+ cfConfig.getDiscoveryPort(),
+ cfConfig.getClientID(),
+ cfConfig.getDiscoveryRefreshTimeout(),
+ cfConfig.getClientFailureCheckPeriod(),
+ cfConfig.getConnectionTTL(),
+ cfConfig.getCallTimeout(),
+ cfConfig.isCacheLargeMessagesClient(),
+ cfConfig.getMinLargeMessageSize(),
+ cfConfig.getConsumerWindowSize(),
+ cfConfig.getConsumerMaxRate(),
+ cfConfig.getConfirmationWindowSize(),
+ cfConfig.getProducerWindowSize(),
+ cfConfig.getProducerMaxRate(),
+ cfConfig.isBlockOnAcknowledge(),
+ cfConfig.isBlockOnDurableSend(),
+ cfConfig.isBlockOnNonDurableSend(),
+ cfConfig.isAutoGroup(),
+ cfConfig.isPreAcknowledge(),
+ cfConfig.getLoadBalancingPolicyClassName(),
+ cfConfig.getTransactionBatchSize(),
+ cfConfig.getDupsOKBatchSize(),
+ cfConfig.getInitialWaitTimeout(),
+ cfConfig.isUseGlobalPools(),
+ cfConfig.getScheduledThreadPoolMaxSize(),
+ cfConfig.getThreadPoolMaxSize(),
+ cfConfig.getRetryInterval(),
+ cfConfig.getRetryIntervalMultiplier(),
+ cfConfig.getMaxRetryInterval(),
+ cfConfig.getReconnectAttempts(),
+ cfConfig.isFailoverOnServerShutdown(),
+ cfConfig.getGroupID());
}
else
{
- return internalCreateConnectionFactory(cfConfig.getName(),
- connectorConfigs,
- cfConfig.getClientID(),
- cfConfig.getClientFailureCheckPeriod(),
- cfConfig.getConnectionTTL(),
- cfConfig.getCallTimeout(),
- cfConfig.isCacheLargeMessagesClient(),
- cfConfig.getMinLargeMessageSize(),
- cfConfig.getConsumerWindowSize(),
- cfConfig.getConsumerMaxRate(),
- cfConfig.getConfirmationWindowSize(),
- cfConfig.getProducerWindowSize(),
- cfConfig.getProducerMaxRate(),
- cfConfig.isBlockOnAcknowledge(),
- cfConfig.isBlockOnDurableSend(),
- cfConfig.isBlockOnNonDurableSend(),
- cfConfig.isAutoGroup(),
- cfConfig.isPreAcknowledge(),
- cfConfig.getLoadBalancingPolicyClassName(),
- cfConfig.getTransactionBatchSize(),
- cfConfig.getDupsOKBatchSize(),
- cfConfig.isUseGlobalPools(),
- cfConfig.getScheduledThreadPoolMaxSize(),
- cfConfig.getThreadPoolMaxSize(),
- cfConfig.getRetryInterval(),
- cfConfig.getRetryIntervalMultiplier(),
- cfConfig.getMaxRetryInterval(),
- cfConfig.getReconnectAttempts(),
- cfConfig.isFailoverOnServerShutdown(),
- cfConfig.getGroupID());
+ cf = internalCreateConnectionFactory(cfConfig.getName(),
+ connectorConfigs,
+ cfConfig.getClientID(),
+ cfConfig.getClientFailureCheckPeriod(),
+ cfConfig.getConnectionTTL(),
+ cfConfig.getCallTimeout(),
+ cfConfig.isCacheLargeMessagesClient(),
+ cfConfig.getMinLargeMessageSize(),
+ cfConfig.getConsumerWindowSize(),
+ cfConfig.getConsumerMaxRate(),
+ cfConfig.getConfirmationWindowSize(),
+ cfConfig.getProducerWindowSize(),
+ cfConfig.getProducerMaxRate(),
+ cfConfig.isBlockOnAcknowledge(),
+ cfConfig.isBlockOnDurableSend(),
+ cfConfig.isBlockOnNonDurableSend(),
+ cfConfig.isAutoGroup(),
+ cfConfig.isPreAcknowledge(),
+ cfConfig.getLoadBalancingPolicyClassName(),
+ cfConfig.getTransactionBatchSize(),
+ cfConfig.getDupsOKBatchSize(),
+ cfConfig.isUseGlobalPools(),
+ cfConfig.getScheduledThreadPoolMaxSize(),
+ cfConfig.getThreadPoolMaxSize(),
+ cfConfig.getRetryInterval(),
+ cfConfig.getRetryIntervalMultiplier(),
+ cfConfig.getMaxRetryInterval(),
+ cfConfig.getReconnectAttempts(),
+ cfConfig.isFailoverOnServerShutdown(),
+ cfConfig.getGroupID());
}
+ connectionFactories.put(cfConfig.getName(), cf);
+
+ jmsManagementService.registerConnectionFactory(cfConfig.getName(), cf);
+
+ return cf;
}
public synchronized void createConnectionFactory(final String name,
final TransportConfiguration liveTC,
- final String ... jndiBindings) throws Exception
+ final String... jndiBindings) throws Exception
{
checkInitialised();
HornetQConnectionFactory cf = connectionFactories.get(name);
@@ -1072,7 +1092,7 @@
public synchronized void createConnectionFactory(final String name,
final TransportConfiguration liveTC,
final String clientID,
- final String ... jndiBindings) throws Exception
+ final String... jndiBindings) throws Exception
{
checkInitialised();
HornetQConnectionFactory cf = connectionFactories.get(name);
@@ -1087,7 +1107,7 @@
public synchronized void createConnectionFactory(final String name,
final TransportConfiguration liveTC,
final TransportConfiguration backupTC,
- final String ... jndiBindings) throws Exception
+ final String... jndiBindings) throws Exception
{
checkInitialised();
HornetQConnectionFactory cf = connectionFactories.get(name);
@@ -1102,7 +1122,7 @@
final TransportConfiguration liveTC,
final TransportConfiguration backupTC,
final String clientID,
- final String ... jndiBindings) throws Exception
+ final String... jndiBindings) throws Exception
{
checkInitialised();
HornetQConnectionFactory cf = connectionFactories.get(name);
@@ -1198,7 +1218,7 @@
jmsManagementService.registerConnectionFactory(name, cf);
}
-
+
private void addToBindings(Map<String, List<String>> map, String name, String jndi)
{
List<String> list = map.get(name);
@@ -1257,16 +1277,16 @@
DiscoveryGroupConfiguration discoveryGroupConfiguration = null;
discoveryGroupConfiguration = configuration.getDiscoveryGroupConfigurations()
- .get(cfConfig.getDiscoveryGroupName());
+ .get(cfConfig.getDiscoveryGroupName());
if (discoveryGroupConfiguration == null)
{
JMSServerManagerImpl.log.warn("There is no discovery group with name '" + cfConfig.getDiscoveryGroupName() +
- "' deployed.");
+ "' deployed.");
throw new HornetQException(HornetQException.ILLEGAL_STATE,
- "There is no discovery group with name '" + cfConfig.getDiscoveryGroupName() +
- "' deployed.");
+ "There is no discovery group with name '" + cfConfig.getDiscoveryGroupName() +
+ "' deployed.");
}
cfConfig.setDiscoveryAddress(discoveryGroupConfiguration.getGroupAddress());
@@ -1309,7 +1329,7 @@
{
String[] bindings = config.getBindings();
createTopic(config.getName());
-
+
for (String binding : bindings)
{
addTopicToJndi(config.getName(), binding);
@@ -1324,15 +1344,18 @@
{
this.coreConfig = server.getConfiguration();
- if (coreConfig.isPersistenceEnabled())
+ if (storage == null)
{
- // TODO: replication
- storage = new JournalJMSStorageManagerImpl(new TimeAndCounterIDGenerator(), coreConfig, null);
+ if (coreConfig.isPersistenceEnabled())
+ {
+ // TODO: replication
+ storage = new JournalJMSStorageManagerImpl(new TimeAndCounterIDGenerator(), coreConfig, null);
+ }
+ else
+ {
+ storage = new NullJMSStorageManagerImpl();
+ }
}
- else
- {
- storage = new NullJMSStorageManagerImpl();
- }
storage.start();
@@ -1350,21 +1373,21 @@
if (destination.getType() == PersistedType.Queue)
{
internalCreateQueue(destination.getName(),
- destination.getSelector(),
- destination.isDurable());
+ destination.getSelector(),
+ destination.isDurable());
}
else if (destination.getType() == PersistedType.Topic)
{
internalCreateTopic(destination.getName());
}
}
-
+
List<PersistedJNDI> jndiSpace = storage.recoverPersistedJNDI();
for (PersistedJNDI record : jndiSpace)
{
Map<String, List<String>> mapJNDI;
Map<String, ?> objects;
-
+
switch (record.getType())
{
case Queue:
@@ -1381,22 +1404,22 @@
objects = connectionFactories;
break;
}
-
+
Object objectToBind = objects.get(record.getName());
-
+
if (objectToBind == null)
{
continue;
}
-
+
List<String> jndiList = mapJNDI.get(record.getName());
if (jndiList == null)
{
jndiList = new ArrayList<String>();
mapJNDI.put(record.getName(), jndiList);
}
-
-
+
+
for (String jndi : record.getJndi())
{
jndiList.add(jndi);
@@ -1404,7 +1427,7 @@
}
}
}
-
+
private synchronized boolean removeFromJNDI(final Map<String, List<String>> jndiMap, final String name) throws Exception
{
checkInitialised();
@@ -1425,8 +1448,8 @@
}
return true;
}
-
-
+
+
private synchronized boolean removeFromJNDI(final Map<String, List<String>> jndiMap, final String name, final String jndi) throws Exception
{
checkInitialised();
@@ -1444,7 +1467,7 @@
}
return true;
}
-
+
/**
* @param cfConfig
* @return
@@ -1472,7 +1495,7 @@
{
JMSServerManagerImpl.log.warn("There is no connector with name '" + connectorName + "' deployed.");
throw new HornetQException(HornetQException.ILLEGAL_STATE,
- "There is no connector with name '" + connectorName + "' deployed.");
+ "There is no connector with name '" + connectorName + "' deployed.");
}
TransportConfiguration backupConnector = null;
@@ -1484,10 +1507,10 @@
if (backupConnector == null)
{
JMSServerManagerImpl.log.warn("There is no backup connector with name '" + backupConnectorName +
- "' deployed.");
+ "' deployed.");
throw new HornetQException(HornetQException.ILLEGAL_STATE,
- "There is no backup connector with name '" + backupConnectorName +
- "' deployed.");
+ "There is no backup connector with name '" + backupConnectorName +
+ "' deployed.");
}
}
@@ -1501,5 +1524,4 @@
return null;
}
}
-
}
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java 2010-03-27 10:52:12 UTC (rev 8979)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java 2010-03-27 12:41:58 UTC (rev 8980)
@@ -22,6 +22,7 @@
import junit.framework.Assert;
+import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.management.AddressControl;
import org.hornetq.api.core.management.ObjectNameBuilder;
@@ -38,6 +39,11 @@
import org.hornetq.core.server.HornetQServers;
import org.hornetq.jms.client.HornetQConnectionFactory;
import org.hornetq.jms.client.HornetQDestination;
+import org.hornetq.jms.persistence.JMSStorageManager;
+import org.hornetq.jms.persistence.config.PersistedConnectionFactory;
+import org.hornetq.jms.persistence.config.PersistedDestination;
+import org.hornetq.jms.persistence.config.PersistedJNDI;
+import org.hornetq.jms.persistence.config.PersistedType;
import org.hornetq.jms.server.JMSServerManager;
import org.hornetq.jms.server.impl.JMSServerManagerImpl;
import org.hornetq.tests.integration.management.ManagementControlHelper;
@@ -46,6 +52,9 @@
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.UnitTestCase;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+
/**
* A JMSServerControlTest
*
@@ -69,6 +78,8 @@
private JMSServerManagerImpl serverManager;
+ private FakeJMSStorageManager fakeJMSStorageManager;
+
// Static --------------------------------------------------------
private static String toCSV(final Object[] objects)
@@ -96,25 +107,122 @@
Assert.assertEquals(serverManager.getVersion(), version);
}
- public void testCreateQueue() throws Exception
+ public void testCreateQueueWithBindings() throws Exception
{
- String queueJNDIBinding = RandomUtil.randomString();
+ String[] bindings = new String[3];
+ bindings[0] = RandomUtil.randomString();
+ bindings[1] = RandomUtil.randomString();
+ bindings[2] = RandomUtil.randomString();
String queueName = RandomUtil.randomString();
- UnitTestCase.checkNoBinding(context, queueJNDIBinding);
+ String bindingsCSV = JMSServerControlTest.toCSV(bindings);
+ UnitTestCase.checkNoBinding(context, bindingsCSV);
+
checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
JMSServerControl control = createManagementControl();
- control.createQueue(queueName, queueJNDIBinding);
+ control.createQueue(queueName, bindingsCSV);
- Object o = UnitTestCase.checkBinding(context, queueJNDIBinding);
+ Object o = UnitTestCase.checkBinding(context, bindings[0]);
Assert.assertTrue(o instanceof Queue);
Queue queue = (Queue)o;
Assert.assertEquals(queueName, queue.getQueueName());
+ o = UnitTestCase.checkBinding(context, bindings[1]);
+ Assert.assertTrue(o instanceof Queue);
+ queue = (Queue)o;
+ Assert.assertEquals(queueName, queue.getQueueName());
+ o = UnitTestCase.checkBinding(context, bindings[2]);
+ Assert.assertTrue(o instanceof Queue);
+ queue = (Queue)o;
+ Assert.assertEquals(queueName, queue.getQueueName());
checkResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
+ Assert.assertNotNull(fakeJMSStorageManager.destinationMap.get(queueName));
+ Assert.assertNotNull(fakeJMSStorageManager.persistedJNDIMap.get(queueName));
+ Assert.assertTrue(fakeJMSStorageManager.persistedJNDIMap.get(queueName).contains(bindings[0]));
+ Assert.assertTrue(fakeJMSStorageManager.persistedJNDIMap.get(queueName).contains(bindings[1]));
+ Assert.assertTrue(fakeJMSStorageManager.persistedJNDIMap.get(queueName).contains(bindings[2]));
}
+ public void testCreateQueueWithCommaBindings() throws Exception
+ {
+ String[] bindings = new String[3];
+ bindings[0] = "first,first";
+ bindings[1] = "second,second";
+ bindings[2] = "third,third";
+ String queueName = RandomUtil.randomString();
+
+ String bindingsCSV = JMSServerControlTest.toCSV(bindings);
+ UnitTestCase.checkNoBinding(context, bindingsCSV);
+
+ checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
+
+ JMSServerControl control = createManagementControl();
+ control.createQueue(queueName, bindingsCSV);
+
+ Object o = UnitTestCase.checkBinding(context, "first,first");
+ Assert.assertTrue(o instanceof Queue);
+ Queue queue = (Queue)o;
+ Assert.assertEquals(queueName, queue.getQueueName());
+ o = UnitTestCase.checkBinding(context, "second,second");
+ Assert.assertTrue(o instanceof Queue);
+ queue = (Queue)o;
+ Assert.assertEquals(queueName, queue.getQueueName());
+ o = UnitTestCase.checkBinding(context, "third,third");
+ Assert.assertTrue(o instanceof Queue);
+ queue = (Queue)o;
+ Assert.assertEquals(queueName, queue.getQueueName());
+ checkResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
+
+ Assert.assertNotNull(fakeJMSStorageManager.destinationMap.get(queueName));
+ Assert.assertNotNull(fakeJMSStorageManager.persistedJNDIMap.get(queueName));
+ Assert.assertTrue(fakeJMSStorageManager.persistedJNDIMap.get(queueName).contains("first,first"));
+ Assert.assertTrue(fakeJMSStorageManager.persistedJNDIMap.get(queueName).contains("second,second"));
+ Assert.assertTrue(fakeJMSStorageManager.persistedJNDIMap.get(queueName).contains("third,third"));
+ }
+
+ public void testCreateQueueWithSelector() throws Exception
+ {
+ String[] bindings = new String[3];
+ bindings[0] = RandomUtil.randomString();
+ bindings[1] = RandomUtil.randomString();
+ bindings[2] = RandomUtil.randomString();
+ String queueName = RandomUtil.randomString();
+
+ String bindingsCSV = JMSServerControlTest.toCSV(bindings);
+ UnitTestCase.checkNoBinding(context, bindingsCSV);
+
+ checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
+
+ JMSServerControl control = createManagementControl();
+ String selector = "foo='bar'";
+ control.createQueue(queueName, bindingsCSV, selector);
+
+ Object o = UnitTestCase.checkBinding(context, bindings[0]);
+ Assert.assertTrue(o instanceof Queue);
+ Queue queue = (Queue)o;
+ //assertEquals(((HornetQDestination)queue).get);
+ Assert.assertEquals(queueName, queue.getQueueName());
+ Assert.assertEquals(selector,server.getPostOffice().getBinding(new SimpleString("jms.queue." + queueName)).getFilter().getFilterString().toString());
+ o = UnitTestCase.checkBinding(context, bindings[1]);
+ Assert.assertTrue(o instanceof Queue);
+ queue = (Queue)o;
+ Assert.assertEquals(queueName, queue.getQueueName());
+ Assert.assertEquals(selector,server.getPostOffice().getBinding(new SimpleString("jms.queue." + queueName)).getFilter().getFilterString().toString());
+ o = UnitTestCase.checkBinding(context, bindings[2]);
+ Assert.assertTrue(o instanceof Queue);
+ queue = (Queue)o;
+ Assert.assertEquals(queueName, queue.getQueueName());
+ Assert.assertEquals(selector,server.getPostOffice().getBinding(new SimpleString("jms.queue." + queueName)).getFilter().getFilterString().toString());
+ checkResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
+
+ Assert.assertNotNull(fakeJMSStorageManager.destinationMap.get(queueName));
+ Assert.assertNotNull(fakeJMSStorageManager.persistedJNDIMap.get(queueName));
+ Assert.assertTrue(fakeJMSStorageManager.persistedJNDIMap.get(queueName).contains(bindings[0]));
+ Assert.assertTrue(fakeJMSStorageManager.persistedJNDIMap.get(queueName).contains(bindings[1]));
+ Assert.assertTrue(fakeJMSStorageManager.persistedJNDIMap.get(queueName).contains(bindings[2]));
+ }
+
public void testDestroyQueue() throws Exception
{
String queueJNDIBinding = RandomUtil.randomString();
@@ -133,6 +241,8 @@
UnitTestCase.checkNoBinding(context, queueJNDIBinding);
checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
+
+ Assert.assertNull(fakeJMSStorageManager.destinationMap.get(queueName));
}
public void testGetQueueNames() throws Exception
@@ -156,7 +266,12 @@
public void testCreateTopic() throws Exception
{
- String topicJNDIBinding = RandomUtil.randomString();
+ String[] bindings = new String[3];
+ bindings[0] = RandomUtil.randomString();
+ bindings[1] = RandomUtil.randomString();
+ bindings[2] = RandomUtil.randomString();
+ String topicJNDIBinding = JMSServerControlTest.toCSV(bindings);
+ UnitTestCase.checkNoBinding(context, topicJNDIBinding);
String topicName = RandomUtil.randomString();
UnitTestCase.checkNoBinding(context, topicJNDIBinding);
@@ -165,11 +280,25 @@
JMSServerControl control = createManagementControl();
control.createTopic(topicName, topicJNDIBinding);
- Object o = UnitTestCase.checkBinding(context, topicJNDIBinding);
+ Object o = UnitTestCase.checkBinding(context, bindings[0]);
Assert.assertTrue(o instanceof Topic);
Topic topic = (Topic)o;
Assert.assertEquals(topicName, topic.getTopicName());
+ o = UnitTestCase.checkBinding(context, bindings[1]);
+ Assert.assertTrue(o instanceof Topic);
+ topic = (Topic)o;
+ Assert.assertEquals(topicName, topic.getTopicName());
+ o = UnitTestCase.checkBinding(context, bindings[2]);
+ Assert.assertTrue(o instanceof Topic);
+ topic = (Topic)o;
+ Assert.assertEquals(topicName, topic.getTopicName());
checkResource(ObjectNameBuilder.DEFAULT.getJMSTopicObjectName(topicName));
+
+ Assert.assertNotNull(fakeJMSStorageManager.destinationMap.get(topicName));
+ Assert.assertNotNull(fakeJMSStorageManager.persistedJNDIMap.get(topicName));
+ Assert.assertTrue(fakeJMSStorageManager.persistedJNDIMap.get(topicName).contains(bindings[0]));
+ Assert.assertTrue(fakeJMSStorageManager.persistedJNDIMap.get(topicName).contains(bindings[1]));
+ Assert.assertTrue(fakeJMSStorageManager.persistedJNDIMap.get(topicName).contains(bindings[2]));
}
public void testDestroyTopic() throws Exception
@@ -204,6 +333,8 @@
assertNull(server.getManagementService().getResource(ResourceNames.CORE_ADDRESS + topicAddress));
UnitTestCase.checkNoBinding(context, topicJNDIBinding);
checkNoResource(ObjectNameBuilder.DEFAULT.getJMSTopicObjectName(topicName));
+
+ Assert.assertNull(fakeJMSStorageManager.destinationMap.get(topicName));
}
public void testGetTopicNames() throws Exception
@@ -306,7 +437,8 @@
server = HornetQServers.newHornetQServer(conf, mbeanServer, false);
context = new InVMContext();
- serverManager = new JMSServerManagerImpl(server);
+ fakeJMSStorageManager = new FakeJMSStorageManager();
+ serverManager = new JMSServerManagerImpl(server, null, fakeJMSStorageManager);
serverManager.setContext(context);
serverManager.start();
serverManager.activated();
@@ -333,7 +465,9 @@
// Private -------------------------------------------------------
- private void doCreateConnectionFactory(final ConnectionFactoryCreator creator) throws Exception
+ private void
+
+ doCreateConnectionFactory(final ConnectionFactoryCreator creator) throws Exception
{
Object[] cfJNDIBindings = new Object[] { RandomUtil.randomString(),
RandomUtil.randomString(),
@@ -359,6 +493,11 @@
connection.close();
}
checkResource(ObjectNameBuilder.DEFAULT.getConnectionFactoryObjectName(cfName));
+
+ Assert.assertNotNull(fakeJMSStorageManager.connectionFactoryMap.get(cfName));
+ Assert.assertTrue(fakeJMSStorageManager.persistedJNDIMap.get(cfName).contains(cfJNDIBindings[0]));
+ Assert.assertTrue(fakeJMSStorageManager.persistedJNDIMap.get(cfName).contains(cfJNDIBindings[1]));
+ Assert.assertTrue(fakeJMSStorageManager.persistedJNDIMap.get(cfName).contains(cfJNDIBindings[2]));
}
private JMSServerManager startHornetQServer(final int discoveryPort) throws Exception
@@ -390,4 +529,76 @@
void createConnectionFactory(JMSServerControl control, String cfName, Object[] bindings) throws Exception;
}
+ class FakeJMSStorageManager implements JMSStorageManager
+ {
+ Map<String, PersistedDestination> destinationMap = new HashMap<String, PersistedDestination>();
+ Map<String, PersistedConnectionFactory> connectionFactoryMap = new HashMap<String, PersistedConnectionFactory>();
+ ConcurrentHashMap<String, List<String>> persistedJNDIMap = new ConcurrentHashMap<String, List<String>>();
+ public void storeDestination(PersistedDestination destination) throws Exception
+ {
+ destinationMap.put(destination.getName(), destination);
+ }
+
+ public void deleteDestination(PersistedType type, String name) throws Exception
+ {
+ destinationMap.remove(name);
+ }
+
+ public List<PersistedDestination> recoverDestinations()
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ public void deleteConnectionFactory(String connectionFactory) throws Exception
+ {
+ connectionFactoryMap.remove(connectionFactory);
+ }
+
+ public void storeConnectionFactory(PersistedConnectionFactory connectionFactory) throws Exception
+ {
+ connectionFactoryMap.put(connectionFactory.getName(), connectionFactory);
+ }
+
+ public List<PersistedConnectionFactory> recoverConnectionFactories()
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ public void addJNDI(PersistedType type, String name, String address) throws Exception
+ {
+ persistedJNDIMap.putIfAbsent(name, new ArrayList<String>());
+ persistedJNDIMap.get(name).add(address);
+ }
+
+ public List<PersistedJNDI> recoverPersistedJNDI() throws Exception
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ public void deleteJNDI(PersistedType type, String name, String address) throws Exception
+ {
+ persistedJNDIMap.get(name).remove(address);
+ }
+
+ public void deleteJNDI(PersistedType type, String name) throws Exception
+ {
+ persistedJNDIMap.get(name).clear();
+ }
+
+ public void start() throws Exception
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void stop() throws Exception
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean isStarted()
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+ }
+
}
\ No newline at end of file
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java 2010-03-27 10:52:12 UTC (rev 8979)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java 2010-03-27 12:41:58 UTC (rev 8980)
@@ -261,14 +261,12 @@
public boolean createQueue(String name, String jndiBinding) throws Exception
{
- // TODO add a test for this
- return false;
+ return (Boolean)proxy.invokeOperation("createQueue", name, jndiBinding);
}
public boolean createTopic(String name, String jndiBinding) throws Exception
{
- // TODO add a test for this
- return false;
+ return (Boolean)proxy.invokeOperation("createTopic", name, jndiBinding);
}
};
15 years, 9 months
JBoss hornetq SVN: r8979 - in trunk: src/main/org/hornetq/jms/management/impl and 1 other directories.
by do-not-reply@jboss.org
Author: ataylor
Date: 2010-03-27 06:52:12 -0400 (Sat, 27 Mar 2010)
New Revision: 8979
Modified:
trunk/src/main/org/hornetq/api/jms/management/JMSServerControl.java
trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
Log:
added methods to jmsservercontrol
Modified: trunk/src/main/org/hornetq/api/jms/management/JMSServerControl.java
===================================================================
--- trunk/src/main/org/hornetq/api/jms/management/JMSServerControl.java 2010-03-27 10:16:27 UTC (rev 8978)
+++ trunk/src/main/org/hornetq/api/jms/management/JMSServerControl.java 2010-03-27 10:52:12 UTC (rev 8979)
@@ -59,6 +59,13 @@
String[] getConnectionFactoryNames();
// Operations ----------------------------------------------------
+ /**
+ * Creates a JMS Queue.
+ *
+ * @return {@code true} if the queue was created, {@code false} else
+ */
+ @Operation(desc = "Create a JMS Queue", impact = MBeanOperationInfo.ACTION)
+ boolean createQueue(@Parameter(name = "name", desc = "Name of the queue to create") String name) throws Exception;
/**
* Creates a JMS Queue with the specified name and JNDI binding.
@@ -67,9 +74,20 @@
*/
@Operation(desc = "Create a JMS Queue", impact = MBeanOperationInfo.ACTION)
boolean createQueue(@Parameter(name = "name", desc = "Name of the queue to create") String name,
- @Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndiBinding) throws Exception;
+ @Parameter(name = "jndiBindings", desc = "comma-separated list of JNDI bindings (use ',' if u need to use commas in your jndi name)") String jndiBindings) throws Exception;
/**
+ * Creates a JMS Queue with the specified name and JNDI binding.
+ *
+ * @return {@code true} if the queue was created, {@code false} else
+ */
+ @Operation(desc = "Create a JMS Queue", impact = MBeanOperationInfo.ACTION)
+ boolean createQueue(@Parameter(name = "name", desc = "Name of the queue to create") String name,
+ @Parameter(name = "jndiBindings", desc = "comma-separated list of JNDI bindings (use ',' if u need to use commas in your jndi name)") String jndiBindings,
+ @Parameter(name = "selector", desc = "the jms selector") String selector) throws Exception;
+
+
+ /**
* Destroys a JMS Queue with the specified name.
*
* @return {@code true} if the queue was destroyed, {@code false} else
@@ -78,13 +96,21 @@
boolean destroyQueue(@Parameter(name = "name", desc = "Name of the queue to destroy") String name) throws Exception;
/**
+ * Creates a JMS Topic.
+ *
+ * @return {@code true} if the topic was created, {@code false} else
+ */
+ @Operation(desc = "Create a JMS Topic", impact = MBeanOperationInfo.ACTION)
+ boolean createTopic(@Parameter(name = "name", desc = "Name of the topic to create") String name) throws Exception;
+
+ /**
* Creates a JMS Topic with the specified name and JNDI binding.
*
* @return {@code true} if the topic was created, {@code false} else
*/
@Operation(desc = "Create a JMS Topic", impact = MBeanOperationInfo.ACTION)
boolean createTopic(@Parameter(name = "name", desc = "Name of the topic to create") String name,
- @Parameter(name = "jndiBinding", desc = "the name of the binding for JNDI") String jndiBinding) throws Exception;
+ @Parameter(name = "jndiBindings", desc = "comma-separated list of JNDI bindings (use ',' if u need to use commas in your jndi name)") String jndiBindings) throws Exception;
/**
* Destroys a JMS Topic with the specified name.
@@ -134,7 +160,7 @@
@Parameter(name = "liveTransportParams", desc = "comma-separated list of key=value parameters for the live transports (enclosed between { } for each transport)") String liveTransportParams,
@Parameter(name = "backupTransportClassNames", desc = "comma-separated list of class names for transport to backup servers") String backupTransportClassNames,
@Parameter(name = "backupTransportParams", desc = "comma-separated list of key=value parameters for the backup transports (enclosed between { } for each transport)") String backupTransportParams,
- @Parameter(name = "jndiBindings", desc = "comma-separated list of JNDI bindings") String jndiBindings) throws Exception;
+ @Parameter(name = "jndiBindings", desc = "comma-separated list of JNDI bindings (use ',' if u need to use commas in your jndi name)") String jndiBindings) throws Exception;
/**
* Create a JMS ConnectionFactory with the specified name using a discovery group to discover HornetQ servers.
Modified: trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java 2010-03-27 10:16:27 UTC (rev 8978)
+++ trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java 2010-03-27 10:52:12 UTC (rev 8979)
@@ -31,6 +31,7 @@
import org.hornetq.api.core.Pair;
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.management.ManagementHelper;
+import org.hornetq.api.core.management.Parameter;
import org.hornetq.api.jms.management.ConnectionFactoryControl;
import org.hornetq.api.jms.management.JMSQueueControl;
import org.hornetq.api.jms.management.JMSServerControl;
@@ -81,6 +82,7 @@
for (int i = 0; i < values.length; i++)
{
trimmed[i] = values[i].trim();
+ trimmed[i] = trimmed[i].replace(",", ",");
}
return trimmed;
}
@@ -270,15 +272,27 @@
}
- public boolean createQueue(final String name, final String jndiBinding) throws Exception
+ public boolean createQueue(@Parameter(name = "name", desc = "Name of the queue to create") String name) throws Exception
{
+ return createQueue(name, null, null);
+ }
+
+
+
+ public boolean createQueue(final String name, final String jndiBindings) throws Exception
+ {
+ return createQueue(name, jndiBindings, null);
+ }
+
+ public boolean createQueue(@Parameter(name = "name", desc = "Name of the queue to create") String name, @Parameter(name = "jndiBindings", desc = "comma-separated list of JNDI bindings (use ',' if u need to use commas in your jndi name)") String jndiBindings, @Parameter(name = "selector", desc = "the jms selector") String selector) throws Exception
+ {
checkStarted();
clearIO();
try
{
- boolean created = server.createQueue(name, null, true, jndiBinding);
+ boolean created = server.createQueue(name, selector, true, JMSServerControlImpl.toArray(jndiBindings));
if (created)
{
sendNotification(NotificationType.QUEUE_CREATED, name);
@@ -312,15 +326,20 @@
}
}
- public boolean createTopic(final String topicName, final String jndiBinding) throws Exception
+ public boolean createTopic(@Parameter(name = "name", desc = "Name of the topic to create") String name) throws Exception
{
+ return createTopic(name, null);
+ }
+
+ public boolean createTopic(final String topicName, final String jndiBindings) throws Exception
+ {
checkStarted();
clearIO();
try
{
- boolean created = server.createTopic(topicName, jndiBinding);
+ boolean created = server.createTopic(topicName, JMSServerControlImpl.toArray(jndiBindings));
if (created)
{
sendNotification(NotificationType.TOPIC_CREATED, topicName);
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java 2010-03-27 10:16:27 UTC (rev 8978)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java 2010-03-27 10:52:12 UTC (rev 8979)
@@ -21,6 +21,7 @@
import javax.jms.Session;
import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.api.core.management.Parameter;
import org.hornetq.api.core.management.ResourceNames;
import org.hornetq.api.jms.HornetQJMSClient;
import org.hornetq.api.jms.management.JMSServerControl;
@@ -172,6 +173,11 @@
return (Boolean)proxy.invokeOperation("createQueue", name);
}
+ public boolean createQueue(String name, String jndiBindings, String selector) throws Exception
+ {
+ return (Boolean)proxy.invokeOperation("createQueue", name, jndiBindings, selector);
+ }
+
public boolean createTopic(final String name) throws Exception
{
return (Boolean)proxy.invokeOperation("createTopic", name);
15 years, 9 months