Author: gaohoward
Date: 2012-02-14 09:41:49 -0500 (Tue, 14 Feb 2012)
New Revision: 12112
Added:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/persistence/JMSStorageManagerTest.java
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/jms/persistence/impl/journal/JMSJournalStorageManagerImpl.java
branches/Branch_2_2_EAP/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlTest.java
Log:
HORNETQ-812
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/jms/persistence/impl/journal/JMSJournalStorageManagerImpl.java
===================================================================
---
branches/Branch_2_2_EAP/src/main/org/hornetq/jms/persistence/impl/journal/JMSJournalStorageManagerImpl.java 2012-02-14
09:57:46 UTC (rev 12111)
+++
branches/Branch_2_2_EAP/src/main/org/hornetq/jms/persistence/impl/journal/JMSJournalStorageManagerImpl.java 2012-02-14
14:41:49 UTC (rev 12112)
@@ -272,7 +272,6 @@
{
jmsJournal.appendDeleteRecord(destination.getId(), false);
}
- deleteJNDI(type, name);
}
/* (non-Javadoc)
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
===================================================================
---
branches/Branch_2_2_EAP/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2012-02-14
09:57:46 UTC (rev 12111)
+++
branches/Branch_2_2_EAP/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2012-02-14
14:41:49 UTC (rev 12112)
@@ -226,7 +226,8 @@
}
cachedCommands.clear();
-
+
+ recoverJndiBindings();
}
catch (Exception e)
{
@@ -234,6 +235,55 @@
}
}
+ private void recoverJndiBindings() throws Exception
+ {
+ // now its time to add journal recovered stuff
+ List<PersistedJNDI> jndiSpace = storage.recoverPersistedJNDI();
+
+ for (PersistedJNDI record : jndiSpace)
+ {
+ Map<String, List<String>> mapJNDI;
+ Map<String, ?> objects;
+
+ switch (record.getType())
+ {
+ case Queue:
+ mapJNDI = queueJNDI;
+ objects = queues;
+ break;
+ case Topic:
+ mapJNDI = topicJNDI;
+ objects = topics;
+ break;
+ default:
+ case ConnectionFactory:
+ mapJNDI = connectionFactoryJNDI;
+ 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);
+ bindToJndi(jndi, objectToBind);
+ }
+ }
+ }
+
// HornetQComponent implementation -----------------------------------
public synchronized void start() throws Exception
@@ -1524,50 +1574,6 @@
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:
- mapJNDI = queueJNDI;
- objects = queues;
- break;
- case Topic:
- mapJNDI = topicJNDI;
- objects = topics;
- break;
- default:
- case ConnectionFactory:
- mapJNDI = connectionFactoryJNDI;
- 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);
- bindToJndi(jndi, objectToBind);
- }
- }
}
/**
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlTest.java
===================================================================
---
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlTest.java 2012-02-14
09:57:46 UTC (rev 12111)
+++
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/jms/server/management/JMSQueueControlTest.java 2012-02-14
14:41:49 UTC (rev 12112)
@@ -1181,6 +1181,54 @@
}
}
+ public void testQueueAddJndi() throws Exception
+ {
+ String testQueueName = "testQueueAddJndi";
+ serverManager.createQueue(true, testQueueName, null, true, testQueueName);
+ HornetQQueue testQueue =
(HornetQQueue)HornetQJMSClient.createQueue(testQueueName);
+
+ JMSQueueControl queueControl = createManagementControl(testQueue);
+ String[] bindings = queueControl.getJNDIBindings();
+
+ String newJndi = "newTestQueueAddJndi";
+
+ for (String b : bindings)
+ {
+ assertFalse(b.equals(newJndi));
+ }
+ queueControl.addJNDI(newJndi);
+
+ bindings = queueControl.getJNDIBindings();
+ boolean newBindingAdded = false;
+ for (String b : bindings)
+ {
+ if (b.equals(newJndi))
+ {
+ newBindingAdded = true;
+ }
+ }
+ assertTrue(newBindingAdded);
+
+ serverManager.stop();
+
+ serverManager.start();
+
+ testQueue = (HornetQQueue)HornetQJMSClient.createQueue(testQueueName);
+
+ queueControl = createManagementControl(testQueue);
+
+ bindings = queueControl.getJNDIBindings();
+ newBindingAdded = false;
+ for (String b : bindings)
+ {
+ if (b.equals(newJndi))
+ {
+ newBindingAdded = true;
+ }
+ }
+ assertTrue(newBindingAdded);
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Added:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/persistence/JMSStorageManagerTest.java
===================================================================
---
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/persistence/JMSStorageManagerTest.java
(rev 0)
+++
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/persistence/JMSStorageManagerTest.java 2012-02-14
14:41:49 UTC (rev 12112)
@@ -0,0 +1,80 @@
+/*
+ * 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.List;
+
+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.config.ConnectionFactoryConfiguration;
+import org.hornetq.jms.server.config.impl.ConnectionFactoryConfigurationImpl;
+
+/**
+ * A JMSStorageManagerTest
+ *
+ * @author <mailto:hgao@redhat.com">Howard Gao</a>
+ *
+ *
+ */
+public class JMSStorageManagerTest extends StorageManagerTestBase
+{
+ //https://issues.jboss.org/browse/HORNETQ-812
+ public void testJNDIPersistence() throws Exception
+ {
+ createJMSStorage();
+
+ jmsJournal.storeDestination(new PersistedDestination(PersistedType.Queue,
+ "jndiPersistQueue", null, true));
+
+ jmsJournal.addJNDI(PersistedType.Queue, "jndiPersistQueue",
"jndi-1");
+
+ List<PersistedDestination> destinations = jmsJournal.recoverDestinations();
+
+ List<PersistedJNDI> jndiList = jmsJournal.recoverPersistedJNDI();
+
+ assertEquals(1, destinations.size());
+
+ assertEquals(1, jndiList.size());
+
+ jmsJournal.deleteDestination(PersistedType.Queue, "jndiPersistQueue");
+
+ destinations = jmsJournal.recoverDestinations();
+
+ assertEquals(0, destinations.size());
+
+ jmsJournal.stop();
+
+ createJMSStorage();
+
+ destinations = jmsJournal.recoverDestinations();
+
+ assertEquals(0, destinations.size());
+
+ jndiList = jmsJournal.recoverPersistedJNDI();
+
+ assertEquals(1, jndiList.size());
+
+ PersistedJNDI jndi = jndiList.get(0);
+
+ List<String> jndis = jndi.getJndi();
+
+ assertEquals(1, jndis.size());
+
+ assertEquals("jndi-1", jndis.get(0));
+
+ }
+
+}