activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-6033 - fix shadowing error, additional test
Date Mon, 02 Nov 2015 15:21:55 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 014d5594d -> fd0f71a4c


https://issues.apache.org/jira/browse/AMQ-6033 - fix shadowing error, additional test


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/fd0f71a4
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/fd0f71a4
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/fd0f71a4

Branch: refs/heads/master
Commit: fd0f71a4c82f1189bed6bd31efa4b17c297816f7
Parents: 014d559
Author: gtully <gary.tully@gmail.com>
Authored: Mon Nov 2 15:07:56 2015 +0000
Committer: gtully <gary.tully@gmail.com>
Committed: Mon Nov 2 15:08:22 2015 +0000

----------------------------------------------------------------------
 .../kahadb/MultiKahaDBPersistenceAdapter.java   |  8 +--
 .../activemq/store/MKahaDbSharedLockerTest.java | 72 ++++++++++++++++++++
 2 files changed, 73 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/fd0f71a4/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java
b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java
index d46108a..31268a3 100644
--- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java
+++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java
@@ -83,7 +83,6 @@ public class MultiKahaDBPersistenceAdapter extends LockableServiceSupport
implem
     };
     final DelegateDestinationMap destinationMap = new DelegateDestinationMap();
 
-    BrokerService brokerService;
     List<PersistenceAdapter> adapters = new CopyOnWriteArrayList<PersistenceAdapter>();
     private File directory = new File(IOHelper.getDefaultDataDirectory() + File.separator
+ "mKahaDB");
 
@@ -470,7 +469,7 @@ public class MultiKahaDBPersistenceAdapter extends LockableServiceSupport
implem
 
     @Override
     public void setBrokerService(BrokerService brokerService) {
-        this.brokerService = brokerService;
+        super.setBrokerService(brokerService);
         for (PersistenceAdapter persistenceAdapter : adapters) {
             if( persistenceAdapter instanceof BrokerServiceAware ) {
                 ((BrokerServiceAware)persistenceAdapter).setBrokerService(getBrokerService());
@@ -478,11 +477,6 @@ public class MultiKahaDBPersistenceAdapter extends LockableServiceSupport
implem
         }
     }
 
-    @Override
-    public BrokerService getBrokerService() {
-        return brokerService;
-    }
-
     public void setTransactionStore(MultiKahaDBTransactionStore transactionStore) {
         this.transactionStore = transactionStore;
     }

http://git-wip-us.apache.org/repos/asf/activemq/blob/fd0f71a4/activemq-unit-tests/src/test/java/org/apache/activemq/store/MKahaDbSharedLockerTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/MKahaDbSharedLockerTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/store/MKahaDbSharedLockerTest.java
new file mode 100644
index 0000000..f61179e
--- /dev/null
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/MKahaDbSharedLockerTest.java
@@ -0,0 +1,72 @@
+/**
+ * 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.store;
+
+import java.io.File;
+import java.util.LinkedList;
+import java.util.List;
+import junit.framework.TestCase;
+import org.apache.activemq.broker.BrokerService;
+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.apache.commons.io.FileUtils;
+
+public class MKahaDbSharedLockerTest extends TestCase {
+
+
+    public void testBrokerShutdown() throws Exception {
+        final BrokerService master = new BrokerService();
+        master.setBrokerName("master");
+
+        master.setUseJmx(false);
+        master.setPersistent(true);
+        master.setDeleteAllMessagesOnStartup(true);
+
+        MultiKahaDBPersistenceAdapter mKahaDB = new MultiKahaDBPersistenceAdapter();
+        mKahaDB.setDirectory(new File("target/test/kahadb"));
+        List adapters = new LinkedList<FilteredKahaDBPersistenceAdapter>();
+        FilteredKahaDBPersistenceAdapter defaultEntry = new FilteredKahaDBPersistenceAdapter();
+        defaultEntry.setPersistenceAdapter(new KahaDBPersistenceAdapter());
+        defaultEntry.setPerDestination(true);
+        adapters.add(defaultEntry);
+
+        mKahaDB.setFilteredPersistenceAdapters(adapters);
+        master.setPersistenceAdapter(mKahaDB);
+
+        SharedFileLocker sharedFileLocker = new SharedFileLocker();
+        mKahaDB.setLockKeepAlivePeriod(1000);
+        mKahaDB.setLocker(sharedFileLocker);
+
+        master.start();
+        master.waitUntilStarted();
+
+        FileUtils.forceDelete(new File("target/test/kahadb/lock"));
+
+        assertTrue("broker should be stopped now", Wait.waitFor(new Wait.Condition() {
+            @Override
+            public boolean isSatisified() throws Exception {
+                return master.isStopped();
+            }
+        }));
+
+        master.stop();
+        master.waitUntilStopped();
+    }
+
+}
\ No newline at end of file


Mime
View raw message