activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cepo...@apache.org
Subject svn commit: r1480060 - in /activemq/trunk/activemq-leveldb-store/src: main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBStore.scala test/java/org/apache/activemq/leveldb/test/MasterLevelDBStoreTest.java
Date Tue, 07 May 2013 20:29:56 GMT
Author: ceposta
Date: Tue May  7 20:29:56 2013
New Revision: 1480060

URL: http://svn.apache.org/r1480060
Log:
fix for https://issues.apache.org/jira/browse/AMQ-4519 - MasterLevelDBStore does not shutdown
its protocol server when stopped
made fix and added test

Added:
    activemq/trunk/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/MasterLevelDBStoreTest.java
Modified:
    activemq/trunk/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBStore.scala

Modified: activemq/trunk/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBStore.scala
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBStore.scala?rev=1480060&r1=1480059&r2=1480060&view=diff
==============================================================================
--- activemq/trunk/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBStore.scala
(original)
+++ activemq/trunk/activemq-leveldb-store/src/main/scala/org/apache/activemq/leveldb/replicated/MasterLevelDBStore.scala
Tue May  7 20:29:56 2013
@@ -58,7 +58,7 @@ class MasterLevelDBStore extends LevelDB
 
   override def doStop(stopper: ServiceStopper): Unit = {
     if( transport_server!=null ) {
-      transport_server.start(NOOP)
+      stop_protocol_server
       transport_server = null
     }
     super.doStop(stopper)

Added: activemq/trunk/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/MasterLevelDBStoreTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/MasterLevelDBStoreTest.java?rev=1480060&view=auto
==============================================================================
--- activemq/trunk/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/MasterLevelDBStoreTest.java
(added)
+++ activemq/trunk/activemq-leveldb-store/src/test/java/org/apache/activemq/leveldb/test/MasterLevelDBStoreTest.java
Tue May  7 20:29:56 2013
@@ -0,0 +1,85 @@
+/**
+ * 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.leveldb.test;
+
+import junit.framework.TestCase;
+import org.apache.activemq.leveldb.replicated.MasterLevelDBStore;
+
+import java.net.BindException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.URI;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * @author <a href="http://www.christianposta.com/blog">Christian Posta</a>
+ */
+public class MasterLevelDBStoreTest extends TestCase {
+
+    public void testStoppingStoreStopsTransport() throws Exception {
+        final MasterLevelDBStore store = new MasterLevelDBStore();
+        store.setReplicas(0);
+
+        ExecutorService threads = Executors.newFixedThreadPool(1);
+        threads.execute(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    store.start();
+                } catch (Exception e) {
+                    e.printStackTrace();  //To change body of catch statement use File |
Settings | File Templates.
+                }
+            }
+        });
+
+        // give some time to come up..
+        Thread.sleep(2000);
+        String address = store.transport_server().getBoundAddress();
+        URI bindAddress = new URI(address);
+        System.out.println(address);
+        Socket socket = new Socket();
+        try {
+            socket.bind(new InetSocketAddress(bindAddress.getHost(), bindAddress.getPort()));
+            fail("We should not have been able to connect...");
+        } catch (BindException e) {
+            System.out.println("Good. We cannot bind.");
+        }
+
+
+        threads.execute(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    store.stop();
+                } catch (Exception e) {
+                    e.printStackTrace();  //To change body of catch statement use File |
Settings | File Templates.
+                }
+            }
+        });
+
+        Thread.sleep(2000);
+        try {
+            socket.bind(new InetSocketAddress(bindAddress.getHost(), bindAddress.getPort()));
+            System.out.println("Can bind, so protocol server must have been shut down.");
+
+        } catch (IllegalStateException e) {
+            fail("Server protocol port is still opened..");
+        }
+
+    }
+}



Mime
View raw message