From 360341e56da3dfed2c5175e99a599aff9e772a3e Mon Sep 17 00:00:00 2001 From: "zhendongliu.lzd" Date: Mon, 26 Dec 2016 10:31:45 +0800 Subject: [PATCH 01/14] [ROCKETMQ-3] Remove try...catch, using assertNull etc --- .../java/com/alibaba/rocketmq/broker/BrokerControllerTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 9246d6f208f..b6613853a9a 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 @@ -21,6 +21,7 @@ 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; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,8 +49,8 @@ public void testRestart() throws Exception { new NettyClientConfig(), // new MessageStoreConfig()); boolean initResult = brokerController.initialize(); + Assert.assertTrue(initResult); logger.info("Broker is initialized " + initResult); - brokerController.start(); logger.info("Broker is started"); From f1552f6e66b283bdd429cd4fc82fb9046a20f868 Mon Sep 17 00:00:00 2001 From: shtykh_roman Date: Mon, 26 Dec 2016 12:17:53 +0900 Subject: [PATCH 02/14] [ROCKETMQ-13] Wrong log level for AcceptSocketService termination. Additionally, added code comments and did a cleanup. JIRA issue: https://issues.apache.org/jira/browse/ROCKETMQ-13 --- .../alibaba/rocketmq/store/ha/HAService.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) 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 075252cb3a6..2cf695c588f 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 @@ -46,7 +46,7 @@ public class HAService { private final AtomicInteger connectionCount = new AtomicInteger(0); - private final List connectionList = new LinkedList(); + private final List connectionList = new LinkedList<>(); private final AcceptSocketService acceptSocketService; @@ -170,17 +170,22 @@ public AtomicLong getPush2SlaveMaxOffset() { return push2SlaveMaxOffset; } + /** + * Listens to slave connections to create {@link HAConnection}. + */ class AcceptSocketService extends ServiceThread { private ServerSocketChannel serverSocketChannel; private Selector selector; private final SocketAddress socketAddressListen; - public AcceptSocketService(final int port) { this.socketAddressListen = new InetSocketAddress(port); } - + /** + * Starts listening to slave connections. + * @throws Exception If fails. + */ public void beginAccept() throws Exception { this.serverSocketChannel = ServerSocketChannel.open(); this.selector = RemotingUtil.openSelector(); @@ -190,6 +195,7 @@ public void beginAccept() throws Exception { this.serverSocketChannel.register(this.selector, SelectionKey.OP_ACCEPT); } + /** {@inheritDoc} */ @Override public void shutdown(final boolean interrupt) { super.shutdown(interrupt); @@ -202,6 +208,7 @@ public void shutdown(final boolean interrupt) { } } + /** {@inheritDoc} */ @Override public void run() { log.info(this.getServiceName() + " service started"); @@ -210,10 +217,12 @@ public void run() { try { this.selector.select(1000); Set selected = this.selector.selectedKeys(); + if (selected != null) { for (SelectionKey k : selected) { if ((k.readyOps() & SelectionKey.OP_ACCEPT) != 0) { SocketChannel sc = ((ServerSocketChannel) k.channel()).accept(); + if (sc != null) { HAService.log.info("HAService receive new connection, " + sc.socket().getRemoteSocketAddress()); @@ -234,16 +243,15 @@ public void run() { selected.clear(); } - } catch (Exception e) { log.error(this.getServiceName() + " service has exception.", e); } } - log.error(this.getServiceName() + " service end"); + log.info(this.getServiceName() + " service end"); } - + /** {@inheritDoc} */ @Override public String getServiceName() { return AcceptSocketService.class.getSimpleName(); @@ -256,8 +264,8 @@ public String getServiceName() { class GroupTransferService extends ServiceThread { private final WaitNotifyObject notifyTransferObject = new WaitNotifyObject(); - private volatile List requestsWrite = new ArrayList(); - private volatile List requestsRead = new ArrayList(); + private volatile List requestsWrite = new ArrayList<>(); + private volatile List requestsRead = new ArrayList<>(); public void putRequest(final GroupCommitRequest request) { @@ -333,7 +341,7 @@ public String getServiceName() { class HAClient extends ServiceThread { private static final int READ_MAX_BUFFER_SIZE = 1024 * 1024 * 4; - private final AtomicReference masterAddress = new AtomicReference(); + private final AtomicReference masterAddress = new AtomicReference<>(); private final ByteBuffer reportOffset = ByteBuffer.allocate(8); private SocketChannel socketChannel; private Selector selector; From e8deb23cb0481bfa175dbf74e675eaef4f2c733e Mon Sep 17 00:00:00 2001 From: shtykh_roman Date: Mon, 26 Dec 2016 18:32:00 +0900 Subject: [PATCH 03/14] [ROCKETMQ-9] Errors in rocketmq-store module. JIRA issue: https://issues.apache.org/jira/browse/ROCKETMQ-9 --- .../store/AllocateMappedFileService.java | 2 +- .../rocketmq/store/MappedFileQueue.java | 26 ++++++++++------ .../rocketmq/store/index/IndexFile.java | 5 ++- .../rocketmq/store/index/IndexService.java | 31 ++++++++++--------- .../rocketmq/store/MappedFileQueueTest.java | 17 ++++++++-- .../rocketmq/store/index/IndexFileTest.java | 18 ++++++----- .../src/test/resources/logback-test.xml | 2 +- 7 files changed, 63 insertions(+), 38 deletions(-) diff --git a/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/AllocateMappedFileService.java b/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/AllocateMappedFileService.java index 40eee7a6603..06113c82c10 100644 --- a/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/AllocateMappedFileService.java +++ b/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/AllocateMappedFileService.java @@ -213,7 +213,7 @@ private boolean mmapOperation() { isSuccess = true; } } catch (InterruptedException e) { - log.warn(this.getServiceName() + " service has exception, maybe by shutdown"); + log.warn(this.getServiceName() + " interrupted, possibly by shutdown."); this.hasException = true; return false; } catch (IOException e) { diff --git a/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/MappedFileQueue.java b/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/MappedFileQueue.java index 2b006c0e533..8d9d3ab0b4a 100644 --- a/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/MappedFileQueue.java +++ b/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/MappedFileQueue.java @@ -459,27 +459,35 @@ public boolean commit(final int commitLeastPages) { return result; } - + /** + * Finds a mapped file by offset. + * + * @param offset Offset. + * @param returnFirstOnNotFound If the mapped file is not found, then return the first one. + * @return Mapped file or null (when not found and returnFirstOnNotFound is false). + */ public MappedFile findMappedFileByOffset(final long offset, final boolean returnFirstOnNotFound) { try { MappedFile mappedFile = this.getFirstMappedFile(); if (mappedFile != null) { int index = (int) ((offset / this.mappedFileSize) - (mappedFile.getFileFromOffset() / this.mappedFileSize)); if (index < 0 || index >= this.mappedFiles.size()) { - LOG_ERROR.warn("findMappedFileByOffset offset not matched, request Offset: {}, index: {}, mappedFileSize: {}, mappedFiles count: {}, StackTrace: {}", - offset, - index, - this.mappedFileSize, - this.mappedFiles.size(), - UtilAll.currentStackTrace()); + LOG_ERROR.warn("Offset for {} not matched. Request offset: {}, index: {}, " + + "mappedFileSize: {}, mappedFiles count: {}", + mappedFile, + offset, + index, + this.mappedFileSize, + this.mappedFiles.size()); } try { return this.mappedFiles.get(index); } catch (Exception e) { - if (returnFirstOnNotFound) { + if (returnFirstOnNotFound) return mappedFile; - } + + LOG_ERROR.warn("findMappedFileByOffset failure. {}", UtilAll.currentStackTrace()); } } } catch (Exception e) { diff --git a/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/index/IndexFile.java b/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/index/IndexFile.java index f35332014eb..befa5f9aa82 100644 --- a/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/index/IndexFile.java +++ b/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/index/IndexFile.java @@ -94,7 +94,6 @@ public boolean isWriteFull() { return this.indexHeader.getIndexCount() >= this.indexNum; } - public boolean destroy(final long intervalForcibly) { return this.mappedFile.destroy(intervalForcibly); } @@ -167,8 +166,8 @@ public boolean putKey(final String key, final long phyOffset, final long storeTi } } } else { - log.warn("putKey index count " + this.indexHeader.getIndexCount() + " index max num " - + this.indexNum); + log.warn("Over index file capacity: index count = " + this.indexHeader.getIndexCount() + + "; index max num = " + this.indexNum); } return false; diff --git a/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/index/IndexService.java b/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/index/IndexService.java index f275f80875d..fded74734c2 100644 --- a/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/index/IndexService.java +++ b/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/index/IndexService.java @@ -49,6 +49,9 @@ public class IndexService { private final ArrayList indexFileList = new ArrayList(); private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock(); + /** Maximum times to attempt index file creation. */ + private static final int MAX_TRY_IDX_CREATE = 3; + public IndexService(final DefaultMessageStore store) { this.defaultMessageStore = store; @@ -257,44 +260,44 @@ public void buildIndex(DispatchRequest req) { private IndexFile putKey(IndexFile indexFile, DispatchRequest msg, String idxKey) { - for (boolean ok = - indexFile.putKey(idxKey, msg.getCommitLogOffset(), - msg.getStoreTimestamp()); !ok; ) { - log.warn("index file full, so create another one, " + indexFile.getFileName()); + for (boolean ok = indexFile.putKey(idxKey, msg.getCommitLogOffset(), msg.getStoreTimestamp()); !ok; ) { + log.warn("Index file [" + indexFile.getFileName() + "] is full, trying to create another one"); + indexFile = retryGetAndCreateIndexFile(); if (null == indexFile) { return null; } - ok = - indexFile.putKey(idxKey, msg.getCommitLogOffset(), - msg.getStoreTimestamp()); + ok = indexFile.putKey(idxKey, msg.getCommitLogOffset(), msg.getStoreTimestamp()); } + return indexFile; } - - public IndexFile retryGetAndCreateIndexFile() { + /** + * Retries to get or create index file. + * + * @return {@link IndexFile} or null on failure. + */ + private IndexFile retryGetAndCreateIndexFile() { IndexFile indexFile = null; - - for (int times = 0; null == indexFile && times < 3; times++) { + for (int times = 0; null == indexFile && times < MAX_TRY_IDX_CREATE; times++) { indexFile = this.getAndCreateLastIndexFile(); if (null != indexFile) break; try { - log.error("try to create index file, " + times + " times"); + log.error("Tried to create index file " + times + " times"); Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } - if (null == indexFile) { this.defaultMessageStore.getAccessRights().makeIndexFileError(); - log.error("mark index file can not build flag"); + log.error("Mark index file cannot build flag"); } return indexFile; diff --git a/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/MappedFileQueueTest.java b/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/MappedFileQueueTest.java index 89b37be1019..700f1c604eb 100644 --- a/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/MappedFileQueueTest.java +++ b/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/MappedFileQueueTest.java @@ -52,6 +52,7 @@ public void tearDown() throws Exception { @Test public void test_getLastMapedFile() { final String fixedMsg = "0123456789abcdef"; + logger.debug("================================================================"); MappedFileQueue mappedFileQueue = new MappedFileQueue("target/unit_test_store/a/", 1024, null); @@ -59,6 +60,7 @@ public void test_getLastMapedFile() { for (int i = 0; i < 1024; i++) { MappedFile mappedFile = mappedFileQueue.getLastMappedFile(0); assertTrue(mappedFile != null); + boolean result = mappedFile.appendMessage(fixedMsg.getBytes()); if (!result) { logger.debug("appendMessage " + i); @@ -74,7 +76,9 @@ public void test_getLastMapedFile() { @Test public void test_findMapedFileByOffset() { + // four-byte string. final String fixedMsg = "abcd"; + logger.debug("================================================================"); MappedFileQueue mappedFileQueue = new MappedFileQueue("target/unit_test_store/b/", 1024, null); @@ -82,11 +86,13 @@ public void test_findMapedFileByOffset() { for (int i = 0; i < 1024; i++) { MappedFile mappedFile = mappedFileQueue.getLastMappedFile(0); assertTrue(mappedFile != null); + boolean result = mappedFile.appendMessage(fixedMsg.getBytes()); - // logger.debug("appendMessage " + bytes); assertTrue(result); } + assertEquals(fixedMsg.getBytes().length * 1024, mappedFileQueue.getMappedMemorySize()); + MappedFile mappedFile = mappedFileQueue.findMappedFileByOffset(0); assertTrue(mappedFile != null); assertEquals(mappedFile.getFileFromOffset(), 0); @@ -110,7 +116,8 @@ public void test_findMapedFileByOffset() { mappedFile = mappedFileQueue.findMappedFileByOffset(1024 * 2 + 100); assertTrue(mappedFile != null); assertEquals(mappedFile.getFileFromOffset(), 1024 * 2); - + + // over mapped memory size. mappedFile = mappedFileQueue.findMappedFileByOffset(1024 * 4); assertTrue(mappedFile == null); @@ -125,6 +132,7 @@ public void test_findMapedFileByOffset() { @Test public void test_commit() { final String fixedMsg = "0123456789abcdef"; + logger.debug("================================================================"); MappedFileQueue mappedFileQueue = new MappedFileQueue("target/unit_test_store/c/", 1024, null); @@ -132,6 +140,7 @@ public void test_commit() { for (int i = 0; i < 1024; i++) { MappedFile mappedFile = mappedFileQueue.getLastMappedFile(0); assertTrue(mappedFile != null); + boolean result = mappedFile.appendMessage(fixedMsg.getBytes()); assertTrue(result); } @@ -168,6 +177,7 @@ public void test_commit() { @Test public void test_getMapedMemorySize() { final String fixedMsg = "abcd"; + logger.debug("================================================================"); MappedFileQueue mappedFileQueue = new MappedFileQueue("target/unit_test_store/d/", 1024, null); @@ -175,14 +185,15 @@ public void test_getMapedMemorySize() { for (int i = 0; i < 1024; i++) { MappedFile mappedFile = mappedFileQueue.getLastMappedFile(0); assertTrue(mappedFile != null); + boolean result = mappedFile.appendMessage(fixedMsg.getBytes()); assertTrue(result); } assertEquals(fixedMsg.length() * 1024, mappedFileQueue.getMappedMemorySize()); + mappedFileQueue.shutdown(1000); mappedFileQueue.destroy(); logger.debug("MappedFileQueue.getMappedMemorySize() OK"); } - } diff --git a/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/index/IndexFileTest.java b/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/index/IndexFileTest.java index f6bfc0a660a..9e446f7c1a1 100644 --- a/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/index/IndexFileTest.java +++ b/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/index/IndexFileTest.java @@ -31,17 +31,18 @@ public class IndexFileTest { - private static final int hashSlotNum = 100; - private static final int indexNum = 400; + private static final int HASH_SLOT_NUM = 100; + private static final int INDEX_NUM = 400; @Test public void test_put_index() throws Exception { - IndexFile indexFile = new IndexFile("100", hashSlotNum, indexNum, 0, 0); - for (long i = 0; i < (indexNum - 1); i++) { + IndexFile indexFile = new IndexFile("100", HASH_SLOT_NUM, INDEX_NUM, 0, 0); + for (long i = 0; i < (INDEX_NUM - 1); i++) { boolean putResult = indexFile.putKey(Long.toString(i), i, System.currentTimeMillis()); assertTrue(putResult); } - + + // put over index file capacity. boolean putResult = indexFile.putKey(Long.toString(400), 400, System.currentTimeMillis()); assertFalse(putResult); @@ -51,12 +52,14 @@ public void test_put_index() throws Exception { @Test public void test_put_get_index() throws Exception { - IndexFile indexFile = new IndexFile("200", hashSlotNum, indexNum, 0, 0); + IndexFile indexFile = new IndexFile("200", HASH_SLOT_NUM, INDEX_NUM, 0, 0); - for (long i = 0; i < (indexNum - 1); i++) { + for (long i = 0; i < (INDEX_NUM - 1); i++) { boolean putResult = indexFile.putKey(Long.toString(i), i, System.currentTimeMillis()); assertTrue(putResult); } + + // put over index file capacity. boolean putResult = indexFile.putKey(Long.toString(400), 400, System.currentTimeMillis()); assertFalse(putResult); @@ -64,6 +67,7 @@ public void test_put_get_index() throws Exception { indexFile.selectPhyOffset(phyOffsets, "60", 10, 0, Long.MAX_VALUE, true); assertFalse(phyOffsets.isEmpty()); assertEquals(1, phyOffsets.size()); + indexFile.destroy(0); } } diff --git a/rocketmq-store/src/test/resources/logback-test.xml b/rocketmq-store/src/test/resources/logback-test.xml index acdfa10b267..11d429dfd8c 100644 --- a/rocketmq-store/src/test/resources/logback-test.xml +++ b/rocketmq-store/src/test/resources/logback-test.xml @@ -27,7 +27,7 @@ - + From b85645996a573b19159ad184007484a99742cc5f Mon Sep 17 00:00:00 2001 From: Willem Jiang Date: Tue, 27 Dec 2016 13:33:43 +0800 Subject: [PATCH 04/14] [ROCKETMQ-9] Clean up the code --- .../java/com/alibaba/rocketmq/store/MappedFileQueue.java | 6 +++--- .../java/com/alibaba/rocketmq/store/index/IndexService.java | 4 ++-- rocketmq-store/src/test/resources/logback-test.xml | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/MappedFileQueue.java b/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/MappedFileQueue.java index 8d9d3ab0b4a..0d15ece1d24 100644 --- a/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/MappedFileQueue.java +++ b/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/MappedFileQueue.java @@ -484,10 +484,10 @@ public MappedFile findMappedFileByOffset(final long offset, final boolean return try { return this.mappedFiles.get(index); } catch (Exception e) { - if (returnFirstOnNotFound) + if (returnFirstOnNotFound) { return mappedFile; - - LOG_ERROR.warn("findMappedFileByOffset failure. {}", UtilAll.currentStackTrace()); + } + LOG_ERROR.warn("findMappedFileByOffset failure. ", e); } } } catch (Exception e) { diff --git a/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/index/IndexService.java b/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/index/IndexService.java index fded74734c2..f4f27bc3b8d 100644 --- a/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/index/IndexService.java +++ b/rocketmq-store/src/main/java/com/alibaba/rocketmq/store/index/IndexService.java @@ -279,7 +279,7 @@ private IndexFile putKey(IndexFile indexFile, DispatchRequest msg, String idxKey * * @return {@link IndexFile} or null on failure. */ - private IndexFile retryGetAndCreateIndexFile() { + public IndexFile retryGetAndCreateIndexFile() { IndexFile indexFile = null; for (int times = 0; null == indexFile && times < MAX_TRY_IDX_CREATE; times++) { @@ -288,7 +288,7 @@ private IndexFile retryGetAndCreateIndexFile() { break; try { - log.error("Tried to create index file " + times + " times"); + log.info("Tried to create index file " + times + " times"); Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); diff --git a/rocketmq-store/src/test/resources/logback-test.xml b/rocketmq-store/src/test/resources/logback-test.xml index 11d429dfd8c..6754c0aaf37 100644 --- a/rocketmq-store/src/test/resources/logback-test.xml +++ b/rocketmq-store/src/test/resources/logback-test.xml @@ -20,6 +20,7 @@ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n + UTF-8 From 1aca01f26ef362d340ef009a8f1d5cbed9b9db48 Mon Sep 17 00:00:00 2001 From: vongosling Date: Fri, 23 Dec 2016 11:50:16 +0800 Subject: [PATCH 05/14] Remove redundant groupId statement if it is stardard maven plugin --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8c20a239b38..4650af1aa33 100644 --- a/pom.xml +++ b/pom.xml @@ -313,7 +313,6 @@ - org.apache.maven.plugins maven-checkstyle-plugin 2.17 From 2a43743d81540bb161ff883623922901f63084bf Mon Sep 17 00:00:00 2001 From: Willem Jiang Date: Fri, 23 Dec 2016 12:42:59 +0800 Subject: [PATCH 06/14] ROCKETMQ-3 Clean up the unit test code of rocketmq-store --- pom.xml | 7 +- rocketmq-store/pom.xml | 18 +++- .../store/DefaultMessageStoreTest.java | 78 ++++++++++-------- .../rocketmq/store/MappedFileQueueTest.java | 59 ++++++------- .../rocketmq/store/MappedFileTest.java | 82 +++++++++---------- .../alibaba/rocketmq/store/RecoverTest.java | 3 +- .../rocketmq/store/StoreCheckpointTest.java | 35 ++++---- .../rocketmq/store/index/IndexFileTest.java | 61 ++++++-------- .../src/test/resources/logback-test.xml | 34 ++++++++ 9 files changed, 200 insertions(+), 177 deletions(-) create mode 100644 rocketmq-store/src/test/resources/logback-test.xml diff --git a/pom.xml b/pom.xml index 4650af1aa33..decb3525f1b 100644 --- a/pom.xml +++ b/pom.xml @@ -347,12 +347,7 @@ maven-resources-plugin 3.0.2 - - - src/main/resources - false - - + ${project.build.sourceEncoding} diff --git a/rocketmq-store/pom.xml b/rocketmq-store/pom.xml index 440e521a37c..d37384269f1 100644 --- a/rocketmq-store/pom.xml +++ b/rocketmq-store/pom.xml @@ -29,18 +29,28 @@ rocketmq-store ${project.version} + + ${project.groupId} + rocketmq-common + + + net.java.dev.jna + jna + junit junit test - ${project.groupId} - rocketmq-common + ch.qos.logback + logback-classic + test - net.java.dev.jna - jna + ch.qos.logback + logback-core + test diff --git a/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/DefaultMessageStoreTest.java b/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/DefaultMessageStoreTest.java index ac577c7930e..d1784cd98cb 100644 --- a/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/DefaultMessageStoreTest.java +++ b/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/DefaultMessageStoreTest.java @@ -17,11 +17,14 @@ package com.alibaba.rocketmq.store; +import com.alibaba.rocketmq.common.BrokerConfig; import com.alibaba.rocketmq.store.config.FlushDiskType; import com.alibaba.rocketmq.store.config.MessageStoreConfig; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.net.InetAddress; import java.net.InetSocketAddress; @@ -35,6 +38,8 @@ * @author shijia.wxr */ public class DefaultMessageStoreTest { + private static final Logger logger = LoggerFactory.getLogger(DefaultMessageStoreTest.class); + private static final String StoreMessage = "Once, there was a chance for me!"; private static int QUEUE_TOTAL = 100; @@ -59,7 +64,7 @@ public static void tearDownAfterClass() throws Exception { @Test public void test_write_read() throws Exception { - System.out.println("================================================================"); + logger.debug("================================================================"); long totalMsgs = 100; QUEUE_TOTAL = 1; MessageBody = StoreMessage.getBytes(); @@ -69,34 +74,32 @@ public void test_write_read() throws Exception { messageStoreConfig.setMapedFileSizeConsumeQueue(1024 * 4); messageStoreConfig.setMaxHashSlotNum(100); messageStoreConfig.setMaxIndexNum(100 * 10); - MessageStore master = new DefaultMessageStore(messageStoreConfig, null, null, null); + MessageStore master = new DefaultMessageStore(messageStoreConfig, null, new MyMessageArrivingListener(), new BrokerConfig()); boolean load = master.load(); assertTrue(load); master.start(); - for (long i = 0; i < totalMsgs; i++) { - PutMessageResult result = master.putMessage(buildMessage()); - System.out.println(i + "\t" + result.getAppendMessageResult().getMsgId()); - } - - for (long i = 0; i < totalMsgs; i++) { - try { + try { + for (long i = 0; i < totalMsgs; i++) { + PutMessageResult result = master.putMessage(buildMessage()); + logger.debug(i + "\t" + result.getAppendMessageResult().getMsgId()); + } + + for (long i = 0; i < totalMsgs; i++) { GetMessageResult result = master.getMessage("GROUP_A", "TOPIC_A", 0, i, 1024 * 1024, null); if (result == null) { - System.out.println("result == null " + i); + logger.debug("result == null " + i); } assertTrue(result != null); result.release(); - System.out.println("read " + i + " OK"); - } catch (Exception e) { - e.printStackTrace(); + logger.debug("read " + i + " OK"); } - + } finally { + master.shutdown(); + master.destroy(); } - master.shutdown(); - master.destroy(); - System.out.println("================================================================"); + logger.debug("================================================================"); } public MessageExtBrokerInner buildMessage() { @@ -116,39 +119,46 @@ public MessageExtBrokerInner buildMessage() { @Test public void test_group_commit() throws Exception { - System.out.println("================================================================"); + logger.debug("================================================================"); long totalMsgs = 100; QUEUE_TOTAL = 1; MessageBody = StoreMessage.getBytes(); MessageStoreConfig messageStoreConfig = new MessageStoreConfig(); messageStoreConfig.setMapedFileSizeCommitLog(1024 * 8); messageStoreConfig.setFlushDiskType(FlushDiskType.SYNC_FLUSH); - MessageStore master = new DefaultMessageStore(messageStoreConfig, null, null, null); + MessageStore master = new DefaultMessageStore(messageStoreConfig, null, new MyMessageArrivingListener(), new BrokerConfig()); boolean load = master.load(); assertTrue(load); master.start(); - for (long i = 0; i < totalMsgs; i++) { - PutMessageResult result = master.putMessage(buildMessage()); - System.out.println(i + "\t" + result.getAppendMessageResult().getMsgId()); - } - - for (long i = 0; i < totalMsgs; i++) { - try { + try { + for (long i = 0; i < totalMsgs; i++) { + PutMessageResult result = master.putMessage(buildMessage()); + logger.debug(i + "\t" + result.getAppendMessageResult().getMsgId()); + } + + for (long i = 0; i < totalMsgs; i++) { GetMessageResult result = master.getMessage("GROUP_A", "TOPIC_A", 0, i, 1024 * 1024, null); if (result == null) { - System.out.println("result == null " + i); + logger.debug("result == null " + i); } assertTrue(result != null); result.release(); - System.out.println("read " + i + " OK"); - } catch (Exception e) { - e.printStackTrace(); + logger.debug("read " + i + " OK"); + } - + } finally { + master.shutdown(); + master.destroy(); + } + logger.debug("================================================================"); + } + + private class MyMessageArrivingListener implements MessageArrivingListener { + + @Override + public void arriving(String topic, int queueId, long logicOffset, long tagsCode) { + // Do nothing here } - master.shutdown(); - master.destroy(); - System.out.println("================================================================"); } } diff --git a/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/MappedFileQueueTest.java b/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/MappedFileQueueTest.java index ce7666fb6ee..89b37be1019 100644 --- a/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/MappedFileQueueTest.java +++ b/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/MappedFileQueueTest.java @@ -21,11 +21,14 @@ package com.alibaba.rocketmq.store; import org.junit.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import static org.junit.Assert.*; public class MappedFileQueueTest { + private static final Logger logger = LoggerFactory.getLogger(MappedFileQueueTest.class); // private static final String StoreMessage = // "Once, there was a chance for me! but I did not treasure it. if"; @@ -49,7 +52,7 @@ public void tearDown() throws Exception { @Test public void test_getLastMapedFile() { final String fixedMsg = "0123456789abcdef"; - System.out.println("================================================================"); + logger.debug("================================================================"); MappedFileQueue mappedFileQueue = new MappedFileQueue("target/unit_test_store/a/", 1024, null); @@ -58,21 +61,21 @@ public void test_getLastMapedFile() { assertTrue(mappedFile != null); boolean result = mappedFile.appendMessage(fixedMsg.getBytes()); if (!result) { - System.out.println("appendMessage " + i); + logger.debug("appendMessage " + i); } assertTrue(result); } mappedFileQueue.shutdown(1000); mappedFileQueue.destroy(); - System.out.println("MappedFileQueue.getLastMappedFile() OK"); + logger.debug("MappedFileQueue.getLastMappedFile() OK"); } @Test public void test_findMapedFileByOffset() { final String fixedMsg = "abcd"; - System.out.println("================================================================"); + logger.debug("================================================================"); MappedFileQueue mappedFileQueue = new MappedFileQueue("target/unit_test_store/b/", 1024, null); @@ -80,40 +83,34 @@ public void test_findMapedFileByOffset() { MappedFile mappedFile = mappedFileQueue.getLastMappedFile(0); assertTrue(mappedFile != null); boolean result = mappedFile.appendMessage(fixedMsg.getBytes()); - // System.out.println("appendMessage " + bytes); + // logger.debug("appendMessage " + bytes); assertTrue(result); } MappedFile mappedFile = mappedFileQueue.findMappedFileByOffset(0); assertTrue(mappedFile != null); assertEquals(mappedFile.getFileFromOffset(), 0); - System.out.println(mappedFile.getFileFromOffset()); - + mappedFile = mappedFileQueue.findMappedFileByOffset(100); assertTrue(mappedFile != null); assertEquals(mappedFile.getFileFromOffset(), 0); - System.out.println(mappedFile.getFileFromOffset()); - + mappedFile = mappedFileQueue.findMappedFileByOffset(1024); assertTrue(mappedFile != null); assertEquals(mappedFile.getFileFromOffset(), 1024); - System.out.println(mappedFile.getFileFromOffset()); - + mappedFile = mappedFileQueue.findMappedFileByOffset(1024 + 100); assertTrue(mappedFile != null); assertEquals(mappedFile.getFileFromOffset(), 1024); - System.out.println(mappedFile.getFileFromOffset()); - + mappedFile = mappedFileQueue.findMappedFileByOffset(1024 * 2); assertTrue(mappedFile != null); assertEquals(mappedFile.getFileFromOffset(), 1024 * 2); - System.out.println(mappedFile.getFileFromOffset()); - + mappedFile = mappedFileQueue.findMappedFileByOffset(1024 * 2 + 100); assertTrue(mappedFile != null); assertEquals(mappedFile.getFileFromOffset(), 1024 * 2); - System.out.println(mappedFile.getFileFromOffset()); - + mappedFile = mappedFileQueue.findMappedFileByOffset(1024 * 4); assertTrue(mappedFile == null); @@ -122,13 +119,13 @@ public void test_findMapedFileByOffset() { mappedFileQueue.shutdown(1000); mappedFileQueue.destroy(); - System.out.println("MappedFileQueue.findMappedFileByOffset() OK"); + logger.debug("MappedFileQueue.findMappedFileByOffset() OK"); } @Test public void test_commit() { final String fixedMsg = "0123456789abcdef"; - System.out.println("================================================================"); + logger.debug("================================================================"); MappedFileQueue mappedFileQueue = new MappedFileQueue("target/unit_test_store/c/", 1024, null); @@ -142,42 +139,36 @@ public void test_commit() { boolean result = mappedFileQueue.flush(0); assertFalse(result); assertEquals(1024 * 1, mappedFileQueue.getFlushedWhere()); - System.out.println("1 " + result + " " + mappedFileQueue.getFlushedWhere()); - + result = mappedFileQueue.flush(0); assertFalse(result); assertEquals(1024 * 2, mappedFileQueue.getFlushedWhere()); - System.out.println("2 " + result + " " + mappedFileQueue.getFlushedWhere()); - + result = mappedFileQueue.flush(0); assertFalse(result); assertEquals(1024 * 3, mappedFileQueue.getFlushedWhere()); - System.out.println("3 " + result + " " + mappedFileQueue.getFlushedWhere()); - + result = mappedFileQueue.flush(0); assertFalse(result); assertEquals(1024 * 4, mappedFileQueue.getFlushedWhere()); - System.out.println("4 " + result + " " + mappedFileQueue.getFlushedWhere()); - + result = mappedFileQueue.flush(0); assertFalse(result); assertEquals(1024 * 5, mappedFileQueue.getFlushedWhere()); - System.out.println("5 " + result + " " + mappedFileQueue.getFlushedWhere()); - + result = mappedFileQueue.flush(0); assertFalse(result); assertEquals(1024 * 6, mappedFileQueue.getFlushedWhere()); - System.out.println("6 " + result + " " + mappedFileQueue.getFlushedWhere()); - + mappedFileQueue.shutdown(1000); mappedFileQueue.destroy(); - System.out.println("MappedFileQueue.flush() OK"); + logger.debug("MappedFileQueue.flush() OK"); } @Test public void test_getMapedMemorySize() { final String fixedMsg = "abcd"; - System.out.println("================================================================"); + logger.debug("================================================================"); MappedFileQueue mappedFileQueue = new MappedFileQueue("target/unit_test_store/d/", 1024, null); @@ -191,7 +182,7 @@ public void test_getMapedMemorySize() { assertEquals(fixedMsg.length() * 1024, mappedFileQueue.getMappedMemorySize()); mappedFileQueue.shutdown(1000); mappedFileQueue.destroy(); - System.out.println("MappedFileQueue.getMappedMemorySize() OK"); + logger.debug("MappedFileQueue.getMappedMemorySize() OK"); } } diff --git a/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/MappedFileTest.java b/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/MappedFileTest.java index 94fd5ee3cc5..44523aeba60 100644 --- a/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/MappedFileTest.java +++ b/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/MappedFileTest.java @@ -24,6 +24,8 @@ import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; @@ -31,7 +33,10 @@ public class MappedFileTest { - + + private static final Logger logger = LoggerFactory.getLogger(MappedFileTest.class); + + private static final String StoreMessage = "Once, there was a chance for me!"; @BeforeClass @@ -44,50 +49,41 @@ public static void tearDownAfterClass() throws Exception { } @Test - public void test_write_read() { - try { - MappedFile mappedFile = new MappedFile("target/unit_test_store/MappedFileTest/000", 1024 * 64); - boolean result = mappedFile.appendMessage(StoreMessage.getBytes()); - assertTrue(result); - System.out.println("write OK"); - - SelectMappedBufferResult selectMappedBufferResult = mappedFile.selectMappedBuffer(0); - byte[] data = new byte[StoreMessage.length()]; - selectMappedBufferResult.getByteBuffer().get(data); - String readString = new String(data); - - System.out.println("Read: " + readString); - assertTrue(readString.equals(StoreMessage)); - - mappedFile.shutdown(1000); - assertTrue(!mappedFile.isAvailable()); - selectMappedBufferResult.release(); - assertTrue(mappedFile.isCleanupOver()); - assertTrue(mappedFile.destroy(1000)); - } catch (IOException e) { - e.printStackTrace(); - } + public void test_write_read() throws IOException { + MappedFile mappedFile = new MappedFile("target/unit_test_store/MappedFileTest/000", 1024 * 64); + boolean result = mappedFile.appendMessage(StoreMessage.getBytes()); + assertTrue(result); + logger.debug("write OK"); + + SelectMappedBufferResult selectMappedBufferResult = mappedFile.selectMappedBuffer(0); + byte[] data = new byte[StoreMessage.length()]; + selectMappedBufferResult.getByteBuffer().get(data); + String readString = new String(data); + + logger.debug("Read: " + readString); + assertTrue(readString.equals(StoreMessage)); + + mappedFile.shutdown(1000); + assertTrue(!mappedFile.isAvailable()); + selectMappedBufferResult.release(); + assertTrue(mappedFile.isCleanupOver()); + assertTrue(mappedFile.destroy(1000)); } @Ignore - public void test_jvm_crashed() { - try { - MappedFile mappedFile = new MappedFile("target/unit_test_store/MappedFileTest/10086", 1024 * 64); - boolean result = mappedFile.appendMessage(StoreMessage.getBytes()); - assertTrue(result); - System.out.println("write OK"); - - SelectMappedBufferResult selectMappedBufferResult = mappedFile.selectMappedBuffer(0); - selectMappedBufferResult.release(); - mappedFile.shutdown(1000); - - byte[] data = new byte[StoreMessage.length()]; - selectMappedBufferResult.getByteBuffer().get(data); - String readString = new String(data); - System.out.println(readString); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + public void test_jvm_crashed() throws IOException { + MappedFile mappedFile = new MappedFile("target/unit_test_store/MappedFileTest/10086", 1024 * 64); + boolean result = mappedFile.appendMessage(StoreMessage.getBytes()); + assertTrue(result); + logger.debug("write OK"); + + SelectMappedBufferResult selectMappedBufferResult = mappedFile.selectMappedBuffer(0); + selectMappedBufferResult.release(); + mappedFile.shutdown(1000); + + byte[] data = new byte[StoreMessage.length()]; + selectMappedBufferResult.getByteBuffer().get(data); + String readString = new String(data); + logger.debug(readString); } } diff --git a/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/RecoverTest.java b/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/RecoverTest.java index ea833752d3c..2da777046c6 100644 --- a/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/RecoverTest.java +++ b/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/RecoverTest.java @@ -25,6 +25,7 @@ import com.alibaba.rocketmq.store.config.MessageStoreConfig; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; import java.net.InetAddress; @@ -36,7 +37,7 @@ import static org.junit.Assert.assertTrue; - +@Ignore("This test need to be fixed!") public class RecoverTest { private static final String StoreMessage = "Once, there was a chance for me!aaaaaaaaaaaaaaaaaaaaaaaa"; diff --git a/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/StoreCheckpointTest.java b/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/StoreCheckpointTest.java index e0a550d91e3..bffa5b24275 100644 --- a/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/StoreCheckpointTest.java +++ b/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/StoreCheckpointTest.java @@ -24,6 +24,8 @@ import org.junit.BeforeClass; import org.junit.Test; +import java.io.IOException; + import static org.junit.Assert.assertTrue; @@ -38,24 +40,19 @@ public static void tearDownAfterClass() throws Exception { } @Test - public void test_write_read() { - try { - StoreCheckpoint storeCheckpoint = new StoreCheckpoint("target/checkpoint_test/0000"); - long physicMsgTimestamp = 0xAABB; - long logicsMsgTimestamp = 0xCCDD; - storeCheckpoint.setPhysicMsgTimestamp(physicMsgTimestamp); - storeCheckpoint.setLogicsMsgTimestamp(logicsMsgTimestamp); - storeCheckpoint.flush(); - - long diff = physicMsgTimestamp - storeCheckpoint.getMinTimestamp(); - assertTrue(diff == 3000); - storeCheckpoint.shutdown(); - storeCheckpoint = new StoreCheckpoint("target/checkpoint_test/0000"); - assertTrue(physicMsgTimestamp == storeCheckpoint.getPhysicMsgTimestamp()); - assertTrue(logicsMsgTimestamp == storeCheckpoint.getLogicsMsgTimestamp()); - } catch (Throwable e) { - e.printStackTrace(); - assertTrue(false); - } + public void test_write_read() throws IOException { + StoreCheckpoint storeCheckpoint = new StoreCheckpoint("target/checkpoint_test/0000"); + long physicMsgTimestamp = 0xAABB; + long logicsMsgTimestamp = 0xCCDD; + storeCheckpoint.setPhysicMsgTimestamp(physicMsgTimestamp); + storeCheckpoint.setLogicsMsgTimestamp(logicsMsgTimestamp); + storeCheckpoint.flush(); + + long diff = physicMsgTimestamp - storeCheckpoint.getMinTimestamp(); + assertTrue(diff == 3000); + storeCheckpoint.shutdown(); + storeCheckpoint = new StoreCheckpoint("target/checkpoint_test/0000"); + assertTrue(physicMsgTimestamp == storeCheckpoint.getPhysicMsgTimestamp()); + assertTrue(logicsMsgTimestamp == storeCheckpoint.getLogicsMsgTimestamp()); } } diff --git a/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/index/IndexFileTest.java b/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/index/IndexFileTest.java index 288b87e9d96..f6bfc0a660a 100644 --- a/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/index/IndexFileTest.java +++ b/rocketmq-store/src/test/java/com/alibaba/rocketmq/store/index/IndexFileTest.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.List; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -34,47 +35,35 @@ public class IndexFileTest { private static final int indexNum = 400; @Test - public void test_put_index() { - try { - IndexFile indexFile = new IndexFile("100", hashSlotNum, indexNum, 0, 0); - for (long i = 0; i < (indexNum - 1); i++) { - boolean putResult = indexFile.putKey(Long.toString(i), i, System.currentTimeMillis()); - assertTrue(putResult); - } - - boolean putResult = indexFile.putKey(Long.toString(400), 400, System.currentTimeMillis()); - assertFalse(putResult); - - indexFile.destroy(0); - } catch (Exception e) { - e.printStackTrace(); - assertTrue(false); + public void test_put_index() throws Exception { + IndexFile indexFile = new IndexFile("100", hashSlotNum, indexNum, 0, 0); + for (long i = 0; i < (indexNum - 1); i++) { + boolean putResult = indexFile.putKey(Long.toString(i), i, System.currentTimeMillis()); + assertTrue(putResult); } + + boolean putResult = indexFile.putKey(Long.toString(400), 400, System.currentTimeMillis()); + assertFalse(putResult); + + indexFile.destroy(0); } @Test - public void test_put_get_index() { - try { - IndexFile indexFile = new IndexFile("200", hashSlotNum, indexNum, 0, 0); - - for (long i = 0; i < (indexNum - 1); i++) { - boolean putResult = indexFile.putKey(Long.toString(i), i, System.currentTimeMillis()); - assertTrue(putResult); - } - boolean putResult = indexFile.putKey(Long.toString(400), 400, System.currentTimeMillis()); - assertFalse(putResult); - - final List phyOffsets = new ArrayList(); - indexFile.selectPhyOffset(phyOffsets, "60", 10, 0, Long.MAX_VALUE, true); - for (Long offset : phyOffsets) { - System.out.println(offset); - } - assertFalse(phyOffsets.isEmpty()); - indexFile.destroy(0); - } catch (Exception e) { - e.printStackTrace(); - assertTrue(false); + public void test_put_get_index() throws Exception { + IndexFile indexFile = new IndexFile("200", hashSlotNum, indexNum, 0, 0); + + for (long i = 0; i < (indexNum - 1); i++) { + boolean putResult = indexFile.putKey(Long.toString(i), i, System.currentTimeMillis()); + assertTrue(putResult); } + boolean putResult = indexFile.putKey(Long.toString(400), 400, System.currentTimeMillis()); + assertFalse(putResult); + + final List phyOffsets = new ArrayList(); + indexFile.selectPhyOffset(phyOffsets, "60", 10, 0, Long.MAX_VALUE, true); + assertFalse(phyOffsets.isEmpty()); + assertEquals(1, phyOffsets.size()); + indexFile.destroy(0); } } diff --git a/rocketmq-store/src/test/resources/logback-test.xml b/rocketmq-store/src/test/resources/logback-test.xml new file mode 100644 index 00000000000..acdfa10b267 --- /dev/null +++ b/rocketmq-store/src/test/resources/logback-test.xml @@ -0,0 +1,34 @@ + + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n + + + + + + + + + + + + From 915be84b339db399b0e15f1061d82d6e626267e2 Mon Sep 17 00:00:00 2001 From: Willem Jiang Date: Fri, 23 Dec 2016 12:44:59 +0800 Subject: [PATCH 07/14] ROCKETMQ-3 Clean up the unit test code of rocketmq-client --- .../rocketmq/client/ValidatorsTest.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/rocketmq-client/src/test/java/com/alibaba/rocketmq/client/ValidatorsTest.java b/rocketmq-client/src/test/java/com/alibaba/rocketmq/client/ValidatorsTest.java index 6dadafb4992..2a10ec42f96 100644 --- a/rocketmq-client/src/test/java/com/alibaba/rocketmq/client/ValidatorsTest.java +++ b/rocketmq-client/src/test/java/com/alibaba/rocketmq/client/ValidatorsTest.java @@ -17,6 +17,7 @@ package com.alibaba.rocketmq.client; +import com.alibaba.rocketmq.client.exception.MQClientException; import org.junit.Assert; import org.junit.Test; @@ -24,16 +25,11 @@ public class ValidatorsTest { @Test - public void topicValidatorTest() { - try { - Validators.checkTopic("Hello"); - Validators.checkTopic("%RETRY%Hello"); - Validators.checkTopic("_%RETRY%Hello"); - Validators.checkTopic("-%RETRY%Hello"); - Validators.checkTopic("223-%RETRY%Hello"); - } catch (Exception e) { - e.printStackTrace(); - Assert.assertTrue(false); - } + public void topicValidatorTest() throws MQClientException { + Validators.checkTopic("Hello"); + Validators.checkTopic("%RETRY%Hello"); + Validators.checkTopic("_%RETRY%Hello"); + Validators.checkTopic("-%RETRY%Hello"); + Validators.checkTopic("223-%RETRY%Hello"); } } From e91312e70f49446111e006d229c9427b19f94745 Mon Sep 17 00:00:00 2001 From: shroman Date: Fri, 23 Dec 2016 15:37:48 +0800 Subject: [PATCH 08/14] ROCKETMQ-2 [ROCKETMQ-2] Closing the channel closes apache/incubator-rocketmq#1 --- .../rocketmq/broker/BrokerControllerTest.java | 53 +++++++++++++++++++ .../alibaba/rocketmq/store/ha/HAService.java | 28 ++++++---- 2 files changed, 70 insertions(+), 11 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..6b0b62d3940 --- /dev/null +++ b/rocketmq-broker/src/test/java/com/alibaba/rocketmq/broker/BrokerControllerTest.java @@ -0,0 +1,53 @@ +/** + * 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.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 < RESTART_NUM; i++) { + BrokerController brokerController = new BrokerController(// + new BrokerConfig(), // + new NettyServerConfig(), // + new NettyClientConfig(), // + new MessageStoreConfig()); + boolean initResult = brokerController.initialize(); + System.out.println("initialize " + initResult); + brokerController.start(); + + brokerController.shutdown(); + } + } +} 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..5f9375320b2 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 @@ -116,7 +116,7 @@ public AtomicInteger getConnectionCount() { // this.groupTransferService.notifyTransferSome(); // } - public void start() { + public void start() throws Exception { this.acceptSocketService.beginAccept(); this.acceptSocketService.start(); this.groupTransferService.start(); @@ -181,20 +181,26 @@ public AcceptSocketService(final int port) { } - public void beginAccept() { + public void beginAccept() throws Exception { + this.serverSocketChannel = ServerSocketChannel.open(); + this.selector = RemotingUtil.openSelector(); + this.serverSocketChannel.socket().setReuseAddress(true); + this.serverSocketChannel.socket().bind(this.socketAddressListen); + this.serverSocketChannel.configureBlocking(false); + this.serverSocketChannel.register(this.selector, SelectionKey.OP_ACCEPT); + } + + @Override + public void shutdown(final boolean interrupt) { + super.shutdown(interrupt); try { - this.serverSocketChannel = ServerSocketChannel.open(); - this.selector = RemotingUtil.openSelector(); - this.serverSocketChannel.socket().setReuseAddress(true); - this.serverSocketChannel.socket().bind(this.socketAddressListen); - this.serverSocketChannel.configureBlocking(false); - this.serverSocketChannel.register(this.selector, SelectionKey.OP_ACCEPT); - } catch (Exception e) { - log.error("beginAccept exception", e); + serverSocketChannel.close(); + } + catch (IOException e) { + log.error("AcceptSocketService shutdown exception", e); } } - @Override public void run() { log.info(this.getServiceName() + " service started"); From f74f2ebb15ffa028ea833b87cbd14310077d596b Mon Sep 17 00:00:00 2001 From: lollipop Date: Thu, 29 Dec 2016 14:56:25 +0800 Subject: [PATCH 09/14] ROCKETMQ-14 closes apache/incubator-rocketmq#19 *Won't fix: We could close this pr without any more works, thanks @Jaskey* From 5919c9112ca6cb2a7426ecb9f80121abc39e07ba Mon Sep 17 00:00:00 2001 From: tain198127 Date: Thu, 12 Jan 2017 21:41:14 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E7=94=B1=E4=BA=8E=20clientconfig=20?= =?UTF-8?q?=E5=9C=A8=E8=8E=B7=E5=8F=96=E6=9C=AC=E5=9C=B0=20ip=20=E6=97=B6?= =?UTF-8?q?=EF=BC=8Cipv4=E8=8E=B7=E5=8F=96=E6=9C=80=E5=90=8E=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=20ip=EF=BC=8C=E8=87=B4=E4=BD=BF=E5=9C=A8=E5=8F=8C?= =?UTF-8?q?=E7=BD=91=E5=8D=A1=E7=9A=84=E7=8E=AF=E5=A2=83=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E5=A6=82=E6=9E=9C=E6=9C=80=E5=90=8E=E4=B8=80=E4=B8=AA=20ip=20?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E7=9A=84=E6=98=AF=E5=A4=96=E7=BD=91=20?= =?UTF-8?q?=E2=80=A6=20=E2=80=A6ip=E3=80=82=E9=82=A3=E4=B9=88=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E4=BC=9A=E9=80=A0=E6=88=90=E6=80=A7=E8=83=BD=E4=B8=8B?= =?UTF-8?q?=E9=99=8D=E6=88=96=E8=80=85=E6=97=A0=E6=B3=95=E8=81=94=E9=80=9A?= =?UTF-8?q?=E3=80=82=E8=99=BD=E7=84=B6=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=20setClientIP=E6=96=B9=E6=B3=95=E6=9D=A5=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E8=BF=99=E4=B8=AA=E9=97=AE=E9=A2=98=E3=80=82=E4=BD=86=E6=98=AF?= =?UTF-8?q?=E5=A4=84=E7=90=86=E5=A4=AA=E8=BF=87=E7=A1=AC=E6=80=A7=E3=80=82?= =?UTF-8?q?=E5=9C=A8=E9=9B=86=E7=BE=A4=E7=8E=AF=E5=A2=83=E4=B8=AD=E4=BC=9A?= =?UTF-8?q?=E5=AF=B9=E9=83=A8=E7=BD=B2=E9=80=A0=E6=88=90=E5=BE=88=E5=A4=A7?= =?UTF-8?q?=E5=8E=8B=E5=8A=9B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改增加了可以通过过滤来取得正确的地址的方法。 --- .../apache/rocketmq/client/ClientConfig.java | 41 +++++++++ .../client/producer/DefaultMQProducer.java | 1 + .../client/SimpleConsumerProducerTest.java | 88 +++++++++++++++++++ .../remoting/common/RemotingUtil.java | 31 +++++-- .../rocketmq/remoting/LocalAddressTest.java | 19 ++++ 5 files changed, 172 insertions(+), 8 deletions(-) create mode 100644 client/src/test/java/org/apache/rocketmq/client/SimpleConsumerProducerTest.java create mode 100644 remoting/src/test/java/org/apache/rocketmq/remoting/LocalAddressTest.java diff --git a/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java b/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java index 69ebfefd87a..2626b5f55bb 100644 --- a/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java +++ b/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java @@ -20,6 +20,9 @@ import org.apache.rocketmq.common.UtilAll; import org.apache.rocketmq.remoting.common.RemotingUtil; +import java.util.ArrayList; +import java.util.List; + /** * Client Common configuration */ @@ -27,6 +30,8 @@ public class ClientConfig { public static final String SEND_MESSAGE_WITH_VIP_CHANNEL_PROPERTY = "com.rocketmq.sendMessageWithVIPChannel"; private String namesrvAddr = System.getProperty(MixAll.NAMESRV_ADDR_PROPERTY, System.getenv(MixAll.NAMESRV_ADDR_ENV)); private String clientIP = RemotingUtil.getLocalAddress(); + private List clientIPArray = RemotingUtil.getLocalAddressArray(); + private boolean isClientIPReplaced=false; private String instanceName = System.getProperty("rocketmq.client.name", "DEFAULT"); private int clientCallbackExecutorThreads = Runtime.getRuntime().availableProcessors(); /** @@ -63,7 +68,43 @@ public String getClientIP() { return clientIP; } + /** + * to match the right ip, + * side effort:if the candidate is only one,the clientIP will be replace by the first candidate + * @param ipPattern:ip parttern,if ipPattern is null or empty,will return all the candidate, e.g:10.1.2 + * + * + * @return ip candidate list + */ + public List computeClientIP(String ipPattern){ + List rstIPArray = new ArrayList(this.clientIPArray.size()); + if(ipPattern != null && !ipPattern.isEmpty()) + { + for(String ip : this.clientIPArray) + { + if(ip.contains(ipPattern)) + rstIPArray.add(ip); + } + if(!isClientIPReplaced && rstIPArray.size()<=0) + throw new RuntimeException("you do not have ip address pls use ifconfig to check you ip"); + + if(!isClientIPReplaced && rstIPArray.size() == 1) + this.setClientIP(rstIPArray.get(0)); + } + else{ + rstIPArray.addAll(this.clientIPArray); + } + if(rstIPArray.size()>1 && !isClientIPReplaced) + try{ + throw new RuntimeException("you have more than one ip address, pls use to avoid it ,or use "); + } + catch(Exception e){ + e.printStackTrace(); + } + return rstIPArray; + } public void setClientIP(String clientIP) { + isClientIPReplaced=true; this.clientIP = clientIP; } diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java b/client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java index 3480c920e89..1a82f374642 100644 --- a/client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java +++ b/client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java @@ -161,6 +161,7 @@ public DefaultMQProducer(RPCHook rpcHook) { */ @Override public void start() throws MQClientException { + this.computeClientIP(null); this.defaultMQProducerImpl.start(); } diff --git a/client/src/test/java/org/apache/rocketmq/client/SimpleConsumerProducerTest.java b/client/src/test/java/org/apache/rocketmq/client/SimpleConsumerProducerTest.java new file mode 100644 index 00000000000..d7e3ff21b18 --- /dev/null +++ b/client/src/test/java/org/apache/rocketmq/client/SimpleConsumerProducerTest.java @@ -0,0 +1,88 @@ +/** + * 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.rocketmq.client; + +import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; +import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.client.producer.DefaultMQProducer; +import org.apache.rocketmq.client.producer.SendResult; +import org.apache.rocketmq.common.consumer.ConsumeFromWhere; +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.common.message.MessageExt; +import org.junit.Test; + +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; + + +public class SimpleConsumerProducerTest { + private static final String TOPIC_TEST = "TopicTest-fundmng"; + + @Test + public void producerConsumerTest() throws MQClientException, InterruptedException, IOException { + System.setProperty("rocketmq.namesrv.domain", "jmenv.tbsite.alipay.net"); + + DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("S_fundmng_demo_producer"); + DefaultMQProducer producer = new DefaultMQProducer("P_fundmng_demo_producer"); + //producer.computeClientIP("10.1.33"); + consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET); + consumer.subscribe(TOPIC_TEST, null); + + final AtomicLong lastReceivedMills = new AtomicLong(System.currentTimeMillis()); + + final AtomicLong consumeTimes = new AtomicLong(0); + + consumer.registerMessageListener(new MessageListenerConcurrently() { + public ConsumeConcurrentlyStatus consumeMessage(final List msgs, + final ConsumeConcurrentlyContext context) { + System.out.println("Received" + consumeTimes.incrementAndGet() + "messages !"); + + lastReceivedMills.set(System.currentTimeMillis()); + + return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; + } + }); + + consumer.start(); + producer.start(); + + for (int i = 0; i < 100; i++) { + try { + Message msg = new Message(TOPIC_TEST, ("Hello RocketMQ " + i).getBytes()); + SendResult sendResult = producer.send(msg); + System.out.println(sendResult); + } catch (Exception e) { + System.err.println(e.toString()); + TimeUnit.SECONDS.sleep(1); + } + } + +// // wait no messages + while ((System.currentTimeMillis() - lastReceivedMills.get()) < 5000) { + TimeUnit.MILLISECONDS.sleep(200); + } + + consumer.shutdown(); + producer.shutdown(); + } +} diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingUtil.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingUtil.java index f64f9e153ef..12170345027 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingUtil.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingUtil.java @@ -32,7 +32,10 @@ import java.nio.channels.SocketChannel; import java.nio.channels.spi.SelectorProvider; import java.util.ArrayList; +import java.util.Collections; import java.util.Enumeration; +import java.util.List; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -92,7 +95,9 @@ public static boolean isLinuxPlatform() { return isLinuxPlatform; } - public static String getLocalAddress() { + public static List getLocalAddressArray() + { + ArrayList rstIP = new ArrayList(); try { // Traversal Network interface to get the first non-loopback and non-private address Enumeration enumeration = NetworkInterface.getNetworkInterfaces(); @@ -119,17 +124,18 @@ public static String getLocalAddress() { if (ip.startsWith("127.0") || ip.startsWith("192.168")) { continue; } + rstIP.add(ip); - return ip; } - - return ipv4Result.get(ipv4Result.size() - 1); + //to adapt old rocketmq,make the last ent address be the first + Collections.reverse(rstIP); } else if (!ipv6Result.isEmpty()) { - return ipv6Result.get(0); + rstIP.addAll(ipv6Result); } - //If failed to find,fall back to localhost - final InetAddress localHost = InetAddress.getLocalHost(); - return normalizeHostAddress(localHost); + else{ + rstIP.add(normalizeHostAddress(InetAddress.getLocalHost())); + } + return rstIP; } catch (SocketException e) { e.printStackTrace(); } catch (UnknownHostException e) { @@ -138,6 +144,15 @@ public static String getLocalAddress() { return null; } + public static String getLocalAddress() { + final List address = getLocalAddressArray(); + if(address!=null && !address.isEmpty()) + { + return address.get(0); + } + + return null; + } public static String normalizeHostAddress(final InetAddress localHost) { if (localHost instanceof Inet6Address) { diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/LocalAddressTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/LocalAddressTest.java new file mode 100644 index 00000000000..84438100801 --- /dev/null +++ b/remoting/src/test/java/org/apache/rocketmq/remoting/LocalAddressTest.java @@ -0,0 +1,19 @@ +package org.apache.rocketmq.remoting; + + +import org.apache.rocketmq.remoting.common.RemotingUtil; +import org.junit.Test; + +import java.util.List; + +/** + * Created by tain on 2017/1/11. + */ +public class LocalAddressTest { + @Test + public void getLoacalAddress() + { + List address = RemotingUtil.getLocalAddressArray(); + System.out.println(address); + } +} From 06b0b15d8150817cdf8d55af768ef5c41775fcb6 Mon Sep 17 00:00:00 2001 From: tain198127 Date: Thu, 12 Jan 2017 22:28:32 +0800 Subject: [PATCH 11/14] fix the last pull request error --- .../apache/rocketmq/client/ClientConfig.java | 25 +++++++++---------- .../remoting/common/RemotingUtil.java | 11 +++----- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java b/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java index 2626b5f55bb..f5be396048f 100644 --- a/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java +++ b/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java @@ -31,7 +31,7 @@ public class ClientConfig { private String namesrvAddr = System.getProperty(MixAll.NAMESRV_ADDR_PROPERTY, System.getenv(MixAll.NAMESRV_ADDR_ENV)); private String clientIP = RemotingUtil.getLocalAddress(); private List clientIPArray = RemotingUtil.getLocalAddressArray(); - private boolean isClientIPReplaced=false; + private boolean isClientIPReplaced = false; private String instanceName = System.getProperty("rocketmq.client.name", "DEFAULT"); private int clientCallbackExecutorThreads = Runtime.getRuntime().availableProcessors(); /** @@ -76,35 +76,34 @@ public String getClientIP() { * * @return ip candidate list */ - public List computeClientIP(String ipPattern){ + public List computeClientIP(String ipPattern) { List rstIPArray = new ArrayList(this.clientIPArray.size()); - if(ipPattern != null && !ipPattern.isEmpty()) + if (ipPattern != null && !ipPattern.isEmpty()) { - for(String ip : this.clientIPArray) + for (String ip : this.clientIPArray) { - if(ip.contains(ipPattern)) + if (ip.contains(ipPattern)) rstIPArray.add(ip); } - if(!isClientIPReplaced && rstIPArray.size()<=0) + if (!isClientIPReplaced && rstIPArray.size() <= 0) throw new RuntimeException("you do not have ip address pls use ifconfig to check you ip"); - if(!isClientIPReplaced && rstIPArray.size() == 1) + if (!isClientIPReplaced && rstIPArray.size() == 1) this.setClientIP(rstIPArray.get(0)); - } - else{ + } else { rstIPArray.addAll(this.clientIPArray); } - if(rstIPArray.size()>1 && !isClientIPReplaced) - try{ + if (rstIPArray.size() > 1 && !isClientIPReplaced) + try { throw new RuntimeException("you have more than one ip address, pls use to avoid it ,or use "); } - catch(Exception e){ + catch (Exception e) { e.printStackTrace(); } return rstIPArray; } public void setClientIP(String clientIP) { - isClientIPReplaced=true; + isClientIPReplaced = true; this.clientIP = clientIP; } diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingUtil.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingUtil.java index 12170345027..868cd7d373b 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingUtil.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingUtil.java @@ -94,8 +94,7 @@ public static Selector openSelector() throws IOException { public static boolean isLinuxPlatform() { return isLinuxPlatform; } - - public static List getLocalAddressArray() + public static List getLocalAddressArray() { ArrayList rstIP = new ArrayList(); try { @@ -131,8 +130,7 @@ public static List getLocalAddressArray() Collections.reverse(rstIP); } else if (!ipv6Result.isEmpty()) { rstIP.addAll(ipv6Result); - } - else{ + } else { rstIP.add(normalizeHostAddress(InetAddress.getLocalHost())); } return rstIP; @@ -145,9 +143,8 @@ public static List getLocalAddressArray() return null; } public static String getLocalAddress() { - final List address = getLocalAddressArray(); - if(address!=null && !address.isEmpty()) - { + final List address = getLocalAddressArray(); + if (address != null && !address.isEmpty()) { return address.get(0); } From 4311d26bf754996e32ae279c89e0ac0ed861eb08 Mon Sep 17 00:00:00 2001 From: tain198127 Date: Fri, 13 Jan 2017 16:08:22 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E5=92=8C=E5=90=88=E5=B9=B6=E7=9A=84=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.sh | 1 + merge.sh | 3 +++ 2 files changed, 4 insertions(+) create mode 100755 build.sh create mode 100755 merge.sh diff --git a/build.sh b/build.sh new file mode 100755 index 00000000000..1b2cf076cde --- /dev/null +++ b/build.sh @@ -0,0 +1 @@ +mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V -X diff --git a/merge.sh b/merge.sh new file mode 100755 index 00000000000..4dc256c5a46 --- /dev/null +++ b/merge.sh @@ -0,0 +1,3 @@ +git fetch upstream +git checkout master +git merge upstream/master From d178a6f42d361e0e3f69073d6f88a82672857bab Mon Sep 17 00:00:00 2001 From: tain198127 Date: Tue, 17 Jan 2017 15:39:01 +0800 Subject: [PATCH 13/14] Revert "IntegrateASF sonar" This reverts commit 2892a7759f3f867cdca7214399ff121eded78970. --- pom.xml | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index f189bb422c5..afd3d847b0c 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ rocketmq-all 4.0.0-SNAPSHOT pom - Apache RocketMQ git s${project.version} + rocketmq-all ${project.version} http://rocketmq.incubator.apache.org/ @@ -42,8 +42,7 @@ https://git-wip-us.apache.org/repos/asf/incubator-rocketmq.git scm:git:https://git-wip-us.apache.org/repos/asf/incubator-rocketmq.git - scm:git:https://git-wip-us.apache.org/repos/asf/incubator-rocketmq.git - + scm:git:https://git-wip-us.apache.org/repos/asf/incubator-rocketmq.git @@ -158,11 +157,6 @@ 1.7 1.7 - - - https://builds.apache.org/analysis - - file:**/generated-sources/** @@ -343,11 +337,6 @@ findbugs-maven-plugin 3.0.4 - - org.sonarsource.scanner.maven - sonar-maven-plugin - 3.0.2 - From accaf725f846a1c9bdeeea2e42f321fca1c55ef6 Mon Sep 17 00:00:00 2001 From: tain198127 Date: Tue, 17 Jan 2017 15:40:08 +0800 Subject: [PATCH 14/14] Revert "Remove script command in travis config file" This reverts commit df9d621baac504ae2d7288a19a3907a3c02cd485. --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 45b7d5d79a6..a9927e27687 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,9 @@ jdk: - oraclejdk7 - openjdk7 -#script: -# - travis_retry mvn --batch-mode clean apache-rat:check -# - travis_wait 60 mvn --batch-mode clean package findbugs:check +script: + - travis_retry mvn --batch-mode clean apache-rat:check + - travis_wait 60 mvn --batch-mode clean package findbugs:check after_success: - - mvn clean apache-rat:check cobertura:cobertura coveralls:report + - mvn clean cobertura:cobertura coveralls:report