From 924e39c0311b7a0c5c10c818f486a7f5ffea0f30 Mon Sep 17 00:00:00 2001 From: shtykh_roman Date: Wed, 21 Dec 2016 19:23:04 +0900 Subject: [PATCH 1/3] Closing the channel. Fix for ROCKETMQ-2. --- .../java/com/alibaba/rocketmq/store/ha/HAService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/ha/HAService.java b/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/ha/HAService.java index 00f9833750e..5b476f8b5c2 100644 --- a/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/ha/HAService.java +++ b/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/ha/HAService.java @@ -194,6 +194,16 @@ public void beginAccept() { } } + @Override + public void shutdown(final boolean interrupt) { + super.shutdown(interrupt); + try { + serverSocketChannel.close(); + } + catch (IOException e) { + log.error("AcceptSocketService shutdown exception", e); + } + } @Override public void run() { From 52a231e19fa9f3a90b707a5f9f99c288647f709f Mon Sep 17 00:00:00 2001 From: shtykh_roman Date: Thu, 22 Dec 2016 10:52:31 +0900 Subject: [PATCH 2/3] JIRA Issue: https://issues.apache.org/jira/browse/ROCKETMQ-2 Added the test and propagated the exception to be able to catch. --- .../rocketmq/broker/BrokerControllerTest.java | 37 +++++++++++++++++++ .../alibaba/rocketmq/store/ha/HAService.java | 20 ++++------ 2 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 rocketmq-broker/src/test/java/com/alibaba/rocketmq/broker/BrokerControllerTest.java diff --git a/rocketmq-broker/src/test/java/com/alibaba/rocketmq/broker/BrokerControllerTest.java b/rocketmq-broker/src/test/java/com/alibaba/rocketmq/broker/BrokerControllerTest.java new file mode 100644 index 00000000000..5567ce17853 --- /dev/null +++ b/rocketmq-broker/src/test/java/com/alibaba/rocketmq/broker/BrokerControllerTest.java @@ -0,0 +1,37 @@ +package com.alibaba.rocketmq.broker; + +import com.alibaba.rocketmq.common.BrokerConfig; +import com.alibaba.rocketmq.remoting.netty.NettyClientConfig; +import com.alibaba.rocketmq.remoting.netty.NettyServerConfig; +import com.alibaba.rocketmq.store.config.MessageStoreConfig; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author shtykh_roman + */ +public class BrokerControllerTest { + private static final int RESTART_NUM = 3; + + /** + * Tests if the controller can be properly stopped and started. + * + * @throws Exception If fails. + */ + @Test + public void testRestart() throws Exception { + + for (int i=0; i Date: Thu, 22 Dec 2016 11:40:35 +0900 Subject: [PATCH 3/3] JIRA Issue: https://issues.apache.org/jira/browse/ROCKETMQ-2 Added ASF header. --- .../rocketmq/broker/BrokerControllerTest.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/rocketmq-broker/src/test/java/com/alibaba/rocketmq/broker/BrokerControllerTest.java b/rocketmq-broker/src/test/java/com/alibaba/rocketmq/broker/BrokerControllerTest.java index 5567ce17853..6b0b62d3940 100644 --- a/rocketmq-broker/src/test/java/com/alibaba/rocketmq/broker/BrokerControllerTest.java +++ b/rocketmq-broker/src/test/java/com/alibaba/rocketmq/broker/BrokerControllerTest.java @@ -1,10 +1,26 @@ +/** + * 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 com.alibaba.rocketmq.broker; import com.alibaba.rocketmq.common.BrokerConfig; import com.alibaba.rocketmq.remoting.netty.NettyClientConfig; import com.alibaba.rocketmq.remoting.netty.NettyServerConfig; import com.alibaba.rocketmq.store.config.MessageStoreConfig; -import org.junit.Assert; import org.junit.Test; /** @@ -21,7 +37,7 @@ public class BrokerControllerTest { @Test public void testRestart() throws Exception { - for (int i=0; i