activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1421059 - in /activemq/trunk: activemq-core/src/test/java/org/apache/activemq/bugs/AMQ4220Test.java activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java
Date Thu, 13 Dec 2012 01:27:33 GMT
Author: tabish
Date: Thu Dec 13 01:27:30 2012
New Revision: 1421059

URL: http://svn.apache.org/viewvc?rev=1421059&view=rev
Log:
fix for: https://issues.apache.org/jira/browse/AMQ-4220

Added:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ4220Test.java 
 (with props)
Modified:
    activemq/trunk/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ4220Test.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ4220Test.java?rev=1421059&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ4220Test.java (added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ4220Test.java Thu
Dec 13 01:27:30 2012
@@ -0,0 +1,120 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.bugs;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.store.PersistenceAdapter;
+import org.apache.activemq.store.kahadb.FilteredKahaDBPersistenceAdapter;
+import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
+import org.apache.activemq.store.kahadb.MultiKahaDBPersistenceAdapter;
+import org.apache.activemq.util.Wait;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AMQ4220Test {
+
+    static final Logger LOG = LoggerFactory.getLogger(AMQ4220Test.class);
+    private final static int maxFileLength = 1024*1024*32;
+    private final static String destinationName = "TEST.QUEUE";
+    BrokerService broker;
+
+    @Before
+    public void setUp() throws Exception {
+        prepareBrokerWithMultiStore(true);
+        broker.start();
+        broker.waitUntilStarted();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        broker.stop();
+    }
+
+    protected BrokerService createBroker(PersistenceAdapter kaha) throws Exception {
+        BrokerService broker = new BrokerService();
+        broker.setUseJmx(true);
+        broker.setBrokerName("localhost");
+        broker.setPersistenceAdapter(kaha);
+        return broker;
+    }
+
+    @Test
+    public void testRestartAfterQueueDelete() throws Exception {
+
+        // Ensure we have an Admin View.
+        assertTrue("Broker doesn't have an Admin View.", Wait.waitFor(new Wait.Condition()
{
+            @Override
+            public boolean isSatisified() throws Exception {
+                return (broker.getAdminView()) != null;
+            }
+        }));
+
+
+        LOG.info("Adding initial destination: {}", destinationName);
+
+        broker.getAdminView().addQueue(destinationName);
+
+        assertNotNull(broker.getDestination(new ActiveMQQueue(destinationName)));
+
+        LOG.info("Removing initial destination: {}", destinationName);
+
+        broker.getAdminView().removeQueue(destinationName);
+
+        LOG.info("Adding back destination: {}", destinationName);
+
+        broker.getAdminView().addQueue(destinationName);
+
+        assertNotNull(broker.getDestination(new ActiveMQQueue(destinationName)));
+    }
+
+    protected KahaDBPersistenceAdapter createStore(boolean delete) throws IOException {
+        KahaDBPersistenceAdapter kaha = new KahaDBPersistenceAdapter();
+        kaha.setJournalMaxFileLength(maxFileLength);
+        kaha.setCleanupInterval(5000);
+        if (delete) {
+            kaha.deleteAllMessages();
+        }
+        return kaha;
+    }
+
+    public void prepareBrokerWithMultiStore(boolean deleteAllMessages) throws Exception {
+
+        MultiKahaDBPersistenceAdapter multiKahaDBPersistenceAdapter = new MultiKahaDBPersistenceAdapter();
+        if (deleteAllMessages) {
+            multiKahaDBPersistenceAdapter.deleteAllMessages();
+        }
+        ArrayList<FilteredKahaDBPersistenceAdapter> adapters = new ArrayList<FilteredKahaDBPersistenceAdapter>();
+
+        FilteredKahaDBPersistenceAdapter template = new FilteredKahaDBPersistenceAdapter();
+        template.setPersistenceAdapter(createStore(deleteAllMessages));
+        template.setPerDestination(true);
+        adapters.add(template);
+
+        multiKahaDBPersistenceAdapter.setFilteredPersistenceAdapters(adapters);
+        broker = createBroker(multiKahaDBPersistenceAdapter);
+    }
+}

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ4220Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/trunk/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java?rev=1421059&r1=1421058&r2=1421059&view=diff
==============================================================================
--- activemq/trunk/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java
(original)
+++ activemq/trunk/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java
Thu Dec 13 01:27:30 2012
@@ -124,7 +124,6 @@ public class MultiKahaDBPersistenceAdapt
     }
 
     private String nameFromDestinationFilter(ActiveMQDestination destination) {
-
         if (destination.getQualifiedName().length() > IOHelper.getMaxFileNameLength())
{
             LOG.warn("Destination name is longer than 'MaximumFileNameLength' system property,
" +
                      "potential problem with recovery can result from name truncation.");
@@ -247,10 +246,10 @@ public class MultiKahaDBPersistenceAdapt
     @Override
     public void removeQueueMessageStore(ActiveMQQueue destination) {
         PersistenceAdapter adapter = getMatchingPersistenceAdapter(destination);
-        adapter.removeQueueMessageStore(destination);
         if (adapter instanceof KahaDBPersistenceAdapter) {
             adapter.removeQueueMessageStore(destination);
             removeMessageStore((KahaDBPersistenceAdapter)adapter, destination);
+            removeAll(destination);
         }
     }
 
@@ -260,6 +259,7 @@ public class MultiKahaDBPersistenceAdapt
         if (adapter instanceof KahaDBPersistenceAdapter) {
             adapter.removeTopicMessageStore(destination);
             removeMessageStore((KahaDBPersistenceAdapter)adapter, destination);
+            removeAll(destination);
         }
     }
 
@@ -464,5 +464,4 @@ public class MultiKahaDBPersistenceAdapt
         String path = getDirectory() != null ? getDirectory().getAbsolutePath() : "DIRECTORY_NOT_SET";
         return "MultiKahaDBPersistenceAdapter[" + path + "]" + adapters;
     }
-
 }



Mime
View raw message