You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by yu...@apache.org on 2016/12/28 09:13:52 UTC
[01/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Repository: incubator-rocketmq
Updated Branches:
refs/heads/master 1356e35f4 -> 2eae25c6a
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/namesrv/src/main/java/com/alibaba/rocketmq/namesrv/NamesrvStartup.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/com/alibaba/rocketmq/namesrv/NamesrvStartup.java b/namesrv/src/main/java/com/alibaba/rocketmq/namesrv/NamesrvStartup.java
deleted file mode 100644
index 286de3a..0000000
--- a/namesrv/src/main/java/com/alibaba/rocketmq/namesrv/NamesrvStartup.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/**
- * 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.namesrv;
-
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.joran.JoranConfigurator;
-import com.alibaba.rocketmq.common.MQVersion;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.namesrv.NamesrvConfig;
-import com.alibaba.rocketmq.remoting.netty.NettyServerConfig;
-import com.alibaba.rocketmq.remoting.netty.NettySystemConfig;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import com.alibaba.rocketmq.srvutil.ServerUtil;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.PosixParser;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicInteger;
-
-
-/**
- * @author shijia.wxr
- */
-public class NamesrvStartup {
- public static Properties properties = null;
- public static CommandLine commandLine = null;
-
- public static void main(String[] args) {
- main0(args);
- }
-
- public static NamesrvController main0(String[] args) {
- System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));
-
-
- if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE)) {
- NettySystemConfig.socketSndbufSize = 4096;
- }
-
-
- if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE)) {
- NettySystemConfig.socketRcvbufSize = 4096;
- }
-
- try {
- //PackageConflictDetect.detectFastjson();
-
- Options options = ServerUtil.buildCommandlineOptions(new Options());
- commandLine =
- ServerUtil.parseCmdLine("mqnamesrv", args, buildCommandlineOptions(options),
- new PosixParser());
- if (null == commandLine) {
- System.exit(-1);
- return null;
- }
-
-
- final NamesrvConfig namesrvConfig = new NamesrvConfig();
- final NettyServerConfig nettyServerConfig = new NettyServerConfig();
- nettyServerConfig.setListenPort(9876);
- if (commandLine.hasOption('c')) {
- String file = commandLine.getOptionValue('c');
- if (file != null) {
- InputStream in = new BufferedInputStream(new FileInputStream(file));
- properties = new Properties();
- properties.load(in);
- MixAll.properties2Object(properties, namesrvConfig);
- MixAll.properties2Object(properties, nettyServerConfig);
-
- namesrvConfig.setConfigStorePath(file);
-
- System.out.printf("load config properties file OK, " + file + "%n");
- in.close();
- }
- }
-
-
- if (commandLine.hasOption('p')) {
- MixAll.printObjectProperties(null, namesrvConfig);
- MixAll.printObjectProperties(null, nettyServerConfig);
- System.exit(0);
- }
-
- MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), namesrvConfig);
-
- if (null == namesrvConfig.getRocketmqHome()) {
- System.out.printf("Please set the " + MixAll.ROCKETMQ_HOME_ENV
- + " variable in your environment to match the location of the RocketMQ installation%n");
- System.exit(-2);
- }
-
- LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
- JoranConfigurator configurator = new JoranConfigurator();
- configurator.setContext(lc);
- lc.reset();
- configurator.doConfigure(namesrvConfig.getRocketmqHome() + "/conf/logback_namesrv.xml");
- final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
-
-
- MixAll.printObjectProperties(log, namesrvConfig);
- MixAll.printObjectProperties(log, nettyServerConfig);
-
-
- final NamesrvController controller = new NamesrvController(namesrvConfig, nettyServerConfig);
-
- // remember all configs to prevent discard
- controller.getConfiguration().registerConfig(properties);
-
- boolean initResult = controller.initialize();
- if (!initResult) {
- controller.shutdown();
- System.exit(-3);
- }
-
- Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
- private volatile boolean hasShutdown = false;
- private AtomicInteger shutdownTimes = new AtomicInteger(0);
-
-
- @Override
- public void run() {
- synchronized (this) {
- log.info("shutdown hook was invoked, " + this.shutdownTimes.incrementAndGet());
- if (!this.hasShutdown) {
- this.hasShutdown = true;
- long begineTime = System.currentTimeMillis();
- controller.shutdown();
- long consumingTimeTotal = System.currentTimeMillis() - begineTime;
- log.info("shutdown hook over, consuming time total(ms): " + consumingTimeTotal);
- }
- }
- }
- }, "ShutdownHook"));
-
-
- controller.start();
-
- String tip = "The Name Server boot success. serializeType=" + RemotingCommand.getSerializeTypeConfigInThisServer();
- log.info(tip);
- System.out.printf(tip + "%n");
-
- return controller;
- } catch (Throwable e) {
- e.printStackTrace();
- System.exit(-1);
- }
-
- return null;
- }
-
- public static Options buildCommandlineOptions(final Options options) {
- Option opt = new Option("c", "configFile", true, "Name server config properties file");
- opt.setRequired(false);
- options.addOption(opt);
-
- opt = new Option("p", "printConfigItem", false, "Print all config item");
- opt.setRequired(false);
- options.addOption(opt);
-
- return options;
- }
-}
[15/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
deleted file mode 100644
index e6283b6..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: GetAllTopicConfigResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class GetAllTopicConfigResponseHeader implements CommandCustomHeader {
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
deleted file mode 100644
index 21a16fa..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: GetBrokerConfigResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class GetBrokerConfigResponseHeader implements CommandCustomHeader {
- @CFNotNull
- private String version;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getVersion() {
- return version;
- }
-
-
- public void setVersion(String version) {
- this.version = version;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumeStatsInBrokerHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumeStatsInBrokerHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumeStatsInBrokerHeader.java
deleted file mode 100644
index 20eff19..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumeStatsInBrokerHeader.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-public class GetConsumeStatsInBrokerHeader implements CommandCustomHeader {
- @CFNotNull
- private boolean isOrder;
-
- @Override
- public void checkFields() throws RemotingCommandException {
-
- }
-
- public boolean isOrder() {
- return isOrder;
- }
-
- public void setIsOrder(boolean isOrder) {
- this.isOrder = isOrder;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
deleted file mode 100644
index e2f4ca3..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class GetConsumeStatsRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String consumerGroup;
- private String topic;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- // TODO Auto-generated method stub
-
- }
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
deleted file mode 100644
index 96bfed5..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- *
- * @author shijia.wxr
- *
- */
-public class GetConsumerConnectionListRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String consumerGroup;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- // To change body of implemented methods use File | Settings | File
- // Templates.
- }
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java
deleted file mode 100644
index bf38215..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class GetConsumerListByGroupRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String consumerGroup;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java
deleted file mode 100644
index b382ece..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public class GetConsumerListByGroupResponseBody extends RemotingSerializable {
- private List<String> consumerIdList;
-
-
- public List<String> getConsumerIdList() {
- return consumerIdList;
- }
-
-
- public void setConsumerIdList(List<String> consumerIdList) {
- this.consumerIdList = consumerIdList;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java
deleted file mode 100644
index 33f73e5..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class GetConsumerListByGroupResponseHeader implements CommandCustomHeader {
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java
deleted file mode 100644
index bc6ac89..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.annotation.CFNullable;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class GetConsumerRunningInfoRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String consumerGroup;
- @CFNotNull
- private String clientId;
- @CFNullable
- private boolean jstackEnable;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
-
- public String getClientId() {
- return clientId;
- }
-
-
- public void setClientId(String clientId) {
- this.clientId = clientId;
- }
-
-
- public boolean isJstackEnable() {
- return jstackEnable;
- }
-
-
- public void setJstackEnable(boolean jstackEnable) {
- this.jstackEnable = jstackEnable;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java
deleted file mode 100644
index aa138f7..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.annotation.CFNullable;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author manhong.yqd
- *
- */
-public class GetConsumerStatusRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String topic;
- @CFNotNull
- private String group;
- @CFNullable
- private String clientAddr;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- // TODO Auto-generated method stub
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public String getGroup() {
- return group;
- }
-
-
- public void setGroup(String group) {
- this.group = group;
- }
-
-
- public String getClientAddr() {
- return clientAddr;
- }
-
-
- public void setClientAddr(String clientAddr) {
- this.clientAddr = clientAddr;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
deleted file mode 100644
index 0610fc8..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: GetEarliestMsgStoretimeRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class GetEarliestMsgStoretimeRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String topic;
- @CFNotNull
- private Integer queueId;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- // TODO Auto-generated method stub
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public Integer getQueueId() {
- return queueId;
- }
-
-
- public void setQueueId(Integer queueId) {
- this.queueId = queueId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
deleted file mode 100644
index 710fbfb..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: GetEarliestMsgStoretimeResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class GetEarliestMsgStoretimeResponseHeader implements CommandCustomHeader {
- @CFNotNull
- private Long timestamp;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public Long getTimestamp() {
- return timestamp;
- }
-
-
- public void setTimestamp(Long timestamp) {
- this.timestamp = timestamp;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
deleted file mode 100644
index f44aeaf..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: GetMaxOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class GetMaxOffsetRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String topic;
- @CFNotNull
- private Integer queueId;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public Integer getQueueId() {
- return queueId;
- }
-
-
- public void setQueueId(Integer queueId) {
- this.queueId = queueId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
deleted file mode 100644
index a0592a1..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: GetMaxOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class GetMaxOffsetResponseHeader implements CommandCustomHeader {
- @CFNotNull
- private Long offset;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public Long getOffset() {
- return offset;
- }
-
-
- public void setOffset(Long offset) {
- this.offset = offset;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
deleted file mode 100644
index 0e6371e..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: GetMinOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class GetMinOffsetRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String topic;
- @CFNotNull
- private Integer queueId;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public Integer getQueueId() {
- return queueId;
- }
-
-
- public void setQueueId(Integer queueId) {
- this.queueId = queueId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
deleted file mode 100644
index 82e588b..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: GetMinOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class GetMinOffsetResponseHeader implements CommandCustomHeader {
- @CFNotNull
- private Long offset;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public Long getOffset() {
- return offset;
- }
-
-
- public void setOffset(Long offset) {
- this.offset = offset;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java
deleted file mode 100644
index 83f0e61..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class GetProducerConnectionListRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String producerGroup;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- // To change body of implemented methods use File | Settings | File
- // Templates.
- }
-
-
- public String getProducerGroup() {
- return producerGroup;
- }
-
-
- public void setProducerGroup(String producerGroup) {
- this.producerGroup = producerGroup;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java
deleted file mode 100644
index b7085bb..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class GetTopicStatsInfoRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String topic;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetTopicsByClusterRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetTopicsByClusterRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetTopicsByClusterRequestHeader.java
deleted file mode 100644
index c0f026f..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/GetTopicsByClusterRequestHeader.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author manhong.yqd
- *
- */
-public class GetTopicsByClusterRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String cluster;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getCluster() {
- return cluster;
- }
-
-
- public void setCluster(String cluster) {
- this.cluster = cluster;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java
deleted file mode 100644
index bc93fb6..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class NotifyConsumerIdsChangedRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String consumerGroup;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/PullMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/PullMessageRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/PullMessageRequestHeader.java
deleted file mode 100644
index ce2a6ce..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/PullMessageRequestHeader.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: PullMessageRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.annotation.CFNullable;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class PullMessageRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String consumerGroup;
- @CFNotNull
- private String topic;
- @CFNotNull
- private Integer queueId;
- @CFNotNull
- private Long queueOffset;
- @CFNotNull
- private Integer maxMsgNums;
- @CFNotNull
- private Integer sysFlag;
- @CFNotNull
- private Long commitOffset;
- @CFNotNull
- private Long suspendTimeoutMillis;
- @CFNullable
- private String subscription;
- @CFNotNull
- private Long subVersion;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public Integer getQueueId() {
- return queueId;
- }
-
-
- public void setQueueId(Integer queueId) {
- this.queueId = queueId;
- }
-
-
- public Long getQueueOffset() {
- return queueOffset;
- }
-
-
- public void setQueueOffset(Long queueOffset) {
- this.queueOffset = queueOffset;
- }
-
-
- public Integer getMaxMsgNums() {
- return maxMsgNums;
- }
-
-
- public void setMaxMsgNums(Integer maxMsgNums) {
- this.maxMsgNums = maxMsgNums;
- }
-
-
- public Integer getSysFlag() {
- return sysFlag;
- }
-
-
- public void setSysFlag(Integer sysFlag) {
- this.sysFlag = sysFlag;
- }
-
-
- public Long getCommitOffset() {
- return commitOffset;
- }
-
-
- public void setCommitOffset(Long commitOffset) {
- this.commitOffset = commitOffset;
- }
-
-
- public Long getSuspendTimeoutMillis() {
- return suspendTimeoutMillis;
- }
-
-
- public void setSuspendTimeoutMillis(Long suspendTimeoutMillis) {
- this.suspendTimeoutMillis = suspendTimeoutMillis;
- }
-
-
- public String getSubscription() {
- return subscription;
- }
-
-
- public void setSubscription(String subscription) {
- this.subscription = subscription;
- }
-
-
- public Long getSubVersion() {
- return subVersion;
- }
-
-
- public void setSubVersion(Long subVersion) {
- this.subVersion = subVersion;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/PullMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/PullMessageResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/PullMessageResponseHeader.java
deleted file mode 100644
index 952f718..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/PullMessageResponseHeader.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: PullMessageResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class PullMessageResponseHeader implements CommandCustomHeader {
- @CFNotNull
- private Long suggestWhichBrokerId;
- @CFNotNull
- private Long nextBeginOffset;
- @CFNotNull
- private Long minOffset;
- @CFNotNull
- private Long maxOffset;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public Long getNextBeginOffset() {
- return nextBeginOffset;
- }
-
-
- public void setNextBeginOffset(Long nextBeginOffset) {
- this.nextBeginOffset = nextBeginOffset;
- }
-
-
- public Long getMinOffset() {
- return minOffset;
- }
-
-
- public void setMinOffset(Long minOffset) {
- this.minOffset = minOffset;
- }
-
-
- public Long getMaxOffset() {
- return maxOffset;
- }
-
-
- public void setMaxOffset(Long maxOffset) {
- this.maxOffset = maxOffset;
- }
-
-
- public Long getSuggestWhichBrokerId() {
- return suggestWhichBrokerId;
- }
-
-
- public void setSuggestWhichBrokerId(Long suggestWhichBrokerId) {
- this.suggestWhichBrokerId = suggestWhichBrokerId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryConsumeTimeSpanRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryConsumeTimeSpanRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryConsumeTimeSpanRequestHeader.java
deleted file mode 100644
index 58ad741..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryConsumeTimeSpanRequestHeader.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author manhong.yqd
- *
- */
-public class QueryConsumeTimeSpanRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String topic;
- @CFNotNull
- private String group;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public String getGroup() {
- return group;
- }
-
-
- public void setGroup(String group) {
- this.group = group;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
deleted file mode 100644
index e5e9247..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: QueryConsumerOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class QueryConsumerOffsetRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String consumerGroup;
- @CFNotNull
- private String topic;
- @CFNotNull
- private Integer queueId;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public Integer getQueueId() {
- return queueId;
- }
-
-
- public void setQueueId(Integer queueId) {
- this.queueId = queueId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
deleted file mode 100644
index baca342..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: QueryConsumerOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class QueryConsumerOffsetResponseHeader implements CommandCustomHeader {
- @CFNotNull
- private Long offset;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public Long getOffset() {
- return offset;
- }
-
-
- public void setOffset(Long offset) {
- this.offset = offset;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
deleted file mode 100644
index 85b4d0c..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: GetMinOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- *
- * @author manhong.yqd
- *
- */
-public class QueryCorrectionOffsetHeader implements CommandCustomHeader {
- private String filterGroups;
- @CFNotNull
- private String compareGroup;
- @CFNotNull
- private String topic;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- // TODO Auto-generated method stub
- }
-
-
- public String getFilterGroups() {
- return filterGroups;
- }
-
-
- public void setFilterGroups(String filterGroups) {
- this.filterGroups = filterGroups;
- }
-
-
- public String getCompareGroup() {
- return compareGroup;
- }
-
-
- public void setCompareGroup(String compareGroup) {
- this.compareGroup = compareGroup;
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryMessageRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
deleted file mode 100644
index 828e35c..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: QueryMessageRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class QueryMessageRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String topic;
- @CFNotNull
- private String key;
- @CFNotNull
- private Integer maxNum;
- @CFNotNull
- private Long beginTimestamp;
- @CFNotNull
- private Long endTimestamp;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
-
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public String getKey() {
- return key;
- }
-
-
- public void setKey(String key) {
- this.key = key;
- }
-
-
- public Integer getMaxNum() {
- return maxNum;
- }
-
-
- public void setMaxNum(Integer maxNum) {
- this.maxNum = maxNum;
- }
-
-
- public Long getBeginTimestamp() {
- return beginTimestamp;
- }
-
-
- public void setBeginTimestamp(Long beginTimestamp) {
- this.beginTimestamp = beginTimestamp;
- }
-
-
- public Long getEndTimestamp() {
- return endTimestamp;
- }
-
-
- public void setEndTimestamp(Long endTimestamp) {
- this.endTimestamp = endTimestamp;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryMessageResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
deleted file mode 100644
index b05bee9..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: QueryMessageResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class QueryMessageResponseHeader implements CommandCustomHeader {
- @CFNotNull
- private Long indexLastUpdateTimestamp;
- @CFNotNull
- private Long indexLastUpdatePhyoffset;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public Long getIndexLastUpdateTimestamp() {
- return indexLastUpdateTimestamp;
- }
-
-
- public void setIndexLastUpdateTimestamp(Long indexLastUpdateTimestamp) {
- this.indexLastUpdateTimestamp = indexLastUpdateTimestamp;
- }
-
-
- public Long getIndexLastUpdatePhyoffset() {
- return indexLastUpdatePhyoffset;
- }
-
-
- public void setIndexLastUpdatePhyoffset(Long indexLastUpdatePhyoffset) {
- this.indexLastUpdatePhyoffset = indexLastUpdatePhyoffset;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
deleted file mode 100644
index 7ba3dc3..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: QueryMessageRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class QueryTopicConsumeByWhoRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String topic;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
-
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java
deleted file mode 100644
index cad1aab..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- *
- * @author manhong.yqd
- *
- */
-public class ResetOffsetRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String topic;
- @CFNotNull
- private String group;
- @CFNotNull
- private long timestamp;
- @CFNotNull
- private boolean isForce;
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public String getGroup() {
- return group;
- }
-
-
- public void setGroup(String group) {
- this.group = group;
- }
-
-
- public long getTimestamp() {
- return timestamp;
- }
-
-
- public void setTimestamp(long timestamp) {
- this.timestamp = timestamp;
- }
-
-
- public boolean isForce() {
- return isForce;
- }
-
-
- public void setForce(boolean isForce) {
- this.isForce = isForce;
- }
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
deleted file mode 100644
index 6e9d476..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: SearchOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class SearchOffsetRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String topic;
- @CFNotNull
- private Integer queueId;
- @CFNotNull
- private Long timestamp;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- // TODO Auto-generated method stub
-
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public Integer getQueueId() {
- return queueId;
- }
-
-
- public void setQueueId(Integer queueId) {
- this.queueId = queueId;
- }
-
-
- public Long getTimestamp() {
- return timestamp;
- }
-
-
- public void setTimestamp(Long timestamp) {
- this.timestamp = timestamp;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
deleted file mode 100644
index 829f360..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: SearchOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class SearchOffsetResponseHeader implements CommandCustomHeader {
- @CFNotNull
- private Long offset;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public Long getOffset() {
- return offset;
- }
-
-
- public void setOffset(Long offset) {
- this.offset = offset;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SendMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SendMessageRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SendMessageRequestHeader.java
deleted file mode 100644
index 93b1951..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SendMessageRequestHeader.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: SendMessageRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.annotation.CFNullable;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class SendMessageRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String producerGroup;
- @CFNotNull
- private String topic;
- @CFNotNull
- private String defaultTopic;
- @CFNotNull
- private Integer defaultTopicQueueNums;
- @CFNotNull
- private Integer queueId;
- @CFNotNull
- private Integer sysFlag;
- @CFNotNull
- private Long bornTimestamp;
- @CFNotNull
- private Integer flag;
- @CFNullable
- private String properties;
- @CFNullable
- private Integer reconsumeTimes;
- @CFNullable
- private boolean unitMode = false;
- private Integer maxReconsumeTimes;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getProducerGroup() {
- return producerGroup;
- }
-
-
- public void setProducerGroup(String producerGroup) {
- this.producerGroup = producerGroup;
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public String getDefaultTopic() {
- return defaultTopic;
- }
-
-
- public void setDefaultTopic(String defaultTopic) {
- this.defaultTopic = defaultTopic;
- }
-
-
- public Integer getDefaultTopicQueueNums() {
- return defaultTopicQueueNums;
- }
-
-
- public void setDefaultTopicQueueNums(Integer defaultTopicQueueNums) {
- this.defaultTopicQueueNums = defaultTopicQueueNums;
- }
-
-
- public Integer getQueueId() {
- return queueId;
- }
-
-
- public void setQueueId(Integer queueId) {
- this.queueId = queueId;
- }
-
-
- public Integer getSysFlag() {
- return sysFlag;
- }
-
-
- public void setSysFlag(Integer sysFlag) {
- this.sysFlag = sysFlag;
- }
-
-
- public Long getBornTimestamp() {
- return bornTimestamp;
- }
-
-
- public void setBornTimestamp(Long bornTimestamp) {
- this.bornTimestamp = bornTimestamp;
- }
-
-
- public Integer getFlag() {
- return flag;
- }
-
-
- public void setFlag(Integer flag) {
- this.flag = flag;
- }
-
-
- public String getProperties() {
- return properties;
- }
-
-
- public void setProperties(String properties) {
- this.properties = properties;
- }
-
-
- public Integer getReconsumeTimes() {
- return reconsumeTimes;
- }
-
-
- public void setReconsumeTimes(Integer reconsumeTimes) {
- this.reconsumeTimes = reconsumeTimes;
- }
-
-
- public boolean isUnitMode() {
- return unitMode;
- }
-
-
- public void setUnitMode(boolean isUnitMode) {
- this.unitMode = isUnitMode;
- }
-
-
- public Integer getMaxReconsumeTimes() {
- return maxReconsumeTimes;
- }
-
-
- public void setMaxReconsumeTimes(final Integer maxReconsumeTimes) {
- this.maxReconsumeTimes = maxReconsumeTimes;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
deleted file mode 100644
index 6ce4cd5..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/**
- * 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 producerGroup 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.annotation.CFNullable;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * Use short variable name to speed up FastJson deserialization process.
- * @author shijia.wxr
- */
-public class SendMessageRequestHeaderV2 implements CommandCustomHeader {
- @CFNotNull
- private String a; // producerGroup;
- @CFNotNull
- private String b; // topic;
- @CFNotNull
- private String c; // defaultTopic;
- @CFNotNull
- private Integer d; // defaultTopicQueueNums;
- @CFNotNull
- private Integer e; // queueId;
- @CFNotNull
- private Integer f; // sysFlag;
- @CFNotNull
- private Long g; // bornTimestamp;
- @CFNotNull
- private Integer h; // flag;
- @CFNullable
- private String i; // properties;
- @CFNullable
- private Integer j; // reconsumeTimes;
- @CFNullable
- private boolean k; // unitMode = false;
-
- private Integer l; // consumeRetryTimes
-
- public static SendMessageRequestHeader createSendMessageRequestHeaderV1(final SendMessageRequestHeaderV2 v2) {
- SendMessageRequestHeader v1 = new SendMessageRequestHeader();
- v1.setProducerGroup(v2.a);
- v1.setTopic(v2.b);
- v1.setDefaultTopic(v2.c);
- v1.setDefaultTopicQueueNums(v2.d);
- v1.setQueueId(v2.e);
- v1.setSysFlag(v2.f);
- v1.setBornTimestamp(v2.g);
- v1.setFlag(v2.h);
- v1.setProperties(v2.i);
- v1.setReconsumeTimes(v2.j);
- v1.setUnitMode(v2.k);
- v1.setMaxReconsumeTimes(v2.l);
- return v1;
- }
-
- public static SendMessageRequestHeaderV2 createSendMessageRequestHeaderV2(final SendMessageRequestHeader v1) {
- SendMessageRequestHeaderV2 v2 = new SendMessageRequestHeaderV2();
- v2.a = v1.getProducerGroup();
- v2.b = v1.getTopic();
- v2.c = v1.getDefaultTopic();
- v2.d = v1.getDefaultTopicQueueNums();
- v2.e = v1.getQueueId();
- v2.f = v1.getSysFlag();
- v2.g = v1.getBornTimestamp();
- v2.h = v1.getFlag();
- v2.i = v1.getProperties();
- v2.j = v1.getReconsumeTimes();
- v2.k = v1.isUnitMode();
- v2.l = v1.getMaxReconsumeTimes();
- return v2;
- }
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
- public String getA() {
- return a;
- }
-
-
- public void setA(String a) {
- this.a = a;
- }
-
-
- public String getB() {
- return b;
- }
-
-
- public void setB(String b) {
- this.b = b;
- }
-
-
- public String getC() {
- return c;
- }
-
-
- public void setC(String c) {
- this.c = c;
- }
-
-
- public Integer getD() {
- return d;
- }
-
-
- public void setD(Integer d) {
- this.d = d;
- }
-
-
- public Integer getE() {
- return e;
- }
-
-
- public void setE(Integer e) {
- this.e = e;
- }
-
-
- public Integer getF() {
- return f;
- }
-
-
- public void setF(Integer f) {
- this.f = f;
- }
-
-
- public Long getG() {
- return g;
- }
-
-
- public void setG(Long g) {
- this.g = g;
- }
-
-
- public Integer getH() {
- return h;
- }
-
-
- public void setH(Integer h) {
- this.h = h;
- }
-
-
- public String getI() {
- return i;
- }
-
-
- public void setI(String i) {
- this.i = i;
- }
-
-
- public Integer getJ() {
- return j;
- }
-
-
- public void setJ(Integer j) {
- this.j = j;
- }
-
-
- public boolean isK() {
- return k;
- }
-
-
- public void setK(boolean k) {
- this.k = k;
- }
-
-
- public Integer getL() {
- return l;
- }
-
-
- public void setL(final Integer l) {
- this.l = l;
- }
-}
\ No newline at end of file
[82/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
index 55d9b3f..54bcdef 100644
--- a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
+++ b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
@@ -16,8 +16,6 @@
*/
package org.apache.rocketmq.common;
-import org.apache.rocketmq.remoting.common.RemotingHelper;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -30,17 +28,21 @@ import java.net.NetworkInterface;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Map;
import java.util.zip.CRC32;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;
-
+import org.apache.rocketmq.remoting.common.RemotingHelper;
public class UtilAll {
public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
public static final String YYYY_MM_DD_HH_MM_SS_SSS = "yyyy-MM-dd#HH:mm:ss:SSS";
public static final String YYYY_MMDD_HHMMSS = "yyyyMMddHHmmss";
-
+ final static char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
public static int getPid() {
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
@@ -75,7 +77,6 @@ public class UtilAll {
return System.currentTimeMillis() - beginTime;
}
-
public static boolean isItTimeToDo(final String when) {
String[] whiles = when.split(";");
if (whiles != null && whiles.length > 0) {
@@ -91,21 +92,18 @@ public class UtilAll {
return false;
}
-
public static String timeMillisToHumanString() {
return timeMillisToHumanString(System.currentTimeMillis());
}
-
public static String timeMillisToHumanString(final long t) {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(t);
return String.format("%04d%02d%02d%02d%02d%02d%03d", cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1,
- cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND),
- cal.get(Calendar.MILLISECOND));
+ cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND),
+ cal.get(Calendar.MILLISECOND));
}
-
public static long computNextMorningTimeMillis() {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
@@ -118,7 +116,6 @@ public class UtilAll {
return cal.getTimeInMillis();
}
-
public static long computNextMinutesTimeMillis() {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
@@ -131,7 +128,6 @@ public class UtilAll {
return cal.getTimeInMillis();
}
-
public static long computNextHourTimeMillis() {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
@@ -144,7 +140,6 @@ public class UtilAll {
return cal.getTimeInMillis();
}
-
public static long computNextHalfHourTimeMillis() {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
@@ -157,34 +152,31 @@ public class UtilAll {
return cal.getTimeInMillis();
}
-
public static String timeMillisToHumanString2(final long t) {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(t);
return String.format("%04d-%02d-%02d %02d:%02d:%02d,%03d",
- cal.get(Calendar.YEAR),
- cal.get(Calendar.MONTH) + 1,
- cal.get(Calendar.DAY_OF_MONTH),
- cal.get(Calendar.HOUR_OF_DAY),
- cal.get(Calendar.MINUTE),
- cal.get(Calendar.SECOND),
- cal.get(Calendar.MILLISECOND));
+ cal.get(Calendar.YEAR),
+ cal.get(Calendar.MONTH) + 1,
+ cal.get(Calendar.DAY_OF_MONTH),
+ cal.get(Calendar.HOUR_OF_DAY),
+ cal.get(Calendar.MINUTE),
+ cal.get(Calendar.SECOND),
+ cal.get(Calendar.MILLISECOND));
}
-
public static String timeMillisToHumanString3(final long t) {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(t);
return String.format("%04d%02d%02d%02d%02d%02d",
- cal.get(Calendar.YEAR),
- cal.get(Calendar.MONTH) + 1,
- cal.get(Calendar.DAY_OF_MONTH),
- cal.get(Calendar.HOUR_OF_DAY),
- cal.get(Calendar.MINUTE),
- cal.get(Calendar.SECOND));
+ cal.get(Calendar.YEAR),
+ cal.get(Calendar.MONTH) + 1,
+ cal.get(Calendar.DAY_OF_MONTH),
+ cal.get(Calendar.HOUR_OF_DAY),
+ cal.get(Calendar.MINUTE),
+ cal.get(Calendar.SECOND));
}
-
public static double getDiskPartitionSpaceUsedPercent(final String path) {
if (null == path || path.isEmpty())
return -1;
@@ -201,7 +193,7 @@ public class UtilAll {
long freeSpace = file.getFreeSpace();
long usedSpace = totalSpace - freeSpace;
if (totalSpace > 0) {
- return usedSpace / (double) totalSpace;
+ return usedSpace / (double)totalSpace;
}
} catch (Exception e) {
return -1;
@@ -210,7 +202,6 @@ public class UtilAll {
return -1;
}
-
public static final int crc32(byte[] array) {
if (array != null) {
return crc32(array, 0, array.length);
@@ -219,15 +210,12 @@ public class UtilAll {
return 0;
}
-
public static final int crc32(byte[] array, int offset, int length) {
CRC32 crc32 = new CRC32();
crc32.update(array, offset, length);
- return (int) (crc32.getValue() & 0x7FFFFFFF);
+ return (int)(crc32.getValue() & 0x7FFFFFFF);
}
- final static char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
-
public static String bytes2string(byte[] src) {
char[] hexChars = new char[src.length * 2];
for (int j = 0; j < src.length; j++) {
@@ -248,17 +236,15 @@ public class UtilAll {
byte[] d = new byte[length];
for (int i = 0; i < length; i++) {
int pos = i * 2;
- d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
+ d[i] = (byte)(charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
}
return d;
}
-
private static byte charToByte(char c) {
- return (byte) "0123456789ABCDEF".indexOf(c);
+ return (byte)"0123456789ABCDEF".indexOf(c);
}
-
public static byte[] uncompress(final byte[] src) throws IOException {
byte[] result = src;
byte[] uncompressData = new byte[src.length];
@@ -296,7 +282,6 @@ public class UtilAll {
return result;
}
-
public static byte[] compress(final byte[] src, final int level) throws IOException {
byte[] result = src;
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(src.length);
@@ -322,7 +307,6 @@ public class UtilAll {
return result;
}
-
public static int asInt(String str, int defaultValue) {
try {
return Integer.parseInt(str);
@@ -331,7 +315,6 @@ public class UtilAll {
}
}
-
public static long asLong(String str, long defaultValue) {
try {
return Long.parseLong(str);
@@ -340,13 +323,11 @@ public class UtilAll {
}
}
-
public static String formatDate(Date date, String pattern) {
SimpleDateFormat df = new SimpleDateFormat(pattern);
return df.format(date);
}
-
public static Date parseDate(String date, String pattern) {
SimpleDateFormat df = new SimpleDateFormat(pattern);
try {
@@ -356,12 +337,10 @@ public class UtilAll {
}
}
-
public static String responseCode2String(final int code) {
return Integer.toString(code);
}
-
public static String frontStringAtLeast(final String str, final int size) {
if (str != null) {
if (str.length() > size) {
@@ -372,7 +351,6 @@ public class UtilAll {
return str;
}
-
public static boolean isBlank(String str) {
int strLen;
if (str == null || (strLen = str.length()) == 0) {
@@ -386,12 +364,10 @@ public class UtilAll {
return true;
}
-
public static String jstack() {
return jstack(Thread.getAllStackTraces());
}
-
public static String jstack(Map<Thread, StackTraceElement[]> map) {
StringBuilder result = new StringBuilder();
try {
@@ -421,19 +397,18 @@ public class UtilAll {
throw new RuntimeException("illegal ipv4 bytes");
}
-
//10.0.0.0~10.255.255.255
//172.16.0.0~172.31.255.255
//192.168.0.0~192.168.255.255
- if (ip[0] == (byte) 10) {
+ if (ip[0] == (byte)10) {
return true;
- } else if (ip[0] == (byte) 172) {
- if (ip[1] >= (byte) 16 && ip[1] <= (byte) 31) {
+ } else if (ip[0] == (byte)172) {
+ if (ip[1] >= (byte)16 && ip[1] <= (byte)31) {
return true;
}
- } else if (ip[0] == (byte) 192) {
- if (ip[1] == (byte) 168) {
+ } else if (ip[0] == (byte)192) {
+ if (ip[1] == (byte)168) {
return true;
}
}
@@ -448,28 +423,27 @@ public class UtilAll {
// if (ip[0] == (byte)30 && ip[1] == (byte)10 && ip[2] == (byte)163 && ip[3] == (byte)120) {
// }
-
- if (ip[0] >= (byte) 1 && ip[0] <= (byte) 126) {
- if (ip[1] == (byte) 1 && ip[2] == (byte) 1 && ip[3] == (byte) 1) {
+ if (ip[0] >= (byte)1 && ip[0] <= (byte)126) {
+ if (ip[1] == (byte)1 && ip[2] == (byte)1 && ip[3] == (byte)1) {
return false;
}
- if (ip[1] == (byte) 0 && ip[2] == (byte) 0 && ip[3] == (byte) 0) {
+ if (ip[1] == (byte)0 && ip[2] == (byte)0 && ip[3] == (byte)0) {
return false;
}
return true;
- } else if (ip[0] >= (byte) 128 && ip[0] <= (byte) 191) {
- if (ip[2] == (byte) 1 && ip[3] == (byte) 1) {
+ } else if (ip[0] >= (byte)128 && ip[0] <= (byte)191) {
+ if (ip[2] == (byte)1 && ip[3] == (byte)1) {
return false;
}
- if (ip[2] == (byte) 0 && ip[3] == (byte) 0) {
+ if (ip[2] == (byte)0 && ip[3] == (byte)0) {
return false;
}
return true;
- } else if (ip[0] >= (byte) 192 && ip[0] <= (byte) 223) {
- if (ip[3] == (byte) 1) {
+ } else if (ip[0] >= (byte)192 && ip[0] <= (byte)223) {
+ if (ip[3] == (byte)1) {
return false;
}
- if (ip[3] == (byte) 0) {
+ if (ip[3] == (byte)0) {
return false;
}
return true;
@@ -482,8 +456,8 @@ public class UtilAll {
return null;
}
return new StringBuilder().append(ip[0] & 0xFF).append(".").append(
- ip[1] & 0xFF).append(".").append(ip[2] & 0xFF)
- .append(".").append(ip[3] & 0xFF).toString();
+ ip[1] & 0xFF).append(".").append(ip[2] & 0xFF)
+ .append(".").append(ip[3] & 0xFF).toString();
}
public static byte[] getIP() {
@@ -492,10 +466,10 @@ public class UtilAll {
InetAddress ip = null;
byte[] internalIP = null;
while (allNetInterfaces.hasMoreElements()) {
- NetworkInterface netInterface = (NetworkInterface) allNetInterfaces.nextElement();
+ NetworkInterface netInterface = (NetworkInterface)allNetInterfaces.nextElement();
Enumeration addresses = netInterface.getInetAddresses();
while (addresses.hasMoreElements()) {
- ip = (InetAddress) addresses.nextElement();
+ ip = (InetAddress)addresses.nextElement();
if (ip != null && ip instanceof Inet4Address) {
byte[] ipByte = ip.getAddress();
if (ipByte.length == 4) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java b/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
index efab41b..1fc8897 100644
--- a/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
@@ -6,23 +6,21 @@
* (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
+ * 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.
+ * 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.common.admin;
-import org.apache.rocketmq.common.message.MessageQueue;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
-
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
/**
*
@@ -32,7 +30,6 @@ public class ConsumeStats extends RemotingSerializable {
private HashMap<MessageQueue, OffsetWrapper> offsetTable = new HashMap<MessageQueue, OffsetWrapper>();
private double consumeTps = 0;
-
public long computeTotalDiff() {
long diffTotal = 0L;
@@ -46,12 +43,10 @@ public class ConsumeStats extends RemotingSerializable {
return diffTotal;
}
-
public HashMap<MessageQueue, OffsetWrapper> getOffsetTable() {
return offsetTable;
}
-
public void setOffsetTable(HashMap<MessageQueue, OffsetWrapper> offsetTable) {
this.offsetTable = offsetTable;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java b/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
index 170509a..a5697ec 100644
--- a/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.admin;
@@ -26,32 +26,26 @@ public class OffsetWrapper {
private long lastTimestamp;
-
public long getBrokerOffset() {
return brokerOffset;
}
-
public void setBrokerOffset(long brokerOffset) {
this.brokerOffset = brokerOffset;
}
-
public long getConsumerOffset() {
return consumerOffset;
}
-
public void setConsumerOffset(long consumerOffset) {
this.consumerOffset = consumerOffset;
}
-
public long getLastTimestamp() {
return lastTimestamp;
}
-
public void setLastTimestamp(long lastTimestamp) {
this.lastTimestamp = lastTimestamp;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/admin/RollbackStats.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/RollbackStats.java b/common/src/main/java/org/apache/rocketmq/common/admin/RollbackStats.java
index 3af6a0c..2f90e69 100644
--- a/common/src/main/java/org/apache/rocketmq/common/admin/RollbackStats.java
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/RollbackStats.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.admin;
@@ -28,62 +28,50 @@ public class RollbackStats {
private long timestampOffset;
private long rollbackOffset;
-
public String getBrokerName() {
return brokerName;
}
-
public void setBrokerName(String brokerName) {
this.brokerName = brokerName;
}
-
public long getQueueId() {
return queueId;
}
-
public void setQueueId(long queueId) {
this.queueId = queueId;
}
-
public long getBrokerOffset() {
return brokerOffset;
}
-
public void setBrokerOffset(long brokerOffset) {
this.brokerOffset = brokerOffset;
}
-
public long getConsumerOffset() {
return consumerOffset;
}
-
public void setConsumerOffset(long consumerOffset) {
this.consumerOffset = consumerOffset;
}
-
public long getTimestampOffset() {
return timestampOffset;
}
-
public void setTimestampOffset(long timestampOffset) {
this.timestampOffset = timestampOffset;
}
-
public long getRollbackOffset() {
return rollbackOffset;
}
-
public void setRollbackOffset(long rollbackOffset) {
this.rollbackOffset = rollbackOffset;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java b/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
index f64ddcb..8147d63 100644
--- a/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.admin;
@@ -25,32 +25,26 @@ public class TopicOffset {
private long maxOffset;
private long lastUpdateTimestamp;
-
public long getMinOffset() {
return minOffset;
}
-
public void setMinOffset(long minOffset) {
this.minOffset = minOffset;
}
-
public long getMaxOffset() {
return maxOffset;
}
-
public void setMaxOffset(long maxOffset) {
this.maxOffset = maxOffset;
}
-
public long getLastUpdateTimestamp() {
return lastUpdateTimestamp;
}
-
public void setLastUpdateTimestamp(long lastUpdateTimestamp) {
this.lastUpdateTimestamp = lastUpdateTimestamp;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java b/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
index a9e9e84..01f4557 100644
--- a/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
@@ -6,22 +6,20 @@
* (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
+ * 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.
+ * 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.common.admin;
+import java.util.HashMap;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-import java.util.HashMap;
-
-
/**
*
*
@@ -29,12 +27,10 @@ import java.util.HashMap;
public class TopicStatsTable extends RemotingSerializable {
private HashMap<MessageQueue, TopicOffset> offsetTable = new HashMap<MessageQueue, TopicOffset>();
-
public HashMap<MessageQueue, TopicOffset> getOffsetTable() {
return offsetTable;
}
-
public void setOffsetTable(HashMap<MessageQueue, TopicOffset> offsetTable) {
this.offsetTable = offsetTable;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/constant/DBMsgConstants.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/constant/DBMsgConstants.java b/common/src/main/java/org/apache/rocketmq/common/constant/DBMsgConstants.java
index 298a427..ee3e52a 100644
--- a/common/src/main/java/org/apache/rocketmq/common/constant/DBMsgConstants.java
+++ b/common/src/main/java/org/apache/rocketmq/common/constant/DBMsgConstants.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.constant;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java b/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java
index 2bcfacf..482a04e 100644
--- a/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java
+++ b/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.constant;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java b/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java
index e5ab1fc..72ac372 100644
--- a/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java
+++ b/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.constant;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java b/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java
index 2c8e989..2e6c2db 100644
--- a/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java
+++ b/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.consumer;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.java b/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.java
index 7f558ef..01c1732 100644
--- a/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.java
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.java
@@ -6,20 +6,18 @@
* (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
+ * 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.
+ * 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.common.filter;
-import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
-
import java.net.URL;
-
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
/**
*
@@ -42,7 +40,7 @@ public class FilterAPI {
}
public static SubscriptionData buildSubscriptionData(final String consumerGroup, String topic,
- String subString) throws Exception {
+ String subString) throws Exception {
SubscriptionData subscriptionData = new SubscriptionData();
subscriptionData.setTopic(topic);
subscriptionData.setSubString(subString);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/filter/FilterContext.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/FilterContext.java b/common/src/main/java/org/apache/rocketmq/common/filter/FilterContext.java
index e18fe48..3501d26 100644
--- a/common/src/main/java/org/apache/rocketmq/common/filter/FilterContext.java
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/FilterContext.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.filter;
@@ -20,12 +20,10 @@ package org.apache.rocketmq.common.filter;
public class FilterContext {
private String consumerGroup;
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/filter/MessageFilter.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/MessageFilter.java b/common/src/main/java/org/apache/rocketmq/common/filter/MessageFilter.java
index c20e737..3af3d10 100644
--- a/common/src/main/java/org/apache/rocketmq/common/filter/MessageFilter.java
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/MessageFilter.java
@@ -19,7 +19,6 @@ package org.apache.rocketmq.common.filter;
import org.apache.rocketmq.common.message.MessageExt;
-
public interface MessageFilter {
boolean match(final MessageExt msg, final FilterContext context);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/filter/impl/Op.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/impl/Op.java b/common/src/main/java/org/apache/rocketmq/common/filter/impl/Op.java
index af54566..ac85e4d 100644
--- a/common/src/main/java/org/apache/rocketmq/common/filter/impl/Op.java
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/impl/Op.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.filter.impl;
@@ -21,17 +21,14 @@ public abstract class Op {
private String symbol;
-
protected Op(String symbol) {
this.symbol = symbol;
}
-
public String getSymbol() {
return symbol;
}
-
public String toString() {
return symbol;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/filter/impl/Operand.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/impl/Operand.java b/common/src/main/java/org/apache/rocketmq/common/filter/impl/Operand.java
index ce21d90..5de03b7 100644
--- a/common/src/main/java/org/apache/rocketmq/common/filter/impl/Operand.java
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/impl/Operand.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.filter.impl;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/filter/impl/Operator.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/impl/Operator.java b/common/src/main/java/org/apache/rocketmq/common/filter/impl/Operator.java
index 45bebf0..a232fe4 100644
--- a/common/src/main/java/org/apache/rocketmq/common/filter/impl/Operator.java
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/impl/Operator.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.filter.impl;
@@ -27,7 +27,6 @@ public class Operator extends Op {
private int priority;
private boolean compareable;
-
private Operator(String symbol, int priority, boolean compareable) {
super(symbol);
this.priority = priority;
@@ -55,7 +54,6 @@ public class Operator extends Op {
return compareable;
}
-
public int compare(Operator operator) {
if (this.priority > operator.priority)
return 1;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/filter/impl/PolishExpr.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/impl/PolishExpr.java b/common/src/main/java/org/apache/rocketmq/common/filter/impl/PolishExpr.java
index 73b51b6..2b89944 100644
--- a/common/src/main/java/org/apache/rocketmq/common/filter/impl/PolishExpr.java
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/impl/PolishExpr.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.filter.impl;
@@ -49,7 +49,7 @@ public class PolishExpr {
segments.add(token);
} else if (isLeftParenthesis(token)) {
- operatorStack.push((Operator) token);
+ operatorStack.push((Operator)token);
} else if (isRightParenthesis(token)) {
Operator opNew = null;
@@ -60,7 +60,7 @@ public class PolishExpr {
throw new IllegalArgumentException("mismatched parentheses");
} else if (isOperator(token)) {
- Operator opNew = (Operator) token;
+ Operator opNew = (Operator)token;
if (!operatorStack.empty()) {
Operator opOld = operatorStack.peek();
if (opOld.isCompareable() && opNew.compare(opOld) != 1) {
@@ -99,17 +99,16 @@ public class PolishExpr {
Type preType = Type.NULL;
for (int i = 0; i < size; i++) {
- int chValue = (int) expression.charAt(i);
+ int chValue = (int)expression.charAt(i);
if ((97 <= chValue && chValue <= 122) || (65 <= chValue && chValue <= 90)
- || (49 <= chValue && chValue <= 57) || 95 == chValue) {
-
+ || (49 <= chValue && chValue <= 57) || 95 == chValue) {
if (Type.OPERATOR == preType || Type.SEPAERATOR == preType || Type.NULL == preType
- || Type.PARENTHESIS == preType) {
+ || Type.PARENTHESIS == preType) {
if (Type.OPERATOR == preType) {
segments.add(createOperator(expression.substring(wordStartIndex, wordStartIndex
- + wordLen)));
+ + wordLen)));
}
wordStartIndex = i;
wordLen = 0;
@@ -118,10 +117,9 @@ public class PolishExpr {
wordLen++;
} else if (40 == chValue || 41 == chValue) {
-
if (Type.OPERATOR == preType) {
segments.add(createOperator(expression
- .substring(wordStartIndex, wordStartIndex + wordLen)));
+ .substring(wordStartIndex, wordStartIndex + wordLen)));
wordStartIndex = -1;
wordLen = 0;
} else if (Type.OPERAND == preType) {
@@ -131,13 +129,13 @@ public class PolishExpr {
}
preType = Type.PARENTHESIS;
- segments.add(createOperator((char) chValue + ""));
+ segments.add(createOperator((char)chValue + ""));
} else if (38 == chValue || 124 == chValue) {
if (Type.OPERAND == preType || Type.SEPAERATOR == preType || Type.PARENTHESIS == preType) {
if (Type.OPERAND == preType) {
segments.add(new Operand(expression.substring(wordStartIndex, wordStartIndex
- + wordLen)));
+ + wordLen)));
}
wordStartIndex = i;
wordLen = 0;
@@ -146,10 +144,9 @@ public class PolishExpr {
wordLen++;
} else if (32 == chValue || 9 == chValue) {
-
if (Type.OPERATOR == preType) {
segments.add(createOperator(expression
- .substring(wordStartIndex, wordStartIndex + wordLen)));
+ .substring(wordStartIndex, wordStartIndex + wordLen)));
wordStartIndex = -1;
wordLen = 0;
} else if (Type.OPERAND == preType) {
@@ -160,7 +157,7 @@ public class PolishExpr {
preType = Type.SEPAERATOR;
} else {
- throw new IllegalArgumentException("illegal expression, at index " + i + " " + (char) chValue);
+ throw new IllegalArgumentException("illegal expression, at index " + i + " " + (char)chValue);
}
}
@@ -176,11 +173,11 @@ public class PolishExpr {
}
public static boolean isLeftParenthesis(Op token) {
- return token instanceof Operator && LEFTPARENTHESIS == (Operator) token;
+ return token instanceof Operator && LEFTPARENTHESIS == (Operator)token;
}
public static boolean isRightParenthesis(Op token) {
- return token instanceof Operator && RIGHTPARENTHESIS == (Operator) token;
+ return token instanceof Operator && RIGHTPARENTHESIS == (Operator)token;
}
public static boolean isOperator(Op token) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/filter/impl/Type.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/impl/Type.java b/common/src/main/java/org/apache/rocketmq/common/filter/impl/Type.java
index 834bde8..68797de 100644
--- a/common/src/main/java/org/apache/rocketmq/common/filter/impl/Type.java
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/impl/Type.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.filter.impl;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java b/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java
index d3c5f33..603db27 100644
--- a/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java
+++ b/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java
@@ -6,72 +6,61 @@
* (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
+ * 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.
+ * 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.common.help;
public class FAQUrl {
public static final String APPLY_TOPIC_URL = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&topic_not_exist";
-
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&topic_not_exist";
public static final String NAME_SERVER_ADDR_NOT_EXIST_URL = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&namesrv_not_exist";
-
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&namesrv_not_exist";
public static final String GROUP_NAME_DUPLICATE_URL = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&group_duplicate";
-
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&group_duplicate";
public static final String CLIENT_PARAMETER_CHECK_URL = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions¶meter_check_failed";
-
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions¶meter_check_failed";
public static final String SUBSCRIPTION_GROUP_NOT_EXIST = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&subGroup_not_exist";
-
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&subGroup_not_exist";
public static final String CLIENT_SERVICE_NOT_OK = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&service_not_ok";
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&service_not_ok";
// FAQ: No route info of this topic, TopicABC
public static final String NO_TOPIC_ROUTE_INFO = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&topic_not_exist";
-
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&topic_not_exist";
public static final String LOAD_JSON_EXCEPTION = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&load_json_exception";
-
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&load_json_exception";
public static final String SAME_GROUP_DIFFERENT_TOPIC = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&subscription_exception";
-
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&subscription_exception";
public static final String MQLIST_NOT_EXIST = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&queue_not_exist";
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&queue_not_exist";
public static final String UNEXPECTED_EXCEPTION_URL = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&unexpected_exception";
-
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&unexpected_exception";
public static final String SEND_MSG_FAILED = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&send_msg_failed";
-
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&send_msg_failed";
public static final String UNKNOWN_HOST_EXCEPTION = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&unknown_host";
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&unknown_host";
private static final String TIP_STRING_BEGIN = "\nSee ";
private static final String TIP_STRING_END = " for further details.";
-
public static String suggestTodo(final String url) {
StringBuilder sb = new StringBuilder();
sb.append(TIP_STRING_BEGIN);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java b/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java
index 10b1097..a0a7925 100644
--- a/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java
+++ b/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java
@@ -6,20 +6,19 @@
* (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
+ * 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.
+ * 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.common.hook;
import java.nio.ByteBuffer;
-
/**
*
*
@@ -27,6 +26,5 @@ import java.nio.ByteBuffer;
public interface FilterCheckHook {
public String hookName();
-
public boolean isFilterMatched(final boolean isUnitMode, final ByteBuffer byteBuffer);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/message/Message.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/Message.java b/common/src/main/java/org/apache/rocketmq/common/message/Message.java
index 258104c..00cb6d1 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/Message.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/Message.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.message;
@@ -21,7 +21,6 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-
/**
*
*
@@ -34,16 +33,13 @@ public class Message implements Serializable {
private Map<String, String> properties;
private byte[] body;
-
public Message() {
}
-
public Message(String topic, byte[] body) {
this(topic, "", "", 0, body, true);
}
-
public Message(String topic, String tags, String keys, int flag, byte[] body, boolean waitStoreMsgOK) {
this.topic = topic;
this.flag = flag;
@@ -58,6 +54,14 @@ public class Message implements Serializable {
this.setWaitStoreMsgOK(waitStoreMsgOK);
}
+ public Message(String topic, String tags, byte[] body) {
+ this(topic, tags, "", 0, body, true);
+ }
+
+ public Message(String topic, String tags, String keys, byte[] body) {
+ this(topic, tags, keys, 0, body, true);
+ }
+
public void setKeys(String keys) {
this.putProperty(MessageConst.PROPERTY_KEYS, keys);
}
@@ -70,16 +74,6 @@ public class Message implements Serializable {
this.properties.put(name, value);
}
-
- public Message(String topic, String tags, byte[] body) {
- this(topic, tags, "", 0, body, true);
- }
-
-
- public Message(String topic, String tags, String keys, byte[] body) {
- this(topic, tags, keys, 0, body, true);
- }
-
void clearProperty(final String name) {
if (null != this.properties) {
this.properties.remove(name);
@@ -89,7 +83,7 @@ public class Message implements Serializable {
public void putUserProperty(final String name, final String value) {
if (MessageConst.STRING_HASH_SET.contains(name)) {
throw new RuntimeException(String.format(
- "The Property<%s> is used by system, input another please", name));
+ "The Property<%s> is used by system, input another please", name));
}
this.putProperty(name, value);
}
@@ -136,7 +130,6 @@ public class Message implements Serializable {
this.setKeys(sb.toString().trim());
}
-
public int getDelayTimeLevel() {
String t = this.getProperty(MessageConst.PROPERTY_DELAY_TIME_LEVEL);
if (t != null) {
@@ -146,12 +139,10 @@ public class Message implements Serializable {
return 0;
}
-
public void setDelayTimeLevel(int level) {
this.putProperty(MessageConst.PROPERTY_DELAY_TIME_LEVEL, String.valueOf(level));
}
-
public boolean isWaitStoreMsgOK() {
String result = this.getProperty(MessageConst.PROPERTY_WAIT_STORE_MSG_OK);
if (null == result)
@@ -160,37 +151,30 @@ public class Message implements Serializable {
return Boolean.parseBoolean(result);
}
-
public void setWaitStoreMsgOK(boolean waitStoreMsgOK) {
this.putProperty(MessageConst.PROPERTY_WAIT_STORE_MSG_OK, Boolean.toString(waitStoreMsgOK));
}
-
public int getFlag() {
return flag;
}
-
public void setFlag(int flag) {
this.flag = flag;
}
-
public byte[] getBody() {
return body;
}
-
public void setBody(byte[] body) {
this.body = body;
}
-
public Map<String, String> getProperties() {
return properties;
}
-
void setProperties(Map<String, String> properties) {
this.properties = properties;
}
@@ -206,6 +190,6 @@ public class Message implements Serializable {
@Override
public String toString() {
return "Message [topic=" + topic + ", flag=" + flag + ", properties=" + properties + ", body="
- + (body != null ? body.length : 0) + "]";
+ + (body != null ? body.length : 0) + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/message/MessageAccessor.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageAccessor.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageAccessor.java
index 5cd0ba8..7663ecd 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageAccessor.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageAccessor.java
@@ -6,20 +6,19 @@
* (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
+ * 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.
+ * 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.common.message;
import java.util.Map;
-
public class MessageAccessor {
public static void clearProperty(final Message msg, final String name) {
@@ -42,52 +41,42 @@ public class MessageAccessor {
return msg.getProperty(MessageConst.PROPERTY_TRANSFER_FLAG);
}
-
public static void setCorrectionFlag(final Message msg, String unit) {
putProperty(msg, MessageConst.PROPERTY_CORRECTION_FLAG, unit);
}
-
public static String getCorrectionFlag(final Message msg) {
return msg.getProperty(MessageConst.PROPERTY_CORRECTION_FLAG);
}
-
public static void setOriginMessageId(final Message msg, String originMessageId) {
putProperty(msg, MessageConst.PROPERTY_ORIGIN_MESSAGE_ID, originMessageId);
}
-
public static String getOriginMessageId(final Message msg) {
return msg.getProperty(MessageConst.PROPERTY_ORIGIN_MESSAGE_ID);
}
-
public static void setMQ2Flag(final Message msg, String flag) {
putProperty(msg, MessageConst.PROPERTY_MQ2_FLAG, flag);
}
-
public static String getMQ2Flag(final Message msg) {
return msg.getProperty(MessageConst.PROPERTY_MQ2_FLAG);
}
-
public static void setReconsumeTime(final Message msg, String reconsumeTimes) {
putProperty(msg, MessageConst.PROPERTY_RECONSUME_TIME, reconsumeTimes);
}
-
public static String getReconsumeTime(final Message msg) {
return msg.getProperty(MessageConst.PROPERTY_RECONSUME_TIME);
}
-
public static void setMaxReconsumeTimes(final Message msg, String maxReconsumeTimes) {
putProperty(msg, MessageConst.PROPERTY_MAX_RECONSUME_TIMES, maxReconsumeTimes);
}
-
public static String getMaxReconsumeTimes(final Message msg) {
return msg.getProperty(MessageConst.PROPERTY_MAX_RECONSUME_TIMES);
}
@@ -96,7 +85,6 @@ public class MessageAccessor {
putProperty(msg, MessageConst.PROPERTY_CONSUME_START_TIMESTAMP, propertyConsumeStartTimeStamp);
}
-
public static String getConsumeStartTimeStamp(final Message msg) {
return msg.getProperty(MessageConst.PROPERTY_CONSUME_START_TIMESTAMP);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/message/MessageClientExt.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageClientExt.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageClientExt.java
index 90703ca..8fa6a15 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageClientExt.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageClientExt.java
@@ -6,40 +6,38 @@
* (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
+ * 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.
+ * 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.common.message;
public class MessageClientExt extends MessageExt {
-
- public void setOffsetMsgId(String offsetMsgId) {
- super.setMsgId(offsetMsgId);
- }
-
public String getOffsetMsgId() {
return super.getMsgId();
}
-
- public void setMsgId(String msgId) {
- //DO NOTHING
- //MessageClientIDSetter.setUniqID(this);
+
+ public void setOffsetMsgId(String offsetMsgId) {
+ super.setMsgId(offsetMsgId);
}
-
+
@Override
public String getMsgId() {
String uniqID = MessageClientIDSetter.getUniqID(this);
if (uniqID == null) {
return this.getOffsetMsgId();
- }
- else {
+ } else {
return uniqID;
}
}
+
+ public void setMsgId(String msgId) {
+ //DO NOTHING
+ //MessageClientIDSetter.setUniqID(this);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/message/MessageClientIDSetter.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageClientIDSetter.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageClientIDSetter.java
index 1c3a1b7..1c27920 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageClientIDSetter.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageClientIDSetter.java
@@ -16,12 +16,11 @@
*/
package org.apache.rocketmq.common.message;
-import org.apache.rocketmq.common.UtilAll;
-
import java.nio.ByteBuffer;
import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.rocketmq.common.UtilAll;
public class MessageClientIDSetter {
private static final String TOPIC_KEY_SPLITTER = "#";
@@ -65,10 +64,10 @@ public class MessageClientIDSetter {
public static Date getNearlyTimeFromID(String msgID) {
ByteBuffer buf = ByteBuffer.allocate(8);
byte[] bytes = UtilAll.string2bytes(msgID);
- buf.put((byte) 0);
- buf.put((byte) 0);
- buf.put((byte) 0);
- buf.put((byte) 0);
+ buf.put((byte)0);
+ buf.put((byte)0);
+ buf.put((byte)0);
+ buf.put((byte)0);
buf.put(bytes, 10, 4);
buf.position(0);
long spanMS = buf.getLong();
@@ -107,7 +106,6 @@ public class MessageClientIDSetter {
return sb.toString();
}
-
private static byte[] createUniqIDBuffer() {
ByteBuffer buffer = ByteBuffer.allocate(4 + 2);
long current = System.currentTimeMillis();
@@ -115,8 +113,8 @@ public class MessageClientIDSetter {
setStartTime(current);
}
buffer.position(0);
- buffer.putInt((int) (System.currentTimeMillis() - startTime));
- buffer.putShort((short) COUNTER.getAndIncrement());
+ buffer.putInt((int)(System.currentTimeMillis() - startTime));
+ buffer.putShort((short)COUNTER.getAndIncrement());
return buffer.array();
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/message/MessageConst.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageConst.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageConst.java
index d65160b..a4c15a8 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageConst.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageConst.java
@@ -18,7 +18,6 @@ package org.apache.rocketmq.common.message;
import java.util.HashSet;
-
public class MessageConst {
public static final String PROPERTY_KEYS = "KEYS";
public static final String PROPERTY_TAGS = "TAGS";
@@ -47,7 +46,6 @@ public class MessageConst {
public static final HashSet<String> STRING_HASH_SET = new HashSet<String>();
-
static {
STRING_HASH_SET.add(PROPERTY_TRACE_SWITCH);
STRING_HASH_SET.add(PROPERTY_MSG_REGION);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
index 375cc47..6ae1d2a 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.common.message;
-import org.apache.rocketmq.common.UtilAll;
-import org.apache.rocketmq.common.sysflag.MessageSysFlag;
-
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
@@ -30,7 +27,8 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.sysflag.MessageSysFlag;
public class MessageDecoder {
public final static int MSG_ID_LENGTH = 8 + 8;
@@ -41,7 +39,8 @@ public class MessageDecoder {
public final static int MESSAGE_PHYSIC_OFFSET_POSTION = 28;
public final static int MESSAGE_STORE_TIMESTAMP_POSTION = 56;
public final static int MESSAGE_MAGIC_CODE = 0xAABBCCDD ^ 1880681586 + 8;
-
+ public static final char NAME_VALUE_SEPARATOR = 1;
+ public static final char PROPERTY_SEPARATOR = 2;
public static String createMessageId(final ByteBuffer input, final ByteBuffer addr, final long offset) {
input.flip();
@@ -53,10 +52,9 @@ public class MessageDecoder {
return UtilAll.bytes2string(input.array());
}
-
public static String createMessageId(SocketAddress socketAddress, long transactionIdhashCode) {
ByteBuffer byteBuffer = ByteBuffer.allocate(MessageDecoder.MSG_ID_LENGTH);
- InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
+ InetSocketAddress inetSocketAddress = (InetSocketAddress)socketAddress;
byteBuffer.put(inetSocketAddress.getAddress().getAddress());
byteBuffer.putInt(inetSocketAddress.getPort());
byteBuffer.putLong(transactionIdhashCode);
@@ -64,12 +62,10 @@ public class MessageDecoder {
return UtilAll.bytes2string(byteBuffer.array());
}
-
public static MessageId decodeMessageId(final String msgId) throws UnknownHostException {
SocketAddress address;
long offset;
-
byte[] ip = UtilAll.string2bytes(msgId.substring(0, 8));
byte[] port = UtilAll.string2bytes(msgId.substring(8, 16));
ByteBuffer bb = ByteBuffer.wrap(port);
@@ -84,7 +80,6 @@ public class MessageDecoder {
return new MessageId(address, offset);
}
-
public static MessageExt decode(java.nio.ByteBuffer byteBuffer) {
return decode(byteBuffer, true, true, false);
}
@@ -97,14 +92,13 @@ public class MessageDecoder {
return decode(byteBuffer, readBody, true, false);
}
-
public static byte[] encode(MessageExt messageExt, boolean needCompress) throws Exception {
byte[] body = messageExt.getBody();
byte[] topics = messageExt.getTopic().getBytes(CHARSET_UTF8);
- byte topicLen = (byte) topics.length;
+ byte topicLen = (byte)topics.length;
String properties = messageProperties2String(messageExt.getProperties());
byte[] propertiesBytes = properties.getBytes(CHARSET_UTF8);
- short propertiesLength = (short) propertiesBytes.length;
+ short propertiesLength = (short)propertiesBytes.length;
int sysFlag = messageExt.getSysFlag();
byte[] newBody = messageExt.getBody();
if (needCompress && (sysFlag & MessageSysFlag.COMPRESSED_FLAG) == MessageSysFlag.COMPRESSED_FLAG) {
@@ -117,23 +111,23 @@ public class MessageDecoder {
byteBuffer = ByteBuffer.allocate(storeSize);
} else {
storeSize = 4 // 1 TOTALSIZE
- + 4 // 2 MAGICCODE
- + 4 // 3 BODYCRC
- + 4 // 4 QUEUEID
- + 4 // 5 FLAG
- + 8 // 6 QUEUEOFFSET
- + 8 // 7 PHYSICALOFFSET
- + 4 // 8 SYSFLAG
- + 8 // 9 BORNTIMESTAMP
- + 8 // 10 BORNHOST
- + 8 // 11 STORETIMESTAMP
- + 8 // 12 STOREHOSTADDRESS
- + 4 // 13 RECONSUMETIMES
- + 8 // 14 Prepared Transaction Offset
- + 4 + bodyLength // 14 BODY
- + 1 + topicLen // 15 TOPIC
- + 2 + propertiesLength // 16 propertiesLength
- + 0;
+ + 4 // 2 MAGICCODE
+ + 4 // 3 BODYCRC
+ + 4 // 4 QUEUEID
+ + 4 // 5 FLAG
+ + 8 // 6 QUEUEOFFSET
+ + 8 // 7 PHYSICALOFFSET
+ + 4 // 8 SYSFLAG
+ + 8 // 9 BORNTIMESTAMP
+ + 8 // 10 BORNHOST
+ + 8 // 11 STORETIMESTAMP
+ + 8 // 12 STOREHOSTADDRESS
+ + 4 // 13 RECONSUMETIMES
+ + 8 // 14 Prepared Transaction Offset
+ + 4 + bodyLength // 14 BODY
+ + 1 + topicLen // 15 TOPIC
+ + 2 + propertiesLength // 16 propertiesLength
+ + 0;
byteBuffer = ByteBuffer.allocate(storeSize);
}
// 1 TOTALSIZE
@@ -170,7 +164,7 @@ public class MessageDecoder {
byteBuffer.putLong(bornTimeStamp);
// 10 BORNHOST
- InetSocketAddress bornHost = (InetSocketAddress) messageExt.getBornHost();
+ InetSocketAddress bornHost = (InetSocketAddress)messageExt.getBornHost();
byteBuffer.put(bornHost.getAddress().getAddress());
byteBuffer.putInt(bornHost.getPort());
@@ -179,7 +173,7 @@ public class MessageDecoder {
byteBuffer.putLong(storeTimestamp);
// 12 STOREHOST
- InetSocketAddress serverHost = (InetSocketAddress) messageExt.getStoreHost();
+ InetSocketAddress serverHost = (InetSocketAddress)messageExt.getStoreHost();
byteBuffer.put(serverHost.getAddress().getAddress());
byteBuffer.putInt(serverHost.getPort());
@@ -207,12 +201,12 @@ public class MessageDecoder {
}
public static MessageExt decode(
- java.nio.ByteBuffer byteBuffer, final boolean readBody, final boolean deCompressBody) {
+ java.nio.ByteBuffer byteBuffer, final boolean readBody, final boolean deCompressBody) {
return decode(byteBuffer, readBody, deCompressBody, false);
}
public static MessageExt decode(
- java.nio.ByteBuffer byteBuffer, final boolean readBody, final boolean deCompressBody, final boolean isClient) {
+ java.nio.ByteBuffer byteBuffer, final boolean readBody, final boolean deCompressBody, final boolean isClient) {
try {
MessageExt msgExt;
@@ -301,7 +295,7 @@ public class MessageDecoder {
// 16 TOPIC
byte topicLen = byteBuffer.get();
- byte[] topic = new byte[(int) topicLen];
+ byte[] topic = new byte[(int)topicLen];
byteBuffer.get(topic);
msgExt.setTopic(new String(topic, CHARSET_UTF8));
@@ -320,7 +314,7 @@ public class MessageDecoder {
msgExt.setMsgId(msgId);
if (isClient) {
- ((MessageClientExt) msgExt).setOffsetMsgId(msgId);
+ ((MessageClientExt)msgExt).setOffsetMsgId(msgId);
}
return msgExt;
@@ -335,7 +329,6 @@ public class MessageDecoder {
return null;
}
-
public static List<MessageExt> decodes(java.nio.ByteBuffer byteBuffer) {
return decodes(byteBuffer, true);
}
@@ -353,10 +346,6 @@ public class MessageDecoder {
return msgExts;
}
- public static final char NAME_VALUE_SEPARATOR = 1;
- public static final char PROPERTY_SEPARATOR = 2;
-
-
public static String messageProperties2String(Map<String, String> properties) {
StringBuilder sb = new StringBuilder();
if (properties != null) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
index b771666..9fec0ca 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
@@ -6,23 +6,21 @@
* (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
+ * 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.
+ * 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.common.message;
-import org.apache.rocketmq.common.TopicFilterType;
-import org.apache.rocketmq.common.sysflag.MessageSysFlag;
-
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
-
+import org.apache.rocketmq.common.TopicFilterType;
+import org.apache.rocketmq.common.sysflag.MessageSysFlag;
public class MessageExt extends Message {
private static final long serialVersionUID = 5720810158625748049L;
@@ -45,13 +43,11 @@ public class MessageExt extends Message {
private long preparedTransactionOffset;
-
public MessageExt() {
}
-
public MessageExt(int queueId, long bornTimestamp, SocketAddress bornHost, long storeTimestamp,
- SocketAddress storeHost, String msgId) {
+ SocketAddress storeHost, String msgId) {
this.queueId = queueId;
this.bornTimestamp = bornTimestamp;
this.bornHost = bornHost;
@@ -68,16 +64,8 @@ public class MessageExt extends Message {
return TopicFilterType.SINGLE_TAG;
}
- public ByteBuffer getBornHostBytes() {
- return socketAddress2ByteBuffer(this.bornHost);
- }
-
- public ByteBuffer getBornHostBytes(ByteBuffer byteBuffer) {
- return socketAddress2ByteBuffer(this.bornHost, byteBuffer);
- }
-
private static ByteBuffer socketAddress2ByteBuffer(final SocketAddress socketAddress, final ByteBuffer byteBuffer) {
- InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
+ InetSocketAddress inetSocketAddress = (InetSocketAddress)socketAddress;
byteBuffer.put(inetSocketAddress.getAddress().getAddress(), 0, 4);
byteBuffer.putInt(inetSocketAddress.getPort());
byteBuffer.flip();
@@ -89,6 +77,14 @@ public class MessageExt extends Message {
return socketAddress2ByteBuffer(socketAddress, byteBuffer);
}
+ public ByteBuffer getBornHostBytes() {
+ return socketAddress2ByteBuffer(this.bornHost);
+ }
+
+ public ByteBuffer getBornHostBytes(ByteBuffer byteBuffer) {
+ return socketAddress2ByteBuffer(this.bornHost, byteBuffer);
+ }
+
public ByteBuffer getStoreHostBytes() {
return socketAddress2ByteBuffer(this.storeHost);
}
@@ -123,7 +119,7 @@ public class MessageExt extends Message {
public String getBornHostString() {
if (this.bornHost != null) {
- InetSocketAddress inetSocketAddress = (InetSocketAddress) this.bornHost;
+ InetSocketAddress inetSocketAddress = (InetSocketAddress)this.bornHost;
return inetSocketAddress.getAddress().getHostAddress();
}
@@ -132,7 +128,7 @@ public class MessageExt extends Message {
public String getBornHostNameString() {
if (this.bornHost != null) {
- InetSocketAddress inetSocketAddress = (InetSocketAddress) this.bornHost;
+ InetSocketAddress inetSocketAddress = (InetSocketAddress)this.bornHost;
return inetSocketAddress.getAddress().getHostName();
}
@@ -207,29 +203,25 @@ public class MessageExt extends Message {
return reconsumeTimes;
}
-
public void setReconsumeTimes(int reconsumeTimes) {
this.reconsumeTimes = reconsumeTimes;
}
-
public long getPreparedTransactionOffset() {
return preparedTransactionOffset;
}
-
public void setPreparedTransactionOffset(long preparedTransactionOffset) {
this.preparedTransactionOffset = preparedTransactionOffset;
}
-
@Override
public String toString() {
return "MessageExt [queueId=" + queueId + ", storeSize=" + storeSize + ", queueOffset=" + queueOffset
- + ", sysFlag=" + sysFlag + ", bornTimestamp=" + bornTimestamp + ", bornHost=" + bornHost
- + ", storeTimestamp=" + storeTimestamp + ", storeHost=" + storeHost + ", msgId=" + msgId
- + ", commitLogOffset=" + commitLogOffset + ", bodyCRC=" + bodyCRC + ", reconsumeTimes="
- + reconsumeTimes + ", preparedTransactionOffset=" + preparedTransactionOffset
- + ", toString()=" + super.toString() + "]";
+ + ", sysFlag=" + sysFlag + ", bornTimestamp=" + bornTimestamp + ", bornHost=" + bornHost
+ + ", storeTimestamp=" + storeTimestamp + ", storeHost=" + storeHost + ", msgId=" + msgId
+ + ", commitLogOffset=" + commitLogOffset + ", bodyCRC=" + bodyCRC + ", reconsumeTimes="
+ + reconsumeTimes + ", preparedTransactionOffset=" + preparedTransactionOffset
+ + ", toString()=" + super.toString() + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java
index 04dd01f..0de3318 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java
@@ -6,45 +6,39 @@
* (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
+ * 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.
+ * 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.common.message;
import java.net.SocketAddress;
-
public class MessageId {
private SocketAddress address;
private long offset;
-
public MessageId(SocketAddress address, long offset) {
this.address = address;
this.offset = offset;
}
-
public SocketAddress getAddress() {
return address;
}
-
public void setAddress(SocketAddress address) {
this.address = address;
}
-
public long getOffset() {
return offset;
}
-
public void setOffset(long offset) {
this.offset = offset;
}
[55/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Use apache
email as author.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java
index 86529ee..7b63eb0 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java
@@ -24,7 +24,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface ConsumeMessageService {
void start();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
index affb652..c343b17 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
@@ -57,7 +57,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class DefaultMQPullConsumerImpl implements MQConsumerInner {
private final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
index 664b9fb..3a7014e 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
@@ -66,7 +66,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class DefaultMQPushConsumerImpl implements MQConsumerInner {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
index c1abd2f..5aab2ce 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
@@ -29,7 +29,7 @@ import java.util.Set;
/**
* Consumer inner interface
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface MQConsumerInner {
String groupName();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
index 0849b5e..2d553cb 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
@@ -24,7 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* Message lock,strictly ensure the single queue only one thread at a time consuming
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MessageQueueLock {
private ConcurrentHashMap<MessageQueue, Object> mqLockTable =
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
index adca859..e54d2e3 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
@@ -38,7 +38,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* Queue consumption snapshot
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ProcessQueue {
public final static long REBALANCE_LOCK_MAX_LIVE_TIME =
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
index 05aa8d1..b5fc4a3 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
@@ -45,7 +45,7 @@ import java.util.concurrent.atomic.AtomicLong;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class PullAPIWrapper {
private final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
index 9f79543..17610a3 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
@@ -25,7 +25,7 @@ import java.util.concurrent.*;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class PullMessageService extends ServiceThread {
private final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
index b98b2a2..211ed21 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
@@ -20,7 +20,7 @@ import org.apache.rocketmq.common.message.MessageQueue;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class PullRequest {
private String consumerGroup;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java
index b924472..95ca1aa 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java
@@ -24,7 +24,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class PullResultExt extends PullResult {
private final long suggestWhichBrokerId;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
index 05b7cfc..58a6157 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
@@ -37,7 +37,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* Base class for rebalance algorithm
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public abstract class RebalanceImpl {
protected static final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java
index 376c21c..273b973 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java
@@ -28,7 +28,7 @@ import java.util.Set;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class RebalancePullImpl extends RebalanceImpl {
private final DefaultMQPullConsumerImpl defaultMQPullConsumerImpl;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
index 4efac01..f9eaf41 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
@@ -34,7 +34,7 @@ import java.util.concurrent.TimeUnit;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class RebalancePushImpl extends RebalanceImpl {
private final static long UNLOCK_DELAY_TIME_MILLS = Long.parseLong(System.getProperty("rocketmq.client.unlockDelayTimeMills", "20000"));
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
index e6059fe..1745324 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
@@ -25,7 +25,7 @@ import org.slf4j.Logger;
/**
* Rebalance Service
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class RebalanceService extends ServiceThread {
private static long waitInterval =
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java b/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
index fcadd9a..4a1cef4 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
@@ -59,7 +59,7 @@ import java.util.concurrent.locks.ReentrantLock;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MQClientInstance {
private final static long LOCK_TIMEOUT_MILLIS = 3000;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
index 62af958..ec0a9db 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
@@ -55,7 +55,7 @@ import java.util.concurrent.*;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class DefaultMQProducerImpl implements MQProducerInner {
private final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java b/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java
index c196a43..894017d 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java
@@ -24,7 +24,7 @@ import java.util.Set;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface MQProducerInner {
Set<String> getPublishTopicList();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java b/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
index 5267625..1712308 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
@@ -26,7 +26,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class TopicPublishInfo {
private boolean orderTopic = false;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultTolerance.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultTolerance.java b/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultTolerance.java
index c5e25ce..2da66f1 100644
--- a/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultTolerance.java
+++ b/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultTolerance.java
@@ -18,7 +18,7 @@
package org.apache.rocketmq.client.latency;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface LatencyFaultTolerance<T> {
void updateFaultItem(final T name, final long currentLatency, final long notAvailableDuration);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java b/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
index 3bd7788..8448128 100644
--- a/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
@@ -26,7 +26,7 @@ import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class LatencyFaultToleranceImpl implements LatencyFaultTolerance<String> {
private final ConcurrentHashMap<String, FaultItem> faultItemTable = new ConcurrentHashMap<String, FaultItem>(16);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java b/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java
index 6d32105..75a3b0a 100644
--- a/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java
+++ b/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java
@@ -21,7 +21,7 @@ import org.apache.rocketmq.client.impl.producer.TopicPublishInfo;
import org.apache.rocketmq.common.message.MessageQueue;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MQFaultStrategy {
private final LatencyFaultTolerance<String> latencyFaultTolerance = new LatencyFaultToleranceImpl();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java b/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java
index e4c5525..48595a5 100644
--- a/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java
+++ b/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java
@@ -26,7 +26,7 @@ import java.net.URL;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ClientLogger {
private static Logger log;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java
----------------------------------------------------------------------
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 070635a..854623f 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
@@ -30,7 +30,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class DefaultMQProducer extends ClientConfig implements MQProducer {
protected final transient DefaultMQProducerImpl defaultMQProducerImpl;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java b/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java
index 5e8178a..50ed48d 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java
@@ -20,7 +20,7 @@ import org.apache.rocketmq.common.message.Message;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface LocalTransactionExecuter {
public LocalTransactionState executeLocalTransactionBranch(final Message msg, final Object arg);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java b/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java
index ce5b0d9..eeec460 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.client.producer;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public enum LocalTransactionState {
COMMIT_MESSAGE,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java b/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java
index 0ea4a33..7fb6561 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java
@@ -27,7 +27,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface MQProducer extends MQAdmin {
void start() throws MQClientException;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java b/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java
index c7a9124..30d7ba5 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java
@@ -23,7 +23,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface MessageQueueSelector {
MessageQueue select(final List<MessageQueue> mqs, final Message msg, final Object arg);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java b/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java
index 7b0e00e..eca9762 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.client.producer;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface SendCallback {
public void onSuccess(final SendResult sendResult);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java b/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java
index 02ed6b5..7c918f0 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java
@@ -21,7 +21,7 @@ import org.apache.rocketmq.common.message.MessageQueue;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class SendResult {
private SendStatus sendStatus;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java b/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java
index 038bc99..740228f 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.client.producer;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public enum SendStatus {
SEND_OK,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java
index 9a11d50..0616949 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java
@@ -20,7 +20,7 @@ import org.apache.rocketmq.common.message.MessageExt;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface TransactionCheckListener {
LocalTransactionState checkLocalTransactionState(final MessageExt msg);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java
index eaca6ec..ab6d782 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java
@@ -22,7 +22,7 @@ import org.apache.rocketmq.remoting.RPCHook;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class TransactionMQProducer extends DefaultMQProducer {
private TransactionCheckListener transactionCheckListener;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java
index 478c39d..3ea7efc 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.client.producer;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class TransactionSendResult extends SendResult {
private LocalTransactionState localTransactionState;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java
index 0f6ce48..b304d91 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java
@@ -24,7 +24,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class SelectMessageQueueByHash implements MessageQueueSelector {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java
index 1902de5..967b27a 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java
@@ -25,7 +25,7 @@ import java.util.Set;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class SelectMessageQueueByMachineRoom implements MessageQueueSelector {
private Set<String> consumeridcs;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java
index b39b777..d33c725 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java
@@ -25,7 +25,7 @@ import java.util.Random;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class SelectMessageQueueByRandoom implements MessageQueueSelector {
private Random random = new Random(System.currentTimeMillis());
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java b/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java
index f035ed6..51b4f25 100644
--- a/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java
+++ b/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java
@@ -25,7 +25,7 @@ import java.net.UnknownHostException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class BrokerConfig {
private String rocketmqHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV));
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java b/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java
index c9303b7..0175cac 100644
--- a/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java
+++ b/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java
@@ -24,7 +24,7 @@ import java.io.IOException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public abstract class ConfigManager {
private static final Logger PLOG = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/CountDownLatch.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/CountDownLatch.java b/common/src/main/java/org/apache/rocketmq/common/CountDownLatch.java
deleted file mode 100644
index 971c0c7..0000000
--- a/common/src/main/java/org/apache/rocketmq/common/CountDownLatch.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/**
- * 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.common;
-
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.AbstractQueuedSynchronizer;
-
-/**
- * Add reset feature for @see java.util.concurrent.CountDownLatch
- *
- * @author xinyuzhou.zxy
- */
-public class CountDownLatch {
- /**
- * Synchronization control For CountDownLatch.
- * Uses AQS state to represent count.
- */
- private static final class Sync extends AbstractQueuedSynchronizer {
- private static final long serialVersionUID = 4982264981922014374L;
-
- private final int startCount;
-
- Sync(int count) {
- this.startCount = count;
- setState(count);
- }
-
- int getCount() {
- return getState();
- }
-
- protected int tryAcquireShared(int acquires) {
- return (getState() == 0) ? 1 : -1;
- }
-
- protected boolean tryReleaseShared(int releases) {
- // Decrement count; signal when transition to zero
- for (;;) {
- int c = getState();
- if (c == 0)
- return false;
- int nextc = c - 1;
- if (compareAndSetState(c, nextc))
- return nextc == 0;
- }
- }
-
- protected void reset() {
- setState(startCount);
- }
- }
-
- private final Sync sync;
-
- /**
- * Constructs a {@code CountDownLatch} initialized with the given count.
- *
- * @param count
- * the number of times {@link #countDown} must be invoked
- * before threads can pass through {@link #await}
- *
- * @throws IllegalArgumentException
- * if {@code count} is negative
- */
- public CountDownLatch(int count) {
- if (count < 0) throw new IllegalArgumentException("count < 0");
- this.sync = new Sync(count);
- }
-
- /**
- * Causes the current thread to wait until the latch has counted down to
- * zero, unless the thread is {@linkplain Thread#interrupt interrupted}.
- *
- * <p>If the current count is zero then this method returns immediately.
- *
- * <p>If the current count is greater than zero then the current
- * thread becomes disabled for thread scheduling purposes and lies
- * dormant until one of two things happen:
- * <ul>
- * <li>The count reaches zero due to invocations of the
- * {@link #countDown} method; or
- * <li>Some other thread {@linkplain Thread#interrupt interrupts}
- * the current thread.
- * </ul>
- *
- * <p>If the current thread:
- * <ul>
- * <li>has its interrupted status set on entry to this method; or
- * <li>is {@linkplain Thread#interrupt interrupted} while waiting,
- * </ul>
- * then {@link InterruptedException} is thrown and the current thread's
- * interrupted status is cleared.
- *
- * @throws InterruptedException
- * if the current thread is interrupted
- * while waiting
- */
- public void await() throws InterruptedException {
- sync.acquireSharedInterruptibly(1);
- }
-
- /**
- * Causes the current thread to wait until the latch has counted down to
- * zero, unless the thread is {@linkplain Thread#interrupt interrupted},
- * or the specified waiting time elapses.
- *
- * <p>If the current count is zero then this method returns immediately
- * with the value {@code true}.
- *
- * <p>If the current count is greater than zero then the current
- * thread becomes disabled for thread scheduling purposes and lies
- * dormant until one of three things happen:
- * <ul>
- * <li>The count reaches zero due to invocations of the
- * {@link #countDown} method; or
- * <li>Some other thread {@linkplain Thread#interrupt interrupts}
- * the current thread; or
- * <li>The specified waiting time elapses.
- * </ul>
- *
- * <p>If the count reaches zero then the method returns with the
- * value {@code true}.
- *
- * <p>If the current thread:
- * <ul>
- * <li>has its interrupted status set on entry to this method; or
- * <li>is {@linkplain Thread#interrupt interrupted} while waiting,
- * </ul>
- * then {@link InterruptedException} is thrown and the current thread's
- * interrupted status is cleared.
- *
- * <p>If the specified waiting time elapses then the value {@code false}
- * is returned. If the time is less than or equal to zero, the method
- * will not wait at all.
- *
- * @param timeout
- * the maximum time to wait
- * @param unit
- * the time unit of the {@code timeout} argument
- *
- * @return {@code true} if the count reached zero and {@code false}
- * if the waiting time elapsed before the count reached zero
- *
- * @throws InterruptedException
- * if the current thread is interrupted
- * while waiting
- */
- public boolean await(long timeout, TimeUnit unit)
- throws InterruptedException {
- return sync.tryAcquireSharedNanos(1, unit.toNanos(timeout));
- }
-
- /**
- * Decrements the count of the latch, releasing all waiting threads if
- * the count reaches zero.
- *
- * <p>If the current count is greater than zero then it is decremented.
- * If the new count is zero then all waiting threads are re-enabled for
- * thread scheduling purposes.
- *
- * <p>If the current count equals zero then nothing happens.
- */
- public void countDown() {
- sync.releaseShared(1);
- }
-
- /**
- * Returns the current count.
- *
- * <p>This method is typically used for debugging and testing purposes.
- *
- * @return the current count
- */
- public long getCount() {
- return sync.getCount();
- }
-
- public void reset() {
- sync.reset();
- }
-
- /**
- * Returns a string identifying this latch, as well as its state.
- * The state, in brackets, includes the String {@code "Count ="}
- * followed by the current count.
- *
- * @return a string identifying this latch, as well as its state
- */
- public String toString() {
- return super.toString() + "[Count = " + sync.getCount() + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java b/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java
new file mode 100644
index 0000000..a1a4061
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java
@@ -0,0 +1,207 @@
+/**
+ * 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.common;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.AbstractQueuedSynchronizer;
+
+/**
+ * Add reset feature for @see java.util.concurrent.CountDownLatch2
+ *
+ * @author yukon@apache.org
+ */
+public class CountDownLatch2 {
+ /**
+ * Synchronization control For CountDownLatch2.
+ * Uses AQS state to represent count.
+ */
+ private static final class Sync extends AbstractQueuedSynchronizer {
+ private static final long serialVersionUID = 4982264981922014374L;
+
+ private final int startCount;
+
+ Sync(int count) {
+ this.startCount = count;
+ setState(count);
+ }
+
+ int getCount() {
+ return getState();
+ }
+
+ protected int tryAcquireShared(int acquires) {
+ return (getState() == 0) ? 1 : -1;
+ }
+
+ protected boolean tryReleaseShared(int releases) {
+ // Decrement count; signal when transition to zero
+ for (;;) {
+ int c = getState();
+ if (c == 0)
+ return false;
+ int nextc = c - 1;
+ if (compareAndSetState(c, nextc))
+ return nextc == 0;
+ }
+ }
+
+ protected void reset() {
+ setState(startCount);
+ }
+ }
+
+ private final Sync sync;
+
+ /**
+ * Constructs a {@code CountDownLatch2} initialized with the given count.
+ *
+ * @param count
+ * the number of times {@link #countDown} must be invoked
+ * before threads can pass through {@link #await}
+ *
+ * @throws IllegalArgumentException
+ * if {@code count} is negative
+ */
+ public CountDownLatch2(int count) {
+ if (count < 0) throw new IllegalArgumentException("count < 0");
+ this.sync = new Sync(count);
+ }
+
+ /**
+ * Causes the current thread to wait until the latch has counted down to
+ * zero, unless the thread is {@linkplain Thread#interrupt interrupted}.
+ *
+ * <p>If the current count is zero then this method returns immediately.
+ *
+ * <p>If the current count is greater than zero then the current
+ * thread becomes disabled for thread scheduling purposes and lies
+ * dormant until one of two things happen:
+ * <ul>
+ * <li>The count reaches zero due to invocations of the
+ * {@link #countDown} method; or
+ * <li>Some other thread {@linkplain Thread#interrupt interrupts}
+ * the current thread.
+ * </ul>
+ *
+ * <p>If the current thread:
+ * <ul>
+ * <li>has its interrupted status set on entry to this method; or
+ * <li>is {@linkplain Thread#interrupt interrupted} while waiting,
+ * </ul>
+ * then {@link InterruptedException} is thrown and the current thread's
+ * interrupted status is cleared.
+ *
+ * @throws InterruptedException
+ * if the current thread is interrupted
+ * while waiting
+ */
+ public void await() throws InterruptedException {
+ sync.acquireSharedInterruptibly(1);
+ }
+
+ /**
+ * Causes the current thread to wait until the latch has counted down to
+ * zero, unless the thread is {@linkplain Thread#interrupt interrupted},
+ * or the specified waiting time elapses.
+ *
+ * <p>If the current count is zero then this method returns immediately
+ * with the value {@code true}.
+ *
+ * <p>If the current count is greater than zero then the current
+ * thread becomes disabled for thread scheduling purposes and lies
+ * dormant until one of three things happen:
+ * <ul>
+ * <li>The count reaches zero due to invocations of the
+ * {@link #countDown} method; or
+ * <li>Some other thread {@linkplain Thread#interrupt interrupts}
+ * the current thread; or
+ * <li>The specified waiting time elapses.
+ * </ul>
+ *
+ * <p>If the count reaches zero then the method returns with the
+ * value {@code true}.
+ *
+ * <p>If the current thread:
+ * <ul>
+ * <li>has its interrupted status set on entry to this method; or
+ * <li>is {@linkplain Thread#interrupt interrupted} while waiting,
+ * </ul>
+ * then {@link InterruptedException} is thrown and the current thread's
+ * interrupted status is cleared.
+ *
+ * <p>If the specified waiting time elapses then the value {@code false}
+ * is returned. If the time is less than or equal to zero, the method
+ * will not wait at all.
+ *
+ * @param timeout
+ * the maximum time to wait
+ * @param unit
+ * the time unit of the {@code timeout} argument
+ *
+ * @return {@code true} if the count reached zero and {@code false}
+ * if the waiting time elapsed before the count reached zero
+ *
+ * @throws InterruptedException
+ * if the current thread is interrupted
+ * while waiting
+ */
+ public boolean await(long timeout, TimeUnit unit)
+ throws InterruptedException {
+ return sync.tryAcquireSharedNanos(1, unit.toNanos(timeout));
+ }
+
+ /**
+ * Decrements the count of the latch, releasing all waiting threads if
+ * the count reaches zero.
+ *
+ * <p>If the current count is greater than zero then it is decremented.
+ * If the new count is zero then all waiting threads are re-enabled for
+ * thread scheduling purposes.
+ *
+ * <p>If the current count equals zero then nothing happens.
+ */
+ public void countDown() {
+ sync.releaseShared(1);
+ }
+
+ /**
+ * Returns the current count.
+ *
+ * <p>This method is typically used for debugging and testing purposes.
+ *
+ * @return the current count
+ */
+ public long getCount() {
+ return sync.getCount();
+ }
+
+ public void reset() {
+ sync.reset();
+ }
+
+ /**
+ * Returns a string identifying this latch, as well as its state.
+ * The state, in brackets, includes the String {@code "Count ="}
+ * followed by the current count.
+ *
+ * @return a string identifying this latch, as well as its state
+ */
+ public String toString() {
+ return super.toString() + "[Count = " + sync.getCount() + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/DataVersion.java b/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
index 94fd90b..067c028 100644
--- a/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
+++ b/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
@@ -22,7 +22,7 @@ import java.util.concurrent.atomic.AtomicLong;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class DataVersion extends RemotingSerializable {
private long timestatmp = System.currentTimeMillis();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/MQVersion.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/MQVersion.java b/common/src/main/java/org/apache/rocketmq/common/MQVersion.java
index f53fc27..d2c1a45 100644
--- a/common/src/main/java/org/apache/rocketmq/common/MQVersion.java
+++ b/common/src/main/java/org/apache/rocketmq/common/MQVersion.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.common;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MQVersion {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/MixAll.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/MixAll.java b/common/src/main/java/org/apache/rocketmq/common/MixAll.java
index 12fb65a..1e8374c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/MixAll.java
+++ b/common/src/main/java/org/apache/rocketmq/common/MixAll.java
@@ -49,7 +49,7 @@ import java.util.concurrent.atomic.AtomicLong;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MixAll {
public static final String ROCKETMQ_HOME_ENV = "ROCKETMQ_HOME";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/Pair.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/Pair.java b/common/src/main/java/org/apache/rocketmq/common/Pair.java
index ed6c246..dd8fded 100644
--- a/common/src/main/java/org/apache/rocketmq/common/Pair.java
+++ b/common/src/main/java/org/apache/rocketmq/common/Pair.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.common;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class Pair<T1, T2> {
private T1 object1;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/ServiceState.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/ServiceState.java b/common/src/main/java/org/apache/rocketmq/common/ServiceState.java
index 97f5b90..f211d7b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/ServiceState.java
+++ b/common/src/main/java/org/apache/rocketmq/common/ServiceState.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.common;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public enum ServiceState {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java b/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java
index 4fd5154..8884a96 100644
--- a/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java
+++ b/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java
@@ -24,8 +24,8 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
/**
- * @author shijia.wxr
- * @author xinyuzhou.zxy
+ * @author vintagewang@apache.org
+ * @author yukon@apache.org
*/
public abstract class ServiceThread implements Runnable {
private static final Logger STLOG = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
@@ -37,7 +37,7 @@ public abstract class ServiceThread implements Runnable {
protected volatile boolean stopped = false;
- protected final CountDownLatch waitPoint = new CountDownLatch(1);
+ protected final CountDownLatch2 waitPoint = new CountDownLatch2(1);
public ServiceThread() {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java b/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
index 1aef5e7..9fa8e94 100644
--- a/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
+++ b/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
@@ -20,7 +20,7 @@ import org.apache.rocketmq.common.constant.PermName;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class TopicConfig {
private static final String SEPARATOR = " ";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java b/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java
index 771fcaf..d98a972 100644
--- a/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java
+++ b/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.common;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public enum TopicFilterType {
SINGLE_TAG,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
index 2f9b72e..5ab75b5 100644
--- a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
+++ b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
@@ -37,7 +37,7 @@ import java.util.zip.InflaterInputStream;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class UtilAll {
public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java b/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
index 1405299..2e9d1bb 100644
--- a/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
@@ -26,7 +26,7 @@ import java.util.Map.Entry;
/**
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class ConsumeStats extends RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java b/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
index 00bab0e..218e033 100644
--- a/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
@@ -18,7 +18,7 @@ package org.apache.rocketmq.common.admin;
/**
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class OffsetWrapper {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java b/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
index d1b36a5..fc1e2ce 100644
--- a/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
@@ -18,7 +18,7 @@ package org.apache.rocketmq.common.admin;
/**
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class TopicOffset {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java b/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
index d8f7e0a..db73eb8 100644
--- a/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
@@ -24,7 +24,7 @@ import java.util.HashMap;
/**
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class TopicStatsTable extends RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java b/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java
index 1942dc8..e88a57b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java
+++ b/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.common.constant;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class LoggerName {
public static final String FILTERSRV_LOGGER_NAME = "RocketmqFiltersrv";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java b/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java
index ed379ec..d9a524c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java
+++ b/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.common.constant;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class PermName {
public static final int PERM_PRIORITY = 0x1 << 3;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java b/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java
index db093a0..fc43a81 100644
--- a/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java
+++ b/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java
@@ -18,7 +18,7 @@ package org.apache.rocketmq.common.consumer;
/**
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public enum ConsumeFromWhere {
CONSUME_FROM_LAST_OFFSET,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.java b/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.java
index fac48ea..0396023 100644
--- a/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.java
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.java
@@ -22,7 +22,7 @@ import java.net.URL;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class FilterAPI {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java b/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java
index 85bef76..0118ff8 100644
--- a/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java
+++ b/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.common.help;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class FAQUrl {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/message/Message.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/Message.java b/common/src/main/java/org/apache/rocketmq/common/message/Message.java
index c2d2d85..ac13e36 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/Message.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/Message.java
@@ -24,7 +24,7 @@ import java.util.Map;
/**
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class Message implements Serializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
index 4410171..285e372 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
@@ -33,7 +33,7 @@ import java.util.Map;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MessageDecoder {
public final static int MSG_ID_LENGTH = 8 + 8;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
index db50672..c159ac2 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
@@ -25,7 +25,7 @@ import java.nio.ByteBuffer;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MessageExt extends Message {
private static final long serialVersionUID = 5720810158625748049L;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java
index 95fe2f9..87ad4e6 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java
@@ -20,7 +20,7 @@ import java.net.SocketAddress;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MessageId {
private SocketAddress address;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
index 3c341e6..7850cd3 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
@@ -20,7 +20,7 @@ import java.io.Serializable;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MessageQueue implements Comparable<MessageQueue>, Serializable {
private static final long serialVersionUID = 6191200464116433425L;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
index d71e6b0..0ba82ac 100644
--- a/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
+++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: NamesrvConfig.java 1839 2013-05-16 02:12:02Z shijia.wxr $
+ * $Id: NamesrvConfig.java 1839 2013-05-16 02:12:02Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.namesrv;
@@ -30,7 +30,7 @@ import java.io.File;
/**
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
* @author lansheng.zj
*/
public class NamesrvConfig {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java
index fb854f8..0622d4b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java
+++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java
@@ -18,7 +18,7 @@
package org.apache.rocketmq.common.namesrv;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class NamesrvUtil {
public static final String NAMESPACE_ORDER_TOPIC_CONFIG = "ORDER_TOPIC_CONFIG";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java
index 10c811e..80b8df0 100644
--- a/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java
+++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java
@@ -21,7 +21,7 @@ import org.apache.rocketmq.common.protocol.body.KVTable;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class RegisterBrokerResult {
private String haServerAddr;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
index 5836c05..d5a4d88 100644
--- a/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
+++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: TopAddressing.java 1831 2013-05-16 01:39:51Z shijia.wxr $
+ * $Id: TopAddressing.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.namesrv;
@@ -32,7 +32,7 @@ import java.io.IOException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
* @author manhong.yqd
*/
public class TopAddressing {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java b/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java
index 44e2e4f..4774aea 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.protocol.RemotingCommand;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MQProtosHelper {
public static boolean registerBrokerToNameServer(final String nsaddr, final String brokerAddr,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java
index 461d28c..a7b53d7 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java
@@ -27,7 +27,7 @@ import java.util.Set;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ClusterInfo extends RemotingSerializable {
private HashMap<String/* brokerName */, BrokerData> brokerAddrTable;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java
index ed8d9b4..f504880 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java
@@ -21,7 +21,7 @@ import org.apache.rocketmq.remoting.protocol.LanguageCode;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class Connection {
private String clientId;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java
index e6d2cad..5e33ef7 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java
@@ -22,7 +22,7 @@ import java.util.HashSet;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class ConsumeByWho extends RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java
index 8d1396a..53b4345 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java
@@ -25,7 +25,7 @@ import java.util.Map;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ConsumeStatsList extends RemotingSerializable {
private List<Map<String/*subscriptionGroupName*/, List<ConsumeStats>>> consumeStatsList = new ArrayList<Map<String/*subscriptionGroupName*/, List<ConsumeStats>>>();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java
index fc3ce46..c2dc644 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java
@@ -28,7 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ConsumerConnection extends RemotingSerializable {
private HashSet<Connection> connectionSet = new HashSet<Connection>();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java
index db7e071..0bc526b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java
@@ -22,7 +22,7 @@ import java.util.HashSet;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class GroupList extends RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java
index 09b090b..8ae3371 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java
@@ -22,7 +22,7 @@ import java.util.HashMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class KVTable extends RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java
index 87e4d6a..19fdaa9 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java
@@ -25,7 +25,7 @@ import java.util.Set;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class LockBatchRequestBody extends RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java
index 04a5106..4a7c1a7 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java
@@ -25,7 +25,7 @@ import java.util.Set;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class LockBatchResponseBody extends RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java
index 3d036fc..aa4e29b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java
@@ -23,7 +23,7 @@ import java.util.HashSet;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ProducerConnection extends RemotingSerializable {
private HashSet<Connection> connectionSet = new HashSet<Connection>();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java
index 7cc7b30..e445bb0 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java
@@ -23,7 +23,7 @@ import java.util.Set;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class TopicList extends RemotingSerializable {
private Set<String> topicList = new HashSet<String>();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java
index 66e902c..ae996c2 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java
@@ -25,7 +25,7 @@ import java.util.Set;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class UnlockBatchRequestBody extends RemotingSerializable {
private String consumerGroup;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
index 5a7da65..b2775ad 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: EndTransactionRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: EndTransactionRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class CheckTransactionStateRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
index 4f8864e..9fcec8b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: EndTransactionResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: EndTransactionResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -27,7 +27,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class CheckTransactionStateResponseHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
index 50722f3..28b9f33 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: DeleteTopicRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: DeleteTopicRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java
index 64a60b0..513a40c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java
@@ -24,7 +24,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class ConsumerSendMsgBackRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
index 6eb85b0..e8f4f05 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: CreateTopicRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: CreateTopicRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -27,7 +27,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class CreateTopicRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
index cc0c324..e09146a 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: DeleteTopicRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: DeleteTopicRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class DeleteTopicRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
index ce9f170..e05c1b4 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: EndTransactionRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: EndTransactionRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -28,7 +28,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class EndTransactionRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
index eb28b6a..9f5e45b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: EndTransactionResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: EndTransactionResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -25,7 +25,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class EndTransactionResponseHeader implements CommandCustomHeader {
[17/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/message/MessageConst.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageConst.java b/common/src/main/java/com/alibaba/rocketmq/common/message/MessageConst.java
deleted file mode 100644
index fc06d6e..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageConst.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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.common.message;
-
-import java.util.HashSet;
-
-
-public class MessageConst {
- public static final String PROPERTY_KEYS = "KEYS";
- public static final String PROPERTY_TAGS = "TAGS";
- public static final String PROPERTY_WAIT_STORE_MSG_OK = "WAIT";
- public static final String PROPERTY_DELAY_TIME_LEVEL = "DELAY";
- public static final String PROPERTY_RETRY_TOPIC = "RETRY_TOPIC";
- public static final String PROPERTY_REAL_TOPIC = "REAL_TOPIC";
- public static final String PROPERTY_REAL_QUEUE_ID = "REAL_QID";
- public static final String PROPERTY_TRANSACTION_PREPARED = "TRAN_MSG";
- public static final String PROPERTY_PRODUCER_GROUP = "PGROUP";
- public static final String PROPERTY_MIN_OFFSET = "MIN_OFFSET";
- public static final String PROPERTY_MAX_OFFSET = "MAX_OFFSET";
- public static final String PROPERTY_BUYER_ID = "BUYER_ID";
- public static final String PROPERTY_ORIGIN_MESSAGE_ID = "ORIGIN_MESSAGE_ID";
- public static final String PROPERTY_TRANSFER_FLAG = "TRANSFER_FLAG";
- public static final String PROPERTY_CORRECTION_FLAG = "CORRECTION_FLAG";
- public static final String PROPERTY_MQ2_FLAG = "MQ2_FLAG";
- public static final String PROPERTY_RECONSUME_TIME = "RECONSUME_TIME";
- public static final String PROPERTY_MSG_REGION = "MSG_REGION";
- public static final String PROPERTY_TRACE_SWITCH = "TRACE_ON";
- public static final String PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX = "UNIQ_KEY";
- public static final String PROPERTY_MAX_RECONSUME_TIMES = "MAX_RECONSUME_TIMES";
- public static final String PROPERTY_CONSUME_START_TIMESTAMP = "CONSUME_START_TIME";
-
- public static final String KEY_SEPARATOR = " ";
-
- public static final HashSet<String> STRING_HASH_SET = new HashSet<String>();
-
-
- static {
- STRING_HASH_SET.add(PROPERTY_TRACE_SWITCH);
- STRING_HASH_SET.add(PROPERTY_MSG_REGION);
- STRING_HASH_SET.add(PROPERTY_KEYS);
- STRING_HASH_SET.add(PROPERTY_TAGS);
- STRING_HASH_SET.add(PROPERTY_WAIT_STORE_MSG_OK);
- STRING_HASH_SET.add(PROPERTY_DELAY_TIME_LEVEL);
- STRING_HASH_SET.add(PROPERTY_RETRY_TOPIC);
- STRING_HASH_SET.add(PROPERTY_REAL_TOPIC);
- STRING_HASH_SET.add(PROPERTY_REAL_QUEUE_ID);
- STRING_HASH_SET.add(PROPERTY_TRANSACTION_PREPARED);
- STRING_HASH_SET.add(PROPERTY_PRODUCER_GROUP);
- STRING_HASH_SET.add(PROPERTY_MIN_OFFSET);
- STRING_HASH_SET.add(PROPERTY_MAX_OFFSET);
- STRING_HASH_SET.add(PROPERTY_BUYER_ID);
- STRING_HASH_SET.add(PROPERTY_ORIGIN_MESSAGE_ID);
- STRING_HASH_SET.add(PROPERTY_TRANSFER_FLAG);
- STRING_HASH_SET.add(PROPERTY_CORRECTION_FLAG);
- STRING_HASH_SET.add(PROPERTY_MQ2_FLAG);
- STRING_HASH_SET.add(PROPERTY_RECONSUME_TIME);
- STRING_HASH_SET.add(PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX);
- STRING_HASH_SET.add(PROPERTY_MAX_RECONSUME_TIMES);
- STRING_HASH_SET.add(PROPERTY_CONSUME_START_TIMESTAMP);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/message/MessageDecoder.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageDecoder.java b/common/src/main/java/com/alibaba/rocketmq/common/message/MessageDecoder.java
deleted file mode 100644
index e21c1ca..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageDecoder.java
+++ /dev/null
@@ -1,395 +0,0 @@
-/**
- * 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.common.message;
-
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.sysflag.MessageSysFlag;
-
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.net.UnknownHostException;
-import java.nio.BufferUnderflowException;
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-
-/**
- * @author shijia.wxr
- */
-public class MessageDecoder {
- public final static int MSG_ID_LENGTH = 8 + 8;
-
- public final static Charset CHARSET_UTF8 = Charset.forName("UTF-8");
- public final static int MESSAGE_MAGIC_CODE_POSTION = 4;
- public final static int MESSAGE_FLAG_POSTION = 16;
- public final static int MESSAGE_PHYSIC_OFFSET_POSTION = 28;
- public final static int MESSAGE_STORE_TIMESTAMP_POSTION = 56;
- public final static int MESSAGE_MAGIC_CODE = 0xAABBCCDD ^ 1880681586 + 8;
-
-
- public static String createMessageId(final ByteBuffer input, final ByteBuffer addr, final long offset) {
- input.flip();
- input.limit(MessageDecoder.MSG_ID_LENGTH);
-
- input.put(addr);
- input.putLong(offset);
-
- return UtilAll.bytes2string(input.array());
- }
-
-
- public static String createMessageId(SocketAddress socketAddress, long transactionIdhashCode) {
- ByteBuffer byteBuffer = ByteBuffer.allocate(MessageDecoder.MSG_ID_LENGTH);
- InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
- byteBuffer.put(inetSocketAddress.getAddress().getAddress());
- byteBuffer.putInt(inetSocketAddress.getPort());
- byteBuffer.putLong(transactionIdhashCode);
- byteBuffer.flip();
- return UtilAll.bytes2string(byteBuffer.array());
- }
-
-
- public static MessageId decodeMessageId(final String msgId) throws UnknownHostException {
- SocketAddress address;
- long offset;
-
-
- byte[] ip = UtilAll.string2bytes(msgId.substring(0, 8));
- byte[] port = UtilAll.string2bytes(msgId.substring(8, 16));
- ByteBuffer bb = ByteBuffer.wrap(port);
- int portInt = bb.getInt(0);
- address = new InetSocketAddress(InetAddress.getByAddress(ip), portInt);
-
- // offset
- byte[] data = UtilAll.string2bytes(msgId.substring(16, 32));
- bb = ByteBuffer.wrap(data);
- offset = bb.getLong(0);
-
- return new MessageId(address, offset);
- }
-
-
- public static MessageExt decode(java.nio.ByteBuffer byteBuffer) {
- return decode(byteBuffer, true, true, false);
- }
-
- public static MessageExt clientDecode(java.nio.ByteBuffer byteBuffer, final boolean readBody) {
- return decode(byteBuffer, readBody, true, true);
- }
-
- public static MessageExt decode(java.nio.ByteBuffer byteBuffer, final boolean readBody) {
- return decode(byteBuffer, readBody, true, false);
- }
-
-
- public static byte[] encode(MessageExt messageExt, boolean needCompress) throws Exception {
- byte[] body = messageExt.getBody();
- byte[] topics = messageExt.getTopic().getBytes(CHARSET_UTF8);
- byte topicLen = (byte) topics.length;
- String properties = messageProperties2String(messageExt.getProperties());
- byte[] propertiesBytes = properties.getBytes(CHARSET_UTF8);
- short propertiesLength = (short) propertiesBytes.length;
- int sysFlag = messageExt.getSysFlag();
- byte[] newBody = messageExt.getBody();
- if (needCompress && (sysFlag & MessageSysFlag.COMPRESSED_FLAG) == MessageSysFlag.COMPRESSED_FLAG) {
- newBody = UtilAll.compress(body, 5);
- }
- int bodyLength = newBody.length;
- int storeSize = messageExt.getStoreSize();
- ByteBuffer byteBuffer;
- if (storeSize > 0) {
- byteBuffer = ByteBuffer.allocate(storeSize);
- } else {
- storeSize = 4 // 1 TOTALSIZE
- + 4 // 2 MAGICCODE
- + 4 // 3 BODYCRC
- + 4 // 4 QUEUEID
- + 4 // 5 FLAG
- + 8 // 6 QUEUEOFFSET
- + 8 // 7 PHYSICALOFFSET
- + 4 // 8 SYSFLAG
- + 8 // 9 BORNTIMESTAMP
- + 8 // 10 BORNHOST
- + 8 // 11 STORETIMESTAMP
- + 8 // 12 STOREHOSTADDRESS
- + 4 // 13 RECONSUMETIMES
- + 8 // 14 Prepared Transaction Offset
- + 4 + bodyLength // 14 BODY
- + 1 + topicLen // 15 TOPIC
- + 2 + propertiesLength // 16 propertiesLength
- + 0;
- byteBuffer = ByteBuffer.allocate(storeSize);
- }
- // 1 TOTALSIZE
- byteBuffer.putInt(storeSize);
-
- // 2 MAGICCODE
- byteBuffer.putInt(MESSAGE_MAGIC_CODE);
-
- // 3 BODYCRC
- int bodyCRC = messageExt.getBodyCRC();
- byteBuffer.putInt(bodyCRC);
-
- // 4 QUEUEID
- int queueId = messageExt.getQueueId();
- byteBuffer.putInt(queueId);
-
- // 5 FLAG
- int flag = messageExt.getFlag();
- byteBuffer.putInt(flag);
-
- // 6 QUEUEOFFSET
- long queueOffset = messageExt.getQueueOffset();
- byteBuffer.putLong(queueOffset);
-
- // 7 PHYSICALOFFSET
- long physicOffset = messageExt.getCommitLogOffset();
- byteBuffer.putLong(physicOffset);
-
- // 8 SYSFLAG
- byteBuffer.putInt(sysFlag);
-
- // 9 BORNTIMESTAMP
- long bornTimeStamp = messageExt.getBornTimestamp();
- byteBuffer.putLong(bornTimeStamp);
-
- // 10 BORNHOST
- InetSocketAddress bornHost = (InetSocketAddress) messageExt.getBornHost();
- byteBuffer.put(bornHost.getAddress().getAddress());
- byteBuffer.putInt(bornHost.getPort());
-
- // 11 STORETIMESTAMP
- long storeTimestamp = messageExt.getStoreTimestamp();
- byteBuffer.putLong(storeTimestamp);
-
- // 12 STOREHOST
- InetSocketAddress serverHost = (InetSocketAddress) messageExt.getStoreHost();
- byteBuffer.put(serverHost.getAddress().getAddress());
- byteBuffer.putInt(serverHost.getPort());
-
- // 13 RECONSUMETIMES
- int reconsumeTimes = messageExt.getReconsumeTimes();
- byteBuffer.putInt(reconsumeTimes);
-
- // 14 Prepared Transaction Offset
- long preparedTransactionOffset = messageExt.getPreparedTransactionOffset();
- byteBuffer.putLong(preparedTransactionOffset);
-
- // 15 BODY
- byteBuffer.putInt(bodyLength);
- byteBuffer.put(newBody);
-
- // 16 TOPIC
- byteBuffer.put(topicLen);
- byteBuffer.put(topics);
-
- // 17 properties
- byteBuffer.putShort(propertiesLength);
- byteBuffer.put(propertiesBytes);
-
- return byteBuffer.array();
- }
-
- public static MessageExt decode(
- java.nio.ByteBuffer byteBuffer, final boolean readBody, final boolean deCompressBody) {
- return decode(byteBuffer, readBody, deCompressBody, false);
- }
-
- public static MessageExt decode(
- java.nio.ByteBuffer byteBuffer, final boolean readBody, final boolean deCompressBody, final boolean isClient) {
- try {
-
- MessageExt msgExt;
- if (isClient) {
- msgExt = new MessageClientExt();
- } else {
- msgExt = new MessageExt();
- }
-
- // 1 TOTALSIZE
- int storeSize = byteBuffer.getInt();
- msgExt.setStoreSize(storeSize);
-
- // 2 MAGICCODE
- byteBuffer.getInt();
-
- // 3 BODYCRC
- int bodyCRC = byteBuffer.getInt();
- msgExt.setBodyCRC(bodyCRC);
-
- // 4 QUEUEID
- int queueId = byteBuffer.getInt();
- msgExt.setQueueId(queueId);
-
- // 5 FLAG
- int flag = byteBuffer.getInt();
- msgExt.setFlag(flag);
-
- // 6 QUEUEOFFSET
- long queueOffset = byteBuffer.getLong();
- msgExt.setQueueOffset(queueOffset);
-
- // 7 PHYSICALOFFSET
- long physicOffset = byteBuffer.getLong();
- msgExt.setCommitLogOffset(physicOffset);
-
- // 8 SYSFLAG
- int sysFlag = byteBuffer.getInt();
- msgExt.setSysFlag(sysFlag);
-
- // 9 BORNTIMESTAMP
- long bornTimeStamp = byteBuffer.getLong();
- msgExt.setBornTimestamp(bornTimeStamp);
-
- // 10 BORNHOST
- byte[] bornHost = new byte[4];
- byteBuffer.get(bornHost, 0, 4);
- int port = byteBuffer.getInt();
- msgExt.setBornHost(new InetSocketAddress(InetAddress.getByAddress(bornHost), port));
-
- // 11 STORETIMESTAMP
- long storeTimestamp = byteBuffer.getLong();
- msgExt.setStoreTimestamp(storeTimestamp);
-
- // 12 STOREHOST
- byte[] storeHost = new byte[4];
- byteBuffer.get(storeHost, 0, 4);
- port = byteBuffer.getInt();
- msgExt.setStoreHost(new InetSocketAddress(InetAddress.getByAddress(storeHost), port));
-
- // 13 RECONSUMETIMES
- int reconsumeTimes = byteBuffer.getInt();
- msgExt.setReconsumeTimes(reconsumeTimes);
-
- // 14 Prepared Transaction Offset
- long preparedTransactionOffset = byteBuffer.getLong();
- msgExt.setPreparedTransactionOffset(preparedTransactionOffset);
-
- // 15 BODY
- int bodyLen = byteBuffer.getInt();
- if (bodyLen > 0) {
- if (readBody) {
- byte[] body = new byte[bodyLen];
- byteBuffer.get(body);
-
- // uncompress body
- if (deCompressBody && (sysFlag & MessageSysFlag.COMPRESSED_FLAG) == MessageSysFlag.COMPRESSED_FLAG) {
- body = UtilAll.uncompress(body);
- }
-
- msgExt.setBody(body);
- } else {
- byteBuffer.position(byteBuffer.position() + bodyLen);
- }
- }
-
- // 16 TOPIC
- byte topicLen = byteBuffer.get();
- byte[] topic = new byte[(int) topicLen];
- byteBuffer.get(topic);
- msgExt.setTopic(new String(topic, CHARSET_UTF8));
-
- // 17 properties
- short propertiesLength = byteBuffer.getShort();
- if (propertiesLength > 0) {
- byte[] properties = new byte[propertiesLength];
- byteBuffer.get(properties);
- String propertiesString = new String(properties, CHARSET_UTF8);
- Map<String, String> map = string2messageProperties(propertiesString);
- msgExt.setProperties(map);
- }
-
- ByteBuffer byteBufferMsgId = ByteBuffer.allocate(MSG_ID_LENGTH);
- String msgId = createMessageId(byteBufferMsgId, msgExt.getStoreHostBytes(), msgExt.getCommitLogOffset());
- msgExt.setMsgId(msgId);
-
- if (isClient) {
- ((MessageClientExt) msgExt).setOffsetMsgId(msgId);
- }
-
- return msgExt;
- } catch (UnknownHostException e) {
- byteBuffer.position(byteBuffer.limit());
- } catch (BufferUnderflowException e) {
- byteBuffer.position(byteBuffer.limit());
- } catch (Exception e) {
- byteBuffer.position(byteBuffer.limit());
- }
-
- return null;
- }
-
-
- public static List<MessageExt> decodes(java.nio.ByteBuffer byteBuffer) {
- return decodes(byteBuffer, true);
- }
-
- public static List<MessageExt> decodes(java.nio.ByteBuffer byteBuffer, final boolean readBody) {
- List<MessageExt> msgExts = new ArrayList<MessageExt>();
- while (byteBuffer.hasRemaining()) {
- MessageExt msgExt = clientDecode(byteBuffer, readBody);
- if (null != msgExt) {
- msgExts.add(msgExt);
- } else {
- break;
- }
- }
- return msgExts;
- }
-
- public static final char NAME_VALUE_SEPARATOR = 1;
- public static final char PROPERTY_SEPARATOR = 2;
-
-
- public static String messageProperties2String(Map<String, String> properties) {
- StringBuilder sb = new StringBuilder();
- if (properties != null) {
- for (final Map.Entry<String, String> entry : properties.entrySet()) {
- final String name = entry.getKey();
- final String value = entry.getValue();
-
- sb.append(name);
- sb.append(NAME_VALUE_SEPARATOR);
- sb.append(value);
- sb.append(PROPERTY_SEPARATOR);
- }
- }
- return sb.toString();
- }
-
- public static Map<String, String> string2messageProperties(final String properties) {
- Map<String, String> map = new HashMap<String, String>();
- if (properties != null) {
- String[] items = properties.split(String.valueOf(PROPERTY_SEPARATOR));
- if (items != null) {
- for (String i : items) {
- String[] nv = i.split(String.valueOf(NAME_VALUE_SEPARATOR));
- if (nv != null && 2 == nv.length) {
- map.put(nv[0], nv[1]);
- }
- }
- }
- }
-
- return map;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/message/MessageExt.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageExt.java b/common/src/main/java/com/alibaba/rocketmq/common/message/MessageExt.java
deleted file mode 100644
index 627935d..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageExt.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/**
- * 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.common.message;
-
-import com.alibaba.rocketmq.common.TopicFilterType;
-import com.alibaba.rocketmq.common.sysflag.MessageSysFlag;
-
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.nio.ByteBuffer;
-
-
-/**
- * @author shijia.wxr
- */
-public class MessageExt extends Message {
- private static final long serialVersionUID = 5720810158625748049L;
-
- private int queueId;
-
- private int storeSize;
-
- private long queueOffset;
- private int sysFlag;
- private long bornTimestamp;
- private SocketAddress bornHost;
-
- private long storeTimestamp;
- private SocketAddress storeHost;
- private String msgId;
- private long commitLogOffset;
- private int bodyCRC;
- private int reconsumeTimes;
-
- private long preparedTransactionOffset;
-
-
- public MessageExt() {
- }
-
-
- public MessageExt(int queueId, long bornTimestamp, SocketAddress bornHost, long storeTimestamp,
- SocketAddress storeHost, String msgId) {
- this.queueId = queueId;
- this.bornTimestamp = bornTimestamp;
- this.bornHost = bornHost;
- this.storeTimestamp = storeTimestamp;
- this.storeHost = storeHost;
- this.msgId = msgId;
- }
-
- public static TopicFilterType parseTopicFilterType(final int sysFlag) {
- if ((sysFlag & MessageSysFlag.MULTI_TAGS_FLAG) == MessageSysFlag.MULTI_TAGS_FLAG) {
- return TopicFilterType.MULTI_TAG;
- }
-
- return TopicFilterType.SINGLE_TAG;
- }
-
- public ByteBuffer getBornHostBytes() {
- return socketAddress2ByteBuffer(this.bornHost);
- }
-
- public ByteBuffer getBornHostBytes(ByteBuffer byteBuffer) {
- return socketAddress2ByteBuffer(this.bornHost, byteBuffer);
- }
-
- private static ByteBuffer socketAddress2ByteBuffer(final SocketAddress socketAddress, final ByteBuffer byteBuffer) {
- InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
- byteBuffer.put(inetSocketAddress.getAddress().getAddress(), 0, 4);
- byteBuffer.putInt(inetSocketAddress.getPort());
- byteBuffer.flip();
- return byteBuffer;
- }
-
- public static ByteBuffer socketAddress2ByteBuffer(SocketAddress socketAddress) {
- ByteBuffer byteBuffer = ByteBuffer.allocate(8);
- return socketAddress2ByteBuffer(socketAddress, byteBuffer);
- }
-
- public ByteBuffer getStoreHostBytes() {
- return socketAddress2ByteBuffer(this.storeHost);
- }
-
- public ByteBuffer getStoreHostBytes(ByteBuffer byteBuffer) {
- return socketAddress2ByteBuffer(this.storeHost, byteBuffer);
- }
-
- public int getQueueId() {
- return queueId;
- }
-
- public void setQueueId(int queueId) {
- this.queueId = queueId;
- }
-
- public long getBornTimestamp() {
- return bornTimestamp;
- }
-
- public void setBornTimestamp(long bornTimestamp) {
- this.bornTimestamp = bornTimestamp;
- }
-
- public SocketAddress getBornHost() {
- return bornHost;
- }
-
- public void setBornHost(SocketAddress bornHost) {
- this.bornHost = bornHost;
- }
-
- public String getBornHostString() {
- if (this.bornHost != null) {
- InetSocketAddress inetSocketAddress = (InetSocketAddress) this.bornHost;
- return inetSocketAddress.getAddress().getHostAddress();
- }
-
- return null;
- }
-
- public String getBornHostNameString() {
- if (this.bornHost != null) {
- InetSocketAddress inetSocketAddress = (InetSocketAddress) this.bornHost;
- return inetSocketAddress.getAddress().getHostName();
- }
-
- return null;
- }
-
- public long getStoreTimestamp() {
- return storeTimestamp;
- }
-
- public void setStoreTimestamp(long storeTimestamp) {
- this.storeTimestamp = storeTimestamp;
- }
-
- public SocketAddress getStoreHost() {
- return storeHost;
- }
-
- public void setStoreHost(SocketAddress storeHost) {
- this.storeHost = storeHost;
- }
-
- public String getMsgId() {
- return msgId;
- }
-
- public void setMsgId(String msgId) {
- this.msgId = msgId;
- }
-
- public int getSysFlag() {
- return sysFlag;
- }
-
- public void setSysFlag(int sysFlag) {
- this.sysFlag = sysFlag;
- }
-
- public int getBodyCRC() {
- return bodyCRC;
- }
-
- public void setBodyCRC(int bodyCRC) {
- this.bodyCRC = bodyCRC;
- }
-
- public long getQueueOffset() {
- return queueOffset;
- }
-
- public void setQueueOffset(long queueOffset) {
- this.queueOffset = queueOffset;
- }
-
- public long getCommitLogOffset() {
- return commitLogOffset;
- }
-
- public void setCommitLogOffset(long physicOffset) {
- this.commitLogOffset = physicOffset;
- }
-
- public int getStoreSize() {
- return storeSize;
- }
-
- public void setStoreSize(int storeSize) {
- this.storeSize = storeSize;
- }
-
- public int getReconsumeTimes() {
- return reconsumeTimes;
- }
-
-
- public void setReconsumeTimes(int reconsumeTimes) {
- this.reconsumeTimes = reconsumeTimes;
- }
-
-
- public long getPreparedTransactionOffset() {
- return preparedTransactionOffset;
- }
-
-
- public void setPreparedTransactionOffset(long preparedTransactionOffset) {
- this.preparedTransactionOffset = preparedTransactionOffset;
- }
-
-
- @Override
- public String toString() {
- return "MessageExt [queueId=" + queueId + ", storeSize=" + storeSize + ", queueOffset=" + queueOffset
- + ", sysFlag=" + sysFlag + ", bornTimestamp=" + bornTimestamp + ", bornHost=" + bornHost
- + ", storeTimestamp=" + storeTimestamp + ", storeHost=" + storeHost + ", msgId=" + msgId
- + ", commitLogOffset=" + commitLogOffset + ", bodyCRC=" + bodyCRC + ", reconsumeTimes="
- + reconsumeTimes + ", preparedTransactionOffset=" + preparedTransactionOffset
- + ", toString()=" + super.toString() + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/message/MessageId.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageId.java b/common/src/main/java/com/alibaba/rocketmq/common/message/MessageId.java
deleted file mode 100644
index d08be86..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageId.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * 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.common.message;
-
-import java.net.SocketAddress;
-
-
-/**
- * @author shijia.wxr
- */
-public class MessageId {
- private SocketAddress address;
- private long offset;
-
-
- public MessageId(SocketAddress address, long offset) {
- this.address = address;
- this.offset = offset;
- }
-
-
- public SocketAddress getAddress() {
- return address;
- }
-
-
- public void setAddress(SocketAddress address) {
- this.address = address;
- }
-
-
- public long getOffset() {
- return offset;
- }
-
-
- public void setOffset(long offset) {
- this.offset = offset;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/message/MessageQueue.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageQueue.java b/common/src/main/java/com/alibaba/rocketmq/common/message/MessageQueue.java
deleted file mode 100644
index 35d2827..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageQueue.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- * 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.common.message;
-
-import java.io.Serializable;
-
-
-/**
- * @author shijia.wxr
- */
-public class MessageQueue implements Comparable<MessageQueue>, Serializable {
- private static final long serialVersionUID = 6191200464116433425L;
- private String topic;
- private String brokerName;
- private int queueId;
-
-
- public MessageQueue() {
-
- }
-
-
- public MessageQueue(String topic, String brokerName, int queueId) {
- this.topic = topic;
- this.brokerName = brokerName;
- this.queueId = queueId;
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public String getBrokerName() {
- return brokerName;
- }
-
-
- public void setBrokerName(String brokerName) {
- this.brokerName = brokerName;
- }
-
-
- public int getQueueId() {
- return queueId;
- }
-
-
- public void setQueueId(int queueId) {
- this.queueId = queueId;
- }
-
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((brokerName == null) ? 0 : brokerName.hashCode());
- result = prime * result + queueId;
- result = prime * result + ((topic == null) ? 0 : topic.hashCode());
- return result;
- }
-
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- MessageQueue other = (MessageQueue) obj;
- if (brokerName == null) {
- if (other.brokerName != null)
- return false;
- } else if (!brokerName.equals(other.brokerName))
- return false;
- if (queueId != other.queueId)
- return false;
- if (topic == null) {
- if (other.topic != null)
- return false;
- } else if (!topic.equals(other.topic))
- return false;
- return true;
- }
-
-
- @Override
- public String toString() {
- return "MessageQueue [topic=" + topic + ", brokerName=" + brokerName + ", queueId=" + queueId + "]";
- }
-
-
- @Override
- public int compareTo(MessageQueue o) {
- {
- int result = this.topic.compareTo(o.topic);
- if (result != 0) {
- return result;
- }
- }
-
- {
- int result = this.brokerName.compareTo(o.brokerName);
- if (result != 0) {
- return result;
- }
- }
-
- return this.queueId - o.queueId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/message/MessageQueueForC.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageQueueForC.java b/common/src/main/java/com/alibaba/rocketmq/common/message/MessageQueueForC.java
deleted file mode 100644
index a905af6..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageQueueForC.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/**
- * 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.common.message;
-
-import java.io.Serializable;
-
-
-/**
- * @author lansheng.zj
- */
-public class MessageQueueForC implements Comparable<MessageQueueForC>, Serializable {
-
- private static final long serialVersionUID = 5320967846569962104L;
- private String topic;
- private String brokerName;
- private int queueId;
- private long offset;
-
-
- public MessageQueueForC(String topic, String brokerName, int queueId, long offset) {
- this.topic = topic;
- this.brokerName = brokerName;
- this.queueId = queueId;
- this.offset = offset;
- }
-
-
- @Override
- public int compareTo(MessageQueueForC o) {
- int result = this.topic.compareTo(o.topic);
- if (result != 0) {
- return result;
- }
- result = this.brokerName.compareTo(o.brokerName);
- if (result != 0) {
- return result;
- }
- result = this.queueId - o.queueId;
- if (result != 0) {
- return result;
- }
- if ((this.offset - o.offset) > 0) {
- return 1;
- } else if ((this.offset - o.offset) == 0) {
- return 0;
- } else {
- return -1;
- }
- }
-
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((brokerName == null) ? 0 : brokerName.hashCode());
- result = prime * result + queueId;
- result = prime * result + ((topic == null) ? 0 : topic.hashCode());
- return result;
- }
-
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- MessageQueueForC other = (MessageQueueForC) obj;
- if (brokerName == null) {
- if (other.brokerName != null)
- return false;
- } else if (!brokerName.equals(other.brokerName))
- return false;
- if (queueId != other.queueId)
- return false;
- if (topic == null) {
- if (other.topic != null)
- return false;
- } else if (!topic.equals(other.topic))
- return false;
-
- if (offset != other.offset) {
- return false;
- }
- return true;
- }
-
-
- @Override
- public String toString() {
- return "MessageQueueForC [topic=" + topic + ", brokerName=" + brokerName + ", queueId=" + queueId
- + ", offset=" + offset + "]";
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public String getBrokerName() {
- return brokerName;
- }
-
-
- public void setBrokerName(String brokerName) {
- this.brokerName = brokerName;
- }
-
-
- public int getQueueId() {
- return queueId;
- }
-
-
- public void setQueueId(int queueId) {
- this.queueId = queueId;
- }
-
-
- public long getOffset() {
- return offset;
- }
-
-
- public void setOffset(long offset) {
- this.offset = offset;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/message/MessageType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageType.java b/common/src/main/java/com/alibaba/rocketmq/common/message/MessageType.java
deleted file mode 100644
index 164eb87..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageType.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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.common.message;
-
-public enum MessageType {
- Normal_Msg,
- Trans_Msg_Half,
- Trans_msg_Commit,
- Delay_Msg,
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/namesrv/NamesrvConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/namesrv/NamesrvConfig.java b/common/src/main/java/com/alibaba/rocketmq/common/namesrv/NamesrvConfig.java
deleted file mode 100644
index 08db357..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/namesrv/NamesrvConfig.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: NamesrvConfig.java 1839 2013-05-16 02:12:02Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.namesrv;
-
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-
-
-/**
- *
- * @author shijia.wxr
- * @author lansheng.zj
- */
-public class NamesrvConfig {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
- private String rocketmqHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV));
-
- private String kvConfigPath = System.getProperty("user.home") + File.separator + "namesrv" + File.separator + "kvConfig.json";
- private String configStorePath = System.getProperty("user.home") + File.separator + "namesrv" + File.separator + "namesrv.properties";
- private String productEnvName = "center";
- private boolean clusterTest = false;
- private boolean orderMessageEnable = false;
-
- public boolean isOrderMessageEnable() {
- return orderMessageEnable;
- }
-
- public void setOrderMessageEnable(boolean orderMessageEnable) {
- this.orderMessageEnable = orderMessageEnable;
- }
-
- public String getRocketmqHome() {
- return rocketmqHome;
- }
-
-
- public void setRocketmqHome(String rocketmqHome) {
- this.rocketmqHome = rocketmqHome;
- }
-
-
- public String getKvConfigPath() {
- return kvConfigPath;
- }
-
-
- public void setKvConfigPath(String kvConfigPath) {
- this.kvConfigPath = kvConfigPath;
- }
-
-
- public String getProductEnvName() {
- return productEnvName;
- }
-
-
- public void setProductEnvName(String productEnvName) {
- this.productEnvName = productEnvName;
- }
-
-
- public boolean isClusterTest() {
- return clusterTest;
- }
-
-
- public void setClusterTest(boolean clusterTest) {
- this.clusterTest = clusterTest;
- }
-
- public String getConfigStorePath() {
- return configStorePath;
- }
-
- public void setConfigStorePath(final String configStorePath) {
- this.configStorePath = configStorePath;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/namesrv/NamesrvUtil.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/namesrv/NamesrvUtil.java b/common/src/main/java/com/alibaba/rocketmq/common/namesrv/NamesrvUtil.java
deleted file mode 100644
index fcc32d9..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/namesrv/NamesrvUtil.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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.common.namesrv;
-
-/**
- * @author shijia.wxr
- */
-public class NamesrvUtil {
- public static final String NAMESPACE_ORDER_TOPIC_CONFIG = "ORDER_TOPIC_CONFIG";
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/namesrv/RegisterBrokerResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/namesrv/RegisterBrokerResult.java b/common/src/main/java/com/alibaba/rocketmq/common/namesrv/RegisterBrokerResult.java
deleted file mode 100644
index 68bf44a..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/namesrv/RegisterBrokerResult.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * 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.common.namesrv;
-
-import com.alibaba.rocketmq.common.protocol.body.KVTable;
-
-
-/**
- * @author shijia.wxr
- */
-public class RegisterBrokerResult {
- private String haServerAddr;
- private String masterAddr;
- private KVTable kvTable;
-
-
- public String getHaServerAddr() {
- return haServerAddr;
- }
-
-
- public void setHaServerAddr(String haServerAddr) {
- this.haServerAddr = haServerAddr;
- }
-
-
- public String getMasterAddr() {
- return masterAddr;
- }
-
-
- public void setMasterAddr(String masterAddr) {
- this.masterAddr = masterAddr;
- }
-
-
- public KVTable getKvTable() {
- return kvTable;
- }
-
-
- public void setKvTable(KVTable kvTable) {
- this.kvTable = kvTable;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/namesrv/TopAddressing.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/namesrv/TopAddressing.java b/common/src/main/java/com/alibaba/rocketmq/common/namesrv/TopAddressing.java
deleted file mode 100644
index 2e4ad87..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/namesrv/TopAddressing.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: TopAddressing.java 1831 2013-05-16 01:39:51Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.namesrv;
-
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.help.FAQUrl;
-import com.alibaba.rocketmq.common.utils.HttpTinyClient;
-import com.alibaba.rocketmq.common.utils.HttpTinyClient.HttpResult;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-
-
-/**
- * @author shijia.wxr
- * @author manhong.yqd
- */
-public class TopAddressing {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
- private String nsAddr;
- private String wsAddr;
- private String unitName;
-
-
- public TopAddressing(final String wsAddr) {
- this(wsAddr, null);
- }
-
-
- public TopAddressing(final String wsAddr, final String unitName) {
- this.wsAddr = wsAddr;
- this.unitName = unitName;
- }
-
- public final String fetchNSAddr() {
- return fetchNSAddr(true, 3000);
- }
-
- public final String fetchNSAddr(boolean verbose, long timeoutMills) {
- String url = this.wsAddr;
- try {
- if (!UtilAll.isBlank(this.unitName)) {
- url = url + "-" + this.unitName + "?nofix=1";
- }
- HttpResult result = HttpTinyClient.httpGet(url, null, null, "UTF-8", timeoutMills);
- if (200 == result.code) {
- String responseStr = result.content;
- if (responseStr != null) {
- return clearNewLine(responseStr);
- } else {
- log.error("fetch nameserver address is null");
- }
- } else {
- log.error("fetch nameserver address failed. statusCode={}", result.code);
- }
- } catch (IOException e) {
- if (verbose) {
- log.error("fetch name server address exception", e);
- }
- }
-
- if (verbose) {
- String errorMsg =
- "connect to " + url + " failed, maybe the domain name " + MixAll.WS_DOMAIN_NAME + " not bind in /etc/hosts";
- errorMsg += FAQUrl.suggestTodo(FAQUrl.NAME_SERVER_ADDR_NOT_EXIST_URL);
-
- log.warn(errorMsg);
- }
- return null;
- }
-
- private static String clearNewLine(final String str) {
- String newString = str.trim();
- int index = newString.indexOf("\r");
- if (index != -1) {
- return newString.substring(0, index);
- }
-
- index = newString.indexOf("\n");
- if (index != -1) {
- return newString.substring(0, index);
- }
-
- return newString;
- }
-
- public String getNsAddr() {
- return nsAddr;
- }
-
-
- public void setNsAddr(String nsAddr) {
- this.nsAddr = nsAddr;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/MQProtosHelper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/MQProtosHelper.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/MQProtosHelper.java
deleted file mode 100644
index aaaa51d..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/MQProtosHelper.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * 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.common.protocol;
-
-import com.alibaba.rocketmq.common.protocol.header.namesrv.RegisterBrokerRequestHeader;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import com.alibaba.rocketmq.remoting.exception.RemotingConnectException;
-import com.alibaba.rocketmq.remoting.exception.RemotingSendRequestException;
-import com.alibaba.rocketmq.remoting.exception.RemotingTimeoutException;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-
-
-/**
- * @author shijia.wxr
- */
-public class MQProtosHelper {
- public static boolean registerBrokerToNameServer(final String nsaddr, final String brokerAddr,
- final long timeoutMillis) {
- RegisterBrokerRequestHeader requestHeader = new RegisterBrokerRequestHeader();
- requestHeader.setBrokerAddr(brokerAddr);
-
- RemotingCommand request =
- RemotingCommand.createRequestCommand(RequestCode.REGISTER_BROKER, requestHeader);
-
- try {
- RemotingCommand response = RemotingHelper.invokeSync(nsaddr, request, timeoutMillis);
- if (response != null) {
- return ResponseCode.SUCCESS == response.getCode();
- }
- } catch (RemotingConnectException e) {
- e.printStackTrace();
- } catch (RemotingSendRequestException e) {
- e.printStackTrace();
- } catch (RemotingTimeoutException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/RequestCode.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/RequestCode.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/RequestCode.java
deleted file mode 100644
index a8b8698..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/RequestCode.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/**
- * 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.common.protocol;
-
-public class RequestCode {
-
- public static final int SEND_MESSAGE = 10;
-
- public static final int PULL_MESSAGE = 11;
-
- public static final int QUERY_MESSAGE = 12;
- public static final int QUERY_BROKER_OFFSET = 13;
- public static final int QUERY_CONSUMER_OFFSET = 14;
- public static final int UPDATE_CONSUMER_OFFSET = 15;
- public static final int UPDATE_AND_CREATE_TOPIC = 17;
- public static final int GET_ALL_TOPIC_CONFIG = 21;
- public static final int GET_TOPIC_CONFIG_LIST = 22;
-
- public static final int GET_TOPIC_NAME_LIST = 23;
-
- public static final int UPDATE_BROKER_CONFIG = 25;
-
- public static final int GET_BROKER_CONFIG = 26;
-
- public static final int TRIGGER_DELETE_FILES = 27;
-
- public static final int GET_BROKER_RUNTIME_INFO = 28;
- public static final int SEARCH_OFFSET_BY_TIMESTAMP = 29;
- public static final int GET_MAX_OFFSET = 30;
- public static final int GET_MIN_OFFSET = 31;
-
- public static final int GET_EARLIEST_MSG_STORETIME = 32;
-
- public static final int VIEW_MESSAGE_BY_ID = 33;
-
- public static final int HEART_BEAT = 34;
-
- public static final int UNREGISTER_CLIENT = 35;
-
- public static final int CONSUMER_SEND_MSG_BACK = 36;
-
- public static final int END_TRANSACTION = 37;
- public static final int GET_CONSUMER_LIST_BY_GROUP = 38;
-
- public static final int CHECK_TRANSACTION_STATE = 39;
-
- public static final int NOTIFY_CONSUMER_IDS_CHANGED = 40;
-
- public static final int LOCK_BATCH_MQ = 41;
-
- public static final int UNLOCK_BATCH_MQ = 42;
- public static final int GET_ALL_CONSUMER_OFFSET = 43;
-
- public static final int GET_ALL_DELAY_OFFSET = 45;
-
- public static final int PUT_KV_CONFIG = 100;
-
- public static final int GET_KV_CONFIG = 101;
-
- public static final int DELETE_KV_CONFIG = 102;
-
- public static final int REGISTER_BROKER = 103;
-
- public static final int UNREGISTER_BROKER = 104;
- public static final int GET_ROUTEINTO_BY_TOPIC = 105;
-
- public static final int GET_BROKER_CLUSTER_INFO = 106;
- public static final int UPDATE_AND_CREATE_SUBSCRIPTIONGROUP = 200;
- public static final int GET_ALL_SUBSCRIPTIONGROUP_CONFIG = 201;
- public static final int GET_TOPIC_STATS_INFO = 202;
- public static final int GET_CONSUMER_CONNECTION_LIST = 203;
- public static final int GET_PRODUCER_CONNECTION_LIST = 204;
- public static final int WIPE_WRITE_PERM_OF_BROKER = 205;
-
-
- public static final int GET_ALL_TOPIC_LIST_FROM_NAMESERVER = 206;
-
- public static final int DELETE_SUBSCRIPTIONGROUP = 207;
- public static final int GET_CONSUME_STATS = 208;
-
- public static final int SUSPEND_CONSUMER = 209;
-
- public static final int RESUME_CONSUMER = 210;
- public static final int RESET_CONSUMER_OFFSET_IN_CONSUMER = 211;
- public static final int RESET_CONSUMER_OFFSET_IN_BROKER = 212;
-
- public static final int ADJUST_CONSUMER_THREAD_POOL = 213;
-
- public static final int WHO_CONSUME_THE_MESSAGE = 214;
-
-
- public static final int DELETE_TOPIC_IN_BROKER = 215;
-
- public static final int DELETE_TOPIC_IN_NAMESRV = 216;
- public static final int GET_KVLIST_BY_NAMESPACE = 219;
-
-
- public static final int RESET_CONSUMER_CLIENT_OFFSET = 220;
-
- public static final int GET_CONSUMER_STATUS_FROM_CLIENT = 221;
-
- public static final int INVOKE_BROKER_TO_RESET_OFFSET = 222;
-
- public static final int INVOKE_BROKER_TO_GET_CONSUMER_STATUS = 223;
-
-
- public static final int QUERY_TOPIC_CONSUME_BY_WHO = 300;
-
- public static final int GET_TOPICS_BY_CLUSTER = 224;
-
- public static final int REGISTER_FILTER_SERVER = 301;
- public static final int REGISTER_MESSAGE_FILTER_CLASS = 302;
-
- public static final int QUERY_CONSUME_TIME_SPAN = 303;
-
- public static final int GET_SYSTEM_TOPIC_LIST_FROM_NS = 304;
- public static final int GET_SYSTEM_TOPIC_LIST_FROM_BROKER = 305;
-
- public static final int CLEAN_EXPIRED_CONSUMEQUEUE = 306;
-
- public static final int GET_CONSUMER_RUNNING_INFO = 307;
-
- public static final int QUERY_CORRECTION_OFFSET = 308;
- public static final int CONSUME_MESSAGE_DIRECTLY = 309;
-
- public static final int SEND_MESSAGE_V2 = 310;
-
- public static final int GET_UNIT_TOPIC_LIST = 311;
-
- public static final int GET_HAS_UNIT_SUB_TOPIC_LIST = 312;
-
- public static final int GET_HAS_UNIT_SUB_UNUNIT_TOPIC_LIST = 313;
-
- public static final int CLONE_GROUP_OFFSET = 314;
-
- public static final int VIEW_BROKER_STATS_DATA = 315;
-
- public static final int CLEAN_UNUSED_TOPIC = 316;
-
- public static final int GET_BROKER_CONSUME_STATS = 317;
-
- /**
- * update the config of name server
- */
- public static final int UPDATE_NAMESRV_CONFIG = 318;
-
- /**
- * get config from name server
- */
- public static final int GET_NAMESRV_CONFIG = 319;
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/ResponseCode.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/ResponseCode.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/ResponseCode.java
deleted file mode 100644
index 3c01fad..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/ResponseCode.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * 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.common.protocol;
-
-import com.alibaba.rocketmq.remoting.protocol.RemotingSysResponseCode;
-
-
-public class ResponseCode extends RemotingSysResponseCode {
-
- public static final int FLUSH_DISK_TIMEOUT = 10;
-
- public static final int SLAVE_NOT_AVAILABLE = 11;
-
- public static final int FLUSH_SLAVE_TIMEOUT = 12;
-
- public static final int MESSAGE_ILLEGAL = 13;
-
- public static final int SERVICE_NOT_AVAILABLE = 14;
-
- public static final int VERSION_NOT_SUPPORTED = 15;
-
- public static final int NO_PERMISSION = 16;
-
- public static final int TOPIC_NOT_EXIST = 17;
- public static final int TOPIC_EXIST_ALREADY = 18;
- public static final int PULL_NOT_FOUND = 19;
-
- public static final int PULL_RETRY_IMMEDIATELY = 20;
-
- public static final int PULL_OFFSET_MOVED = 21;
-
- public static final int QUERY_NOT_FOUND = 22;
-
- public static final int SUBSCRIPTION_PARSE_FAILED = 23;
-
- public static final int SUBSCRIPTION_NOT_EXIST = 24;
-
- public static final int SUBSCRIPTION_NOT_LATEST = 25;
-
- public static final int SUBSCRIPTION_GROUP_NOT_EXIST = 26;
-
- public static final int TRANSACTION_SHOULD_COMMIT = 200;
-
- public static final int TRANSACTION_SHOULD_ROLLBACK = 201;
-
- public static final int TRANSACTION_STATE_UNKNOW = 202;
-
- public static final int TRANSACTION_STATE_GROUP_WRONG = 203;
- public static final int NO_BUYER_ID = 204;
-
-
- public static final int NOT_IN_CURRENT_UNIT = 205;
-
-
- public static final int CONSUMER_NOT_ONLINE = 206;
-
-
- public static final int CONSUME_MSG_TIMEOUT = 207;
-
-
- public static final int NO_MESSAGE = 208;
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/BrokerStatsData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/BrokerStatsData.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/BrokerStatsData.java
deleted file mode 100644
index 6f51b06..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/BrokerStatsData.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-
-public class BrokerStatsData extends RemotingSerializable {
-
- private BrokerStatsItem statsMinute;
-
- private BrokerStatsItem statsHour;
-
- private BrokerStatsItem statsDay;
-
-
- public BrokerStatsItem getStatsMinute() {
- return statsMinute;
- }
-
-
- public void setStatsMinute(BrokerStatsItem statsMinute) {
- this.statsMinute = statsMinute;
- }
-
-
- public BrokerStatsItem getStatsHour() {
- return statsHour;
- }
-
-
- public void setStatsHour(BrokerStatsItem statsHour) {
- this.statsHour = statsHour;
- }
-
-
- public BrokerStatsItem getStatsDay() {
- return statsDay;
- }
-
-
- public void setStatsDay(BrokerStatsItem statsDay) {
- this.statsDay = statsDay;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/BrokerStatsItem.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/BrokerStatsItem.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/BrokerStatsItem.java
deleted file mode 100644
index 1cf6c3d..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/BrokerStatsItem.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-public class BrokerStatsItem {
- private long sum;
- private double tps;
- private double avgpt;
-
-
- public long getSum() {
- return sum;
- }
-
-
- public void setSum(long sum) {
- this.sum = sum;
- }
-
-
- public double getTps() {
- return tps;
- }
-
-
- public void setTps(double tps) {
- this.tps = tps;
- }
-
-
- public double getAvgpt() {
- return avgpt;
- }
-
-
- public void setAvgpt(double avgpt) {
- this.avgpt = avgpt;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/CMResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/CMResult.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/CMResult.java
deleted file mode 100644
index 873b548..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/CMResult.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-public enum CMResult {
- CR_SUCCESS,
- CR_LATER,
- CR_ROLLBACK,
- CR_COMMIT,
- CR_THROW_EXCEPTION,
- CR_RETURN_NULL,
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ClusterInfo.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ClusterInfo.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ClusterInfo.java
deleted file mode 100644
index 81d6447..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ClusterInfo.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.common.protocol.route.BrokerData;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Set;
-
-
-/**
- * @author shijia.wxr
- */
-public class ClusterInfo extends RemotingSerializable {
- private HashMap<String/* brokerName */, BrokerData> brokerAddrTable;
- private HashMap<String/* clusterName */, Set<String/* brokerName */>> clusterAddrTable;
-
-
- public HashMap<String, BrokerData> getBrokerAddrTable() {
- return brokerAddrTable;
- }
-
-
- public void setBrokerAddrTable(HashMap<String, BrokerData> brokerAddrTable) {
- this.brokerAddrTable = brokerAddrTable;
- }
-
-
- public HashMap<String, Set<String>> getClusterAddrTable() {
- return clusterAddrTable;
- }
-
-
- public void setClusterAddrTable(HashMap<String, Set<String>> clusterAddrTable) {
- this.clusterAddrTable = clusterAddrTable;
- }
-
-
- public String[] retrieveAllAddrByCluster(String cluster) {
- List<String> addrs = new ArrayList<String>();
- if (clusterAddrTable.containsKey(cluster)) {
- Set<String> brokerNames = clusterAddrTable.get(cluster);
- for (String brokerName : brokerNames) {
- BrokerData brokerData = brokerAddrTable.get(brokerName);
- if (null != brokerData) {
- addrs.addAll(brokerData.getBrokerAddrs().values());
- }
- }
- }
-
- return addrs.toArray(new String[]{});
- }
-
-
- public String[] retrieveAllClusterNames() {
- return clusterAddrTable.keySet().toArray(new String[]{});
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/Connection.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/Connection.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/Connection.java
deleted file mode 100644
index 72cf601..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/Connection.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.remoting.protocol.LanguageCode;
-
-
-/**
- * @author shijia.wxr
- */
-public class Connection {
- private String clientId;
- private String clientAddr;
- private LanguageCode language;
- private int version;
-
-
- public String getClientId() {
- return clientId;
- }
-
-
- public void setClientId(String clientId) {
- this.clientId = clientId;
- }
-
-
- public String getClientAddr() {
- return clientAddr;
- }
-
-
- public void setClientAddr(String clientAddr) {
- this.clientAddr = clientAddr;
- }
-
-
- public LanguageCode getLanguage() {
- return language;
- }
-
-
- public void setLanguage(LanguageCode language) {
- this.language = language;
- }
-
-
- public int getVersion() {
- return version;
- }
-
-
- public void setVersion(int version) {
- this.version = version;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumeByWho.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumeByWho.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumeByWho.java
deleted file mode 100644
index 8a69352..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumeByWho.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.HashSet;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class ConsumeByWho extends RemotingSerializable {
- private HashSet<String> consumedGroup = new HashSet<String>();
- private HashSet<String> notConsumedGroup = new HashSet<String>();
- private String topic;
- private int queueId;
- private long offset;
-
-
- public HashSet<String> getConsumedGroup() {
- return consumedGroup;
- }
-
-
- public void setConsumedGroup(HashSet<String> consumedGroup) {
- this.consumedGroup = consumedGroup;
- }
-
-
- public HashSet<String> getNotConsumedGroup() {
- return notConsumedGroup;
- }
-
-
- public void setNotConsumedGroup(HashSet<String> notConsumedGroup) {
- this.notConsumedGroup = notConsumedGroup;
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public int getQueueId() {
- return queueId;
- }
-
-
- public void setQueueId(int queueId) {
- this.queueId = queueId;
- }
-
-
- public long getOffset() {
- return offset;
- }
-
-
- public void setOffset(long offset) {
- this.offset = offset;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumeMessageDirectlyResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumeMessageDirectlyResult.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumeMessageDirectlyResult.java
deleted file mode 100644
index c895fe2..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumeMessageDirectlyResult.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-
-public class ConsumeMessageDirectlyResult extends RemotingSerializable {
- private boolean order = false;
- private boolean autoCommit = true;
- private CMResult consumeResult;
- private String remark;
- private long spentTimeMills;
-
-
- public boolean isOrder() {
- return order;
- }
-
-
- public void setOrder(boolean order) {
- this.order = order;
- }
-
-
- public boolean isAutoCommit() {
- return autoCommit;
- }
-
-
- public void setAutoCommit(boolean autoCommit) {
- this.autoCommit = autoCommit;
- }
-
-
- public String getRemark() {
- return remark;
- }
-
-
- public void setRemark(String remark) {
- this.remark = remark;
- }
-
-
- public CMResult getConsumeResult() {
- return consumeResult;
- }
-
-
- public void setConsumeResult(CMResult consumeResult) {
- this.consumeResult = consumeResult;
- }
-
-
- public long getSpentTimeMills() {
- return spentTimeMills;
- }
-
-
- public void setSpentTimeMills(long spentTimeMills) {
- this.spentTimeMills = spentTimeMills;
- }
-
-
- @Override
- public String toString() {
- return "ConsumeMessageDirectlyResult [order=" + order + ", autoCommit=" + autoCommit
- + ", consumeResult=" + consumeResult + ", remark=" + remark + ", spentTimeMills="
- + spentTimeMills + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumeStatsList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumeStatsList.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumeStatsList.java
deleted file mode 100644
index a1c608d..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumeStatsList.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.common.admin.ConsumeStats;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-
-/**
- * @author shijia.wxr
- */
-public class ConsumeStatsList extends RemotingSerializable {
- private List<Map<String/*subscriptionGroupName*/, List<ConsumeStats>>> consumeStatsList = new ArrayList<Map<String/*subscriptionGroupName*/, List<ConsumeStats>>>();
- private String brokerAddr;
- private long totalDiff;
-
- public List<Map<String, List<ConsumeStats>>> getConsumeStatsList() {
- return consumeStatsList;
- }
-
- public void setConsumeStatsList(List<Map<String, List<ConsumeStats>>> consumeStatsList) {
- this.consumeStatsList = consumeStatsList;
- }
-
- public String getBrokerAddr() {
- return brokerAddr;
- }
-
- public void setBrokerAddr(String brokerAddr) {
- this.brokerAddr = brokerAddr;
- }
-
- public long getTotalDiff() {
- return totalDiff;
- }
-
- public void setTotalDiff(long totalDiff) {
- this.totalDiff = totalDiff;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumeStatus.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumeStatus.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumeStatus.java
deleted file mode 100644
index dcb6281..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumeStatus.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-public class ConsumeStatus {
- private double pullRT;
- private double pullTPS;
- private double consumeRT;
- private double consumeOKTPS;
- private double consumeFailedTPS;
-
- private long consumeFailedMsgs;
-
-
- public double getPullRT() {
- return pullRT;
- }
-
-
- public void setPullRT(double pullRT) {
- this.pullRT = pullRT;
- }
-
-
- public double getPullTPS() {
- return pullTPS;
- }
-
-
- public void setPullTPS(double pullTPS) {
- this.pullTPS = pullTPS;
- }
-
-
- public double getConsumeRT() {
- return consumeRT;
- }
-
-
- public void setConsumeRT(double consumeRT) {
- this.consumeRT = consumeRT;
- }
-
-
- public double getConsumeOKTPS() {
- return consumeOKTPS;
- }
-
-
- public void setConsumeOKTPS(double consumeOKTPS) {
- this.consumeOKTPS = consumeOKTPS;
- }
-
-
- public double getConsumeFailedTPS() {
- return consumeFailedTPS;
- }
-
-
- public void setConsumeFailedTPS(double consumeFailedTPS) {
- this.consumeFailedTPS = consumeFailedTPS;
- }
-
-
- public long getConsumeFailedMsgs() {
- return consumeFailedMsgs;
- }
-
-
- public void setConsumeFailedMsgs(long consumeFailedMsgs) {
- this.consumeFailedMsgs = consumeFailedMsgs;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumerConnection.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumerConnection.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumerConnection.java
deleted file mode 100644
index f74c6fc..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumerConnection.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.common.consumer.ConsumeFromWhere;
-import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType;
-import com.alibaba.rocketmq.common.protocol.heartbeat.MessageModel;
-import com.alibaba.rocketmq.common.protocol.heartbeat.SubscriptionData;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.HashSet;
-import java.util.concurrent.ConcurrentHashMap;
-
-
-/**
- * @author shijia.wxr
- */
-public class ConsumerConnection extends RemotingSerializable {
- private HashSet<Connection> connectionSet = new HashSet<Connection>();
- private ConcurrentHashMap<String/* Topic */, SubscriptionData> subscriptionTable =
- new ConcurrentHashMap<String, SubscriptionData>();
- private ConsumeType consumeType;
- private MessageModel messageModel;
- private ConsumeFromWhere consumeFromWhere;
-
-
- public int computeMinVersion() {
- int minVersion = Integer.MAX_VALUE;
- for (Connection c : this.connectionSet) {
- if (c.getVersion() < minVersion) {
- minVersion = c.getVersion();
- }
- }
-
- return minVersion;
- }
-
-
- public HashSet<Connection> getConnectionSet() {
- return connectionSet;
- }
-
-
- public void setConnectionSet(HashSet<Connection> connectionSet) {
- this.connectionSet = connectionSet;
- }
-
-
- public ConcurrentHashMap<String, SubscriptionData> getSubscriptionTable() {
- return subscriptionTable;
- }
-
-
- public void setSubscriptionTable(ConcurrentHashMap<String, SubscriptionData> subscriptionTable) {
- this.subscriptionTable = subscriptionTable;
- }
-
-
- public ConsumeType getConsumeType() {
- return consumeType;
- }
-
-
- public void setConsumeType(ConsumeType consumeType) {
- this.consumeType = consumeType;
- }
-
-
- public MessageModel getMessageModel() {
- return messageModel;
- }
-
-
- public void setMessageModel(MessageModel messageModel) {
- this.messageModel = messageModel;
- }
-
-
- public ConsumeFromWhere getConsumeFromWhere() {
- return consumeFromWhere;
- }
-
-
- public void setConsumeFromWhere(ConsumeFromWhere consumeFromWhere) {
- this.consumeFromWhere = consumeFromWhere;
- }
-}
[72/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java b/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
index 6326d4b..d9e2f03 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
@@ -16,14 +16,12 @@
*/
package org.apache.rocketmq.store;
-import org.apache.rocketmq.common.constant.LoggerName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.File;
import java.nio.ByteBuffer;
import java.util.List;
-
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ConsumeQueue {
@@ -43,13 +41,12 @@ public class ConsumeQueue {
private long maxPhysicOffset = -1;
private volatile long minLogicOffset = 0;
-
public ConsumeQueue(
- final String topic,
- final int queueId,
- final String storePath,
- final int mappedFileSize,
- final DefaultMessageStore defaultMessageStore) {
+ final String topic,
+ final int queueId,
+ final String storePath,
+ final int mappedFileSize,
+ final DefaultMessageStore defaultMessageStore) {
this.storePath = storePath;
this.mappedFileSize = mappedFileSize;
this.defaultMessageStore = defaultMessageStore;
@@ -58,22 +55,20 @@ public class ConsumeQueue {
this.queueId = queueId;
String queueDir = this.storePath
- + File.separator + topic
- + File.separator + queueId;
+ + File.separator + topic
+ + File.separator + queueId;
this.mappedFileQueue = new MappedFileQueue(queueDir, mappedFileSize, null);
this.byteBufferIndex = ByteBuffer.allocate(CQ_STORE_UNIT_SIZE);
}
-
public boolean load() {
boolean result = this.mappedFileQueue.load();
log.info("load consume queue " + this.topic + "-" + this.queueId + " " + (result ? "OK" : "Failed"));
return result;
}
-
public void recover() {
final List<MappedFile> mappedFiles = this.mappedFileQueue.getMappedFiles();
if (!mappedFiles.isEmpty()) {
@@ -98,18 +93,17 @@ public class ConsumeQueue {
this.maxPhysicOffset = offset;
} else {
log.info("recover current consume queue file over, " + mappedFile.getFileName() + " "
- + offset + " " + size + " " + tagsCode);
+ + offset + " " + size + " " + tagsCode);
break;
}
}
-
if (mapedFileOffset == mapedFileSizeLogics) {
index++;
if (index >= mappedFiles.size()) {
log.info("recover last consume queue file over, last maped file "
- + mappedFile.getFileName());
+ + mappedFile.getFileName());
break;
} else {
mappedFile = mappedFiles.get(index);
@@ -120,7 +114,7 @@ public class ConsumeQueue {
}
} else {
log.info("recover current consume queue queue over " + mappedFile.getFileName() + " "
- + (processOffset + mapedFileOffset));
+ + (processOffset + mapedFileOffset));
break;
}
}
@@ -137,8 +131,8 @@ public class ConsumeQueue {
if (mappedFile != null) {
long offset = 0;
int low =
- minLogicOffset > mappedFile.getFileFromOffset() ? (int) (minLogicOffset - mappedFile
- .getFileFromOffset()) : 0;
+ minLogicOffset > mappedFile.getFileFromOffset() ? (int)(minLogicOffset - mappedFile
+ .getFileFromOffset()) : 0;
int high = 0;
int midOffset = -1, targetOffset = -1, leftOffset = -1, rightOffset = -1;
long leftIndexValue = -1L, rightIndexValue = -1L;
@@ -160,7 +154,7 @@ public class ConsumeQueue {
}
long storeTime =
- this.defaultMessageStore.getCommitLog().pickupStoreTimestamp(phyOffset, size);
+ this.defaultMessageStore.getCommitLog().pickupStoreTimestamp(phyOffset, size);
if (storeTime < 0) {
return 0;
} else if (storeTime == timestamp) {
@@ -189,8 +183,8 @@ public class ConsumeQueue {
offset = leftOffset;
} else {
offset =
- Math.abs(timestamp - leftIndexValue) > Math.abs(timestamp
- - rightIndexValue) ? rightOffset : leftOffset;
+ Math.abs(timestamp - leftIndexValue) > Math.abs(timestamp
+ - rightIndexValue) ? rightOffset : leftOffset;
}
}
@@ -223,7 +217,6 @@ public class ConsumeQueue {
int size = byteBuffer.getInt();
byteBuffer.getLong();
-
if (0 == i) {
if (offset >= phyOffet) {
this.mappedFileQueue.deleteLastMappedFile();
@@ -249,7 +242,6 @@ public class ConsumeQueue {
mappedFile.setFlushedPosition(pos);
this.maxPhysicOffset = offset;
-
if (pos == logicFileSize) {
return;
}
@@ -283,7 +275,6 @@ public class ConsumeQueue {
int size = byteBuffer.getInt();
byteBuffer.getLong();
-
if (offset >= 0 && size > 0) {
lastOffset = offset + size;
} else {
@@ -295,12 +286,10 @@ public class ConsumeQueue {
return lastOffset;
}
-
public boolean flush(final int flushLeastPages) {
return this.mappedFileQueue.flush(flushLeastPages);
}
-
public int deleteExpiredFile(long offset) {
int cnt = this.mappedFileQueue.deleteExpiredFileByOffset(offset, CQ_STORE_UNIT_SIZE);
this.correctMinOffset(offset);
@@ -322,7 +311,7 @@ public class ConsumeQueue {
if (offsetPy >= phyMinOffset) {
this.minLogicOffset = result.getMappedFile().getFileFromOffset() + i;
log.info("compute logics min offset: " + this.getMinOffsetInQuque() + ", topic: "
- + this.topic + ", queueId: " + this.queueId);
+ + this.topic + ", queueId: " + this.queueId);
break;
}
}
@@ -335,14 +324,12 @@ public class ConsumeQueue {
}
}
-
public long getMinOffsetInQuque() {
return this.minLogicOffset / CQ_STORE_UNIT_SIZE;
}
-
public void putMessagePositionInfoWrapper(long offset, int size, long tagsCode, long storeTimestamp,
- long logicOffset) {
+ long logicOffset) {
final int maxRetries = 30;
boolean canWrite = this.defaultMessageStore.getRunningFlags().isWriteable();
for (int i = 0; i < maxRetries && canWrite; i++) {
@@ -353,7 +340,7 @@ public class ConsumeQueue {
} else {
// XXX: warn and notify me
log.warn("[BUG]put commit log position info to " + topic + ":" + queueId + " " + offset
- + " failed, retry " + i + " times");
+ + " failed, retry " + i + " times");
try {
Thread.sleep(1000);
@@ -369,7 +356,7 @@ public class ConsumeQueue {
}
private boolean putMessagePositionInfo(final long offset, final int size, final long tagsCode,
- final long cqOffset) {
+ final long cqOffset) {
if (offset <= this.maxPhysicOffset) {
return true;
@@ -392,19 +379,19 @@ public class ConsumeQueue {
this.mappedFileQueue.setCommittedWhere(expectLogicOffset);
this.fillPreBlank(mappedFile, expectLogicOffset);
log.info("fill pre blank space " + mappedFile.getFileName() + " " + expectLogicOffset + " "
- + mappedFile.getWrotePosition());
+ + mappedFile.getWrotePosition());
}
if (cqOffset != 0) {
long currentLogicOffset = mappedFile.getWrotePosition() + mappedFile.getFileFromOffset();
if (expectLogicOffset != currentLogicOffset) {
LOG_ERROR.warn(
- "[BUG]logic queue order maybe wrong, expectLogicOffset: {} currentLogicOffset: {} Topic: {} QID: {} Diff: {}",
- expectLogicOffset,
- currentLogicOffset,
- this.topic,
- this.queueId,
- expectLogicOffset - currentLogicOffset
+ "[BUG]logic queue order maybe wrong, expectLogicOffset: {} currentLogicOffset: {} Topic: {} QID: {} Diff: {}",
+ expectLogicOffset,
+ currentLogicOffset,
+ this.topic,
+ this.queueId,
+ expectLogicOffset - currentLogicOffset
);
}
}
@@ -414,14 +401,13 @@ public class ConsumeQueue {
return false;
}
-
private void fillPreBlank(final MappedFile mappedFile, final long untilWhere) {
ByteBuffer byteBuffer = ByteBuffer.allocate(CQ_STORE_UNIT_SIZE);
byteBuffer.putLong(0L);
byteBuffer.putInt(Integer.MAX_VALUE);
byteBuffer.putLong(0L);
- int until = (int) (untilWhere % this.mappedFileQueue.getMappedFileSize());
+ int until = (int)(untilWhere % this.mappedFileQueue.getMappedFileSize());
for (int i = 0; i < until; i += CQ_STORE_UNIT_SIZE) {
mappedFile.appendMessage(byteBuffer.array());
}
@@ -433,7 +419,7 @@ public class ConsumeQueue {
if (offset >= this.getMinLogicOffset()) {
MappedFile mappedFile = this.mappedFileQueue.findMappedFileByOffset(offset);
if (mappedFile != null) {
- SelectMappedBufferResult result = mappedFile.selectMappedBuffer((int) (offset % mappedFileSize));
+ SelectMappedBufferResult result = mappedFile.selectMappedBuffer((int)(offset % mappedFileSize));
return result;
}
}
@@ -480,12 +466,10 @@ public class ConsumeQueue {
return this.getMaxOffsetInQuque() - this.getMinOffsetInQuque();
}
-
public long getMaxOffsetInQuque() {
return this.mappedFileQueue.getMaxOffset() / CQ_STORE_UNIT_SIZE;
}
-
public void checkSelf() {
mappedFileQueue.checkSelf();
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/DefaultMessageFilter.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageFilter.java b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageFilter.java
index ac149f4..4ebcb3e 100644
--- a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageFilter.java
+++ b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageFilter.java
@@ -6,19 +6,18 @@
* (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
+ * 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.
+ * 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.store;
import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
-
public class DefaultMessageFilter implements MessageFilter {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
index 8714055..7e3af19 100644
--- a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
+++ b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
@@ -16,7 +16,27 @@
*/
package org.apache.rocketmq.store;
-import org.apache.rocketmq.common.*;
+import java.io.File;
+import java.io.IOException;
+import java.net.SocketAddress;
+import java.nio.ByteBuffer;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+import org.apache.rocketmq.common.BrokerConfig;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.ServiceThread;
+import org.apache.rocketmq.common.SystemClock;
+import org.apache.rocketmq.common.ThreadFactoryImpl;
+import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.common.message.MessageDecoder;
import org.apache.rocketmq.common.message.MessageExt;
@@ -34,21 +54,8 @@ import org.apache.rocketmq.store.stats.BrokerStatsManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.IOException;
-import java.net.SocketAddress;
-import java.nio.ByteBuffer;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-
import static org.apache.rocketmq.store.config.BrokerRole.SLAVE;
-
public class DefaultMessageStore implements MessageStore {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
@@ -84,7 +91,7 @@ public class DefaultMessageStore implements MessageStore {
private final SystemClock systemClock = new SystemClock();
private final ScheduledExecutorService scheduledExecutorService =
- Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("StoreScheduledThread"));
+ Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("StoreScheduledThread"));
private final BrokerStatsManager brokerStatsManager;
private final MessageArrivingListener messageArrivingListener;
private final BrokerConfig brokerConfig;
@@ -96,7 +103,7 @@ public class DefaultMessageStore implements MessageStore {
private AtomicLong printTimes = new AtomicLong(0);
public DefaultMessageStore(final MessageStoreConfig messageStoreConfig, final BrokerStatsManager brokerStatsManager,
- final MessageArrivingListener messageArrivingListener, final BrokerConfig brokerConfig) throws IOException {
+ final MessageArrivingListener messageArrivingListener, final BrokerConfig brokerConfig) throws IOException {
this.messageArrivingListener = messageArrivingListener;
this.brokerConfig = brokerConfig;
this.messageStoreConfig = messageStoreConfig;
@@ -122,13 +129,11 @@ public class DefaultMessageStore implements MessageStore {
this.transientStorePool.init();
}
-
this.allocateMappedFileService.start();
this.indexService.start();
}
-
public void truncateDirtyLogicFiles(long phyOffset) {
ConcurrentHashMap<String, ConcurrentHashMap<Integer, ConsumeQueue>> tables = DefaultMessageStore.this.consumeQueueTable;
@@ -139,7 +144,6 @@ public class DefaultMessageStore implements MessageStore {
}
}
-
/**
* @throws IOException
*/
@@ -162,11 +166,10 @@ public class DefaultMessageStore implements MessageStore {
if (result) {
this.storeCheckpoint =
- new StoreCheckpoint(StorePathConfigHelper.getStoreCheckpoint(this.messageStoreConfig.getStorePathRootDir()));
+ new StoreCheckpoint(StorePathConfigHelper.getStoreCheckpoint(this.messageStoreConfig.getStorePathRootDir()));
this.indexService.load(lastExitOK);
-
this.recover(lastExitOK);
log.info("load over, and the max phy offset = {}", this.getMaxPhyOffset());
@@ -191,7 +194,6 @@ public class DefaultMessageStore implements MessageStore {
this.commitLog.start();
this.storeStatsService.start();
-
if (this.scheduleMessageService != null && SLAVE != messageStoreConfig.getBrokerRole()) {
this.scheduleMessageService.start();
}
@@ -293,19 +295,16 @@ public class DefaultMessageStore implements MessageStore {
this.printTimes.set(0);
}
-
if (msg.getTopic().length() > Byte.MAX_VALUE) {
log.warn("putMessage message topic length too long " + msg.getTopic().length());
return new PutMessageResult(PutMessageStatus.MESSAGE_ILLEGAL, null);
}
-
if (msg.getPropertiesString() != null && msg.getPropertiesString().length() > Short.MAX_VALUE) {
log.warn("putMessage message properties length too long " + msg.getPropertiesString().length());
return new PutMessageResult(PutMessageStatus.PROPERTIES_SIZE_EXCEEDED, null);
}
-
if (this.isOSPageCacheBusy()) {
return new PutMessageResult(PutMessageStatus.OS_PAGECACHE_BUSY, null);
}
@@ -332,7 +331,7 @@ public class DefaultMessageStore implements MessageStore {
long diff = this.systemClock.now() - begin;
if (diff < 10000000 //
- && diff > this.messageStoreConfig.getOsPageCacheBusyTimeOutMills()) {
+ && diff > this.messageStoreConfig.getOsPageCacheBusyTimeOutMills()) {
return true;
}
@@ -353,7 +352,7 @@ public class DefaultMessageStore implements MessageStore {
}
public GetMessageResult getMessage(final String group, final String topic, final int queueId, final long offset, final int maxMsgNums,
- final SubscriptionData subscriptionData) {
+ final SubscriptionData subscriptionData) {
if (this.shutdown) {
log.warn("message store has shutdown, so getMessage is forbidden");
return null;
@@ -366,7 +365,6 @@ public class DefaultMessageStore implements MessageStore {
long beginTime = this.getSystemClock().now();
-
GetMessageStatus status = GetMessageStatus.NO_MESSAGE_IN_QUEUE;
long nextBeginOffset = offset;
long minOffset = 0;
@@ -374,7 +372,6 @@ public class DefaultMessageStore implements MessageStore {
GetMessageResult getResult = new GetMessageResult();
-
final long maxOffsetPy = this.commitLog.getMaxOffset();
ConsumeQueue consumeQueue = findConsumeQueue(topic, queueId);
@@ -417,21 +414,18 @@ public class DefaultMessageStore implements MessageStore {
maxPhyOffsetPulling = offsetPy;
-
if (nextPhyFileStartOffset != Long.MIN_VALUE) {
if (offsetPy < nextPhyFileStartOffset)
continue;
}
-
boolean isInDisk = checkInDiskByCommitOffset(offsetPy, maxOffsetPy);
if (this.isTheBatchFull(sizePy, maxMsgNums, getResult.getBufferTotalSize(), getResult.getMessageCount(),
- isInDisk)) {
+ isInDisk)) {
break;
}
-
if (this.messageFilter.isMessageMatched(subscriptionData, tagsCode)) {
SelectMappedBufferResult selectResult = this.commitLog.getMessage(offsetPy, sizePy);
if (selectResult != null) {
@@ -444,7 +438,6 @@ public class DefaultMessageStore implements MessageStore {
status = GetMessageStatus.MESSAGE_WAS_REMOVING;
}
-
nextPhyFileStartOffset = this.commitLog.rollNextFile(offsetPy);
}
} else {
@@ -458,7 +451,6 @@ public class DefaultMessageStore implements MessageStore {
}
}
-
if (diskFallRecorded) {
long fallBehind = maxOffsetPy - maxPhyOffsetPulling;
brokerStatsManager.recordDiskFallBehindSize(group, topic, queueId, fallBehind);
@@ -466,10 +458,9 @@ public class DefaultMessageStore implements MessageStore {
nextBeginOffset = offset + (i / ConsumeQueue.CQ_STORE_UNIT_SIZE);
-
long diff = maxOffsetPy - maxPhyOffsetPulling;
- long memory = (long) (StoreUtil.TOTAL_PHYSICAL_MEMORY_SIZE
- * (this.messageStoreConfig.getAccessMessageInMemoryMaxRatio() / 100.0));
+ long memory = (long)(StoreUtil.TOTAL_PHYSICAL_MEMORY_SIZE
+ * (this.messageStoreConfig.getAccessMessageInMemoryMaxRatio() / 100.0));
getResult.setSuggestPullingFromSlave(diff > memory);
} finally {
@@ -479,7 +470,7 @@ public class DefaultMessageStore implements MessageStore {
status = GetMessageStatus.OFFSET_FOUND_NULL;
nextBeginOffset = nextOffsetCorrection(offset, consumeQueue.rollNextFile(offset));
log.warn("consumer request topic: " + topic + "offset: " + offset + " minOffset: " + minOffset + " maxOffset: "
- + maxOffset + ", but access logic queue failed.");
+ + maxOffset + ", but access logic queue failed.");
}
}
} else {
@@ -605,7 +596,6 @@ public class DefaultMessageStore implements MessageStore {
}
-
{
String storePathLogics = StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir());
@@ -613,7 +603,6 @@ public class DefaultMessageStore implements MessageStore {
result.put(RunningStats.consumeQueueDiskRatio.name(), String.valueOf(logicsRatio));
}
-
{
if (this.scheduleMessageService != null) {
this.scheduleMessageService.buildRunningStats(result);
@@ -741,7 +730,6 @@ public class DefaultMessageStore implements MessageStore {
break;
}
-
Collections.sort(queryOffsetResult.getPhyOffsets());
queryMessageResult.setIndexLastUpdatePhyoffset(queryOffsetResult.getIndexLastUpdatePhyoffset());
@@ -784,12 +772,10 @@ public class DefaultMessageStore implements MessageStore {
}
}
-
if (queryMessageResult.getBufferTotalSize() > 0) {
break;
}
-
if (lastQueryMsgTime < begin) {
break;
}
@@ -825,8 +811,8 @@ public class DefaultMessageStore implements MessageStore {
for (ConsumeQueue cq : queueTable.values()) {
cq.destroy();
log.info("cleanUnusedTopic: {} {} ConsumeQueue cleaned", //
- cq.getTopic(), //
- cq.getQueueId() //
+ cq.getTopic(), //
+ cq.getQueueId() //
);
this.commitLog.removeQueueFromTopicQueueTable(cq.getTopic(), cq.getQueueId());
@@ -854,23 +840,22 @@ public class DefaultMessageStore implements MessageStore {
Entry<Integer, ConsumeQueue> nextQT = itQT.next();
long maxCLOffsetInConsumeQueue = nextQT.getValue().getLastOffset();
-
if (maxCLOffsetInConsumeQueue == -1) {
log.warn("maybe ConsumeQueue was created just now. topic={} queueId={} maxPhysicOffset={} minLogicOffset={}.", //
- nextQT.getValue().getTopic(), //
- nextQT.getValue().getQueueId(), //
- nextQT.getValue().getMaxPhysicOffset(), //
- nextQT.getValue().getMinLogicOffset());
+ nextQT.getValue().getTopic(), //
+ nextQT.getValue().getQueueId(), //
+ nextQT.getValue().getMaxPhysicOffset(), //
+ nextQT.getValue().getMinLogicOffset());
} else if (maxCLOffsetInConsumeQueue < minCommitLogOffset) {
log.info(
- "cleanExpiredConsumerQueue: {} {} consumer queue destroyed, minCommitLogOffset: {} maxCLOffsetInConsumeQueue: {}", //
- topic, //
- nextQT.getKey(), //
- minCommitLogOffset, //
- maxCLOffsetInConsumeQueue);
+ "cleanExpiredConsumerQueue: {} {} consumer queue destroyed, minCommitLogOffset: {} maxCLOffsetInConsumeQueue: {}", //
+ topic, //
+ nextQT.getKey(), //
+ minCommitLogOffset, //
+ maxCLOffsetInConsumeQueue);
DefaultMessageStore.this.commitLog.removeQueueFromTopicQueueTable(nextQT.getValue().getTopic(),
- nextQT.getValue().getQueueId());
+ nextQT.getValue().getQueueId());
nextQT.getValue().destroy();
itQT.remove();
@@ -910,7 +895,7 @@ public class DefaultMessageStore implements MessageStore {
long offsetPy = bufferConsumeQueue.getByteBuffer().getLong();
final ByteBuffer msgIdMemory = ByteBuffer.allocate(MessageDecoder.MSG_ID_LENGTH);
String msgId =
- MessageDecoder.createMessageId(msgIdMemory, MessageExt.socketAddress2ByteBuffer(storeHost), offsetPy);
+ MessageDecoder.createMessageId(msgIdMemory, MessageExt.socketAddress2ByteBuffer(storeHost), offsetPy);
messageIds.put(msgId, nextOffset++);
if (nextOffset > maxOffset) {
return messageIds;
@@ -1006,11 +991,11 @@ public class DefaultMessageStore implements MessageStore {
ConsumeQueue logic = map.get(queueId);
if (null == logic) {
ConsumeQueue newLogic = new ConsumeQueue(//
- topic, //
- queueId, //
- StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir()), //
- this.getMessageStoreConfig().getMapedFileSizeConsumeQueue(), //
- this);
+ topic, //
+ queueId, //
+ StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir()), //
+ this.getMessageStoreConfig().getMapedFileSizeConsumeQueue(), //
+ this);
ConsumeQueue oldLogic = map.putIfAbsent(queueId, newLogic);
if (oldLogic != null) {
logic = oldLogic;
@@ -1031,7 +1016,7 @@ public class DefaultMessageStore implements MessageStore {
}
private boolean checkInDiskByCommitOffset(long offsetPy, long maxOffsetPy) {
- long memory = (long) (StoreUtil.TOTAL_PHYSICAL_MEMORY_SIZE * (this.messageStoreConfig.getAccessMessageInMemoryMaxRatio() / 100.0));
+ long memory = (long)(StoreUtil.TOTAL_PHYSICAL_MEMORY_SIZE * (this.messageStoreConfig.getAccessMessageInMemoryMaxRatio() / 100.0));
return (maxOffsetPy - offsetPy) > memory;
}
@@ -1045,7 +1030,6 @@ public class DefaultMessageStore implements MessageStore {
return true;
}
-
if (isInDisk) {
if ((bufferTotal + sizePy) > this.messageStoreConfig.getMaxTransferBytesOnMessageInDisk()) {
return true;
@@ -1093,7 +1077,6 @@ public class DefaultMessageStore implements MessageStore {
}
}, 1000 * 60, this.messageStoreConfig.getCleanResourceInterval(), TimeUnit.MILLISECONDS);
-
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
@@ -1101,7 +1084,6 @@ public class DefaultMessageStore implements MessageStore {
}
}, 1, 10, TimeUnit.MINUTES);
-
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
@@ -1113,7 +1095,7 @@ public class DefaultMessageStore implements MessageStore {
String stack = UtilAll.jstack();
final String fileName = System.getProperty("user.home") + File.separator + "debug/lock/stack-"
- + DefaultMessageStore.this.commitLog.getBeginTimeInLock() + "-" + lockTime;
+ + DefaultMessageStore.this.commitLog.getBeginTimeInLock() + "-" + lockTime;
MixAll.string2FileNotSafe(stack, fileName);
}
}
@@ -1174,11 +1156,11 @@ public class DefaultMessageStore implements MessageStore {
continue;
}
ConsumeQueue logic = new ConsumeQueue(
- topic,
- queueId,
- StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir()),
- this.getMessageStoreConfig().getMapedFileSizeConsumeQueue(),
- this);
+ topic,
+ queueId,
+ StorePathConfigHelper.getStorePathConsumeQueue(this.messageStoreConfig.getStorePathRootDir()),
+ this.getMessageStoreConfig().getMapedFileSizeConsumeQueue(),
+ this);
this.putConsumeQueue(topic, queueId, logic);
if (!logic.load()) {
return false;
@@ -1196,7 +1178,6 @@ public class DefaultMessageStore implements MessageStore {
private void recover(final boolean lastExitOK) {
this.recoverConsumeQueue();
-
if (lastExitOK) {
this.commitLog.recoverNormally();
} else {
@@ -1285,7 +1266,7 @@ public class DefaultMessageStore implements MessageStore {
case MessageSysFlag.TRANSACTION_NOT_TYPE:
case MessageSysFlag.TRANSACTION_COMMIT_TYPE:
DefaultMessageStore.this.putMessagePositionInfo(req.getTopic(), req.getQueueId(), req.getCommitLogOffset(), req.getMsgSize(),
- req.getTagsCode(), req.getStoreTimestamp(), req.getConsumeQueueOffset());
+ req.getTagsCode(), req.getStoreTimestamp(), req.getConsumeQueueOffset());
break;
case MessageSysFlag.TRANSACTION_PREPARED_TYPE:
case MessageSysFlag.TRANSACTION_ROLLBACK_TYPE:
@@ -1298,7 +1279,7 @@ public class DefaultMessageStore implements MessageStore {
}
public void putMessagePositionInfo(String topic, int queueId, long offset, int size, long tagsCode, long storeTimestamp,
- long logicOffset) {
+ long logicOffset) {
ConsumeQueue cq = this.findConsumeQueue(topic, queueId);
cq.putMessagePositionInfoWrapper(offset, size, tagsCode, storeTimestamp, logicOffset);
}
@@ -1311,23 +1292,21 @@ public class DefaultMessageStore implements MessageStore {
private final static int MAX_MANUAL_DELETE_FILE_TIMES = 20;
private final double diskSpaceWarningLevelRatio =
- Double.parseDouble(System.getProperty("rocketmq.broker.diskSpaceWarningLevelRatio", "0.90"));
+ Double.parseDouble(System.getProperty("rocketmq.broker.diskSpaceWarningLevelRatio", "0.90"));
private final double diskSpaceCleanForciblyRatio =
- Double.parseDouble(System.getProperty("rocketmq.broker.diskSpaceCleanForciblyRatio", "0.85"));
+ Double.parseDouble(System.getProperty("rocketmq.broker.diskSpaceCleanForciblyRatio", "0.85"));
private long lastRedeleteTimestamp = 0;
private volatile int manualDeleteFileSeveralTimes = 0;
private volatile boolean cleanImmediately = false;
-
public void excuteDeleteFilesManualy() {
this.manualDeleteFileSeveralTimes = MAX_MANUAL_DELETE_FILE_TIMES;
DefaultMessageStore.log.info("excuteDeleteFilesManualy was invoked");
}
-
public void run() {
try {
this.deleteExpiredFiles();
@@ -1348,27 +1327,24 @@ public class DefaultMessageStore implements MessageStore {
boolean spacefull = this.isSpaceToDelete();
boolean manualDelete = this.manualDeleteFileSeveralTimes > 0;
-
if (timeup || spacefull || manualDelete) {
if (manualDelete)
this.manualDeleteFileSeveralTimes--;
-
boolean cleanAtOnce = DefaultMessageStore.this.getMessageStoreConfig().isCleanFileForciblyEnable() && this.cleanImmediately;
log.info("begin to delete before {} hours file. timeup: {} spacefull: {} manualDeleteFileSeveralTimes: {} cleanAtOnce: {}", //
- fileReservedTime, //
- timeup, //
- spacefull, //
- manualDeleteFileSeveralTimes, //
- cleanAtOnce);
-
+ fileReservedTime, //
+ timeup, //
+ spacefull, //
+ manualDeleteFileSeveralTimes, //
+ cleanAtOnce);
fileReservedTime *= 60 * 60 * 1000;
deleteCount = DefaultMessageStore.this.commitLog.deleteExpiredFile(fileReservedTime, deletePhysicFilesInterval,
- destroyMapedFileIntervalForcibly, cleanAtOnce);
+ destroyMapedFileIntervalForcibly, cleanAtOnce);
if (deleteCount > 0) {
} else if (spacefull) {
log.warn("disk space will be full soon, but delete file failed.");
@@ -1382,7 +1358,7 @@ public class DefaultMessageStore implements MessageStore {
if ((currentTimestamp - this.lastRedeleteTimestamp) > interval) {
this.lastRedeleteTimestamp = currentTimestamp;
int destroyMapedFileIntervalForcibly =
- DefaultMessageStore.this.getMessageStoreConfig().getDestroyMapedFileIntervalForcibly();
+ DefaultMessageStore.this.getMessageStoreConfig().getDestroyMapedFileIntervalForcibly();
if (DefaultMessageStore.this.commitLog.retryDeleteFirstFile(destroyMapedFileIntervalForcibly)) {
}
}
@@ -1407,7 +1383,6 @@ public class DefaultMessageStore implements MessageStore {
cleanImmediately = false;
-
{
String storePathPhysic = DefaultMessageStore.this.getMessageStoreConfig().getStorePathCommitLog();
double physicRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathPhysic);
@@ -1433,10 +1408,9 @@ public class DefaultMessageStore implements MessageStore {
}
}
-
{
String storePathLogics = StorePathConfigHelper
- .getStorePathConsumeQueue(DefaultMessageStore.this.getMessageStoreConfig().getStorePathRootDir());
+ .getStorePathConsumeQueue(DefaultMessageStore.this.getMessageStoreConfig().getStorePathRootDir());
double logicsRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathLogics);
if (logicsRatio > diskSpaceWarningLevelRatio) {
boolean diskok = DefaultMessageStore.this.runningFlags.getAndMakeDiskFull();
@@ -1490,7 +1464,6 @@ public class DefaultMessageStore implements MessageStore {
if (minOffset > this.lastPhysicalMinOffset) {
this.lastPhysicalMinOffset = minOffset;
-
ConcurrentHashMap<String, ConcurrentHashMap<Integer, ConsumeQueue>> tables = DefaultMessageStore.this.consumeQueueTable;
for (ConcurrentHashMap<Integer, ConsumeQueue> maps : tables.values()) {
@@ -1506,7 +1479,6 @@ public class DefaultMessageStore implements MessageStore {
}
}
-
DefaultMessageStore.this.indexService.deleteExpiredFile(minOffset);
}
}
@@ -1520,7 +1492,6 @@ public class DefaultMessageStore implements MessageStore {
private static final int RETRY_TIMES_OVER = 3;
private long lastFlushTimestamp = 0;
-
private void doFlush(int retryTimes) {
int flushConsumeQueueLeastPages = DefaultMessageStore.this.getMessageStoreConfig().getFlushConsumeQueueLeastPages();
@@ -1530,7 +1501,6 @@ public class DefaultMessageStore implements MessageStore {
long logicsMsgTimestamp = 0;
-
int flushConsumeQueueThoroughInterval = DefaultMessageStore.this.getMessageStoreConfig().getFlushConsumeQueueThoroughInterval();
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis >= (this.lastFlushTimestamp + flushConsumeQueueThoroughInterval)) {
@@ -1558,7 +1528,6 @@ public class DefaultMessageStore implements MessageStore {
}
}
-
public void run() {
DefaultMessageStore.log.info(this.getServiceName() + " service started");
@@ -1572,19 +1541,16 @@ public class DefaultMessageStore implements MessageStore {
}
}
-
this.doFlush(RETRY_TIMES_OVER);
DefaultMessageStore.log.info(this.getServiceName() + " service end");
}
-
@Override
public String getServiceName() {
return FlushConsumeQueueService.class.getSimpleName();
}
-
@Override
public long getJointime() {
return 1000 * 60;
@@ -1610,7 +1576,7 @@ public class DefaultMessageStore implements MessageStore {
if (this.isCommitLogAvailable()) {
log.warn("shutdown ReputMessageService, but commitlog have not finish to be dispatched, CL: {} reputFromOffset: {}",
- DefaultMessageStore.this.commitLog.getMaxOffset(), this.reputFromOffset);
+ DefaultMessageStore.this.commitLog.getMaxOffset(), this.reputFromOffset);
}
super.shutdown();
@@ -1624,17 +1590,15 @@ public class DefaultMessageStore implements MessageStore {
return DefaultMessageStore.this.commitLog.getMaxOffset() - this.reputFromOffset;
}
-
private boolean isCommitLogAvailable() {
return this.reputFromOffset < DefaultMessageStore.this.commitLog.getMaxOffset();
}
-
private void doReput() {
for (boolean doNext = true; this.isCommitLogAvailable() && doNext; ) {
if (DefaultMessageStore.this.getMessageStoreConfig().isDuplicationEnable() //
- && this.reputFromOffset >= DefaultMessageStore.this.getConfirmOffset()) {
+ && this.reputFromOffset >= DefaultMessageStore.this.getConfirmOffset()) {
break;
}
@@ -1645,7 +1609,7 @@ public class DefaultMessageStore implements MessageStore {
for (int readSize = 0; readSize < result.getSize() && doNext; ) {
DispatchRequest dispatchRequest =
- DefaultMessageStore.this.commitLog.checkMessageAndReturnSize(result.getByteBuffer(), false, false);
+ DefaultMessageStore.this.commitLog.checkMessageAndReturnSize(result.getByteBuffer(), false, false);
int size = dispatchRequest.getMsgSize();
if (dispatchRequest.isSuccess()) {
@@ -1653,20 +1617,20 @@ public class DefaultMessageStore implements MessageStore {
DefaultMessageStore.this.doDispatch(dispatchRequest);
if (BrokerRole.SLAVE != DefaultMessageStore.this.getMessageStoreConfig().getBrokerRole()
- && DefaultMessageStore.this.brokerConfig.isLongPollingEnable()) {
+ && DefaultMessageStore.this.brokerConfig.isLongPollingEnable()) {
DefaultMessageStore.this.messageArrivingListener.arriving(dispatchRequest.getTopic(),
- dispatchRequest.getQueueId(), dispatchRequest.getConsumeQueueOffset() + 1,
- dispatchRequest.getTagsCode());
+ dispatchRequest.getQueueId(), dispatchRequest.getConsumeQueueOffset() + 1,
+ dispatchRequest.getTagsCode());
}
// FIXED BUG By shijia
this.reputFromOffset += size;
readSize += size;
if (DefaultMessageStore.this.getMessageStoreConfig().getBrokerRole() == BrokerRole.SLAVE) {
DefaultMessageStore.this.storeStatsService
- .getSinglePutMessageTopicTimesTotal(dispatchRequest.getTopic()).incrementAndGet();
+ .getSinglePutMessageTopicTimesTotal(dispatchRequest.getTopic()).incrementAndGet();
DefaultMessageStore.this.storeStatsService
- .getSinglePutMessageTopicSizeTotal(dispatchRequest.getTopic())
- .addAndGet(dispatchRequest.getMsgSize());
+ .getSinglePutMessageTopicSizeTotal(dispatchRequest.getTopic())
+ .addAndGet(dispatchRequest.getMsgSize());
}
} else if (size == 0) {
this.reputFromOffset = DefaultMessageStore.this.commitLog.rollNextFile(this.reputFromOffset);
@@ -1674,7 +1638,6 @@ public class DefaultMessageStore implements MessageStore {
}
} else if (!dispatchRequest.isSuccess()) {
-
if (size > 0) {
log.error("[BUG]read total count not equals msg total size. reputFromOffset={}", reputFromOffset);
this.reputFromOffset += size;
@@ -1682,7 +1645,7 @@ public class DefaultMessageStore implements MessageStore {
doNext = false;
if (DefaultMessageStore.this.brokerConfig.getBrokerId() == MixAll.MASTER_ID) {
log.error("[BUG]the master dispatch message to consume queue error, COMMITLOG OFFSET: {}",
- this.reputFromOffset);
+ this.reputFromOffset);
this.reputFromOffset += result.getSize() - readSize;
}
@@ -1698,7 +1661,6 @@ public class DefaultMessageStore implements MessageStore {
}
}
-
@Override
public void run() {
DefaultMessageStore.log.info(this.getServiceName() + " service started");
@@ -1715,13 +1677,11 @@ public class DefaultMessageStore implements MessageStore {
DefaultMessageStore.log.info(this.getServiceName() + " service end");
}
-
@Override
public String getServiceName() {
return ReputMessageService.class.getSimpleName();
}
-
}
public int remainTransientStoreBufferNumbs() {
@@ -1733,7 +1693,6 @@ public class DefaultMessageStore implements MessageStore {
return remainTransientStoreBufferNumbs() == 0;
}
-
public void unlockMappedFile(final MappedFile mappedFile) {
this.scheduledExecutorService.schedule(new Runnable() {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/DispatchRequest.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/DispatchRequest.java b/store/src/main/java/org/apache/rocketmq/store/DispatchRequest.java
index d0855ab..b086aee 100644
--- a/store/src/main/java/org/apache/rocketmq/store/DispatchRequest.java
+++ b/store/src/main/java/org/apache/rocketmq/store/DispatchRequest.java
@@ -31,19 +31,18 @@ public class DispatchRequest {
private final int sysFlag;
private final long preparedTransactionOffset;
-
public DispatchRequest(
- final String topic,
- final int queueId,
- final long commitLogOffset,
- final int msgSize,
- final long tagsCode,
- final long storeTimestamp,
- final long consumeQueueOffset,
- final String keys,
- final String uniqKey,
- final int sysFlag,
- final long preparedTransactionOffset
+ final String topic,
+ final int queueId,
+ final long commitLogOffset,
+ final int msgSize,
+ final long tagsCode,
+ final long storeTimestamp,
+ final long consumeQueueOffset,
+ final String keys,
+ final String uniqKey,
+ final int sysFlag,
+ final long preparedTransactionOffset
) {
this.topic = topic;
this.queueId = queueId;
@@ -108,57 +107,46 @@ public class DispatchRequest {
this.success = success;
}
-
public String getTopic() {
return topic;
}
-
public int getQueueId() {
return queueId;
}
-
public long getCommitLogOffset() {
return commitLogOffset;
}
-
public int getMsgSize() {
return msgSize;
}
-
public long getStoreTimestamp() {
return storeTimestamp;
}
-
public long getConsumeQueueOffset() {
return consumeQueueOffset;
}
-
public String getKeys() {
return keys;
}
-
public long getTagsCode() {
return tagsCode;
}
-
public int getSysFlag() {
return sysFlag;
}
-
public long getPreparedTransactionOffset() {
return preparedTransactionOffset;
}
-
public boolean isSuccess() {
return success;
}
@@ -167,5 +155,4 @@ public class DispatchRequest {
return uniqKey;
}
-
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java b/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java
index 0f1ba8c..b7d33f3 100644
--- a/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java
@@ -6,27 +6,25 @@
* (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
+ * 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.
+ * 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.store;
-import org.apache.rocketmq.store.stats.BrokerStatsManager;
-
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
-
+import org.apache.rocketmq.store.stats.BrokerStatsManager;
public class GetMessageResult {
private final List<SelectMappedBufferResult> messageMapedList =
- new ArrayList<SelectMappedBufferResult>(100);
+ new ArrayList<SelectMappedBufferResult>(100);
private final List<ByteBuffer> messageBufferList = new ArrayList<ByteBuffer>(100);
@@ -41,97 +39,79 @@ public class GetMessageResult {
private int msgCount4Commercial = 0;
-
public GetMessageResult() {
}
-
public GetMessageStatus getStatus() {
return status;
}
-
public void setStatus(GetMessageStatus status) {
this.status = status;
}
-
public long getNextBeginOffset() {
return nextBeginOffset;
}
-
public void setNextBeginOffset(long nextBeginOffset) {
this.nextBeginOffset = nextBeginOffset;
}
-
public long getMinOffset() {
return minOffset;
}
-
public void setMinOffset(long minOffset) {
this.minOffset = minOffset;
}
-
public long getMaxOffset() {
return maxOffset;
}
-
public void setMaxOffset(long maxOffset) {
this.maxOffset = maxOffset;
}
-
public List<SelectMappedBufferResult> getMessageMapedList() {
return messageMapedList;
}
-
public List<ByteBuffer> getMessageBufferList() {
return messageBufferList;
}
-
public void addMessage(final SelectMappedBufferResult mapedBuffer) {
this.messageMapedList.add(mapedBuffer);
this.messageBufferList.add(mapedBuffer.getByteBuffer());
this.bufferTotalSize += mapedBuffer.getSize();
- this.msgCount4Commercial += (int) Math.ceil(
- mapedBuffer.getSize() / BrokerStatsManager.SIZE_PER_COUNT);
+ this.msgCount4Commercial += (int)Math.ceil(
+ mapedBuffer.getSize() / BrokerStatsManager.SIZE_PER_COUNT);
}
-
public void release() {
for (SelectMappedBufferResult select : this.messageMapedList) {
select.release();
}
}
-
public int getBufferTotalSize() {
return bufferTotalSize;
}
-
public void setBufferTotalSize(int bufferTotalSize) {
this.bufferTotalSize = bufferTotalSize;
}
-
public int getMessageCount() {
return this.messageMapedList.size();
}
-
public boolean isSuggestPullingFromSlave() {
return suggestPullingFromSlave;
}
-
public void setSuggestPullingFromSlave(boolean suggestPullingFromSlave) {
this.suggestPullingFromSlave = suggestPullingFromSlave;
}
@@ -144,12 +124,11 @@ public class GetMessageResult {
this.msgCount4Commercial = msgCount4Commercial;
}
-
@Override
public String toString() {
return "GetMessageResult [status=" + status + ", nextBeginOffset=" + nextBeginOffset + ", minOffset="
- + minOffset + ", maxOffset=" + maxOffset + ", bufferTotalSize=" + bufferTotalSize
- + ", suggestPullingFromSlave=" + suggestPullingFromSlave + "]";
+ + minOffset + ", maxOffset=" + maxOffset + ", bufferTotalSize=" + bufferTotalSize
+ + ", suggestPullingFromSlave=" + suggestPullingFromSlave + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/GetMessageStatus.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/GetMessageStatus.java b/store/src/main/java/org/apache/rocketmq/store/GetMessageStatus.java
index 003d1d4..f512e12 100644
--- a/store/src/main/java/org/apache/rocketmq/store/GetMessageStatus.java
+++ b/store/src/main/java/org/apache/rocketmq/store/GetMessageStatus.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.store;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/MappedFile.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/MappedFile.java b/store/src/main/java/org/apache/rocketmq/store/MappedFile.java
index ce5f570..6803ec9 100644
--- a/store/src/main/java/org/apache/rocketmq/store/MappedFile.java
+++ b/store/src/main/java/org/apache/rocketmq/store/MappedFile.java
@@ -16,16 +16,8 @@
*/
package org.apache.rocketmq.store;
-import org.apache.rocketmq.common.UtilAll;
-import org.apache.rocketmq.common.constant.LoggerName;
-import org.apache.rocketmq.store.config.FlushDiskType;
-import org.apache.rocketmq.store.util.LibC;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import sun.nio.ch.DirectBuffer;
-
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -39,7 +31,13 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
-
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.store.config.FlushDiskType;
+import org.apache.rocketmq.store.util.LibC;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import sun.nio.ch.DirectBuffer;
public class MappedFile extends ReferenceResource {
public static final int OS_PAGE_SIZE = 1024 * 4;
@@ -48,34 +46,23 @@ public class MappedFile extends ReferenceResource {
private static final AtomicLong TOTAL_MAPED_VITUAL_MEMORY = new AtomicLong(0);
private static final AtomicInteger TOTAL_MAPED_FILES = new AtomicInteger(0);
-
- private String fileName;
-
- private long fileFromOffset;
-
- protected int fileSize;
-
- private File file;
-
- private MappedByteBuffer mappedByteBuffer;
-
protected final AtomicInteger wrotePosition = new AtomicInteger(0);
-
- private final AtomicInteger flushedPosition = new AtomicInteger(0);
//ADD BY ChenYang
protected final AtomicInteger committedPosition = new AtomicInteger(0);
-
-
+ private final AtomicInteger flushedPosition = new AtomicInteger(0);
+ protected int fileSize;
protected FileChannel fileChannel;
-
- private volatile long storeTimestamp = 0;
- private boolean firstCreateInQueue = false;
-
/**
* Message will put to here first, and then reput to FileChannel if writeBuffer is not null.
*/
protected ByteBuffer writeBuffer = null;
protected TransientStorePool transientStorePool = null;
+ private String fileName;
+ private long fileFromOffset;
+ private File file;
+ private MappedByteBuffer mappedByteBuffer;
+ private volatile long storeTimestamp = 0;
+ private boolean firstCreateInQueue = false;
public MappedFile() {
}
@@ -88,41 +75,6 @@ public class MappedFile extends ReferenceResource {
init(fileName, fileSize, transientStorePool);
}
- public void init(final String fileName, final int fileSize, final TransientStorePool transientStorePool) throws IOException {
- init(fileName, fileSize);
- this.writeBuffer = transientStorePool.borrowBuffer();
- this.transientStorePool = transientStorePool;
- }
-
- private void init(final String fileName, final int fileSize) throws IOException {
- this.fileName = fileName;
- this.fileSize = fileSize;
- this.file = new File(fileName);
- this.fileFromOffset = Long.parseLong(this.file.getName());
- boolean ok = false;
-
- ensureDirOK(this.file.getParent());
-
- try {
- this.fileChannel = new RandomAccessFile(this.file, "rw").getChannel();
- this.mappedByteBuffer = this.fileChannel.map(MapMode.READ_WRITE, 0, fileSize);
- TOTAL_MAPED_VITUAL_MEMORY.addAndGet(fileSize);
- TOTAL_MAPED_FILES.incrementAndGet();
- ok = true;
- } catch (FileNotFoundException e) {
- log.error("create file channel " + this.fileName + " Failed. ", e);
- throw e;
- } catch (IOException e) {
- log.error("map file " + this.fileName + " Failed. ", e);
- throw e;
- } finally {
- if (!ok && this.fileChannel != null) {
- this.fileChannel.close();
- }
- }
- }
-
-
public static void ensureDirOK(final String dirName) {
if (dirName != null) {
File f = new File(dirName);
@@ -133,14 +85,12 @@ public class MappedFile extends ReferenceResource {
}
}
-
public static void clean(final ByteBuffer buffer) {
if (buffer == null || !buffer.isDirect() || buffer.capacity() == 0)
return;
invoke(invoke(viewed(buffer), "cleaner"), "clean");
}
-
private static Object invoke(final Object target, final String methodName, final Class<?>... args) {
return AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
@@ -155,9 +105,8 @@ public class MappedFile extends ReferenceResource {
});
}
-
private static Method method(Object target, String methodName, Class<?>[] args)
- throws NoSuchMethodException {
+ throws NoSuchMethodException {
try {
return target.getClass().getMethod(methodName, args);
} catch (NoSuchMethodException e) {
@@ -165,11 +114,9 @@ public class MappedFile extends ReferenceResource {
}
}
-
private static ByteBuffer viewed(ByteBuffer buffer) {
String methodName = "viewedBuffer";
-
Method[] methods = buffer.getClass().getMethods();
for (int i = 0; i < methods.length; i++) {
if (methods[i].getName().equals("attachment")) {
@@ -178,23 +125,54 @@ public class MappedFile extends ReferenceResource {
}
}
- ByteBuffer viewedBuffer = (ByteBuffer) invoke(buffer, methodName);
+ ByteBuffer viewedBuffer = (ByteBuffer)invoke(buffer, methodName);
if (viewedBuffer == null)
return buffer;
else
return viewed(viewedBuffer);
}
-
public static int getTotalmapedfiles() {
return TOTAL_MAPED_FILES.get();
}
-
public static long getTotalMapedVitualMemory() {
return TOTAL_MAPED_VITUAL_MEMORY.get();
}
+ public void init(final String fileName, final int fileSize, final TransientStorePool transientStorePool) throws IOException {
+ init(fileName, fileSize);
+ this.writeBuffer = transientStorePool.borrowBuffer();
+ this.transientStorePool = transientStorePool;
+ }
+
+ private void init(final String fileName, final int fileSize) throws IOException {
+ this.fileName = fileName;
+ this.fileSize = fileSize;
+ this.file = new File(fileName);
+ this.fileFromOffset = Long.parseLong(this.file.getName());
+ boolean ok = false;
+
+ ensureDirOK(this.file.getParent());
+
+ try {
+ this.fileChannel = new RandomAccessFile(this.file, "rw").getChannel();
+ this.mappedByteBuffer = this.fileChannel.map(MapMode.READ_WRITE, 0, fileSize);
+ TOTAL_MAPED_VITUAL_MEMORY.addAndGet(fileSize);
+ TOTAL_MAPED_FILES.incrementAndGet();
+ ok = true;
+ } catch (FileNotFoundException e) {
+ log.error("create file channel " + this.fileName + " Failed. ", e);
+ throw e;
+ } catch (IOException e) {
+ log.error("map file " + this.fileName + " Failed. ", e);
+ throw e;
+ } finally {
+ if (!ok && this.fileChannel != null) {
+ this.fileChannel.close();
+ }
+ }
+ }
public long getLastModifiedTimestamp() {
return this.file.lastModified();
@@ -214,20 +192,18 @@ public class MappedFile extends ReferenceResource {
int currentPos = this.wrotePosition.get();
-
if (currentPos < this.fileSize) {
ByteBuffer byteBuffer = writeBuffer != null ? writeBuffer.slice() : this.mappedByteBuffer.slice();
byteBuffer.position(currentPos);
AppendMessageResult result =
- cb.doAppend(this.getFileFromOffset(), byteBuffer, this.fileSize - currentPos, msg);
+ cb.doAppend(this.getFileFromOffset(), byteBuffer, this.fileSize - currentPos, msg);
this.wrotePosition.addAndGet(result.getWroteBytes());
this.storeTimestamp = result.getStoreTimestamp();
return result;
}
-
log.error("MappedFile.appendMessage return null, wrotePosition: " + currentPos + " fileSize: "
- + this.fileSize);
+ + this.fileSize);
return new AppendMessageResult(AppendMessageStatus.UNKNOWN_ERROR);
}
@@ -246,7 +222,6 @@ public class MappedFile extends ReferenceResource {
public boolean appendMessage(final byte[] data) {
int currentPos = this.wrotePosition.get();
-
if ((currentPos + data.length) <= this.fileSize) {
try {
this.fileChannel.position(currentPos);
@@ -262,11 +237,7 @@ public class MappedFile extends ReferenceResource {
}
/**
-
- *
* @param flushLeastPages
-
- *
* @return The current flushed position
*/
public int flush(final int flushLeastPages) {
@@ -370,12 +341,10 @@ public class MappedFile extends ReferenceResource {
return flushedPosition.get();
}
-
public void setFlushedPosition(int pos) {
this.flushedPosition.set(pos);
}
-
public boolean isFull() {
return this.fileSize == this.wrotePosition.get();
}
@@ -392,14 +361,13 @@ public class MappedFile extends ReferenceResource {
return new SelectMappedBufferResult(this.fileFromOffset + pos, byteBufferNew, size, this);
} else {
log.warn("matched, but hold failed, request pos: " + pos + ", fileFromOffset: "
- + this.fileFromOffset);
+ + this.fileFromOffset);
}
} else {
log.warn("selectMappedBuffer request pos invalid, request pos: " + pos + ", size: " + size
- + ", fileFromOffset: " + this.fileFromOffset);
+ + ", fileFromOffset: " + this.fileFromOffset);
}
-
return null;
}
@@ -419,7 +387,6 @@ public class MappedFile extends ReferenceResource {
}
}
-
return null;
}
@@ -427,13 +394,13 @@ public class MappedFile extends ReferenceResource {
public boolean cleanup(final long currentRef) {
if (this.isAvailable()) {
log.error("this file[REF:" + currentRef + "] " + this.fileName
- + " have not shutdown, stop unmaping.");
+ + " have not shutdown, stop unmaping.");
return false;
}
if (this.isCleanupOver()) {
log.error("this file[REF:" + currentRef + "] " + this.fileName
- + " have cleanup, do not do it again.");
+ + " have cleanup, do not do it again.");
return true;
}
@@ -455,9 +422,9 @@ public class MappedFile extends ReferenceResource {
long beginTime = System.currentTimeMillis();
boolean result = this.file.delete();
log.info("delete file[REF:" + this.getRefCount() + "] " + this.fileName
- + (result ? " OK, " : " Failed, ") + "W:" + this.getWrotePosition() + " M:"
- + this.getFlushedPosition() + ", "
- + UtilAll.computeEclipseTimeMilliseconds(beginTime));
+ + (result ? " OK, " : " Failed, ") + "W:" + this.getWrotePosition() + " M:"
+ + this.getFlushedPosition() + ", "
+ + UtilAll.computeEclipseTimeMilliseconds(beginTime));
} catch (Exception e) {
log.warn("close file channel " + this.fileName + " Failed. ", e);
}
@@ -465,7 +432,7 @@ public class MappedFile extends ReferenceResource {
return true;
} else {
log.warn("destroy maped file[REF:" + this.getRefCount() + "] " + this.fileName
- + " Failed. cleanupOver: " + this.cleanupOver);
+ + " Failed. cleanupOver: " + this.cleanupOver);
}
return false;
@@ -475,18 +442,17 @@ public class MappedFile extends ReferenceResource {
return wrotePosition.get();
}
+ public void setWrotePosition(int pos) {
+ this.wrotePosition.set(pos);
+ }
+
/**
- *
* @return The max position which have valid data
*/
public int getReadPosition() {
return this.writeBuffer == null ? this.wrotePosition.get() : this.committedPosition.get();
}
- public void setWrotePosition(int pos) {
- this.wrotePosition.set(pos);
- }
-
public void setCommittedPosition(int pos) {
this.committedPosition.set(pos);
}
@@ -497,7 +463,7 @@ public class MappedFile extends ReferenceResource {
int flush = 0;
long time = System.currentTimeMillis();
for (int i = 0, j = 0; i < this.fileSize; i += MappedFile.OS_PAGE_SIZE, j++) {
- byteBuffer.put(i, (byte) 0);
+ byteBuffer.put(i, (byte)0);
// force flush when flush disk type is sync
if (type == FlushDiskType.SYNC_FLUSH) {
if ((i / OS_PAGE_SIZE) - (flush / OS_PAGE_SIZE) >= pages) {
@@ -521,11 +487,11 @@ public class MappedFile extends ReferenceResource {
// force flush when prepare load finished
if (type == FlushDiskType.SYNC_FLUSH) {
log.info("mapped file worm up done, force to disk, mappedFile={}, costTime={}",
- this.getFileName(), System.currentTimeMillis() - beginTime);
+ this.getFileName(), System.currentTimeMillis() - beginTime);
mappedByteBuffer.force();
}
log.info("mapped file worm up done. mappedFile={}, costTime={}", this.getFileName(),
- System.currentTimeMillis() - beginTime);
+ System.currentTimeMillis() - beginTime);
this.mlock();
}
@@ -542,25 +508,21 @@ public class MappedFile extends ReferenceResource {
return this.mappedByteBuffer.slice();
}
-
public long getStoreTimestamp() {
return storeTimestamp;
}
-
public boolean isFirstCreateInQueue() {
return firstCreateInQueue;
}
-
public void setFirstCreateInQueue(boolean firstCreateInQueue) {
this.firstCreateInQueue = firstCreateInQueue;
}
-
public void mlock() {
final long beginTime = System.currentTimeMillis();
- final long address = ((DirectBuffer) (this.mappedByteBuffer)).address();
+ final long address = ((DirectBuffer)(this.mappedByteBuffer)).address();
Pointer pointer = new Pointer(address);
{
int ret = LibC.INSTANCE.mlock(pointer, new NativeLong(this.fileSize));
@@ -575,7 +537,7 @@ public class MappedFile extends ReferenceResource {
public void munlock() {
final long beginTime = System.currentTimeMillis();
- final long address = ((DirectBuffer) (this.mappedByteBuffer)).address();
+ final long address = ((DirectBuffer)(this.mappedByteBuffer)).address();
Pointer pointer = new Pointer(address);
int ret = LibC.INSTANCE.munlock(pointer, new NativeLong(this.fileSize));
log.info("munlock {} {} {} ret = {} time consuming = {}", address, this.fileName, this.fileSize, ret, System.currentTimeMillis() - beginTime);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java b/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
index a208a07..49455c6 100644
--- a/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
+++ b/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
@@ -16,17 +16,19 @@
*/
package org.apache.rocketmq.store;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.constant.LoggerName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.IOException;
-import java.util.*;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-
public class MappedFileQueue {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
private static final Logger LOG_ERROR = LoggerFactory.getLogger(LoggerName.STORE_ERROR_LOGGER_NAME);
@@ -46,15 +48,13 @@ public class MappedFileQueue {
private volatile long storeTimestamp = 0;
-
public MappedFileQueue(final String storePath, int mappedFileSize,
- AllocateMappedFileService allocateMappedFileService) {
+ AllocateMappedFileService allocateMappedFileService) {
this.storePath = storePath;
this.mappedFileSize = mappedFileSize;
this.allocateMappedFileService = allocateMappedFileService;
}
-
public void checkSelf() {
if (!this.mappedFiles.isEmpty()) {
@@ -66,7 +66,7 @@ public class MappedFileQueue {
if (pre != null) {
if (cur.getFileFromOffset() - pre.getFileFromOffset() != this.mappedFileSize) {
LOG_ERROR.error("[BUG]The mappedFile queue's data is damaged, the adjacent mappedFile's offset don't match. pre file {}, cur file {}",
- pre.getFileName(), cur.getFileName());
+ pre.getFileName(), cur.getFileName());
}
}
pre = cur;
@@ -74,7 +74,6 @@ public class MappedFileQueue {
}
}
-
public MappedFile getMappedFileByTime(final long timestamp) {
Object[] mfs = this.copyMappedFiles(0);
@@ -82,16 +81,15 @@ public class MappedFileQueue {
return null;
for (int i = 0; i < mfs.length; i++) {
- MappedFile mappedFile = (MappedFile) mfs[i];
+ MappedFile mappedFile = (MappedFile)mfs[i];
if (mappedFile.getLastModifiedTimestamp() >= timestamp) {
return mappedFile;
}
}
- return (MappedFile) mfs[mfs.length - 1];
+ return (MappedFile)mfs[mfs.length - 1];
}
-
private Object[] copyMappedFiles(final int reservedMappedFiles) {
Object[] mfs;
@@ -103,7 +101,6 @@ public class MappedFileQueue {
return mfs;
}
-
public void truncateDirtyFiles(long offset) {
List<MappedFile> willRemoveFiles = new ArrayList<MappedFile>();
@@ -111,9 +108,9 @@ public class MappedFileQueue {
long fileTailOffset = file.getFileFromOffset() + this.mappedFileSize;
if (fileTailOffset > offset) {
if (offset >= file.getFileFromOffset()) {
- file.setWrotePosition((int) (offset % this.mappedFileSize));
- file.setCommittedPosition((int) (offset % this.mappedFileSize));
- file.setFlushedPosition((int) (offset % this.mappedFileSize));
+ file.setWrotePosition((int)(offset % this.mappedFileSize));
+ file.setCommittedPosition((int)(offset % this.mappedFileSize));
+ file.setFlushedPosition((int)(offset % this.mappedFileSize));
} else {
file.destroy(1000);
willRemoveFiles.add(file);
@@ -124,7 +121,6 @@ public class MappedFileQueue {
this.deleteExpiredFile(willRemoveFiles);
}
-
private void deleteExpiredFile(List<MappedFile> files) {
if (!files.isEmpty()) {
@@ -148,7 +144,6 @@ public class MappedFileQueue {
}
}
-
public boolean load() {
File dir = new File(this.storePath);
File[] files = dir.listFiles();
@@ -159,11 +154,10 @@ public class MappedFileQueue {
if (file.length() != this.mappedFileSize) {
log.warn(file + "\t" + file.length()
- + " length not matched message store config value, ignore it");
+ + " length not matched message store config value, ignore it");
return true;
}
-
try {
MappedFile mappedFile = new MappedFile(file.getPath(), mappedFileSize);
@@ -182,7 +176,6 @@ public class MappedFileQueue {
return true;
}
-
public long howMuchFallBehind() {
if (this.mappedFiles.isEmpty())
return 0;
@@ -198,7 +191,6 @@ public class MappedFileQueue {
return 0;
}
-
public MappedFile getLastMappedFile(final long startOffset, boolean needCreate) {
long createOffset = -1;
MappedFile mappedFileLast = getLastMappedFile();
@@ -214,12 +206,12 @@ public class MappedFileQueue {
if (createOffset != -1 && needCreate) {
String nextFilePath = this.storePath + File.separator + UtilAll.offset2FileName(createOffset);
String nextNextFilePath = this.storePath + File.separator
- + UtilAll.offset2FileName(createOffset + this.mappedFileSize);
+ + UtilAll.offset2FileName(createOffset + this.mappedFileSize);
MappedFile mappedFile = null;
if (this.allocateMappedFileService != null) {
mappedFile = this.allocateMappedFileService.putRequestAndReturnMappedFile(nextFilePath,
- nextNextFilePath, this.mappedFileSize);
+ nextNextFilePath, this.mappedFileSize);
} else {
try {
mappedFile = new MappedFile(nextFilePath, this.mappedFileSize);
@@ -268,11 +260,12 @@ public class MappedFileQueue {
if (mappedFileLast != null) {
long lastOffset = mappedFileLast.getFileFromOffset() +
- mappedFileLast.getWrotePosition();
+ mappedFileLast.getWrotePosition();
long diff = lastOffset - offset;
final int maxDiff = this.mappedFileSize * 2;
- if (diff > maxDiff) return false;
+ if (diff > maxDiff)
+ return false;
}
ListIterator<MappedFile> iterator = this.mappedFiles.listIterator();
@@ -280,7 +273,7 @@ public class MappedFileQueue {
while (iterator.hasPrevious()) {
mappedFileLast = iterator.previous();
if (offset >= mappedFileLast.getFileFromOffset()) {
- int where = (int) (offset % mappedFileLast.getFileSize());
+ int where = (int)(offset % mappedFileLast.getFileSize());
mappedFileLast.setFlushedPosition(where);
mappedFileLast.setWrotePosition(where);
mappedFileLast.setCommittedPosition(where);
@@ -306,7 +299,6 @@ public class MappedFileQueue {
return -1;
}
-
public long getMaxOffset() {
MappedFile mappedFile = getLastMappedFile();
if (mappedFile != null) {
@@ -342,9 +334,9 @@ public class MappedFileQueue {
}
public int deleteExpiredFileByTime(final long expiredTime,
- final int deleteFilesInterval,
- final long intervalForcibly,
- final boolean cleanImmediately) {
+ final int deleteFilesInterval,
+ final long intervalForcibly,
+ final boolean cleanImmediately) {
Object[] mfs = this.copyMappedFiles(0);
if (null == mfs)
@@ -355,7 +347,7 @@ public class MappedFileQueue {
List<MappedFile> files = new ArrayList<MappedFile>();
if (null != mfs) {
for (int i = 0; i < mfsLength; i++) {
- MappedFile mappedFile = (MappedFile) mfs[i];
+ MappedFile mappedFile = (MappedFile)mfs[i];
long liveMaxTimestamp = mappedFile.getLastModifiedTimestamp() + expiredTime;
if (System.currentTimeMillis() >= liveMaxTimestamp || cleanImmediately) {
if (mappedFile.destroy(intervalForcibly)) {
@@ -384,7 +376,6 @@ public class MappedFileQueue {
return deleteCount;
}
-
public int deleteExpiredFileByOffset(long offset, int unitSize) {
Object[] mfs = this.copyMappedFiles(0);
@@ -396,7 +387,7 @@ public class MappedFileQueue {
for (int i = 0; i < mfsLength; i++) {
boolean destroy;
- MappedFile mappedFile = (MappedFile) mfs[i];
+ MappedFile mappedFile = (MappedFile)mfs[i];
SelectMappedBufferResult result = mappedFile.selectMappedBuffer(this.mappedFileSize - unitSize);
if (result != null) {
long maxOffsetInLogicQueue = result.getByteBuffer().getLong();
@@ -404,7 +395,7 @@ public class MappedFileQueue {
destroy = maxOffsetInLogicQueue < offset;
if (destroy) {
log.info("physic min offset " + offset + ", logics in current mappedFile max offset "
- + maxOffsetInLogicQueue + ", delete it");
+ + maxOffsetInLogicQueue + ", delete it");
}
} else {
log.warn("this being not executed forever.");
@@ -425,7 +416,6 @@ public class MappedFileQueue {
return deleteCount;
}
-
public boolean flush(final int flushLeastPages) {
boolean result = true;
MappedFile mappedFile = this.findMappedFileByOffset(this.flushedWhere, false);
@@ -467,10 +457,10 @@ public class MappedFileQueue {
try {
MappedFile mappedFile = this.getFirstMappedFile();
if (mappedFile != null) {
- int index = (int) ((offset / this.mappedFileSize) - (mappedFile.getFileFromOffset() / this.mappedFileSize));
+ int index = (int)((offset / this.mappedFileSize) - (mappedFile.getFileFromOffset() / this.mappedFileSize));
if (index < 0 || index >= this.mappedFiles.size()) {
LOG_ERROR.warn("Offset for {} not matched. Request offset: {}, index: {}, " +
- "mappedFileSize: {}, mappedFiles count: {}",
+ "mappedFileSize: {}, mappedFiles count: {}",
mappedFile,
offset,
index,
@@ -494,7 +484,6 @@ public class MappedFileQueue {
return null;
}
-
public MappedFile getFirstMappedFile() {
MappedFile mappedFileFirst = null;
@@ -515,14 +504,13 @@ public class MappedFileQueue {
return findMappedFileByOffset(offset, false);
}
-
public long getMappedMemorySize() {
long size = 0;
Object[] mfs = this.copyMappedFiles(0);
if (mfs != null) {
for (Object mf : mfs) {
- if (((ReferenceResource) mf).isAvailable()) {
+ if (((ReferenceResource)mf).isAvailable()) {
size += this.mappedFileSize;
}
}
@@ -531,7 +519,6 @@ public class MappedFileQueue {
return size;
}
-
public boolean retryDeleteFirstFile(final long intervalForcibly) {
MappedFile mappedFile = this.getFirstMappedFile();
if (mappedFile != null) {
@@ -554,14 +541,12 @@ public class MappedFileQueue {
return false;
}
-
public void shutdown(final long intervalForcibly) {
for (MappedFile mf : this.mappedFiles) {
mf.shutdown(intervalForcibly);
}
}
-
public void destroy() {
for (MappedFile mf : this.mappedFiles) {
mf.destroy(1000 * 3);
@@ -576,27 +561,22 @@ public class MappedFileQueue {
}
}
-
public long getFlushedWhere() {
return flushedWhere;
}
-
public void setFlushedWhere(long flushedWhere) {
this.flushedWhere = flushedWhere;
}
-
public long getStoreTimestamp() {
return storeTimestamp;
}
-
public List<MappedFile> getMappedFiles() {
return mappedFiles;
}
-
public int getMappedFileSize() {
return mappedFileSize;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/MessageArrivingListener.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/MessageArrivingListener.java b/store/src/main/java/org/apache/rocketmq/store/MessageArrivingListener.java
index 25304b9..ebc57a7 100644
--- a/store/src/main/java/org/apache/rocketmq/store/MessageArrivingListener.java
+++ b/store/src/main/java/org/apache/rocketmq/store/MessageArrivingListener.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.store;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/MessageExtBrokerInner.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/MessageExtBrokerInner.java b/store/src/main/java/org/apache/rocketmq/store/MessageExtBrokerInner.java
index dabb418..4cbdacf 100644
--- a/store/src/main/java/org/apache/rocketmq/store/MessageExtBrokerInner.java
+++ b/store/src/main/java/org/apache/rocketmq/store/MessageExtBrokerInner.java
@@ -6,20 +6,19 @@
* (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
+ * 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.
+ * 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.store;
import org.apache.rocketmq.common.TopicFilterType;
import org.apache.rocketmq.common.message.MessageExt;
-
public class MessageExtBrokerInner extends MessageExt {
private static final long serialVersionUID = 7256001576878700634L;
private String propertiesString;
@@ -32,22 +31,18 @@ public class MessageExtBrokerInner extends MessageExt {
return tags.hashCode();
}
-
public String getPropertiesString() {
return propertiesString;
}
-
public void setPropertiesString(String propertiesString) {
this.propertiesString = propertiesString;
}
-
public long getTagsCode() {
return tagsCode;
}
-
public void setTagsCode(long tagsCode) {
this.tagsCode = tagsCode;
}
[32/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/factory/MQClientInstance.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/factory/MQClientInstance.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/factory/MQClientInstance.java
deleted file mode 100644
index 508e249..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/factory/MQClientInstance.java
+++ /dev/null
@@ -1,1147 +0,0 @@
-/**
- * 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.client.impl.factory;
-
-import com.alibaba.rocketmq.client.ClientConfig;
-import com.alibaba.rocketmq.client.admin.MQAdminExtInner;
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.impl.*;
-import com.alibaba.rocketmq.client.impl.consumer.*;
-import com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl;
-import com.alibaba.rocketmq.client.impl.producer.MQProducerInner;
-import com.alibaba.rocketmq.client.impl.producer.TopicPublishInfo;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
-import com.alibaba.rocketmq.client.stat.ConsumerStatsManager;
-import com.alibaba.rocketmq.common.MQVersion;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.ServiceState;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.constant.PermName;
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
-import com.alibaba.rocketmq.common.protocol.body.ConsumerRunningInfo;
-import com.alibaba.rocketmq.common.protocol.heartbeat.*;
-import com.alibaba.rocketmq.common.protocol.route.BrokerData;
-import com.alibaba.rocketmq.common.protocol.route.QueueData;
-import com.alibaba.rocketmq.common.protocol.route.TopicRouteData;
-import com.alibaba.rocketmq.remoting.RPCHook;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import com.alibaba.rocketmq.remoting.exception.RemotingException;
-import com.alibaba.rocketmq.remoting.netty.NettyClientConfig;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import org.slf4j.Logger;
-
-import java.io.UnsupportedEncodingException;
-import java.net.DatagramSocket;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-
-/**
- * @author shijia.wxr
- */
-public class MQClientInstance {
- private final static long LOCK_TIMEOUT_MILLIS = 3000;
- private final Logger log = ClientLogger.getLog();
- private final ClientConfig clientConfig;
- private final int instanceIndex;
- private final String clientId;
- private final long bootTimestamp = System.currentTimeMillis();
- private final ConcurrentHashMap<String/* group */, MQProducerInner> producerTable = new ConcurrentHashMap<String, MQProducerInner>();
- private final ConcurrentHashMap<String/* group */, MQConsumerInner> consumerTable = new ConcurrentHashMap<String, MQConsumerInner>();
- private final ConcurrentHashMap<String/* group */, MQAdminExtInner> adminExtTable = new ConcurrentHashMap<String, MQAdminExtInner>();
- private final NettyClientConfig nettyClientConfig;
- private final MQClientAPIImpl mQClientAPIImpl;
- private final MQAdminImpl mQAdminImpl;
- private final ConcurrentHashMap<String/* Topic */, TopicRouteData> topicRouteTable = new ConcurrentHashMap<String, TopicRouteData>();
- private final Lock lockNamesrv = new ReentrantLock();
- private final Lock lockHeartbeat = new ReentrantLock();
- private final ConcurrentHashMap<String/* Broker Name */, HashMap<Long/* brokerId */, String/* address */>> brokerAddrTable =
- new ConcurrentHashMap<String, HashMap<Long, String>>();
- private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
- @Override
- public Thread newThread(Runnable r) {
- return new Thread(r, "MQClientFactoryScheduledThread");
- }
- });
- private final ClientRemotingProcessor clientRemotingProcessor;
- private final PullMessageService pullMessageService;
- private final RebalanceService rebalanceService;
- private final DefaultMQProducer defaultMQProducer;
- private final ConsumerStatsManager consumerStatsManager;
- private final AtomicLong storeTimesTotal = new AtomicLong(0);
- private ServiceState serviceState = ServiceState.CREATE_JUST;
- private DatagramSocket datagramSocket;
- private Random random = new Random();
-
-
- public MQClientInstance(ClientConfig clientConfig, int instanceIndex, String clientId) {
- this(clientConfig, instanceIndex, clientId, null);
- }
-
-
- public MQClientInstance(ClientConfig clientConfig, int instanceIndex, String clientId, RPCHook rpcHook) {
- this.clientConfig = clientConfig;
- this.instanceIndex = instanceIndex;
- this.nettyClientConfig = new NettyClientConfig();
- this.nettyClientConfig.setClientCallbackExecutorThreads(clientConfig.getClientCallbackExecutorThreads());
- this.clientRemotingProcessor = new ClientRemotingProcessor(this);
- this.mQClientAPIImpl = new MQClientAPIImpl(this.nettyClientConfig, this.clientRemotingProcessor, rpcHook, clientConfig);
-
- if (this.clientConfig.getNamesrvAddr() != null) {
- this.mQClientAPIImpl.updateNameServerAddressList(this.clientConfig.getNamesrvAddr());
- log.info("user specified name server address: {}", this.clientConfig.getNamesrvAddr());
- }
-
- this.clientId = clientId;
-
- this.mQAdminImpl = new MQAdminImpl(this);
-
- this.pullMessageService = new PullMessageService(this);
-
- this.rebalanceService = new RebalanceService(this);
-
- this.defaultMQProducer = new DefaultMQProducer(MixAll.CLIENT_INNER_PRODUCER_GROUP);
- this.defaultMQProducer.resetClientConfig(clientConfig);
-
- this.consumerStatsManager = new ConsumerStatsManager(this.scheduledExecutorService);
-
- log.info("created a new client Instance, FactoryIndex: {} ClinetID: {} {} {}, serializeType={}", //
- this.instanceIndex, //
- this.clientId, //
- this.clientConfig, //
- MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION), RemotingCommand.getSerializeTypeConfigInThisServer());
- }
-
- public void start() throws MQClientException {
-
- synchronized (this) {
- switch (this.serviceState) {
- case CREATE_JUST:
- this.serviceState = ServiceState.START_FAILED;
- // If not specified,looking address from name server
- if (null == this.clientConfig.getNamesrvAddr()) {
- this.clientConfig.setNamesrvAddr(this.mQClientAPIImpl.fetchNameServerAddr());
- }
- // Start request-response channel
- this.mQClientAPIImpl.start();
- // Start various schedule tasks
- this.startScheduledTask();
- // Start pull service
- this.pullMessageService.start();
- // Start rebalance service
- this.rebalanceService.start();
- // Start push service
- this.defaultMQProducer.getDefaultMQProducerImpl().start(false);
- log.info("the client factory [{}] start OK", this.clientId);
- this.serviceState = ServiceState.RUNNING;
- break;
- case RUNNING:
- break;
- case SHUTDOWN_ALREADY:
- break;
- case START_FAILED:
- throw new MQClientException("The Factory object[" + this.getClientId() + "] has been created before, and failed.", null);
- default:
- break;
- }
- }
- }
-
-
- private void startScheduledTask() {
- if (null == this.clientConfig.getNamesrvAddr()) {
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
-
- @Override
- public void run() {
- try {
- MQClientInstance.this.mQClientAPIImpl.fetchNameServerAddr();
- } catch (Exception e) {
- log.error("ScheduledTask fetchNameServerAddr exception", e);
- }
- }
- }, 1000 * 10, 1000 * 60 * 2, TimeUnit.MILLISECONDS);
- }
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
-
- @Override
- public void run() {
- try {
- MQClientInstance.this.updateTopicRouteInfoFromNameServer();
- } catch (Exception e) {
- log.error("ScheduledTask updateTopicRouteInfoFromNameServer exception", e);
- }
- }
- }, 10, this.clientConfig.getPollNameServerInteval(), TimeUnit.MILLISECONDS);
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
-
- @Override
- public void run() {
- try {
- MQClientInstance.this.cleanOfflineBroker();
- MQClientInstance.this.sendHeartbeatToAllBrokerWithLock();
- } catch (Exception e) {
- log.error("ScheduledTask sendHeartbeatToAllBroker exception", e);
- }
- }
- }, 1000, this.clientConfig.getHeartbeatBrokerInterval(), TimeUnit.MILLISECONDS);
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
-
- @Override
- public void run() {
- try {
- MQClientInstance.this.persistAllConsumerOffset();
- } catch (Exception e) {
- log.error("ScheduledTask persistAllConsumerOffset exception", e);
- }
- }
- }, 1000 * 10, this.clientConfig.getPersistConsumerOffsetInterval(), TimeUnit.MILLISECONDS);
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
-
- @Override
- public void run() {
- try {
- MQClientInstance.this.adjustThreadPool();
- } catch (Exception e) {
- log.error("ScheduledTask adjustThreadPool exception", e);
- }
- }
- }, 1, 1, TimeUnit.MINUTES);
- }
-
- public String getClientId() {
- return clientId;
- }
-
- public void updateTopicRouteInfoFromNameServer() {
- Set<String> topicList = new HashSet<String>();
-
- // Consumer
- {
- Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, MQConsumerInner> entry = it.next();
- MQConsumerInner impl = entry.getValue();
- if (impl != null) {
- Set<SubscriptionData> subList = impl.subscriptions();
- if (subList != null) {
- for (SubscriptionData subData : subList) {
- topicList.add(subData.getTopic());
- }
- }
- }
- }
- }
-
- // Producer
- {
- Iterator<Entry<String, MQProducerInner>> it = this.producerTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, MQProducerInner> entry = it.next();
- MQProducerInner impl = entry.getValue();
- if (impl != null) {
- Set<String> lst = impl.getPublishTopicList();
- topicList.addAll(lst);
- }
- }
- }
-
- for (String topic : topicList) {
- this.updateTopicRouteInfoFromNameServer(topic);
- }
- }
-
- /**
- * Remove offline broker
- */
- private void cleanOfflineBroker() {
- try {
- if (this.lockNamesrv.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS))
- try {
- ConcurrentHashMap<String, HashMap<Long, String>> updatedTable = new ConcurrentHashMap<String, HashMap<Long, String>>();
-
- Iterator<Entry<String, HashMap<Long, String>>> itBrokerTable = this.brokerAddrTable.entrySet().iterator();
- while (itBrokerTable.hasNext()) {
- Entry<String, HashMap<Long, String>> entry = itBrokerTable.next();
- String brokerName = entry.getKey();
- HashMap<Long, String> oneTable = entry.getValue();
-
- HashMap<Long, String> cloneAddrTable = new HashMap<Long, String>();
- cloneAddrTable.putAll(oneTable);
-
- Iterator<Entry<Long, String>> it = cloneAddrTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<Long, String> ee = it.next();
- String addr = ee.getValue();
- if (!this.isBrokerAddrExistInTopicRouteTable(addr)) {
- it.remove();
- log.info("the broker addr[{} {}] is offline, remove it", brokerName, addr);
- }
- }
-
- if (cloneAddrTable.isEmpty()) {
- itBrokerTable.remove();
- log.info("the broker[{}] name's host is offline, remove it", brokerName);
- } else {
- updatedTable.put(brokerName, cloneAddrTable);
- }
- }
-
- if (!updatedTable.isEmpty()) {
- this.brokerAddrTable.putAll(updatedTable);
- }
- } finally {
- this.lockNamesrv.unlock();
- }
- } catch (InterruptedException e) {
- log.warn("cleanOfflineBroker Exception", e);
- }
- }
-
- public void sendHeartbeatToAllBrokerWithLock() {
- if (this.lockHeartbeat.tryLock()) {
- try {
- this.sendHeartbeatToAllBroker();
- this.uploadFilterClassSource();
- } catch (final Exception e) {
- log.error("sendHeartbeatToAllBroker exception", e);
- } finally {
- this.lockHeartbeat.unlock();
- }
- } else {
- log.warn("lock heartBeat, but failed.");
- }
- }
-
- private void persistAllConsumerOffset() {
- Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, MQConsumerInner> entry = it.next();
- MQConsumerInner impl = entry.getValue();
- impl.persistConsumerOffset();
- }
- }
-
- public void adjustThreadPool() {
- Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, MQConsumerInner> entry = it.next();
- MQConsumerInner impl = entry.getValue();
- if (impl != null) {
- try {
- if (impl instanceof DefaultMQPushConsumerImpl) {
- DefaultMQPushConsumerImpl dmq = (DefaultMQPushConsumerImpl) impl;
- dmq.adjustThreadPool();
- }
- } catch (Exception e) {
- }
- }
- }
- }
-
- public boolean updateTopicRouteInfoFromNameServer(final String topic) {
- return updateTopicRouteInfoFromNameServer(topic, false, null);
- }
-
- private boolean isBrokerAddrExistInTopicRouteTable(final String addr) {
- Iterator<Entry<String, TopicRouteData>> it = this.topicRouteTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, TopicRouteData> entry = it.next();
- TopicRouteData topicRouteData = entry.getValue();
- List<BrokerData> bds = topicRouteData.getBrokerDatas();
- for (BrokerData bd : bds) {
- if (bd.getBrokerAddrs() != null) {
- boolean exist = bd.getBrokerAddrs().containsValue(addr);
- if (exist)
- return true;
- }
- }
- }
-
- return false;
- }
-
- private void sendHeartbeatToAllBroker() {
- final HeartbeatData heartbeatData = this.prepareHeartbeatData();
- final boolean producerEmpty = heartbeatData.getProducerDataSet().isEmpty();
- final boolean consumerEmpty = heartbeatData.getConsumerDataSet().isEmpty();
- if (producerEmpty && consumerEmpty) {
- log.warn("sending hearbeat, but no consumer and no producer");
- return;
- }
-
- long times = this.storeTimesTotal.getAndIncrement();
- Iterator<Entry<String, HashMap<Long, String>>> it = this.brokerAddrTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, HashMap<Long, String>> entry = it.next();
- String brokerName = entry.getKey();
- HashMap<Long, String> oneTable = entry.getValue();
- if (oneTable != null) {
- for (Map.Entry<Long, String> entry1 : oneTable.entrySet()) {
- Long id = entry1.getKey();
- String addr = entry1.getValue();
- if (addr != null) {
- if (consumerEmpty) {
- if (id != MixAll.MASTER_ID)
- continue;
- }
-
- try {
- this.mQClientAPIImpl.sendHearbeat(addr, heartbeatData, 3000);
- if (times % 20 == 0) {
- log.info("send heart beat to broker[{} {} {}] success", brokerName, id, addr);
- log.info(heartbeatData.toString());
- }
- } catch (Exception e) {
- if (this.isBrokerInNameServer(addr)) {
- log.error("send heart beat to broker exception", e);
- } else {
- log.info("send heart beat to broker[{} {} {}] exception, because the broker not up, forget it", brokerName,
- id, addr);
- }
- }
- }
- }
- }
- }
- }
-
- private void uploadFilterClassSource() {
- Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, MQConsumerInner> next = it.next();
- MQConsumerInner consumer = next.getValue();
- if (ConsumeType.CONSUME_PASSIVELY == consumer.consumeType()) {
- Set<SubscriptionData> subscriptions = consumer.subscriptions();
- for (SubscriptionData sub : subscriptions) {
- if (sub.isClassFilterMode() && sub.getFilterClassSource() != null) {
- final String consumerGroup = consumer.groupName();
- final String className = sub.getSubString();
- final String topic = sub.getTopic();
- final String filterClassSource = sub.getFilterClassSource();
- try {
- this.uploadFilterClassToAllFilterServer(consumerGroup, className, topic, filterClassSource);
- } catch (Exception e) {
- log.error("uploadFilterClassToAllFilterServer Exception", e);
- }
- }
- }
- }
- }
- }
-
- public boolean updateTopicRouteInfoFromNameServer(final String topic, boolean isDefault, DefaultMQProducer defaultMQProducer) {
- try {
- if (this.lockNamesrv.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
- try {
- TopicRouteData topicRouteData;
- if (isDefault && defaultMQProducer != null) {
- topicRouteData = this.mQClientAPIImpl.getDefaultTopicRouteInfoFromNameServer(defaultMQProducer.getCreateTopicKey(),
- 1000 * 3);
- if (topicRouteData != null) {
- for (QueueData data : topicRouteData.getQueueDatas()) {
- int queueNums = Math.min(defaultMQProducer.getDefaultTopicQueueNums(), data.getReadQueueNums());
- data.setReadQueueNums(queueNums);
- data.setWriteQueueNums(queueNums);
- }
- }
- } else {
- topicRouteData = this.mQClientAPIImpl.getTopicRouteInfoFromNameServer(topic, 1000 * 3);
- }
- if (topicRouteData != null) {
- TopicRouteData old = this.topicRouteTable.get(topic);
- boolean changed = topicRouteDataIsChange(old, topicRouteData);
- if (!changed) {
- changed = this.isNeedUpdateTopicRouteInfo(topic);
- } else {
- log.info("the topic[{}] route info changed, old[{}] ,new[{}]", topic, old, topicRouteData);
- }
-
- if (changed) {
- TopicRouteData cloneTopicRouteData = topicRouteData.cloneTopicRouteData();
-
- for (BrokerData bd : topicRouteData.getBrokerDatas()) {
- this.brokerAddrTable.put(bd.getBrokerName(), bd.getBrokerAddrs());
- }
-
- // Update Pub info
- {
- TopicPublishInfo publishInfo = topicRouteData2TopicPublishInfo(topic, topicRouteData);
- publishInfo.setHaveTopicRouterInfo(true);
- Iterator<Entry<String, MQProducerInner>> it = this.producerTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, MQProducerInner> entry = it.next();
- MQProducerInner impl = entry.getValue();
- if (impl != null) {
- impl.updateTopicPublishInfo(topic, publishInfo);
- }
- }
- }
-
- // Update sub info
- {
- Set<MessageQueue> subscribeInfo = topicRouteData2TopicSubscribeInfo(topic, topicRouteData);
- Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, MQConsumerInner> entry = it.next();
- MQConsumerInner impl = entry.getValue();
- if (impl != null) {
- impl.updateTopicSubscribeInfo(topic, subscribeInfo);
- }
- }
- }
- log.info("topicRouteTable.put TopicRouteData[{}]", cloneTopicRouteData);
- this.topicRouteTable.put(topic, cloneTopicRouteData);
- return true;
- }
- } else {
- log.warn("updateTopicRouteInfoFromNameServer, getTopicRouteInfoFromNameServer return null, Topic: {}", topic);
- }
- } catch (Exception e) {
- if (!topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX) && !topic.equals(MixAll.DEFAULT_TOPIC)) {
- log.warn("updateTopicRouteInfoFromNameServer Exception", e);
- }
- } finally {
- this.lockNamesrv.unlock();
- }
- } else {
- log.warn("updateTopicRouteInfoFromNameServer tryLock timeout {}ms", LOCK_TIMEOUT_MILLIS);
- }
- } catch (InterruptedException e) {
- log.warn("updateTopicRouteInfoFromNameServer Exception", e);
- }
-
- return false;
- }
-
- private HeartbeatData prepareHeartbeatData() {
- HeartbeatData heartbeatData = new HeartbeatData();
-
- // clientID
- heartbeatData.setClientID(this.clientId);
-
- // Consumer
- for (Map.Entry<String, MQConsumerInner> entry : this.consumerTable.entrySet()) {
- MQConsumerInner impl = entry.getValue();
- if (impl != null) {
- ConsumerData consumerData = new ConsumerData();
- consumerData.setGroupName(impl.groupName());
- consumerData.setConsumeType(impl.consumeType());
- consumerData.setMessageModel(impl.messageModel());
- consumerData.setConsumeFromWhere(impl.consumeFromWhere());
- consumerData.getSubscriptionDataSet().addAll(impl.subscriptions());
- consumerData.setUnitMode(impl.isUnitMode());
-
- heartbeatData.getConsumerDataSet().add(consumerData);
- }
- }
-
-
- // Producer
- for (Map.Entry<String/* group */, MQProducerInner> entry : this.producerTable.entrySet()) {
- MQProducerInner impl = entry.getValue();
- if (impl != null) {
- ProducerData producerData = new ProducerData();
- producerData.setGroupName(entry.getKey());
-
- heartbeatData.getProducerDataSet().add(producerData);
- }
- }
-
- return heartbeatData;
- }
-
- private boolean isBrokerInNameServer(final String brokerAddr) {
- Iterator<Entry<String, TopicRouteData>> it = this.topicRouteTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, TopicRouteData> itNext = it.next();
- List<BrokerData> brokerDatas = itNext.getValue().getBrokerDatas();
- for (BrokerData bd : brokerDatas) {
- boolean contain = bd.getBrokerAddrs().containsValue(brokerAddr);
- if (contain)
- return true;
- }
- }
-
- return false;
- }
-
- private void uploadFilterClassToAllFilterServer(final String consumerGroup, final String fullClassName, final String topic,
- final String filterClassSource) throws UnsupportedEncodingException {
- byte[] classBody = null;
- int classCRC = 0;
- try {
- classBody = filterClassSource.getBytes(MixAll.DEFAULT_CHARSET);
- classCRC = UtilAll.crc32(classBody);
- } catch (Exception e1) {
- log.warn("uploadFilterClassToAllFilterServer Exception, ClassName: {} {}", //
- fullClassName, //
- RemotingHelper.exceptionSimpleDesc(e1));
- }
-
- TopicRouteData topicRouteData = this.topicRouteTable.get(topic);
- if (topicRouteData != null //
- && topicRouteData.getFilterServerTable() != null && !topicRouteData.getFilterServerTable().isEmpty()) {
- Iterator<Entry<String, List<String>>> it = topicRouteData.getFilterServerTable().entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, List<String>> next = it.next();
- List<String> value = next.getValue();
- for (final String fsAddr : value) {
- try {
- this.mQClientAPIImpl.registerMessageFilterClass(fsAddr, consumerGroup, topic, fullClassName, classCRC, classBody,
- 5000);
-
- log.info("register message class filter to {} OK, ConsumerGroup: {} Topic: {} ClassName: {}", fsAddr, consumerGroup,
- topic, fullClassName);
-
- } catch (Exception e) {
- log.error("uploadFilterClassToAllFilterServer Exception", e);
- }
- }
- }
- } else {
- log.warn("register message class filter failed, because no filter server, ConsumerGroup: {} Topic: {} ClassName: {}",
- consumerGroup, topic, fullClassName);
- }
- }
-
- private boolean topicRouteDataIsChange(TopicRouteData olddata, TopicRouteData nowdata) {
- if (olddata == null || nowdata == null)
- return true;
- TopicRouteData old = olddata.cloneTopicRouteData();
- TopicRouteData now = nowdata.cloneTopicRouteData();
- Collections.sort(old.getQueueDatas());
- Collections.sort(old.getBrokerDatas());
- Collections.sort(now.getQueueDatas());
- Collections.sort(now.getBrokerDatas());
- return !old.equals(now);
-
- }
-
- private boolean isNeedUpdateTopicRouteInfo(final String topic) {
- boolean result = false;
- {
- Iterator<Entry<String, MQProducerInner>> it = this.producerTable.entrySet().iterator();
- while (it.hasNext() && !result) {
- Entry<String, MQProducerInner> entry = it.next();
- MQProducerInner impl = entry.getValue();
- if (impl != null) {
- result = impl.isPublishTopicNeedUpdate(topic);
- }
- }
- }
-
- {
- Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator();
- while (it.hasNext() && !result) {
- Entry<String, MQConsumerInner> entry = it.next();
- MQConsumerInner impl = entry.getValue();
- if (impl != null) {
- result = impl.isSubscribeTopicNeedUpdate(topic);
- }
- }
- }
-
- return result;
- }
-
- public static TopicPublishInfo topicRouteData2TopicPublishInfo(final String topic, final TopicRouteData route) {
- TopicPublishInfo info = new TopicPublishInfo();
- info.setTopicRouteData(route);
- if (route.getOrderTopicConf() != null && route.getOrderTopicConf().length() > 0) {
- String[] brokers = route.getOrderTopicConf().split(";");
- for (String broker : brokers) {
- String[] item = broker.split(":");
- int nums = Integer.parseInt(item[1]);
- for (int i = 0; i < nums; i++) {
- MessageQueue mq = new MessageQueue(topic, item[0], i);
- info.getMessageQueueList().add(mq);
- }
- }
-
- info.setOrderTopic(true);
- } else {
- List<QueueData> qds = route.getQueueDatas();
- Collections.sort(qds);
- for (QueueData qd : qds) {
- if (PermName.isWriteable(qd.getPerm())) {
- BrokerData brokerData = null;
- for (BrokerData bd : route.getBrokerDatas()) {
- if (bd.getBrokerName().equals(qd.getBrokerName())) {
- brokerData = bd;
- break;
- }
- }
-
- if (null == brokerData) {
- continue;
- }
-
- if (!brokerData.getBrokerAddrs().containsKey(MixAll.MASTER_ID)) {
- continue;
- }
-
- for (int i = 0; i < qd.getWriteQueueNums(); i++) {
- MessageQueue mq = new MessageQueue(topic, qd.getBrokerName(), i);
- info.getMessageQueueList().add(mq);
- }
- }
- }
-
- info.setOrderTopic(false);
- }
-
- return info;
- }
-
- public static Set<MessageQueue> topicRouteData2TopicSubscribeInfo(final String topic, final TopicRouteData route) {
- Set<MessageQueue> mqList = new HashSet<MessageQueue>();
- List<QueueData> qds = route.getQueueDatas();
- for (QueueData qd : qds) {
- if (PermName.isReadable(qd.getPerm())) {
- for (int i = 0; i < qd.getReadQueueNums(); i++) {
- MessageQueue mq = new MessageQueue(topic, qd.getBrokerName(), i);
- mqList.add(mq);
- }
- }
- }
-
- return mqList;
- }
-
- public void shutdown() {
- // Consumer
- if (!this.consumerTable.isEmpty())
- return;
-
- // AdminExt
- if (!this.adminExtTable.isEmpty())
- return;
-
- // Producer
- if (this.producerTable.size() > 1)
- return;
-
- synchronized (this) {
- switch (this.serviceState) {
- case CREATE_JUST:
- break;
- case RUNNING:
- this.defaultMQProducer.getDefaultMQProducerImpl().shutdown(false);
-
- this.serviceState = ServiceState.SHUTDOWN_ALREADY;
- this.pullMessageService.shutdown(true);
- this.scheduledExecutorService.shutdown();
- this.mQClientAPIImpl.shutdown();
- this.rebalanceService.shutdown();
-
- if (this.datagramSocket != null) {
- this.datagramSocket.close();
- this.datagramSocket = null;
- }
- MQClientManager.getInstance().removeClientFactory(this.clientId);
- log.info("the client factory [{}] shutdown OK", this.clientId);
- break;
- case SHUTDOWN_ALREADY:
- break;
- default:
- break;
- }
- }
- }
-
- public boolean registerConsumer(final String group, final MQConsumerInner consumer) {
- if (null == group || null == consumer) {
- return false;
- }
-
- MQConsumerInner prev = this.consumerTable.putIfAbsent(group, consumer);
- if (prev != null) {
- log.warn("the consumer group[" + group + "] exist already.");
- return false;
- }
-
- return true;
- }
-
- public void unregisterConsumer(final String group) {
- this.consumerTable.remove(group);
- this.unregisterClientWithLock(null, group);
- }
-
- private void unregisterClientWithLock(final String producerGroup, final String consumerGroup) {
- try {
- if (this.lockHeartbeat.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
- try {
- this.unregisterClient(producerGroup, consumerGroup);
- } catch (Exception e) {
- log.error("unregisterClient exception", e);
- } finally {
- this.lockHeartbeat.unlock();
- }
- } else {
- log.warn("lock heartBeat, but failed.");
- }
- } catch (InterruptedException e) {
- log.warn("unregisterClientWithLock exception", e);
- }
- }
-
- private void unregisterClient(final String producerGroup, final String consumerGroup) {
- Iterator<Entry<String, HashMap<Long, String>>> it = this.brokerAddrTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, HashMap<Long, String>> entry = it.next();
- String brokerName = entry.getKey();
- HashMap<Long, String> oneTable = entry.getValue();
-
- if (oneTable != null) {
- for (Map.Entry<Long, String> entry1 : oneTable.entrySet()) {
- String addr = entry1.getValue();
- if (addr != null) {
- try {
- this.mQClientAPIImpl.unregisterClient(addr, this.clientId, producerGroup, consumerGroup, 3000);
- log.info("unregister client[Producer: {} Consumer: {}] from broker[{} {} {}] success", producerGroup,
- consumerGroup, brokerName, entry1.getKey(), addr);
- } catch (RemotingException e) {
- log.error("unregister client exception from broker: " + addr, e);
- } catch (MQBrokerException e) {
- log.error("unregister client exception from broker: " + addr, e);
- } catch (InterruptedException e) {
- log.error("unregister client exception from broker: " + addr, e);
- }
- }
- }
- }
- }
- }
-
- public boolean registerProducer(final String group, final DefaultMQProducerImpl producer) {
- if (null == group || null == producer) {
- return false;
- }
-
- MQProducerInner prev = this.producerTable.putIfAbsent(group, producer);
- if (prev != null) {
- log.warn("the producer group[{}] exist already.", group);
- return false;
- }
-
- return true;
- }
-
- public void unregisterProducer(final String group) {
- this.producerTable.remove(group);
- this.unregisterClientWithLock(group, null);
- }
-
- public boolean registerAdminExt(final String group, final MQAdminExtInner admin) {
- if (null == group || null == admin) {
- return false;
- }
-
- MQAdminExtInner prev = this.adminExtTable.putIfAbsent(group, admin);
- if (prev != null) {
- log.warn("the admin group[{}] exist already.", group);
- return false;
- }
-
- return true;
- }
-
- public void unregisterAdminExt(final String group) {
- this.adminExtTable.remove(group);
- }
-
- public void rebalanceImmediately() {
- this.rebalanceService.wakeup();
- }
-
- public void doRebalance() {
- for (Map.Entry<String, MQConsumerInner> entry : this.consumerTable.entrySet()) {
- MQConsumerInner impl = entry.getValue();
- if (impl != null) {
- try {
- impl.doRebalance();
- } catch (Throwable e) {
- log.error("doRebalance exception", e);
- }
- }
- }
- }
-
- public MQProducerInner selectProducer(final String group) {
- return this.producerTable.get(group);
- }
-
- public MQConsumerInner selectConsumer(final String group) {
- return this.consumerTable.get(group);
- }
-
- public FindBrokerResult findBrokerAddressInAdmin(final String brokerName) {
- String brokerAddr = null;
- boolean slave = false;
- boolean found = false;
-
- HashMap<Long/* brokerId */, String/* address */> map = this.brokerAddrTable.get(brokerName);
- if (map != null && !map.isEmpty()) {
- FOR_SEG:
- for (Map.Entry<Long, String> entry : map.entrySet()) {
- Long id = entry.getKey();
- brokerAddr = entry.getValue();
- if (brokerAddr != null) {
- found = true;
- if (MixAll.MASTER_ID == id) {
- slave = false;
- break FOR_SEG;
- } else {
- slave = true;
- }
- break;
-
- }
- } // end of for
- }
-
- if (found) {
- return new FindBrokerResult(brokerAddr, slave);
- }
-
- return null;
- }
-
- public String findBrokerAddressInPublish(final String brokerName) {
- HashMap<Long/* brokerId */, String/* address */> map = this.brokerAddrTable.get(brokerName);
- if (map != null && !map.isEmpty()) {
- return map.get(MixAll.MASTER_ID);
- }
-
- return null;
- }
-
- public FindBrokerResult findBrokerAddressInSubscribe(//
- final String brokerName, //
- final long brokerId, //
- final boolean onlyThisBroker//
- ) {
- String brokerAddr = null;
- boolean slave = false;
- boolean found = false;
-
- HashMap<Long/* brokerId */, String/* address */> map = this.brokerAddrTable.get(brokerName);
- if (map != null && !map.isEmpty()) {
- brokerAddr = map.get(brokerId);
- slave = brokerId != MixAll.MASTER_ID;
- found = brokerAddr != null;
-
- if (!found && !onlyThisBroker) {
- Entry<Long, String> entry = map.entrySet().iterator().next();
- brokerAddr = entry.getValue();
- slave = entry.getKey() != MixAll.MASTER_ID;
- found = true;
- }
- }
-
- if (found) {
- return new FindBrokerResult(brokerAddr, slave);
- }
-
- return null;
- }
-
- public List<String> findConsumerIdList(final String topic, final String group) {
- String brokerAddr = this.findBrokerAddrByTopic(topic);
- if (null == brokerAddr) {
- this.updateTopicRouteInfoFromNameServer(topic);
- brokerAddr = this.findBrokerAddrByTopic(topic);
- }
-
- if (null != brokerAddr) {
- try {
- return this.mQClientAPIImpl.getConsumerIdListByGroup(brokerAddr, group, 3000);
- } catch (Exception e) {
- log.warn("getConsumerIdListByGroup exception, " + brokerAddr + " " + group, e);
- }
- }
-
- return null;
- }
-
- public String findBrokerAddrByTopic(final String topic) {
- TopicRouteData topicRouteData = this.topicRouteTable.get(topic);
- if (topicRouteData != null) {
- List<BrokerData> brokers = topicRouteData.getBrokerDatas();
- if (!brokers.isEmpty()) {
- int index = random.nextInt(brokers.size());
- BrokerData bd = brokers.get(index % brokers.size());
- return bd.selectBrokerAddr();
- }
- }
-
- return null;
- }
-
- public void resetOffset(String topic, String group, Map<MessageQueue, Long> offsetTable) {
- DefaultMQPushConsumerImpl consumer = null;
- try {
- MQConsumerInner impl = this.consumerTable.get(group);
- if (impl != null && impl instanceof DefaultMQPushConsumerImpl) {
- consumer = (DefaultMQPushConsumerImpl) impl;
- } else {
- log.info("[reset-offset] consumer dose not exist. group={}", group);
- return;
- }
- consumer.suspend();
-
- ConcurrentHashMap<MessageQueue, ProcessQueue> processQueueTable = consumer.getRebalanceImpl().getProcessQueueTable();
- for (Map.Entry<MessageQueue, ProcessQueue> entry : processQueueTable.entrySet()) {
- MessageQueue mq = entry.getKey();
- if (topic.equals(mq.getTopic()) && offsetTable.containsKey(mq)) {
- ProcessQueue pq = entry.getValue();
- pq.setDropped(true);
- pq.clear();
- }
- }
-
- try {
- TimeUnit.SECONDS.sleep(10);
- } catch (InterruptedException e) {
- //
- }
-
- Iterator<MessageQueue> iterator = processQueueTable.keySet().iterator();
- while (iterator.hasNext()) {
- MessageQueue mq = iterator.next();
- Long offset = offsetTable.get(mq);
- if (topic.equals(mq.getTopic()) && offset != null) {
- try {
- consumer.updateConsumeOffset(mq, offset);
- consumer.getRebalanceImpl().removeUnnecessaryMessageQueue(mq, processQueueTable.get(mq));
- iterator.remove();
- } catch (Exception e) {
- log.warn("reset offset failed. group={}, {}", group, mq, e);
- }
- }
- }
- } finally {
- consumer.resume();
- }
- }
-
- public Map<MessageQueue, Long> getConsumerStatus(String topic, String group) {
- MQConsumerInner impl = this.consumerTable.get(group);
- if (impl != null && impl instanceof DefaultMQPushConsumerImpl) {
- DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) impl;
- return consumer.getOffsetStore().cloneOffsetTable(topic);
- } else if (impl != null && impl instanceof DefaultMQPullConsumerImpl) {
- DefaultMQPullConsumerImpl consumer = (DefaultMQPullConsumerImpl) impl;
- return consumer.getOffsetStore().cloneOffsetTable(topic);
- } else {
- return Collections.EMPTY_MAP;
- }
- }
-
- public TopicRouteData getAnExistTopicRouteData(final String topic) {
- return this.topicRouteTable.get(topic);
- }
-
- public MQClientAPIImpl getMQClientAPIImpl() {
- return mQClientAPIImpl;
- }
-
- public MQAdminImpl getMQAdminImpl() {
- return mQAdminImpl;
- }
-
- public long getBootTimestamp() {
- return bootTimestamp;
- }
-
- public ScheduledExecutorService getScheduledExecutorService() {
- return scheduledExecutorService;
- }
-
- public PullMessageService getPullMessageService() {
- return pullMessageService;
- }
-
- public DefaultMQProducer getDefaultMQProducer() {
- return defaultMQProducer;
- }
-
- public ConcurrentHashMap<String, TopicRouteData> getTopicRouteTable() {
- return topicRouteTable;
- }
-
- public ConsumeMessageDirectlyResult consumeMessageDirectly(final MessageExt msg, //
- final String consumerGroup, //
- final String brokerName) {
- MQConsumerInner mqConsumerInner = this.consumerTable.get(consumerGroup);
- if (null != mqConsumerInner) {
- DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) mqConsumerInner;
-
- ConsumeMessageDirectlyResult result = consumer.getConsumeMessageService().consumeMessageDirectly(msg, brokerName);
- return result;
- }
-
- return null;
- }
-
-
- public ConsumerRunningInfo consumerRunningInfo(final String consumerGroup) {
- MQConsumerInner mqConsumerInner = this.consumerTable.get(consumerGroup);
-
- ConsumerRunningInfo consumerRunningInfo = mqConsumerInner.consumerRunningInfo();
-
- List<String> nsList = this.mQClientAPIImpl.getRemotingClient().getNameServerAddressList();
-
- StringBuffer strBuffer = new StringBuffer();
- if (nsList != null) {
- for (String addr : nsList) {
- strBuffer.append(addr + ";");
- }
- }
-
- String nsAddr = strBuffer.toString();
- consumerRunningInfo.getProperties().put(ConsumerRunningInfo.PROP_NAMESERVER_ADDR, nsAddr);
- consumerRunningInfo.getProperties().put(ConsumerRunningInfo.PROP_CONSUME_TYPE, mqConsumerInner.consumeType().name());
- consumerRunningInfo.getProperties().put(ConsumerRunningInfo.PROP_CLIENT_VERSION,
- MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION));
-
- return consumerRunningInfo;
- }
-
-
- public ConsumerStatsManager getConsumerStatsManager() {
- return consumerStatsManager;
- }
-
- public NettyClientConfig getNettyClientConfig() {
- return nettyClientConfig;
- }
-}
[64/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Remove
author annotation.
Posted by yu...@apache.org.
ROCKETMQ-18 Remove author annotation.
Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/commit/8ca4657e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/tree/8ca4657e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/diff/8ca4657e
Branch: refs/heads/master
Commit: 8ca4657e15953255450bc5c90673621aeef37132
Parents: f98b121
Author: yukon <yu...@apache.org>
Authored: Wed Dec 28 14:28:13 2016 +0800
Committer: yukon <yu...@apache.org>
Committed: Wed Dec 28 14:28:13 2016 +0800
----------------------------------------------------------------------
.../main/java/org/apache/rocketmq/broker/BrokerController.java | 3 ---
.../src/main/java/org/apache/rocketmq/broker/BrokerStartup.java | 3 ---
.../org/apache/rocketmq/broker/client/ClientChannelInfo.java | 3 ---
.../rocketmq/broker/client/ClientHousekeepingService.java | 3 ---
.../org/apache/rocketmq/broker/client/ConsumerGroupInfo.java | 3 ---
.../rocketmq/broker/client/ConsumerIdsChangeListener.java | 3 ---
.../java/org/apache/rocketmq/broker/client/ConsumerManager.java | 3 ---
.../broker/client/DefaultConsumerIdsChangeListener.java | 3 ---
.../java/org/apache/rocketmq/broker/client/ProducerManager.java | 3 ---
.../org/apache/rocketmq/broker/client/net/Broker2Client.java | 3 ---
.../rocketmq/broker/client/rebalance/RebalanceLockManager.java | 3 ---
.../org/apache/rocketmq/broker/latency/BrokerFastFailure.java | 3 ---
.../rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java | 3 ---
.../java/org/apache/rocketmq/broker/latency/FutureTaskExt.java | 3 ---
.../org/apache/rocketmq/broker/longpolling/ManyPullRequest.java | 3 ---
.../org/apache/rocketmq/broker/longpolling/PullRequest.java | 3 ---
.../rocketmq/broker/longpolling/PullRequestHoldService.java | 3 ---
.../apache/rocketmq/broker/offset/ConsumerOffsetManager.java | 3 ---
.../java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java | 4 ----
.../apache/rocketmq/broker/pagecache/ManyMessageTransfer.java | 3 ---
.../apache/rocketmq/broker/pagecache/OneMessageTransfer.java | 3 ---
.../apache/rocketmq/broker/pagecache/QueryMessageTransfer.java | 3 ---
.../rocketmq/broker/processor/AbstractSendMessageProcessor.java | 3 ---
.../apache/rocketmq/broker/processor/AdminBrokerProcessor.java | 4 ----
.../apache/rocketmq/broker/processor/ClientManageProcessor.java | 3 ---
.../rocketmq/broker/processor/ConsumerManageProcessor.java | 3 ---
.../rocketmq/broker/processor/EndTransactionProcessor.java | 3 ---
.../rocketmq/broker/processor/ForwardRequestProcessor.java | 3 ---
.../apache/rocketmq/broker/processor/PullMessageProcessor.java | 3 ---
.../apache/rocketmq/broker/processor/QueryMessageProcessor.java | 3 ---
.../apache/rocketmq/broker/processor/SendMessageProcessor.java | 3 ---
.../java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java | 4 ----
.../rocketmq/broker/subscription/SubscriptionGroupManager.java | 3 ---
.../org/apache/rocketmq/broker/topic/TopicConfigManager.java | 3 ---
.../java/org/apache/rocketmq/broker/BrokerControllerTest.java | 3 ---
.../test/java/org/apache/rocketmq/broker/BrokerTestHarness.java | 3 ---
.../java/org/apache/rocketmq/broker/api/SendMessageTest.java | 3 ---
.../rocketmq/broker/offset/ConsumerOffsetManagerTest.java | 3 ---
.../apache/rocketmq/broker/topic/TopicConfigManagerTest.java | 3 ---
.../src/main/java/org/apache/rocketmq/client/ClientConfig.java | 2 --
client/src/main/java/org/apache/rocketmq/client/MQAdmin.java | 1 -
client/src/main/java/org/apache/rocketmq/client/MQHelper.java | 3 ---
.../src/main/java/org/apache/rocketmq/client/QueryResult.java | 3 ---
client/src/main/java/org/apache/rocketmq/client/Validators.java | 1 -
.../java/org/apache/rocketmq/client/admin/MQAdminExtInner.java | 3 ---
.../rocketmq/client/consumer/AllocateMessageQueueStrategy.java | 2 --
.../apache/rocketmq/client/consumer/DefaultMQPullConsumer.java | 1 -
.../apache/rocketmq/client/consumer/DefaultMQPushConsumer.java | 1 -
.../java/org/apache/rocketmq/client/consumer/MQConsumer.java | 1 -
.../org/apache/rocketmq/client/consumer/MQPullConsumer.java | 1 -
.../rocketmq/client/consumer/MQPullConsumerScheduleService.java | 1 -
.../org/apache/rocketmq/client/consumer/MQPushConsumer.java | 1 -
.../apache/rocketmq/client/consumer/MessageQueueListener.java | 2 --
.../java/org/apache/rocketmq/client/consumer/PullCallback.java | 1 -
.../java/org/apache/rocketmq/client/consumer/PullResult.java | 3 ---
.../java/org/apache/rocketmq/client/consumer/PullStatus.java | 3 ---
.../client/consumer/listener/ConsumeConcurrentlyContext.java | 1 -
.../client/consumer/listener/ConsumeConcurrentlyStatus.java | 3 ---
.../client/consumer/listener/ConsumeOrderlyContext.java | 1 -
.../rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java | 3 ---
.../rocketmq/client/consumer/listener/MessageListener.java | 1 -
.../client/consumer/listener/MessageListenerConcurrently.java | 1 -
.../client/consumer/listener/MessageListenerOrderly.java | 1 -
.../consumer/rebalance/AllocateMessageQueueAveragely.java | 1 -
.../rebalance/AllocateMessageQueueAveragelyByCircle.java | 1 -
.../client/consumer/rebalance/AllocateMessageQueueByConfig.java | 3 ---
.../rocketmq/client/consumer/store/LocalFileOffsetStore.java | 1 -
.../rocketmq/client/consumer/store/OffsetSerializeWrapper.java | 1 -
.../org/apache/rocketmq/client/consumer/store/OffsetStore.java | 1 -
.../rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java | 1 -
.../org/apache/rocketmq/client/exception/MQBrokerException.java | 3 ---
.../org/apache/rocketmq/client/exception/MQClientException.java | 3 ---
.../org/apache/rocketmq/client/hook/CheckForbiddenContext.java | 3 ---
.../org/apache/rocketmq/client/hook/CheckForbiddenHook.java | 3 ---
.../org/apache/rocketmq/client/hook/FilterMessageContext.java | 3 ---
.../java/org/apache/rocketmq/client/hook/FilterMessageHook.java | 3 ---
.../apache/rocketmq/client/impl/ClientRemotingProcessor.java | 3 ---
.../java/org/apache/rocketmq/client/impl/CommunicationMode.java | 3 ---
.../java/org/apache/rocketmq/client/impl/FindBrokerResult.java | 3 ---
.../main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java | 3 ---
.../java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java | 3 ---
.../java/org/apache/rocketmq/client/impl/MQClientManager.java | 3 ---
.../client/impl/consumer/ConsumeMessageConcurrentlyService.java | 3 ---
.../client/impl/consumer/ConsumeMessageOrderlyService.java | 3 ---
.../rocketmq/client/impl/consumer/ConsumeMessageService.java | 3 ---
.../client/impl/consumer/DefaultMQPullConsumerImpl.java | 3 ---
.../client/impl/consumer/DefaultMQPushConsumerImpl.java | 3 ---
.../apache/rocketmq/client/impl/consumer/MQConsumerInner.java | 1 -
.../apache/rocketmq/client/impl/consumer/MessageQueueLock.java | 1 -
.../org/apache/rocketmq/client/impl/consumer/ProcessQueue.java | 1 -
.../apache/rocketmq/client/impl/consumer/PullAPIWrapper.java | 3 ---
.../rocketmq/client/impl/consumer/PullMessageService.java | 3 ---
.../org/apache/rocketmq/client/impl/consumer/PullRequest.java | 3 ---
.../org/apache/rocketmq/client/impl/consumer/PullResultExt.java | 3 ---
.../org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java | 1 -
.../apache/rocketmq/client/impl/consumer/RebalancePullImpl.java | 3 ---
.../apache/rocketmq/client/impl/consumer/RebalancePushImpl.java | 3 ---
.../apache/rocketmq/client/impl/consumer/RebalanceService.java | 1 -
.../apache/rocketmq/client/impl/factory/MQClientInstance.java | 3 ---
.../rocketmq/client/impl/producer/DefaultMQProducerImpl.java | 3 ---
.../apache/rocketmq/client/impl/producer/MQProducerInner.java | 3 ---
.../apache/rocketmq/client/impl/producer/TopicPublishInfo.java | 3 ---
.../apache/rocketmq/client/latency/LatencyFaultTolerance.java | 3 ---
.../rocketmq/client/latency/LatencyFaultToleranceImpl.java | 3 ---
.../org/apache/rocketmq/client/latency/MQFaultStrategy.java | 3 ---
.../main/java/org/apache/rocketmq/client/log/ClientLogger.java | 3 ---
.../org/apache/rocketmq/client/producer/DefaultMQProducer.java | 3 ---
.../rocketmq/client/producer/LocalTransactionExecuter.java | 3 ---
.../apache/rocketmq/client/producer/LocalTransactionState.java | 3 ---
.../java/org/apache/rocketmq/client/producer/MQProducer.java | 3 ---
.../apache/rocketmq/client/producer/MessageQueueSelector.java | 3 ---
.../java/org/apache/rocketmq/client/producer/SendCallback.java | 3 ---
.../java/org/apache/rocketmq/client/producer/SendResult.java | 3 ---
.../java/org/apache/rocketmq/client/producer/SendStatus.java | 3 ---
.../rocketmq/client/producer/TransactionCheckListener.java | 3 ---
.../apache/rocketmq/client/producer/TransactionMQProducer.java | 3 ---
.../apache/rocketmq/client/producer/TransactionSendResult.java | 3 ---
.../client/producer/selector/SelectMessageQueueByHash.java | 3 ---
.../producer/selector/SelectMessageQueueByMachineRoom.java | 3 ---
.../client/producer/selector/SelectMessageQueueByRandoom.java | 3 ---
.../src/main/java/org/apache/rocketmq/common/BrokerConfig.java | 3 ---
.../src/main/java/org/apache/rocketmq/common/ConfigManager.java | 3 ---
.../src/main/java/org/apache/rocketmq/common/Configuration.java | 3 ---
.../main/java/org/apache/rocketmq/common/CountDownLatch2.java | 1 -
.../src/main/java/org/apache/rocketmq/common/DataVersion.java | 3 ---
common/src/main/java/org/apache/rocketmq/common/MQVersion.java | 3 ---
common/src/main/java/org/apache/rocketmq/common/MixAll.java | 3 ---
common/src/main/java/org/apache/rocketmq/common/Pair.java | 3 ---
.../src/main/java/org/apache/rocketmq/common/ServiceState.java | 3 ---
.../src/main/java/org/apache/rocketmq/common/ServiceThread.java | 4 ----
.../src/main/java/org/apache/rocketmq/common/SystemClock.java | 3 ---
.../src/main/java/org/apache/rocketmq/common/TopicConfig.java | 3 ---
.../main/java/org/apache/rocketmq/common/TopicFilterType.java | 3 ---
common/src/main/java/org/apache/rocketmq/common/UtilAll.java | 3 ---
.../java/org/apache/rocketmq/common/admin/ConsumeStats.java | 1 -
.../java/org/apache/rocketmq/common/admin/OffsetWrapper.java | 1 -
.../java/org/apache/rocketmq/common/admin/RollbackStats.java | 1 -
.../main/java/org/apache/rocketmq/common/admin/TopicOffset.java | 1 -
.../java/org/apache/rocketmq/common/admin/TopicStatsTable.java | 1 -
.../java/org/apache/rocketmq/common/constant/LoggerName.java | 3 ---
.../main/java/org/apache/rocketmq/common/constant/PermName.java | 3 ---
.../org/apache/rocketmq/common/consumer/ConsumeFromWhere.java | 1 -
.../main/java/org/apache/rocketmq/common/filter/FilterAPI.java | 1 -
.../src/main/java/org/apache/rocketmq/common/help/FAQUrl.java | 3 ---
.../java/org/apache/rocketmq/common/hook/FilterCheckHook.java | 1 -
.../main/java/org/apache/rocketmq/common/message/Message.java | 1 -
.../java/org/apache/rocketmq/common/message/MessageDecoder.java | 3 ---
.../java/org/apache/rocketmq/common/message/MessageExt.java | 3 ---
.../main/java/org/apache/rocketmq/common/message/MessageId.java | 3 ---
.../java/org/apache/rocketmq/common/message/MessageQueue.java | 3 ---
.../org/apache/rocketmq/common/message/MessageQueueForC.java | 3 ---
.../java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java | 2 --
.../java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java | 3 ---
.../apache/rocketmq/common/namesrv/RegisterBrokerResult.java | 3 ---
.../java/org/apache/rocketmq/common/namesrv/TopAddressing.java | 4 ----
.../org/apache/rocketmq/common/protocol/MQProtosHelper.java | 3 ---
.../org/apache/rocketmq/common/protocol/body/ClusterInfo.java | 3 ---
.../org/apache/rocketmq/common/protocol/body/Connection.java | 3 ---
.../org/apache/rocketmq/common/protocol/body/ConsumeByWho.java | 1 -
.../apache/rocketmq/common/protocol/body/ConsumeStatsList.java | 3 ---
.../rocketmq/common/protocol/body/ConsumerConnection.java | 3 ---
.../common/protocol/body/ConsumerOffsetSerializeWrapper.java | 3 ---
.../rocketmq/common/protocol/body/GetConsumerStatusBody.java | 3 ---
.../org/apache/rocketmq/common/protocol/body/GroupList.java | 1 -
.../java/org/apache/rocketmq/common/protocol/body/KVTable.java | 1 -
.../rocketmq/common/protocol/body/LockBatchRequestBody.java | 1 -
.../rocketmq/common/protocol/body/LockBatchResponseBody.java | 1 -
.../rocketmq/common/protocol/body/ProducerConnection.java | 3 ---
.../rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java | 3 ---
.../common/protocol/body/QueryCorrectionOffsetBody.java | 3 ---
.../org/apache/rocketmq/common/protocol/body/QueueTimeSpan.java | 3 ---
.../apache/rocketmq/common/protocol/body/ResetOffsetBody.java | 1 -
.../rocketmq/common/protocol/body/SubscriptionGroupWrapper.java | 3 ---
.../org/apache/rocketmq/common/protocol/body/TopicList.java | 3 ---
.../rocketmq/common/protocol/body/UnlockBatchRequestBody.java | 3 ---
.../protocol/header/CheckTransactionStateRequestHeader.java | 3 ---
.../protocol/header/CheckTransactionStateResponseHeader.java | 3 ---
.../common/protocol/header/CloneGroupOffsetRequestHeader.java | 3 ---
.../protocol/header/ConsumerSendMsgBackRequestHeader.java | 1 -
.../common/protocol/header/CreateTopicRequestHeader.java | 3 ---
.../protocol/header/DeleteSubscriptionGroupRequestHeader.java | 3 ---
.../common/protocol/header/DeleteTopicRequestHeader.java | 3 ---
.../common/protocol/header/EndTransactionRequestHeader.java | 3 ---
.../common/protocol/header/EndTransactionResponseHeader.java | 3 ---
.../common/protocol/header/GetAllTopicConfigResponseHeader.java | 3 ---
.../common/protocol/header/GetBrokerConfigResponseHeader.java | 3 ---
.../common/protocol/header/GetConsumeStatsRequestHeader.java | 3 ---
.../protocol/header/GetConsumerConnectionListRequestHeader.java | 1 -
.../protocol/header/GetConsumerListByGroupRequestHeader.java | 3 ---
.../protocol/header/GetConsumerListByGroupResponseBody.java | 3 ---
.../protocol/header/GetConsumerListByGroupResponseHeader.java | 3 ---
.../protocol/header/GetConsumerRunningInfoRequestHeader.java | 3 ---
.../common/protocol/header/GetConsumerStatusRequestHeader.java | 1 -
.../protocol/header/GetEarliestMsgStoretimeRequestHeader.java | 3 ---
.../protocol/header/GetEarliestMsgStoretimeResponseHeader.java | 3 ---
.../common/protocol/header/GetMaxOffsetRequestHeader.java | 3 ---
.../common/protocol/header/GetMaxOffsetResponseHeader.java | 3 ---
.../common/protocol/header/GetMinOffsetRequestHeader.java | 3 ---
.../common/protocol/header/GetMinOffsetResponseHeader.java | 3 ---
.../protocol/header/GetProducerConnectionListRequestHeader.java | 3 ---
.../common/protocol/header/GetTopicStatsInfoRequestHeader.java | 1 -
.../common/protocol/header/GetTopicsByClusterRequestHeader.java | 1 -
.../protocol/header/NotifyConsumerIdsChangedRequestHeader.java | 3 ---
.../common/protocol/header/PullMessageRequestHeader.java | 3 ---
.../common/protocol/header/PullMessageResponseHeader.java | 3 ---
.../protocol/header/QueryConsumeTimeSpanRequestHeader.java | 1 -
.../protocol/header/QueryConsumerOffsetRequestHeader.java | 3 ---
.../protocol/header/QueryConsumerOffsetResponseHeader.java | 3 ---
.../common/protocol/header/QueryCorrectionOffsetHeader.java | 1 -
.../common/protocol/header/QueryMessageRequestHeader.java | 3 ---
.../common/protocol/header/QueryMessageResponseHeader.java | 3 ---
.../protocol/header/QueryTopicConsumeByWhoRequestHeader.java | 3 ---
.../common/protocol/header/ResetOffsetRequestHeader.java | 1 -
.../common/protocol/header/SearchOffsetRequestHeader.java | 3 ---
.../common/protocol/header/SearchOffsetResponseHeader.java | 3 ---
.../common/protocol/header/SendMessageRequestHeader.java | 3 ---
.../common/protocol/header/SendMessageRequestHeaderV2.java | 1 -
.../common/protocol/header/SendMessageResponseHeader.java | 3 ---
.../common/protocol/header/UnregisterClientRequestHeader.java | 3 ---
.../common/protocol/header/UnregisterClientResponseHeader.java | 3 ---
.../protocol/header/UpdateConsumerOffsetRequestHeader.java | 3 ---
.../protocol/header/UpdateConsumerOffsetResponseHeader.java | 3 ---
.../common/protocol/header/ViewMessageRequestHeader.java | 3 ---
.../common/protocol/header/ViewMessageResponseHeader.java | 3 ---
.../protocol/header/namesrv/DeleteKVConfigRequestHeader.java | 1 -
.../header/namesrv/DeleteTopicInNamesrvRequestHeader.java | 1 -
.../protocol/header/namesrv/GetKVConfigRequestHeader.java | 1 -
.../protocol/header/namesrv/GetKVConfigResponseHeader.java | 1 -
.../header/namesrv/GetKVListByNamespaceRequestHeader.java | 1 -
.../protocol/header/namesrv/GetRouteInfoRequestHeader.java | 3 ---
.../protocol/header/namesrv/GetRouteInfoResponseHeader.java | 3 ---
.../protocol/header/namesrv/RegisterBrokerRequestHeader.java | 3 ---
.../protocol/header/namesrv/RegisterBrokerResponseHeader.java | 1 -
.../header/namesrv/RegisterOrderTopicRequestHeader.java | 3 ---
.../protocol/header/namesrv/UnRegisterBrokerRequestHeader.java | 3 ---
.../header/namesrv/WipeWritePermOfBrokerRequestHeader.java | 1 -
.../header/namesrv/WipeWritePermOfBrokerResponseHeader.java | 1 -
.../apache/rocketmq/common/protocol/heartbeat/ConsumeType.java | 3 ---
.../apache/rocketmq/common/protocol/heartbeat/ConsumerData.java | 3 ---
.../rocketmq/common/protocol/heartbeat/HeartbeatData.java | 3 ---
.../apache/rocketmq/common/protocol/heartbeat/MessageModel.java | 1 -
.../apache/rocketmq/common/protocol/heartbeat/ProducerData.java | 3 ---
.../rocketmq/common/protocol/heartbeat/SubscriptionData.java | 3 ---
.../org/apache/rocketmq/common/protocol/route/BrokerData.java | 1 -
.../apache/rocketmq/common/protocol/route/TopicRouteData.java | 3 ---
.../org/apache/rocketmq/common/queue/ConcurrentTreeMap.java | 1 -
.../main/java/org/apache/rocketmq/common/queue/RoundQueue.java | 1 -
.../rocketmq/common/subscription/SubscriptionGroupConfig.java | 3 ---
.../java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java | 3 ---
.../java/org/apache/rocketmq/common/sysflag/PullSysFlag.java | 3 ---
.../org/apache/rocketmq/common/sysflag/SubscriptionSysFlag.java | 3 ---
.../java/org/apache/rocketmq/common/sysflag/TopicSysFlag.java | 1 -
.../main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java | 3 ---
common/src/test/java/org/apache/rocketmq/common/MixAllTest.java | 3 ---
.../java/org/apache/rocketmq/common/filter/FilterAPITest.java | 1 -
.../org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java | 3 ---
.../java/org/apache/rocketmq/filtersrv/FiltersrvController.java | 3 ---
.../java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java | 3 ---
.../rocketmq/filtersrv/processor/DefaultRequestProcessor.java | 3 ---
.../java/org/apache/rocketmq/namesrv/NamesrvController.java | 3 ---
.../main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java | 3 ---
.../org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java | 3 ---
.../rocketmq/namesrv/kvconfig/KVConfigSerializeWrapper.java | 3 ---
.../rocketmq/namesrv/processor/ClusterTestRequestProcessor.java | 3 ---
.../rocketmq/namesrv/processor/DefaultRequestProcessor.java | 3 ---
.../rocketmq/namesrv/routeinfo/BrokerHousekeepingService.java | 3 ---
.../org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java | 3 ---
.../java/org/apache/rocketmq/remoting/ChannelEventListener.java | 1 -
.../java/org/apache/rocketmq/remoting/CommandCustomHeader.java | 3 ---
.../main/java/org/apache/rocketmq/remoting/InvokeCallback.java | 1 -
.../main/java/org/apache/rocketmq/remoting/RemotingClient.java | 1 -
.../main/java/org/apache/rocketmq/remoting/RemotingServer.java | 1 -
.../java/org/apache/rocketmq/remoting/annotation/CFNotNull.java | 3 ---
.../org/apache/rocketmq/remoting/annotation/CFNullable.java | 3 ---
.../src/main/java/org/apache/rocketmq/remoting/common/Pair.java | 3 ---
.../org/apache/rocketmq/remoting/common/RemotingHelper.java | 3 ---
.../java/org/apache/rocketmq/remoting/common/RemotingUtil.java | 3 ---
.../rocketmq/remoting/common/SemaphoreReleaseOnlyOnce.java | 3 ---
.../java/org/apache/rocketmq/remoting/common/ServiceThread.java | 1 -
.../rocketmq/remoting/exception/RemotingCommandException.java | 3 ---
.../rocketmq/remoting/exception/RemotingConnectException.java | 3 ---
.../apache/rocketmq/remoting/exception/RemotingException.java | 3 ---
.../remoting/exception/RemotingSendRequestException.java | 3 ---
.../rocketmq/remoting/exception/RemotingTimeoutException.java | 3 ---
.../remoting/exception/RemotingTooMuchRequestException.java | 3 ---
.../org/apache/rocketmq/remoting/netty/NettyClientConfig.java | 1 -
.../java/org/apache/rocketmq/remoting/netty/NettyDecoder.java | 1 -
.../java/org/apache/rocketmq/remoting/netty/NettyEncoder.java | 1 -
.../java/org/apache/rocketmq/remoting/netty/NettyEvent.java | 3 ---
.../java/org/apache/rocketmq/remoting/netty/NettyEventType.java | 1 -
.../apache/rocketmq/remoting/netty/NettyRemotingAbstract.java | 3 ---
.../org/apache/rocketmq/remoting/netty/NettyRemotingClient.java | 3 ---
.../apache/rocketmq/remoting/netty/NettyRequestProcessor.java | 1 -
.../org/apache/rocketmq/remoting/netty/NettyServerConfig.java | 1 -
.../java/org/apache/rocketmq/remoting/netty/ResponseFuture.java | 3 ---
.../org/apache/rocketmq/remoting/protocol/RemotingCommand.java | 3 ---
.../apache/rocketmq/remoting/protocol/RemotingCommandType.java | 1 -
.../apache/rocketmq/remoting/protocol/RemotingSerializable.java | 1 -
.../apache/rocketmq/remoting/protocol/RocketMQSerializable.java | 1 -
.../src/test/java/org/apache/rocketmq/remoting/MixTest.java | 3 ---
.../test/java/org/apache/rocketmq/remoting/NettyRPCTest.java | 3 ---
.../java/org/apache/rocketmq/subclass/TestSubClassAuto.java | 3 ---
.../org/apache/rocketmq/store/AllocateMappedFileService.java | 1 -
.../java/org/apache/rocketmq/store/AppendMessageCallback.java | 1 -
.../java/org/apache/rocketmq/store/AppendMessageResult.java | 1 -
.../java/org/apache/rocketmq/store/AppendMessageStatus.java | 1 -
store/src/main/java/org/apache/rocketmq/store/CommitLog.java | 1 -
store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java | 3 ---
.../java/org/apache/rocketmq/store/DefaultMessageFilter.java | 3 ---
.../java/org/apache/rocketmq/store/DefaultMessageStore.java | 3 ---
.../main/java/org/apache/rocketmq/store/DispatchRequest.java | 3 ---
.../main/java/org/apache/rocketmq/store/GetMessageResult.java | 3 ---
.../main/java/org/apache/rocketmq/store/GetMessageStatus.java | 3 ---
store/src/main/java/org/apache/rocketmq/store/MappedFile.java | 3 ---
.../main/java/org/apache/rocketmq/store/MappedFileQueue.java | 3 ---
.../java/org/apache/rocketmq/store/MessageExtBrokerInner.java | 3 ---
.../src/main/java/org/apache/rocketmq/store/MessageFilter.java | 3 ---
store/src/main/java/org/apache/rocketmq/store/MessageStore.java | 3 ---
.../main/java/org/apache/rocketmq/store/PutMessageResult.java | 3 ---
.../main/java/org/apache/rocketmq/store/PutMessageStatus.java | 3 ---
.../main/java/org/apache/rocketmq/store/QueryMessageResult.java | 3 ---
.../main/java/org/apache/rocketmq/store/ReferenceResource.java | 3 ---
store/src/main/java/org/apache/rocketmq/store/RunningFlags.java | 3 ---
.../org/apache/rocketmq/store/SelectMappedBufferResult.java | 3 ---
.../main/java/org/apache/rocketmq/store/StoreCheckpoint.java | 3 ---
.../main/java/org/apache/rocketmq/store/StoreStatsService.java | 3 ---
store/src/main/java/org/apache/rocketmq/store/StoreUtil.java | 1 -
.../main/java/org/apache/rocketmq/store/TransientStorePool.java | 3 ---
.../main/java/org/apache/rocketmq/store/config/BrokerRole.java | 3 ---
.../java/org/apache/rocketmq/store/config/FlushDiskType.java | 3 ---
.../org/apache/rocketmq/store/config/MessageStoreConfig.java | 4 ----
.../main/java/org/apache/rocketmq/store/ha/HAConnection.java | 5 -----
store/src/main/java/org/apache/rocketmq/store/ha/HAService.java | 3 ---
.../java/org/apache/rocketmq/store/ha/WaitNotifyObject.java | 3 ---
.../main/java/org/apache/rocketmq/store/index/IndexFile.java | 3 ---
.../main/java/org/apache/rocketmq/store/index/IndexHeader.java | 1 -
.../main/java/org/apache/rocketmq/store/index/IndexService.java | 3 ---
.../java/org/apache/rocketmq/store/index/QueryOffsetResult.java | 3 ---
.../rocketmq/store/schedule/DelayOffsetSerializeWrapper.java | 1 -
.../apache/rocketmq/store/schedule/ScheduleMessageService.java | 1 -
.../main/java/org/apache/rocketmq/store/stats/BrokerStats.java | 3 ---
.../java/org/apache/rocketmq/store/DefaultMessageStoreTest.java | 3 ---
.../java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java | 3 ---
.../org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java | 3 ---
.../java/org/apache/rocketmq/tools/command/CommandUtil.java | 3 ---
.../java/org/apache/rocketmq/tools/command/MQAdminStartup.java | 3 ---
.../main/java/org/apache/rocketmq/tools/command/SubCommand.java | 3 ---
.../tools/command/broker/BrokerConsumeStatsSubCommad.java | 3 ---
.../rocketmq/tools/command/broker/BrokerStatusSubCommand.java | 3 ---
.../rocketmq/tools/command/broker/CleanExpiredCQSubCommand.java | 3 ---
.../rocketmq/tools/command/broker/CleanUnusedTopicCommand.java | 3 ---
.../rocketmq/tools/command/broker/GetBrokerConfigCommand.java | 3 ---
.../rocketmq/tools/command/broker/SendMsgStatusCommand.java | 3 ---
.../tools/command/broker/UpdateBrokerConfigSubCommand.java | 3 ---
.../rocketmq/tools/command/cluster/CLusterSendMsgRTCommand.java | 3 ---
.../rocketmq/tools/command/cluster/ClusterListSubCommand.java | 3 ---
.../tools/command/connection/ConsumerConnectionSubCommand.java | 3 ---
.../tools/command/connection/ProducerConnectionSubCommand.java | 3 ---
.../tools/command/consumer/ConsumerProgressSubCommand.java | 3 ---
.../tools/command/consumer/ConsumerStatusSubCommand.java | 3 ---
.../rocketmq/tools/command/consumer/ConsumerSubCommand.java | 3 ---
.../tools/command/consumer/DeleteSubscriptionGroupCommand.java | 3 ---
.../tools/command/consumer/StartMonitoringSubCommand.java | 3 ---
.../tools/command/consumer/UpdateSubGroupSubCommand.java | 3 ---
.../rocketmq/tools/command/message/PrintMessageSubCommand.java | 3 ---
.../rocketmq/tools/command/message/QueryMsgByIdSubCommand.java | 3 ---
.../rocketmq/tools/command/message/QueryMsgByKeySubCommand.java | 1 -
.../tools/command/message/QueryMsgByOffsetSubCommand.java | 3 ---
.../rocketmq/tools/command/namesrv/DeleteKvConfigCommand.java | 1 -
.../rocketmq/tools/command/namesrv/GetNamesrvConfigCommand.java | 3 ---
.../rocketmq/tools/command/namesrv/UpdateKvConfigCommand.java | 1 -
.../tools/command/namesrv/UpdateNamesrvConfigCommand.java | 3 ---
.../rocketmq/tools/command/offset/ResetOffsetByTimeCommand.java | 3 ---
.../tools/command/offset/ResetOffsetByTimeOldCommand.java | 1 -
.../rocketmq/tools/command/topic/DeleteTopicSubCommand.java | 1 -
.../rocketmq/tools/command/topic/TopicClusterSubCommand.java | 1 -
.../rocketmq/tools/command/topic/TopicListSubCommand.java | 1 -
.../rocketmq/tools/command/topic/TopicRouteSubCommand.java | 1 -
.../rocketmq/tools/command/topic/TopicStatusSubCommand.java | 1 -
.../rocketmq/tools/command/topic/UpdateOrderConfCommand.java | 1 -
.../rocketmq/tools/command/topic/UpdateTopicSubCommand.java | 3 ---
381 files changed, 953 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
index 869e4ab..8e973ac 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
@@ -63,9 +63,6 @@ import java.util.Map;
import java.util.concurrent.*;
-/**
- * @author vintagewang@apache.org
- */
public class BrokerController {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private static final Logger LOG_PROTECTION = LoggerFactory.getLogger(LoggerName.PROTECTION_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
index 2882d2d..86091c4 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
@@ -44,9 +44,6 @@ import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
-/**
- * @author vintagewang@apache.org
- */
public class BrokerStartup {
public static Properties properties = null;
public static CommandLine commandLine = null;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
index 8144b48..a994503 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
@@ -20,9 +20,6 @@ import org.apache.rocketmq.remoting.protocol.LanguageCode;
import io.netty.channel.Channel;
-/**
- * @author vintagewang@apache.org
- */
public class ClientChannelInfo {
private final Channel channel;
private final String clientId;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java
index 2842bd6..856ce72 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java
@@ -29,9 +29,6 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-/**
- * @author vintagewang@apache.org
- */
public class ClientHousekeepingService implements ChannelEventListener {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final BrokerController brokerController;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java
index 6265d43..d5b056e 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java
@@ -33,9 +33,6 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-/**
- * @author vintagewang@apache.org
- */
public class ConsumerGroupInfo {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final String groupName;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java
index d580b26..368582a 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java
@@ -21,9 +21,6 @@ import io.netty.channel.Channel;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public interface ConsumerIdsChangeListener {
void consumerIdsChanged(final String group, final List<Channel> channels);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java
index a9490a6..95ed478 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java
@@ -34,9 +34,6 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-/**
- * @author vintagewang@apache.org
- */
public class ConsumerManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private static final long CHANNEL_EXPIRED_TIMEOUT = 1000 * 120;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java b/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java
index b974db4..b60fcb3 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java
@@ -22,9 +22,6 @@ import io.netty.channel.Channel;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class DefaultConsumerIdsChangeListener implements ConsumerIdsChangeListener {
private final BrokerController brokerController;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java
index 8abb903..0f9954b 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java
@@ -32,9 +32,6 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-/**
- * @author vintagewang@apache.org
- */
public class ProducerManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private static final long LOCK_TIMEOUT_MILLIS = 3000;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java b/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
index 70027cd..40eff81 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
@@ -55,9 +55,6 @@ import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
-/**
- * @author vintagewang@apache.org
- */
public class Broker2Client {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final BrokerController brokerController;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java b/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java
index 1fa835c..82ca014 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java
@@ -28,9 +28,6 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-/**
- * @author vintagewang@apache.org
- */
public class RebalanceLockManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.REBALANCE_LOCK_LOGGER_NAME);
private final static long REBALANCE_LOCK_MAX_LIVE_TIME = Long.parseLong(System.getProperty(
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
index 2f4b568..5359368 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
@@ -29,9 +29,6 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-/**
- * @author vintagewang@apache.org
- */
public class BrokerFastFailure {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl(
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java
index 9891222..8c4c5e8 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java
@@ -19,9 +19,6 @@ package org.apache.rocketmq.broker.latency;
import java.util.concurrent.*;
-/**
- * @author vintagewang@apache.org
- */
public class BrokerFixedThreadPoolExecutor extends ThreadPoolExecutor {
public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit, final BlockingQueue<Runnable> workQueue) {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/latency/FutureTaskExt.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/latency/FutureTaskExt.java b/broker/src/main/java/org/apache/rocketmq/broker/latency/FutureTaskExt.java
index a6a01b2..9454a57 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/latency/FutureTaskExt.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/latency/FutureTaskExt.java
@@ -20,9 +20,6 @@ package org.apache.rocketmq.broker.latency;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
-/**
- * @author vintagewang@apache.org
- */
public class FutureTaskExt<V> extends FutureTask<V> {
private final Runnable runnable;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
index a6510c7..e261b40 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
@@ -20,9 +20,6 @@ import java.util.ArrayList;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class ManyPullRequest {
private final ArrayList<PullRequest> pullRequestList = new ArrayList<PullRequest>();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java
index b3cf00b..40716f8 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java
@@ -21,9 +21,6 @@ import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import io.netty.channel.Channel;
-/**
- * @author vintagewang@apache.org
- */
public class PullRequest {
private final RemotingCommand requestCommand;
private final Channel clientChannel;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java
index d6e4ac9..5182664 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java
@@ -30,9 +30,6 @@ import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
-/**
- * @author vintagewang@apache.org
- */
public class PullRequestHoldService extends ServiceThread {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private static final String TOPIC_QUEUEID_SEPARATOR = "@";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java b/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
index 7188e8d..06ceb36 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
@@ -30,9 +30,6 @@ import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
-/**
- * @author vintagewang@apache.org
- */
public class ConsumerOffsetManager extends ConfigManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private static final String TOPIC_GROUP_SEPARATOR = "@";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java b/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
index 335c105..3d969c4 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
@@ -41,10 +41,6 @@ import java.util.ArrayList;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- * @author manhong.yqd
- */
public class BrokerOuterAPI {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final RemotingClient remotingClient;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java
index 9369bd0..e4c3045 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java
@@ -26,9 +26,6 @@ import java.nio.channels.WritableByteChannel;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class ManyMessageTransfer extends AbstractReferenceCounted implements FileRegion {
private final ByteBuffer byteBufferHeader;
private final GetMessageResult getMessageResult;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java
index ed56be0..3f00ece 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java
@@ -25,9 +25,6 @@ import java.nio.ByteBuffer;
import java.nio.channels.WritableByteChannel;
-/**
- * @author vintagewang@apache.org
- */
public class OneMessageTransfer extends AbstractReferenceCounted implements FileRegion {
private final ByteBuffer byteBufferHeader;
private final SelectMappedBufferResult selectMappedBufferResult;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java
index ec51508..146770a 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java
@@ -26,9 +26,6 @@ import java.nio.channels.WritableByteChannel;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class QueryMessageTransfer extends AbstractReferenceCounted implements FileRegion {
private final ByteBuffer byteBufferHeader;
private final QueryMessageResult queryMessageResult;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
index 8a285e8..f04e86c 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
@@ -53,9 +53,6 @@ import java.util.Map;
import java.util.Random;
-/**
- * @author vintagewang@apache.org
- */
public abstract class AbstractSendMessageProcessor implements NettyRequestProcessor {
protected static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
index 4588d2d..d2d4bc7 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
@@ -61,10 +61,6 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
-/**
- * @author vintagewang@apache.org
- * @author manhong.yqd
- */
public class AdminBrokerProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final BrokerController brokerController;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
index c7b2972..62de995 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
@@ -39,9 +39,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- * @author vintagewang@apache.org
- */
public class ClientManageProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final BrokerController brokerController;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
index ef15589..c0c43e0 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
@@ -33,9 +33,6 @@ import org.slf4j.LoggerFactory;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class ConsumerManageProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
index d86d03b..c493c70 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
@@ -38,9 +38,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- * @author vintagewang@apache.org
- */
public class EndTransactionProcessor implements NettyRequestProcessor {
private static final Logger LOGGER = LoggerFactory.getLogger(LoggerName.TRANSACTION_LOGGER_NAME);
private final BrokerController brokerController;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java
index 781bd69..67e55a4 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java
@@ -25,9 +25,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- * @author vintagewang@apache.org
- */
public class ForwardRequestProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
index 7625d21..041037f 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
@@ -57,9 +57,6 @@ import java.nio.ByteBuffer;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class PullMessageProcessor implements NettyRequestProcessor {
private static final Logger LOG = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final BrokerController brokerController;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
index 5c60255..0b6b775 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
@@ -39,9 +39,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- * @author vintagewang@apache.org
- */
public class QueryMessageProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
index 5cebd0e..6002df2 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
@@ -48,9 +48,6 @@ import java.net.SocketAddress;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class SendMessageProcessor extends AbstractSendMessageProcessor implements NettyRequestProcessor {
private List<ConsumeMessageHook> consumeMessageHookList;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java b/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
index 049c07d..2db2317 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
@@ -30,10 +30,6 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
-/**
- * @author vintagewang@apache.org
- * @author manhong.yqd
- */
public class SlaveSynchronize {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final BrokerController brokerController;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java b/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java
index c4432fa..7865bc7 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java
@@ -33,9 +33,6 @@ import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
-/**
- * @author vintagewang@apache.org
- */
public class SubscriptionGroupManager extends ConfigManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java b/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java
index 26a898c..9e14332 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java
@@ -42,9 +42,6 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-/**
- * @author vintagewang@apache.org
- */
public class TopicConfigManager extends ConfigManager {
private static final Logger LOG = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private static final long LOCK_TIMEOUT_MILLIS = 3000;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java b/broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java
index 79f82a6..6e7b9b0 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java
@@ -26,9 +26,6 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- * @author shtykh_roman
- */
public class BrokerControllerTest {
protected Logger logger = LoggerFactory.getLogger(BrokerControllerTest.class);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java b/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
index cbc041f..4fd7a5b 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
@@ -33,9 +33,6 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.Random;
-/**
- * @author zander
- */
public class BrokerTestHarness {
protected BrokerController brokerController = null;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java b/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
index 79013af..0ff589d 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
@@ -39,9 +39,6 @@ import org.junit.Test;
import static org.junit.Assert.*;
-/**
- * @author zander
- */
public class SendMessageTest extends BrokerTestHarness{
MQClientAPIImpl client = new MQClientAPIImpl(new NettyClientConfig(), null, null, new ClientConfig());
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java b/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
index 8063ff9..d6be5fb 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
@@ -26,9 +26,6 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
-/**
- * @author zander
- */
public class ConsumerOffsetManagerTest extends BrokerTestHarness {
@Test
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java b/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
index e199f8d..ab9ab6f 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
@@ -28,9 +28,6 @@ import org.junit.Test;
import static org.junit.Assert.*;
-/**
- * @author zander
- */
public class TopicConfigManagerTest extends BrokerTestHarness {
@Test
public void testFlushTopicConfig() throws Exception {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/ClientConfig.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 b4cd41c..8afca13 100644
--- a/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java
+++ b/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java
@@ -24,8 +24,6 @@ import org.apache.rocketmq.remoting.common.RemotingUtil;
/**
* Client Common configuration
*
- * @author vintagewang@apache.org
- * @author vongosling@apache.org
*/
public class ClientConfig {
public static final String SEND_MESSAGE_WITH_VIP_CHANNEL_PROPERTY = "com.rocketmq.sendMessageWithVIPChannel";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java b/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
index f350073..6596855 100644
--- a/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
+++ b/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
@@ -26,7 +26,6 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
/**
* Base interface for MQ management
*
- * @author vintagewang@apache.org
*/
public interface MQAdmin {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/MQHelper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/MQHelper.java b/client/src/main/java/org/apache/rocketmq/client/MQHelper.java
index efca00f..b4ddb08 100644
--- a/client/src/main/java/org/apache/rocketmq/client/MQHelper.java
+++ b/client/src/main/java/org/apache/rocketmq/client/MQHelper.java
@@ -26,9 +26,6 @@ import java.util.Set;
import java.util.TreeSet;
-/**
- * @author vintagewang@apache.org
- */
public class MQHelper {
public static void resetOffsetByTimestamp(
final MessageModel messageModel,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/QueryResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/QueryResult.java b/client/src/main/java/org/apache/rocketmq/client/QueryResult.java
index 16f0f83..af3649b 100644
--- a/client/src/main/java/org/apache/rocketmq/client/QueryResult.java
+++ b/client/src/main/java/org/apache/rocketmq/client/QueryResult.java
@@ -21,9 +21,6 @@ import org.apache.rocketmq.common.message.MessageExt;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class QueryResult {
private final long indexLastUpdateTimestamp;
private final List<MessageExt> messageList;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/Validators.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/Validators.java b/client/src/main/java/org/apache/rocketmq/client/Validators.java
index e977d44..92fc53b 100644
--- a/client/src/main/java/org/apache/rocketmq/client/Validators.java
+++ b/client/src/main/java/org/apache/rocketmq/client/Validators.java
@@ -31,7 +31,6 @@ import java.util.regex.Pattern;
/**
* Common Validator
*
- * @author manhong.yqd
*/
public class Validators {
public static final String VALID_PATTERN_STR = "^[%|a-zA-Z0-9_-]+$";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java b/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java
index 2cc0f2c..bc4ca6c 100644
--- a/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java
+++ b/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.client.admin;
-/**
- * @author vintagewang@apache.org
- */
public interface MQAdminExtInner {
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java b/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java
index 9fb2c48..81a71e4 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java
@@ -24,8 +24,6 @@ import java.util.List;
/**
* Strategy Algorithm for message allocating between consumers
*
- * @author vintagewang@apache.org
- * @author vongosling@apache.org
*/
public interface AllocateMessageQueueStrategy {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
index aac4207..156b3d0 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
@@ -38,7 +38,6 @@ import java.util.Set;
/**
* Default pulling consumer
*
- * @author vintagewang@apache.org
*/
public class DefaultMQPullConsumer extends ClientConfig implements MQPullConsumer {
protected final transient DefaultMQPullConsumerImpl defaultMQPullConsumerImpl;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
index 2575827..228e075 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
@@ -44,7 +44,6 @@ import java.util.Set;
/**
* Wrapped push consumer.in fact,it works as remarkable as the pull consumer
*
- * @author vintagewang@apache.org
*/
public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsumer {
protected final transient DefaultMQPushConsumerImpl defaultMQPushConsumerImpl;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
index 6d5f7da..9d9c72b 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
@@ -29,7 +29,6 @@ import java.util.Set;
/**
* Message queue consumer interface
*
- * @author vintagewang@apache.org
*/
public interface MQConsumer extends MQAdmin {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
index 036fca2..2335e3d 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
@@ -28,7 +28,6 @@ import java.util.Set;
/**
* Pulling consumer interface
*
- * @author vintagewang@apache.org
*/
public interface MQPullConsumer extends MQConsumer {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java
index 5a36ce6..da8ffb5 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java
@@ -34,7 +34,6 @@ import java.util.concurrent.TimeUnit;
/**
* Schedule service for pull consumer
*
- * @author vintagewang@apache.org
*/
public class MQPullConsumerScheduleService {
private final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
index 76f7cea..b04956c 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
@@ -25,7 +25,6 @@ import org.apache.rocketmq.client.exception.MQClientException;
/**
* Push consumer
*
- * @author vintagewang@apache.org
*/
public interface MQPushConsumer extends MQConsumer {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
index 5d50252..7a08348 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
@@ -24,8 +24,6 @@ import java.util.Set;
/**
* A MessageQueueListener is implemented by the application and may be specified when a message queue changed
*
- * @author vintagewang@apache.org
- * @author vongosling@apache.org
*/
public interface MessageQueueListener {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
index 508050d..cf554c4 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
@@ -19,7 +19,6 @@ package org.apache.rocketmq.client.consumer;
/**
* Async message pulling interface
*
- * @author vintagewang@apache.org
*/
public interface PullCallback {
void onSuccess(final PullResult pullResult);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java
index 4bd9a78..1cb23ce 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java
@@ -21,9 +21,6 @@ import org.apache.rocketmq.common.message.MessageExt;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class PullResult {
private final PullStatus pullStatus;
private final long nextBeginOffset;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java
index 79378a3..b2a3c8c 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.client.consumer;
-/**
- * @author vintagewang@apache.org
- */
public enum PullStatus {
/**
* Founded
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java
index 75fffe8..981ceaf 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java
@@ -22,7 +22,6 @@ import org.apache.rocketmq.common.message.MessageQueue;
/**
* Consumer concurrent consumption context
*
- * @author vintagewang@apache.org
*/
public class ConsumeConcurrentlyContext {
private final MessageQueue messageQueue;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java
index 21febbd..cd66699 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.client.consumer.listener;
-/**
- * @author vintagewang@apache.org
- */
public enum ConsumeConcurrentlyStatus {
/**
* Success consumption
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
index cfca174..3c1ef3d 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
@@ -22,7 +22,6 @@ import org.apache.rocketmq.common.message.MessageQueue;
/**
* Consumer Orderly consumption context
*
- * @author vintagewang@apache.org
*/
public class ConsumeOrderlyContext {
private final MessageQueue messageQueue;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java
index 2783714..2e55d89 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.client.consumer.listener;
-/**
- * @author vintagewang@apache.org
- */
public enum ConsumeOrderlyStatus {
/**
* Success consumption
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
index 9148b33..5d05452 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
@@ -19,7 +19,6 @@ package org.apache.rocketmq.client.consumer.listener;
/**
* A MessageListener object is used to receive asynchronously delivered messages.
*
- * @author vintagewang@apache.org
*/
public interface MessageListener {
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
index 1c807ce..1c59ef7 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
@@ -24,7 +24,6 @@ import java.util.List;
/**
* A MessageListenerConcurrently object is used to receive asynchronously delivered messages concurrently
*
- * @author vintagewang@apache.org
*/
public interface MessageListenerConcurrently extends MessageListener {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
index 1efd19f..5de976f 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
@@ -24,7 +24,6 @@ import java.util.List;
/**
* A MessageListenerConcurrently object is used to receive asynchronously delivered messages orderly.one queue,one thread
*
- * @author vintagewang@apache.org
*/
public interface MessageListenerOrderly extends MessageListener {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragely.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragely.java b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragely.java
index 747df83..218f659 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragely.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragely.java
@@ -28,7 +28,6 @@ import java.util.List;
/**
* Average Hashing queue algorithm
*
- * @author manhong.yqd
*/
public class AllocateMessageQueueAveragely implements AllocateMessageQueueStrategy {
private final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragelyByCircle.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragelyByCircle.java b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragelyByCircle.java
index d6ab041..d612d4f 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragelyByCircle.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragelyByCircle.java
@@ -28,7 +28,6 @@ import java.util.List;
/**
* Cycle average Hashing queue algorithm
*
- * @author manhong.yqd
*/
public class AllocateMessageQueueAveragelyByCircle implements AllocateMessageQueueStrategy {
private final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java
index 8886cb3..c8fe2d1 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java
@@ -22,9 +22,6 @@ import org.apache.rocketmq.common.message.MessageQueue;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class AllocateMessageQueueByConfig implements AllocateMessageQueueStrategy {
private List<MessageQueue> messageQueueList;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
index 2e32700..bdaeb58 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
@@ -39,7 +39,6 @@ import java.util.concurrent.atomic.AtomicLong;
/**
* Local storage implementation
*
- * @author vintagewang@apache.org
*/
public class LocalFileOffsetStore implements OffsetStore {
public final static String LOCAL_OFFSET_STORE_DIR = System.getProperty(
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
index b103084..a9fadf2 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
@@ -26,7 +26,6 @@ import java.util.concurrent.atomic.AtomicLong;
/**
* Wrapper class for offset serialization
*
- * @author vintagewang@apache.org
*/
public class OffsetSerializeWrapper extends RemotingSerializable {
private ConcurrentHashMap<MessageQueue, AtomicLong> offsetTable =
[34/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
deleted file mode 100644
index 82c342f..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
+++ /dev/null
@@ -1,1071 +0,0 @@
-/**
- * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.client.impl.consumer;
-
-import com.alibaba.rocketmq.client.QueryResult;
-import com.alibaba.rocketmq.client.Validators;
-import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
-import com.alibaba.rocketmq.client.consumer.PullCallback;
-import com.alibaba.rocketmq.client.consumer.PullResult;
-import com.alibaba.rocketmq.client.consumer.listener.MessageListener;
-import com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
-import com.alibaba.rocketmq.client.consumer.listener.MessageListenerOrderly;
-import com.alibaba.rocketmq.client.consumer.store.LocalFileOffsetStore;
-import com.alibaba.rocketmq.client.consumer.store.OffsetStore;
-import com.alibaba.rocketmq.client.consumer.store.ReadOffsetType;
-import com.alibaba.rocketmq.client.consumer.store.RemoteBrokerOffsetStore;
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.hook.ConsumeMessageContext;
-import com.alibaba.rocketmq.client.hook.ConsumeMessageHook;
-import com.alibaba.rocketmq.client.hook.FilterMessageHook;
-import com.alibaba.rocketmq.client.impl.CommunicationMode;
-import com.alibaba.rocketmq.client.impl.MQClientManager;
-import com.alibaba.rocketmq.client.impl.factory.MQClientInstance;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.client.stat.ConsumerStatsManager;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.ServiceState;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.consumer.ConsumeFromWhere;
-import com.alibaba.rocketmq.common.filter.FilterAPI;
-import com.alibaba.rocketmq.common.help.FAQUrl;
-import com.alibaba.rocketmq.common.message.*;
-import com.alibaba.rocketmq.common.protocol.body.ConsumeStatus;
-import com.alibaba.rocketmq.common.protocol.body.ConsumerRunningInfo;
-import com.alibaba.rocketmq.common.protocol.body.ProcessQueueInfo;
-import com.alibaba.rocketmq.common.protocol.body.QueueTimeSpan;
-import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType;
-import com.alibaba.rocketmq.common.protocol.heartbeat.MessageModel;
-import com.alibaba.rocketmq.common.protocol.heartbeat.SubscriptionData;
-import com.alibaba.rocketmq.common.protocol.route.BrokerData;
-import com.alibaba.rocketmq.common.protocol.route.TopicRouteData;
-import com.alibaba.rocketmq.common.sysflag.PullSysFlag;
-import com.alibaba.rocketmq.remoting.RPCHook;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import com.alibaba.rocketmq.remoting.exception.RemotingException;
-import org.slf4j.Logger;
-
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-
-
-/**
- * @author shijia.wxr
- */
-public class DefaultMQPushConsumerImpl implements MQConsumerInner {
- /**
- * Delay some time when exception occur
- */
- private static final long PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION = 3000;
- /**
- * Flow control interval
- */
- private static final long PULL_TIME_DELAY_MILLS_WHEN_FLOW_CONTROL = 50;
- /**
- * Delay some time when suspend pull service
- */
- private static final long PULL_TIME_DELAY_MILLS_WHEN_SUSPEND = 1000;
- private static final long BROKER_SUSPEND_MAX_TIME_MILLIS = 1000 * 15;
- private static final long CONSUMER_TIMEOUT_MILLIS_WHEN_SUSPEND = 1000 * 30;
- private final Logger log = ClientLogger.getLog();
- private final DefaultMQPushConsumer defaultMQPushConsumer;
- private final RebalanceImpl rebalanceImpl = new RebalancePushImpl(this);
- private final ArrayList<FilterMessageHook> filterMessageHookList = new ArrayList<FilterMessageHook>();
- private final long consumerStartTimestamp = System.currentTimeMillis();
- private final ArrayList<ConsumeMessageHook> consumeMessageHookList = new ArrayList<ConsumeMessageHook>();
- private final RPCHook rpcHook;
- private ServiceState serviceState = ServiceState.CREATE_JUST;
- private MQClientInstance mQClientFactory;
- private PullAPIWrapper pullAPIWrapper;
- private volatile boolean pause = false;
- private boolean consumeOrderly = false;
- private MessageListener messageListenerInner;
- private OffsetStore offsetStore;
- private ConsumeMessageService consumeMessageService;
- private long flowControlTimes1 = 0;
- private long flowControlTimes2 = 0;
-
-
- public DefaultMQPushConsumerImpl(DefaultMQPushConsumer defaultMQPushConsumer, RPCHook rpcHook) {
- this.defaultMQPushConsumer = defaultMQPushConsumer;
- this.rpcHook = rpcHook;
- }
-
- public void registerFilterMessageHook(final FilterMessageHook hook) {
- this.filterMessageHookList.add(hook);
- log.info("register FilterMessageHook Hook, {}", hook.hookName());
- }
-
- public boolean hasHook() {
- return !this.consumeMessageHookList.isEmpty();
- }
-
- public void registerConsumeMessageHook(final ConsumeMessageHook hook) {
- this.consumeMessageHookList.add(hook);
- log.info("register consumeMessageHook Hook, {}", hook.hookName());
- }
-
- public void executeHookBefore(final ConsumeMessageContext context) {
- if (!this.consumeMessageHookList.isEmpty()) {
- for (ConsumeMessageHook hook : this.consumeMessageHookList) {
- try {
- hook.consumeMessageBefore(context);
- } catch (Throwable e) {
- }
- }
- }
- }
-
- public void executeHookAfter(final ConsumeMessageContext context) {
- if (!this.consumeMessageHookList.isEmpty()) {
- for (ConsumeMessageHook hook : this.consumeMessageHookList) {
- try {
- hook.consumeMessageAfter(context);
- } catch (Throwable e) {
- }
- }
- }
- }
-
- public void createTopic(String key, String newTopic, int queueNum) throws MQClientException {
- createTopic(key, newTopic, queueNum, 0);
- }
-
- public void createTopic(String key, String newTopic, int queueNum, int topicSysFlag) throws MQClientException {
- this.mQClientFactory.getMQAdminImpl().createTopic(key, newTopic, queueNum, topicSysFlag);
- }
-
- public Set<MessageQueue> fetchSubscribeMessageQueues(String topic) throws MQClientException {
- Set<MessageQueue> result = this.rebalanceImpl.getTopicSubscribeInfoTable().get(topic);
- if (null == result) {
- this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic);
- result = this.rebalanceImpl.getTopicSubscribeInfoTable().get(topic);
- }
-
- if (null == result) {
- throw new MQClientException("The topic[" + topic + "] not exist", null);
- }
-
- return result;
- }
-
- public DefaultMQPushConsumer getDefaultMQPushConsumer() {
- return defaultMQPushConsumer;
- }
-
- public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
- return this.mQClientFactory.getMQAdminImpl().earliestMsgStoreTime(mq);
- }
-
- public long maxOffset(MessageQueue mq) throws MQClientException {
- return this.mQClientFactory.getMQAdminImpl().maxOffset(mq);
- }
-
- public long minOffset(MessageQueue mq) throws MQClientException {
- return this.mQClientFactory.getMQAdminImpl().minOffset(mq);
- }
-
- public OffsetStore getOffsetStore() {
- return offsetStore;
- }
-
- public void setOffsetStore(OffsetStore offsetStore) {
- this.offsetStore = offsetStore;
- }
-
- public void pullMessage(final PullRequest pullRequest) {
- final ProcessQueue processQueue = pullRequest.getProcessQueue();
- if (processQueue.isDropped()) {
- log.info("the pull request[{}] is dropped.", pullRequest.toString());
- return;
- }
-
- pullRequest.getProcessQueue().setLastPullTimestamp(System.currentTimeMillis());
-
- try {
- this.makeSureStateOK();
- } catch (MQClientException e) {
- log.warn("pullMessage exception, consumer state not ok", e);
- this.executePullRequestLater(pullRequest, PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION);
- return;
- }
-
- if (this.isPause()) {
- log.warn("consumer was paused, execute pull request later. instanceName={}, group={}", this.defaultMQPushConsumer.getInstanceName(), this.defaultMQPushConsumer.getConsumerGroup());
- this.executePullRequestLater(pullRequest, PULL_TIME_DELAY_MILLS_WHEN_SUSPEND);
- return;
- }
-
- long size = processQueue.getMsgCount().get();
- if (size > this.defaultMQPushConsumer.getPullThresholdForQueue()) {
- this.executePullRequestLater(pullRequest, PULL_TIME_DELAY_MILLS_WHEN_FLOW_CONTROL);
- if ((flowControlTimes1++ % 1000) == 0) {
- log.warn(
- "the consumer message buffer is full, so do flow control, minOffset={}, maxOffset={}, size={}, pullRequest={}, flowControlTimes={}",
- processQueue.getMsgTreeMap().firstKey(), processQueue.getMsgTreeMap().lastKey(), size, pullRequest, flowControlTimes1);
- }
- return;
- }
-
- if (!this.consumeOrderly) {
- if (processQueue.getMaxSpan() > this.defaultMQPushConsumer.getConsumeConcurrentlyMaxSpan()) {
- this.executePullRequestLater(pullRequest, PULL_TIME_DELAY_MILLS_WHEN_FLOW_CONTROL);
- if ((flowControlTimes2++ % 1000) == 0) {
- log.warn(
- "the queue's messages, span too long, so do flow control, minOffset={}, maxOffset={}, maxSpan={}, pullRequest={}, flowControlTimes={}",
- processQueue.getMsgTreeMap().firstKey(), processQueue.getMsgTreeMap().lastKey(), processQueue.getMaxSpan(),
- pullRequest, flowControlTimes2);
- }
- return;
- }
- } else {
- if (processQueue.isLocked()) {
- if (!pullRequest.isLockedFirst()) {
- final long offset = this.rebalanceImpl.computePullFromWhere(pullRequest.getMessageQueue());
- boolean brokerBusy = offset < pullRequest.getNextOffset();
- log.info("the first time to pull message, so fix offset from broker. pullRequest: {} NewOffset: {} brokerBusy: {}",
- pullRequest, offset, brokerBusy);
- if (brokerBusy) {
- log.info("[NOTIFYME]the first time to pull message, but pull request offset larger than broker consume offset. pullRequest: {} NewOffset: {}",
- pullRequest, offset);
- }
-
- pullRequest.setLockedFirst(true);
- pullRequest.setNextOffset(offset);
- }
- } else {
- this.executePullRequestLater(pullRequest, PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION);
- log.info("pull message later because not locked in broker, {}", pullRequest);
- return;
- }
- }
-
- final SubscriptionData subscriptionData = this.rebalanceImpl.getSubscriptionInner().get(pullRequest.getMessageQueue().getTopic());
- if (null == subscriptionData) {
- this.executePullRequestLater(pullRequest, PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION);
- log.warn("find the consumer's subscription failed, {}", pullRequest);
- return;
- }
-
- final long beginTimestamp = System.currentTimeMillis();
-
- PullCallback pullCallback = new PullCallback() {
- @Override
- public void onSuccess(PullResult pullResult) {
- if (pullResult != null) {
- pullResult = DefaultMQPushConsumerImpl.this.pullAPIWrapper.processPullResult(pullRequest.getMessageQueue(), pullResult,
- subscriptionData);
-
- switch (pullResult.getPullStatus()) {
- case FOUND:
- long prevRequestOffset = pullRequest.getNextOffset();
- pullRequest.setNextOffset(pullResult.getNextBeginOffset());
- long pullRT = System.currentTimeMillis() - beginTimestamp;
- DefaultMQPushConsumerImpl.this.getConsumerStatsManager().incPullRT(pullRequest.getConsumerGroup(),
- pullRequest.getMessageQueue().getTopic(), pullRT);
-
- long firstMsgOffset = Long.MAX_VALUE;
- if (pullResult.getMsgFoundList() == null || pullResult.getMsgFoundList().isEmpty()) {
- DefaultMQPushConsumerImpl.this.executePullRequestImmediately(pullRequest);
- } else {
- firstMsgOffset = pullResult.getMsgFoundList().get(0).getQueueOffset();
-
- DefaultMQPushConsumerImpl.this.getConsumerStatsManager().incPullTPS(pullRequest.getConsumerGroup(),
- pullRequest.getMessageQueue().getTopic(), pullResult.getMsgFoundList().size());
-
- boolean dispathToConsume = processQueue.putMessage(pullResult.getMsgFoundList());
- DefaultMQPushConsumerImpl.this.consumeMessageService.submitConsumeRequest(//
- pullResult.getMsgFoundList(), //
- processQueue, //
- pullRequest.getMessageQueue(), //
- dispathToConsume);
-
- if (DefaultMQPushConsumerImpl.this.defaultMQPushConsumer.getPullInterval() > 0) {
- DefaultMQPushConsumerImpl.this.executePullRequestLater(pullRequest,
- DefaultMQPushConsumerImpl.this.defaultMQPushConsumer.getPullInterval());
- } else {
- DefaultMQPushConsumerImpl.this.executePullRequestImmediately(pullRequest);
- }
- }
-
- if (pullResult.getNextBeginOffset() < prevRequestOffset//
- || firstMsgOffset < prevRequestOffset) {
- log.warn(
- "[BUG] pull message result maybe data wrong, nextBeginOffset: {} firstMsgOffset: {} prevRequestOffset: {}", //
- pullResult.getNextBeginOffset(), //
- firstMsgOffset, //
- prevRequestOffset);
- }
-
- break;
- case NO_NEW_MSG:
- pullRequest.setNextOffset(pullResult.getNextBeginOffset());
-
- DefaultMQPushConsumerImpl.this.correctTagsOffset(pullRequest);
-
- DefaultMQPushConsumerImpl.this.executePullRequestImmediately(pullRequest);
- break;
- case NO_MATCHED_MSG:
- pullRequest.setNextOffset(pullResult.getNextBeginOffset());
-
- DefaultMQPushConsumerImpl.this.correctTagsOffset(pullRequest);
-
- DefaultMQPushConsumerImpl.this.executePullRequestImmediately(pullRequest);
- break;
- case OFFSET_ILLEGAL:
- log.warn("the pull request offset illegal, {} {}", //
- pullRequest.toString(), pullResult.toString());
- pullRequest.setNextOffset(pullResult.getNextBeginOffset());
-
- pullRequest.getProcessQueue().setDropped(true);
- DefaultMQPushConsumerImpl.this.executeTaskLater(new Runnable() {
-
- @Override
- public void run() {
- try {
- DefaultMQPushConsumerImpl.this.offsetStore.updateOffset(pullRequest.getMessageQueue(),
- pullRequest.getNextOffset(), false);
-
- DefaultMQPushConsumerImpl.this.offsetStore.persist(pullRequest.getMessageQueue());
-
- DefaultMQPushConsumerImpl.this.rebalanceImpl.removeProcessQueue(pullRequest.getMessageQueue());
-
- log.warn("fix the pull request offset, {}", pullRequest);
- } catch (Throwable e) {
- log.error("executeTaskLater Exception", e);
- }
- }
- }, 10000);
- break;
- default:
- break;
- }
- }
- }
-
-
- @Override
- public void onException(Throwable e) {
- if (!pullRequest.getMessageQueue().getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
- log.warn("execute the pull request exception", e);
- }
-
- DefaultMQPushConsumerImpl.this.executePullRequestLater(pullRequest, PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION);
- }
- };
-
- boolean commitOffsetEnable = false;
- long commitOffsetValue = 0L;
- if (MessageModel.CLUSTERING == this.defaultMQPushConsumer.getMessageModel()) {
- commitOffsetValue = this.offsetStore.readOffset(pullRequest.getMessageQueue(), ReadOffsetType.READ_FROM_MEMORY);
- if (commitOffsetValue > 0) {
- commitOffsetEnable = true;
- }
- }
-
- String subExpression = null;
- boolean classFilter = false;
- SubscriptionData sd = this.rebalanceImpl.getSubscriptionInner().get(pullRequest.getMessageQueue().getTopic());
- if (sd != null) {
- if (this.defaultMQPushConsumer.isPostSubscriptionWhenPull() && !sd.isClassFilterMode()) {
- subExpression = sd.getSubString();
- }
-
- classFilter = sd.isClassFilterMode();
- }
-
- int sysFlag = PullSysFlag.buildSysFlag(//
- commitOffsetEnable, // commitOffset
- true, // suspend
- subExpression != null, // subscription
- classFilter // class filter
- );
- try {
- this.pullAPIWrapper.pullKernelImpl(//
- pullRequest.getMessageQueue(), // 1
- subExpression, // 2
- subscriptionData.getSubVersion(), // 3
- pullRequest.getNextOffset(), // 4
- this.defaultMQPushConsumer.getPullBatchSize(), // 5
- sysFlag, // 6
- commitOffsetValue, // 7
- BROKER_SUSPEND_MAX_TIME_MILLIS, // 8
- CONSUMER_TIMEOUT_MILLIS_WHEN_SUSPEND, // 9
- CommunicationMode.ASYNC, // 10
- pullCallback// 11
- );
- } catch (Exception e) {
- log.error("pullKernelImpl exception", e);
- this.executePullRequestLater(pullRequest, PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION);
- }
- }
-
- private void makeSureStateOK() throws MQClientException {
- if (this.serviceState != ServiceState.RUNNING) {
- throw new MQClientException("The consumer service state not OK, "//
- + this.serviceState//
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
- null);
- }
- }
-
- private void executePullRequestLater(final PullRequest pullRequest, final long timeDelay) {
- this.mQClientFactory.getPullMessageService().executePullRequestLater(pullRequest, timeDelay);
- }
-
- public boolean isPause() {
- return pause;
- }
-
- public void setPause(boolean pause) {
- this.pause = pause;
- }
-
- public ConsumerStatsManager getConsumerStatsManager() {
- return this.mQClientFactory.getConsumerStatsManager();
- }
-
- public void executePullRequestImmediately(final PullRequest pullRequest) {
- this.mQClientFactory.getPullMessageService().executePullRequestImmediately(pullRequest);
- }
-
- private void correctTagsOffset(final PullRequest pullRequest) {
- if (0L == pullRequest.getProcessQueue().getMsgCount().get()) {
- this.offsetStore.updateOffset(pullRequest.getMessageQueue(), pullRequest.getNextOffset(), true);
- }
- }
-
- public void executeTaskLater(final Runnable r, final long timeDelay) {
- this.mQClientFactory.getPullMessageService().executeTaskLater(r, timeDelay);
- }
-
- public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
- throws MQClientException, InterruptedException {
- return this.mQClientFactory.getMQAdminImpl().queryMessage(topic, key, maxNum, begin, end);
- }
-
- public MessageExt queryMessageByUniqKey(String topic, String uniqKey) throws MQClientException,
- InterruptedException {
- return this.mQClientFactory.getMQAdminImpl().queryMessageByUniqKey(topic, uniqKey);
- }
-
-
- public void registerMessageListener(MessageListener messageListener) {
- this.messageListenerInner = messageListener;
- }
-
- public void resume() {
- this.pause = false;
- doRebalance();
- log.info("resume this consumer, {}", this.defaultMQPushConsumer.getConsumerGroup());
- }
-
- public void sendMessageBack(MessageExt msg, int delayLevel, final String brokerName)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- try {
- String brokerAddr = (null != brokerName) ? this.mQClientFactory.findBrokerAddressInPublish(brokerName)
- : RemotingHelper.parseSocketAddressAddr(msg.getStoreHost());
- this.mQClientFactory.getMQClientAPIImpl().consumerSendMessageBack(brokerAddr, msg,
- this.defaultMQPushConsumer.getConsumerGroup(), delayLevel, 5000, getMaxReconsumeTimes());
- } catch (Exception e) {
- log.error("sendMessageBack Exception, " + this.defaultMQPushConsumer.getConsumerGroup(), e);
-
- Message newMsg = new Message(MixAll.getRetryTopic(this.defaultMQPushConsumer.getConsumerGroup()), msg.getBody());
-
- String originMsgId = MessageAccessor.getOriginMessageId(msg);
- MessageAccessor.setOriginMessageId(newMsg, UtilAll.isBlank(originMsgId) ? msg.getMsgId() : originMsgId);
-
- newMsg.setFlag(msg.getFlag());
- MessageAccessor.setProperties(newMsg, msg.getProperties());
- MessageAccessor.putProperty(newMsg, MessageConst.PROPERTY_RETRY_TOPIC, msg.getTopic());
- MessageAccessor.setReconsumeTime(newMsg, String.valueOf(msg.getReconsumeTimes() + 1));
- MessageAccessor.setMaxReconsumeTimes(newMsg, String.valueOf(getMaxReconsumeTimes()));
- newMsg.setDelayTimeLevel(3 + msg.getReconsumeTimes());
-
- this.mQClientFactory.getDefaultMQProducer().send(newMsg);
- }
- }
-
- private int getMaxReconsumeTimes() {
- // default reconsume times: 16
- if (this.defaultMQPushConsumer.getMaxReconsumeTimes() == -1) {
- return 16;
- } else {
- return this.defaultMQPushConsumer.getMaxReconsumeTimes();
- }
- }
-
- public void shutdown() {
- switch (this.serviceState) {
- case CREATE_JUST:
- break;
- case RUNNING:
- this.consumeMessageService.shutdown();
- this.persistConsumerOffset();
- this.mQClientFactory.unregisterConsumer(this.defaultMQPushConsumer.getConsumerGroup());
- this.mQClientFactory.shutdown();
- log.info("the consumer [{}] shutdown OK", this.defaultMQPushConsumer.getConsumerGroup());
- this.rebalanceImpl.destroy();
- this.serviceState = ServiceState.SHUTDOWN_ALREADY;
- break;
- case SHUTDOWN_ALREADY:
- break;
- default:
- break;
- }
- }
-
- public void start() throws MQClientException {
- switch (this.serviceState) {
- case CREATE_JUST:
- log.info("the consumer [{}] start beginning. messageModel={}, isUnitMode={}", this.defaultMQPushConsumer.getConsumerGroup(),
- this.defaultMQPushConsumer.getMessageModel(), this.defaultMQPushConsumer.isUnitMode());
- this.serviceState = ServiceState.START_FAILED;
-
- this.checkConfig();
-
- this.copySubscription();
-
- if (this.defaultMQPushConsumer.getMessageModel() == MessageModel.CLUSTERING) {
- this.defaultMQPushConsumer.changeInstanceNameToPID();
- }
-
- this.mQClientFactory = MQClientManager.getInstance().getAndCreateMQClientInstance(this.defaultMQPushConsumer, this.rpcHook);
-
- this.rebalanceImpl.setConsumerGroup(this.defaultMQPushConsumer.getConsumerGroup());
- this.rebalanceImpl.setMessageModel(this.defaultMQPushConsumer.getMessageModel());
- this.rebalanceImpl.setAllocateMessageQueueStrategy(this.defaultMQPushConsumer.getAllocateMessageQueueStrategy());
- this.rebalanceImpl.setmQClientFactory(this.mQClientFactory);
-
- this.pullAPIWrapper = new PullAPIWrapper(
- mQClientFactory,
- this.defaultMQPushConsumer.getConsumerGroup(), isUnitMode());
- this.pullAPIWrapper.registerFilterMessageHook(filterMessageHookList);
-
- if (this.defaultMQPushConsumer.getOffsetStore() != null) {
- this.offsetStore = this.defaultMQPushConsumer.getOffsetStore();
- } else {
- switch (this.defaultMQPushConsumer.getMessageModel()) {
- case BROADCASTING:
- this.offsetStore = new LocalFileOffsetStore(this.mQClientFactory, this.defaultMQPushConsumer.getConsumerGroup());
- break;
- case CLUSTERING:
- this.offsetStore = new RemoteBrokerOffsetStore(this.mQClientFactory, this.defaultMQPushConsumer.getConsumerGroup());
- break;
- default:
- break;
- }
- }
- this.offsetStore.load();
-
- if (this.getMessageListenerInner() instanceof MessageListenerOrderly) {
- this.consumeOrderly = true;
- this.consumeMessageService =
- new ConsumeMessageOrderlyService(this, (MessageListenerOrderly) this.getMessageListenerInner());
- } else if (this.getMessageListenerInner() instanceof MessageListenerConcurrently) {
- this.consumeOrderly = false;
- this.consumeMessageService =
- new ConsumeMessageConcurrentlyService(this, (MessageListenerConcurrently) this.getMessageListenerInner());
- }
-
- this.consumeMessageService.start();
-
- boolean registerOK = mQClientFactory.registerConsumer(this.defaultMQPushConsumer.getConsumerGroup(), this);
- if (!registerOK) {
- this.serviceState = ServiceState.CREATE_JUST;
- this.consumeMessageService.shutdown();
- throw new MQClientException("The consumer group[" + this.defaultMQPushConsumer.getConsumerGroup()
- + "] has been created before, specify another name please." + FAQUrl.suggestTodo(FAQUrl.GROUP_NAME_DUPLICATE_URL),
- null);
- }
-
- mQClientFactory.start();
- log.info("the consumer [{}] start OK.", this.defaultMQPushConsumer.getConsumerGroup());
- this.serviceState = ServiceState.RUNNING;
- break;
- case RUNNING:
- case START_FAILED:
- case SHUTDOWN_ALREADY:
- throw new MQClientException("The PushConsumer service state not OK, maybe started once, "//
- + this.serviceState//
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
- null);
- default:
- break;
- }
-
- this.updateTopicSubscribeInfoWhenSubscriptionChanged();
-
- this.mQClientFactory.sendHeartbeatToAllBrokerWithLock();
-
- this.mQClientFactory.rebalanceImmediately();
- }
-
- private void checkConfig() throws MQClientException {
- Validators.checkGroup(this.defaultMQPushConsumer.getConsumerGroup());
-
- if (null == this.defaultMQPushConsumer.getConsumerGroup()) {
- throw new MQClientException(
- "consumerGroup is null"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
- }
-
- if (this.defaultMQPushConsumer.getConsumerGroup().equals(MixAll.DEFAULT_CONSUMER_GROUP)) {
- throw new MQClientException(
- "consumerGroup can not equal "
- + MixAll.DEFAULT_CONSUMER_GROUP
- + ", please specify another one."
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
- }
-
- if (null == this.defaultMQPushConsumer.getMessageModel()) {
- throw new MQClientException(
- "messageModel is null"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
- }
-
- if (null == this.defaultMQPushConsumer.getConsumeFromWhere()) {
- throw new MQClientException(
- "consumeFromWhere is null"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
- }
-
- Date dt = UtilAll.parseDate(this.defaultMQPushConsumer.getConsumeTimestamp(), UtilAll.YYYY_MMDD_HHMMSS);
- if (null == dt) {
- throw new MQClientException(
- "consumeTimestamp is invalid, YYYY_MMDD_HHMMSS"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
- }
-
- // allocateMessageQueueStrategy
- if (null == this.defaultMQPushConsumer.getAllocateMessageQueueStrategy()) {
- throw new MQClientException(
- "allocateMessageQueueStrategy is null"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
- }
-
- // subscription
- if (null == this.defaultMQPushConsumer.getSubscription()) {
- throw new MQClientException(
- "subscription is null"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
- }
-
- // messageListener
- if (null == this.defaultMQPushConsumer.getMessageListener()) {
- throw new MQClientException(
- "messageListener is null"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
- }
-
- boolean orderly = this.defaultMQPushConsumer.getMessageListener() instanceof MessageListenerOrderly;
- boolean concurrently = this.defaultMQPushConsumer.getMessageListener() instanceof MessageListenerConcurrently;
- if (!orderly && !concurrently) {
- throw new MQClientException(
- "messageListener must be instanceof MessageListenerOrderly or MessageListenerConcurrently"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
- }
-
- // consumeThreadMin
- if (this.defaultMQPushConsumer.getConsumeThreadMin() < 1
- || this.defaultMQPushConsumer.getConsumeThreadMin() > 1000
- || this.defaultMQPushConsumer.getConsumeThreadMin() > this.defaultMQPushConsumer.getConsumeThreadMax()) {
- throw new MQClientException(
- "consumeThreadMin Out of range [1, 1000]"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
- }
-
- // consumeThreadMax
- if (this.defaultMQPushConsumer.getConsumeThreadMax() < 1 || this.defaultMQPushConsumer.getConsumeThreadMax() > 1000) {
- throw new MQClientException(
- "consumeThreadMax Out of range [1, 1000]"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
- }
-
- // consumeConcurrentlyMaxSpan
- if (this.defaultMQPushConsumer.getConsumeConcurrentlyMaxSpan() < 1
- || this.defaultMQPushConsumer.getConsumeConcurrentlyMaxSpan() > 65535) {
- throw new MQClientException(
- "consumeConcurrentlyMaxSpan Out of range [1, 65535]"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
- }
-
- // pullThresholdForQueue
- if (this.defaultMQPushConsumer.getPullThresholdForQueue() < 1 || this.defaultMQPushConsumer.getPullThresholdForQueue() > 65535) {
- throw new MQClientException(
- "pullThresholdForQueue Out of range [1, 65535]"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
- }
-
- // pullInterval
- if (this.defaultMQPushConsumer.getPullInterval() < 0 || this.defaultMQPushConsumer.getPullInterval() > 65535) {
- throw new MQClientException(
- "pullInterval Out of range [0, 65535]"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
- }
-
- // consumeMessageBatchMaxSize
- if (this.defaultMQPushConsumer.getConsumeMessageBatchMaxSize() < 1
- || this.defaultMQPushConsumer.getConsumeMessageBatchMaxSize() > 1024) {
- throw new MQClientException(
- "consumeMessageBatchMaxSize Out of range [1, 1024]"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
- }
-
- // pullBatchSize
- if (this.defaultMQPushConsumer.getPullBatchSize() < 1 || this.defaultMQPushConsumer.getPullBatchSize() > 1024) {
- throw new MQClientException(
- "pullBatchSize Out of range [1, 1024]"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
- }
- }
-
- private void copySubscription() throws MQClientException {
- try {
- Map<String, String> sub = this.defaultMQPushConsumer.getSubscription();
- if (sub != null) {
- for (final Map.Entry<String, String> entry : sub.entrySet()) {
- final String topic = entry.getKey();
- final String subString = entry.getValue();
- SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPushConsumer.getConsumerGroup(), //
- topic, subString);
- this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData);
- }
- }
-
- if (null == this.messageListenerInner) {
- this.messageListenerInner = this.defaultMQPushConsumer.getMessageListener();
- }
-
- switch (this.defaultMQPushConsumer.getMessageModel()) {
- case BROADCASTING:
- break;
- case CLUSTERING:
- final String retryTopic = MixAll.getRetryTopic(this.defaultMQPushConsumer.getConsumerGroup());
- SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPushConsumer.getConsumerGroup(), //
- retryTopic, SubscriptionData.SUB_ALL);
- this.rebalanceImpl.getSubscriptionInner().put(retryTopic, subscriptionData);
- break;
- default:
- break;
- }
- } catch (Exception e) {
- throw new MQClientException("subscription exception", e);
- }
- }
-
- public MessageListener getMessageListenerInner() {
- return messageListenerInner;
- }
-
- private void updateTopicSubscribeInfoWhenSubscriptionChanged() {
- Map<String, SubscriptionData> subTable = this.getSubscriptionInner();
- if (subTable != null) {
- for (final Map.Entry<String, SubscriptionData> entry : subTable.entrySet()) {
- final String topic = entry.getKey();
- this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic);
- }
- }
- }
-
- public ConcurrentHashMap<String, SubscriptionData> getSubscriptionInner() {
- return this.rebalanceImpl.getSubscriptionInner();
- }
-
- public void subscribe(String topic, String subExpression) throws MQClientException {
- try {
- SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPushConsumer.getConsumerGroup(), //
- topic, subExpression);
- this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData);
- if (this.mQClientFactory != null) {
- this.mQClientFactory.sendHeartbeatToAllBrokerWithLock();
- }
- } catch (Exception e) {
- throw new MQClientException("subscription exception", e);
- }
- }
-
- public void subscribe(String topic, String fullClassName, String filterClassSource) throws MQClientException {
- try {
- SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPushConsumer.getConsumerGroup(), //
- topic, "*");
- subscriptionData.setSubString(fullClassName);
- subscriptionData.setClassFilterMode(true);
- subscriptionData.setFilterClassSource(filterClassSource);
- this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData);
- if (this.mQClientFactory != null) {
- this.mQClientFactory.sendHeartbeatToAllBrokerWithLock();
- }
-
- } catch (Exception e) {
- throw new MQClientException("subscription exception", e);
- }
- }
-
- public void suspend() {
- this.pause = true;
- log.info("suspend this consumer, {}", this.defaultMQPushConsumer.getConsumerGroup());
- }
-
- public void unsubscribe(String topic) {
- this.rebalanceImpl.getSubscriptionInner().remove(topic);
- }
-
- public void updateConsumeOffset(MessageQueue mq, long offset) {
- this.offsetStore.updateOffset(mq, offset, false);
- }
-
- public void updateCorePoolSize(int corePoolSize) {
- this.consumeMessageService.updateCorePoolSize(corePoolSize);
- }
-
- public MessageExt viewMessage(String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- return this.mQClientFactory.getMQAdminImpl().viewMessage(msgId);
- }
-
- public RebalanceImpl getRebalanceImpl() {
- return rebalanceImpl;
- }
-
- public boolean isConsumeOrderly() {
- return consumeOrderly;
- }
-
- public void setConsumeOrderly(boolean consumeOrderly) {
- this.consumeOrderly = consumeOrderly;
- }
-
- public void resetOffsetByTimeStamp(long timeStamp)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- for (String topic : rebalanceImpl.getSubscriptionInner().keySet()) {
- Set<MessageQueue> mqs = rebalanceImpl.getTopicSubscribeInfoTable().get(topic);
- Map<MessageQueue, Long> offsetTable = new HashMap<MessageQueue, Long>();
- if (mqs != null) {
- for (MessageQueue mq : mqs) {
- long offset = searchOffset(mq, timeStamp);
- offsetTable.put(mq, offset);
- }
- this.mQClientFactory.resetOffset(topic, groupName(), offsetTable);
- }
- }
- }
-
- public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
- return this.mQClientFactory.getMQAdminImpl().searchOffset(mq, timestamp);
- }
-
- @Override
- public String groupName() {
- return this.defaultMQPushConsumer.getConsumerGroup();
- }
-
- @Override
- public MessageModel messageModel() {
- return this.defaultMQPushConsumer.getMessageModel();
- }
-
- @Override
- public ConsumeType consumeType() {
- return ConsumeType.CONSUME_PASSIVELY;
- }
-
- @Override
- public ConsumeFromWhere consumeFromWhere() {
- return this.defaultMQPushConsumer.getConsumeFromWhere();
- }
-
- @Override
- public Set<SubscriptionData> subscriptions() {
- Set<SubscriptionData> subSet = new HashSet<SubscriptionData>();
-
- subSet.addAll(this.rebalanceImpl.getSubscriptionInner().values());
-
- return subSet;
- }
-
- @Override
- public void doRebalance() {
- if (this.rebalanceImpl != null && !this.pause) {
- this.rebalanceImpl.doRebalance(this.isConsumeOrderly());
- }
- }
-
- @Override
- public void persistConsumerOffset() {
- try {
- this.makeSureStateOK();
- Set<MessageQueue> mqs = new HashSet<MessageQueue>();
- Set<MessageQueue> allocateMq = this.rebalanceImpl.getProcessQueueTable().keySet();
- if (allocateMq != null) {
- mqs.addAll(allocateMq);
- }
-
- this.offsetStore.persistAll(mqs);
- } catch (Exception e) {
- log.error("group: " + this.defaultMQPushConsumer.getConsumerGroup() + " persistConsumerOffset exception", e);
- }
- }
-
- @Override
- public void updateTopicSubscribeInfo(String topic, Set<MessageQueue> info) {
- Map<String, SubscriptionData> subTable = this.getSubscriptionInner();
- if (subTable != null) {
- if (subTable.containsKey(topic)) {
- this.rebalanceImpl.topicSubscribeInfoTable.put(topic, info);
- }
- }
- }
-
- @Override
- public boolean isSubscribeTopicNeedUpdate(String topic) {
- Map<String, SubscriptionData> subTable = this.getSubscriptionInner();
- if (subTable != null) {
- if (subTable.containsKey(topic)) {
- return !this.rebalanceImpl.topicSubscribeInfoTable.containsKey(topic);
- }
- }
-
- return false;
- }
-
- @Override
- public boolean isUnitMode() {
- return this.defaultMQPushConsumer.isUnitMode();
- }
-
- @Override
- public ConsumerRunningInfo consumerRunningInfo() {
- ConsumerRunningInfo info = new ConsumerRunningInfo();
-
- Properties prop = MixAll.object2Properties(this.defaultMQPushConsumer);
-
- prop.put(ConsumerRunningInfo.PROP_CONSUME_ORDERLY, String.valueOf(this.consumeOrderly));
- prop.put(ConsumerRunningInfo.PROP_THREADPOOL_CORE_SIZE, String.valueOf(this.consumeMessageService.getCorePoolSize()));
- prop.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, String.valueOf(this.consumerStartTimestamp));
-
- info.setProperties(prop);
-
- Set<SubscriptionData> subSet = this.subscriptions();
- info.getSubscriptionSet().addAll(subSet);
-
- Iterator<Entry<MessageQueue, ProcessQueue>> it = this.rebalanceImpl.getProcessQueueTable().entrySet().iterator();
- while (it.hasNext()) {
- Entry<MessageQueue, ProcessQueue> next = it.next();
- MessageQueue mq = next.getKey();
- ProcessQueue pq = next.getValue();
-
- ProcessQueueInfo pqinfo = new ProcessQueueInfo();
- pqinfo.setCommitOffset(this.offsetStore.readOffset(mq, ReadOffsetType.MEMORY_FIRST_THEN_STORE));
- pq.fillProcessQueueInfo(pqinfo);
- info.getMqTable().put(mq, pqinfo);
- }
-
- for (SubscriptionData sd : subSet) {
- ConsumeStatus consumeStatus = this.mQClientFactory.getConsumerStatsManager().consumeStatus(this.groupName(), sd.getTopic());
- info.getStatusTable().put(sd.getTopic(), consumeStatus);
- }
-
- return info;
- }
-
- public MQClientInstance getmQClientFactory() {
- return mQClientFactory;
- }
-
- public void setmQClientFactory(MQClientInstance mQClientFactory) {
- this.mQClientFactory = mQClientFactory;
- }
-
- public ServiceState getServiceState() {
- return serviceState;
- }
-
- public void setServiceState(ServiceState serviceState) {
- this.serviceState = serviceState;
- }
-
- public void adjustThreadPool() {
- long computeAccTotal = this.computeAccumulationTotal();
- long adjustThreadPoolNumsThreshold = this.defaultMQPushConsumer.getAdjustThreadPoolNumsThreshold();
-
- long incThreshold = (long) (adjustThreadPoolNumsThreshold * 1.0);
-
- long decThreshold = (long) (adjustThreadPoolNumsThreshold * 0.8);
-
- if (computeAccTotal >= incThreshold) {
- this.consumeMessageService.incCorePoolSize();
- }
-
- if (computeAccTotal < decThreshold) {
- this.consumeMessageService.decCorePoolSize();
- }
- }
-
- private long computeAccumulationTotal() {
- long msgAccTotal = 0;
- ConcurrentHashMap<MessageQueue, ProcessQueue> processQueueTable = this.rebalanceImpl.getProcessQueueTable();
- Iterator<Entry<MessageQueue, ProcessQueue>> it = processQueueTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<MessageQueue, ProcessQueue> next = it.next();
- ProcessQueue value = next.getValue();
- msgAccTotal += value.getMsgAccCnt();
- }
-
- return msgAccTotal;
- }
-
- public List<QueueTimeSpan> queryConsumeTimeSpan(final String topic)
- throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
- List<QueueTimeSpan> queueTimeSpan = new ArrayList<QueueTimeSpan>();
- TopicRouteData routeData = this.mQClientFactory.getMQClientAPIImpl().getTopicRouteInfoFromNameServer(topic, 3000);
- for (BrokerData brokerData : routeData.getBrokerDatas()) {
- String addr = brokerData.selectBrokerAddr();
- queueTimeSpan.addAll(this.mQClientFactory.getMQClientAPIImpl().queryConsumeTimeSpan(addr, topic, groupName(), 3000));
- }
-
- return queueTimeSpan;
- }
-
-
- public ConsumeMessageService getConsumeMessageService() {
- return consumeMessageService;
- }
-
-
- public void setConsumeMessageService(ConsumeMessageService consumeMessageService) {
- this.consumeMessageService = consumeMessageService;
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/MQConsumerInner.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/MQConsumerInner.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/MQConsumerInner.java
deleted file mode 100644
index 1ff430b..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/MQConsumerInner.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * 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.client.impl.consumer;
-
-import com.alibaba.rocketmq.common.consumer.ConsumeFromWhere;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.body.ConsumerRunningInfo;
-import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType;
-import com.alibaba.rocketmq.common.protocol.heartbeat.MessageModel;
-import com.alibaba.rocketmq.common.protocol.heartbeat.SubscriptionData;
-
-import java.util.Set;
-
-
-/**
- * Consumer inner interface
- *
- * @author shijia.wxr
- */
-public interface MQConsumerInner {
- String groupName();
-
-
- MessageModel messageModel();
-
-
- ConsumeType consumeType();
-
-
- ConsumeFromWhere consumeFromWhere();
-
-
- Set<SubscriptionData> subscriptions();
-
-
- void doRebalance();
-
-
- void persistConsumerOffset();
-
-
- void updateTopicSubscribeInfo(final String topic, final Set<MessageQueue> info);
-
-
- boolean isSubscribeTopicNeedUpdate(final String topic);
-
-
- boolean isUnitMode();
-
-
- ConsumerRunningInfo consumerRunningInfo();
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/MessageQueueLock.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/MessageQueueLock.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/MessageQueueLock.java
deleted file mode 100644
index 9de7ac0..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/MessageQueueLock.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * 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.client.impl.consumer;
-
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-import java.util.concurrent.ConcurrentHashMap;
-
-
-/**
- * Message lock,strictly ensure the single queue only one thread at a time consuming
- *
- * @author shijia.wxr
- */
-public class MessageQueueLock {
- private ConcurrentHashMap<MessageQueue, Object> mqLockTable =
- new ConcurrentHashMap<MessageQueue, Object>();
-
-
- public Object fetchLockObject(final MessageQueue mq) {
- Object objLock = this.mqLockTable.get(mq);
- if (null == objLock) {
- objLock = new Object();
- Object prevLock = this.mqLockTable.putIfAbsent(mq, objLock);
- if (prevLock != null) {
- objLock = prevLock;
- }
- }
-
- return objLock;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/ProcessQueue.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/ProcessQueue.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/ProcessQueue.java
deleted file mode 100644
index 05ffeb7..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/ProcessQueue.java
+++ /dev/null
@@ -1,451 +0,0 @@
-/**
- * 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.client.impl.consumer;
-
-import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.common.message.MessageAccessor;
-import com.alibaba.rocketmq.common.message.MessageConst;
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.protocol.body.ProcessQueueInfo;
-import org.slf4j.Logger;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-
-/**
- * Queue consumption snapshot
- *
- * @author shijia.wxr
- */
-public class ProcessQueue {
- public final static long REBALANCE_LOCK_MAX_LIVE_TIME =
- Long.parseLong(System.getProperty("rocketmq.client.rebalance.lockMaxLiveTime", "30000"));
- public final static long REBALANCE_LOCK_INTERVAL = Long.parseLong(System.getProperty("rocketmq.client.rebalance.lockInterval", "20000"));
- private final static long PULL_MAX_IDLE_TIME = Long.parseLong(System.getProperty("rocketmq.client.pull.pullMaxIdleTime", "120000"));
- private final Logger log = ClientLogger.getLog();
- private final ReadWriteLock lockTreeMap = new ReentrantReadWriteLock();
- private final TreeMap<Long, MessageExt> msgTreeMap = new TreeMap<Long, MessageExt>();
- private final AtomicLong msgCount = new AtomicLong();
- private final Lock lockConsume = new ReentrantLock();
- private final TreeMap<Long, MessageExt> msgTreeMapTemp = new TreeMap<Long, MessageExt>();
- private final AtomicLong tryUnlockTimes = new AtomicLong(0);
- private volatile long queueOffsetMax = 0L;
- private volatile boolean dropped = false;
- private volatile long lastPullTimestamp = System.currentTimeMillis();
- private volatile long lastConsumeTimestamp = System.currentTimeMillis();
- private volatile boolean locked = false;
- private volatile long lastLockTimestamp = System.currentTimeMillis();
- private volatile boolean consuming = false;
- private volatile long msgAccCnt = 0;
-
- public boolean isLockExpired() {
- boolean result = (System.currentTimeMillis() - this.lastLockTimestamp) > REBALANCE_LOCK_MAX_LIVE_TIME;
- return result;
- }
-
-
- public boolean isPullExpired() {
- boolean result = (System.currentTimeMillis() - this.lastPullTimestamp) > PULL_MAX_IDLE_TIME;
- return result;
- }
-
- /**
-
- *
- * @param pushConsumer
- */
- public void cleanExpiredMsg(DefaultMQPushConsumer pushConsumer) {
- if (pushConsumer.getDefaultMQPushConsumerImpl().isConsumeOrderly()) {
- return;
- }
-
- int loop = msgTreeMap.size() < 16 ? msgTreeMap.size() : 16;
- for (int i = 0; i < loop; i++) {
- MessageExt msg = null;
- try {
- this.lockTreeMap.readLock().lockInterruptibly();
- try {
- if (!msgTreeMap.isEmpty() && System.currentTimeMillis() - Long.parseLong(MessageAccessor.getConsumeStartTimeStamp(msgTreeMap.firstEntry().getValue())) > pushConsumer.getConsumeTimeout() * 60 * 1000) {
- msg = msgTreeMap.firstEntry().getValue();
- } else {
-
- break;
- }
- } finally {
- this.lockTreeMap.readLock().unlock();
- }
- } catch (InterruptedException e) {
- log.error("getExpiredMsg exception", e);
- }
-
- try {
-
- pushConsumer.sendMessageBack(msg, 3);
- log.info("send expire msg back. topic={}, msgId={}, storeHost={}, queueId={}, queueOffset={}", msg.getTopic(), msg.getMsgId(), msg.getStoreHost(), msg.getQueueId(), msg.getQueueOffset());
- try {
- this.lockTreeMap.writeLock().lockInterruptibly();
- try {
- if (!msgTreeMap.isEmpty() && msg.getQueueOffset() == msgTreeMap.firstKey()) {
- try {
- msgTreeMap.remove(msgTreeMap.firstKey());
- } catch (Exception e) {
- log.error("send expired msg exception", e);
- }
- }
- } finally {
- this.lockTreeMap.writeLock().unlock();
- }
- } catch (InterruptedException e) {
- log.error("getExpiredMsg exception", e);
- }
- } catch (Exception e) {
- log.error("send expired msg exception", e);
- }
- }
- }
-
-
- public boolean putMessage(final List<MessageExt> msgs) {
- boolean dispatchToConsume = false;
- try {
- this.lockTreeMap.writeLock().lockInterruptibly();
- try {
- int validMsgCnt = 0;
- for (MessageExt msg : msgs) {
- MessageExt old = msgTreeMap.put(msg.getQueueOffset(), msg);
- if (null == old) {
- validMsgCnt++;
- this.queueOffsetMax = msg.getQueueOffset();
- }
- }
- msgCount.addAndGet(validMsgCnt);
-
- if (!msgTreeMap.isEmpty() && !this.consuming) {
- dispatchToConsume = true;
- this.consuming = true;
- }
-
- if (!msgs.isEmpty()) {
- MessageExt messageExt = msgs.get(msgs.size() - 1);
- String property = messageExt.getProperty(MessageConst.PROPERTY_MAX_OFFSET);
- if (property != null) {
- long accTotal = Long.parseLong(property) - messageExt.getQueueOffset();
- if (accTotal > 0) {
- this.msgAccCnt = accTotal;
- }
- }
- }
- } finally {
- this.lockTreeMap.writeLock().unlock();
- }
- } catch (InterruptedException e) {
- log.error("putMessage exception", e);
- }
-
- return dispatchToConsume;
- }
-
-
- public long getMaxSpan() {
- try {
- this.lockTreeMap.readLock().lockInterruptibly();
- try {
- if (!this.msgTreeMap.isEmpty()) {
- return this.msgTreeMap.lastKey() - this.msgTreeMap.firstKey();
- }
- } finally {
- this.lockTreeMap.readLock().unlock();
- }
- } catch (InterruptedException e) {
- log.error("getMaxSpan exception", e);
- }
-
- return 0;
- }
-
-
- public long removeMessage(final List<MessageExt> msgs) {
- long result = -1;
- final long now = System.currentTimeMillis();
- try {
- this.lockTreeMap.writeLock().lockInterruptibly();
- this.lastConsumeTimestamp = now;
- try {
- if (!msgTreeMap.isEmpty()) {
- result = this.queueOffsetMax + 1;
- int removedCnt = 0;
- for (MessageExt msg : msgs) {
- MessageExt prev = msgTreeMap.remove(msg.getQueueOffset());
- if (prev != null) {
- removedCnt--;
- }
- }
- msgCount.addAndGet(removedCnt);
-
- if (!msgTreeMap.isEmpty()) {
- result = msgTreeMap.firstKey();
- }
- }
- } finally {
- this.lockTreeMap.writeLock().unlock();
- }
- } catch (Throwable t) {
- log.error("removeMessage exception", t);
- }
-
- return result;
- }
-
-
- public TreeMap<Long, MessageExt> getMsgTreeMap() {
- return msgTreeMap;
- }
-
-
- public AtomicLong getMsgCount() {
- return msgCount;
- }
-
-
- public boolean isDropped() {
- return dropped;
- }
-
-
- public void setDropped(boolean dropped) {
- this.dropped = dropped;
- }
-
- public boolean isLocked() {
- return locked;
- }
-
- public void setLocked(boolean locked) {
- this.locked = locked;
- }
-
- public void rollback() {
- try {
- this.lockTreeMap.writeLock().lockInterruptibly();
- try {
- this.msgTreeMap.putAll(this.msgTreeMapTemp);
- this.msgTreeMapTemp.clear();
- } finally {
- this.lockTreeMap.writeLock().unlock();
- }
- } catch (InterruptedException e) {
- log.error("rollback exception", e);
- }
- }
-
-
- public long commit() {
- try {
- this.lockTreeMap.writeLock().lockInterruptibly();
- try {
- Long offset = this.msgTreeMapTemp.lastKey();
- msgCount.addAndGet(this.msgTreeMapTemp.size() * (-1));
- this.msgTreeMapTemp.clear();
- if (offset != null) {
- return offset + 1;
- }
- } finally {
- this.lockTreeMap.writeLock().unlock();
- }
- } catch (InterruptedException e) {
- log.error("commit exception", e);
- }
-
- return -1;
- }
-
-
- public void makeMessageToCosumeAgain(List<MessageExt> msgs) {
- try {
- this.lockTreeMap.writeLock().lockInterruptibly();
- try {
- for (MessageExt msg : msgs) {
- this.msgTreeMapTemp.remove(msg.getQueueOffset());
- this.msgTreeMap.put(msg.getQueueOffset(), msg);
- }
- } finally {
- this.lockTreeMap.writeLock().unlock();
- }
- } catch (InterruptedException e) {
- log.error("makeMessageToCosumeAgain exception", e);
- }
- }
-
-
- public List<MessageExt> takeMessags(final int batchSize) {
- List<MessageExt> result = new ArrayList<MessageExt>(batchSize);
- final long now = System.currentTimeMillis();
- try {
- this.lockTreeMap.writeLock().lockInterruptibly();
- this.lastConsumeTimestamp = now;
- try {
- if (!this.msgTreeMap.isEmpty()) {
- for (int i = 0; i < batchSize; i++) {
- Map.Entry<Long, MessageExt> entry = this.msgTreeMap.pollFirstEntry();
- if (entry != null) {
- result.add(entry.getValue());
- msgTreeMapTemp.put(entry.getKey(), entry.getValue());
- } else {
- break;
- }
- }
- }
-
- if (result.isEmpty()) {
- consuming = false;
- }
- } finally {
- this.lockTreeMap.writeLock().unlock();
- }
- } catch (InterruptedException e) {
- log.error("take Messages exception", e);
- }
-
- return result;
- }
-
-
- public boolean hasTempMessage() {
- try {
- this.lockTreeMap.readLock().lockInterruptibly();
- try {
- return !this.msgTreeMap.isEmpty();
- } finally {
- this.lockTreeMap.readLock().unlock();
- }
- } catch (InterruptedException e) {
- }
-
- return true;
- }
-
-
- public void clear() {
- try {
- this.lockTreeMap.writeLock().lockInterruptibly();
- try {
- this.msgTreeMap.clear();
- this.msgTreeMapTemp.clear();
- this.msgCount.set(0);
- this.queueOffsetMax = 0L;
- } finally {
- this.lockTreeMap.writeLock().unlock();
- }
- } catch (InterruptedException e) {
- log.error("rollback exception", e);
- }
- }
-
-
- public long getLastLockTimestamp() {
- return lastLockTimestamp;
- }
-
-
- public void setLastLockTimestamp(long lastLockTimestamp) {
- this.lastLockTimestamp = lastLockTimestamp;
- }
-
-
- public Lock getLockConsume() {
- return lockConsume;
- }
-
-
- public long getLastPullTimestamp() {
- return lastPullTimestamp;
- }
-
-
- public void setLastPullTimestamp(long lastPullTimestamp) {
- this.lastPullTimestamp = lastPullTimestamp;
- }
-
-
- public long getMsgAccCnt() {
- return msgAccCnt;
- }
-
-
- public void setMsgAccCnt(long msgAccCnt) {
- this.msgAccCnt = msgAccCnt;
- }
-
-
- public long getTryUnlockTimes() {
- return this.tryUnlockTimes.get();
- }
-
-
- public void incTryUnlockTimes() {
- this.tryUnlockTimes.incrementAndGet();
- }
-
-
- public void fillProcessQueueInfo(final ProcessQueueInfo info) {
- try {
- this.lockTreeMap.readLock().lockInterruptibly();
-
- if (!this.msgTreeMap.isEmpty()) {
- info.setCachedMsgMinOffset(this.msgTreeMap.firstKey());
- info.setCachedMsgMaxOffset(this.msgTreeMap.lastKey());
- info.setCachedMsgCount(this.msgTreeMap.size());
- }
-
- if (!this.msgTreeMapTemp.isEmpty()) {
- info.setTransactionMsgMinOffset(this.msgTreeMapTemp.firstKey());
- info.setTransactionMsgMaxOffset(this.msgTreeMapTemp.lastKey());
- info.setTransactionMsgCount(this.msgTreeMapTemp.size());
- }
-
- info.setLocked(this.locked);
- info.setTryUnlockTimes(this.tryUnlockTimes.get());
- info.setLastLockTimestamp(this.lastLockTimestamp);
-
- info.setDroped(this.dropped);
- info.setLastPullTimestamp(this.lastPullTimestamp);
- info.setLastConsumeTimestamp(this.lastConsumeTimestamp);
- } catch (Exception e) {
- } finally {
- this.lockTreeMap.readLock().unlock();
- }
- }
-
-
- public long getLastConsumeTimestamp() {
- return lastConsumeTimestamp;
- }
-
-
- public void setLastConsumeTimestamp(long lastConsumeTimestamp) {
- this.lastConsumeTimestamp = lastConsumeTimestamp;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/PullAPIWrapper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/PullAPIWrapper.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/PullAPIWrapper.java
deleted file mode 100644
index 730b090..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/PullAPIWrapper.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/**
- * 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.client.impl.consumer;
-
-import com.alibaba.rocketmq.client.consumer.PullCallback;
-import com.alibaba.rocketmq.client.consumer.PullResult;
-import com.alibaba.rocketmq.client.consumer.PullStatus;
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.hook.FilterMessageContext;
-import com.alibaba.rocketmq.client.hook.FilterMessageHook;
-import com.alibaba.rocketmq.client.impl.CommunicationMode;
-import com.alibaba.rocketmq.client.impl.FindBrokerResult;
-import com.alibaba.rocketmq.client.impl.factory.MQClientInstance;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.message.*;
-import com.alibaba.rocketmq.common.protocol.header.PullMessageRequestHeader;
-import com.alibaba.rocketmq.common.protocol.heartbeat.SubscriptionData;
-import com.alibaba.rocketmq.common.protocol.route.TopicRouteData;
-import com.alibaba.rocketmq.common.sysflag.PullSysFlag;
-import com.alibaba.rocketmq.remoting.exception.RemotingException;
-import org.slf4j.Logger;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
-
-
-/**
- * @author shijia.wxr
- */
-public class PullAPIWrapper {
- private final Logger log = ClientLogger.getLog();
- private final MQClientInstance mQClientFactory;
- private final String consumerGroup;
- private final boolean unitMode;
- private ConcurrentHashMap<MessageQueue, AtomicLong/* brokerId */> pullFromWhichNodeTable =
- new ConcurrentHashMap<MessageQueue, AtomicLong>(32);
- private volatile boolean connectBrokerByUser = false;
- private volatile long defaultBrokerId = MixAll.MASTER_ID;
- private Random random = new Random(System.currentTimeMillis());
- private ArrayList<FilterMessageHook> filterMessageHookList = new ArrayList<FilterMessageHook>();
-
- public PullAPIWrapper(MQClientInstance mQClientFactory, String consumerGroup, boolean unitMode) {
- this.mQClientFactory = mQClientFactory;
- this.consumerGroup = consumerGroup;
- this.unitMode = unitMode;
- }
-
- public PullResult processPullResult(final MessageQueue mq, final PullResult pullResult,
- final SubscriptionData subscriptionData) {
- PullResultExt pullResultExt = (PullResultExt) pullResult;
-
- this.updatePullFromWhichNode(mq, pullResultExt.getSuggestWhichBrokerId());
- if (PullStatus.FOUND == pullResult.getPullStatus()) {
- ByteBuffer byteBuffer = ByteBuffer.wrap(pullResultExt.getMessageBinary());
- List<MessageExt> msgList = MessageDecoder.decodes(byteBuffer);
-
- List<MessageExt> msgListFilterAgain = msgList;
- if (!subscriptionData.getTagsSet().isEmpty() && !subscriptionData.isClassFilterMode()) {
- msgListFilterAgain = new ArrayList<MessageExt>(msgList.size());
- for (MessageExt msg : msgList) {
- if (msg.getTags() != null) {
- if (subscriptionData.getTagsSet().contains(msg.getTags())) {
- msgListFilterAgain.add(msg);
- }
- }
- }
- }
-
- if (this.hasHook()) {
- FilterMessageContext filterMessageContext = new FilterMessageContext();
- filterMessageContext.setUnitMode(unitMode);
- filterMessageContext.setMsgList(msgListFilterAgain);
- this.executeHook(filterMessageContext);
- }
-
- for (MessageExt msg : msgListFilterAgain) {
- MessageAccessor.putProperty(msg, MessageConst.PROPERTY_MIN_OFFSET,
- Long.toString(pullResult.getMinOffset()));
- MessageAccessor.putProperty(msg, MessageConst.PROPERTY_MAX_OFFSET,
- Long.toString(pullResult.getMaxOffset()));
- }
-
- pullResultExt.setMsgFoundList(msgListFilterAgain);
- }
-
- pullResultExt.setMessageBinary(null);
-
- return pullResult;
- }
-
- public void updatePullFromWhichNode(final MessageQueue mq, final long brokerId) {
- AtomicLong suggest = this.pullFromWhichNodeTable.get(mq);
- if (null == suggest) {
- this.pullFromWhichNodeTable.put(mq, new AtomicLong(brokerId));
- } else {
- suggest.set(brokerId);
- }
- }
-
- public boolean hasHook() {
- return !this.filterMessageHookList.isEmpty();
- }
-
- public void executeHook(final FilterMessageContext context) {
- if (!this.filterMessageHookList.isEmpty()) {
- for (FilterMessageHook hook : this.filterMessageHookList) {
- try {
- hook.filterMessage(context);
- } catch (Throwable e) {
- log.error("execute hook error. hookName={}", hook.hookName());
- }
- }
- }
- }
-
- public PullResult pullKernelImpl(
- final MessageQueue mq,
- final String subExpression,
- final long subVersion,
- final long offset,
- final int maxNums,
- final int sysFlag,
- final long commitOffset,
- final long brokerSuspendMaxTimeMillis,
- final long timeoutMillis,
- final CommunicationMode communicationMode,
- final PullCallback pullCallback
- ) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- FindBrokerResult findBrokerResult =
- this.mQClientFactory.findBrokerAddressInSubscribe(mq.getBrokerName(),
- this.recalculatePullFromWhichNode(mq), false);
- if (null == findBrokerResult) {
- this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
- findBrokerResult =
- this.mQClientFactory.findBrokerAddressInSubscribe(mq.getBrokerName(),
- this.recalculatePullFromWhichNode(mq), false);
- }
-
- if (findBrokerResult != null) {
- int sysFlagInner = sysFlag;
-
- if (findBrokerResult.isSlave()) {
- sysFlagInner = PullSysFlag.clearCommitOffsetFlag(sysFlagInner);
- }
-
- PullMessageRequestHeader requestHeader = new PullMessageRequestHeader();
- requestHeader.setConsumerGroup(this.consumerGroup);
- requestHeader.setTopic(mq.getTopic());
- requestHeader.setQueueId(mq.getQueueId());
- requestHeader.setQueueOffset(offset);
- requestHeader.setMaxMsgNums(maxNums);
- requestHeader.setSysFlag(sysFlagInner);
- requestHeader.setCommitOffset(commitOffset);
- requestHeader.setSuspendTimeoutMillis(brokerSuspendMaxTimeMillis);
- requestHeader.setSubscription(subExpression);
- requestHeader.setSubVersion(subVersion);
-
- String brokerAddr = findBrokerResult.getBrokerAddr();
- if (PullSysFlag.hasClassFilterFlag(sysFlagInner)) {
- brokerAddr = computPullFromWhichFilterServer(mq.getTopic(), brokerAddr);
- }
-
- PullResult pullResult = this.mQClientFactory.getMQClientAPIImpl().pullMessage(
- brokerAddr,
- requestHeader,
- timeoutMillis,
- communicationMode,
- pullCallback);
-
- return pullResult;
- }
-
- throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
- }
-
- public long recalculatePullFromWhichNode(final MessageQueue mq) {
- if (this.isConnectBrokerByUser()) {
- return this.defaultBrokerId;
- }
-
- AtomicLong suggest = this.pullFromWhichNodeTable.get(mq);
- if (suggest != null) {
- return suggest.get();
- }
-
- return MixAll.MASTER_ID;
- }
-
- private String computPullFromWhichFilterServer(final String topic, final String brokerAddr)
- throws MQClientException {
- ConcurrentHashMap<String, TopicRouteData> topicRouteTable = this.mQClientFactory.getTopicRouteTable();
- if (topicRouteTable != null) {
- TopicRouteData topicRouteData = topicRouteTable.get(topic);
- List<String> list = topicRouteData.getFilterServerTable().get(brokerAddr);
-
- if (list != null && !list.isEmpty()) {
- return list.get(randomNum() % list.size());
- }
- }
-
- throw new MQClientException("Find Filter Server Failed, Broker Addr: " + brokerAddr + " topic: "
- + topic, null);
- }
-
- public boolean isConnectBrokerByUser() {
- return connectBrokerByUser;
- }
-
- public int randomNum() {
- int value = random.nextInt();
- if (value < 0) {
- value = Math.abs(value);
- if (value < 0)
- value = 0;
- }
- return value;
- }
-
- public void setConnectBrokerByUser(boolean connectBrokerByUser) {
- this.connectBrokerByUser = connectBrokerByUser;
-
- }
-
- public void registerFilterMessageHook(ArrayList<FilterMessageHook> filterMessageHookList) {
- this.filterMessageHookList = filterMessageHookList;
- }
-
- public long getDefaultBrokerId() {
- return defaultBrokerId;
- }
-
- public void setDefaultBrokerId(long defaultBrokerId) {
- this.defaultBrokerId = defaultBrokerId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/PullMessageService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/PullMessageService.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/PullMessageService.java
deleted file mode 100644
index 161a039..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/PullMessageService.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * 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.client.impl.consumer;
-
-import com.alibaba.rocketmq.client.impl.factory.MQClientInstance;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.common.ServiceThread;
-import org.slf4j.Logger;
-
-import java.util.concurrent.*;
-
-
-/**
- * @author shijia.wxr
- */
-public class PullMessageService extends ServiceThread {
- private final Logger log = ClientLogger.getLog();
- private final LinkedBlockingQueue<PullRequest> pullRequestQueue = new LinkedBlockingQueue<PullRequest>();
- private final MQClientInstance mQClientFactory;
- private final ScheduledExecutorService scheduledExecutorService = Executors
- .newSingleThreadScheduledExecutor(new ThreadFactory() {
- @Override
- public Thread newThread(Runnable r) {
- return new Thread(r, "PullMessageServiceScheduledThread");
- }
- });
-
- public PullMessageService(MQClientInstance mQClientFactory) {
- this.mQClientFactory = mQClientFactory;
- }
-
- public void executePullRequestLater(final PullRequest pullRequest, final long timeDelay) {
- this.scheduledExecutorService.schedule(new Runnable() {
-
- @Override
- public void run() {
- PullMessageService.this.executePullRequestImmediately(pullRequest);
- }
- }, timeDelay, TimeUnit.MILLISECONDS);
- }
-
- public void executePullRequestImmediately(final PullRequest pullRequest) {
- try {
- this.pullRequestQueue.put(pullRequest);
- } catch (InterruptedException e) {
- log.error("executePullRequestImmediately pullRequestQueue.put", e);
- }
- }
-
- public void executeTaskLater(final Runnable r, final long timeDelay) {
- this.scheduledExecutorService.schedule(r, timeDelay, TimeUnit.MILLISECONDS);
- }
-
- public ScheduledExecutorService getScheduledExecutorService() {
- return scheduledExecutorService;
- }
-
- private void pullMessage(final PullRequest pullRequest) {
- final MQConsumerInner consumer = this.mQClientFactory.selectConsumer(pullRequest.getConsumerGroup());
- if (consumer != null) {
- DefaultMQPushConsumerImpl impl = (DefaultMQPushConsumerImpl) consumer;
- impl.pullMessage(pullRequest);
- } else {
- log.warn("No matched consumer for the PullRequest {}, drop it", pullRequest);
- }
- }
-
-
- @Override
- public void run() {
- log.info(this.getServiceName() + " service started");
-
- while (!this.isStopped()) {
- try {
- PullRequest pullRequest = this.pullRequestQueue.take();
- if (pullRequest != null) {
- this.pullMessage(pullRequest);
- }
- } catch (InterruptedException e) {
- } catch (Exception e) {
- log.error("Pull Message Service Run Method exception", e);
- }
- }
-
- log.info(this.getServiceName() + " service end");
- }
-
-
- @Override
- public String getServiceName() {
- return PullMessageService.class.getSimpleName();
- }
-
-
-}
[40/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
new file mode 100644
index 0000000..7a0ddae
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
@@ -0,0 +1,497 @@
+/**
+ * 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.broker.processor;
+
+import io.netty.channel.ChannelHandlerContext;
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.broker.mqtrace.ConsumeMessageContext;
+import org.apache.rocketmq.broker.mqtrace.ConsumeMessageHook;
+import org.apache.rocketmq.broker.mqtrace.SendMessageContext;
+import org.apache.rocketmq.common.*;
+import org.apache.rocketmq.common.constant.PermName;
+import org.apache.rocketmq.common.help.FAQUrl;
+import org.apache.rocketmq.common.message.MessageAccessor;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageDecoder;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.protocol.RequestCode;
+import org.apache.rocketmq.common.protocol.ResponseCode;
+import org.apache.rocketmq.common.protocol.header.ConsumerSendMsgBackRequestHeader;
+import org.apache.rocketmq.common.protocol.header.SendMessageRequestHeader;
+import org.apache.rocketmq.common.protocol.header.SendMessageResponseHeader;
+import org.apache.rocketmq.common.subscription.SubscriptionGroupConfig;
+import org.apache.rocketmq.common.sysflag.MessageSysFlag;
+import org.apache.rocketmq.common.sysflag.TopicSysFlag;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.apache.rocketmq.store.MessageExtBrokerInner;
+import org.apache.rocketmq.store.PutMessageResult;
+import org.apache.rocketmq.store.config.StorePathConfigHelper;
+import org.apache.rocketmq.store.stats.BrokerStatsManager;
+
+import java.net.SocketAddress;
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class SendMessageProcessor extends AbstractSendMessageProcessor implements NettyRequestProcessor {
+
+ private List<ConsumeMessageHook> consumeMessageHookList;
+
+ public SendMessageProcessor(final BrokerController brokerController) {
+ super(brokerController);
+ }
+
+ @Override
+ public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ SendMessageContext mqtraceContext;
+ switch (request.getCode()) {
+ case RequestCode.CONSUMER_SEND_MSG_BACK:
+ return this.consumerSendMsgBack(ctx, request);
+ default:
+ SendMessageRequestHeader requestHeader = parseRequestHeader(request);
+ if (requestHeader == null) {
+ return null;
+ }
+
+ mqtraceContext = buildMsgContext(ctx, requestHeader);
+ this.executeSendMessageHookBefore(ctx, request, mqtraceContext);
+ final RemotingCommand response = this.sendMessage(ctx, request, mqtraceContext, requestHeader);
+
+ this.executeSendMessageHookAfter(response, mqtraceContext);
+ return response;
+ }
+ }
+
+ @Override
+ public boolean rejectRequest() {
+ return this.brokerController.getMessageStore().isOSPageCacheBusy() ||
+ this.brokerController.getMessageStore().isTransientStorePoolDeficient();
+ }
+
+ private RemotingCommand consumerSendMsgBack(final ChannelHandlerContext ctx, final RemotingCommand request)
+ throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ final ConsumerSendMsgBackRequestHeader requestHeader =
+ (ConsumerSendMsgBackRequestHeader) request.decodeCommandCustomHeader(ConsumerSendMsgBackRequestHeader.class);
+
+ if (this.hasConsumeMessageHook() && !UtilAll.isBlank(requestHeader.getOriginMsgId())) {
+
+ ConsumeMessageContext context = new ConsumeMessageContext();
+ context.setConsumerGroup(requestHeader.getGroup());
+ context.setTopic(requestHeader.getOriginTopic());
+ context.setCommercialRcvStats(BrokerStatsManager.StatsType.SEND_BACK);
+ context.setCommercialRcvTimes(1);
+ context.setCommercialOwner(request.getExtFields().get(BrokerStatsManager.COMMERCIAL_OWNER));
+
+ this.executeConsumeMessageHookAfter(context);
+ }
+
+
+ SubscriptionGroupConfig subscriptionGroupConfig =
+ this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(requestHeader.getGroup());
+ if (null == subscriptionGroupConfig) {
+ response.setCode(ResponseCode.SUBSCRIPTION_GROUP_NOT_EXIST);
+ response.setRemark("subscription group not exist, " + requestHeader.getGroup() + " "
+ + FAQUrl.suggestTodo(FAQUrl.SUBSCRIPTION_GROUP_NOT_EXIST));
+ return response;
+ }
+
+
+ if (!PermName.isWriteable(this.brokerController.getBrokerConfig().getBrokerPermission())) {
+ response.setCode(ResponseCode.NO_PERMISSION);
+ response.setRemark("the broker[" + this.brokerController.getBrokerConfig().getBrokerIP1() + "] sending message is forbidden");
+ return response;
+ }
+
+
+ if (subscriptionGroupConfig.getRetryQueueNums() <= 0) {
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ String newTopic = MixAll.getRetryTopic(requestHeader.getGroup());
+ int queueIdInt = Math.abs(this.random.nextInt() % 99999999) % subscriptionGroupConfig.getRetryQueueNums();
+
+
+ int topicSysFlag = 0;
+ if (requestHeader.isUnitMode()) {
+ topicSysFlag = TopicSysFlag.buildSysFlag(false, true);
+ }
+
+
+ TopicConfig topicConfig = this.brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(//
+ newTopic, //
+ subscriptionGroupConfig.getRetryQueueNums(), //
+ PermName.PERM_WRITE | PermName.PERM_READ, topicSysFlag);
+ if (null == topicConfig) {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("topic[" + newTopic + "] not exist");
+ return response;
+ }
+
+
+ if (!PermName.isWriteable(topicConfig.getPerm())) {
+ response.setCode(ResponseCode.NO_PERMISSION);
+ response.setRemark(String.format("the topic[%s] sending message is forbidden", newTopic));
+ return response;
+ }
+
+ MessageExt msgExt = this.brokerController.getMessageStore().lookMessageByOffset(requestHeader.getOffset());
+ if (null == msgExt) {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("look message by offset failed, " + requestHeader.getOffset());
+ return response;
+ }
+
+
+ final String retryTopic = msgExt.getProperty(MessageConst.PROPERTY_RETRY_TOPIC);
+ if (null == retryTopic) {
+ MessageAccessor.putProperty(msgExt, MessageConst.PROPERTY_RETRY_TOPIC, msgExt.getTopic());
+ }
+ msgExt.setWaitStoreMsgOK(false);
+
+
+ int delayLevel = requestHeader.getDelayLevel();
+
+
+ int maxReconsumeTimes = subscriptionGroupConfig.getRetryMaxTimes();
+ if (request.getVersion() >= MQVersion.Version.V3_4_9.ordinal()) {
+ maxReconsumeTimes = requestHeader.getMaxReconsumeTimes();
+ }
+
+
+ if (msgExt.getReconsumeTimes() >= maxReconsumeTimes//
+ || delayLevel < 0) {
+ newTopic = MixAll.getDLQTopic(requestHeader.getGroup());
+ queueIdInt = Math.abs(this.random.nextInt() % 99999999) % DLQ_NUMS_PER_GROUP;
+
+ topicConfig = this.brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(newTopic, //
+ DLQ_NUMS_PER_GROUP, //
+ PermName.PERM_WRITE, 0
+ );
+ if (null == topicConfig) {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("topic[" + newTopic + "] not exist");
+ return response;
+ }
+ } else {
+ if (0 == delayLevel) {
+ delayLevel = 3 + msgExt.getReconsumeTimes();
+ }
+
+ msgExt.setDelayTimeLevel(delayLevel);
+ }
+
+ MessageExtBrokerInner msgInner = new MessageExtBrokerInner();
+ msgInner.setTopic(newTopic);
+ msgInner.setBody(msgExt.getBody());
+ msgInner.setFlag(msgExt.getFlag());
+ MessageAccessor.setProperties(msgInner, msgExt.getProperties());
+ msgInner.setPropertiesString(MessageDecoder.messageProperties2String(msgExt.getProperties()));
+ msgInner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(null, msgExt.getTags()));
+
+ msgInner.setQueueId(queueIdInt);
+ msgInner.setSysFlag(msgExt.getSysFlag());
+ msgInner.setBornTimestamp(msgExt.getBornTimestamp());
+ msgInner.setBornHost(msgExt.getBornHost());
+ msgInner.setStoreHost(this.getStoreHost());
+ msgInner.setReconsumeTimes(msgExt.getReconsumeTimes() + 1);
+
+ String originMsgId = MessageAccessor.getOriginMessageId(msgExt);
+ MessageAccessor.setOriginMessageId(msgInner, UtilAll.isBlank(originMsgId) ? msgExt.getMsgId() : originMsgId);
+
+ PutMessageResult putMessageResult = this.brokerController.getMessageStore().putMessage(msgInner);
+ if (putMessageResult != null) {
+ switch (putMessageResult.getPutMessageStatus()) {
+ case PUT_OK:
+ String backTopic = msgExt.getTopic();
+ String correctTopic = msgExt.getProperty(MessageConst.PROPERTY_RETRY_TOPIC);
+ if (correctTopic != null) {
+ backTopic = correctTopic;
+ }
+
+ this.brokerController.getBrokerStatsManager().incSendBackNums(requestHeader.getGroup(), backTopic);
+
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+
+ return response;
+ default:
+ break;
+ }
+
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark(putMessageResult.getPutMessageStatus().name());
+ return response;
+ }
+
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("putMessageResult is null");
+ return response;
+ }
+
+ private RemotingCommand sendMessage(final ChannelHandlerContext ctx, //
+ final RemotingCommand request, //
+ final SendMessageContext sendMessageContext, //
+ final SendMessageRequestHeader requestHeader) throws RemotingCommandException {
+
+ final RemotingCommand response = RemotingCommand.createResponseCommand(SendMessageResponseHeader.class);
+ final SendMessageResponseHeader responseHeader = (SendMessageResponseHeader) response.readCustomHeader();
+
+
+ response.setOpaque(request.getOpaque());
+
+ response.addExtField(MessageConst.PROPERTY_MSG_REGION, this.brokerController.getBrokerConfig().getRegionId());
+ response.addExtField(MessageConst.PROPERTY_TRACE_SWITCH, String.valueOf(this.brokerController.getBrokerConfig().isTraceOn()));
+
+ if (log.isDebugEnabled()) {
+ log.debug("receive SendMessage request command, " + request);
+ }
+
+ final long startTimstamp = this.brokerController.getBrokerConfig().getStartAcceptSendRequestTimeStamp();
+ if (this.brokerController.getMessageStore().now() < startTimstamp) {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark(String.format("broker unable to service, until %s", UtilAll.timeMillisToHumanString2(startTimstamp)));
+ return response;
+ }
+
+ response.setCode(-1);
+ super.msgCheck(ctx, requestHeader, response);
+ if (response.getCode() != -1) {
+ return response;
+ }
+
+ final byte[] body = request.getBody();
+
+ int queueIdInt = requestHeader.getQueueId();
+ TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(requestHeader.getTopic());
+
+ if (queueIdInt < 0) {
+ queueIdInt = Math.abs(this.random.nextInt() % 99999999) % topicConfig.getWriteQueueNums();
+ }
+
+ int sysFlag = requestHeader.getSysFlag();
+
+ if (TopicFilterType.MULTI_TAG == topicConfig.getTopicFilterType()) {
+ sysFlag |= MessageSysFlag.MULTI_TAGS_FLAG;
+ }
+
+ String newTopic = requestHeader.getTopic();
+ if (null != newTopic && newTopic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
+ String groupName = newTopic.substring(MixAll.RETRY_GROUP_TOPIC_PREFIX.length());
+ SubscriptionGroupConfig subscriptionGroupConfig =
+ this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(groupName);
+ if (null == subscriptionGroupConfig) {
+ response.setCode(ResponseCode.SUBSCRIPTION_GROUP_NOT_EXIST);
+ response.setRemark(
+ "subscription group not exist, " + groupName + " " + FAQUrl.suggestTodo(FAQUrl.SUBSCRIPTION_GROUP_NOT_EXIST));
+ return response;
+ }
+
+
+ int maxReconsumeTimes = subscriptionGroupConfig.getRetryMaxTimes();
+ if (request.getVersion() >= MQVersion.Version.V3_4_9.ordinal()) {
+ maxReconsumeTimes = requestHeader.getMaxReconsumeTimes();
+ }
+ int reconsumeTimes = requestHeader.getReconsumeTimes() == null ? 0 : requestHeader.getReconsumeTimes();
+ if (reconsumeTimes >= maxReconsumeTimes) {
+ newTopic = MixAll.getDLQTopic(groupName);
+ queueIdInt = Math.abs(this.random.nextInt() % 99999999) % DLQ_NUMS_PER_GROUP;
+ topicConfig = this.brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(newTopic, //
+ DLQ_NUMS_PER_GROUP, //
+ PermName.PERM_WRITE, 0
+ );
+ if (null == topicConfig) {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("topic[" + newTopic + "] not exist");
+ return response;
+ }
+ }
+ }
+ MessageExtBrokerInner msgInner = new MessageExtBrokerInner();
+ msgInner.setTopic(newTopic);
+ msgInner.setBody(body);
+ msgInner.setFlag(requestHeader.getFlag());
+ MessageAccessor.setProperties(msgInner, MessageDecoder.string2messageProperties(requestHeader.getProperties()));
+ msgInner.setPropertiesString(requestHeader.getProperties());
+ msgInner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(topicConfig.getTopicFilterType(), msgInner.getTags()));
+
+ msgInner.setQueueId(queueIdInt);
+ msgInner.setSysFlag(sysFlag);
+ msgInner.setBornTimestamp(requestHeader.getBornTimestamp());
+ msgInner.setBornHost(ctx.channel().remoteAddress());
+ msgInner.setStoreHost(this.getStoreHost());
+ msgInner.setReconsumeTimes(requestHeader.getReconsumeTimes() == null ? 0 : requestHeader.getReconsumeTimes());
+
+ if (this.brokerController.getBrokerConfig().isRejectTransactionMessage()) {
+ String traFlag = msgInner.getProperty(MessageConst.PROPERTY_TRANSACTION_PREPARED);
+ if (traFlag != null) {
+ response.setCode(ResponseCode.NO_PERMISSION);
+ response.setRemark(
+ "the broker[" + this.brokerController.getBrokerConfig().getBrokerIP1() + "] sending transaction message is forbidden");
+ return response;
+ }
+ }
+
+ PutMessageResult putMessageResult = this.brokerController.getMessageStore().putMessage(msgInner);
+ if (putMessageResult != null) {
+ boolean sendOK = false;
+
+ switch (putMessageResult.getPutMessageStatus()) {
+ // Success
+ case PUT_OK:
+ sendOK = true;
+ response.setCode(ResponseCode.SUCCESS);
+ break;
+ case FLUSH_DISK_TIMEOUT:
+ response.setCode(ResponseCode.FLUSH_DISK_TIMEOUT);
+ sendOK = true;
+ break;
+ case FLUSH_SLAVE_TIMEOUT:
+ response.setCode(ResponseCode.FLUSH_SLAVE_TIMEOUT);
+ sendOK = true;
+ break;
+ case SLAVE_NOT_AVAILABLE:
+ response.setCode(ResponseCode.SLAVE_NOT_AVAILABLE);
+ sendOK = true;
+ break;
+
+ // Failed
+ case CREATE_MAPEDFILE_FAILED:
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("create mapped file failed, server is busy or broken.");
+ break;
+ case MESSAGE_ILLEGAL:
+ case PROPERTIES_SIZE_EXCEEDED:
+ response.setCode(ResponseCode.MESSAGE_ILLEGAL);
+ response.setRemark(
+ "the message is illegal, maybe msg body or properties length not matched. msg body length limit 128k, msg properties length limit 32k.");
+ break;
+ case SERVICE_NOT_AVAILABLE:
+ response.setCode(ResponseCode.SERVICE_NOT_AVAILABLE);
+ response.setRemark(
+ "service not available now, maybe disk full, " + diskUtil() + ", maybe your broker machine memory too small.");
+ break;
+ case OS_PAGECACHE_BUSY:
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("[PC_SYNCHRONIZED]broker busy, start flow control for a while");
+ break;
+ case UNKNOWN_ERROR:
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("UNKNOWN_ERROR");
+ break;
+ default:
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("UNKNOWN_ERROR DEFAULT");
+ break;
+ }
+
+ String owner = request.getExtFields().get(BrokerStatsManager.COMMERCIAL_OWNER);
+ if (sendOK) {
+
+ this.brokerController.getBrokerStatsManager().incTopicPutNums(msgInner.getTopic());
+ this.brokerController.getBrokerStatsManager().incTopicPutSize(msgInner.getTopic(),
+ putMessageResult.getAppendMessageResult().getWroteBytes());
+ this.brokerController.getBrokerStatsManager().incBrokerPutNums();
+
+ response.setRemark(null);
+
+ responseHeader.setMsgId(putMessageResult.getAppendMessageResult().getMsgId());
+ responseHeader.setQueueId(queueIdInt);
+ responseHeader.setQueueOffset(putMessageResult.getAppendMessageResult().getLogicsOffset());
+
+
+ doResponse(ctx, request, response);
+
+
+ if (hasSendMessageHook()) {
+ sendMessageContext.setMsgId(responseHeader.getMsgId());
+ sendMessageContext.setQueueId(responseHeader.getQueueId());
+ sendMessageContext.setQueueOffset(responseHeader.getQueueOffset());
+
+ int commercialBaseCount = brokerController.getBrokerConfig().getCommercialBaseCount();
+ int wroteSize = putMessageResult.getAppendMessageResult().getWroteBytes();
+ int incValue = (int) Math.ceil(wroteSize / BrokerStatsManager.SIZE_PER_COUNT) * commercialBaseCount;
+
+ sendMessageContext.setCommercialSendStats(BrokerStatsManager.StatsType.SEND_SUCCESS);
+ sendMessageContext.setCommercialSendTimes(incValue);
+ sendMessageContext.setCommercialSendSize(wroteSize);
+ sendMessageContext.setCommercialOwner(owner);
+ }
+ return null;
+ } else {
+ if (hasSendMessageHook()) {
+ int wroteSize = request.getBody().length;
+ int incValue = (int) Math.ceil(wroteSize / BrokerStatsManager.SIZE_PER_COUNT);
+
+ sendMessageContext.setCommercialSendStats(BrokerStatsManager.StatsType.SEND_FAILURE);
+ sendMessageContext.setCommercialSendTimes(incValue);
+ sendMessageContext.setCommercialSendSize(wroteSize);
+ sendMessageContext.setCommercialOwner(owner);
+ }
+ }
+ } else {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("store putMessage return null");
+ }
+
+ return response;
+ }
+
+ public boolean hasConsumeMessageHook() {
+ return consumeMessageHookList != null && !this.consumeMessageHookList.isEmpty();
+ }
+
+ public void executeConsumeMessageHookAfter(final ConsumeMessageContext context) {
+ if (hasConsumeMessageHook()) {
+ for (ConsumeMessageHook hook : this.consumeMessageHookList) {
+ try {
+ hook.consumeMessageAfter(context);
+ } catch (Throwable e) {
+ }
+ }
+ }
+ }
+
+ public SocketAddress getStoreHost() {
+ return storeHost;
+ }
+
+ private String diskUtil() {
+ String storePathPhysic = this.brokerController.getMessageStoreConfig().getStorePathCommitLog();
+ double physicRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathPhysic);
+
+ String storePathLogis =
+ StorePathConfigHelper.getStorePathConsumeQueue(this.brokerController.getMessageStoreConfig().getStorePathRootDir());
+ double logisRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathLogis);
+
+ String storePathIndex =
+ StorePathConfigHelper.getStorePathIndex(this.brokerController.getMessageStoreConfig().getStorePathRootDir());
+ double indexRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathIndex);
+
+ return String.format("CL: %5.2f CQ: %5.2f INDEX: %5.2f", physicRatio, logisRatio, indexRatio);
+ }
+
+ public void registerConsumeMessageHook(List<ConsumeMessageHook> consumeMessageHookList) {
+ this.consumeMessageHookList = consumeMessageHookList;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java b/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
new file mode 100644
index 0000000..45914d7
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
@@ -0,0 +1,158 @@
+/**
+ * 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.broker.slave;
+
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.broker.subscription.SubscriptionGroupManager;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.protocol.body.ConsumerOffsetSerializeWrapper;
+import org.apache.rocketmq.common.protocol.body.SubscriptionGroupWrapper;
+import org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper;
+import org.apache.rocketmq.store.config.StorePathConfigHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+
+/**
+ * @author shijia.wxr
+ * @author manhong.yqd
+ */
+public class SlaveSynchronize {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+ private final BrokerController brokerController;
+ private volatile String masterAddr = null;
+
+
+ public SlaveSynchronize(BrokerController brokerController) {
+ this.brokerController = brokerController;
+ }
+
+
+ public String getMasterAddr() {
+ return masterAddr;
+ }
+
+
+ public void setMasterAddr(String masterAddr) {
+ this.masterAddr = masterAddr;
+ }
+
+
+ public void syncAll() {
+ this.syncTopicConfig();
+ this.syncConsumerOffset();
+ this.syncDelayOffset();
+ this.syncSubscriptionGroupConfig();
+ }
+
+
+ private void syncTopicConfig() {
+ String masterAddrBak = this.masterAddr;
+ if (masterAddrBak != null) {
+ try {
+ TopicConfigSerializeWrapper topicWrapper =
+ this.brokerController.getBrokerOuterAPI().getAllTopicConfig(masterAddrBak);
+ if (!this.brokerController.getTopicConfigManager().getDataVersion()
+ .equals(topicWrapper.getDataVersion())) {
+
+ this.brokerController.getTopicConfigManager().getDataVersion()
+ .assignNewOne(topicWrapper.getDataVersion());
+ this.brokerController.getTopicConfigManager().getTopicConfigTable().clear();
+ this.brokerController.getTopicConfigManager().getTopicConfigTable()
+ .putAll(topicWrapper.getTopicConfigTable());
+ this.brokerController.getTopicConfigManager().persist();
+
+ log.info("update slave topic config from master, {}", masterAddrBak);
+ }
+ } catch (Exception e) {
+ log.error("syncTopicConfig Exception, " + masterAddrBak, e);
+ }
+ }
+ }
+
+
+ private void syncConsumerOffset() {
+ String masterAddrBak = this.masterAddr;
+ if (masterAddrBak != null) {
+ try {
+ ConsumerOffsetSerializeWrapper offsetWrapper =
+ this.brokerController.getBrokerOuterAPI().getAllConsumerOffset(masterAddrBak);
+ this.brokerController.getConsumerOffsetManager().getOffsetTable()
+ .putAll(offsetWrapper.getOffsetTable());
+ this.brokerController.getConsumerOffsetManager().persist();
+ log.info("update slave consumer offset from master, {}", masterAddrBak);
+ } catch (Exception e) {
+ log.error("syncConsumerOffset Exception, " + masterAddrBak, e);
+ }
+ }
+ }
+
+
+ private void syncDelayOffset() {
+ String masterAddrBak = this.masterAddr;
+ if (masterAddrBak != null) {
+ try {
+ String delayOffset =
+ this.brokerController.getBrokerOuterAPI().getAllDelayOffset(masterAddrBak);
+ if (delayOffset != null) {
+
+ String fileName =
+ StorePathConfigHelper.getDelayOffsetStorePath(this.brokerController
+ .getMessageStoreConfig().getStorePathRootDir());
+ try {
+ MixAll.string2File(delayOffset, fileName);
+ } catch (IOException e) {
+ log.error("persist file Exception, " + fileName, e);
+ }
+ }
+ log.info("update slave delay offset from master, {}", masterAddrBak);
+ } catch (Exception e) {
+ log.error("syncDelayOffset Exception, " + masterAddrBak, e);
+ }
+ }
+ }
+
+
+ private void syncSubscriptionGroupConfig() {
+ String masterAddrBak = this.masterAddr;
+ if (masterAddrBak != null) {
+ try {
+ SubscriptionGroupWrapper subscriptionWrapper =
+ this.brokerController.getBrokerOuterAPI()
+ .getAllSubscriptionGroupConfig(masterAddrBak);
+
+ if (!this.brokerController.getSubscriptionGroupManager().getDataVersion()
+ .equals(subscriptionWrapper.getDataVersion())) {
+ SubscriptionGroupManager subscriptionGroupManager =
+ this.brokerController.getSubscriptionGroupManager();
+ subscriptionGroupManager.getDataVersion().assignNewOne(
+ subscriptionWrapper.getDataVersion());
+ subscriptionGroupManager.getSubscriptionGroupTable().clear();
+ subscriptionGroupManager.getSubscriptionGroupTable().putAll(
+ subscriptionWrapper.getSubscriptionGroupTable());
+ subscriptionGroupManager.persist();
+ log.info("update slave Subscription Group from master, {}", masterAddrBak);
+ }
+ } catch (Exception e) {
+ log.error("syncSubscriptionGroup Exception, " + masterAddrBak, e);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java b/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java
new file mode 100644
index 0000000..364d5c8
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java
@@ -0,0 +1,203 @@
+/**
+ * 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.broker.subscription;
+
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.broker.BrokerPathConfigHelper;
+import org.apache.rocketmq.common.ConfigManager;
+import org.apache.rocketmq.common.DataVersion;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.subscription.SubscriptionGroupConfig;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class SubscriptionGroupManager extends ConfigManager {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+
+ private final ConcurrentHashMap<String, SubscriptionGroupConfig> subscriptionGroupTable =
+ new ConcurrentHashMap<String, SubscriptionGroupConfig>(1024);
+ private final DataVersion dataVersion = new DataVersion();
+ private transient BrokerController brokerController;
+
+
+ public SubscriptionGroupManager() {
+ this.init();
+ }
+
+ private void init() {
+ {
+ SubscriptionGroupConfig subscriptionGroupConfig = new SubscriptionGroupConfig();
+ subscriptionGroupConfig.setGroupName(MixAll.TOOLS_CONSUMER_GROUP);
+ this.subscriptionGroupTable.put(MixAll.TOOLS_CONSUMER_GROUP, subscriptionGroupConfig);
+ }
+
+ {
+ SubscriptionGroupConfig subscriptionGroupConfig = new SubscriptionGroupConfig();
+ subscriptionGroupConfig.setGroupName(MixAll.FILTERSRV_CONSUMER_GROUP);
+ this.subscriptionGroupTable.put(MixAll.FILTERSRV_CONSUMER_GROUP, subscriptionGroupConfig);
+ }
+
+ {
+ SubscriptionGroupConfig subscriptionGroupConfig = new SubscriptionGroupConfig();
+ subscriptionGroupConfig.setGroupName(MixAll.SELF_TEST_CONSUMER_GROUP);
+ this.subscriptionGroupTable.put(MixAll.SELF_TEST_CONSUMER_GROUP, subscriptionGroupConfig);
+ }
+
+ {
+ SubscriptionGroupConfig subscriptionGroupConfig = new SubscriptionGroupConfig();
+ subscriptionGroupConfig.setGroupName(MixAll.ONS_HTTP_PROXY_GROUP);
+ subscriptionGroupConfig.setConsumeBroadcastEnable(true);
+ this.subscriptionGroupTable.put(MixAll.ONS_HTTP_PROXY_GROUP, subscriptionGroupConfig);
+ }
+
+ {
+ SubscriptionGroupConfig subscriptionGroupConfig = new SubscriptionGroupConfig();
+ subscriptionGroupConfig.setGroupName(MixAll.CID_ONSAPI_PULL_GROUP);
+ subscriptionGroupConfig.setConsumeBroadcastEnable(true);
+ this.subscriptionGroupTable.put(MixAll.CID_ONSAPI_PULL_GROUP, subscriptionGroupConfig);
+ }
+
+ {
+ SubscriptionGroupConfig subscriptionGroupConfig = new SubscriptionGroupConfig();
+ subscriptionGroupConfig.setGroupName(MixAll.CID_ONSAPI_PERMISSION_GROUP);
+ subscriptionGroupConfig.setConsumeBroadcastEnable(true);
+ this.subscriptionGroupTable.put(MixAll.CID_ONSAPI_PERMISSION_GROUP, subscriptionGroupConfig);
+ }
+
+ {
+ SubscriptionGroupConfig subscriptionGroupConfig = new SubscriptionGroupConfig();
+ subscriptionGroupConfig.setGroupName(MixAll.CID_ONSAPI_OWNER_GROUP);
+ subscriptionGroupConfig.setConsumeBroadcastEnable(true);
+ this.subscriptionGroupTable.put(MixAll.CID_ONSAPI_OWNER_GROUP, subscriptionGroupConfig);
+ }
+ }
+
+
+ public SubscriptionGroupManager(BrokerController brokerController) {
+ this.brokerController = brokerController;
+ this.init();
+ }
+
+
+ public void updateSubscriptionGroupConfig(final SubscriptionGroupConfig config) {
+ SubscriptionGroupConfig old = this.subscriptionGroupTable.put(config.getGroupName(), config);
+ if (old != null) {
+ log.info("update subscription group config, old: " + old + " new: " + config);
+ } else {
+ log.info("create new subscription group, " + config);
+ }
+
+ this.dataVersion.nextVersion();
+
+ this.persist();
+ }
+
+ public void disableConsume(final String groupName) {
+ SubscriptionGroupConfig old = this.subscriptionGroupTable.get(groupName);
+ if (old != null) {
+ old.setConsumeEnable(false);
+ this.dataVersion.nextVersion();
+ }
+ }
+
+
+ public SubscriptionGroupConfig findSubscriptionGroupConfig(final String group) {
+ SubscriptionGroupConfig subscriptionGroupConfig = this.subscriptionGroupTable.get(group);
+ if (null == subscriptionGroupConfig) {
+ if (brokerController.getBrokerConfig().isAutoCreateSubscriptionGroup() || MixAll.isSysConsumerGroup(group)) {
+ subscriptionGroupConfig = new SubscriptionGroupConfig();
+ subscriptionGroupConfig.setGroupName(group);
+ SubscriptionGroupConfig preConfig = this.subscriptionGroupTable.putIfAbsent(group, subscriptionGroupConfig);
+ if (null == preConfig) {
+ log.info("auto create a subscription group, {}", subscriptionGroupConfig.toString());
+ }
+ this.dataVersion.nextVersion();
+ this.persist();
+ }
+ }
+
+ return subscriptionGroupConfig;
+ }
+
+
+ @Override
+ public String encode() {
+ return this.encode(false);
+ }
+
+ @Override
+ public String configFilePath() {
+ //return BrokerPathConfigHelper.getSubscriptionGroupPath(this.brokerController.getMessageStoreConfig().getStorePathRootDir());
+ return BrokerPathConfigHelper.getSubscriptionGroupPath(System.getProperty("user.home") + File.separator + "store");
+ }
+
+ @Override
+ public void decode(String jsonString) {
+ if (jsonString != null) {
+ SubscriptionGroupManager obj = RemotingSerializable.fromJson(jsonString, SubscriptionGroupManager.class);
+ if (obj != null) {
+ this.subscriptionGroupTable.putAll(obj.subscriptionGroupTable);
+ this.dataVersion.assignNewOne(obj.dataVersion);
+ this.printLoadDataWhenFirstBoot(obj);
+ }
+ }
+ }
+
+ public String encode(final boolean prettyFormat) {
+ return RemotingSerializable.toJson(this, prettyFormat);
+ }
+
+ private void printLoadDataWhenFirstBoot(final SubscriptionGroupManager sgm) {
+ Iterator<Entry<String, SubscriptionGroupConfig>> it = sgm.getSubscriptionGroupTable().entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, SubscriptionGroupConfig> next = it.next();
+ log.info("load exist subscription group, {}", next.getValue().toString());
+ }
+ }
+
+ public ConcurrentHashMap<String, SubscriptionGroupConfig> getSubscriptionGroupTable() {
+ return subscriptionGroupTable;
+ }
+
+
+ public DataVersion getDataVersion() {
+ return dataVersion;
+ }
+
+
+ public void deleteSubscriptionGroupConfig(final String groupName) {
+ SubscriptionGroupConfig old = this.subscriptionGroupTable.remove(groupName);
+ if (old != null) {
+ log.info("delete subscription group OK, subscription group: " + old);
+ this.dataVersion.nextVersion();
+ this.persist();
+ } else {
+ log.warn("delete subscription group failed, subscription group: " + old + " not exist");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java b/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java
new file mode 100644
index 0000000..40fdd68
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java
@@ -0,0 +1,440 @@
+/**
+ * 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.broker.topic;
+
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.broker.BrokerPathConfigHelper;
+import org.apache.rocketmq.common.ConfigManager;
+import org.apache.rocketmq.common.DataVersion;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.TopicConfig;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.constant.PermName;
+import org.apache.rocketmq.common.protocol.body.KVTable;
+import org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper;
+import org.apache.rocketmq.common.sysflag.TopicSysFlag;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class TopicConfigManager extends ConfigManager {
+ private static final Logger LOG = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+ private static final long LOCK_TIMEOUT_MILLIS = 3000;
+ private transient final Lock lockTopicConfigTable = new ReentrantLock();
+
+ private final ConcurrentHashMap<String, TopicConfig> topicConfigTable =
+ new ConcurrentHashMap<String, TopicConfig>(1024);
+ private final DataVersion dataVersion = new DataVersion();
+ private final Set<String> systemTopicList = new HashSet<String>();
+ private transient BrokerController brokerController;
+
+
+ public TopicConfigManager() {
+ }
+
+
+ public TopicConfigManager(BrokerController brokerController) {
+ this.brokerController = brokerController;
+ {
+ // MixAll.SELF_TEST_TOPIC
+ String topic = MixAll.SELF_TEST_TOPIC;
+ TopicConfig topicConfig = new TopicConfig(topic);
+ this.systemTopicList.add(topic);
+ topicConfig.setReadQueueNums(1);
+ topicConfig.setWriteQueueNums(1);
+ this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig);
+ }
+ {
+ // MixAll.DEFAULT_TOPIC
+ if (this.brokerController.getBrokerConfig().isAutoCreateTopicEnable()) {
+ String topic = MixAll.DEFAULT_TOPIC;
+ TopicConfig topicConfig = new TopicConfig(topic);
+ this.systemTopicList.add(topic);
+ topicConfig.setReadQueueNums(this.brokerController.getBrokerConfig()
+ .getDefaultTopicQueueNums());
+ topicConfig.setWriteQueueNums(this.brokerController.getBrokerConfig()
+ .getDefaultTopicQueueNums());
+ int perm = PermName.PERM_INHERIT | PermName.PERM_READ | PermName.PERM_WRITE;
+ topicConfig.setPerm(perm);
+ this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig);
+ }
+ }
+ {
+ // MixAll.BENCHMARK_TOPIC
+ String topic = MixAll.BENCHMARK_TOPIC;
+ TopicConfig topicConfig = new TopicConfig(topic);
+ this.systemTopicList.add(topic);
+ topicConfig.setReadQueueNums(1024);
+ topicConfig.setWriteQueueNums(1024);
+ this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig);
+ }
+ {
+
+ String topic = this.brokerController.getBrokerConfig().getBrokerClusterName();
+ TopicConfig topicConfig = new TopicConfig(topic);
+ this.systemTopicList.add(topic);
+ int perm = PermName.PERM_INHERIT;
+ if (this.brokerController.getBrokerConfig().isClusterTopicEnable()) {
+ perm |= PermName.PERM_READ | PermName.PERM_WRITE;
+ }
+ topicConfig.setPerm(perm);
+ this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig);
+ }
+ {
+
+ String topic = this.brokerController.getBrokerConfig().getBrokerName();
+ TopicConfig topicConfig = new TopicConfig(topic);
+ this.systemTopicList.add(topic);
+ int perm = PermName.PERM_INHERIT;
+ if (this.brokerController.getBrokerConfig().isBrokerTopicEnable()) {
+ perm |= PermName.PERM_READ | PermName.PERM_WRITE;
+ }
+ topicConfig.setReadQueueNums(1);
+ topicConfig.setWriteQueueNums(1);
+ topicConfig.setPerm(perm);
+ this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig);
+ }
+ {
+ // MixAll.OFFSET_MOVED_EVENT
+ String topic = MixAll.OFFSET_MOVED_EVENT;
+ TopicConfig topicConfig = new TopicConfig(topic);
+ this.systemTopicList.add(topic);
+ topicConfig.setReadQueueNums(1);
+ topicConfig.setWriteQueueNums(1);
+ this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig);
+ }
+ }
+
+
+ public boolean isSystemTopic(final String topic) {
+ return this.systemTopicList.contains(topic);
+ }
+
+
+ public Set<String> getSystemTopic() {
+ return this.systemTopicList;
+ }
+
+
+ public boolean isTopicCanSendMessage(final String topic) {
+ return !topic.equals(MixAll.DEFAULT_TOPIC);
+ }
+
+
+ public TopicConfig selectTopicConfig(final String topic) {
+ return this.topicConfigTable.get(topic);
+ }
+
+
+ public TopicConfig createTopicInSendMessageMethod(final String topic, final String defaultTopic,
+ final String remoteAddress, final int clientDefaultTopicQueueNums, final int topicSysFlag) {
+ TopicConfig topicConfig = null;
+ boolean createNew = false;
+
+ try {
+ if (this.lockTopicConfigTable.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
+ try {
+ topicConfig = this.topicConfigTable.get(topic);
+ if (topicConfig != null)
+ return topicConfig;
+
+ TopicConfig defaultTopicConfig = this.topicConfigTable.get(defaultTopic);
+ if (defaultTopicConfig != null) {
+ if (defaultTopic.equals(MixAll.DEFAULT_TOPIC)) {
+ if (!this.brokerController.getBrokerConfig().isAutoCreateTopicEnable()) {
+ defaultTopicConfig.setPerm(PermName.PERM_READ | PermName.PERM_WRITE);
+ }
+ }
+
+ if (PermName.isInherited(defaultTopicConfig.getPerm())) {
+ topicConfig = new TopicConfig(topic);
+
+ int queueNums =
+ clientDefaultTopicQueueNums > defaultTopicConfig.getWriteQueueNums() ? defaultTopicConfig
+ .getWriteQueueNums() : clientDefaultTopicQueueNums;
+
+ if (queueNums < 0) {
+ queueNums = 0;
+ }
+
+ topicConfig.setReadQueueNums(queueNums);
+ topicConfig.setWriteQueueNums(queueNums);
+ int perm = defaultTopicConfig.getPerm();
+ perm &= ~PermName.PERM_INHERIT;
+ topicConfig.setPerm(perm);
+ topicConfig.setTopicSysFlag(topicSysFlag);
+ topicConfig.setTopicFilterType(defaultTopicConfig.getTopicFilterType());
+ } else {
+ LOG.warn("create new topic failed, because the default topic[" + defaultTopic
+ + "] no perm, " + defaultTopicConfig.getPerm() + " producer: "
+ + remoteAddress);
+ }
+ } else {
+ LOG.warn("create new topic failed, because the default topic[" + defaultTopic
+ + "] not exist." + " producer: " + remoteAddress);
+ }
+
+ if (topicConfig != null) {
+ LOG.info("create new topic by default topic[" + defaultTopic + "], " + topicConfig
+ + " producer: " + remoteAddress);
+
+ this.topicConfigTable.put(topic, topicConfig);
+
+ this.dataVersion.nextVersion();
+
+ createNew = true;
+
+ this.persist();
+ }
+ } finally {
+ this.lockTopicConfigTable.unlock();
+ }
+ }
+ } catch (InterruptedException e) {
+ LOG.error("createTopicInSendMessageMethod exception", e);
+ }
+
+ if (createNew) {
+ this.brokerController.registerBrokerAll(false, true);
+ }
+
+ return topicConfig;
+ }
+
+ public TopicConfig createTopicInSendMessageBackMethod(
+ final String topic,
+ final int clientDefaultTopicQueueNums,
+ final int perm,
+ final int topicSysFlag) {
+ TopicConfig topicConfig = this.topicConfigTable.get(topic);
+ if (topicConfig != null)
+ return topicConfig;
+
+ boolean createNew = false;
+
+ try {
+ if (this.lockTopicConfigTable.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
+ try {
+ topicConfig = this.topicConfigTable.get(topic);
+ if (topicConfig != null)
+ return topicConfig;
+
+ topicConfig = new TopicConfig(topic);
+ topicConfig.setReadQueueNums(clientDefaultTopicQueueNums);
+ topicConfig.setWriteQueueNums(clientDefaultTopicQueueNums);
+ topicConfig.setPerm(perm);
+ topicConfig.setTopicSysFlag(topicSysFlag);
+
+ LOG.info("create new topic {}", topicConfig);
+ this.topicConfigTable.put(topic, topicConfig);
+ createNew = true;
+ this.dataVersion.nextVersion();
+ this.persist();
+ } finally {
+ this.lockTopicConfigTable.unlock();
+ }
+ }
+ } catch (InterruptedException e) {
+ LOG.error("createTopicInSendMessageBackMethod exception", e);
+ }
+
+ if (createNew) {
+ this.brokerController.registerBrokerAll(false, true);
+ }
+
+ return topicConfig;
+ }
+
+ public void updateTopicUnitFlag(final String topic, final boolean unit) {
+
+ TopicConfig topicConfig = this.topicConfigTable.get(topic);
+ if (topicConfig != null) {
+ int oldTopicSysFlag = topicConfig.getTopicSysFlag();
+ if (unit) {
+ topicConfig.setTopicSysFlag(TopicSysFlag.setUnitFlag(oldTopicSysFlag));
+ } else {
+ topicConfig.setTopicSysFlag(TopicSysFlag.clearUnitFlag(oldTopicSysFlag));
+ }
+
+ LOG.info("update topic sys flag. oldTopicSysFlag={}, newTopicSysFlag", oldTopicSysFlag,
+ topicConfig.getTopicSysFlag());
+
+ this.topicConfigTable.put(topic, topicConfig);
+
+ this.dataVersion.nextVersion();
+
+ this.persist();
+ this.brokerController.registerBrokerAll(false, true);
+ }
+ }
+
+ public void updateTopicUnitSubFlag(final String topic, final boolean hasUnitSub) {
+ TopicConfig topicConfig = this.topicConfigTable.get(topic);
+ if (topicConfig != null) {
+ int oldTopicSysFlag = topicConfig.getTopicSysFlag();
+ if (hasUnitSub) {
+ topicConfig.setTopicSysFlag(TopicSysFlag.setUnitSubFlag(oldTopicSysFlag));
+ }
+
+ LOG.info("update topic sys flag. oldTopicSysFlag={}, newTopicSysFlag", oldTopicSysFlag,
+ topicConfig.getTopicSysFlag());
+
+ this.topicConfigTable.put(topic, topicConfig);
+
+ this.dataVersion.nextVersion();
+
+ this.persist();
+ this.brokerController.registerBrokerAll(false, true);
+ }
+ }
+
+ public void updateTopicConfig(final TopicConfig topicConfig) {
+ TopicConfig old = this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig);
+ if (old != null) {
+ LOG.info("update topic config, old: " + old + " new: " + topicConfig);
+ } else {
+ LOG.info("create new topic, " + topicConfig);
+ }
+
+ this.dataVersion.nextVersion();
+
+ this.persist();
+ }
+
+
+ public void updateOrderTopicConfig(final KVTable orderKVTableFromNs) {
+
+ if (orderKVTableFromNs != null && orderKVTableFromNs.getTable() != null) {
+ boolean isChange = false;
+ Set<String> orderTopics = orderKVTableFromNs.getTable().keySet();
+ for (String topic : orderTopics) {
+ TopicConfig topicConfig = this.topicConfigTable.get(topic);
+ if (topicConfig != null && !topicConfig.isOrder()) {
+ topicConfig.setOrder(true);
+ isChange = true;
+ LOG.info("update order topic config, topic={}, order={}", topic, true);
+ }
+ }
+
+ for (Map.Entry<String, TopicConfig> entry : this.topicConfigTable.entrySet()) {
+ String topic = entry.getKey();
+ if (!orderTopics.contains(topic)) {
+ TopicConfig topicConfig = entry.getValue();
+ if (topicConfig.isOrder()) {
+ topicConfig.setOrder(false);
+ isChange = true;
+ LOG.info("update order topic config, topic={}, order={}", topic, false);
+ }
+ }
+ }
+
+ if (isChange) {
+ this.dataVersion.nextVersion();
+ this.persist();
+ }
+ }
+ }
+
+ public boolean isOrderTopic(final String topic) {
+ TopicConfig topicConfig = this.topicConfigTable.get(topic);
+ if (topicConfig == null) {
+ return false;
+ } else {
+ return topicConfig.isOrder();
+ }
+ }
+
+ public void deleteTopicConfig(final String topic) {
+ TopicConfig old = this.topicConfigTable.remove(topic);
+ if (old != null) {
+ LOG.info("delete topic config OK, topic: " + old);
+ this.dataVersion.nextVersion();
+ this.persist();
+ } else {
+ LOG.warn("delete topic config failed, topic: " + topic + " not exist");
+ }
+ }
+
+ public TopicConfigSerializeWrapper buildTopicConfigSerializeWrapper() {
+ TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper();
+ topicConfigSerializeWrapper.setTopicConfigTable(this.topicConfigTable);
+ topicConfigSerializeWrapper.setDataVersion(this.dataVersion);
+ return topicConfigSerializeWrapper;
+ }
+
+ @Override
+ public String encode() {
+ return encode(false);
+ }
+
+ @Override
+ public String configFilePath() {
+// return BrokerPathConfigHelper.getTopicConfigPath(this.brokerController.getMessageStoreConfig()
+// .getStorePathRootDir());
+ return BrokerPathConfigHelper.getTopicConfigPath(System.getProperty("user.home") + File.separator + "store");
+ }
+
+ @Override
+ public void decode(String jsonString) {
+ if (jsonString != null) {
+ TopicConfigSerializeWrapper topicConfigSerializeWrapper =
+ TopicConfigSerializeWrapper.fromJson(jsonString, TopicConfigSerializeWrapper.class);
+ if (topicConfigSerializeWrapper != null) {
+ this.topicConfigTable.putAll(topicConfigSerializeWrapper.getTopicConfigTable());
+ this.dataVersion.assignNewOne(topicConfigSerializeWrapper.getDataVersion());
+ this.printLoadDataWhenFirstBoot(topicConfigSerializeWrapper);
+ }
+ }
+ }
+
+ public String encode(final boolean prettyFormat) {
+ TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper();
+ topicConfigSerializeWrapper.setTopicConfigTable(this.topicConfigTable);
+ topicConfigSerializeWrapper.setDataVersion(this.dataVersion);
+ return topicConfigSerializeWrapper.toJson(prettyFormat);
+ }
+
+ private void printLoadDataWhenFirstBoot(final TopicConfigSerializeWrapper tcs) {
+ Iterator<Entry<String, TopicConfig>> it = tcs.getTopicConfigTable().entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, TopicConfig> next = it.next();
+ LOG.info("load exist local topic, {}", next.getValue().toString());
+ }
+ }
+
+ public DataVersion getDataVersion() {
+ return dataVersion;
+ }
+
+ public ConcurrentHashMap<String, TopicConfig> getTopicConfigTable() {
+ return topicConfigTable;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionRecord.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionRecord.java b/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionRecord.java
new file mode 100644
index 0000000..68256d9
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionRecord.java
@@ -0,0 +1,44 @@
+/**
+ * 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.broker.transaction;
+
+public class TransactionRecord {
+ // Commit Log Offset
+ private long offset;
+ private String producerGroup;
+
+
+ public long getOffset() {
+ return offset;
+ }
+
+
+ public void setOffset(long offset) {
+ this.offset = offset;
+ }
+
+
+ public String getProducerGroup() {
+ return producerGroup;
+ }
+
+
+ public void setProducerGroup(String producerGroup) {
+ this.producerGroup = producerGroup;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionStore.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionStore.java b/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionStore.java
new file mode 100644
index 0000000..758eeed
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionStore.java
@@ -0,0 +1,46 @@
+/**
+ * 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.broker.transaction;
+
+import java.util.List;
+
+
+public interface TransactionStore {
+ public boolean open();
+
+
+ public void close();
+
+
+ public boolean put(final List<TransactionRecord> trs);
+
+
+ public void remove(final List<Long> pks);
+
+
+ public List<TransactionRecord> traverse(final long pk, final int nums);
+
+
+ public long totalRecords();
+
+
+ public long minPK();
+
+
+ public long maxPK();
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/transaction/jdbc/JDBCTransactionStore.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/transaction/jdbc/JDBCTransactionStore.java b/broker/src/main/java/org/apache/rocketmq/broker/transaction/jdbc/JDBCTransactionStore.java
new file mode 100644
index 0000000..4bf73d2
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/transaction/jdbc/JDBCTransactionStore.java
@@ -0,0 +1,240 @@
+/**
+ * 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.broker.transaction.jdbc;
+
+import org.apache.rocketmq.broker.transaction.TransactionRecord;
+import org.apache.rocketmq.broker.transaction.TransactionStore;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URL;
+import java.sql.*;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicLong;
+
+
+public class JDBCTransactionStore implements TransactionStore {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.TRANSACTION_LOGGER_NAME);
+ private final JDBCTransactionStoreConfig jdbcTransactionStoreConfig;
+ private Connection connection;
+ private AtomicLong totalRecordsValue = new AtomicLong(0);
+
+ public JDBCTransactionStore(JDBCTransactionStoreConfig jdbcTransactionStoreConfig) {
+ this.jdbcTransactionStoreConfig = jdbcTransactionStoreConfig;
+ }
+
+ @Override
+ public boolean open() {
+ if (this.loadDriver()) {
+ Properties props = new Properties();
+ props.put("user", jdbcTransactionStoreConfig.getJdbcUser());
+ props.put("password", jdbcTransactionStoreConfig.getJdbcPassword());
+
+ try {
+ this.connection =
+ DriverManager.getConnection(this.jdbcTransactionStoreConfig.getJdbcURL(), props);
+
+ this.connection.setAutoCommit(false);
+
+
+ if (!this.computeTotalRecords()) {
+ return this.createDB();
+ }
+
+ return true;
+ } catch (SQLException e) {
+ log.info("Create JDBC Connection Exeption", e);
+ }
+ }
+
+ return false;
+ }
+
+ private boolean loadDriver() {
+ try {
+ Class.forName(this.jdbcTransactionStoreConfig.getJdbcDriverClass()).newInstance();
+ log.info("Loaded the appropriate driver, {}",
+ this.jdbcTransactionStoreConfig.getJdbcDriverClass());
+ return true;
+ } catch (Exception e) {
+ log.info("Loaded the appropriate driver Exception", e);
+ }
+
+ return false;
+ }
+
+ private boolean computeTotalRecords() {
+ Statement statement = null;
+ ResultSet resultSet = null;
+ try {
+ statement = this.connection.createStatement();
+
+ resultSet = statement.executeQuery("select count(offset) as total from t_transaction");
+ if (!resultSet.next()) {
+ log.warn("computeTotalRecords ResultSet is empty");
+ return false;
+ }
+
+ this.totalRecordsValue.set(resultSet.getLong(1));
+ } catch (Exception e) {
+ log.warn("computeTotalRecords Exception", e);
+ return false;
+ } finally {
+ if (null != statement) {
+ try {
+ statement.close();
+ } catch (SQLException e) {
+ }
+ }
+
+ if (null != resultSet) {
+ try {
+ resultSet.close();
+ } catch (SQLException e) {
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private boolean createDB() {
+ Statement statement = null;
+ try {
+ statement = this.connection.createStatement();
+
+ String sql = this.createTableSql();
+ log.info("createDB SQL:\n {}", sql);
+ statement.execute(sql);
+ this.connection.commit();
+ return true;
+ } catch (Exception e) {
+ log.warn("createDB Exception", e);
+ return false;
+ } finally {
+ if (null != statement) {
+ try {
+ statement.close();
+ } catch (SQLException e) {
+ log.warn("Close statement exception", e);
+ }
+ }
+ }
+ }
+
+ private String createTableSql() {
+ URL resource = JDBCTransactionStore.class.getClassLoader().getResource("transaction.sql");
+ String fileContent = MixAll.file2String(resource);
+ return fileContent;
+ }
+
+ @Override
+ public void close() {
+ try {
+ if (this.connection != null) {
+ this.connection.close();
+ }
+ } catch (SQLException e) {
+ }
+ }
+
+ @Override
+ public boolean put(List<TransactionRecord> trs) {
+ PreparedStatement statement = null;
+ try {
+ this.connection.setAutoCommit(false);
+ statement = this.connection.prepareStatement("insert into t_transaction values (?, ?)");
+ for (TransactionRecord tr : trs) {
+ statement.setLong(1, tr.getOffset());
+ statement.setString(2, tr.getProducerGroup());
+ statement.addBatch();
+ }
+ int[] executeBatch = statement.executeBatch();
+ this.connection.commit();
+ this.totalRecordsValue.addAndGet(updatedRows(executeBatch));
+ return true;
+ } catch (Exception e) {
+ log.warn("createDB Exception", e);
+ return false;
+ } finally {
+ if (null != statement) {
+ try {
+ statement.close();
+ } catch (SQLException e) {
+ log.warn("Close statement exception", e);
+ }
+ }
+ }
+ }
+
+ private long updatedRows(int[] rows) {
+ long res = 0;
+ for (int i : rows) {
+ res += i;
+ }
+
+ return res;
+ }
+
+ @Override
+ public void remove(List<Long> pks) {
+ PreparedStatement statement = null;
+ try {
+ this.connection.setAutoCommit(false);
+ statement = this.connection.prepareStatement("DELETE FROM t_transaction WHERE offset = ?");
+ for (long pk : pks) {
+ statement.setLong(1, pk);
+ statement.addBatch();
+ }
+ int[] executeBatch = statement.executeBatch();
+ this.connection.commit();
+ } catch (Exception e) {
+ log.warn("createDB Exception", e);
+ } finally {
+ if (null != statement) {
+ try {
+ statement.close();
+ } catch (SQLException e) {
+ }
+ }
+ }
+ }
+
+ @Override
+ public List<TransactionRecord> traverse(long pk, int nums) {
+ return null;
+ }
+
+ @Override
+ public long totalRecords() {
+ return this.totalRecordsValue.get();
+ }
+
+ @Override
+ public long minPK() {
+ return 0;
+ }
+
+ @Override
+ public long maxPK() {
+ return 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/transaction/jdbc/JDBCTransactionStoreConfig.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/transaction/jdbc/JDBCTransactionStoreConfig.java b/broker/src/main/java/org/apache/rocketmq/broker/transaction/jdbc/JDBCTransactionStoreConfig.java
new file mode 100644
index 0000000..5789329
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/transaction/jdbc/JDBCTransactionStoreConfig.java
@@ -0,0 +1,65 @@
+/**
+ * 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.broker.transaction.jdbc;
+
+public class JDBCTransactionStoreConfig {
+ private String jdbcDriverClass = "com.mysql.jdbc.Driver";
+ private String jdbcURL = "jdbc:mysql://xxx.xxx.xxx.xxx:1000/xxx?useUnicode=true&characterEncoding=UTF-8";
+ private String jdbcUser = "xxx";
+ private String jdbcPassword = "xxx";
+
+
+ public String getJdbcDriverClass() {
+ return jdbcDriverClass;
+ }
+
+
+ public void setJdbcDriverClass(String jdbcDriverClass) {
+ this.jdbcDriverClass = jdbcDriverClass;
+ }
+
+
+ public String getJdbcURL() {
+ return jdbcURL;
+ }
+
+
+ public void setJdbcURL(String jdbcURL) {
+ this.jdbcURL = jdbcURL;
+ }
+
+
+ public String getJdbcUser() {
+ return jdbcUser;
+ }
+
+
+ public void setJdbcUser(String jdbcUser) {
+ this.jdbcUser = jdbcUser;
+ }
+
+
+ public String getJdbcPassword() {
+ return jdbcPassword;
+ }
+
+
+ public void setJdbcPassword(String jdbcPassword) {
+ this.jdbcPassword = jdbcPassword;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/test/java/com/alibaba/rocketmq/broker/BrokerControllerTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/com/alibaba/rocketmq/broker/BrokerControllerTest.java b/broker/src/test/java/com/alibaba/rocketmq/broker/BrokerControllerTest.java
deleted file mode 100644
index b661385..0000000
--- a/broker/src/test/java/com/alibaba/rocketmq/broker/BrokerControllerTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * 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;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author shtykh_roman
- */
-public class BrokerControllerTest {
- protected Logger logger = LoggerFactory.getLogger(BrokerControllerTest.class);
-
- 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();
- Assert.assertTrue(initResult);
- logger.info("Broker is initialized " + initResult);
- brokerController.start();
- logger.info("Broker is started");
-
- brokerController.shutdown();
- logger.info("Broker is stopped");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/test/java/com/alibaba/rocketmq/broker/BrokerTestHarness.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/com/alibaba/rocketmq/broker/BrokerTestHarness.java b/broker/src/test/java/com/alibaba/rocketmq/broker/BrokerTestHarness.java
deleted file mode 100644
index ca6f17b..0000000
--- a/broker/src/test/java/com/alibaba/rocketmq/broker/BrokerTestHarness.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: SendMessageTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
- */
-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.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.util.Random;
-
-/**
- * @author zander
- */
-public class BrokerTestHarness {
-
- protected BrokerController brokerController = null;
-
- protected Random random = new Random();
- public final String BROKER_NAME = "TestBrokerName";
- protected String brokerAddr = "";
- protected Logger logger = LoggerFactory.getLogger(BrokerTestHarness.class);
- protected BrokerConfig brokerConfig = new BrokerConfig();
- protected NettyServerConfig nettyServerConfig = new NettyServerConfig();
- protected NettyClientConfig nettyClientConfig = new NettyClientConfig();
- protected MessageStoreConfig storeConfig = new MessageStoreConfig();
-
- @Before
- public void startup() throws Exception {
- brokerConfig.setBrokerName(BROKER_NAME);
- brokerConfig.setBrokerIP1("127.0.0.1");
- storeConfig.setStorePathRootDir(System.getProperty("user.home") + File.separator + "unitteststore");
- storeConfig.setStorePathCommitLog(System.getProperty("user.home") + File.separator + "unitteststore" + File.separator + "commitlog");
- nettyServerConfig.setListenPort(10000 + random.nextInt(1000));
- brokerAddr = brokerConfig.getBrokerIP1() + ":" + nettyServerConfig.getListenPort();
- brokerController = new BrokerController(brokerConfig, nettyServerConfig, nettyClientConfig, storeConfig);
- boolean initResult = brokerController.initialize();
- Assert.assertTrue(initResult);
- logger.info("Broker Start name:{} addr:{}", brokerConfig.getBrokerName(), brokerController.getBrokerAddr());
- brokerController.start();
- }
-
- @After
- public void shutdown() throws Exception {
- if (brokerController != null) {
- brokerController.shutdown();
- }
- //maybe need to clean the file store. But we do not suggest deleting anything.
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/test/java/com/alibaba/rocketmq/broker/api/SendMessageTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/com/alibaba/rocketmq/broker/api/SendMessageTest.java b/broker/src/test/java/com/alibaba/rocketmq/broker/api/SendMessageTest.java
deleted file mode 100644
index cf97876..0000000
--- a/broker/src/test/java/com/alibaba/rocketmq/broker/api/SendMessageTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: SendMessageTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
- */
-package com.alibaba.rocketmq.broker.api;
-
-import com.alibaba.rocketmq.broker.BrokerTestHarness;
-import com.alibaba.rocketmq.client.ClientConfig;
-import com.alibaba.rocketmq.client.hook.SendMessageContext;
-import com.alibaba.rocketmq.client.impl.CommunicationMode;
-import com.alibaba.rocketmq.client.impl.MQClientAPIImpl;
-import com.alibaba.rocketmq.client.producer.SendResult;
-import com.alibaba.rocketmq.client.producer.SendStatus;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.common.message.MessageDecoder;
-import com.alibaba.rocketmq.common.protocol.header.SendMessageRequestHeader;
-import com.alibaba.rocketmq.remoting.netty.NettyClientConfig;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-
-/**
- * @author zander
- */
-public class SendMessageTest extends BrokerTestHarness{
-
- MQClientAPIImpl client = new MQClientAPIImpl(new NettyClientConfig(), null, null, new ClientConfig());
- String topic = "UnitTestTopic";
-
- @Before
- @Override
- public void startup() throws Exception {
- super.startup();
- client.start();
-
- }
-
- @After
- @Override
- public void shutdown() throws Exception {
- client.shutdown();
- super.shutdown();
- }
-
- @Test
- public void testSendSingle() throws Exception{
- Message msg = new Message(topic, "TAG1 TAG2", "100200300", "body".getBytes());
- SendMessageRequestHeader requestHeader = new SendMessageRequestHeader();
- requestHeader.setProducerGroup("abc");
- requestHeader.setTopic(msg.getTopic());
- requestHeader.setDefaultTopic(MixAll.DEFAULT_TOPIC);
- requestHeader.setDefaultTopicQueueNums(4);
- requestHeader.setQueueId(0);
- requestHeader.setSysFlag(0);
- requestHeader.setBornTimestamp(System.currentTimeMillis());
- requestHeader.setFlag(msg.getFlag());
- requestHeader.setProperties(MessageDecoder.messageProperties2String(msg.getProperties()));
-
- SendResult result = client.sendMessage(brokerAddr, BROKER_NAME, msg, requestHeader, 1000 * 5,
- CommunicationMode.SYNC, new SendMessageContext(), null);
- assertEquals(result.getSendStatus(), SendStatus.SEND_OK);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/test/java/com/alibaba/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/com/alibaba/rocketmq/broker/offset/ConsumerOffsetManagerTest.java b/broker/src/test/java/com/alibaba/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
deleted file mode 100644
index 94504a4..0000000
--- a/broker/src/test/java/com/alibaba/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: ConsumerOffsetManagerTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
- */
-package com.alibaba.rocketmq.broker.offset;
-
-import com.alibaba.rocketmq.broker.BrokerTestHarness;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-
-/**
- * @author zander
- */
-public class ConsumerOffsetManagerTest extends BrokerTestHarness{
-
- @Test
- public void testFlushConsumerOffset() throws Exception {
- ConsumerOffsetManager consumerOffsetManager = new ConsumerOffsetManager(brokerController);
- for (int i = 0; i < 10; i++) {
- String group = "UNIT_TEST_GROUP_" + i;
- for (int id = 0; id < 10; id++) {
- consumerOffsetManager.commitOffset(null, group, "TOPIC_A", id, id + 100);
- consumerOffsetManager.commitOffset(null, group, "TOPIC_B", id, id + 100);
- consumerOffsetManager.commitOffset(null, group, "TOPIC_C", id, id + 100);
- }
- }
- consumerOffsetManager.persist();
- consumerOffsetManager.getOffsetTable().clear();
- for (int i = 0; i < 10; i++) {
- String group = "UNIT_TEST_GROUP_" + i;
- for (int id = 0; id < 10; id++) {
- assertEquals(consumerOffsetManager.queryOffset(group, "TOPIC_A", id), -1);
- assertEquals(consumerOffsetManager.queryOffset(group, "TOPIC_B", id), -1);
- assertEquals(consumerOffsetManager.queryOffset(group, "TOPIC_B", id), -1);
- }
- }
- consumerOffsetManager.load();
- for (int i = 0; i < 10; i++) {
- String group = "UNIT_TEST_GROUP_" + i;
- for (int id = 0; id < 10; id++) {
- assertEquals(consumerOffsetManager.queryOffset(group, "TOPIC_A", id), id + 100);
- assertEquals(consumerOffsetManager.queryOffset(group, "TOPIC_B", id), id + 100);
- assertEquals(consumerOffsetManager.queryOffset(group, "TOPIC_B", id), id + 100);
- }
- }
- }
-}
[05/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/benchmark/Consumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/benchmark/Consumer.java b/example/src/main/java/com/alibaba/rocketmq/example/benchmark/Consumer.java
deleted file mode 100644
index 7150513..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/benchmark/Consumer.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/**
- * 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.example.benchmark;
-
-import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
-import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
-import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
-import com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.srvutil.ServerUtil;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.PosixParser;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.atomic.AtomicLong;
-
-public class Consumer {
-
- public static void main(String[] args) throws MQClientException {
- Options options = ServerUtil.buildCommandlineOptions(new Options());
- CommandLine commandLine = ServerUtil.parseCmdLine("benchmarkConsumer", args, buildCommandlineOptions(options), new PosixParser());
- if (null == commandLine) {
- System.exit(-1);
- }
-
- final String topic = commandLine.hasOption('t') ? commandLine.getOptionValue('t').trim() : "BenchmarkTest";
- final String groupPrefix = commandLine.hasOption('g') ? commandLine.getOptionValue('g').trim() : "benchmark_consumer";
- final String isPrefixEnable = commandLine.hasOption('p') ? commandLine.getOptionValue('p').trim() : "true";
- String group = groupPrefix;
- if (Boolean.parseBoolean(isPrefixEnable)) {
- group = groupPrefix + "_" + Long.toString(System.currentTimeMillis() % 100);
- }
-
- System.out.printf("topic %s group %s prefix %s%n", topic, group, isPrefixEnable);
-
- final StatsBenchmarkConsumer statsBenchmarkConsumer = new StatsBenchmarkConsumer();
-
- final Timer timer = new Timer("BenchmarkTimerThread", true);
-
- final LinkedList<Long[]> snapshotList = new LinkedList<Long[]>();
-
- timer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- snapshotList.addLast(statsBenchmarkConsumer.createSnapshot());
- if (snapshotList.size() > 10) {
- snapshotList.removeFirst();
- }
- }
- }, 1000, 1000);
-
- timer.scheduleAtFixedRate(new TimerTask() {
- private void printStats() {
- if (snapshotList.size() >= 10) {
- Long[] begin = snapshotList.getFirst();
- Long[] end = snapshotList.getLast();
-
- final long consumeTps =
- (long) (((end[1] - begin[1]) / (double) (end[0] - begin[0])) * 1000L);
- final double averageB2CRT = (end[2] - begin[2]) / (double) (end[1] - begin[1]);
- final double averageS2CRT = (end[3] - begin[3]) / (double) (end[1] - begin[1]);
-
- System.out.printf("Consume TPS: %d Average(B2C) RT: %7.3f Average(S2C) RT: %7.3f MAX(B2C) RT: %d MAX(S2C) RT: %d%n",
- consumeTps, averageB2CRT, averageS2CRT, end[4], end[5]
- );
- }
- }
-
-
- @Override
- public void run() {
- try {
- this.printStats();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }, 10000, 10000);
-
- DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(group);
- consumer.setInstanceName(Long.toString(System.currentTimeMillis()));
-
- consumer.subscribe(topic, "*");
-
- consumer.registerMessageListener(new MessageListenerConcurrently() {
- @Override
- public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
- ConsumeConcurrentlyContext context) {
- MessageExt msg = msgs.get(0);
- long now = System.currentTimeMillis();
-
- statsBenchmarkConsumer.getReceiveMessageTotalCount().incrementAndGet();
-
- long born2ConsumerRT = now - msg.getBornTimestamp();
- statsBenchmarkConsumer.getBorn2ConsumerTotalRT().addAndGet(born2ConsumerRT);
-
- long store2ConsumerRT = now - msg.getStoreTimestamp();
- statsBenchmarkConsumer.getStore2ConsumerTotalRT().addAndGet(store2ConsumerRT);
-
- compareAndSetMax(statsBenchmarkConsumer.getBorn2ConsumerMaxRT(), born2ConsumerRT);
-
- compareAndSetMax(statsBenchmarkConsumer.getStore2ConsumerMaxRT(), store2ConsumerRT);
-
- return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
- }
- });
-
- consumer.start();
-
- System.out.printf("Consumer Started.%n");
- }
-
- public static Options buildCommandlineOptions(final Options options) {
- Option opt = new Option("t", "topic", true, "Topic name, Default: BenchmarkTest");
- opt.setRequired(false);
- options.addOption(opt);
-
- opt = new Option("g", "group", true, "Consumer group name, Default: benchmark_consumer");
- opt.setRequired(false);
- options.addOption(opt);
-
-
- opt = new Option("p", "group prefix enable", true, "Consumer group name, Default: false");
- opt.setRequired(false);
- options.addOption(opt);
-
- return options;
- }
-
-
- public static void compareAndSetMax(final AtomicLong target, final long value) {
- long prev = target.get();
- while (value > prev) {
- boolean updated = target.compareAndSet(prev, value);
- if (updated)
- break;
-
- prev = target.get();
- }
- }
-}
-
-
-class StatsBenchmarkConsumer {
- private final AtomicLong receiveMessageTotalCount = new AtomicLong(0L);
-
- private final AtomicLong born2ConsumerTotalRT = new AtomicLong(0L);
-
- private final AtomicLong store2ConsumerTotalRT = new AtomicLong(0L);
-
- private final AtomicLong born2ConsumerMaxRT = new AtomicLong(0L);
-
- private final AtomicLong store2ConsumerMaxRT = new AtomicLong(0L);
-
-
- public Long[] createSnapshot() {
- Long[] snap = new Long[]{
- System.currentTimeMillis(),
- this.receiveMessageTotalCount.get(),
- this.born2ConsumerTotalRT.get(),
- this.store2ConsumerTotalRT.get(),
- this.born2ConsumerMaxRT.get(),
- this.store2ConsumerMaxRT.get(),
- };
-
- return snap;
- }
-
-
- public AtomicLong getReceiveMessageTotalCount() {
- return receiveMessageTotalCount;
- }
-
-
- public AtomicLong getBorn2ConsumerTotalRT() {
- return born2ConsumerTotalRT;
- }
-
-
- public AtomicLong getStore2ConsumerTotalRT() {
- return store2ConsumerTotalRT;
- }
-
-
- public AtomicLong getBorn2ConsumerMaxRT() {
- return born2ConsumerMaxRT;
- }
-
-
- public AtomicLong getStore2ConsumerMaxRT() {
- return store2ConsumerMaxRT;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/benchmark/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/benchmark/Producer.java b/example/src/main/java/com/alibaba/rocketmq/example/benchmark/Producer.java
deleted file mode 100644
index b0351c6..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/benchmark/Producer.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/**
- * 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.example.benchmark;
-
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import com.alibaba.rocketmq.remoting.exception.RemotingException;
-import com.alibaba.rocketmq.srvutil.ServerUtil;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.PosixParser;
-import org.slf4j.Logger;
-
-import java.io.UnsupportedEncodingException;
-import java.util.LinkedList;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.atomic.AtomicLong;
-
-public class Producer {
- public static void main(String[] args) throws MQClientException, UnsupportedEncodingException {
-
- Options options = ServerUtil.buildCommandlineOptions(new Options());
- CommandLine commandLine = ServerUtil.parseCmdLine("benchmarkProducer", args, buildCommandlineOptions(options), new PosixParser());
- if (null == commandLine) {
- System.exit(-1);
- }
-
- final String topic = commandLine.hasOption('t') ? commandLine.getOptionValue('t').trim() : "BenchmarkTest";
- final int threadCount = commandLine.hasOption('w') ? Integer.parseInt(commandLine.getOptionValue('w')) : 64;
- final int messageSize = commandLine.hasOption('s') ? Integer.parseInt(commandLine.getOptionValue('s')) : 128;
- final boolean keyEnable = commandLine.hasOption('k') ? Boolean.parseBoolean(commandLine.getOptionValue('k')) : false;
-
- System.out.printf("topic %s threadCount %d messageSize %d keyEnable %s%n", topic, threadCount, messageSize, keyEnable);
-
- final Logger log = ClientLogger.getLog();
-
- final Message msg = buildMessage(messageSize, topic);
-
- final ExecutorService sendThreadPool = Executors.newFixedThreadPool(threadCount);
-
- final StatsBenchmarkProducer statsBenchmark = new StatsBenchmarkProducer();
-
- final Timer timer = new Timer("BenchmarkTimerThread", true);
-
- final LinkedList<Long[]> snapshotList = new LinkedList<Long[]>();
-
- timer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- snapshotList.addLast(statsBenchmark.createSnapshot());
- if (snapshotList.size() > 10) {
- snapshotList.removeFirst();
- }
- }
- }, 1000, 1000);
-
- timer.scheduleAtFixedRate(new TimerTask() {
- private void printStats() {
- if (snapshotList.size() >= 10) {
- Long[] begin = snapshotList.getFirst();
- Long[] end = snapshotList.getLast();
-
- final long sendTps = (long) (((end[3] - begin[3]) / (double) (end[0] - begin[0])) * 1000L);
- final double averageRT = (end[5] - begin[5]) / (double) (end[3] - begin[3]);
-
- System.out.printf("Send TPS: %d Max RT: %d Average RT: %7.3f Send Failed: %d Response Failed: %d%n",
- sendTps, statsBenchmark.getSendMessageMaxRT().get(), averageRT, end[2], end[4]);
- }
- }
-
-
- @Override
- public void run() {
- try {
- this.printStats();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }, 10000, 10000);
-
- final DefaultMQProducer producer = new DefaultMQProducer("benchmark_producer");
- producer.setInstanceName(Long.toString(System.currentTimeMillis()));
-
- if (commandLine.hasOption('n')) {
- String ns = commandLine.getOptionValue('n');
- producer.setNamesrvAddr(ns);
- }
-
- producer.setCompressMsgBodyOverHowmuch(Integer.MAX_VALUE);
-
- producer.start();
-
- for (int i = 0; i < threadCount; i++) {
- sendThreadPool.execute(new Runnable() {
- @Override
- public void run() {
- while (true) {
- try {
- final long beginTimestamp = System.currentTimeMillis();
- if (keyEnable) {
- msg.setKeys(String.valueOf(beginTimestamp / 1000));
- }
- producer.send(msg);
- statsBenchmark.getSendRequestSuccessCount().incrementAndGet();
- statsBenchmark.getReceiveResponseSuccessCount().incrementAndGet();
- final long currentRT = System.currentTimeMillis() - beginTimestamp;
- statsBenchmark.getSendMessageSuccessTimeTotal().addAndGet(currentRT);
- long prevMaxRT = statsBenchmark.getSendMessageMaxRT().get();
- while (currentRT > prevMaxRT) {
- boolean updated = statsBenchmark.getSendMessageMaxRT().compareAndSet(prevMaxRT, currentRT);
- if (updated)
- break;
-
- prevMaxRT = statsBenchmark.getSendMessageMaxRT().get();
- }
- } catch (RemotingException e) {
- statsBenchmark.getSendRequestFailedCount().incrementAndGet();
- log.error("[BENCHMARK_PRODUCER] Send Exception", e);
-
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e1) {
- }
- } catch (InterruptedException e) {
- statsBenchmark.getSendRequestFailedCount().incrementAndGet();
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e1) {
- }
- } catch (MQClientException e) {
- statsBenchmark.getSendRequestFailedCount().incrementAndGet();
- log.error("[BENCHMARK_PRODUCER] Send Exception", e);
- } catch (MQBrokerException e) {
- statsBenchmark.getReceiveResponseFailedCount().incrementAndGet();
- log.error("[BENCHMARK_PRODUCER] Send Exception", e);
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e1) {
- }
- }
- }
- }
- });
- }
- }
-
- public static Options buildCommandlineOptions(final Options options) {
- Option opt = new Option("w", "threadCount", true, "Thread count, Default: 64");
- opt.setRequired(false);
- options.addOption(opt);
-
- opt = new Option("s", "messageSize", true, "Message Size, Default: 128");
- opt.setRequired(false);
- options.addOption(opt);
-
- opt = new Option("k", "keyEnable", true, "Message Key Enable, Default: false");
- opt.setRequired(false);
- options.addOption(opt);
-
- opt = new Option("t", "topic", true, "Topic name, Default: BenchmarkTest");
- opt.setRequired(false);
- options.addOption(opt);
-
- return options;
- }
-
- private static Message buildMessage(final int messageSize, final String topic) throws UnsupportedEncodingException {
- Message msg = new Message();
- msg.setTopic(topic);
-
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < messageSize; i += 10) {
- sb.append("hello baby");
- }
-
- msg.setBody(sb.toString().getBytes(RemotingHelper.DEFAULT_CHARSET));
-
- return msg;
- }
-}
-
-
-class StatsBenchmarkProducer {
- private final AtomicLong sendRequestSuccessCount = new AtomicLong(0L);
-
- private final AtomicLong sendRequestFailedCount = new AtomicLong(0L);
-
- private final AtomicLong receiveResponseSuccessCount = new AtomicLong(0L);
-
- private final AtomicLong receiveResponseFailedCount = new AtomicLong(0L);
-
- private final AtomicLong sendMessageSuccessTimeTotal = new AtomicLong(0L);
-
- private final AtomicLong sendMessageMaxRT = new AtomicLong(0L);
-
-
- public Long[] createSnapshot() {
- Long[] snap = new Long[]{
- System.currentTimeMillis(),
- this.sendRequestSuccessCount.get(),
- this.sendRequestFailedCount.get(),
- this.receiveResponseSuccessCount.get(),
- this.receiveResponseFailedCount.get(),
- this.sendMessageSuccessTimeTotal.get(),
- };
-
- return snap;
- }
-
-
- public AtomicLong getSendRequestSuccessCount() {
- return sendRequestSuccessCount;
- }
-
-
- public AtomicLong getSendRequestFailedCount() {
- return sendRequestFailedCount;
- }
-
-
- public AtomicLong getReceiveResponseSuccessCount() {
- return receiveResponseSuccessCount;
- }
-
-
- public AtomicLong getReceiveResponseFailedCount() {
- return receiveResponseFailedCount;
- }
-
-
- public AtomicLong getSendMessageSuccessTimeTotal() {
- return sendMessageSuccessTimeTotal;
- }
-
-
- public AtomicLong getSendMessageMaxRT() {
- return sendMessageMaxRT;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/benchmark/TransactionProducer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/benchmark/TransactionProducer.java b/example/src/main/java/com/alibaba/rocketmq/example/benchmark/TransactionProducer.java
deleted file mode 100644
index 3dffd2f..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/benchmark/TransactionProducer.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/**
- * 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.example.benchmark;
-
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.producer.*;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-
-import java.io.UnsupportedEncodingException;
-import java.util.LinkedList;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.atomic.AtomicLong;
-
-public class TransactionProducer {
- private static int threadCount;
- private static int messageSize;
- private static boolean ischeck;
- private static boolean ischeckffalse;
-
-
- public static void main(String[] args) throws MQClientException, UnsupportedEncodingException {
- threadCount = args.length >= 1 ? Integer.parseInt(args[0]) : 32;
- messageSize = args.length >= 2 ? Integer.parseInt(args[1]) : 1024 * 2;
- ischeck = args.length >= 3 ? Boolean.parseBoolean(args[2]) : false;
- ischeckffalse = args.length >= 4 ? Boolean.parseBoolean(args[3]) : false;
-
- final Message msg = buildMessage(messageSize);
-
- final ExecutorService sendThreadPool = Executors.newFixedThreadPool(threadCount);
-
- final StatsBenchmarkTProducer statsBenchmark = new StatsBenchmarkTProducer();
-
- final Timer timer = new Timer("BenchmarkTimerThread", true);
-
- final LinkedList<Long[]> snapshotList = new LinkedList<Long[]>();
-
- timer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- snapshotList.addLast(statsBenchmark.createSnapshot());
- while (snapshotList.size() > 10) {
- snapshotList.removeFirst();
- }
- }
- }, 1000, 1000);
-
- timer.scheduleAtFixedRate(new TimerTask() {
- private void printStats() {
- if (snapshotList.size() >= 10) {
- Long[] begin = snapshotList.getFirst();
- Long[] end = snapshotList.getLast();
-
- final long sendTps =
- (long) (((end[3] - begin[3]) / (double) (end[0] - begin[0])) * 1000L);
- final double averageRT = (end[5] - begin[5]) / (double) (end[3] - begin[3]);
-
- System.out.printf(
- "Send TPS: %d Max RT: %d Average RT: %7.3f Send Failed: %d Response Failed: %d transaction checkCount: %d %n",
- sendTps, statsBenchmark.getSendMessageMaxRT().get(), averageRT, end[2], end[4], end[6]);
- }
- }
-
-
- @Override
- public void run() {
- try {
- this.printStats();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }, 10000, 10000);
-
- final TransactionCheckListener transactionCheckListener =
- new TransactionCheckListenerBImpl(ischeckffalse, statsBenchmark);
- final TransactionMQProducer producer = new TransactionMQProducer("benchmark_transaction_producer");
- producer.setInstanceName(Long.toString(System.currentTimeMillis()));
- producer.setTransactionCheckListener(transactionCheckListener);
- producer.setDefaultTopicQueueNums(1000);
- producer.start();
-
- final TransactionExecuterBImpl tranExecuter = new TransactionExecuterBImpl(ischeck);
-
- for (int i = 0; i < threadCount; i++) {
- sendThreadPool.execute(new Runnable() {
- @Override
- public void run() {
- while (true) {
- try {
- // Thread.sleep(1000);
- final long beginTimestamp = System.currentTimeMillis();
- SendResult sendResult =
- producer.sendMessageInTransaction(msg, tranExecuter, null);
- if (sendResult != null) {
- statsBenchmark.getSendRequestSuccessCount().incrementAndGet();
- statsBenchmark.getReceiveResponseSuccessCount().incrementAndGet();
- }
-
- final long currentRT = System.currentTimeMillis() - beginTimestamp;
- statsBenchmark.getSendMessageSuccessTimeTotal().addAndGet(currentRT);
- long prevMaxRT = statsBenchmark.getSendMessageMaxRT().get();
- while (currentRT > prevMaxRT) {
- boolean updated =
- statsBenchmark.getSendMessageMaxRT().compareAndSet(prevMaxRT,
- currentRT);
- if (updated)
- break;
-
- prevMaxRT = statsBenchmark.getSendMessageMaxRT().get();
- }
- } catch (MQClientException e) {
- statsBenchmark.getSendRequestFailedCount().incrementAndGet();
- }
- }
- }
- });
- }
- }
-
-
- private static Message buildMessage(final int messageSize) throws UnsupportedEncodingException {
- Message msg = new Message();
- msg.setTopic("BenchmarkTest");
-
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < messageSize; i += 10) {
- sb.append("hello baby");
- }
-
- msg.setBody(sb.toString().getBytes(RemotingHelper.DEFAULT_CHARSET));
-
- return msg;
- }
-}
-
-
-class TransactionExecuterBImpl implements LocalTransactionExecuter {
-
- private boolean ischeck;
-
-
- public TransactionExecuterBImpl(boolean ischeck) {
- this.ischeck = ischeck;
- }
-
-
- @Override
- public LocalTransactionState executeLocalTransactionBranch(final Message msg, final Object arg) {
- if (ischeck) {
- return LocalTransactionState.UNKNOW;
- }
- return LocalTransactionState.COMMIT_MESSAGE;
- }
-}
-
-
-class TransactionCheckListenerBImpl implements TransactionCheckListener {
- private boolean ischeckffalse;
- private StatsBenchmarkTProducer statsBenchmarkTProducer;
-
-
- public TransactionCheckListenerBImpl(boolean ischeckffalse,
- StatsBenchmarkTProducer statsBenchmarkTProducer) {
- this.ischeckffalse = ischeckffalse;
- this.statsBenchmarkTProducer = statsBenchmarkTProducer;
- }
-
-
- @Override
- public LocalTransactionState checkLocalTransactionState(MessageExt msg) {
- statsBenchmarkTProducer.getCheckRequestSuccessCount().incrementAndGet();
- if (ischeckffalse) {
-
- return LocalTransactionState.ROLLBACK_MESSAGE;
- }
-
- return LocalTransactionState.COMMIT_MESSAGE;
- }
-}
-
-
-class StatsBenchmarkTProducer {
- private final AtomicLong sendRequestSuccessCount = new AtomicLong(0L);
-
- private final AtomicLong sendRequestFailedCount = new AtomicLong(0L);
-
- private final AtomicLong receiveResponseSuccessCount = new AtomicLong(0L);
-
- private final AtomicLong receiveResponseFailedCount = new AtomicLong(0L);
-
- private final AtomicLong sendMessageSuccessTimeTotal = new AtomicLong(0L);
-
- private final AtomicLong sendMessageMaxRT = new AtomicLong(0L);
-
- private final AtomicLong checkRequestSuccessCount = new AtomicLong(0L);
-
-
- public Long[] createSnapshot() {
- Long[] snap = new Long[]{
- System.currentTimeMillis(),
- this.sendRequestSuccessCount.get(),
- this.sendRequestFailedCount.get(),
- this.receiveResponseSuccessCount.get(),
- this.receiveResponseFailedCount.get(),
- this.sendMessageSuccessTimeTotal.get(),
- this.checkRequestSuccessCount.get()};
-
- return snap;
- }
-
-
- public AtomicLong getSendRequestSuccessCount() {
- return sendRequestSuccessCount;
- }
-
-
- public AtomicLong getSendRequestFailedCount() {
- return sendRequestFailedCount;
- }
-
-
- public AtomicLong getReceiveResponseSuccessCount() {
- return receiveResponseSuccessCount;
- }
-
-
- public AtomicLong getReceiveResponseFailedCount() {
- return receiveResponseFailedCount;
- }
-
-
- public AtomicLong getSendMessageSuccessTimeTotal() {
- return sendMessageSuccessTimeTotal;
- }
-
-
- public AtomicLong getSendMessageMaxRT() {
- return sendMessageMaxRT;
- }
-
-
- public AtomicLong getCheckRequestSuccessCount() {
- return checkRequestSuccessCount;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/broadcast/PushConsumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/broadcast/PushConsumer.java b/example/src/main/java/com/alibaba/rocketmq/example/broadcast/PushConsumer.java
deleted file mode 100644
index 6cc6238..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/broadcast/PushConsumer.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * 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.example.broadcast;
-
-import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
-import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
-import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
-import com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.common.consumer.ConsumeFromWhere;
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.protocol.heartbeat.MessageModel;
-
-import java.util.List;
-
-public class PushConsumer {
-
- public static void main(String[] args) throws InterruptedException, MQClientException {
- DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("please_rename_unique_group_name_1");
-
- consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
-
- consumer.setMessageModel(MessageModel.BROADCASTING);
-
- consumer.subscribe("TopicTest", "TagA || TagC || TagD");
-
- consumer.registerMessageListener(new MessageListenerConcurrently() {
-
- @Override
- public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
- ConsumeConcurrentlyContext context) {
- System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n");
- return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
- }
- });
-
- consumer.start();
- System.out.printf("Broadcast Consumer Started.%n");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/filter/Consumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/filter/Consumer.java b/example/src/main/java/com/alibaba/rocketmq/example/filter/Consumer.java
deleted file mode 100644
index 104e6d9..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/filter/Consumer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * 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.example.filter;
-
-import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
-import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
-import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
-import com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.message.MessageExt;
-
-import java.util.List;
-
-
-public class Consumer {
-
- public static void main(String[] args) throws InterruptedException, MQClientException {
- DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("ConsumerGroupNamecc4");
-
- String filterCode = MixAll.file2String("/home/admin/MessageFilterImpl.java");
- consumer.subscribe("TopicFilter7", "com.alibaba.rocketmq.example.filter.MessageFilterImpl",
- filterCode);
-
- consumer.registerMessageListener(new MessageListenerConcurrently() {
-
- @Override
- public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
- ConsumeConcurrentlyContext context) {
- System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n");
- return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
- }
- });
-
- consumer.start();
-
- System.out.printf("Consumer Started.%n");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/filter/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/filter/Producer.java b/example/src/main/java/com/alibaba/rocketmq/example/filter/Producer.java
deleted file mode 100644
index 04251fa..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/filter/Producer.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * 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.example.filter;
-
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
-import com.alibaba.rocketmq.client.producer.SendResult;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-
-public class Producer {
- public static void main(String[] args) throws MQClientException, InterruptedException {
- DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName");
- producer.start();
-
- try {
- for (int i = 0; i < 6000000; i++) {
- Message msg = new Message("TopicFilter7",
- "TagA",
- "OrderID001",
- "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
-
- msg.putUserProperty("SequenceId", String.valueOf(i));
- SendResult sendResult = producer.send(msg);
- System.out.printf("%s%n", sendResult);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- producer.shutdown();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/operation/Consumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/operation/Consumer.java b/example/src/main/java/com/alibaba/rocketmq/example/operation/Consumer.java
deleted file mode 100644
index f6ba067..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/operation/Consumer.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * 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.example.operation;
-
-import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
-import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
-import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
-import com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.common.message.MessageExt;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.cli.PosixParser;
-
-import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
-
-
-public class Consumer {
-
- public static void main(String[] args) throws InterruptedException, MQClientException {
- CommandLine commandLine = buildCommandline(args);
- if (commandLine != null) {
- String group = commandLine.getOptionValue('g');
- String topic = commandLine.getOptionValue('t');
- String subscription = commandLine.getOptionValue('s');
- final String returnFailedHalf = commandLine.getOptionValue('f');
-
- DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(group);
- consumer.setInstanceName(Long.toString(System.currentTimeMillis()));
-
- consumer.subscribe(topic, subscription);
-
- consumer.registerMessageListener(new MessageListenerConcurrently() {
- AtomicLong consumeTimes = new AtomicLong(0);
-
-
- @Override
- public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
- ConsumeConcurrentlyContext context) {
- long currentTimes = this.consumeTimes.incrementAndGet();
- System.out.printf("%-8d %s%n", currentTimes, msgs);
- if (Boolean.parseBoolean(returnFailedHalf)) {
- if ((currentTimes % 2) == 0) {
- return ConsumeConcurrentlyStatus.RECONSUME_LATER;
- }
- }
- return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
- }
- });
-
- consumer.start();
-
- System.out.printf("Consumer Started.%n");
- }
- }
-
- public static CommandLine buildCommandline(String[] args) {
- final Options options = new Options();
- Option opt = new Option("h", "help", false, "Print help");
- opt.setRequired(false);
- options.addOption(opt);
-
- opt = new Option("g", "consumerGroup", true, "Consumer Group Name");
- opt.setRequired(true);
- options.addOption(opt);
-
- opt = new Option("t", "topic", true, "Topic Name");
- opt.setRequired(true);
- options.addOption(opt);
-
- opt = new Option("s", "subscription", true, "subscription");
- opt.setRequired(false);
- options.addOption(opt);
-
- opt = new Option("f", "returnFailedHalf", true, "return failed result, for half message");
- opt.setRequired(true);
- options.addOption(opt);
-
- PosixParser parser = new PosixParser();
- HelpFormatter hf = new HelpFormatter();
- hf.setWidth(110);
- CommandLine commandLine = null;
- try {
- commandLine = parser.parse(options, args);
- if (commandLine.hasOption('h')) {
- hf.printHelp("producer", options, true);
- return null;
- }
- } catch (ParseException e) {
- hf.printHelp("producer", options, true);
- return null;
- }
-
- return commandLine;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/operation/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/operation/Producer.java b/example/src/main/java/com/alibaba/rocketmq/example/operation/Producer.java
deleted file mode 100644
index 816e3e8..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/operation/Producer.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * 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.example.operation;
-
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
-import com.alibaba.rocketmq.client.producer.SendResult;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import org.apache.commons.cli.*;
-
-public class Producer {
-
- public static void main(String[] args) throws MQClientException, InterruptedException {
- CommandLine commandLine = buildCommandline(args);
- if (commandLine != null) {
- String group = commandLine.getOptionValue('g');
- String topic = commandLine.getOptionValue('t');
- String tags = commandLine.getOptionValue('a');
- String keys = commandLine.getOptionValue('k');
- String msgCount = commandLine.getOptionValue('c');
-
- DefaultMQProducer producer = new DefaultMQProducer(group);
- producer.setInstanceName(Long.toString(System.currentTimeMillis()));
-
- producer.start();
-
- for (int i = 0; i < Integer.parseInt(msgCount); i++) {
- try {
- Message msg = new Message(
- topic,
- tags,
- keys,
- ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET));
- SendResult sendResult = producer.send(msg);
- System.out.printf("%-8d %s%n", i, sendResult);
- } catch (Exception e) {
- e.printStackTrace();
- Thread.sleep(1000);
- }
- }
-
- producer.shutdown();
- }
- }
-
- public static CommandLine buildCommandline(String[] args) {
- final Options options = new Options();
- Option opt = new Option("h", "help", false, "Print help");
- opt.setRequired(false);
- options.addOption(opt);
-
- opt = new Option("g", "producerGroup", true, "Producer Group Name");
- opt.setRequired(true);
- options.addOption(opt);
-
- opt = new Option("t", "topic", true, "Topic Name");
- opt.setRequired(true);
- options.addOption(opt);
-
- opt = new Option("a", "tags", true, "Tags Name");
- opt.setRequired(true);
- options.addOption(opt);
-
- opt = new Option("k", "keys", true, "Keys Name");
- opt.setRequired(true);
- options.addOption(opt);
-
- opt = new Option("c", "msgCount", true, "Message Count");
- opt.setRequired(true);
- options.addOption(opt);
-
- PosixParser parser = new PosixParser();
- HelpFormatter hf = new HelpFormatter();
- hf.setWidth(110);
- CommandLine commandLine = null;
- try {
- commandLine = parser.parse(options, args);
- if (commandLine.hasOption('h')) {
- hf.printHelp("producer", options, true);
- return null;
- }
- } catch (ParseException e) {
- hf.printHelp("producer", options, true);
- return null;
- }
-
- return commandLine;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/ordermessage/Consumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/ordermessage/Consumer.java b/example/src/main/java/com/alibaba/rocketmq/example/ordermessage/Consumer.java
deleted file mode 100644
index 7b5f657..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/ordermessage/Consumer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * 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.example.ordermessage;
-
-import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
-import com.alibaba.rocketmq.client.consumer.listener.ConsumeOrderlyContext;
-import com.alibaba.rocketmq.client.consumer.listener.ConsumeOrderlyStatus;
-import com.alibaba.rocketmq.client.consumer.listener.MessageListenerOrderly;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.common.consumer.ConsumeFromWhere;
-import com.alibaba.rocketmq.common.message.MessageExt;
-
-import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
-
-
-public class Consumer {
-
- public static void main(String[] args) throws MQClientException {
- DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("please_rename_unique_group_name_3");
-
- consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
-
- consumer.subscribe("TopicTest", "TagA || TagC || TagD");
-
- consumer.registerMessageListener(new MessageListenerOrderly() {
- AtomicLong consumeTimes = new AtomicLong(0);
-
- @Override
- public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, ConsumeOrderlyContext context) {
- context.setAutoCommit(false);
- System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n");
- this.consumeTimes.incrementAndGet();
- if ((this.consumeTimes.get() % 2) == 0) {
- return ConsumeOrderlyStatus.SUCCESS;
- } else if ((this.consumeTimes.get() % 3) == 0) {
- return ConsumeOrderlyStatus.ROLLBACK;
- } else if ((this.consumeTimes.get() % 4) == 0) {
- return ConsumeOrderlyStatus.COMMIT;
- } else if ((this.consumeTimes.get() % 5) == 0) {
- context.setSuspendCurrentQueueTimeMillis(3000);
- return ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT;
- }
-
- return ConsumeOrderlyStatus.SUCCESS;
- }
- });
-
- consumer.start();
- System.out.printf("Consumer Started.%n");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/ordermessage/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/ordermessage/Producer.java b/example/src/main/java/com/alibaba/rocketmq/example/ordermessage/Producer.java
deleted file mode 100644
index 609aa62..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/ordermessage/Producer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * 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.example.ordermessage;
-
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
-import com.alibaba.rocketmq.client.producer.MQProducer;
-import com.alibaba.rocketmq.client.producer.MessageQueueSelector;
-import com.alibaba.rocketmq.client.producer.SendResult;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import com.alibaba.rocketmq.remoting.exception.RemotingException;
-
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-
-public class Producer {
- public static void main(String[] args) throws UnsupportedEncodingException {
- try {
- MQProducer producer = new DefaultMQProducer("please_rename_unique_group_name");
- producer.start();
-
- String[] tags = new String[]{"TagA", "TagB", "TagC", "TagD", "TagE"};
- for (int i = 0; i < 100; i++) {
- int orderId = i % 10;
- Message msg =
- new Message("TopicTestjjj", tags[i % tags.length], "KEY" + i,
- ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET));
- SendResult sendResult = producer.send(msg, new MessageQueueSelector() {
- @Override
- public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
- Integer id = (Integer) arg;
- int index = id % mqs.size();
- return mqs.get(index);
- }
- }, orderId);
-
- System.out.printf("%s%n", sendResult);
- }
-
- producer.shutdown();
- } catch (MQClientException e) {
- e.printStackTrace();
- } catch (RemotingException e) {
- e.printStackTrace();
- } catch (MQBrokerException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/quickstart/Consumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/quickstart/Consumer.java b/example/src/main/java/com/alibaba/rocketmq/example/quickstart/Consumer.java
deleted file mode 100644
index adac497..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/quickstart/Consumer.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * 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.example.quickstart;
-
-import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
-import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
-import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
-import com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.common.consumer.ConsumeFromWhere;
-import com.alibaba.rocketmq.common.message.MessageExt;
-
-import java.util.List;
-
-public class Consumer {
-
- public static void main(String[] args) throws InterruptedException, MQClientException {
- DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("please_rename_unique_group_name_4");
-
- consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
-
- consumer.subscribe("TopicTest", "*");
-
- consumer.registerMessageListener(new MessageListenerConcurrently() {
-
- @Override
- public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
- ConsumeConcurrentlyContext context) {
- System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n");
- return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
- }
- });
-
- consumer.start();
- System.out.printf("Consumer Started.%n");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/quickstart/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/quickstart/Producer.java b/example/src/main/java/com/alibaba/rocketmq/example/quickstart/Producer.java
deleted file mode 100644
index fb5dbea..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/quickstart/Producer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * 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.example.quickstart;
-
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
-import com.alibaba.rocketmq.client.producer.LocalTransactionExecuter;
-import com.alibaba.rocketmq.client.producer.LocalTransactionState;
-import com.alibaba.rocketmq.client.producer.SendResult;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-
-public class Producer {
- public static void main(String[] args) throws MQClientException, InterruptedException {
- DefaultMQProducer producer = new DefaultMQProducer("please_rename_unique_group_name");
- producer.start();
-
- for (int i = 0; i < 1000; i++) {
- try {
- Message msg = new Message("TopicTest",
- "TagA",
- ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET)
- );
- SendResult sendResult = producer.send(msg);
- LocalTransactionExecuter tranExecuter = new LocalTransactionExecuter() {
- @Override
- public LocalTransactionState executeLocalTransactionBranch(Message msg, Object arg) {
- return null;
- }
- };
- System.out.printf("%s%n", sendResult);
- } catch (Exception e) {
- e.printStackTrace();
- Thread.sleep(1000);
- }
- }
- producer.shutdown();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/simple/AsyncProducer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/simple/AsyncProducer.java b/example/src/main/java/com/alibaba/rocketmq/example/simple/AsyncProducer.java
deleted file mode 100644
index 1a8f07e..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/simple/AsyncProducer.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.example.simple;
-
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
-import com.alibaba.rocketmq.client.producer.SendCallback;
-import com.alibaba.rocketmq.client.producer.SendResult;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-
-import java.io.UnsupportedEncodingException;
-
-
-public class AsyncProducer {
- public static void main(String[] args) throws MQClientException, InterruptedException, UnsupportedEncodingException {
-
- DefaultMQProducer producer = new DefaultMQProducer("Jodie_Daily_test");
- producer.start();
- producer.setRetryTimesWhenSendAsyncFailed(0);
-
- for (int i = 0; i < 10000000; i++) {
- try {
- final int index = i;
- Message msg = new Message("Jodie_topic_1023",
- "TagA",
- "OrderID188",
- "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
- producer.send(msg, new SendCallback() {
- @Override
- public void onSuccess(SendResult sendResult) {
- System.out.printf("%-10d OK %s %n", index, sendResult.getMsgId());
- }
-
- @Override
- public void onException(Throwable e) {
- System.out.printf("%-10d Exception %s %n", index, e);
- e.printStackTrace();
- }
- });
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- producer.shutdown();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/simple/CachedQueue.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/simple/CachedQueue.java b/example/src/main/java/com/alibaba/rocketmq/example/simple/CachedQueue.java
deleted file mode 100644
index 7beb064..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/simple/CachedQueue.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * 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.example.simple;
-
-import com.alibaba.rocketmq.common.message.MessageExt;
-
-import java.util.TreeMap;
-
-
-public class CachedQueue {
- private final TreeMap<Long, MessageExt> msgCachedTable = new TreeMap<Long, MessageExt>();
-
-
- public TreeMap<Long, MessageExt> getMsgCachedTable() {
- return msgCachedTable;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/simple/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/simple/Producer.java b/example/src/main/java/com/alibaba/rocketmq/example/simple/Producer.java
deleted file mode 100644
index e0010d4..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/simple/Producer.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * 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.example.simple;
-
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
-import com.alibaba.rocketmq.client.producer.SendResult;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-
-
-public class Producer {
- public static void main(String[] args) throws MQClientException, InterruptedException {
-
- DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName");
-
- producer.start();
-
- for (int i = 0; i < 10000000; i++)
- try {
- {
- Message msg = new Message("TopicTest",
- "TagA",
- "OrderID188",
- "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
- SendResult sendResult = producer.send(msg);
- System.out.printf("%s%n", sendResult);
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- producer.shutdown();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/simple/PullConsumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/simple/PullConsumer.java b/example/src/main/java/com/alibaba/rocketmq/example/simple/PullConsumer.java
deleted file mode 100644
index 6245769..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/simple/PullConsumer.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * 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.example.simple;
-
-import com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer;
-import com.alibaba.rocketmq.client.consumer.PullResult;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-public class PullConsumer {
- private static final Map<MessageQueue, Long> OFFSE_TABLE = new HashMap<MessageQueue, Long>();
-
-
- public static void main(String[] args) throws MQClientException {
- DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("please_rename_unique_group_name_5");
-
- consumer.start();
-
- Set<MessageQueue> mqs = consumer.fetchSubscribeMessageQueues("TopicTest1");
- for (MessageQueue mq : mqs) {
- System.out.printf("Consume from the queue: " + mq + "%n");
- SINGLE_MQ:
- while (true) {
- try {
- PullResult pullResult =
- consumer.pullBlockIfNotFound(mq, null, getMessageQueueOffset(mq), 32);
- System.out.printf("%s%n", pullResult);
- putMessageQueueOffset(mq, pullResult.getNextBeginOffset());
- switch (pullResult.getPullStatus()) {
- case FOUND:
- break;
- case NO_MATCHED_MSG:
- break;
- case NO_NEW_MSG:
- break SINGLE_MQ;
- case OFFSET_ILLEGAL:
- break;
- default:
- break;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- consumer.shutdown();
- }
-
- private static long getMessageQueueOffset(MessageQueue mq) {
- Long offset = OFFSE_TABLE.get(mq);
- if (offset != null)
- return offset;
-
- return 0;
- }
-
- private static void putMessageQueueOffset(MessageQueue mq, long offset) {
- OFFSE_TABLE.put(mq, offset);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/simple/PullConsumerTest.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/simple/PullConsumerTest.java b/example/src/main/java/com/alibaba/rocketmq/example/simple/PullConsumerTest.java
deleted file mode 100644
index 25d668c..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/simple/PullConsumerTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * 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.example.simple;
-
-import com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer;
-import com.alibaba.rocketmq.client.consumer.PullResult;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-public class PullConsumerTest {
- public static void main(String[] args) throws MQClientException {
- DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("please_rename_unique_group_name_5");
- consumer.start();
-
- try {
- MessageQueue mq = new MessageQueue();
- mq.setQueueId(0);
- mq.setTopic("TopicTest3");
- mq.setBrokerName("vivedeMacBook-Pro.local");
-
- long offset = 26;
-
- long beginTime = System.currentTimeMillis();
- PullResult pullResult = consumer.pullBlockIfNotFound(mq, null, offset, 32);
- System.out.printf("%s%n", System.currentTimeMillis() - beginTime);
- System.out.printf("%s%n", pullResult);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- consumer.shutdown();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/simple/PullScheduleService.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/simple/PullScheduleService.java b/example/src/main/java/com/alibaba/rocketmq/example/simple/PullScheduleService.java
deleted file mode 100644
index 0c86cf8..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/simple/PullScheduleService.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * 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.example.simple;
-
-import com.alibaba.rocketmq.client.consumer.MQPullConsumer;
-import com.alibaba.rocketmq.client.consumer.MQPullConsumerScheduleService;
-import com.alibaba.rocketmq.client.consumer.PullResult;
-import com.alibaba.rocketmq.client.consumer.PullTaskCallback;
-import com.alibaba.rocketmq.client.consumer.PullTaskContext;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.heartbeat.MessageModel;
-
-
-public class PullScheduleService {
-
- public static void main(String[] args) throws MQClientException {
- final MQPullConsumerScheduleService scheduleService = new MQPullConsumerScheduleService("GroupName1");
-
- scheduleService.setMessageModel(MessageModel.CLUSTERING);
- scheduleService.registerPullTaskCallback("TopicTest1", new PullTaskCallback() {
-
- @Override
- public void doPullTask(MessageQueue mq, PullTaskContext context) {
- MQPullConsumer consumer = context.getPullConsumer();
- try {
-
- long offset = consumer.fetchConsumeOffset(mq, false);
- if (offset < 0)
- offset = 0;
-
- PullResult pullResult = consumer.pull(mq, "*", offset, 32);
- System.out.printf("%s%n", offset + "\t" + mq + "\t" + pullResult);
- switch (pullResult.getPullStatus()) {
- case FOUND:
- break;
- case NO_MATCHED_MSG:
- break;
- case NO_NEW_MSG:
- case OFFSET_ILLEGAL:
- break;
- default:
- break;
- }
- consumer.updateConsumeOffset(mq, pullResult.getNextBeginOffset());
-
-
- context.setPullNextDelayTimeMillis(100);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
-
- scheduleService.start();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/simple/PushConsumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/simple/PushConsumer.java b/example/src/main/java/com/alibaba/rocketmq/example/simple/PushConsumer.java
deleted file mode 100644
index 5628ced..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/simple/PushConsumer.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * 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.example.simple;
-
-import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
-import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
-import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
-import com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.common.consumer.ConsumeFromWhere;
-import com.alibaba.rocketmq.common.message.MessageExt;
-
-import java.util.List;
-
-
-public class PushConsumer {
-
- public static void main(String[] args) throws InterruptedException, MQClientException {
- DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("CID_JODIE_1");
- consumer.subscribe("Jodie_topic_1023", "*");
- consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
- consumer.registerMessageListener(new MessageListenerConcurrently() {
-
- /**
-
- */
- @Override
- public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
- System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n");
- return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
- }
- });
- consumer.start();
- System.out.printf("Consumer Started.%n");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/simple/RandomAsyncCommit.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/simple/RandomAsyncCommit.java b/example/src/main/java/com/alibaba/rocketmq/example/simple/RandomAsyncCommit.java
deleted file mode 100644
index fc6bacd..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/simple/RandomAsyncCommit.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * 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.example.simple;
-
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-
-
-public class RandomAsyncCommit {
- private final ConcurrentHashMap<MessageQueue, CachedQueue> mqCachedTable =
- new ConcurrentHashMap<MessageQueue, CachedQueue>();
-
-
- public void putMessages(final MessageQueue mq, final List<MessageExt> msgs) {
- CachedQueue cachedQueue = this.mqCachedTable.get(mq);
- if (null == cachedQueue) {
- cachedQueue = new CachedQueue();
- this.mqCachedTable.put(mq, cachedQueue);
- }
- for (MessageExt msg : msgs) {
- cachedQueue.getMsgCachedTable().put(msg.getQueueOffset(), msg);
- }
- }
-
-
- public void removeMessage(final MessageQueue mq, long offset) {
- CachedQueue cachedQueue = this.mqCachedTable.get(mq);
- if (null != cachedQueue) {
- cachedQueue.getMsgCachedTable().remove(offset);
- }
- }
-
-
- public long commitableOffset(final MessageQueue mq) {
- CachedQueue cachedQueue = this.mqCachedTable.get(mq);
- if (null != cachedQueue) {
- return cachedQueue.getMsgCachedTable().firstKey();
- }
-
- return -1;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/simple/TestProducer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/simple/TestProducer.java b/example/src/main/java/com/alibaba/rocketmq/example/simple/TestProducer.java
deleted file mode 100644
index 68347a6..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/simple/TestProducer.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * 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.example.simple;
-
-import com.alibaba.rocketmq.client.QueryResult;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
-import com.alibaba.rocketmq.client.producer.SendResult;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-
-public class TestProducer {
- public static void main(String[] args) throws MQClientException, InterruptedException {
- DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName");
- producer.start();
-
- for (int i = 0; i < 1; i++)
- try {
- {
- Message msg = new Message("TopicTest1",
- "TagA",
- "key113",
- "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
- SendResult sendResult = producer.send(msg);
- System.out.printf("%s%n", sendResult);
-
- QueryResult queryMessage =
- producer.queryMessage("TopicTest1", "key113", 10, 0, System.currentTimeMillis());
- for (MessageExt m : queryMessage.getMessageList()) {
- System.out.printf("%s%n", m);
- }
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- producer.shutdown();
- }
-}
[87/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
index 84ee7db..2dd9200 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
@@ -16,6 +16,17 @@
*/
package org.apache.rocketmq.client.impl;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
import org.apache.rocketmq.client.ClientConfig;
import org.apache.rocketmq.client.consumer.PullCallback;
import org.apache.rocketmq.client.consumer.PullResult;
@@ -37,21 +48,97 @@ import org.apache.rocketmq.common.TopicConfig;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.admin.ConsumeStats;
import org.apache.rocketmq.common.admin.TopicStatsTable;
-import org.apache.rocketmq.common.message.*;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageClientIDSetter;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageDecoder;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.namesrv.TopAddressing;
import org.apache.rocketmq.common.protocol.RequestCode;
import org.apache.rocketmq.common.protocol.ResponseCode;
-import org.apache.rocketmq.common.protocol.body.*;
-import org.apache.rocketmq.common.protocol.header.*;
+import org.apache.rocketmq.common.protocol.body.BrokerStatsData;
+import org.apache.rocketmq.common.protocol.body.ClusterInfo;
+import org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
+import org.apache.rocketmq.common.protocol.body.ConsumeStatsList;
+import org.apache.rocketmq.common.protocol.body.ConsumerConnection;
+import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
+import org.apache.rocketmq.common.protocol.body.GetConsumerStatusBody;
+import org.apache.rocketmq.common.protocol.body.GroupList;
+import org.apache.rocketmq.common.protocol.body.KVTable;
+import org.apache.rocketmq.common.protocol.body.LockBatchRequestBody;
+import org.apache.rocketmq.common.protocol.body.LockBatchResponseBody;
+import org.apache.rocketmq.common.protocol.body.ProducerConnection;
+import org.apache.rocketmq.common.protocol.body.QueryConsumeTimeSpanBody;
+import org.apache.rocketmq.common.protocol.body.QueryCorrectionOffsetBody;
+import org.apache.rocketmq.common.protocol.body.QueueTimeSpan;
+import org.apache.rocketmq.common.protocol.body.ResetOffsetBody;
+import org.apache.rocketmq.common.protocol.body.SubscriptionGroupWrapper;
+import org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper;
+import org.apache.rocketmq.common.protocol.body.TopicList;
+import org.apache.rocketmq.common.protocol.body.UnlockBatchRequestBody;
+import org.apache.rocketmq.common.protocol.header.CloneGroupOffsetRequestHeader;
+import org.apache.rocketmq.common.protocol.header.ConsumeMessageDirectlyResultRequestHeader;
+import org.apache.rocketmq.common.protocol.header.ConsumerSendMsgBackRequestHeader;
+import org.apache.rocketmq.common.protocol.header.CreateTopicRequestHeader;
+import org.apache.rocketmq.common.protocol.header.DeleteSubscriptionGroupRequestHeader;
+import org.apache.rocketmq.common.protocol.header.DeleteTopicRequestHeader;
+import org.apache.rocketmq.common.protocol.header.EndTransactionRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetConsumeStatsInBrokerHeader;
+import org.apache.rocketmq.common.protocol.header.GetConsumeStatsRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetConsumerConnectionListRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetConsumerListByGroupRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetConsumerListByGroupResponseBody;
+import org.apache.rocketmq.common.protocol.header.GetConsumerRunningInfoRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetConsumerStatusRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetEarliestMsgStoretimeRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetEarliestMsgStoretimeResponseHeader;
+import org.apache.rocketmq.common.protocol.header.GetMaxOffsetRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetMaxOffsetResponseHeader;
+import org.apache.rocketmq.common.protocol.header.GetMinOffsetRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetMinOffsetResponseHeader;
+import org.apache.rocketmq.common.protocol.header.GetProducerConnectionListRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetTopicStatsInfoRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetTopicsByClusterRequestHeader;
+import org.apache.rocketmq.common.protocol.header.PullMessageRequestHeader;
+import org.apache.rocketmq.common.protocol.header.PullMessageResponseHeader;
+import org.apache.rocketmq.common.protocol.header.QueryConsumeTimeSpanRequestHeader;
+import org.apache.rocketmq.common.protocol.header.QueryConsumerOffsetRequestHeader;
+import org.apache.rocketmq.common.protocol.header.QueryConsumerOffsetResponseHeader;
+import org.apache.rocketmq.common.protocol.header.QueryCorrectionOffsetHeader;
+import org.apache.rocketmq.common.protocol.header.QueryMessageRequestHeader;
+import org.apache.rocketmq.common.protocol.header.QueryTopicConsumeByWhoRequestHeader;
+import org.apache.rocketmq.common.protocol.header.ResetOffsetRequestHeader;
+import org.apache.rocketmq.common.protocol.header.SearchOffsetRequestHeader;
+import org.apache.rocketmq.common.protocol.header.SearchOffsetResponseHeader;
+import org.apache.rocketmq.common.protocol.header.SendMessageRequestHeader;
+import org.apache.rocketmq.common.protocol.header.SendMessageRequestHeaderV2;
+import org.apache.rocketmq.common.protocol.header.SendMessageResponseHeader;
+import org.apache.rocketmq.common.protocol.header.UnregisterClientRequestHeader;
+import org.apache.rocketmq.common.protocol.header.UpdateConsumerOffsetRequestHeader;
+import org.apache.rocketmq.common.protocol.header.ViewBrokerStatsDataRequestHeader;
+import org.apache.rocketmq.common.protocol.header.ViewMessageRequestHeader;
import org.apache.rocketmq.common.protocol.header.filtersrv.RegisterMessageFilterClassRequestHeader;
-import org.apache.rocketmq.common.protocol.header.namesrv.*;
+import org.apache.rocketmq.common.protocol.header.namesrv.DeleteKVConfigRequestHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigRequestHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigResponseHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.GetKVListByNamespaceRequestHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.GetRouteInfoRequestHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.PutKVConfigRequestHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.WipeWritePermOfBrokerRequestHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.WipeWritePermOfBrokerResponseHeader;
import org.apache.rocketmq.common.protocol.heartbeat.HeartbeatData;
import org.apache.rocketmq.common.protocol.route.TopicRouteData;
import org.apache.rocketmq.common.subscription.SubscriptionGroupConfig;
import org.apache.rocketmq.remoting.InvokeCallback;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.remoting.RemotingClient;
-import org.apache.rocketmq.remoting.exception.*;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.exception.RemotingConnectException;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
+import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
+import org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException;
import org.apache.rocketmq.remoting.netty.NettyClientConfig;
import org.apache.rocketmq.remoting.netty.NettyRemotingClient;
import org.apache.rocketmq.remoting.netty.ResponseFuture;
@@ -60,17 +147,11 @@ import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
import org.slf4j.Logger;
-import java.io.UnsupportedEncodingException;
-import java.nio.ByteBuffer;
-import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
-
-
public class MQClientAPIImpl {
private final static Logger log = ClientLogger.getLog();
public static boolean sendSmartMsg =
- Boolean.parseBoolean(System.getProperty("org.apache.rocketmq.client.sendSmartMsg", "true"));
+ Boolean.parseBoolean(System.getProperty("org.apache.rocketmq.client.sendSmartMsg", "true"));
static {
System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));
@@ -83,7 +164,7 @@ public class MQClientAPIImpl {
private ClientConfig clientConfig;
public MQClientAPIImpl(final NettyClientConfig nettyClientConfig, final ClientRemotingProcessor clientRemotingProcessor,
- RPCHook rpcHook, final ClientConfig clientConfig) {
+ RPCHook rpcHook, final ClientConfig clientConfig) {
this.clientConfig = clientConfig;
topAddressing = new TopAddressing(MixAll.WS_ADDR, clientConfig.getUnitName());
this.remotingClient = new NettyRemotingClient(nettyClientConfig, null);
@@ -149,14 +230,14 @@ public class MQClientAPIImpl {
}
public void createSubscriptionGroup(final String addr, final SubscriptionGroupConfig config, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_SUBSCRIPTIONGROUP, null);
byte[] body = RemotingSerializable.encode(config);
request.setBody(body);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
@@ -171,7 +252,7 @@ public class MQClientAPIImpl {
}
public void createTopic(final String addr, final String defaultTopic, final TopicConfig topicConfig, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
CreateTopicRequestHeader requestHeader = new CreateTopicRequestHeader();
requestHeader.setTopic(topicConfig.getTopicName());
requestHeader.setDefaultTopic(defaultTopic);
@@ -185,7 +266,7 @@ public class MQClientAPIImpl {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_TOPIC, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
@@ -199,31 +280,31 @@ public class MQClientAPIImpl {
}
public SendResult sendMessage(//
- final String addr, // 1
- final String brokerName, // 2
- final Message msg, // 3
- final SendMessageRequestHeader requestHeader, // 4
- final long timeoutMillis, // 5
- final CommunicationMode communicationMode, // 6
- final SendMessageContext context, // 7
- final DefaultMQProducerImpl producer // 8
+ final String addr, // 1
+ final String brokerName, // 2
+ final Message msg, // 3
+ final SendMessageRequestHeader requestHeader, // 4
+ final long timeoutMillis, // 5
+ final CommunicationMode communicationMode, // 6
+ final SendMessageContext context, // 7
+ final DefaultMQProducerImpl producer // 8
) throws RemotingException, MQBrokerException, InterruptedException {
return sendMessage(addr, brokerName, msg, requestHeader, timeoutMillis, communicationMode, null, null, null, 0, context, producer);
}
public SendResult sendMessage(//
- final String addr, // 1
- final String brokerName, // 2
- final Message msg, // 3
- final SendMessageRequestHeader requestHeader, // 4
- final long timeoutMillis, // 5
- final CommunicationMode communicationMode, // 6
- final SendCallback sendCallback, // 7
- final TopicPublishInfo topicPublishInfo, // 8
- final MQClientInstance instance, // 9
- final int retryTimesWhenSendFailed, // 10
- final SendMessageContext context, // 11
- final DefaultMQProducerImpl producer // 12
+ final String addr, // 1
+ final String brokerName, // 2
+ final Message msg, // 3
+ final SendMessageRequestHeader requestHeader, // 4
+ final long timeoutMillis, // 5
+ final CommunicationMode communicationMode, // 6
+ final SendCallback sendCallback, // 7
+ final TopicPublishInfo topicPublishInfo, // 8
+ final MQClientInstance instance, // 9
+ final int retryTimesWhenSendFailed, // 10
+ final SendMessageContext context, // 11
+ final DefaultMQProducerImpl producer // 12
) throws RemotingException, MQBrokerException, InterruptedException {
RemotingCommand request = null;
if (sendSmartMsg) {
@@ -242,7 +323,7 @@ public class MQClientAPIImpl {
case ASYNC:
final AtomicInteger times = new AtomicInteger();
this.sendMessageAsync(addr, brokerName, msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance,
- retryTimesWhenSendFailed, times, context, producer);
+ retryTimesWhenSendFailed, times, context, producer);
return null;
case SYNC:
return this.sendMessageSync(addr, brokerName, msg, timeoutMillis, request);
@@ -255,11 +336,11 @@ public class MQClientAPIImpl {
}
private SendResult sendMessageSync(//
- final String addr, //
- final String brokerName, //
- final Message msg, //
- final long timeoutMillis, //
- final RemotingCommand request//
+ final String addr, //
+ final String brokerName, //
+ final Message msg, //
+ final long timeoutMillis, //
+ final RemotingCommand request//
) throws RemotingException, MQBrokerException, InterruptedException {
RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
assert response != null;
@@ -267,18 +348,18 @@ public class MQClientAPIImpl {
}
private void sendMessageAsync(//
- final String addr, //
- final String brokerName, //
- final Message msg, //
- final long timeoutMillis, //
- final RemotingCommand request, //
- final SendCallback sendCallback, //
- final TopicPublishInfo topicPublishInfo, //
- final MQClientInstance instance, //
- final int retryTimesWhenSendFailed, //
- final AtomicInteger times, //
- final SendMessageContext context, //
- final DefaultMQProducerImpl producer //
+ final String addr, //
+ final String brokerName, //
+ final Message msg, //
+ final long timeoutMillis, //
+ final RemotingCommand request, //
+ final SendCallback sendCallback, //
+ final TopicPublishInfo topicPublishInfo, //
+ final MQClientInstance instance, //
+ final int retryTimesWhenSendFailed, //
+ final AtomicInteger times, //
+ final SendMessageContext context, //
+ final DefaultMQProducerImpl producer //
) throws InterruptedException, RemotingException {
this.remotingClient.invokeAsync(addr, request, timeoutMillis, new InvokeCallback() {
@Override
@@ -318,68 +399,67 @@ public class MQClientAPIImpl {
} catch (Exception e) {
producer.updateFaultItem(brokerName, System.currentTimeMillis() - responseFuture.getBeginTimestamp(), true);
onExceptionImpl(brokerName, msg, 0L, request, sendCallback, topicPublishInfo, instance,
- retryTimesWhenSendFailed, times, e, context, false, producer);
+ retryTimesWhenSendFailed, times, e, context, false, producer);
}
} else {
producer.updateFaultItem(brokerName, System.currentTimeMillis() - responseFuture.getBeginTimestamp(), true);
if (!responseFuture.isSendRequestOK()) {
MQClientException ex = new MQClientException("send request failed", responseFuture.getCause());
onExceptionImpl(brokerName, msg, 0L, request, sendCallback, topicPublishInfo, instance,
- retryTimesWhenSendFailed, times, ex, context, true, producer);
+ retryTimesWhenSendFailed, times, ex, context, true, producer);
} else if (responseFuture.isTimeout()) {
MQClientException ex = new MQClientException("wait response timeout " + responseFuture.getTimeoutMillis() + "ms",
- responseFuture.getCause());
+ responseFuture.getCause());
onExceptionImpl(brokerName, msg, 0L, request, sendCallback, topicPublishInfo, instance,
- retryTimesWhenSendFailed, times, ex, context, true, producer);
+ retryTimesWhenSendFailed, times, ex, context, true, producer);
} else {
MQClientException ex = new MQClientException("unknow reseaon", responseFuture.getCause());
onExceptionImpl(brokerName, msg, 0L, request, sendCallback, topicPublishInfo, instance,
- retryTimesWhenSendFailed, times, ex, context, true, producer);
+ retryTimesWhenSendFailed, times, ex, context, true, producer);
}
}
}
});
}
-
private void onExceptionImpl(final String brokerName, //
- final Message msg, //
- final long timeoutMillis, //
- final RemotingCommand request, //
- final SendCallback sendCallback, //
- final TopicPublishInfo topicPublishInfo, //
- final MQClientInstance instance, //
- final int timesTotal, //
- final AtomicInteger curTimes, //
- final Exception e, //
- final SendMessageContext context, //
- final boolean needRetry, //
- final DefaultMQProducerImpl producer // 12
+ final Message msg, //
+ final long timeoutMillis, //
+ final RemotingCommand request, //
+ final SendCallback sendCallback, //
+ final TopicPublishInfo topicPublishInfo, //
+ final MQClientInstance instance, //
+ final int timesTotal, //
+ final AtomicInteger curTimes, //
+ final Exception e, //
+ final SendMessageContext context, //
+ final boolean needRetry, //
+ final DefaultMQProducerImpl producer // 12
) {
int tmp = curTimes.incrementAndGet();
if (needRetry && tmp <= timesTotal) {
MessageQueue tmpmq = producer.selectOneMessageQueue(topicPublishInfo, brokerName);
String addr = instance.findBrokerAddressInPublish(tmpmq.getBrokerName());
log.info("async send msg by retry {} times. topic={}, brokerAddr={}, brokerName={}", tmp, msg.getTopic(), addr,
- tmpmq.getBrokerName());
+ tmpmq.getBrokerName());
try {
request.setOpaque(RemotingCommand.createNewRequestId());
sendMessageAsync(addr, tmpmq.getBrokerName(), msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance,
- timesTotal, curTimes, context, producer);
+ timesTotal, curTimes, context, producer);
} catch (InterruptedException e1) {
onExceptionImpl(tmpmq.getBrokerName(), msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance, timesTotal, curTimes, e1,
- context, false, producer);
+ context, false, producer);
} catch (RemotingConnectException e1) {
producer.updateFaultItem(brokerName, 3000, true);
onExceptionImpl(tmpmq.getBrokerName(), msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance, timesTotal, curTimes, e1,
- context, true, producer);
+ context, true, producer);
} catch (RemotingTooMuchRequestException e1) {
onExceptionImpl(tmpmq.getBrokerName(), msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance, timesTotal, curTimes, e1,
- context, false, producer);
+ context, false, producer);
} catch (RemotingException e1) {
producer.updateFaultItem(brokerName, 3000, true);
onExceptionImpl(tmpmq.getBrokerName(), msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance, timesTotal, curTimes, e1,
- context, true, producer);
+ context, true, producer);
}
} else {
if (context != null) {
@@ -393,11 +473,10 @@ public class MQClientAPIImpl {
}
}
-
private SendResult processSendResponse(//
- final String brokerName, //
- final Message msg, //
- final RemotingCommand response//
+ final String brokerName, //
+ final Message msg, //
+ final RemotingCommand response//
) throws MQBrokerException, RemotingCommandException {
switch (response.getCode()) {
case ResponseCode.FLUSH_DISK_TIMEOUT:
@@ -426,13 +505,13 @@ public class MQClientAPIImpl {
}
SendMessageResponseHeader responseHeader =
- (SendMessageResponseHeader) response.decodeCommandCustomHeader(SendMessageResponseHeader.class);
+ (SendMessageResponseHeader)response.decodeCommandCustomHeader(SendMessageResponseHeader.class);
MessageQueue messageQueue = new MessageQueue(msg.getTopic(), brokerName, responseHeader.getQueueId());
SendResult sendResult = new SendResult(sendStatus,
- MessageClientIDSetter.getUniqID(msg),
- responseHeader.getMsgId(), messageQueue, responseHeader.getQueueOffset());
+ MessageClientIDSetter.getUniqID(msg),
+ responseHeader.getMsgId(), messageQueue, responseHeader.getQueueOffset());
sendResult.setTransactionId(responseHeader.getTransactionId());
String regionId = response.getExtFields().get(MessageConst.PROPERTY_MSG_REGION);
String traceOn = response.getExtFields().get(MessageConst.PROPERTY_TRACE_SWITCH);
@@ -454,13 +533,12 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public PullResult pullMessage(//
- final String addr, //
- final PullMessageRequestHeader requestHeader, //
- final long timeoutMillis, //
- final CommunicationMode communicationMode, //
- final PullCallback pullCallback//
+ final String addr, //
+ final PullMessageRequestHeader requestHeader, //
+ final long timeoutMillis, //
+ final CommunicationMode communicationMode, //
+ final PullCallback pullCallback//
) throws RemotingException, MQBrokerException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.PULL_MESSAGE, requestHeader);
@@ -481,12 +559,11 @@ public class MQClientAPIImpl {
return null;
}
-
private void pullMessageAsync(//
- final String addr, // 1
- final RemotingCommand request, //
- final long timeoutMillis, //
- final PullCallback pullCallback//
+ final String addr, // 1
+ final RemotingCommand request, //
+ final long timeoutMillis, //
+ final PullCallback pullCallback//
) throws RemotingException, InterruptedException {
this.remotingClient.invokeAsync(addr, request, timeoutMillis, new InvokeCallback() {
@Override
@@ -505,7 +582,7 @@ public class MQClientAPIImpl {
pullCallback.onException(new MQClientException("send request failed", responseFuture.getCause()));
} else if (responseFuture.isTimeout()) {
pullCallback.onException(new MQClientException("wait response timeout " + responseFuture.getTimeoutMillis() + "ms",
- responseFuture.getCause()));
+ responseFuture.getCause()));
} else {
pullCallback.onException(new MQClientException("unknow reseaon", responseFuture.getCause()));
}
@@ -515,9 +592,9 @@ public class MQClientAPIImpl {
}
private PullResult pullMessageSync(//
- final String addr, // 1
- final RemotingCommand request, // 2
- final long timeoutMillis// 3
+ final String addr, // 1
+ final RemotingCommand request, // 2
+ final long timeoutMillis// 3
) throws RemotingException, InterruptedException, MQBrokerException {
RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
assert response != null;
@@ -545,20 +622,20 @@ public class MQClientAPIImpl {
}
PullMessageResponseHeader responseHeader =
- (PullMessageResponseHeader) response.decodeCommandCustomHeader(PullMessageResponseHeader.class);
+ (PullMessageResponseHeader)response.decodeCommandCustomHeader(PullMessageResponseHeader.class);
return new PullResultExt(pullStatus, responseHeader.getNextBeginOffset(), responseHeader.getMinOffset(),
- responseHeader.getMaxOffset(), null, responseHeader.getSuggestWhichBrokerId(), response.getBody());
+ responseHeader.getMaxOffset(), null, responseHeader.getSuggestWhichBrokerId(), response.getBody());
}
public MessageExt viewMessage(final String addr, final long phyoffset, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException {
+ throws RemotingException, MQBrokerException, InterruptedException {
ViewMessageRequestHeader requestHeader = new ViewMessageRequestHeader();
requestHeader.setOffset(phyoffset);
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.VIEW_MESSAGE_BY_ID, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
@@ -573,9 +650,8 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public long searchOffset(final String addr, final String topic, final int queueId, final long timestamp, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException {
+ throws RemotingException, MQBrokerException, InterruptedException {
SearchOffsetRequestHeader requestHeader = new SearchOffsetRequestHeader();
requestHeader.setTopic(topic);
requestHeader.setQueueId(queueId);
@@ -583,12 +659,12 @@ public class MQClientAPIImpl {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.SEARCH_OFFSET_BY_TIMESTAMP, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
SearchOffsetResponseHeader responseHeader =
- (SearchOffsetResponseHeader) response.decodeCommandCustomHeader(SearchOffsetResponseHeader.class);
+ (SearchOffsetResponseHeader)response.decodeCommandCustomHeader(SearchOffsetResponseHeader.class);
return responseHeader.getOffset();
}
default:
@@ -598,21 +674,20 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public long getMaxOffset(final String addr, final String topic, final int queueId, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException {
+ throws RemotingException, MQBrokerException, InterruptedException {
GetMaxOffsetRequestHeader requestHeader = new GetMaxOffsetRequestHeader();
requestHeader.setTopic(topic);
requestHeader.setQueueId(queueId);
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_MAX_OFFSET, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
GetMaxOffsetResponseHeader responseHeader =
- (GetMaxOffsetResponseHeader) response.decodeCommandCustomHeader(GetMaxOffsetResponseHeader.class);
+ (GetMaxOffsetResponseHeader)response.decodeCommandCustomHeader(GetMaxOffsetResponseHeader.class);
return responseHeader.getOffset();
}
@@ -623,24 +698,23 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public List<String> getConsumerIdListByGroup(//
- final String addr, //
- final String consumerGroup, //
- final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
- MQBrokerException, InterruptedException {
+ final String addr, //
+ final String consumerGroup, //
+ final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
+ MQBrokerException, InterruptedException {
GetConsumerListByGroupRequestHeader requestHeader = new GetConsumerListByGroupRequestHeader();
requestHeader.setConsumerGroup(consumerGroup);
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_LIST_BY_GROUP, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
if (response.getBody() != null) {
GetConsumerListByGroupResponseBody body =
- GetConsumerListByGroupResponseBody.decode(response.getBody(), GetConsumerListByGroupResponseBody.class);
+ GetConsumerListByGroupResponseBody.decode(response.getBody(), GetConsumerListByGroupResponseBody.class);
return body.getConsumerIdList();
}
}
@@ -651,21 +725,20 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public long getMinOffset(final String addr, final String topic, final int queueId, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException {
+ throws RemotingException, MQBrokerException, InterruptedException {
GetMinOffsetRequestHeader requestHeader = new GetMinOffsetRequestHeader();
requestHeader.setTopic(topic);
requestHeader.setQueueId(queueId);
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_MIN_OFFSET, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
GetMinOffsetResponseHeader responseHeader =
- (GetMinOffsetResponseHeader) response.decodeCommandCustomHeader(GetMinOffsetResponseHeader.class);
+ (GetMinOffsetResponseHeader)response.decodeCommandCustomHeader(GetMinOffsetResponseHeader.class);
return responseHeader.getOffset();
}
@@ -676,21 +749,20 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public long getEarliestMsgStoretime(final String addr, final String topic, final int queueId, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException {
+ throws RemotingException, MQBrokerException, InterruptedException {
GetEarliestMsgStoretimeRequestHeader requestHeader = new GetEarliestMsgStoretimeRequestHeader();
requestHeader.setTopic(topic);
requestHeader.setQueueId(queueId);
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_EARLIEST_MSG_STORETIME, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
GetEarliestMsgStoretimeResponseHeader responseHeader =
- (GetEarliestMsgStoretimeResponseHeader) response.decodeCommandCustomHeader(GetEarliestMsgStoretimeResponseHeader.class);
+ (GetEarliestMsgStoretimeResponseHeader)response.decodeCommandCustomHeader(GetEarliestMsgStoretimeResponseHeader.class);
return responseHeader.getTimestamp();
}
@@ -701,21 +773,20 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public long queryConsumerOffset(//
- final String addr, //
- final QueryConsumerOffsetRequestHeader requestHeader, //
- final long timeoutMillis//
+ final String addr, //
+ final QueryConsumerOffsetRequestHeader requestHeader, //
+ final long timeoutMillis//
) throws RemotingException, MQBrokerException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CONSUMER_OFFSET, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
QueryConsumerOffsetResponseHeader responseHeader =
- (QueryConsumerOffsetResponseHeader) response.decodeCommandCustomHeader(QueryConsumerOffsetResponseHeader.class);
+ (QueryConsumerOffsetResponseHeader)response.decodeCommandCustomHeader(QueryConsumerOffsetResponseHeader.class);
return responseHeader.getOffset();
}
@@ -726,16 +797,15 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public void updateConsumerOffset(//
- final String addr, //
- final UpdateConsumerOffsetRequestHeader requestHeader, //
- final long timeoutMillis//
+ final String addr, //
+ final UpdateConsumerOffsetRequestHeader requestHeader, //
+ final long timeoutMillis//
) throws RemotingException, MQBrokerException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_CONSUMER_OFFSET, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
@@ -748,23 +818,21 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public void updateConsumerOffsetOneway(//
- final String addr, //
- final UpdateConsumerOffsetRequestHeader requestHeader, //
- final long timeoutMillis//
+ final String addr, //
+ final UpdateConsumerOffsetRequestHeader requestHeader, //
+ final long timeoutMillis//
) throws RemotingConnectException, RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException,
- InterruptedException {
+ InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_CONSUMER_OFFSET, requestHeader);
this.remotingClient.invokeOneway(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
}
-
public void sendHearbeat(//
- final String addr, //
- final HeartbeatData heartbeatData, //
- final long timeoutMillis//
+ final String addr, //
+ final HeartbeatData heartbeatData, //
+ final long timeoutMillis//
) throws RemotingException, MQBrokerException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.HEART_BEAT, null);
@@ -782,13 +850,12 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public void unregisterClient(//
- final String addr, //
- final String clientID, //
- final String producerGroup, //
- final String consumerGroup, //
- final long timeoutMillis//
+ final String addr, //
+ final String clientID, //
+ final String producerGroup, //
+ final String consumerGroup, //
+ final long timeoutMillis//
) throws RemotingException, MQBrokerException, InterruptedException {
final UnregisterClientRequestHeader requestHeader = new UnregisterClientRequestHeader();
requestHeader.setClientID(clientID);
@@ -809,12 +876,11 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public void endTransactionOneway(//
- final String addr, //
- final EndTransactionRequestHeader requestHeader, //
- final String remark, //
- final long timeoutMillis//
+ final String addr, //
+ final EndTransactionRequestHeader requestHeader, //
+ final String remark, //
+ final long timeoutMillis//
) throws RemotingException, MQBrokerException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.END_TRANSACTION, requestHeader);
@@ -822,23 +888,21 @@ public class MQClientAPIImpl {
this.remotingClient.invokeOneway(addr, request, timeoutMillis);
}
-
public void queryMessage(
- final String addr,
- final QueryMessageRequestHeader requestHeader,
- final long timeoutMillis,
- final InvokeCallback invokeCallback,
- final Boolean isUnqiueKey
+ final String addr,
+ final QueryMessageRequestHeader requestHeader,
+ final long timeoutMillis,
+ final InvokeCallback invokeCallback,
+ final Boolean isUnqiueKey
) throws RemotingException, MQBrokerException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_MESSAGE, requestHeader);
request.addExtField(MixAll.UNIQUE_MSG_QUERY_FLAG, isUnqiueKey.toString());
this.remotingClient.invokeAsync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis,
- invokeCallback);
+ invokeCallback);
}
-
public boolean registerClient(final String addr, final HeartbeatData heartbeat, final long timeoutMillis)
- throws RemotingException, InterruptedException {
+ throws RemotingException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.HEART_BEAT, null);
request.setBody(heartbeat.encode());
@@ -846,14 +910,13 @@ public class MQClientAPIImpl {
return response.getCode() == ResponseCode.SUCCESS;
}
-
public void consumerSendMessageBack(
- final String addr,
- final MessageExt msg,
- final String consumerGroup,
- final int delayLevel,
- final long timeoutMillis,
- final int maxConsumeRetryTimes
+ final String addr,
+ final MessageExt msg,
+ final String consumerGroup,
+ final int delayLevel,
+ final long timeoutMillis,
+ final int maxConsumeRetryTimes
) throws RemotingException, MQBrokerException, InterruptedException {
ConsumerSendMsgBackRequestHeader requestHeader = new ConsumerSendMsgBackRequestHeader();
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.CONSUMER_SEND_MSG_BACK, requestHeader);
@@ -866,7 +929,7 @@ public class MQClientAPIImpl {
requestHeader.setMaxReconsumeTimes(maxConsumeRetryTimes);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
@@ -879,16 +942,15 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public Set<MessageQueue> lockBatchMQ(//
- final String addr, //
- final LockBatchRequestBody requestBody, //
- final long timeoutMillis) throws RemotingException, MQBrokerException, InterruptedException {
+ final String addr, //
+ final LockBatchRequestBody requestBody, //
+ final long timeoutMillis) throws RemotingException, MQBrokerException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.LOCK_BATCH_MQ, null);
request.setBody(requestBody.encode());
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
LockBatchResponseBody responseBody = LockBatchResponseBody.decode(response.getBody(), LockBatchResponseBody.class);
@@ -902,12 +964,11 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public void unlockBatchMQ(//
- final String addr, //
- final UnlockBatchRequestBody requestBody, //
- final long timeoutMillis, //
- final boolean oneway//
+ final String addr, //
+ final UnlockBatchRequestBody requestBody, //
+ final long timeoutMillis, //
+ final boolean oneway//
) throws RemotingException, MQBrokerException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UNLOCK_BATCH_MQ, null);
@@ -917,7 +978,7 @@ public class MQClientAPIImpl {
this.remotingClient.invokeOneway(addr, request, timeoutMillis);
} else {
RemotingCommand response = this.remotingClient
- .invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
+ .invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
return;
@@ -930,16 +991,15 @@ public class MQClientAPIImpl {
}
}
-
public TopicStatsTable getTopicStatsInfo(final String addr, final String topic, final long timeoutMillis) throws InterruptedException,
- RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
+ RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
GetTopicStatsInfoRequestHeader requestHeader = new GetTopicStatsInfoRequestHeader();
requestHeader.setTopic(topic);
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPIC_STATS_INFO, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
TopicStatsTable topicStatsTable = TopicStatsTable.decode(response.getBody(), TopicStatsTable.class);
@@ -952,17 +1012,15 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public ConsumeStats getConsumeStats(final String addr, final String consumerGroup, final long timeoutMillis)
- throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException,
- MQBrokerException {
+ throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException,
+ MQBrokerException {
return getConsumeStats(addr, consumerGroup, null, timeoutMillis);
}
-
public ConsumeStats getConsumeStats(final String addr, final String consumerGroup, final String topic, final long timeoutMillis)
- throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException,
- MQBrokerException {
+ throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException,
+ MQBrokerException {
GetConsumeStatsRequestHeader requestHeader = new GetConsumeStatsRequestHeader();
requestHeader.setConsumerGroup(consumerGroup);
requestHeader.setTopic(topic);
@@ -970,7 +1028,7 @@ public class MQClientAPIImpl {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUME_STATS, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
ConsumeStats consumeStats = ConsumeStats.decode(response.getBody(), ConsumeStats.class);
@@ -983,17 +1041,16 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public ProducerConnection getProducerConnectionList(final String addr, final String producerGroup, final long timeoutMillis)
- throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
- MQBrokerException {
+ throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
+ MQBrokerException {
GetProducerConnectionListRequestHeader requestHeader = new GetProducerConnectionListRequestHeader();
requestHeader.setProducerGroup(producerGroup);
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_PRODUCER_CONNECTION_LIST, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
return ProducerConnection.decode(response.getBody(), ProducerConnection.class);
@@ -1005,17 +1062,16 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public ConsumerConnection getConsumerConnectionList(final String addr, final String consumerGroup, final long timeoutMillis)
- throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
- MQBrokerException {
+ throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
+ MQBrokerException {
GetConsumerConnectionListRequestHeader requestHeader = new GetConsumerConnectionListRequestHeader();
requestHeader.setConsumerGroup(consumerGroup);
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_CONNECTION_LIST, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
ConsumerConnection consumerConnection = ConsumerConnection.decode(response.getBody(), ConsumerConnection.class);
@@ -1028,14 +1084,13 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public KVTable getBrokerRuntimeInfo(final String addr, final long timeoutMillis) throws RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException {
+ RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_RUNTIME_INFO, null);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
return KVTable.decode(response.getBody(), KVTable.class);
@@ -1047,10 +1102,9 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public void updateBrokerConfig(final String addr, final Properties properties, final long timeoutMillis)
- throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
- MQBrokerException, UnsupportedEncodingException {
+ throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
+ MQBrokerException, UnsupportedEncodingException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_BROKER_CONFIG, null);
@@ -1058,7 +1112,7 @@ public class MQClientAPIImpl {
if (str != null && str.length() > 0) {
request.setBody(str.getBytes(MixAll.DEFAULT_CHARSET));
RemotingCommand response = this.remotingClient
- .invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
+ .invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
return;
@@ -1071,10 +1125,9 @@ public class MQClientAPIImpl {
}
}
-
public Properties getBrokerConfig(final String addr, final long timeoutMillis)
- throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
- MQBrokerException, UnsupportedEncodingException {
+ throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
+ MQBrokerException, UnsupportedEncodingException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_CONFIG, null);
RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
@@ -1091,7 +1144,7 @@ public class MQClientAPIImpl {
}
public ClusterInfo getBrokerClusterInfo(final long timeoutMillis) throws InterruptedException, RemotingTimeoutException,
- RemotingSendRequestException, RemotingConnectException, MQBrokerException {
+ RemotingSendRequestException, RemotingConnectException, MQBrokerException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_CLUSTER_INFO, null);
RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
@@ -1108,9 +1161,8 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public TopicRouteData getDefaultTopicRouteInfoFromNameServer(final String topic, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
+ throws RemotingException, MQClientException, InterruptedException {
GetRouteInfoRequestHeader requestHeader = new GetRouteInfoRequestHeader();
requestHeader.setTopic(topic);
@@ -1136,9 +1188,8 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public TopicRouteData getTopicRouteInfoFromNameServer(final String topic, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
+ throws RemotingException, MQClientException, InterruptedException {
GetRouteInfoRequestHeader requestHeader = new GetRouteInfoRequestHeader();
requestHeader.setTopic(topic);
@@ -1165,9 +1216,8 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public TopicList getTopicListFromNameServer(final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
+ throws RemotingException, MQClientException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_LIST_FROM_NAMESERVER, null);
RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
@@ -1187,9 +1237,8 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public int wipeWritePermOfBroker(final String namesrvAddr, String brokerName, final long timeoutMillis) throws RemotingCommandException,
- RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQClientException {
+ RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQClientException {
WipeWritePermOfBrokerRequestHeader requestHeader = new WipeWritePermOfBrokerRequestHeader();
requestHeader.setBrokerName(brokerName);
@@ -1200,7 +1249,7 @@ public class MQClientAPIImpl {
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
WipeWritePermOfBrokerResponseHeader responseHeader =
- (WipeWritePermOfBrokerResponseHeader) response.decodeCommandCustomHeader(WipeWritePermOfBrokerResponseHeader.class);
+ (WipeWritePermOfBrokerResponseHeader)response.decodeCommandCustomHeader(WipeWritePermOfBrokerResponseHeader.class);
return responseHeader.getWipeTopicCount();
}
default:
@@ -1210,15 +1259,14 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public void deleteTopicInBroker(final String addr, final String topic, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
DeleteTopicRequestHeader requestHeader = new DeleteTopicRequestHeader();
requestHeader.setTopic(topic);
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.DELETE_TOPIC_IN_BROKER, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
@@ -1231,9 +1279,8 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public void deleteTopicInNameServer(final String addr, final String topic, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
DeleteTopicRequestHeader requestHeader = new DeleteTopicRequestHeader();
requestHeader.setTopic(topic);
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.DELETE_TOPIC_IN_NAMESRV, requestHeader);
@@ -1251,15 +1298,14 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public void deleteSubscriptionGroup(final String addr, final String groupName, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
DeleteSubscriptionGroupRequestHeader requestHeader = new DeleteSubscriptionGroupRequestHeader();
requestHeader.setGroupName(groupName);
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.DELETE_SUBSCRIPTIONGROUP, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
@@ -1272,9 +1318,8 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public String getKVConfigValue(final String namespace, final String key, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
+ throws RemotingException, MQClientException, InterruptedException {
GetKVConfigRequestHeader requestHeader = new GetKVConfigRequestHeader();
requestHeader.setNamespace(namespace);
requestHeader.setKey(key);
@@ -1286,7 +1331,7 @@ public class MQClientAPIImpl {
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
GetKVConfigResponseHeader responseHeader =
- (GetKVConfigResponseHeader) response.decodeCommandCustomHeader(GetKVConfigResponseHeader.class);
+ (GetKVConfigResponseHeader)response.decodeCommandCustomHeader(GetKVConfigResponseHeader.class);
return responseHeader.getValue();
}
default:
@@ -1296,9 +1341,8 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public void putKVConfigValue(final String namespace, final String key, final String value, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
+ throws RemotingException, MQClientException, InterruptedException {
PutKVConfigRequestHeader requestHeader = new PutKVConfigRequestHeader();
requestHeader.setNamespace(namespace);
requestHeader.setKey(key);
@@ -1327,9 +1371,8 @@ public class MQClientAPIImpl {
}
}
-
public void deleteKVConfigValue(final String namespace, final String key, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
+ throws RemotingException, MQClientException, InterruptedException {
DeleteKVConfigRequestHeader requestHeader = new DeleteKVConfigRequestHeader();
requestHeader.setNamespace(namespace);
requestHeader.setKey(key);
@@ -1356,9 +1399,8 @@ public class MQClientAPIImpl {
}
}
-
public KVTable getKVListByNamespace(final String namespace, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
+ throws RemotingException, MQClientException, InterruptedException {
GetKVListByNamespaceRequestHeader requestHeader = new GetKVListByNamespaceRequestHeader();
requestHeader.setNamespace(namespace);
@@ -1377,17 +1419,15 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public Map<MessageQueue, Long> invokeBrokerToResetOffset(final String addr, final String topic, final String group,
- final long timestamp, final boolean isForce, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
+ final long timestamp, final boolean isForce, final long timeoutMillis)
+ throws RemotingException, MQClientException, InterruptedException {
return invokeBrokerToResetOffset(addr, topic, group, timestamp, isForce, timeoutMillis, false);
}
-
public Map<MessageQueue, Long> invokeBrokerToResetOffset(final String addr, final String topic, final String group,
- final long timestamp, final boolean isForce, final long timeoutMillis, boolean isC)
- throws RemotingException, MQClientException, InterruptedException {
+ final long timestamp, final boolean isForce, final long timeoutMillis, boolean isC)
+ throws RemotingException, MQClientException, InterruptedException {
ResetOffsetRequestHeader requestHeader = new ResetOffsetRequestHeader();
requestHeader.setTopic(topic);
requestHeader.setGroup(group);
@@ -1400,7 +1440,7 @@ public class MQClientAPIImpl {
}
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
@@ -1416,9 +1456,8 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public Map<String, Map<MessageQueue, Long>> invokeBrokerToGetConsumerStatus(final String addr, final String topic, final String group,
- final String clientAddr, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
+ final String clientAddr, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
GetConsumerStatusRequestHeader requestHeader = new GetConsumerStatusRequestHeader();
requestHeader.setTopic(topic);
requestHeader.setGroup(group);
@@ -1427,7 +1466,7 @@ public class MQClientAPIImpl {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.INVOKE_BROKER_TO_GET_CONSUMER_STATUS, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
@@ -1443,17 +1482,16 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public GroupList queryTopicConsumeByWho(final String addr, final String topic, final long timeoutMillis)
- throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
- MQBrokerException {
+ throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
+ MQBrokerException {
QueryTopicConsumeByWhoRequestHeader requestHeader = new QueryTopicConsumeByWhoRequestHeader();
requestHeader.setTopic(topic);
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_TOPIC_CONSUME_BY_WHO, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
GroupList groupList = GroupList.decode(response.getBody(), GroupList.class);
@@ -1466,10 +1504,9 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public List<QueueTimeSpan> queryConsumeTimeSpan(final String addr, final String topic, final String group, final long timeoutMillis)
- throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
- MQBrokerException {
+ throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
+ MQBrokerException {
QueryConsumeTimeSpanRequestHeader requestHeader = new QueryConsumeTimeSpanRequestHeader();
requestHeader.setTopic(topic);
requestHeader.setGroup(group);
@@ -1477,7 +1514,7 @@ public class MQClientAPIImpl {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CONSUME_TIME_SPAN, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
QueryConsumeTimeSpanBody consumeTimeSpanBody = GroupList.decode(response.getBody(), QueryConsumeTimeSpanBody.class);
@@ -1490,9 +1527,8 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public TopicList getTopicsByCluster(final String cluster, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
+ throws RemotingException, MQClientException, InterruptedException {
GetTopicsByClusterRequestHeader requestHeader = new GetTopicsByClusterRequestHeader();
requestHeader.setCluster(cluster);
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPICS_BY_CLUSTER, requestHeader);
@@ -1514,15 +1550,14 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public void registerMessageFilterClass(final String addr, //
- final String consumerGroup, //
- final String topic, //
- final String className, //
- final int classCRC, //
- final byte[] classBody, //
- final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
- InterruptedException, MQBrokerException {
+ final String consumerGroup, //
+ final String topic, //
+ final String className, //
+ final int classCRC, //
+ final byte[] classBody, //
+ final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
+ InterruptedException, MQBrokerException {
RegisterMessageFilterClassRequestHeader requestHeader = new RegisterMessageFilterClassRequestHeader();
requestHeader.setConsumerGroup(consumerGroup);
requestHeader.setClassName(className);
@@ -1543,7 +1578,6 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
public TopicList getSystemTopicList(final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_SYSTEM_TOPIC_LIST_FROM_NS, null);
@@ -1555,7 +1589,7 @@ public class MQClientAPIImpl {
if (body != null) {
TopicList topicList = TopicList.decode(response.getBody(), TopicList.class);
if (topicList.getTopicList() != null && !topicList.getTopicList().isEmpty()
- && !UtilAll.isBlank(topicList.getBrokerAddr())) {
+ && !UtilAll.isBlank(topicList.getBrokerAddr())) {
TopicList tmp = getSystemTopicListFromBroker(topicList.getBrokerAddr(), timeoutMillis);
if (tmp.getTopicList() != null && !tmp.getTopicList().isEmpty()) {
topicList.getTopicList().addAll(tmp.getTopicList());
@@ -1571,13 +1605,12 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public TopicList getSystemTopicListFromBroker(final String addr, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
+ throws RemotingException, MQClientException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_SYSTEM_TOPIC_LIST_FROM_BROKER, null);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
@@ -1594,12 +1627,11 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public boolean cleanExpiredConsumeQueue(final String addr, long timeoutMillis) throws MQClientException, RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException, InterruptedException {
+ RemotingSendRequestException, RemotingTimeoutException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.CLEAN_EXPIRED_CONSUMEQUEUE, null);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
return true;
@@ -1611,12 +1643,11 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public boolean cleanUnusedTopicByAddr(final String addr, long timeoutMillis) throws MQClientException, RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException, InterruptedException {
+ RemotingSendRequestException, RemotingTimeoutException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.CLEAN_UNUSED_TOPIC, null);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
return true;
@@ -1629,7 +1660,7 @@ public class MQClientAPIImpl {
}
public ConsumerRunningInfo getConsumerRunningInfo(final String addr, String consumerGroup, String clientId, boolean jstack,
- final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
+ final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
GetConsumerRunningInfoRequestHeader requestHeader = new GetConsumerRunningInfoRequestHeader();
requestHeader.setConsumerGroup(consumerGroup);
requestHeader.setClientId(clientId);
@@ -1638,7 +1669,7 @@ public class MQClientAPIImpl {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_RUNNING_INFO, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
@@ -1656,10 +1687,10 @@ public class MQClientAPIImpl {
}
public ConsumeMessageDirectlyResult consumeMessageDirectly(final String addr, //
- String consumerGroup, //
- String clientId, //
- String msgId, //
- final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
+ String consumerGroup, //
+ String clientId, //
+ String msgId, //
+ final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
ConsumeMessageDirectlyResultRequestHeader requestHeader = new ConsumeMessageDirectlyResultRequestHeader();
requestHeader.setConsumerGroup(consumerGroup);
requestHeader.setClientId(clientId);
@@ -1668,7 +1699,7 @@ public class MQClientAPIImpl {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.CONSUME_MESSAGE_DIRECTLY, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
@@ -1686,8 +1717,8 @@ public class MQClientAPIImpl {
}
public Map<Integer, Long> queryCorrectionOffset(final String addr, final String topic, final String group, Set<String> filterGroup,
- long timeoutMillis) throws MQClientException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
- InterruptedException {
+ long timeoutMillis) throws MQClientException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
+ InterruptedException {
QueryCorrectionOffsetHeader requestHeader = new QueryCorrectionOffsetHeader();
requestHeader.setCompareGroup(group);
requestHeader.setTopic(topic);
@@ -1703,7 +1734,7 @@ public class MQClientAPIImpl {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CORRECTION_OFFSET, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
@@ -1720,7 +1751,7 @@ public class MQClientAPIImpl {
}
public TopicList getUnitTopicList(final boolean containRetry, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
+ throws RemotingException, MQClientException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_UNIT_TOPIC_LIST, null);
RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
@@ -1749,9 +1780,8 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public TopicList getHasUnitSubTopicList(final boolean containRetry, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
+ throws RemotingException, MQClientException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_HAS_UNIT_SUB_TOPIC_LIST, null);
RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
@@ -1779,9 +1809,8 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public TopicList getHasUnitSubUnUnitTopicList(final boolean containRetry, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
+ throws RemotingException, MQClientException, InterruptedException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_HAS_UNIT_SUB_UNUNIT_TOPIC_LIST, null);
RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
@@ -1809,9 +1838,8 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public void cloneGroupOffset(final String addr, final String srcGroup, final String destGroup, final String topic,
- final boolean isOffline, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
+ final boolean isOffline, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
CloneGroupOffsetRequestHeader requestHeader = new CloneGroupOffsetRequestHeader();
requestHeader.setSrcGroup(srcGroup);
requestHeader.setDestGroup(destGroup);
@@ -1820,7 +1848,7 @@ public class MQClientAPIImpl {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.CLONE_GROUP_OFFSET, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
+ request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
@@ -1833,10 +1861,9 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public BrokerStatsData viewBrokerStatsData(String brokerAddr, String statsName, String statsKey, long timeoutMillis)
- throws MQClientException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
- InterruptedException {
+ throws MQClientException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
+ InterruptedException {
ViewBrokerStatsDataRequestHeader requestHeader = new ViewBrokerStatsDataRequestHeader();
requestHeader.setStatsName(statsName);
requestHeader.setStatsKey(statsKey);
@@ -1844,7 +1871,7 @@ public class MQClientAPIImpl {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.VIEW_BROKER_STATS_DATA, requestHeader);
RemotingCommand response = this.remotingClient
- .invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), brokerAddr), request, timeoutMillis);
+ .invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), brokerAddr), request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
@@ -1860,23 +1887,21 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public Set<String> getClusterList(String topic, long timeoutMillis) throws MQClientException, RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException, InterruptedException {
+ RemotingSendRequestException, RemotingTimeoutException, InterruptedException {
// todo:jodie
return Collections.EMPTY_SET;
}
-
public ConsumeStatsList fetchConsumeStatsInBroker(String brokerAddr, boolean isOrder, long timeoutMillis) throws MQClientException,
- RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException {
+ RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException {
GetConsumeStatsInBrokerHeader requestHeader = new GetConsumeStatsInBrokerHeader();
requestHeader.setIsOrder(isOrder);
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_CONSUME_STATS, requestHeader);
RemotingCommand response = this.remotingClient
- .invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), brokerAddr), request, timeoutMillis);
+ .invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), brokerAddr), request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
@@ -1892,12 +1917,11 @@ public class MQClientAPIImpl {
throw new MQClientException(response.getCode(), response.getRemark());
}
-
public SubscriptionGroupWrapper getAllSubscriptionGroup(final String brokerAddr, long timeoutMillis) throws InterruptedException,
- RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
+ RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_SUBSCRIPTIONGROUP_CONFIG, null);
RemotingCommand response = this.remotingClient
- .invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), brokerAddr), request, timeoutMillis);
+ .invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), brokerAddr), request, timeoutMillis);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
@@ -1909,13 +1933,12 @@ public class MQClientAPIImpl {
throw new MQBrokerException(response.getCode(), response.getRemark());
}
-
<TRUNCATED>
[50/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/BrokerController.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/BrokerController.java b/broker/src/main/java/com/alibaba/rocketmq/broker/BrokerController.java
deleted file mode 100644
index b2b6aed..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/BrokerController.java
+++ /dev/null
@@ -1,773 +0,0 @@
-/**
- * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.broker.client.*;
-import com.alibaba.rocketmq.broker.client.net.Broker2Client;
-import com.alibaba.rocketmq.broker.client.rebalance.RebalanceLockManager;
-import com.alibaba.rocketmq.broker.filtersrv.FilterServerManager;
-import com.alibaba.rocketmq.broker.latency.BrokerFastFailure;
-import com.alibaba.rocketmq.broker.latency.BrokerFixedThreadPoolExecutor;
-import com.alibaba.rocketmq.broker.longpolling.NotifyMessageArrivingListener;
-import com.alibaba.rocketmq.broker.longpolling.PullRequestHoldService;
-import com.alibaba.rocketmq.broker.mqtrace.ConsumeMessageHook;
-import com.alibaba.rocketmq.broker.mqtrace.SendMessageHook;
-import com.alibaba.rocketmq.broker.offset.ConsumerOffsetManager;
-import com.alibaba.rocketmq.broker.out.BrokerOuterAPI;
-import com.alibaba.rocketmq.broker.plugin.MessageStoreFactory;
-import com.alibaba.rocketmq.broker.plugin.MessageStorePluginContext;
-import com.alibaba.rocketmq.broker.processor.*;
-import com.alibaba.rocketmq.broker.slave.SlaveSynchronize;
-import com.alibaba.rocketmq.broker.subscription.SubscriptionGroupManager;
-import com.alibaba.rocketmq.broker.topic.TopicConfigManager;
-import com.alibaba.rocketmq.common.*;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.constant.PermName;
-import com.alibaba.rocketmq.common.namesrv.RegisterBrokerResult;
-import com.alibaba.rocketmq.common.protocol.RequestCode;
-import com.alibaba.rocketmq.common.protocol.body.TopicConfigSerializeWrapper;
-import com.alibaba.rocketmq.common.stats.MomentStatsItem;
-import com.alibaba.rocketmq.remoting.RPCHook;
-import com.alibaba.rocketmq.remoting.RemotingServer;
-import com.alibaba.rocketmq.remoting.netty.*;
-import com.alibaba.rocketmq.store.DefaultMessageStore;
-import com.alibaba.rocketmq.store.MessageArrivingListener;
-import com.alibaba.rocketmq.store.MessageStore;
-import com.alibaba.rocketmq.store.config.BrokerRole;
-import com.alibaba.rocketmq.store.config.MessageStoreConfig;
-import com.alibaba.rocketmq.store.stats.BrokerStats;
-import com.alibaba.rocketmq.store.stats.BrokerStatsManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.*;
-
-
-/**
- * @author shijia.wxr
- */
-public class BrokerController {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
- private static final Logger LOG_PROTECTION = LoggerFactory.getLogger(LoggerName.PROTECTION_LOGGER_NAME);
- private static final Logger LOG_WATER_MARK = LoggerFactory.getLogger(LoggerName.WATER_MARK_LOGGER_NAME);
- private final BrokerConfig brokerConfig;
- private final NettyServerConfig nettyServerConfig;
- private final NettyClientConfig nettyClientConfig;
- private final MessageStoreConfig messageStoreConfig;
- private final ConsumerOffsetManager consumerOffsetManager;
- private final ConsumerManager consumerManager;
- private final ProducerManager producerManager;
- private final ClientHousekeepingService clientHousekeepingService;
- private final PullMessageProcessor pullMessageProcessor;
- private final PullRequestHoldService pullRequestHoldService;
- private final MessageArrivingListener messageArrivingListener;
- private final Broker2Client broker2Client;
- private final SubscriptionGroupManager subscriptionGroupManager;
- private final ConsumerIdsChangeListener consumerIdsChangeListener;
- private final RebalanceLockManager rebalanceLockManager = new RebalanceLockManager();
- private final BrokerOuterAPI brokerOuterAPI;
- private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl(
- "BrokerControllerScheduledThread"));
- private final SlaveSynchronize slaveSynchronize;
- private final BlockingQueue<Runnable> sendThreadPoolQueue;
- private final BlockingQueue<Runnable> pullThreadPoolQueue;
- private final BlockingQueue<Runnable> clientManagerThreadPoolQueue;
- private final BlockingQueue<Runnable> consumerManagerThreadPoolQueue;
- private final FilterServerManager filterServerManager;
- private final BrokerStatsManager brokerStatsManager;
- private final List<SendMessageHook> sendMessageHookList = new ArrayList<SendMessageHook>();
- private final List<ConsumeMessageHook> consumeMessageHookList = new ArrayList<ConsumeMessageHook>();
- private MessageStore messageStore;
- private RemotingServer remotingServer;
- private RemotingServer fastRemotingServer;
- private TopicConfigManager topicConfigManager;
- private ExecutorService sendMessageExecutor;
- private ExecutorService pullMessageExecutor;
- private ExecutorService adminBrokerExecutor;
- private ExecutorService clientManageExecutor;
- private ExecutorService consumerManageExecutor;
- private boolean updateMasterHAServerAddrPeriodically = false;
- private BrokerStats brokerStats;
- private InetSocketAddress storeHost;
- private BrokerFastFailure brokerFastFailure;
- private Configuration configuration;
-
- public BrokerController(//
- final BrokerConfig brokerConfig, //
- final NettyServerConfig nettyServerConfig, //
- final NettyClientConfig nettyClientConfig, //
- final MessageStoreConfig messageStoreConfig //
- ) {
- this.brokerConfig = brokerConfig;
- this.nettyServerConfig = nettyServerConfig;
- this.nettyClientConfig = nettyClientConfig;
- this.messageStoreConfig = messageStoreConfig;
- this.consumerOffsetManager = new ConsumerOffsetManager(this);
- this.topicConfigManager = new TopicConfigManager(this);
- this.pullMessageProcessor = new PullMessageProcessor(this);
- this.pullRequestHoldService = new PullRequestHoldService(this);
- this.messageArrivingListener = new NotifyMessageArrivingListener(this.pullRequestHoldService);
- this.consumerIdsChangeListener = new DefaultConsumerIdsChangeListener(this);
- this.consumerManager = new ConsumerManager(this.consumerIdsChangeListener);
- this.producerManager = new ProducerManager();
- this.clientHousekeepingService = new ClientHousekeepingService(this);
- this.broker2Client = new Broker2Client(this);
- this.subscriptionGroupManager = new SubscriptionGroupManager(this);
- this.brokerOuterAPI = new BrokerOuterAPI(nettyClientConfig);
- this.filterServerManager = new FilterServerManager(this);
-
- if (this.brokerConfig.getNamesrvAddr() != null) {
- this.brokerOuterAPI.updateNameServerAddressList(this.brokerConfig.getNamesrvAddr());
- log.info("user specfied name server address: {}", this.brokerConfig.getNamesrvAddr());
- }
-
- this.slaveSynchronize = new SlaveSynchronize(this);
-
- this.sendThreadPoolQueue = new LinkedBlockingQueue<Runnable>(this.brokerConfig.getSendThreadPoolQueueCapacity());
-
- this.pullThreadPoolQueue = new LinkedBlockingQueue<Runnable>(this.brokerConfig.getPullThreadPoolQueueCapacity());
- this.clientManagerThreadPoolQueue = new LinkedBlockingQueue<Runnable>(this.brokerConfig.getClientManagerThreadPoolQueueCapacity());
- this.consumerManagerThreadPoolQueue = new LinkedBlockingQueue<Runnable>(this.brokerConfig.getConsumerManagerThreadPoolQueueCapacity());
-
- this.brokerStatsManager = new BrokerStatsManager(this.brokerConfig.getBrokerClusterName());
- this.setStoreHost(new InetSocketAddress(this.getBrokerConfig().getBrokerIP1(), this.getNettyServerConfig().getListenPort()));
-
- this.brokerFastFailure = new BrokerFastFailure(this);
- this.configuration = new Configuration(
- log,
- BrokerPathConfigHelper.getBrokerConfigPath(),
- this.brokerConfig, this.nettyServerConfig, this.nettyClientConfig, this.messageStoreConfig
- );
- }
-
- public BrokerConfig getBrokerConfig() {
- return brokerConfig;
- }
-
- public NettyServerConfig getNettyServerConfig() {
- return nettyServerConfig;
- }
-
- public BlockingQueue<Runnable> getPullThreadPoolQueue() {
- return pullThreadPoolQueue;
- }
-
- public boolean initialize() throws CloneNotSupportedException {
- boolean result = true;
-
- result = result && this.topicConfigManager.load();
-
- result = result && this.consumerOffsetManager.load();
- result = result && this.subscriptionGroupManager.load();
-
- if (result) {
- try {
- this.messageStore =
- new DefaultMessageStore(this.messageStoreConfig, this.brokerStatsManager, this.messageArrivingListener,
- this.brokerConfig);
- this.brokerStats = new BrokerStats((DefaultMessageStore) this.messageStore);
- //load plugin
- MessageStorePluginContext context = new MessageStorePluginContext(messageStoreConfig, brokerStatsManager, messageArrivingListener, brokerConfig);
- this.messageStore = MessageStoreFactory.build(context, this.messageStore);
- } catch (IOException e) {
- result = false;
- e.printStackTrace();
- }
- }
-
- result = result && this.messageStore.load();
-
- if (result) {
- this.remotingServer = new NettyRemotingServer(this.nettyServerConfig, this.clientHousekeepingService);
- NettyServerConfig fastConfig = (NettyServerConfig) this.nettyServerConfig.clone();
- fastConfig.setListenPort(nettyServerConfig.getListenPort() - 2);
- this.fastRemotingServer = new NettyRemotingServer(fastConfig, this.clientHousekeepingService);
- this.sendMessageExecutor = new BrokerFixedThreadPoolExecutor(
- this.brokerConfig.getSendMessageThreadPoolNums(),
- this.brokerConfig.getSendMessageThreadPoolNums(),
- 1000 * 60,
- TimeUnit.MILLISECONDS,
- this.sendThreadPoolQueue,
- new ThreadFactoryImpl("SendMessageThread_"));
-
- this.pullMessageExecutor = new BrokerFixedThreadPoolExecutor(
- this.brokerConfig.getPullMessageThreadPoolNums(),
- this.brokerConfig.getPullMessageThreadPoolNums(),
- 1000 * 60,
- TimeUnit.MILLISECONDS,
- this.pullThreadPoolQueue,
- new ThreadFactoryImpl("PullMessageThread_"));
-
- this.adminBrokerExecutor =
- Executors.newFixedThreadPool(this.brokerConfig.getAdminBrokerThreadPoolNums(), new ThreadFactoryImpl(
- "AdminBrokerThread_"));
-
- this.clientManageExecutor = new ThreadPoolExecutor(
- this.brokerConfig.getClientManageThreadPoolNums(),
- this.brokerConfig.getClientManageThreadPoolNums(),
- 1000 * 60,
- TimeUnit.MILLISECONDS,
- this.clientManagerThreadPoolQueue,
- new ThreadFactoryImpl("ClientManageThread_"));
-
- this.consumerManageExecutor =
- Executors.newFixedThreadPool(this.brokerConfig.getConsumerManageThreadPoolNums(), new ThreadFactoryImpl(
- "ConsumerManageThread_"));
-
- this.registerProcessor();
-
-
- // TODO remove in future
- final long initialDelay = UtilAll.computNextMorningTimeMillis() - System.currentTimeMillis();
- final long period = 1000 * 60 * 60 * 24;
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- BrokerController.this.getBrokerStats().record();
- } catch (Throwable e) {
- log.error("schedule record error.", e);
- }
- }
- }, initialDelay, period, TimeUnit.MILLISECONDS);
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- BrokerController.this.consumerOffsetManager.persist();
- } catch (Throwable e) {
- log.error("schedule persist consumerOffset error.", e);
- }
- }
- }, 1000 * 10, this.brokerConfig.getFlushConsumerOffsetInterval(), TimeUnit.MILLISECONDS);
-
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- BrokerController.this.protectBroker();
- } catch (Exception e) {
- log.error("protectBroker error.", e);
- }
- }
- }, 3, 3, TimeUnit.MINUTES);
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- BrokerController.this.printWaterMark();
- } catch (Exception e) {
- log.error("printWaterMark error.", e);
- }
- }
- }, 10, 1, TimeUnit.SECONDS);
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
-
- @Override
- public void run() {
- try {
- log.info("dispatch behind commit log {} bytes", BrokerController.this.getMessageStore().dispatchBehindBytes());
- } catch (Throwable e) {
- log.error("schedule dispatchBehindBytes error.", e);
- }
- }
- }, 1000 * 10, 1000 * 60, TimeUnit.MILLISECONDS);
-
- if (this.brokerConfig.getNamesrvAddr() != null) {
- this.brokerOuterAPI.updateNameServerAddressList(this.brokerConfig.getNamesrvAddr());
- } else if (this.brokerConfig.isFetchNamesrvAddrByAddressServer()) {
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
-
- @Override
- public void run() {
- try {
- BrokerController.this.brokerOuterAPI.fetchNameServerAddr();
- } catch (Throwable e) {
- log.error("ScheduledTask fetchNameServerAddr exception", e);
- }
- }
- }, 1000 * 10, 1000 * 60 * 2, TimeUnit.MILLISECONDS);
- }
-
- if (BrokerRole.SLAVE == this.messageStoreConfig.getBrokerRole()) {
- if (this.messageStoreConfig.getHaMasterAddress() != null && this.messageStoreConfig.getHaMasterAddress().length() >= 6) {
- this.messageStore.updateHaMasterAddress(this.messageStoreConfig.getHaMasterAddress());
- this.updateMasterHAServerAddrPeriodically = false;
- } else {
- this.updateMasterHAServerAddrPeriodically = true;
- }
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
-
- @Override
- public void run() {
- try {
- BrokerController.this.slaveSynchronize.syncAll();
- } catch (Throwable e) {
- log.error("ScheduledTask syncAll slave exception", e);
- }
- }
- }, 1000 * 10, 1000 * 60, TimeUnit.MILLISECONDS);
- } else {
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
-
- @Override
- public void run() {
- try {
- BrokerController.this.printMasterAndSlaveDiff();
- } catch (Throwable e) {
- log.error("schedule printMasterAndSlaveDiff error.", e);
- }
- }
- }, 1000 * 10, 1000 * 60, TimeUnit.MILLISECONDS);
- }
- }
-
- return result;
- }
-
- public void registerProcessor() {
- /**
- * SendMessageProcessor
- */
- SendMessageProcessor sendProcessor = new SendMessageProcessor(this);
- sendProcessor.registerSendMessageHook(sendMessageHookList);
- sendProcessor.registerConsumeMessageHook(consumeMessageHookList);
-
- this.remotingServer.registerProcessor(RequestCode.SEND_MESSAGE, sendProcessor, this.sendMessageExecutor);
- this.remotingServer.registerProcessor(RequestCode.SEND_MESSAGE_V2, sendProcessor, this.sendMessageExecutor);
- this.remotingServer.registerProcessor(RequestCode.CONSUMER_SEND_MSG_BACK, sendProcessor, this.sendMessageExecutor);
- this.fastRemotingServer.registerProcessor(RequestCode.SEND_MESSAGE, sendProcessor, this.sendMessageExecutor);
- this.fastRemotingServer.registerProcessor(RequestCode.SEND_MESSAGE_V2, sendProcessor, this.sendMessageExecutor);
- this.fastRemotingServer.registerProcessor(RequestCode.CONSUMER_SEND_MSG_BACK, sendProcessor, this.sendMessageExecutor);
- /**
- * PullMessageProcessor
- */
- this.remotingServer.registerProcessor(RequestCode.PULL_MESSAGE, this.pullMessageProcessor, this.pullMessageExecutor);
- this.pullMessageProcessor.registerConsumeMessageHook(consumeMessageHookList);
-
- /**
- * QueryMessageProcessor
- */
- NettyRequestProcessor queryProcessor = new QueryMessageProcessor(this);
- this.remotingServer.registerProcessor(RequestCode.QUERY_MESSAGE, queryProcessor, this.pullMessageExecutor);
- this.remotingServer.registerProcessor(RequestCode.VIEW_MESSAGE_BY_ID, queryProcessor, this.pullMessageExecutor);
-
- this.fastRemotingServer.registerProcessor(RequestCode.QUERY_MESSAGE, queryProcessor, this.pullMessageExecutor);
- this.fastRemotingServer.registerProcessor(RequestCode.VIEW_MESSAGE_BY_ID, queryProcessor, this.pullMessageExecutor);
-
- /**
- * ClientManageProcessor
- */
- ClientManageProcessor clientProcessor = new ClientManageProcessor(this);
- this.remotingServer.registerProcessor(RequestCode.HEART_BEAT, clientProcessor, this.clientManageExecutor);
- this.remotingServer.registerProcessor(RequestCode.UNREGISTER_CLIENT, clientProcessor, this.clientManageExecutor);
-
- this.fastRemotingServer.registerProcessor(RequestCode.HEART_BEAT, clientProcessor, this.clientManageExecutor);
- this.fastRemotingServer.registerProcessor(RequestCode.UNREGISTER_CLIENT, clientProcessor, this.clientManageExecutor);
-
- /**
- * ConsumerManageProcessor
- */
- ConsumerManageProcessor consumerManageProcessor = new ConsumerManageProcessor(this);
- this.remotingServer.registerProcessor(RequestCode.GET_CONSUMER_LIST_BY_GROUP, consumerManageProcessor, this.consumerManageExecutor);
- this.remotingServer.registerProcessor(RequestCode.UPDATE_CONSUMER_OFFSET, consumerManageProcessor, this.consumerManageExecutor);
- this.remotingServer.registerProcessor(RequestCode.QUERY_CONSUMER_OFFSET, consumerManageProcessor, this.consumerManageExecutor);
-
- this.fastRemotingServer.registerProcessor(RequestCode.GET_CONSUMER_LIST_BY_GROUP, consumerManageProcessor, this.consumerManageExecutor);
- this.fastRemotingServer.registerProcessor(RequestCode.UPDATE_CONSUMER_OFFSET, consumerManageProcessor, this.consumerManageExecutor);
- this.fastRemotingServer.registerProcessor(RequestCode.QUERY_CONSUMER_OFFSET, consumerManageProcessor, this.consumerManageExecutor);
-
-
- /**
- * EndTransactionProcessor
- */
- this.remotingServer.registerProcessor(RequestCode.END_TRANSACTION, new EndTransactionProcessor(this), this.sendMessageExecutor);
- this.fastRemotingServer.registerProcessor(RequestCode.END_TRANSACTION, new EndTransactionProcessor(this), this.sendMessageExecutor);
-
- /**
- * Default
- */
- AdminBrokerProcessor adminProcessor = new AdminBrokerProcessor(this);
- this.remotingServer.registerDefaultProcessor(adminProcessor, this.adminBrokerExecutor);
- this.fastRemotingServer.registerDefaultProcessor(adminProcessor, this.adminBrokerExecutor);
- }
-
- public BrokerStats getBrokerStats() {
- return brokerStats;
- }
-
- public void setBrokerStats(BrokerStats brokerStats) {
- this.brokerStats = brokerStats;
- }
-
- public void protectBroker() {
- if (this.brokerConfig.isDisableConsumeIfConsumerReadSlowly()) {
- final Iterator<Map.Entry<String, MomentStatsItem>> it = this.brokerStatsManager.getMomentStatsItemSetFallSize().getStatsItemTable().entrySet().iterator();
- while (it.hasNext()) {
- final Map.Entry<String, MomentStatsItem> next = it.next();
- final long fallBehindBytes = next.getValue().getValue().get();
- if (fallBehindBytes > this.brokerConfig.getConsumerFallbehindThreshold()) {
- final String[] split = next.getValue().getStatsKey().split("@");
- final String group = split[2];
- LOG_PROTECTION.info("[PROTECT_BROKER] the consumer[{}] consume slowly, {} bytes, disable it", group, fallBehindBytes);
- this.subscriptionGroupManager.disableConsume(group);
- }
- }
- }
- }
-
- public long headSlowTimeMills(BlockingQueue<Runnable> q) {
- long slowTimeMills = 0;
- final Runnable peek = q.peek();
- if (peek != null) {
- RequestTask rt = BrokerFastFailure.castRunnable(peek);
- slowTimeMills = this.messageStore.now() - rt.getCreateTimestamp();
- }
-
- if (slowTimeMills < 0) slowTimeMills = 0;
-
- return slowTimeMills;
- }
-
- public long headSlowTimeMills4SendThreadPoolQueue() {
- return this.headSlowTimeMills(this.sendThreadPoolQueue);
- }
-
- public long headSlowTimeMills4PullThreadPoolQueue() {
- return this.headSlowTimeMills(this.pullThreadPoolQueue);
- }
-
- public void printWaterMark() {
- LOG_WATER_MARK.info("[WATERMARK] Send Queue Size: {} SlowTimeMills: {}", this.sendThreadPoolQueue.size(), headSlowTimeMills4SendThreadPoolQueue());
- LOG_WATER_MARK.info("[WATERMARK] Pull Queue Size: {} SlowTimeMills: {}", this.pullThreadPoolQueue.size(), headSlowTimeMills4PullThreadPoolQueue());
- }
-
- public MessageStore getMessageStore() {
- return messageStore;
- }
-
- public void setMessageStore(MessageStore messageStore) {
- this.messageStore = messageStore;
- }
-
- private void printMasterAndSlaveDiff() {
- long diff = this.messageStore.slaveFallBehindMuch();
-
- // XXX: warn and notify me
- log.info("slave fall behind master, how much, {} bytes", diff);
- }
-
- public Broker2Client getBroker2Client() {
- return broker2Client;
- }
-
- public ConsumerManager getConsumerManager() {
- return consumerManager;
- }
-
- public ConsumerOffsetManager getConsumerOffsetManager() {
- return consumerOffsetManager;
- }
-
- public MessageStoreConfig getMessageStoreConfig() {
- return messageStoreConfig;
- }
-
- public ProducerManager getProducerManager() {
- return producerManager;
- }
-
- public void setFastRemotingServer(RemotingServer fastRemotingServer) {
- this.fastRemotingServer = fastRemotingServer;
- }
-
- public PullMessageProcessor getPullMessageProcessor() {
- return pullMessageProcessor;
- }
-
- public PullRequestHoldService getPullRequestHoldService() {
- return pullRequestHoldService;
- }
-
- public SubscriptionGroupManager getSubscriptionGroupManager() {
- return subscriptionGroupManager;
- }
-
- public void shutdown() {
- if (this.brokerStatsManager != null) {
- this.brokerStatsManager.shutdown();
- }
-
- if (this.clientHousekeepingService != null) {
- this.clientHousekeepingService.shutdown();
- }
-
- if (this.pullRequestHoldService != null) {
- this.pullRequestHoldService.shutdown();
- }
-
- if (this.remotingServer != null) {
- this.remotingServer.shutdown();
- }
-
- if (this.fastRemotingServer != null) {
- this.fastRemotingServer.shutdown();
- }
-
- if (this.messageStore != null) {
- this.messageStore.shutdown();
- }
-
- this.scheduledExecutorService.shutdown();
- try {
- this.scheduledExecutorService.awaitTermination(5000, TimeUnit.MILLISECONDS);
- } catch (InterruptedException e) {
- }
-
- this.unregisterBrokerAll();
-
- if (this.sendMessageExecutor != null) {
- this.sendMessageExecutor.shutdown();
- }
-
- if (this.pullMessageExecutor != null) {
- this.pullMessageExecutor.shutdown();
- }
-
- if (this.adminBrokerExecutor != null) {
- this.adminBrokerExecutor.shutdown();
- }
-
- if (this.brokerOuterAPI != null) {
- this.brokerOuterAPI.shutdown();
- }
-
- this.consumerOffsetManager.persist();
-
- if (this.filterServerManager != null) {
- this.filterServerManager.shutdown();
- }
-
- if (this.brokerFastFailure != null) {
- this.brokerFastFailure.shutdown();
- }
- }
-
- private void unregisterBrokerAll() {
- this.brokerOuterAPI.unregisterBrokerAll(
- this.brokerConfig.getBrokerClusterName(),
- this.getBrokerAddr(),
- this.brokerConfig.getBrokerName(),
- this.brokerConfig.getBrokerId());
- }
-
- public String getBrokerAddr() {
- return this.brokerConfig.getBrokerIP1() + ":" + this.nettyServerConfig.getListenPort();
- }
-
- public void start() throws Exception {
- if (this.messageStore != null) {
- this.messageStore.start();
- }
-
- if (this.remotingServer != null) {
- this.remotingServer.start();
- }
-
- if (this.fastRemotingServer != null) {
- this.fastRemotingServer.start();
- }
-
- if (this.brokerOuterAPI != null) {
- this.brokerOuterAPI.start();
- }
-
- if (this.pullRequestHoldService != null) {
- this.pullRequestHoldService.start();
- }
-
- if (this.clientHousekeepingService != null) {
- this.clientHousekeepingService.start();
- }
-
- if (this.filterServerManager != null) {
- this.filterServerManager.start();
- }
-
- this.registerBrokerAll(true, false);
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
-
- @Override
- public void run() {
- try {
- BrokerController.this.registerBrokerAll(true, false);
- } catch (Throwable e) {
- log.error("registerBrokerAll Exception", e);
- }
- }
- }, 1000 * 10, 1000 * 30, TimeUnit.MILLISECONDS);
-
- if (this.brokerStatsManager != null) {
- this.brokerStatsManager.start();
- }
-
- if (this.brokerFastFailure != null) {
- this.brokerFastFailure.start();
- }
- }
-
- public synchronized void registerBrokerAll(final boolean checkOrderConfig, boolean oneway) {
- TopicConfigSerializeWrapper topicConfigWrapper = this.getTopicConfigManager().buildTopicConfigSerializeWrapper();
-
- if (!PermName.isWriteable(this.getBrokerConfig().getBrokerPermission())
- || !PermName.isReadable(this.getBrokerConfig().getBrokerPermission())) {
- ConcurrentHashMap<String, TopicConfig> topicConfigTable = new ConcurrentHashMap<String, TopicConfig>();
- for (TopicConfig topicConfig : topicConfigWrapper.getTopicConfigTable().values()) {
- TopicConfig tmp =
- new TopicConfig(topicConfig.getTopicName(), topicConfig.getReadQueueNums(), topicConfig.getWriteQueueNums(),
- this.brokerConfig.getBrokerPermission());
- topicConfigTable.put(topicConfig.getTopicName(), tmp);
- }
- topicConfigWrapper.setTopicConfigTable(topicConfigTable);
- }
-
- RegisterBrokerResult registerBrokerResult = this.brokerOuterAPI.registerBrokerAll(
- this.brokerConfig.getBrokerClusterName(),
- this.getBrokerAddr(),
- this.brokerConfig.getBrokerName(),
- this.brokerConfig.getBrokerId(),
- this.getHAServerAddr(),
- topicConfigWrapper,
- this.filterServerManager.buildNewFilterServerList(),
- oneway,
- this.brokerConfig.getRegisterBrokerTimeoutMills());
-
- if (registerBrokerResult != null) {
- if (this.updateMasterHAServerAddrPeriodically && registerBrokerResult.getHaServerAddr() != null) {
- this.messageStore.updateHaMasterAddress(registerBrokerResult.getHaServerAddr());
- }
-
- this.slaveSynchronize.setMasterAddr(registerBrokerResult.getMasterAddr());
-
- if (checkOrderConfig) {
- this.getTopicConfigManager().updateOrderTopicConfig(registerBrokerResult.getKvTable());
- }
- }
- }
-
- public TopicConfigManager getTopicConfigManager() {
- return topicConfigManager;
- }
-
- public void setTopicConfigManager(TopicConfigManager topicConfigManager) {
- this.topicConfigManager = topicConfigManager;
- }
-
- public String getHAServerAddr() {
- return this.brokerConfig.getBrokerIP2() + ":" + this.messageStoreConfig.getHaListenPort();
- }
-
- public RebalanceLockManager getRebalanceLockManager() {
- return rebalanceLockManager;
- }
-
- public SlaveSynchronize getSlaveSynchronize() {
- return slaveSynchronize;
- }
-
- public ExecutorService getPullMessageExecutor() {
- return pullMessageExecutor;
- }
-
- public void setPullMessageExecutor(ExecutorService pullMessageExecutor) {
- this.pullMessageExecutor = pullMessageExecutor;
- }
-
- public BlockingQueue<Runnable> getSendThreadPoolQueue() {
- return sendThreadPoolQueue;
- }
-
- public FilterServerManager getFilterServerManager() {
- return filterServerManager;
- }
-
- public BrokerStatsManager getBrokerStatsManager() {
- return brokerStatsManager;
- }
-
- public List<SendMessageHook> getSendMessageHookList() {
- return sendMessageHookList;
- }
-
- public void registerSendMessageHook(final SendMessageHook hook) {
- this.sendMessageHookList.add(hook);
- log.info("register SendMessageHook Hook, {}", hook.hookName());
- }
-
- public List<ConsumeMessageHook> getConsumeMessageHookList() {
- return consumeMessageHookList;
- }
-
- public void registerConsumeMessageHook(final ConsumeMessageHook hook) {
- this.consumeMessageHookList.add(hook);
- log.info("register ConsumeMessageHook Hook, {}", hook.hookName());
- }
-
- public void registerServerRPCHook(RPCHook rpcHook) {
- getRemotingServer().registerRPCHook(rpcHook);
- }
-
- public RemotingServer getRemotingServer() {
- return remotingServer;
- }
-
- public void setRemotingServer(RemotingServer remotingServer) {
- this.remotingServer = remotingServer;
- }
-
- public void registerClientRPCHook(RPCHook rpcHook) {
- this.getBrokerOuterAPI().registerRPCHook(rpcHook);
- }
-
- public BrokerOuterAPI getBrokerOuterAPI() {
- return brokerOuterAPI;
- }
-
- public InetSocketAddress getStoreHost() {
- return storeHost;
- }
-
- public void setStoreHost(InetSocketAddress storeHost) {
- this.storeHost = storeHost;
- }
-
- public Configuration getConfiguration() {
- return this.configuration;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/BrokerPathConfigHelper.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/BrokerPathConfigHelper.java b/broker/src/main/java/com/alibaba/rocketmq/broker/BrokerPathConfigHelper.java
deleted file mode 100644
index 055e8dc..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/BrokerPathConfigHelper.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * 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 java.io.File;
-
-
-public class BrokerPathConfigHelper {
- private static String brokerConfigPath = System.getProperty("user.home") + File.separator + "store"
- + File.separator + "config" + File.separator + "broker.properties";
-
-
- public static String getBrokerConfigPath() {
- return brokerConfigPath;
- }
-
-
- public static void setBrokerConfigPath(String path) {
- brokerConfigPath = path;
- }
-
-
- public static String getTopicConfigPath(final String rootDir) {
- return rootDir + File.separator + "config" + File.separator + "topics.json";
- }
-
-
- public static String getConsumerOffsetPath(final String rootDir) {
- return rootDir + File.separator + "config" + File.separator + "consumerOffset.json";
- }
-
-
- public static String getSubscriptionGroupPath(final String rootDir) {
- return rootDir + File.separator + "config" + File.separator + "subscriptionGroup.json";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/BrokerStartup.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/BrokerStartup.java b/broker/src/main/java/com/alibaba/rocketmq/broker/BrokerStartup.java
deleted file mode 100644
index 7e81117..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/BrokerStartup.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/**
- * 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 ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.joran.JoranConfigurator;
-import com.alibaba.rocketmq.common.BrokerConfig;
-import com.alibaba.rocketmq.common.MQVersion;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.remoting.common.RemotingUtil;
-import com.alibaba.rocketmq.remoting.netty.NettyClientConfig;
-import com.alibaba.rocketmq.remoting.netty.NettyServerConfig;
-import com.alibaba.rocketmq.remoting.netty.NettySystemConfig;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import com.alibaba.rocketmq.srvutil.ServerUtil;
-import com.alibaba.rocketmq.store.config.BrokerRole;
-import com.alibaba.rocketmq.store.config.MessageStoreConfig;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.PosixParser;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicInteger;
-
-
-/**
- * @author shijia.wxr
- */
-public class BrokerStartup {
- public static Properties properties = null;
- public static CommandLine commandLine = null;
- public static String configFile = null;
- public static Logger log;
-
- public static void main(String[] args) {
- start(createBrokerController(args));
- }
-
- public static BrokerController start(BrokerController controller) {
- try {
- controller.start();
- String tip = "The broker[" + controller.getBrokerConfig().getBrokerName() + ", "
- + controller.getBrokerAddr() + "] boot success. serializeType=" + RemotingCommand.getSerializeTypeConfigInThisServer();
-
- if (null != controller.getBrokerConfig().getNamesrvAddr()) {
- tip += " and name server is " + controller.getBrokerConfig().getNamesrvAddr();
- }
-
- log.info(tip);
- return controller;
- } catch (Throwable e) {
- e.printStackTrace();
- System.exit(-1);
- }
-
- return null;
- }
-
- public static BrokerController createBrokerController(String[] args) {
- System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));
-
- if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE)) {
- NettySystemConfig.socketSndbufSize = 131072;
- }
-
- if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE)) {
- NettySystemConfig.socketRcvbufSize = 131072;
- }
-
- try {
- //PackageConflictDetect.detectFastjson();
- Options options = ServerUtil.buildCommandlineOptions(new Options());
- commandLine = ServerUtil.parseCmdLine("mqbroker", args, buildCommandlineOptions(options),
- new PosixParser());
- if (null == commandLine) {
- System.exit(-1);
- }
-
- final BrokerConfig brokerConfig = new BrokerConfig();
- final NettyServerConfig nettyServerConfig = new NettyServerConfig();
- final NettyClientConfig nettyClientConfig = new NettyClientConfig();
- nettyServerConfig.setListenPort(10911);
- final MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
-
- if (BrokerRole.SLAVE == messageStoreConfig.getBrokerRole()) {
- int ratio = messageStoreConfig.getAccessMessageInMemoryMaxRatio() - 10;
- messageStoreConfig.setAccessMessageInMemoryMaxRatio(ratio);
- }
-
- if (commandLine.hasOption('p')) {
- MixAll.printObjectProperties(null, brokerConfig);
- MixAll.printObjectProperties(null, nettyServerConfig);
- MixAll.printObjectProperties(null, nettyClientConfig);
- MixAll.printObjectProperties(null, messageStoreConfig);
- System.exit(0);
- } else if (commandLine.hasOption('m')) {
- MixAll.printObjectProperties(null, brokerConfig, true);
- MixAll.printObjectProperties(null, nettyServerConfig, true);
- MixAll.printObjectProperties(null, nettyClientConfig, true);
- MixAll.printObjectProperties(null, messageStoreConfig, true);
- System.exit(0);
- }
-
- if (commandLine.hasOption('c')) {
- String file = commandLine.getOptionValue('c');
- if (file != null) {
- configFile = file;
- InputStream in = new BufferedInputStream(new FileInputStream(file));
- properties = new Properties();
- properties.load(in);
-
- parsePropertie2SystemEnv(properties);
- MixAll.properties2Object(properties, brokerConfig);
- MixAll.properties2Object(properties, nettyServerConfig);
- MixAll.properties2Object(properties, nettyClientConfig);
- MixAll.properties2Object(properties, messageStoreConfig);
-
- BrokerPathConfigHelper.setBrokerConfigPath(file);
- in.close();
- }
- }
-
- MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), brokerConfig);
-
- if (null == brokerConfig.getRocketmqHome()) {
- System.out.printf("Please set the " + MixAll.ROCKETMQ_HOME_ENV
- + " variable in your environment to match the location of the RocketMQ installation");
- System.exit(-2);
- }
-
- String namesrvAddr = brokerConfig.getNamesrvAddr();
- if (null != namesrvAddr) {
- try {
- String[] addrArray = namesrvAddr.split(";");
- if (addrArray != null) {
- for (String addr : addrArray) {
- RemotingUtil.string2SocketAddress(addr);
- }
- }
- } catch (Exception e) {
- System.out.printf(
- "The Name Server Address[%s] illegal, please set it as follows, \"127.0.0.1:9876;192.168.0.1:9876\"%n",
- namesrvAddr);
- System.exit(-3);
- }
- }
-
-
- switch (messageStoreConfig.getBrokerRole()) {
- case ASYNC_MASTER:
- case SYNC_MASTER:
- brokerConfig.setBrokerId(MixAll.MASTER_ID);
- break;
- case SLAVE:
- if (brokerConfig.getBrokerId() <= 0) {
- System.out.printf("Slave's brokerId must be > 0");
- System.exit(-3);
- }
-
- break;
- default:
- break;
- }
-
- messageStoreConfig.setHaListenPort(nettyServerConfig.getListenPort() + 1);
- LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
- JoranConfigurator configurator = new JoranConfigurator();
- configurator.setContext(lc);
- lc.reset();
- configurator.doConfigure(brokerConfig.getRocketmqHome() + "/conf/logback_broker.xml");
- log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
-
- MixAll.printObjectProperties(log, brokerConfig);
- MixAll.printObjectProperties(log, nettyServerConfig);
- MixAll.printObjectProperties(log, nettyClientConfig);
- MixAll.printObjectProperties(log, messageStoreConfig);
-
- final BrokerController controller = new BrokerController(//
- brokerConfig, //
- nettyServerConfig, //
- nettyClientConfig, //
- messageStoreConfig);
- // remember all configs to prevent discard
- controller.getConfiguration().registerConfig(properties);
-
- boolean initResult = controller.initialize();
- if (!initResult) {
- controller.shutdown();
- System.exit(-3);
- }
-
- Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
- private volatile boolean hasShutdown = false;
- private AtomicInteger shutdownTimes = new AtomicInteger(0);
-
- @Override
- public void run() {
- synchronized (this) {
- log.info("shutdown hook was invoked, " + this.shutdownTimes.incrementAndGet());
- if (!this.hasShutdown) {
- this.hasShutdown = true;
- long begineTime = System.currentTimeMillis();
- controller.shutdown();
- long consumingTimeTotal = System.currentTimeMillis() - begineTime;
- log.info("shutdown hook over, consuming time total(ms): " + consumingTimeTotal);
- }
- }
- }
- }, "ShutdownHook"));
-
- return controller;
- } catch (Throwable e) {
- e.printStackTrace();
- System.exit(-1);
- }
-
- return null;
- }
-
- private static void parsePropertie2SystemEnv(Properties properties) {
- if (properties == null) {
- return;
- }
- String rmqAddressServerDomain = properties.getProperty("rmqAddressServerDomain", "jmenv.tbsite.net");
- String rmqAddressServerSubGroup = properties.getProperty("rmqAddressServerSubGroup", "nsaddr");
- System.setProperty("rocketmq.namesrv.domain", rmqAddressServerDomain);
- System.setProperty("rocketmq.namesrv.domain.subgroup", rmqAddressServerSubGroup);
- }
-
- public static Options buildCommandlineOptions(final Options options) {
- Option opt = new Option("c", "configFile", true, "Broker config properties file");
- opt.setRequired(false);
- options.addOption(opt);
-
- opt = new Option("p", "printConfigItem", false, "Print all config item");
- opt.setRequired(false);
- options.addOption(opt);
-
- opt = new Option("m", "printImportantConfig", false, "Print important config item");
- opt.setRequired(false);
- options.addOption(opt);
-
- return options;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/client/ClientChannelInfo.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/client/ClientChannelInfo.java b/broker/src/main/java/com/alibaba/rocketmq/broker/client/ClientChannelInfo.java
deleted file mode 100644
index babf4b7..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/client/ClientChannelInfo.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * 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.client;
-
-import com.alibaba.rocketmq.remoting.protocol.LanguageCode;
-import io.netty.channel.Channel;
-
-
-/**
- * @author shijia.wxr
- */
-public class ClientChannelInfo {
- private final Channel channel;
- private final String clientId;
- private final LanguageCode language;
- private final int version;
- private volatile long lastUpdateTimestamp = System.currentTimeMillis();
-
-
- public ClientChannelInfo(Channel channel) {
- this(channel, null, null, 0);
- }
-
-
- public ClientChannelInfo(Channel channel, String clientId, LanguageCode language, int version) {
- this.channel = channel;
- this.clientId = clientId;
- this.language = language;
- this.version = version;
- }
-
-
- public Channel getChannel() {
- return channel;
- }
-
-
- public String getClientId() {
- return clientId;
- }
-
-
- public LanguageCode getLanguage() {
- return language;
- }
-
-
- public int getVersion() {
- return version;
- }
-
-
- public long getLastUpdateTimestamp() {
- return lastUpdateTimestamp;
- }
-
-
- public void setLastUpdateTimestamp(long lastUpdateTimestamp) {
- this.lastUpdateTimestamp = lastUpdateTimestamp;
- }
-
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((channel == null) ? 0 : channel.hashCode());
- result = prime * result + ((clientId == null) ? 0 : clientId.hashCode());
- result = prime * result + ((language == null) ? 0 : language.hashCode());
- result = prime * result + (int) (lastUpdateTimestamp ^ (lastUpdateTimestamp >>> 32));
- result = prime * result + version;
- return result;
- }
-
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ClientChannelInfo other = (ClientChannelInfo) obj;
- if (channel == null) {
- if (other.channel != null)
- return false;
- } else if (this.channel != other.channel) {
- return false;
- }
-
- return true;
- }
-
-
- @Override
- public String toString() {
- return "ClientChannelInfo [channel=" + channel + ", clientId=" + clientId + ", language=" + language
- + ", version=" + version + ", lastUpdateTimestamp=" + lastUpdateTimestamp + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/client/ClientHousekeepingService.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/client/ClientHousekeepingService.java b/broker/src/main/java/com/alibaba/rocketmq/broker/client/ClientHousekeepingService.java
deleted file mode 100644
index 4ac7532..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/client/ClientHousekeepingService.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * 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.client;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import com.alibaba.rocketmq.common.ThreadFactoryImpl;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.remoting.ChannelEventListener;
-import io.netty.channel.Channel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-
-/**
- * @author shijia.wxr
- */
-public class ClientHousekeepingService implements ChannelEventListener {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
- private final BrokerController brokerController;
-
- private ScheduledExecutorService scheduledExecutorService = Executors
- .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ClientHousekeepingScheduledThread"));
-
-
- public ClientHousekeepingService(final BrokerController brokerController) {
- this.brokerController = brokerController;
- }
-
-
- public void start() {
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- ClientHousekeepingService.this.scanExceptionChannel();
- } catch (Exception e) {
- log.error("", e);
- }
- }
- }, 1000 * 10, 1000 * 10, TimeUnit.MILLISECONDS);
- }
-
- private void scanExceptionChannel() {
- this.brokerController.getProducerManager().scanNotActiveChannel();
- this.brokerController.getConsumerManager().scanNotActiveChannel();
- this.brokerController.getFilterServerManager().scanNotActiveChannel();
- }
-
- public void shutdown() {
- this.scheduledExecutorService.shutdown();
- }
-
- @Override
- public void onChannelConnect(String remoteAddr, Channel channel) {
-
- }
-
-
- @Override
- public void onChannelClose(String remoteAddr, Channel channel) {
- this.brokerController.getProducerManager().doChannelCloseEvent(remoteAddr, channel);
- this.brokerController.getConsumerManager().doChannelCloseEvent(remoteAddr, channel);
- this.brokerController.getFilterServerManager().doChannelCloseEvent(remoteAddr, channel);
- }
-
-
- @Override
- public void onChannelException(String remoteAddr, Channel channel) {
- this.brokerController.getProducerManager().doChannelCloseEvent(remoteAddr, channel);
- this.brokerController.getConsumerManager().doChannelCloseEvent(remoteAddr, channel);
- this.brokerController.getFilterServerManager().doChannelCloseEvent(remoteAddr, channel);
- }
-
-
- @Override
- public void onChannelIdle(String remoteAddr, Channel channel) {
- this.brokerController.getProducerManager().doChannelCloseEvent(remoteAddr, channel);
- this.brokerController.getConsumerManager().doChannelCloseEvent(remoteAddr, channel);
- this.brokerController.getFilterServerManager().doChannelCloseEvent(remoteAddr, channel);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/client/ConsumerGroupInfo.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/client/ConsumerGroupInfo.java b/broker/src/main/java/com/alibaba/rocketmq/broker/client/ConsumerGroupInfo.java
deleted file mode 100644
index 410b703..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/client/ConsumerGroupInfo.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/**
- * 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.client;
-
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.consumer.ConsumeFromWhere;
-import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType;
-import com.alibaba.rocketmq.common.protocol.heartbeat.MessageModel;
-import com.alibaba.rocketmq.common.protocol.heartbeat.SubscriptionData;
-import io.netty.channel.Channel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-
-/**
- * @author shijia.wxr
- */
-public class ConsumerGroupInfo {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
- private final String groupName;
- private final ConcurrentHashMap<String/* Topic */, SubscriptionData> subscriptionTable =
- new ConcurrentHashMap<String, SubscriptionData>();
- private final ConcurrentHashMap<Channel, ClientChannelInfo> channelInfoTable =
- new ConcurrentHashMap<Channel, ClientChannelInfo>(16);
- private volatile ConsumeType consumeType;
- private volatile MessageModel messageModel;
- private volatile ConsumeFromWhere consumeFromWhere;
- private volatile long lastUpdateTimestamp = System.currentTimeMillis();
-
-
- public ConsumerGroupInfo(String groupName, ConsumeType consumeType, MessageModel messageModel,
- ConsumeFromWhere consumeFromWhere) {
- this.groupName = groupName;
- this.consumeType = consumeType;
- this.messageModel = messageModel;
- this.consumeFromWhere = consumeFromWhere;
- }
-
-
- public ClientChannelInfo findChannel(final String clientId) {
- Iterator<Entry<Channel, ClientChannelInfo>> it = this.channelInfoTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<Channel, ClientChannelInfo> next = it.next();
- if (next.getValue().getClientId().equals(clientId)) {
- return next.getValue();
- }
- }
-
- return null;
- }
-
-
- public ConcurrentHashMap<String, SubscriptionData> getSubscriptionTable() {
- return subscriptionTable;
- }
-
-
- public ConcurrentHashMap<Channel, ClientChannelInfo> getChannelInfoTable() {
- return channelInfoTable;
- }
-
-
- public List<Channel> getAllChannel() {
- List<Channel> result = new ArrayList<Channel>();
-
- result.addAll(this.channelInfoTable.keySet());
-
- return result;
- }
-
-
- public List<String> getAllClientId() {
- List<String> result = new ArrayList<String>();
-
- Iterator<Entry<Channel, ClientChannelInfo>> it = this.channelInfoTable.entrySet().iterator();
-
- while (it.hasNext()) {
- Entry<Channel, ClientChannelInfo> entry = it.next();
- ClientChannelInfo clientChannelInfo = entry.getValue();
- result.add(clientChannelInfo.getClientId());
- }
-
- return result;
- }
-
-
- public void unregisterChannel(final ClientChannelInfo clientChannelInfo) {
- ClientChannelInfo old = this.channelInfoTable.remove(clientChannelInfo.getChannel());
- if (old != null) {
- log.info("unregister a consumer[{}] from consumerGroupInfo {}", this.groupName, old.toString());
- }
- }
-
-
- public boolean doChannelCloseEvent(final String remoteAddr, final Channel channel) {
- final ClientChannelInfo info = this.channelInfoTable.remove(channel);
- if (info != null) {
- log.warn(
- "NETTY EVENT: remove not active channel[{}] from ConsumerGroupInfo groupChannelTable, consumer group: {}",
- info.toString(), groupName);
- return true;
- }
-
- return false;
- }
-
- public boolean updateChannel(final ClientChannelInfo infoNew, ConsumeType consumeType,
- MessageModel messageModel, ConsumeFromWhere consumeFromWhere) {
- boolean updated = false;
- this.consumeType = consumeType;
- this.messageModel = messageModel;
- this.consumeFromWhere = consumeFromWhere;
-
- ClientChannelInfo infoOld = this.channelInfoTable.get(infoNew.getChannel());
- if (null == infoOld) {
- ClientChannelInfo prev = this.channelInfoTable.put(infoNew.getChannel(), infoNew);
- if (null == prev) {
- log.info("new consumer connected, group: {} {} {} channel: {}", this.groupName, consumeType,
- messageModel, infoNew.toString());
- updated = true;
- }
-
- infoOld = infoNew;
- } else {
- if (!infoOld.getClientId().equals(infoNew.getClientId())) {
- log.error("[BUG] consumer channel exist in broker, but clientId not equal. GROUP: {} OLD: {} NEW: {} ",
- this.groupName,
- infoOld.toString(),
- infoNew.toString());
- this.channelInfoTable.put(infoNew.getChannel(), infoNew);
- }
- }
-
- this.lastUpdateTimestamp = System.currentTimeMillis();
- infoOld.setLastUpdateTimestamp(this.lastUpdateTimestamp);
-
- return updated;
- }
-
-
- public boolean updateSubscription(final Set<SubscriptionData> subList) {
- boolean updated = false;
-
- for (SubscriptionData sub : subList) {
- SubscriptionData old = this.subscriptionTable.get(sub.getTopic());
- if (old == null) {
- SubscriptionData prev = this.subscriptionTable.putIfAbsent(sub.getTopic(), sub);
- if (null == prev) {
- updated = true;
- log.info("subscription changed, add new topic, group: {} {}",
- this.groupName,
- sub.toString());
- }
- } else if (sub.getSubVersion() > old.getSubVersion()) {
- if (this.consumeType == ConsumeType.CONSUME_PASSIVELY) {
- log.info("subscription changed, group: {} OLD: {} NEW: {}",
- this.groupName,
- old.toString(),
- sub.toString()
- );
- }
-
- this.subscriptionTable.put(sub.getTopic(), sub);
- }
- }
-
-
- Iterator<Entry<String, SubscriptionData>> it = this.subscriptionTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, SubscriptionData> next = it.next();
- String oldTopic = next.getKey();
-
- boolean exist = false;
- for (SubscriptionData sub : subList) {
- if (sub.getTopic().equals(oldTopic)) {
- exist = true;
- break;
- }
- }
-
- if (!exist) {
- log.warn("subscription changed, group: {} remove topic {} {}",
- this.groupName,
- oldTopic,
- next.getValue().toString()
- );
-
- it.remove();
- updated = true;
- }
- }
-
- this.lastUpdateTimestamp = System.currentTimeMillis();
-
- return updated;
- }
-
-
- public Set<String> getSubscribeTopics() {
- return subscriptionTable.keySet();
- }
-
-
- public SubscriptionData findSubscriptionData(final String topic) {
- return this.subscriptionTable.get(topic);
- }
-
-
- public ConsumeType getConsumeType() {
- return consumeType;
- }
-
-
- public void setConsumeType(ConsumeType consumeType) {
- this.consumeType = consumeType;
- }
-
-
- public MessageModel getMessageModel() {
- return messageModel;
- }
-
-
- public void setMessageModel(MessageModel messageModel) {
- this.messageModel = messageModel;
- }
-
-
- public String getGroupName() {
- return groupName;
- }
-
-
- public long getLastUpdateTimestamp() {
- return lastUpdateTimestamp;
- }
-
-
- public void setLastUpdateTimestamp(long lastUpdateTimestamp) {
- this.lastUpdateTimestamp = lastUpdateTimestamp;
- }
-
-
- public ConsumeFromWhere getConsumeFromWhere() {
- return consumeFromWhere;
- }
-
-
- public void setConsumeFromWhere(ConsumeFromWhere consumeFromWhere) {
- this.consumeFromWhere = consumeFromWhere;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/client/ConsumerIdsChangeListener.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/client/ConsumerIdsChangeListener.java b/broker/src/main/java/com/alibaba/rocketmq/broker/client/ConsumerIdsChangeListener.java
deleted file mode 100644
index 4da2eb3..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/client/ConsumerIdsChangeListener.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 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.client;
-
-import io.netty.channel.Channel;
-
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public interface ConsumerIdsChangeListener {
- public void consumerIdsChanged(final String group, final List<Channel> channels);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/client/ConsumerManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/client/ConsumerManager.java b/broker/src/main/java/com/alibaba/rocketmq/broker/client/ConsumerManager.java
deleted file mode 100644
index 48e9673..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/client/ConsumerManager.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/**
- * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.client;
-
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.consumer.ConsumeFromWhere;
-import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType;
-import com.alibaba.rocketmq.common.protocol.heartbeat.MessageModel;
-import com.alibaba.rocketmq.common.protocol.heartbeat.SubscriptionData;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import com.alibaba.rocketmq.remoting.common.RemotingUtil;
-import io.netty.channel.Channel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-
-/**
- * @author shijia.wxr
- */
-public class ConsumerManager {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
- private static final long CHANNEL_EXPIRED_TIMEOUT = 1000 * 120;
- private final ConcurrentHashMap<String/* Group */, ConsumerGroupInfo> consumerTable =
- new ConcurrentHashMap<String, ConsumerGroupInfo>(1024);
- private final ConsumerIdsChangeListener consumerIdsChangeListener;
-
- public ConsumerManager(final ConsumerIdsChangeListener consumerIdsChangeListener) {
- this.consumerIdsChangeListener = consumerIdsChangeListener;
- }
-
- public ClientChannelInfo findChannel(final String group, final String clientId) {
- ConsumerGroupInfo consumerGroupInfo = this.consumerTable.get(group);
- if (consumerGroupInfo != null) {
- return consumerGroupInfo.findChannel(clientId);
- }
- return null;
- }
-
- public SubscriptionData findSubscriptionData(final String group, final String topic) {
- ConsumerGroupInfo consumerGroupInfo = this.getConsumerGroupInfo(group);
- if (consumerGroupInfo != null) {
- return consumerGroupInfo.findSubscriptionData(topic);
- }
-
- return null;
- }
-
- public ConsumerGroupInfo getConsumerGroupInfo(final String group) {
- return this.consumerTable.get(group);
- }
-
- public int findSubscriptionDataCount(final String group) {
- ConsumerGroupInfo consumerGroupInfo = this.getConsumerGroupInfo(group);
- if (consumerGroupInfo != null) {
- return consumerGroupInfo.getSubscriptionTable().size();
- }
-
- return 0;
- }
-
- public void doChannelCloseEvent(final String remoteAddr, final Channel channel) {
- Iterator<Entry<String, ConsumerGroupInfo>> it = this.consumerTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, ConsumerGroupInfo> next = it.next();
- ConsumerGroupInfo info = next.getValue();
- boolean removed = info.doChannelCloseEvent(remoteAddr, channel);
- if (removed) {
- if (info.getChannelInfoTable().isEmpty()) {
- ConsumerGroupInfo remove = this.consumerTable.remove(next.getKey());
- if (remove != null) {
- log.info("unregister consumer ok, no any connection, and remove consumer group, {}",
- next.getKey());
- }
- }
-
- this.consumerIdsChangeListener.consumerIdsChanged(next.getKey(), info.getAllChannel());
- }
- }
- }
-
- public boolean registerConsumer(final String group, final ClientChannelInfo clientChannelInfo,
- ConsumeType consumeType, MessageModel messageModel, ConsumeFromWhere consumeFromWhere,
- final Set<SubscriptionData> subList, boolean isNotifyConsumerIdsChangedEnable) {
-
- ConsumerGroupInfo consumerGroupInfo = this.consumerTable.get(group);
- if (null == consumerGroupInfo) {
- ConsumerGroupInfo tmp = new ConsumerGroupInfo(group, consumeType, messageModel, consumeFromWhere);
- ConsumerGroupInfo prev = this.consumerTable.putIfAbsent(group, tmp);
- consumerGroupInfo = prev != null ? prev : tmp;
- }
-
- boolean r1 =
- consumerGroupInfo.updateChannel(clientChannelInfo, consumeType, messageModel,
- consumeFromWhere);
- boolean r2 = consumerGroupInfo.updateSubscription(subList);
-
- if (r1 || r2) {
- if (isNotifyConsumerIdsChangedEnable) {
- this.consumerIdsChangeListener.consumerIdsChanged(group, consumerGroupInfo.getAllChannel());
- }
- }
-
- return r1 || r2;
- }
-
- public void unregisterConsumer(final String group, final ClientChannelInfo clientChannelInfo, boolean isNotifyConsumerIdsChangedEnable) {
- ConsumerGroupInfo consumerGroupInfo = this.consumerTable.get(group);
- if (null != consumerGroupInfo) {
- consumerGroupInfo.unregisterChannel(clientChannelInfo);
- if (consumerGroupInfo.getChannelInfoTable().isEmpty()) {
- ConsumerGroupInfo remove = this.consumerTable.remove(group);
- if (remove != null) {
- log.info("unregister consumer ok, no any connection, and remove consumer group, {}", group);
- }
- }
- if (isNotifyConsumerIdsChangedEnable) {
- this.consumerIdsChangeListener.consumerIdsChanged(group, consumerGroupInfo.getAllChannel());
- }
- }
- }
-
- public void scanNotActiveChannel() {
- Iterator<Entry<String, ConsumerGroupInfo>> it = this.consumerTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, ConsumerGroupInfo> next = it.next();
- String group = next.getKey();
- ConsumerGroupInfo consumerGroupInfo = next.getValue();
- ConcurrentHashMap<Channel, ClientChannelInfo> channelInfoTable =
- consumerGroupInfo.getChannelInfoTable();
-
- Iterator<Entry<Channel, ClientChannelInfo>> itChannel = channelInfoTable.entrySet().iterator();
- while (itChannel.hasNext()) {
- Entry<Channel, ClientChannelInfo> nextChannel = itChannel.next();
- ClientChannelInfo clientChannelInfo = nextChannel.getValue();
- long diff = System.currentTimeMillis() - clientChannelInfo.getLastUpdateTimestamp();
- if (diff > CHANNEL_EXPIRED_TIMEOUT) {
- log.warn(
- "SCAN: remove expired channel from ConsumerManager consumerTable. channel={}, consumerGroup={}",
- RemotingHelper.parseChannelRemoteAddr(clientChannelInfo.getChannel()), group);
- RemotingUtil.closeChannel(clientChannelInfo.getChannel());
- itChannel.remove();
- }
- }
-
- if (channelInfoTable.isEmpty()) {
- log.warn(
- "SCAN: remove expired channel from ConsumerManager consumerTable, all clear, consumerGroup={}",
- group);
- it.remove();
- }
- }
- }
-
- public HashSet<String> queryTopicConsumeByWho(final String topic) {
- HashSet<String> groups = new HashSet<String>();
- Iterator<Entry<String, ConsumerGroupInfo>> it = this.consumerTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, ConsumerGroupInfo> entry = it.next();
- ConcurrentHashMap<String, SubscriptionData> subscriptionTable =
- entry.getValue().getSubscriptionTable();
- if (subscriptionTable.containsKey(topic)) {
- groups.add(entry.getKey());
- }
- }
- return groups;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java b/broker/src/main/java/com/alibaba/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java
deleted file mode 100644
index 0095913..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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.client;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import io.netty.channel.Channel;
-
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public class DefaultConsumerIdsChangeListener implements ConsumerIdsChangeListener {
- private final BrokerController brokerController;
-
-
- public DefaultConsumerIdsChangeListener(BrokerController brokerController) {
- this.brokerController = brokerController;
- }
-
-
- @Override
- public void consumerIdsChanged(String group, List<Channel> channels) {
- if (channels != null && brokerController.getBrokerConfig().isNotifyConsumerIdsChangedEnable()) {
- for (Channel chl : channels) {
- this.brokerController.getBroker2Client().notifyConsumerIdsChanged(chl, group);
- }
- }
- }
-}
[88/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
index 3e6673c..5fdcab2 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
@@ -16,6 +16,13 @@
*/
package org.apache.rocketmq.client.impl;
+import java.nio.ByteBuffer;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import org.apache.rocketmq.client.QueryResult;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
@@ -25,7 +32,12 @@ import org.apache.rocketmq.client.log.ClientLogger;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.TopicConfig;
import org.apache.rocketmq.common.help.FAQUrl;
-import org.apache.rocketmq.common.message.*;
+import org.apache.rocketmq.common.message.MessageClientIDSetter;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageDecoder;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageId;
+import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.ResponseCode;
import org.apache.rocketmq.common.protocol.header.QueryMessageRequestHeader;
import org.apache.rocketmq.common.protocol.header.QueryMessageResponseHeader;
@@ -39,42 +51,28 @@ import org.apache.rocketmq.remoting.netty.ResponseFuture;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.slf4j.Logger;
-import java.nio.ByteBuffer;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-
public class MQAdminImpl {
private final Logger log = ClientLogger.getLog();
private final MQClientInstance mQClientFactory;
private long timeoutMillis = 6000;
-
public MQAdminImpl(MQClientInstance mQClientFactory) {
this.mQClientFactory = mQClientFactory;
}
-
public long getTimeoutMillis() {
return timeoutMillis;
}
-
public void setTimeoutMillis(long timeoutMillis) {
this.timeoutMillis = timeoutMillis;
}
-
public void createTopic(String key, String newTopic, int queueNum) throws MQClientException {
createTopic(key, newTopic, queueNum, 0);
}
-
public void createTopic(String key, String newTopic, int queueNum, int topicSysFlag) throws MQClientException {
try {
TopicRouteData topicRouteData = this.mQClientFactory.getMQClientAPIImpl().getTopicRouteInfoFromNameServer(key, timeoutMillis);
@@ -129,7 +127,6 @@ public class MQAdminImpl {
}
}
-
public List<MessageQueue> fetchPublishMessageQueues(String topic) throws MQClientException {
try {
TopicRouteData topicRouteData = this.mQClientFactory.getMQClientAPIImpl().getTopicRouteInfoFromNameServer(topic, timeoutMillis);
@@ -146,7 +143,6 @@ public class MQAdminImpl {
throw new MQClientException("Unknow why, Can not find Message Queue for this topic, " + topic, null);
}
-
public Set<MessageQueue> fetchSubscribeMessageQueues(String topic) throws MQClientException {
try {
TopicRouteData topicRouteData = this.mQClientFactory.getMQClientAPIImpl().getTopicRouteInfoFromNameServer(topic, timeoutMillis);
@@ -160,14 +156,13 @@ public class MQAdminImpl {
}
} catch (Exception e) {
throw new MQClientException(
- "Can not find Message Queue for this topic, " + topic + FAQUrl.suggestTodo(FAQUrl.MQLIST_NOT_EXIST), //
- e);
+ "Can not find Message Queue for this topic, " + topic + FAQUrl.suggestTodo(FAQUrl.MQLIST_NOT_EXIST), //
+ e);
}
throw new MQClientException("Unknow why, Can not find Message Queue for this topic, " + topic, null);
}
-
public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
if (null == brokerAddr) {
@@ -178,7 +173,7 @@ public class MQAdminImpl {
if (brokerAddr != null) {
try {
return this.mQClientFactory.getMQClientAPIImpl().searchOffset(brokerAddr, mq.getTopic(), mq.getQueueId(), timestamp,
- timeoutMillis);
+ timeoutMillis);
} catch (Exception e) {
throw new MQClientException("Invoke Broker[" + brokerAddr + "] exception", e);
}
@@ -187,7 +182,6 @@ public class MQAdminImpl {
throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
}
-
public long maxOffset(MessageQueue mq) throws MQClientException {
String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
if (null == brokerAddr) {
@@ -206,7 +200,6 @@ public class MQAdminImpl {
throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
}
-
public long minOffset(MessageQueue mq) throws MQClientException {
String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
if (null == brokerAddr) {
@@ -225,7 +218,6 @@ public class MQAdminImpl {
throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
}
-
public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
if (null == brokerAddr) {
@@ -236,7 +228,7 @@ public class MQAdminImpl {
if (brokerAddr != null) {
try {
return this.mQClientFactory.getMQClientAPIImpl().getEarliestMsgStoretime(brokerAddr, mq.getTopic(), mq.getQueueId(),
- timeoutMillis);
+ timeoutMillis);
} catch (Exception e) {
throw new MQClientException("Invoke Broker[" + brokerAddr + "] exception", e);
}
@@ -254,18 +246,18 @@ public class MQAdminImpl {
throw new MQClientException(ResponseCode.NO_MESSAGE, "query message by id finished, but no message.");
}
return this.mQClientFactory.getMQClientAPIImpl().viewMessage(RemotingUtil.socketAddress2String(messageId.getAddress()),
- messageId.getOffset(), timeoutMillis);
+ messageId.getOffset(), timeoutMillis);
}
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end) throws MQClientException,
- InterruptedException {
+ InterruptedException {
return queryMessage(topic, key, maxNum, begin, end, false);
}
public MessageExt queryMessageByUniqKey(String topic, String uniqKey) throws InterruptedException, MQClientException {
QueryResult qr = this.queryMessage(topic, uniqKey, 32,
- MessageClientIDSetter.getNearlyTimeFromID(uniqKey).getTime() - 1000, Long.MAX_VALUE, true);
+ MessageClientIDSetter.getNearlyTimeFromID(uniqKey).getTime() - 1000, Long.MAX_VALUE, true);
if (qr != null && qr.getMessageList() != null && qr.getMessageList().size() > 0) {
return qr.getMessageList().get(0);
} else {
@@ -274,7 +266,7 @@ public class MQAdminImpl {
}
protected QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end, boolean isUniqKey) throws MQClientException,
- InterruptedException {
+ InterruptedException {
TopicRouteData topicRouteData = this.mQClientFactory.getAnExistTopicRouteData(topic);
if (null == topicRouteData) {
this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic);
@@ -304,43 +296,43 @@ public class MQAdminImpl {
requestHeader.setEndTimestamp(end);
this.mQClientFactory.getMQClientAPIImpl().queryMessage(addr, requestHeader, timeoutMillis * 3,
- new InvokeCallback() {
- @Override
- public void operationComplete(ResponseFuture responseFuture) {
- try {
- RemotingCommand response = responseFuture.getResponseCommand();
- if (response != null) {
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- QueryMessageResponseHeader responseHeader = null;
- try {
- responseHeader =
- (QueryMessageResponseHeader) response
- .decodeCommandCustomHeader(QueryMessageResponseHeader.class);
- } catch (RemotingCommandException e) {
- log.error("decodeCommandCustomHeader exception", e);
- return;
- }
-
- List<MessageExt> wrappers =
- MessageDecoder.decodes(ByteBuffer.wrap(response.getBody()), true);
-
- QueryResult qr = new QueryResult(responseHeader.getIndexLastUpdateTimestamp(), wrappers);
- queryResultList.add(qr);
- break;
+ new InvokeCallback() {
+ @Override
+ public void operationComplete(ResponseFuture responseFuture) {
+ try {
+ RemotingCommand response = responseFuture.getResponseCommand();
+ if (response != null) {
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ QueryMessageResponseHeader responseHeader = null;
+ try {
+ responseHeader =
+ (QueryMessageResponseHeader)response
+ .decodeCommandCustomHeader(QueryMessageResponseHeader.class);
+ } catch (RemotingCommandException e) {
+ log.error("decodeCommandCustomHeader exception", e);
+ return;
}
- default:
- log.warn("getResponseCommand failed, {} {}", response.getCode(), response.getRemark());
- break;
+
+ List<MessageExt> wrappers =
+ MessageDecoder.decodes(ByteBuffer.wrap(response.getBody()), true);
+
+ QueryResult qr = new QueryResult(responseHeader.getIndexLastUpdateTimestamp(), wrappers);
+ queryResultList.add(qr);
+ break;
}
- } else {
- log.warn("getResponseCommand return null");
+ default:
+ log.warn("getResponseCommand failed, {} {}", response.getCode(), response.getRemark());
+ break;
}
- } finally {
- countDownLatch.countDown();
+ } else {
+ log.warn("getResponseCommand return null");
}
+ } finally {
+ countDownLatch.countDown();
}
- }, isUniqKey);
+ }
+ }, isUniqKey);
} catch (Exception e) {
log.warn("queryMessage exception", e);
}
[91/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
index c493c70..6a34a69 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
@@ -16,6 +16,7 @@
*/
package org.apache.rocketmq.broker.processor;
+import io.netty.channel.ChannelHandlerContext;
import org.apache.rocketmq.broker.BrokerController;
import org.apache.rocketmq.common.TopicFilterType;
import org.apache.rocketmq.common.constant.LoggerName;
@@ -33,11 +34,9 @@ import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.apache.rocketmq.store.MessageExtBrokerInner;
import org.apache.rocketmq.store.MessageStore;
import org.apache.rocketmq.store.PutMessageResult;
-import io.netty.channel.ChannelHandlerContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
public class EndTransactionProcessor implements NettyRequestProcessor {
private static final Logger LOGGER = LoggerFactory.getLogger(LoggerName.TRANSACTION_LOGGER_NAME);
private final BrokerController brokerController;
@@ -50,36 +49,35 @@ public class EndTransactionProcessor implements NettyRequestProcessor {
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final EndTransactionRequestHeader requestHeader =
- (EndTransactionRequestHeader) request.decodeCommandCustomHeader(EndTransactionRequestHeader.class);
-
+ (EndTransactionRequestHeader)request.decodeCommandCustomHeader(EndTransactionRequestHeader.class);
if (requestHeader.getFromTransactionCheck()) {
switch (requestHeader.getCommitOrRollback()) {
case MessageSysFlag.TRANSACTION_NOT_TYPE: {
LOGGER.warn("check producer[{}] transaction state, but it's pending status."
- + "RequestHeader: {} Remark: {}",
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
- requestHeader.toString(),
- request.getRemark());
+ + "RequestHeader: {} Remark: {}",
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
+ requestHeader.toString(),
+ request.getRemark());
return null;
}
case MessageSysFlag.TRANSACTION_COMMIT_TYPE: {
LOGGER.warn("check producer[{}] transaction state, the producer commit the message."
- + "RequestHeader: {} Remark: {}",
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
- requestHeader.toString(),
- request.getRemark());
+ + "RequestHeader: {} Remark: {}",
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
+ requestHeader.toString(),
+ request.getRemark());
break;
}
case MessageSysFlag.TRANSACTION_ROLLBACK_TYPE: {
LOGGER.warn("check producer[{}] transaction state, the producer rollback the message."
- + "RequestHeader: {} Remark: {}",
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
- requestHeader.toString(),
- request.getRemark());
+ + "RequestHeader: {} Remark: {}",
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
+ requestHeader.toString(),
+ request.getRemark());
break;
}
default:
@@ -89,10 +87,10 @@ public class EndTransactionProcessor implements NettyRequestProcessor {
switch (requestHeader.getCommitOrRollback()) {
case MessageSysFlag.TRANSACTION_NOT_TYPE: {
LOGGER.warn("the producer[{}] end transaction in sending message, and it's pending status."
- + "RequestHeader: {} Remark: {}",
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
- requestHeader.toString(),
- request.getRemark());
+ + "RequestHeader: {} Remark: {}",
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
+ requestHeader.toString(),
+ request.getRemark());
return null;
}
@@ -102,10 +100,10 @@ public class EndTransactionProcessor implements NettyRequestProcessor {
case MessageSysFlag.TRANSACTION_ROLLBACK_TYPE: {
LOGGER.warn("the producer[{}] end transaction in sending message, rollback the message."
- + "RequestHeader: {} Remark: {}",
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
- requestHeader.toString(),
- request.getRemark());
+ + "RequestHeader: {} Remark: {}",
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
+ requestHeader.toString(),
+ request.getRemark());
break;
}
default:
@@ -210,8 +208,8 @@ public class EndTransactionProcessor implements NettyRequestProcessor {
MessageAccessor.setProperties(msgInner, msgExt.getProperties());
TopicFilterType topicFilterType =
- (msgInner.getSysFlag() & MessageSysFlag.MULTI_TAGS_FLAG) == MessageSysFlag.MULTI_TAGS_FLAG ? TopicFilterType.MULTI_TAG
- : TopicFilterType.SINGLE_TAG;
+ (msgInner.getSysFlag() & MessageSysFlag.MULTI_TAGS_FLAG) == MessageSysFlag.MULTI_TAGS_FLAG ? TopicFilterType.MULTI_TAG
+ : TopicFilterType.SINGLE_TAG;
long tagsCodeValue = MessageExtBrokerInner.tagsString2tagsCode(topicFilterType, msgInner.getTags());
msgInner.setTagsCode(tagsCodeValue);
msgInner.setPropertiesString(MessageDecoder.messageProperties2String(msgExt.getProperties()));
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java
index 67e55a4..2a6482c 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java
@@ -6,36 +6,33 @@
* (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
+ * 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.
+ * 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.broker.processor;
+import io.netty.channel.ChannelHandlerContext;
import org.apache.rocketmq.broker.BrokerController;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-import io.netty.channel.ChannelHandlerContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
public class ForwardRequestProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final BrokerController brokerController;
-
public ForwardRequestProcessor(final BrokerController brokerController) {
this.brokerController = brokerController;
}
-
@Override
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) {
return null;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
index 041037f..7169b9c 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
@@ -16,6 +16,13 @@
*/
package org.apache.rocketmq.broker.processor;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelFutureListener;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.FileRegion;
+import java.nio.ByteBuffer;
+import java.util.List;
import org.apache.rocketmq.broker.BrokerController;
import org.apache.rocketmq.broker.client.ConsumerGroupInfo;
import org.apache.rocketmq.broker.longpolling.PullRequest;
@@ -49,14 +56,9 @@ import org.apache.rocketmq.store.MessageExtBrokerInner;
import org.apache.rocketmq.store.PutMessageResult;
import org.apache.rocketmq.store.config.BrokerRole;
import org.apache.rocketmq.store.stats.BrokerStatsManager;
-import io.netty.channel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.nio.ByteBuffer;
-import java.util.List;
-
-
public class PullMessageProcessor implements NettyRequestProcessor {
private static final Logger LOG = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final BrokerController brokerController;
@@ -77,12 +79,11 @@ public class PullMessageProcessor implements NettyRequestProcessor {
}
private RemotingCommand processRequest(final Channel channel, RemotingCommand request, boolean brokerAllowSuspend)
- throws RemotingCommandException {
+ throws RemotingCommandException {
RemotingCommand response = RemotingCommand.createResponseCommand(PullMessageResponseHeader.class);
- final PullMessageResponseHeader responseHeader = (PullMessageResponseHeader) response.readCustomHeader();
+ final PullMessageResponseHeader responseHeader = (PullMessageResponseHeader)response.readCustomHeader();
final PullMessageRequestHeader requestHeader =
- (PullMessageRequestHeader) request.decodeCommandCustomHeader(PullMessageRequestHeader.class);
-
+ (PullMessageRequestHeader)request.decodeCommandCustomHeader(PullMessageRequestHeader.class);
response.setOpaque(request.getOpaque());
@@ -90,24 +91,21 @@ public class PullMessageProcessor implements NettyRequestProcessor {
LOG.debug("receive PullMessage request command, " + request);
}
-
if (!PermName.isReadable(this.brokerController.getBrokerConfig().getBrokerPermission())) {
response.setCode(ResponseCode.NO_PERMISSION);
response.setRemark("the broker[" + this.brokerController.getBrokerConfig().getBrokerIP1() + "] pulling message is forbidden");
return response;
}
-
SubscriptionGroupConfig subscriptionGroupConfig =
- this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(requestHeader.getConsumerGroup());
+ this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(requestHeader.getConsumerGroup());
if (null == subscriptionGroupConfig) {
response.setCode(ResponseCode.SUBSCRIPTION_GROUP_NOT_EXIST);
response.setRemark("subscription group not exist, " + requestHeader.getConsumerGroup() + " "
- + FAQUrl.suggestTodo(FAQUrl.SUBSCRIPTION_GROUP_NOT_EXIST));
+ + FAQUrl.suggestTodo(FAQUrl.SUBSCRIPTION_GROUP_NOT_EXIST));
return response;
}
-
if (!subscriptionGroupConfig.isConsumeEnable()) {
response.setCode(ResponseCode.NO_PERMISSION);
response.setRemark("subscription group no permission, " + requestHeader.getConsumerGroup());
@@ -120,49 +118,45 @@ public class PullMessageProcessor implements NettyRequestProcessor {
final long suspendTimeoutMillisLong = hasSuspendFlag ? requestHeader.getSuspendTimeoutMillis() : 0;
-
TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(requestHeader.getTopic());
if (null == topicConfig) {
LOG.error("the topic " + requestHeader.getTopic() + " not exist, consumer: " + RemotingHelper.parseChannelRemoteAddr(channel));
response.setCode(ResponseCode.TOPIC_NOT_EXIST);
response.setRemark(
- "topic[" + requestHeader.getTopic() + "] not exist, apply first please!" + FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
+ "topic[" + requestHeader.getTopic() + "] not exist, apply first please!" + FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
return response;
}
-
if (!PermName.isReadable(topicConfig.getPerm())) {
response.setCode(ResponseCode.NO_PERMISSION);
response.setRemark("the topic[" + requestHeader.getTopic() + "] pulling message is forbidden");
return response;
}
-
if (requestHeader.getQueueId() < 0 || requestHeader.getQueueId() >= topicConfig.getReadQueueNums()) {
String errorInfo = "queueId[" + requestHeader.getQueueId() + "] is illagal,Topic :" + requestHeader.getTopic()
- + " topicConfig.readQueueNums: " + topicConfig.getReadQueueNums() + " consumer: " + channel.remoteAddress();
+ + " topicConfig.readQueueNums: " + topicConfig.getReadQueueNums() + " consumer: " + channel.remoteAddress();
LOG.warn(errorInfo);
response.setCode(ResponseCode.SYSTEM_ERROR);
response.setRemark(errorInfo);
return response;
}
-
SubscriptionData subscriptionData = null;
if (hasSubscriptionFlag) {
try {
subscriptionData = FilterAPI.buildSubscriptionData(requestHeader.getConsumerGroup(), requestHeader.getTopic(),
- requestHeader.getSubscription());
+ requestHeader.getSubscription());
} catch (Exception e) {
LOG.warn("parse the consumer's subscription[{}] failed, group: {}", requestHeader.getSubscription(), //
- requestHeader.getConsumerGroup());
+ requestHeader.getConsumerGroup());
response.setCode(ResponseCode.SUBSCRIPTION_PARSE_FAILED);
response.setRemark("parse the consumer's subscription failed");
return response;
}
} else {
ConsumerGroupInfo consumerGroupInfo =
- this.brokerController.getConsumerManager().getConsumerGroupInfo(requestHeader.getConsumerGroup());
+ this.brokerController.getConsumerManager().getConsumerGroupInfo(requestHeader.getConsumerGroup());
if (null == consumerGroupInfo) {
LOG.warn("the consumer's group info not exist, group: {}", requestHeader.getConsumerGroup());
response.setCode(ResponseCode.SUBSCRIPTION_NOT_EXIST);
@@ -171,7 +165,7 @@ public class PullMessageProcessor implements NettyRequestProcessor {
}
if (!subscriptionGroupConfig.isConsumeBroadcastEnable() //
- && consumerGroupInfo.getMessageModel() == MessageModel.BROADCASTING) {
+ && consumerGroupInfo.getMessageModel() == MessageModel.BROADCASTING) {
response.setCode(ResponseCode.NO_PERMISSION);
response.setRemark("the consumer group[" + requestHeader.getConsumerGroup() + "] can not consume by broadcast way");
return response;
@@ -185,10 +179,9 @@ public class PullMessageProcessor implements NettyRequestProcessor {
return response;
}
-
if (subscriptionData.getSubVersion() < requestHeader.getSubVersion()) {
LOG.warn("the broker's subscription is not latest, group: {} {}", requestHeader.getConsumerGroup(),
- subscriptionData.getSubString());
+ subscriptionData.getSubString());
response.setCode(ResponseCode.SUBSCRIPTION_NOT_LATEST);
response.setRemark("the consumer's subscription not latest");
return response;
@@ -196,15 +189,14 @@ public class PullMessageProcessor implements NettyRequestProcessor {
}
final GetMessageResult getMessageResult =
- this.brokerController.getMessageStore().getMessage(requestHeader.getConsumerGroup(), requestHeader.getTopic(),
- requestHeader.getQueueId(), requestHeader.getQueueOffset(), requestHeader.getMaxMsgNums(), subscriptionData);
+ this.brokerController.getMessageStore().getMessage(requestHeader.getConsumerGroup(), requestHeader.getTopic(),
+ requestHeader.getQueueId(), requestHeader.getQueueOffset(), requestHeader.getMaxMsgNums(), subscriptionData);
if (getMessageResult != null) {
response.setRemark(getMessageResult.getStatus().name());
responseHeader.setNextBeginOffset(getMessageResult.getNextBeginOffset());
responseHeader.setMinOffset(getMessageResult.getMinOffset());
responseHeader.setMaxOffset(getMessageResult.getMaxOffset());
-
if (getMessageResult.isSuggestPullingFromSlave()) {
responseHeader.setSuggestWhichBrokerId(subscriptionGroupConfig.getWhichBrokerWhenConsumeSlowly());
} else {
@@ -250,11 +242,11 @@ public class PullMessageProcessor implements NettyRequestProcessor {
// XXX: warn and notify me
LOG.info("the broker store no queue data, fix the request offset {} to {}, Topic: {} QueueId: {} Consumer Group: {}", //
- requestHeader.getQueueOffset(), //
- getMessageResult.getNextBeginOffset(), //
- requestHeader.getTopic(), //
- requestHeader.getQueueId(), //
- requestHeader.getConsumerGroup()//
+ requestHeader.getQueueOffset(), //
+ getMessageResult.getNextBeginOffset(), //
+ requestHeader.getTopic(), //
+ requestHeader.getQueueId(), //
+ requestHeader.getConsumerGroup()//
);
} else {
response.setCode(ResponseCode.PULL_NOT_FOUND);
@@ -270,7 +262,7 @@ public class PullMessageProcessor implements NettyRequestProcessor {
response.setCode(ResponseCode.PULL_OFFSET_MOVED);
// XXX: warn and notify me
LOG.info("the request offset: " + requestHeader.getQueueOffset() + " over flow badly, broker max offset: "
- + getMessageResult.getMaxOffset() + ", consumer: " + channel.remoteAddress());
+ + getMessageResult.getMaxOffset() + ", consumer: " + channel.remoteAddress());
break;
case OFFSET_OVERFLOW_ONE:
response.setCode(ResponseCode.PULL_NOT_FOUND);
@@ -278,8 +270,8 @@ public class PullMessageProcessor implements NettyRequestProcessor {
case OFFSET_TOO_SMALL:
response.setCode(ResponseCode.PULL_OFFSET_MOVED);
LOG.info("the request offset too small. group={}, topic={}, requestOffset={}, brokerMinOffset={}, clientIp={}",
- requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueOffset(),
- getMessageResult.getMinOffset(), channel.remoteAddress());
+ requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueOffset(),
+ getMessageResult.getMinOffset(), channel.remoteAddress());
break;
default:
assert false;
@@ -308,7 +300,6 @@ public class PullMessageProcessor implements NettyRequestProcessor {
case ResponseCode.PULL_NOT_FOUND:
if (!brokerAllowSuspend) {
-
context.setCommercialRcvStats(BrokerStatsManager.StatsType.RCV_EPOLLS);
context.setCommercialRcvTimes(1);
context.setCommercialOwner(owner);
@@ -333,23 +324,23 @@ public class PullMessageProcessor implements NettyRequestProcessor {
case ResponseCode.SUCCESS:
this.brokerController.getBrokerStatsManager().incGroupGetNums(requestHeader.getConsumerGroup(), requestHeader.getTopic(),
- getMessageResult.getMessageCount());
+ getMessageResult.getMessageCount());
this.brokerController.getBrokerStatsManager().incGroupGetSize(requestHeader.getConsumerGroup(), requestHeader.getTopic(),
- getMessageResult.getBufferTotalSize());
+ getMessageResult.getBufferTotalSize());
this.brokerController.getBrokerStatsManager().incBrokerGetNums(getMessageResult.getMessageCount());
if (this.brokerController.getBrokerConfig().isTransferMsgByHeap()) {
final long beginTimeMills = this.brokerController.getMessageStore().now();
final byte[] r = this.readGetMessageResult(getMessageResult, requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueId());
this.brokerController.getBrokerStatsManager().incGroupGetLatency(requestHeader.getConsumerGroup(),
- requestHeader.getTopic(), requestHeader.getQueueId(),
- (int) (this.brokerController.getMessageStore().now() - beginTimeMills));
+ requestHeader.getTopic(), requestHeader.getQueueId(),
+ (int)(this.brokerController.getMessageStore().now() - beginTimeMills));
response.setBody(r);
} else {
try {
FileRegion fileRegion =
- new ManyMessageTransfer(response.encodeHeader(getMessageResult.getBufferTotalSize()), getMessageResult);
+ new ManyMessageTransfer(response.encodeHeader(getMessageResult.getBufferTotalSize()), getMessageResult);
channel.writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
@@ -379,18 +370,17 @@ public class PullMessageProcessor implements NettyRequestProcessor {
long offset = requestHeader.getQueueOffset();
int queueId = requestHeader.getQueueId();
PullRequest pullRequest = new PullRequest(request, channel, pollingTimeMills,
- this.brokerController.getMessageStore().now(), offset, subscriptionData);
+ this.brokerController.getMessageStore().now(), offset, subscriptionData);
this.brokerController.getPullRequestHoldService().suspendPullRequest(topic, queueId, pullRequest);
response = null;
break;
}
-
case ResponseCode.PULL_RETRY_IMMEDIATELY:
break;
case ResponseCode.PULL_OFFSET_MOVED:
if (this.brokerController.getMessageStoreConfig().getBrokerRole() != BrokerRole.SLAVE
- || this.brokerController.getMessageStoreConfig().isOffsetCheckInSlave()) {
+ || this.brokerController.getMessageStoreConfig().isOffsetCheckInSlave()) {
MessageQueue mq = new MessageQueue();
mq.setTopic(requestHeader.getTopic());
mq.setQueueId(requestHeader.getQueueId());
@@ -403,15 +393,15 @@ public class PullMessageProcessor implements NettyRequestProcessor {
event.setOffsetNew(getMessageResult.getNextBeginOffset());
this.generateOffsetMovedEvent(event);
LOG.warn(
- "PULL_OFFSET_MOVED:correction offset. topic={}, groupId={}, requestOffset={}, newOffset={}, suggestBrokerId={}",
- requestHeader.getTopic(), requestHeader.getConsumerGroup(), event.getOffsetRequest(), event.getOffsetNew(),
- responseHeader.getSuggestWhichBrokerId());
+ "PULL_OFFSET_MOVED:correction offset. topic={}, groupId={}, requestOffset={}, newOffset={}, suggestBrokerId={}",
+ requestHeader.getTopic(), requestHeader.getConsumerGroup(), event.getOffsetRequest(), event.getOffsetNew(),
+ responseHeader.getSuggestWhichBrokerId());
} else {
responseHeader.setSuggestWhichBrokerId(subscriptionGroupConfig.getBrokerId());
response.setCode(ResponseCode.PULL_RETRY_IMMEDIATELY);
LOG.warn("PULL_OFFSET_MOVED:none correction. topic={}, groupId={}, requestOffset={}, suggestBrokerId={}",
- requestHeader.getTopic(), requestHeader.getConsumerGroup(), requestHeader.getQueueOffset(),
- responseHeader.getSuggestWhichBrokerId());
+ requestHeader.getTopic(), requestHeader.getConsumerGroup(), requestHeader.getQueueOffset(),
+ responseHeader.getSuggestWhichBrokerId());
}
break;
@@ -423,19 +413,17 @@ public class PullMessageProcessor implements NettyRequestProcessor {
response.setRemark("store getMessage return null");
}
-
boolean storeOffsetEnable = brokerAllowSuspend;
storeOffsetEnable = storeOffsetEnable && hasCommitOffsetFlag;
storeOffsetEnable = storeOffsetEnable
- && this.brokerController.getMessageStoreConfig().getBrokerRole() != BrokerRole.SLAVE;
+ && this.brokerController.getMessageStoreConfig().getBrokerRole() != BrokerRole.SLAVE;
if (storeOffsetEnable) {
this.brokerController.getConsumerOffsetManager().commitOffset(RemotingHelper.parseChannelRemoteAddr(channel),
- requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueId(), requestHeader.getCommitOffset());
+ requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueId(), requestHeader.getCommitOffset());
}
return response;
}
-
public boolean hasConsumeMessageHook() {
return consumeMessageHookList != null && !this.consumeMessageHookList.isEmpty();
}
@@ -512,7 +500,7 @@ public class PullMessageProcessor implements NettyRequestProcessor {
public void operationComplete(ChannelFuture future) throws Exception {
if (!future.isSuccess()) {
LOG.error("processRequestWrapper response to " + future.channel().remoteAddress() + " failed",
- future.cause());
+ future.cause());
LOG.error(request.toString());
LOG.error(response.toString());
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
index 0b6b775..04f206f 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
@@ -6,16 +6,20 @@
* (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
+ * 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.
+ * 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.broker.processor;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelFutureListener;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.FileRegion;
import org.apache.rocketmq.broker.BrokerController;
import org.apache.rocketmq.broker.pagecache.OneMessageTransfer;
import org.apache.rocketmq.broker.pagecache.QueryMessageTransfer;
@@ -31,28 +35,21 @@ import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.apache.rocketmq.store.QueryMessageResult;
import org.apache.rocketmq.store.SelectMappedBufferResult;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelFutureListener;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.FileRegion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
public class QueryMessageProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final BrokerController brokerController;
-
public QueryMessageProcessor(final BrokerController brokerController) {
this.brokerController = brokerController;
}
-
@Override
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
+ throws RemotingCommandException {
switch (request.getCode()) {
case RequestCode.QUERY_MESSAGE:
return this.queryMessage(ctx, request);
@@ -70,44 +67,40 @@ public class QueryMessageProcessor implements NettyRequestProcessor {
return false;
}
-
public RemotingCommand queryMessage(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
+ throws RemotingCommandException {
final RemotingCommand response =
- RemotingCommand.createResponseCommand(QueryMessageResponseHeader.class);
+ RemotingCommand.createResponseCommand(QueryMessageResponseHeader.class);
final QueryMessageResponseHeader responseHeader =
- (QueryMessageResponseHeader) response.readCustomHeader();
+ (QueryMessageResponseHeader)response.readCustomHeader();
final QueryMessageRequestHeader requestHeader =
- (QueryMessageRequestHeader) request
- .decodeCommandCustomHeader(QueryMessageRequestHeader.class);
-
+ (QueryMessageRequestHeader)request
+ .decodeCommandCustomHeader(QueryMessageRequestHeader.class);
response.setOpaque(request.getOpaque());
-
String isUniqueKey = request.getExtFields().get(MixAll.UNIQUE_MSG_QUERY_FLAG);
if (isUniqueKey != null && isUniqueKey.equals("true")) {
requestHeader.setMaxNum(this.brokerController.getMessageStoreConfig().getDefaultQueryMaxNum());
}
final QueryMessageResult queryMessageResult =
- this.brokerController.getMessageStore().queryMessage(requestHeader.getTopic(),
- requestHeader.getKey(), requestHeader.getMaxNum(), requestHeader.getBeginTimestamp(),
- requestHeader.getEndTimestamp());
+ this.brokerController.getMessageStore().queryMessage(requestHeader.getTopic(),
+ requestHeader.getKey(), requestHeader.getMaxNum(), requestHeader.getBeginTimestamp(),
+ requestHeader.getEndTimestamp());
assert queryMessageResult != null;
responseHeader.setIndexLastUpdatePhyoffset(queryMessageResult.getIndexLastUpdatePhyoffset());
responseHeader.setIndexLastUpdateTimestamp(queryMessageResult.getIndexLastUpdateTimestamp());
-
if (queryMessageResult.getBufferTotalSize() > 0) {
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
try {
FileRegion fileRegion =
- new QueryMessageTransfer(response.encodeHeader(queryMessageResult
- .getBufferTotalSize()), queryMessageResult);
+ new QueryMessageTransfer(response.encodeHeader(queryMessageResult
+ .getBufferTotalSize()), queryMessageResult);
ctx.channel().writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
@@ -130,26 +123,24 @@ public class QueryMessageProcessor implements NettyRequestProcessor {
return response;
}
-
public RemotingCommand viewMessageById(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
+ throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final ViewMessageRequestHeader requestHeader =
- (ViewMessageRequestHeader) request.decodeCommandCustomHeader(ViewMessageRequestHeader.class);
-
+ (ViewMessageRequestHeader)request.decodeCommandCustomHeader(ViewMessageRequestHeader.class);
response.setOpaque(request.getOpaque());
final SelectMappedBufferResult selectMappedBufferResult =
- this.brokerController.getMessageStore().selectOneMessageByOffset(requestHeader.getOffset());
+ this.brokerController.getMessageStore().selectOneMessageByOffset(requestHeader.getOffset());
if (selectMappedBufferResult != null) {
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
try {
FileRegion fileRegion =
- new OneMessageTransfer(response.encodeHeader(selectMappedBufferResult.getSize()),
- selectMappedBufferResult);
+ new OneMessageTransfer(response.encodeHeader(selectMappedBufferResult.getSize()),
+ selectMappedBufferResult);
ctx.channel().writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
index 6002df2..1b95205 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
@@ -17,11 +17,17 @@
package org.apache.rocketmq.broker.processor;
import io.netty.channel.ChannelHandlerContext;
+import java.net.SocketAddress;
+import java.util.List;
import org.apache.rocketmq.broker.BrokerController;
import org.apache.rocketmq.broker.mqtrace.ConsumeMessageContext;
import org.apache.rocketmq.broker.mqtrace.ConsumeMessageHook;
import org.apache.rocketmq.broker.mqtrace.SendMessageContext;
-import org.apache.rocketmq.common.*;
+import org.apache.rocketmq.common.MQVersion;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.TopicConfig;
+import org.apache.rocketmq.common.TopicFilterType;
+import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.constant.PermName;
import org.apache.rocketmq.common.help.FAQUrl;
import org.apache.rocketmq.common.message.MessageAccessor;
@@ -44,10 +50,6 @@ import org.apache.rocketmq.store.PutMessageResult;
import org.apache.rocketmq.store.config.StorePathConfigHelper;
import org.apache.rocketmq.store.stats.BrokerStatsManager;
-import java.net.SocketAddress;
-import java.util.List;
-
-
public class SendMessageProcessor extends AbstractSendMessageProcessor implements NettyRequestProcessor {
private List<ConsumeMessageHook> consumeMessageHookList;
@@ -80,14 +82,14 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
@Override
public boolean rejectRequest() {
return this.brokerController.getMessageStore().isOSPageCacheBusy() ||
- this.brokerController.getMessageStore().isTransientStorePoolDeficient();
+ this.brokerController.getMessageStore().isTransientStorePoolDeficient();
}
private RemotingCommand consumerSendMsgBack(final ChannelHandlerContext ctx, final RemotingCommand request)
- throws RemotingCommandException {
+ throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final ConsumerSendMsgBackRequestHeader requestHeader =
- (ConsumerSendMsgBackRequestHeader) request.decodeCommandCustomHeader(ConsumerSendMsgBackRequestHeader.class);
+ (ConsumerSendMsgBackRequestHeader)request.decodeCommandCustomHeader(ConsumerSendMsgBackRequestHeader.class);
if (this.hasConsumeMessageHook() && !UtilAll.isBlank(requestHeader.getOriginMsgId())) {
@@ -101,24 +103,21 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
this.executeConsumeMessageHookAfter(context);
}
-
SubscriptionGroupConfig subscriptionGroupConfig =
- this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(requestHeader.getGroup());
+ this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(requestHeader.getGroup());
if (null == subscriptionGroupConfig) {
response.setCode(ResponseCode.SUBSCRIPTION_GROUP_NOT_EXIST);
response.setRemark("subscription group not exist, " + requestHeader.getGroup() + " "
- + FAQUrl.suggestTodo(FAQUrl.SUBSCRIPTION_GROUP_NOT_EXIST));
+ + FAQUrl.suggestTodo(FAQUrl.SUBSCRIPTION_GROUP_NOT_EXIST));
return response;
}
-
if (!PermName.isWriteable(this.brokerController.getBrokerConfig().getBrokerPermission())) {
response.setCode(ResponseCode.NO_PERMISSION);
response.setRemark("the broker[" + this.brokerController.getBrokerConfig().getBrokerIP1() + "] sending message is forbidden");
return response;
}
-
if (subscriptionGroupConfig.getRetryQueueNums() <= 0) {
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
@@ -128,24 +127,21 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
String newTopic = MixAll.getRetryTopic(requestHeader.getGroup());
int queueIdInt = Math.abs(this.random.nextInt() % 99999999) % subscriptionGroupConfig.getRetryQueueNums();
-
int topicSysFlag = 0;
if (requestHeader.isUnitMode()) {
topicSysFlag = TopicSysFlag.buildSysFlag(false, true);
}
-
TopicConfig topicConfig = this.brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(//
- newTopic, //
- subscriptionGroupConfig.getRetryQueueNums(), //
- PermName.PERM_WRITE | PermName.PERM_READ, topicSysFlag);
+ newTopic, //
+ subscriptionGroupConfig.getRetryQueueNums(), //
+ PermName.PERM_WRITE | PermName.PERM_READ, topicSysFlag);
if (null == topicConfig) {
response.setCode(ResponseCode.SYSTEM_ERROR);
response.setRemark("topic[" + newTopic + "] not exist");
return response;
}
-
if (!PermName.isWriteable(topicConfig.getPerm())) {
response.setCode(ResponseCode.NO_PERMISSION);
response.setRemark(String.format("the topic[%s] sending message is forbidden", newTopic));
@@ -159,31 +155,27 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
return response;
}
-
final String retryTopic = msgExt.getProperty(MessageConst.PROPERTY_RETRY_TOPIC);
if (null == retryTopic) {
MessageAccessor.putProperty(msgExt, MessageConst.PROPERTY_RETRY_TOPIC, msgExt.getTopic());
}
msgExt.setWaitStoreMsgOK(false);
-
int delayLevel = requestHeader.getDelayLevel();
-
int maxReconsumeTimes = subscriptionGroupConfig.getRetryMaxTimes();
if (request.getVersion() >= MQVersion.Version.V3_4_9.ordinal()) {
maxReconsumeTimes = requestHeader.getMaxReconsumeTimes();
}
-
if (msgExt.getReconsumeTimes() >= maxReconsumeTimes//
- || delayLevel < 0) {
+ || delayLevel < 0) {
newTopic = MixAll.getDLQTopic(requestHeader.getGroup());
queueIdInt = Math.abs(this.random.nextInt() % 99999999) % DLQ_NUMS_PER_GROUP;
topicConfig = this.brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(newTopic, //
- DLQ_NUMS_PER_GROUP, //
- PermName.PERM_WRITE, 0
+ DLQ_NUMS_PER_GROUP, //
+ PermName.PERM_WRITE, 0
);
if (null == topicConfig) {
response.setCode(ResponseCode.SYSTEM_ERROR);
@@ -247,13 +239,12 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
}
private RemotingCommand sendMessage(final ChannelHandlerContext ctx, //
- final RemotingCommand request, //
- final SendMessageContext sendMessageContext, //
- final SendMessageRequestHeader requestHeader) throws RemotingCommandException {
+ final RemotingCommand request, //
+ final SendMessageContext sendMessageContext, //
+ final SendMessageRequestHeader requestHeader) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(SendMessageResponseHeader.class);
- final SendMessageResponseHeader responseHeader = (SendMessageResponseHeader) response.readCustomHeader();
-
+ final SendMessageResponseHeader responseHeader = (SendMessageResponseHeader)response.readCustomHeader();
response.setOpaque(request.getOpaque());
@@ -296,15 +287,14 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
if (null != newTopic && newTopic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
String groupName = newTopic.substring(MixAll.RETRY_GROUP_TOPIC_PREFIX.length());
SubscriptionGroupConfig subscriptionGroupConfig =
- this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(groupName);
+ this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(groupName);
if (null == subscriptionGroupConfig) {
response.setCode(ResponseCode.SUBSCRIPTION_GROUP_NOT_EXIST);
response.setRemark(
- "subscription group not exist, " + groupName + " " + FAQUrl.suggestTodo(FAQUrl.SUBSCRIPTION_GROUP_NOT_EXIST));
+ "subscription group not exist, " + groupName + " " + FAQUrl.suggestTodo(FAQUrl.SUBSCRIPTION_GROUP_NOT_EXIST));
return response;
}
-
int maxReconsumeTimes = subscriptionGroupConfig.getRetryMaxTimes();
if (request.getVersion() >= MQVersion.Version.V3_4_9.ordinal()) {
maxReconsumeTimes = requestHeader.getMaxReconsumeTimes();
@@ -314,8 +304,8 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
newTopic = MixAll.getDLQTopic(groupName);
queueIdInt = Math.abs(this.random.nextInt() % 99999999) % DLQ_NUMS_PER_GROUP;
topicConfig = this.brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(newTopic, //
- DLQ_NUMS_PER_GROUP, //
- PermName.PERM_WRITE, 0
+ DLQ_NUMS_PER_GROUP, //
+ PermName.PERM_WRITE, 0
);
if (null == topicConfig) {
response.setCode(ResponseCode.SYSTEM_ERROR);
@@ -344,7 +334,7 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
if (traFlag != null) {
response.setCode(ResponseCode.NO_PERMISSION);
response.setRemark(
- "the broker[" + this.brokerController.getBrokerConfig().getBrokerIP1() + "] sending transaction message is forbidden");
+ "the broker[" + this.brokerController.getBrokerConfig().getBrokerIP1() + "] sending transaction message is forbidden");
return response;
}
}
@@ -381,12 +371,12 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
case PROPERTIES_SIZE_EXCEEDED:
response.setCode(ResponseCode.MESSAGE_ILLEGAL);
response.setRemark(
- "the message is illegal, maybe msg body or properties length not matched. msg body length limit 128k, msg properties length limit 32k.");
+ "the message is illegal, maybe msg body or properties length not matched. msg body length limit 128k, msg properties length limit 32k.");
break;
case SERVICE_NOT_AVAILABLE:
response.setCode(ResponseCode.SERVICE_NOT_AVAILABLE);
response.setRemark(
- "service not available now, maybe disk full, " + diskUtil() + ", maybe your broker machine memory too small.");
+ "service not available now, maybe disk full, " + diskUtil() + ", maybe your broker machine memory too small.");
break;
case OS_PAGECACHE_BUSY:
response.setCode(ResponseCode.SYSTEM_ERROR);
@@ -407,7 +397,7 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
this.brokerController.getBrokerStatsManager().incTopicPutNums(msgInner.getTopic());
this.brokerController.getBrokerStatsManager().incTopicPutSize(msgInner.getTopic(),
- putMessageResult.getAppendMessageResult().getWroteBytes());
+ putMessageResult.getAppendMessageResult().getWroteBytes());
this.brokerController.getBrokerStatsManager().incBrokerPutNums();
response.setRemark(null);
@@ -416,10 +406,8 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
responseHeader.setQueueId(queueIdInt);
responseHeader.setQueueOffset(putMessageResult.getAppendMessageResult().getLogicsOffset());
-
doResponse(ctx, request, response);
-
if (hasSendMessageHook()) {
sendMessageContext.setMsgId(responseHeader.getMsgId());
sendMessageContext.setQueueId(responseHeader.getQueueId());
@@ -427,7 +415,7 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
int commercialBaseCount = brokerController.getBrokerConfig().getCommercialBaseCount();
int wroteSize = putMessageResult.getAppendMessageResult().getWroteBytes();
- int incValue = (int) Math.ceil(wroteSize / BrokerStatsManager.SIZE_PER_COUNT) * commercialBaseCount;
+ int incValue = (int)Math.ceil(wroteSize / BrokerStatsManager.SIZE_PER_COUNT) * commercialBaseCount;
sendMessageContext.setCommercialSendStats(BrokerStatsManager.StatsType.SEND_SUCCESS);
sendMessageContext.setCommercialSendTimes(incValue);
@@ -438,7 +426,7 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
} else {
if (hasSendMessageHook()) {
int wroteSize = request.getBody().length;
- int incValue = (int) Math.ceil(wroteSize / BrokerStatsManager.SIZE_PER_COUNT);
+ int incValue = (int)Math.ceil(wroteSize / BrokerStatsManager.SIZE_PER_COUNT);
sendMessageContext.setCommercialSendStats(BrokerStatsManager.StatsType.SEND_FAILURE);
sendMessageContext.setCommercialSendTimes(incValue);
@@ -479,11 +467,11 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
double physicRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathPhysic);
String storePathLogis =
- StorePathConfigHelper.getStorePathConsumeQueue(this.brokerController.getMessageStoreConfig().getStorePathRootDir());
+ StorePathConfigHelper.getStorePathConsumeQueue(this.brokerController.getMessageStoreConfig().getStorePathRootDir());
double logisRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathLogis);
String storePathIndex =
- StorePathConfigHelper.getStorePathIndex(this.brokerController.getMessageStoreConfig().getStorePathRootDir());
+ StorePathConfigHelper.getStorePathIndex(this.brokerController.getMessageStoreConfig().getStorePathRootDir());
double indexRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathIndex);
return String.format("CL: %5.2f CQ: %5.2f INDEX: %5.2f", physicRatio, logisRatio, indexRatio);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java b/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
index 2db2317..2545f1f 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
@@ -6,16 +6,17 @@
* (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
+ * 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.
+ * 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.broker.slave;
+import java.io.IOException;
import org.apache.rocketmq.broker.BrokerController;
import org.apache.rocketmq.broker.subscription.SubscriptionGroupManager;
import org.apache.rocketmq.common.MixAll;
@@ -27,30 +28,23 @@ import org.apache.rocketmq.store.config.StorePathConfigHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-
-
public class SlaveSynchronize {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final BrokerController brokerController;
private volatile String masterAddr = null;
-
public SlaveSynchronize(BrokerController brokerController) {
this.brokerController = brokerController;
}
-
public String getMasterAddr() {
return masterAddr;
}
-
public void setMasterAddr(String masterAddr) {
this.masterAddr = masterAddr;
}
-
public void syncAll() {
this.syncTopicConfig();
this.syncConsumerOffset();
@@ -58,21 +52,20 @@ public class SlaveSynchronize {
this.syncSubscriptionGroupConfig();
}
-
private void syncTopicConfig() {
String masterAddrBak = this.masterAddr;
if (masterAddrBak != null) {
try {
TopicConfigSerializeWrapper topicWrapper =
- this.brokerController.getBrokerOuterAPI().getAllTopicConfig(masterAddrBak);
+ this.brokerController.getBrokerOuterAPI().getAllTopicConfig(masterAddrBak);
if (!this.brokerController.getTopicConfigManager().getDataVersion()
- .equals(topicWrapper.getDataVersion())) {
+ .equals(topicWrapper.getDataVersion())) {
this.brokerController.getTopicConfigManager().getDataVersion()
- .assignNewOne(topicWrapper.getDataVersion());
+ .assignNewOne(topicWrapper.getDataVersion());
this.brokerController.getTopicConfigManager().getTopicConfigTable().clear();
this.brokerController.getTopicConfigManager().getTopicConfigTable()
- .putAll(topicWrapper.getTopicConfigTable());
+ .putAll(topicWrapper.getTopicConfigTable());
this.brokerController.getTopicConfigManager().persist();
log.info("update slave topic config from master, {}", masterAddrBak);
@@ -83,15 +76,14 @@ public class SlaveSynchronize {
}
}
-
private void syncConsumerOffset() {
String masterAddrBak = this.masterAddr;
if (masterAddrBak != null) {
try {
ConsumerOffsetSerializeWrapper offsetWrapper =
- this.brokerController.getBrokerOuterAPI().getAllConsumerOffset(masterAddrBak);
+ this.brokerController.getBrokerOuterAPI().getAllConsumerOffset(masterAddrBak);
this.brokerController.getConsumerOffsetManager().getOffsetTable()
- .putAll(offsetWrapper.getOffsetTable());
+ .putAll(offsetWrapper.getOffsetTable());
this.brokerController.getConsumerOffsetManager().persist();
log.info("update slave consumer offset from master, {}", masterAddrBak);
} catch (Exception e) {
@@ -100,18 +92,17 @@ public class SlaveSynchronize {
}
}
-
private void syncDelayOffset() {
String masterAddrBak = this.masterAddr;
if (masterAddrBak != null) {
try {
String delayOffset =
- this.brokerController.getBrokerOuterAPI().getAllDelayOffset(masterAddrBak);
+ this.brokerController.getBrokerOuterAPI().getAllDelayOffset(masterAddrBak);
if (delayOffset != null) {
String fileName =
- StorePathConfigHelper.getDelayOffsetStorePath(this.brokerController
- .getMessageStoreConfig().getStorePathRootDir());
+ StorePathConfigHelper.getDelayOffsetStorePath(this.brokerController
+ .getMessageStoreConfig().getStorePathRootDir());
try {
MixAll.string2File(delayOffset, fileName);
} catch (IOException e) {
@@ -125,24 +116,23 @@ public class SlaveSynchronize {
}
}
-
private void syncSubscriptionGroupConfig() {
String masterAddrBak = this.masterAddr;
if (masterAddrBak != null) {
try {
SubscriptionGroupWrapper subscriptionWrapper =
- this.brokerController.getBrokerOuterAPI()
- .getAllSubscriptionGroupConfig(masterAddrBak);
+ this.brokerController.getBrokerOuterAPI()
+ .getAllSubscriptionGroupConfig(masterAddrBak);
if (!this.brokerController.getSubscriptionGroupManager().getDataVersion()
- .equals(subscriptionWrapper.getDataVersion())) {
+ .equals(subscriptionWrapper.getDataVersion())) {
SubscriptionGroupManager subscriptionGroupManager =
- this.brokerController.getSubscriptionGroupManager();
+ this.brokerController.getSubscriptionGroupManager();
subscriptionGroupManager.getDataVersion().assignNewOne(
- subscriptionWrapper.getDataVersion());
+ subscriptionWrapper.getDataVersion());
subscriptionGroupManager.getSubscriptionGroupTable().clear();
subscriptionGroupManager.getSubscriptionGroupTable().putAll(
- subscriptionWrapper.getSubscriptionGroupTable());
+ subscriptionWrapper.getSubscriptionGroupTable());
subscriptionGroupManager.persist();
log.info("update slave Subscription Group from master, {}", masterAddrBak);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java b/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java
index 7865bc7..f77249a 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java
@@ -16,6 +16,10 @@
*/
package org.apache.rocketmq.broker.subscription;
+import java.io.File;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.rocketmq.broker.BrokerController;
import org.apache.rocketmq.broker.BrokerPathConfigHelper;
import org.apache.rocketmq.common.ConfigManager;
@@ -27,25 +31,23 @@ import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-
-
public class SubscriptionGroupManager extends ConfigManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final ConcurrentHashMap<String, SubscriptionGroupConfig> subscriptionGroupTable =
- new ConcurrentHashMap<String, SubscriptionGroupConfig>(1024);
+ new ConcurrentHashMap<String, SubscriptionGroupConfig>(1024);
private final DataVersion dataVersion = new DataVersion();
private transient BrokerController brokerController;
-
public SubscriptionGroupManager() {
this.init();
}
+ public SubscriptionGroupManager(BrokerController brokerController) {
+ this.brokerController = brokerController;
+ this.init();
+ }
+
private void init() {
{
SubscriptionGroupConfig subscriptionGroupConfig = new SubscriptionGroupConfig();
@@ -94,13 +96,6 @@ public class SubscriptionGroupManager extends ConfigManager {
}
}
-
- public SubscriptionGroupManager(BrokerController brokerController) {
- this.brokerController = brokerController;
- this.init();
- }
-
-
public void updateSubscriptionGroupConfig(final SubscriptionGroupConfig config) {
SubscriptionGroupConfig old = this.subscriptionGroupTable.put(config.getGroupName(), config);
if (old != null) {
@@ -122,7 +117,6 @@ public class SubscriptionGroupManager extends ConfigManager {
}
}
-
public SubscriptionGroupConfig findSubscriptionGroupConfig(final String group) {
SubscriptionGroupConfig subscriptionGroupConfig = this.subscriptionGroupTable.get(group);
if (null == subscriptionGroupConfig) {
@@ -141,7 +135,6 @@ public class SubscriptionGroupManager extends ConfigManager {
return subscriptionGroupConfig;
}
-
@Override
public String encode() {
return this.encode(false);
@@ -181,12 +174,10 @@ public class SubscriptionGroupManager extends ConfigManager {
return subscriptionGroupTable;
}
-
public DataVersion getDataVersion() {
return dataVersion;
}
-
public void deleteSubscriptionGroupConfig(final String groupName) {
SubscriptionGroupConfig old = this.subscriptionGroupTable.remove(groupName);
if (old != null) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java b/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java
index 9e14332..e826d24 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java
@@ -16,6 +16,16 @@
*/
package org.apache.rocketmq.broker.topic;
+import java.io.File;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
import org.apache.rocketmq.broker.BrokerController;
import org.apache.rocketmq.broker.BrokerPathConfigHelper;
import org.apache.rocketmq.common.ConfigManager;
@@ -30,34 +40,20 @@ import org.apache.rocketmq.common.sysflag.TopicSysFlag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-
public class TopicConfigManager extends ConfigManager {
private static final Logger LOG = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private static final long LOCK_TIMEOUT_MILLIS = 3000;
private transient final Lock lockTopicConfigTable = new ReentrantLock();
private final ConcurrentHashMap<String, TopicConfig> topicConfigTable =
- new ConcurrentHashMap<String, TopicConfig>(1024);
+ new ConcurrentHashMap<String, TopicConfig>(1024);
private final DataVersion dataVersion = new DataVersion();
private final Set<String> systemTopicList = new HashSet<String>();
private transient BrokerController brokerController;
-
public TopicConfigManager() {
}
-
public TopicConfigManager(BrokerController brokerController) {
this.brokerController = brokerController;
{
@@ -76,9 +72,9 @@ public class TopicConfigManager extends ConfigManager {
TopicConfig topicConfig = new TopicConfig(topic);
this.systemTopicList.add(topic);
topicConfig.setReadQueueNums(this.brokerController.getBrokerConfig()
- .getDefaultTopicQueueNums());
+ .getDefaultTopicQueueNums());
topicConfig.setWriteQueueNums(this.brokerController.getBrokerConfig()
- .getDefaultTopicQueueNums());
+ .getDefaultTopicQueueNums());
int perm = PermName.PERM_INHERIT | PermName.PERM_READ | PermName.PERM_WRITE;
topicConfig.setPerm(perm);
this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig);
@@ -130,29 +126,24 @@ public class TopicConfigManager extends ConfigManager {
}
}
-
public boolean isSystemTopic(final String topic) {
return this.systemTopicList.contains(topic);
}
-
public Set<String> getSystemTopic() {
return this.systemTopicList;
}
-
public boolean isTopicCanSendMessage(final String topic) {
return !topic.equals(MixAll.DEFAULT_TOPIC);
}
-
public TopicConfig selectTopicConfig(final String topic) {
return this.topicConfigTable.get(topic);
}
-
public TopicConfig createTopicInSendMessageMethod(final String topic, final String defaultTopic,
- final String remoteAddress, final int clientDefaultTopicQueueNums, final int topicSysFlag) {
+ final String remoteAddress, final int clientDefaultTopicQueueNums, final int topicSysFlag) {
TopicConfig topicConfig = null;
boolean createNew = false;
@@ -175,8 +166,8 @@ public class TopicConfigManager extends ConfigManager {
topicConfig = new TopicConfig(topic);
int queueNums =
- clientDefaultTopicQueueNums > defaultTopicConfig.getWriteQueueNums() ? defaultTopicConfig
- .getWriteQueueNums() : clientDefaultTopicQueueNums;
+ clientDefaultTopicQueueNums > defaultTopicConfig.getWriteQueueNums() ? defaultTopicConfig
+ .getWriteQueueNums() : clientDefaultTopicQueueNums;
if (queueNums < 0) {
queueNums = 0;
@@ -191,17 +182,17 @@ public class TopicConfigManager extends ConfigManager {
topicConfig.setTopicFilterType(defaultTopicConfig.getTopicFilterType());
} else {
LOG.warn("create new topic failed, because the default topic[" + defaultTopic
- + "] no perm, " + defaultTopicConfig.getPerm() + " producer: "
- + remoteAddress);
+ + "] no perm, " + defaultTopicConfig.getPerm() + " producer: "
+ + remoteAddress);
}
} else {
LOG.warn("create new topic failed, because the default topic[" + defaultTopic
- + "] not exist." + " producer: " + remoteAddress);
+ + "] not exist." + " producer: " + remoteAddress);
}
if (topicConfig != null) {
LOG.info("create new topic by default topic[" + defaultTopic + "], " + topicConfig
- + " producer: " + remoteAddress);
+ + " producer: " + remoteAddress);
this.topicConfigTable.put(topic, topicConfig);
@@ -227,10 +218,10 @@ public class TopicConfigManager extends ConfigManager {
}
public TopicConfig createTopicInSendMessageBackMethod(
- final String topic,
- final int clientDefaultTopicQueueNums,
- final int perm,
- final int topicSysFlag) {
+ final String topic,
+ final int clientDefaultTopicQueueNums,
+ final int perm,
+ final int topicSysFlag) {
TopicConfig topicConfig = this.topicConfigTable.get(topic);
if (topicConfig != null)
return topicConfig;
@@ -282,7 +273,7 @@ public class TopicConfigManager extends ConfigManager {
}
LOG.info("update topic sys flag. oldTopicSysFlag={}, newTopicSysFlag", oldTopicSysFlag,
- topicConfig.getTopicSysFlag());
+ topicConfig.getTopicSysFlag());
this.topicConfigTable.put(topic, topicConfig);
@@ -302,7 +293,7 @@ public class TopicConfigManager extends ConfigManager {
}
LOG.info("update topic sys flag. oldTopicSysFlag={}, newTopicSysFlag", oldTopicSysFlag,
- topicConfig.getTopicSysFlag());
+ topicConfig.getTopicSysFlag());
this.topicConfigTable.put(topic, topicConfig);
@@ -326,7 +317,6 @@ public class TopicConfigManager extends ConfigManager {
this.persist();
}
-
public void updateOrderTopicConfig(final KVTable orderKVTableFromNs) {
if (orderKVTableFromNs != null && orderKVTableFromNs.getTable() != null) {
@@ -403,7 +393,7 @@ public class TopicConfigManager extends ConfigManager {
public void decode(String jsonString) {
if (jsonString != null) {
TopicConfigSerializeWrapper topicConfigSerializeWrapper =
- TopicConfigSerializeWrapper.fromJson(jsonString, TopicConfigSerializeWrapper.class);
+ TopicConfigSerializeWrapper.fromJson(jsonString, TopicConfigSerializeWrapper.class);
if (topicConfigSerializeWrapper != null) {
this.topicConfigTable.putAll(topicConfigSerializeWrapper.getTopicConfigTable());
this.dataVersion.assignNewOne(topicConfigSerializeWrapper.getDataVersion());
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionRecord.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionRecord.java b/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionRecord.java
index 68256d9..830a0c5 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionRecord.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionRecord.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.broker.transaction;
@@ -22,22 +22,18 @@ public class TransactionRecord {
private long offset;
private String producerGroup;
-
public long getOffset() {
return offset;
}
-
public void setOffset(long offset) {
this.offset = offset;
}
-
public String getProducerGroup() {
return producerGroup;
}
-
public void setProducerGroup(String producerGroup) {
this.producerGroup = producerGroup;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionStore.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionStore.java b/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionStore.java
index d6e897a..f9b56d5 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionStore.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionStore.java
@@ -6,41 +6,33 @@
* (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
+ * 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.
+ * 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.broker.transaction;
import java.util.List;
-
public interface TransactionStore {
boolean open();
-
void close();
-
boolean put(final List<TransactionRecord> trs);
-
void remove(final List<Long> pks);
-
List<TransactionRecord> traverse(final long pk, final int nums);
-
long totalRecords();
-
long minPK();
-
long maxPK();
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/transaction/jdbc/JDBCTransactionStore.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/transaction/jdbc/JDBCTransactionStore.java b/broker/src/main/java/org/apache/rocketmq/broker/transaction/jdbc/JDBCTransactionStore.java
index 4bf73d2..240e141 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/transaction/jdbc/JDBCTransactionStore.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/transaction/jdbc/JDBCTransactionStore.java
@@ -6,17 +6,27 @@
* (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
+ * 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.
+ * 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.broker.transaction.jdbc;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicLong;
import org.apache.rocketmq.broker.transaction.TransactionRecord;
import org.apache.rocketmq.broker.transaction.TransactionStore;
import org.apache.rocketmq.common.MixAll;
@@ -24,13 +34,6 @@ import org.apache.rocketmq.common.constant.LoggerName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.net.URL;
-import java.sql.*;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicLong;
-
-
public class JDBCTransactionStore implements TransactionStore {
private static final Logger log = LoggerFactory.getLogger(LoggerName.TRANSACTION_LOGGER_NAME);
private final JDBCTransactionStoreConfig jdbcTransactionStoreConfig;
@@ -50,11 +53,10 @@ public class JDBCTransactionStore implements TransactionStore {
try {
this.connection =
- DriverManager.getConnection(this.jdbcTransactionStoreConfig.getJdbcURL(), props);
+ DriverManager.getConnection(this.jdbcTransactionStoreConfig.getJdbcURL(), props);
this.connection.setAutoCommit(false);
-
if (!this.computeTotalRecords()) {
return this.createDB();
}
@@ -72,7 +74,7 @@ public class JDBCTransactionStore implements TransactionStore {
try {
Class.forName(this.jdbcTransactionStoreConfig.getJdbcDriverClass()).newInstance();
log.info("Loaded the appropriate driver, {}",
- this.jdbcTransactionStoreConfig.getJdbcDriverClass());
+ this.jdbcTransactionStoreConfig.getJdbcDriverClass());
return true;
} catch (Exception e) {
log.info("Loaded the appropriate driver Exception", e);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/transaction/jdbc/JDBCTransactionStoreConfig.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/transaction/jdbc/JDBCTransactionStoreConfig.java b/broker/src/main/java/org/apache/rocketmq/broker/transaction/jdbc/JDBCTransactionStoreConfig.java
index 5789329..86c1ec8 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/transaction/jdbc/JDBCTransactionStoreConfig.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/transaction/jdbc/JDBCTransactionStoreConfig.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.broker.transaction.jdbc;
@@ -23,42 +23,34 @@ public class JDBCTransactionStoreConfig {
private String jdbcUser = "xxx";
private String jdbcPassword = "xxx";
-
public String getJdbcDriverClass() {
return jdbcDriverClass;
}
-
public void setJdbcDriverClass(String jdbcDriverClass) {
this.jdbcDriverClass = jdbcDriverClass;
}
-
public String getJdbcURL() {
return jdbcURL;
}
-
public void setJdbcURL(String jdbcURL) {
this.jdbcURL = jdbcURL;
}
-
public String getJdbcUser() {
return jdbcUser;
}
-
public void setJdbcUser(String jdbcUser) {
this.jdbcUser = jdbcUser;
}
-
public String getJdbcPassword() {
return jdbcPassword;
}
-
public void setJdbcPassword(String jdbcPassword) {
this.jdbcPassword = jdbcPassword;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java b/broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java
index 6e7b9b0..f7675c2 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.broker;
@@ -27,9 +27,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class BrokerControllerTest {
- protected Logger logger = LoggerFactory.getLogger(BrokerControllerTest.class);
-
private static final int RESTART_NUM = 3;
+ protected Logger logger = LoggerFactory.getLogger(BrokerControllerTest.class);
/**
* Tests if the controller can be properly stopped and started.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java b/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
index 4fd7a5b..5e944d8 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: SendMessageTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
@@ -20,6 +22,8 @@
*/
package org.apache.rocketmq.broker;
+import java.io.File;
+import java.util.Random;
import org.apache.rocketmq.common.BrokerConfig;
import org.apache.rocketmq.remoting.netty.NettyClientConfig;
import org.apache.rocketmq.remoting.netty.NettyServerConfig;
@@ -30,15 +34,11 @@ import org.junit.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.util.Random;
-
public class BrokerTestHarness {
+ public final String BROKER_NAME = "TestBrokerName";
protected BrokerController brokerController = null;
-
protected Random random = new Random();
- public final String BROKER_NAME = "TestBrokerName";
protected String brokerAddr = "";
protected Logger logger = LoggerFactory.getLogger(BrokerTestHarness.class);
protected BrokerConfig brokerConfig = new BrokerConfig();
[23/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
new file mode 100644
index 0000000..b98b2a2
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
@@ -0,0 +1,114 @@
+/**
+ * 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.impl.consumer;
+
+import org.apache.rocketmq.common.message.MessageQueue;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class PullRequest {
+ private String consumerGroup;
+ private MessageQueue messageQueue;
+ private ProcessQueue processQueue;
+ private long nextOffset;
+ private boolean lockedFirst = false;
+
+ public boolean isLockedFirst() {
+ return lockedFirst;
+ }
+
+ public void setLockedFirst(boolean lockedFirst) {
+ this.lockedFirst = lockedFirst;
+ }
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+
+ public MessageQueue getMessageQueue() {
+ return messageQueue;
+ }
+
+
+ public void setMessageQueue(MessageQueue messageQueue) {
+ this.messageQueue = messageQueue;
+ }
+
+
+ public long getNextOffset() {
+ return nextOffset;
+ }
+
+
+ public void setNextOffset(long nextOffset) {
+ this.nextOffset = nextOffset;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((consumerGroup == null) ? 0 : consumerGroup.hashCode());
+ result = prime * result + ((messageQueue == null) ? 0 : messageQueue.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ PullRequest other = (PullRequest) obj;
+ if (consumerGroup == null) {
+ if (other.consumerGroup != null)
+ return false;
+ } else if (!consumerGroup.equals(other.consumerGroup))
+ return false;
+ if (messageQueue == null) {
+ if (other.messageQueue != null)
+ return false;
+ } else if (!messageQueue.equals(other.messageQueue))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "PullRequest [consumerGroup=" + consumerGroup + ", messageQueue=" + messageQueue
+ + ", nextOffset=" + nextOffset + "]";
+ }
+
+ public ProcessQueue getProcessQueue() {
+ return processQueue;
+ }
+
+
+ public void setProcessQueue(ProcessQueue processQueue) {
+ this.processQueue = processQueue;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java
new file mode 100644
index 0000000..b924472
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java
@@ -0,0 +1,55 @@
+/**
+ * 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.impl.consumer;
+
+import org.apache.rocketmq.client.consumer.PullResult;
+import org.apache.rocketmq.client.consumer.PullStatus;
+import org.apache.rocketmq.common.message.MessageExt;
+
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class PullResultExt extends PullResult {
+ private final long suggestWhichBrokerId;
+ private byte[] messageBinary;
+
+
+ public PullResultExt(PullStatus pullStatus, long nextBeginOffset, long minOffset, long maxOffset,
+ List<MessageExt> msgFoundList, final long suggestWhichBrokerId, final byte[] messageBinary) {
+ super(pullStatus, nextBeginOffset, minOffset, maxOffset, msgFoundList);
+ this.suggestWhichBrokerId = suggestWhichBrokerId;
+ this.messageBinary = messageBinary;
+ }
+
+
+ public byte[] getMessageBinary() {
+ return messageBinary;
+ }
+
+
+ public void setMessageBinary(byte[] messageBinary) {
+ this.messageBinary = messageBinary;
+ }
+
+
+ public long getSuggestWhichBrokerId() {
+ return suggestWhichBrokerId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
new file mode 100644
index 0000000..05b7cfc
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
@@ -0,0 +1,481 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.impl.consumer;
+
+import org.apache.rocketmq.client.consumer.AllocateMessageQueueStrategy;
+import org.apache.rocketmq.client.impl.FindBrokerResult;
+import org.apache.rocketmq.client.impl.factory.MQClientInstance;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.body.LockBatchRequestBody;
+import org.apache.rocketmq.common.protocol.body.UnlockBatchRequestBody;
+import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
+import org.slf4j.Logger;
+
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * Base class for rebalance algorithm
+ *
+ * @author shijia.wxr
+ */
+public abstract class RebalanceImpl {
+ protected static final Logger log = ClientLogger.getLog();
+ protected final ConcurrentHashMap<MessageQueue, ProcessQueue> processQueueTable = new ConcurrentHashMap<MessageQueue, ProcessQueue>(64);
+ protected final ConcurrentHashMap<String/* topic */, Set<MessageQueue>> topicSubscribeInfoTable =
+ new ConcurrentHashMap<String, Set<MessageQueue>>();
+ protected final ConcurrentHashMap<String /* topic */, SubscriptionData> subscriptionInner =
+ new ConcurrentHashMap<String, SubscriptionData>();
+ protected String consumerGroup;
+ protected MessageModel messageModel;
+ protected AllocateMessageQueueStrategy allocateMessageQueueStrategy;
+ protected MQClientInstance mQClientFactory;
+
+
+ public RebalanceImpl(String consumerGroup, MessageModel messageModel, AllocateMessageQueueStrategy allocateMessageQueueStrategy,
+ MQClientInstance mQClientFactory) {
+ this.consumerGroup = consumerGroup;
+ this.messageModel = messageModel;
+ this.allocateMessageQueueStrategy = allocateMessageQueueStrategy;
+ this.mQClientFactory = mQClientFactory;
+ }
+
+ public void unlock(final MessageQueue mq, final boolean oneway) {
+ FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInSubscribe(mq.getBrokerName(), MixAll.MASTER_ID, true);
+ if (findBrokerResult != null) {
+ UnlockBatchRequestBody requestBody = new UnlockBatchRequestBody();
+ requestBody.setConsumerGroup(this.consumerGroup);
+ requestBody.setClientId(this.mQClientFactory.getClientId());
+ requestBody.getMqSet().add(mq);
+
+ try {
+ this.mQClientFactory.getMQClientAPIImpl().unlockBatchMQ(findBrokerResult.getBrokerAddr(), requestBody, 1000, oneway);
+ log.warn("unlock messageQueue. group:{}, clientId:{}, mq:{}", //
+ this.consumerGroup, //
+ this.mQClientFactory.getClientId(), //
+ mq);
+ } catch (Exception e) {
+ log.error("unlockBatchMQ exception, " + mq, e);
+ }
+ }
+ }
+
+ public void unlockAll(final boolean oneway) {
+ HashMap<String, Set<MessageQueue>> brokerMqs = this.buildProcessQueueTableByBrokerName();
+
+ for (final Map.Entry<String, Set<MessageQueue>> entry : brokerMqs.entrySet()) {
+ final String brokerName = entry.getKey();
+ final Set<MessageQueue> mqs = entry.getValue();
+
+ if (mqs.isEmpty())
+ continue;
+
+ FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInSubscribe(brokerName, MixAll.MASTER_ID, true);
+ if (findBrokerResult != null) {
+ UnlockBatchRequestBody requestBody = new UnlockBatchRequestBody();
+ requestBody.setConsumerGroup(this.consumerGroup);
+ requestBody.setClientId(this.mQClientFactory.getClientId());
+ requestBody.setMqSet(mqs);
+
+ try {
+ this.mQClientFactory.getMQClientAPIImpl().unlockBatchMQ(findBrokerResult.getBrokerAddr(), requestBody, 1000, oneway);
+
+ for (MessageQueue mq : mqs) {
+ ProcessQueue processQueue = this.processQueueTable.get(mq);
+ if (processQueue != null) {
+ processQueue.setLocked(false);
+ log.info("the message queue unlock OK, Group: {} {}", this.consumerGroup, mq);
+ }
+ }
+ } catch (Exception e) {
+ log.error("unlockBatchMQ exception, " + mqs, e);
+ }
+ }
+ }
+ }
+
+ private HashMap<String/* brokerName */, Set<MessageQueue>> buildProcessQueueTableByBrokerName() {
+ HashMap<String, Set<MessageQueue>> result = new HashMap<String, Set<MessageQueue>>();
+ for (MessageQueue mq : this.processQueueTable.keySet()) {
+ Set<MessageQueue> mqs = result.get(mq.getBrokerName());
+ if (null == mqs) {
+ mqs = new HashSet<MessageQueue>();
+ result.put(mq.getBrokerName(), mqs);
+ }
+
+ mqs.add(mq);
+ }
+
+ return result;
+ }
+
+ public boolean lock(final MessageQueue mq) {
+ FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInSubscribe(mq.getBrokerName(), MixAll.MASTER_ID, true);
+ if (findBrokerResult != null) {
+ LockBatchRequestBody requestBody = new LockBatchRequestBody();
+ requestBody.setConsumerGroup(this.consumerGroup);
+ requestBody.setClientId(this.mQClientFactory.getClientId());
+ requestBody.getMqSet().add(mq);
+
+ try {
+ Set<MessageQueue> lockedMq =
+ this.mQClientFactory.getMQClientAPIImpl().lockBatchMQ(findBrokerResult.getBrokerAddr(), requestBody, 1000);
+ for (MessageQueue mmqq : lockedMq) {
+ ProcessQueue processQueue = this.processQueueTable.get(mmqq);
+ if (processQueue != null) {
+ processQueue.setLocked(true);
+ processQueue.setLastLockTimestamp(System.currentTimeMillis());
+ }
+ }
+
+ boolean lockOK = lockedMq.contains(mq);
+ log.info("the message queue lock {}, {} {}",
+ lockOK ? "OK" : "Failed",
+ this.consumerGroup,
+ mq);
+ return lockOK;
+ } catch (Exception e) {
+ log.error("lockBatchMQ exception, " + mq, e);
+ }
+ }
+
+ return false;
+ }
+
+ public void lockAll() {
+ HashMap<String, Set<MessageQueue>> brokerMqs = this.buildProcessQueueTableByBrokerName();
+
+ Iterator<Entry<String, Set<MessageQueue>>> it = brokerMqs.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, Set<MessageQueue>> entry = it.next();
+ final String brokerName = entry.getKey();
+ final Set<MessageQueue> mqs = entry.getValue();
+
+ if (mqs.isEmpty())
+ continue;
+
+ FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInSubscribe(brokerName, MixAll.MASTER_ID, true);
+ if (findBrokerResult != null) {
+ LockBatchRequestBody requestBody = new LockBatchRequestBody();
+ requestBody.setConsumerGroup(this.consumerGroup);
+ requestBody.setClientId(this.mQClientFactory.getClientId());
+ requestBody.setMqSet(mqs);
+
+ try {
+ Set<MessageQueue> lockOKMQSet =
+ this.mQClientFactory.getMQClientAPIImpl().lockBatchMQ(findBrokerResult.getBrokerAddr(), requestBody, 1000);
+
+ for (MessageQueue mq : lockOKMQSet) {
+ ProcessQueue processQueue = this.processQueueTable.get(mq);
+ if (processQueue != null) {
+ if (!processQueue.isLocked()) {
+ log.info("the message queue locked OK, Group: {} {}", this.consumerGroup, mq);
+ }
+
+ processQueue.setLocked(true);
+ processQueue.setLastLockTimestamp(System.currentTimeMillis());
+ }
+ }
+ for (MessageQueue mq : mqs) {
+ if (!lockOKMQSet.contains(mq)) {
+ ProcessQueue processQueue = this.processQueueTable.get(mq);
+ if (processQueue != null) {
+ processQueue.setLocked(false);
+ log.warn("the message queue locked Failed, Group: {} {}", this.consumerGroup, mq);
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.error("lockBatchMQ exception, " + mqs, e);
+ }
+ }
+ }
+ }
+
+ public void doRebalance(final boolean isOrder) {
+ Map<String, SubscriptionData> subTable = this.getSubscriptionInner();
+ if (subTable != null) {
+ for (final Map.Entry<String, SubscriptionData> entry : subTable.entrySet()) {
+ final String topic = entry.getKey();
+ try {
+ this.rebalanceByTopic(topic, isOrder);
+ } catch (Throwable e) {
+ if (!topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
+ log.warn("rebalanceByTopic Exception", e);
+ }
+ }
+ }
+ }
+
+ this.truncateMessageQueueNotMyTopic();
+ }
+
+ public ConcurrentHashMap<String, SubscriptionData> getSubscriptionInner() {
+ return subscriptionInner;
+ }
+
+ private void rebalanceByTopic(final String topic, final boolean isOrder) {
+ switch (messageModel) {
+ case BROADCASTING: {
+ Set<MessageQueue> mqSet = this.topicSubscribeInfoTable.get(topic);
+ if (mqSet != null) {
+ boolean changed = this.updateProcessQueueTableInRebalance(topic, mqSet, isOrder);
+ if (changed) {
+ this.messageQueueChanged(topic, mqSet, mqSet);
+ log.info("messageQueueChanged {} {} {} {}", //
+ consumerGroup, //
+ topic, //
+ mqSet, //
+ mqSet);
+ }
+ } else {
+ log.warn("doRebalance, {}, but the topic[{}] not exist.", consumerGroup, topic);
+ }
+ break;
+ }
+ case CLUSTERING: {
+ Set<MessageQueue> mqSet = this.topicSubscribeInfoTable.get(topic);
+ List<String> cidAll = this.mQClientFactory.findConsumerIdList(topic, consumerGroup);
+ if (null == mqSet) {
+ if (!topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
+ log.warn("doRebalance, {}, but the topic[{}] not exist.", consumerGroup, topic);
+ }
+ }
+
+ if (null == cidAll) {
+ log.warn("doRebalance, {} {}, get consumer id list failed", consumerGroup, topic);
+ }
+
+ if (mqSet != null && cidAll != null) {
+ List<MessageQueue> mqAll = new ArrayList<MessageQueue>();
+ mqAll.addAll(mqSet);
+
+ Collections.sort(mqAll);
+ Collections.sort(cidAll);
+
+ AllocateMessageQueueStrategy strategy = this.allocateMessageQueueStrategy;
+
+ List<MessageQueue> allocateResult = null;
+ try {
+ allocateResult = strategy.allocate(//
+ this.consumerGroup, //
+ this.mQClientFactory.getClientId(), //
+ mqAll, //
+ cidAll);
+ } catch (Throwable e) {
+ log.error("AllocateMessageQueueStrategy.allocate Exception. allocateMessageQueueStrategyName={}", strategy.getName(),
+ e);
+ return;
+ }
+
+ Set<MessageQueue> allocateResultSet = new HashSet<MessageQueue>();
+ if (allocateResult != null) {
+ allocateResultSet.addAll(allocateResult);
+ }
+
+ boolean changed = this.updateProcessQueueTableInRebalance(topic, allocateResultSet, isOrder);
+ if (changed) {
+ log.info(
+ "rebalanced result changed. allocateMessageQueueStrategyName={}, group={}, topic={}, clientId={}, mqAllSize={}, cidAllSize={}, rebalanceResultSize={}, rebalanceResultSet={}",
+ strategy.getName(), consumerGroup, topic, this.mQClientFactory.getClientId(), mqSet.size(), cidAll.size(),
+ allocateResultSet.size(), allocateResultSet);
+ this.messageQueueChanged(topic, mqSet, allocateResultSet);
+ }
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ private void truncateMessageQueueNotMyTopic() {
+ Map<String, SubscriptionData> subTable = this.getSubscriptionInner();
+
+ for (MessageQueue mq : this.processQueueTable.keySet()) {
+ if (!subTable.containsKey(mq.getTopic())) {
+
+ ProcessQueue pq = this.processQueueTable.remove(mq);
+ if (pq != null) {
+ pq.setDropped(true);
+ log.info("doRebalance, {}, truncateMessageQueueNotMyTopic remove unnecessary mq, {}", consumerGroup, mq);
+ }
+ }
+ }
+ }
+
+ private boolean updateProcessQueueTableInRebalance(final String topic, final Set<MessageQueue> mqSet, final boolean isOrder) {
+ boolean changed = false;
+
+ Iterator<Entry<MessageQueue, ProcessQueue>> it = this.processQueueTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<MessageQueue, ProcessQueue> next = it.next();
+ MessageQueue mq = next.getKey();
+ ProcessQueue pq = next.getValue();
+
+ if (mq.getTopic().equals(topic)) {
+ if (!mqSet.contains(mq)) {
+ pq.setDropped(true);
+ if (this.removeUnnecessaryMessageQueue(mq, pq)) {
+ it.remove();
+ changed = true;
+ log.info("doRebalance, {}, remove unnecessary mq, {}", consumerGroup, mq);
+ }
+ } else if (pq.isPullExpired()) {
+ switch (this.consumeType()) {
+ case CONSUME_ACTIVELY:
+ break;
+ case CONSUME_PASSIVELY:
+ pq.setDropped(true);
+ if (this.removeUnnecessaryMessageQueue(mq, pq)) {
+ it.remove();
+ changed = true;
+ log.error("[BUG]doRebalance, {}, remove unnecessary mq, {}, because pull is pause, so try to fixed it",
+ consumerGroup, mq);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ List<PullRequest> pullRequestList = new ArrayList<PullRequest>();
+ for (MessageQueue mq : mqSet) {
+ if (!this.processQueueTable.containsKey(mq)) {
+ if (isOrder && !this.lock(mq)) {
+ log.warn("doRebalance, {}, add a new mq failed, {}, because lock failed", consumerGroup, mq);
+ continue;
+ }
+
+ this.removeDirtyOffset(mq);
+ ProcessQueue pq = new ProcessQueue();
+ long nextOffset = this.computePullFromWhere(mq);
+ if (nextOffset >= 0) {
+ ProcessQueue pre = this.processQueueTable.putIfAbsent(mq, pq);
+ if (pre != null) {
+ log.info("doRebalance, {}, mq already exists, {}", consumerGroup, mq);
+ } else {
+ log.info("doRebalance, {}, add a new mq, {}", consumerGroup, mq);
+ PullRequest pullRequest = new PullRequest();
+ pullRequest.setConsumerGroup(consumerGroup);
+ pullRequest.setNextOffset(nextOffset);
+ pullRequest.setMessageQueue(mq);
+ pullRequest.setProcessQueue(pq);
+ pullRequestList.add(pullRequest);
+ changed = true;
+ }
+ } else {
+ log.warn("doRebalance, {}, add new mq failed, {}", consumerGroup, mq);
+ }
+ }
+ }
+
+ this.dispatchPullRequest(pullRequestList);
+
+ return changed;
+ }
+
+ public abstract void messageQueueChanged(final String topic, final Set<MessageQueue> mqAll, final Set<MessageQueue> mqDivided);
+
+ public abstract boolean removeUnnecessaryMessageQueue(final MessageQueue mq, final ProcessQueue pq);
+
+ public abstract ConsumeType consumeType();
+
+ public abstract void removeDirtyOffset(final MessageQueue mq);
+
+ public abstract long computePullFromWhere(final MessageQueue mq);
+
+ public abstract void dispatchPullRequest(final List<PullRequest> pullRequestList);
+
+ public void removeProcessQueue(final MessageQueue mq) {
+ ProcessQueue prev = this.processQueueTable.remove(mq);
+ if (prev != null) {
+ boolean droped = prev.isDropped();
+ prev.setDropped(true);
+ this.removeUnnecessaryMessageQueue(mq, prev);
+ log.info("Fix Offset, {}, remove unnecessary mq, {} Droped: {}", consumerGroup, mq, droped);
+ }
+ }
+
+ public ConcurrentHashMap<MessageQueue, ProcessQueue> getProcessQueueTable() {
+ return processQueueTable;
+ }
+
+
+ public ConcurrentHashMap<String, Set<MessageQueue>> getTopicSubscribeInfoTable() {
+ return topicSubscribeInfoTable;
+ }
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+
+ public MessageModel getMessageModel() {
+ return messageModel;
+ }
+
+
+ public void setMessageModel(MessageModel messageModel) {
+ this.messageModel = messageModel;
+ }
+
+
+ public AllocateMessageQueueStrategy getAllocateMessageQueueStrategy() {
+ return allocateMessageQueueStrategy;
+ }
+
+
+ public void setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy allocateMessageQueueStrategy) {
+ this.allocateMessageQueueStrategy = allocateMessageQueueStrategy;
+ }
+
+
+ public MQClientInstance getmQClientFactory() {
+ return mQClientFactory;
+ }
+
+
+ public void setmQClientFactory(MQClientInstance mQClientFactory) {
+ this.mQClientFactory = mQClientFactory;
+ }
+
+
+ public void destroy() {
+ Iterator<Entry<MessageQueue, ProcessQueue>> it = this.processQueueTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<MessageQueue, ProcessQueue> next = it.next();
+ next.getValue().setDropped(true);
+ }
+
+ this.processQueueTable.clear();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java
new file mode 100644
index 0000000..376c21c
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java
@@ -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.rocketmq.client.impl.consumer;
+
+import org.apache.rocketmq.client.consumer.AllocateMessageQueueStrategy;
+import org.apache.rocketmq.client.consumer.MessageQueueListener;
+import org.apache.rocketmq.client.impl.factory.MQClientInstance;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+
+import java.util.List;
+import java.util.Set;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class RebalancePullImpl extends RebalanceImpl {
+ private final DefaultMQPullConsumerImpl defaultMQPullConsumerImpl;
+
+
+ public RebalancePullImpl(DefaultMQPullConsumerImpl defaultMQPullConsumerImpl) {
+ this(null, null, null, null, defaultMQPullConsumerImpl);
+ }
+
+
+ public RebalancePullImpl(String consumerGroup, MessageModel messageModel, AllocateMessageQueueStrategy allocateMessageQueueStrategy,
+ MQClientInstance mQClientFactory, DefaultMQPullConsumerImpl defaultMQPullConsumerImpl) {
+ super(consumerGroup, messageModel, allocateMessageQueueStrategy, mQClientFactory);
+ this.defaultMQPullConsumerImpl = defaultMQPullConsumerImpl;
+ }
+
+ @Override
+ public void messageQueueChanged(String topic, Set<MessageQueue> mqAll, Set<MessageQueue> mqDivided) {
+ MessageQueueListener messageQueueListener = this.defaultMQPullConsumerImpl.getDefaultMQPullConsumer().getMessageQueueListener();
+ if (messageQueueListener != null) {
+ try {
+ messageQueueListener.messageQueueChanged(topic, mqAll, mqDivided);
+ } catch (Throwable e) {
+ log.error("messageQueueChanged exception", e);
+ }
+ }
+ }
+
+ @Override
+ public boolean removeUnnecessaryMessageQueue(MessageQueue mq, ProcessQueue pq) {
+ this.defaultMQPullConsumerImpl.getOffsetStore().persist(mq);
+ this.defaultMQPullConsumerImpl.getOffsetStore().removeOffset(mq);
+ return true;
+ }
+
+ @Override
+ public ConsumeType consumeType() {
+ return ConsumeType.CONSUME_ACTIVELY;
+ }
+
+ @Override
+ public void removeDirtyOffset(final MessageQueue mq) {
+ this.defaultMQPullConsumerImpl.getOffsetStore().removeOffset(mq);
+ }
+
+ @Override
+ public long computePullFromWhere(MessageQueue mq) {
+ return 0;
+ }
+
+ @Override
+ public void dispatchPullRequest(List<PullRequest> pullRequestList) {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
new file mode 100644
index 0000000..4efac01
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
@@ -0,0 +1,196 @@
+/**
+ * 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.impl.consumer;
+
+import org.apache.rocketmq.client.consumer.AllocateMessageQueueStrategy;
+import org.apache.rocketmq.client.consumer.store.OffsetStore;
+import org.apache.rocketmq.client.consumer.store.ReadOffsetType;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.impl.factory.MQClientInstance;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class RebalancePushImpl extends RebalanceImpl {
+ private final static long UNLOCK_DELAY_TIME_MILLS = Long.parseLong(System.getProperty("rocketmq.client.unlockDelayTimeMills", "20000"));
+ private final DefaultMQPushConsumerImpl defaultMQPushConsumerImpl;
+
+
+ public RebalancePushImpl(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl) {
+ this(null, null, null, null, defaultMQPushConsumerImpl);
+ }
+
+
+ public RebalancePushImpl(String consumerGroup, MessageModel messageModel, AllocateMessageQueueStrategy allocateMessageQueueStrategy,
+ MQClientInstance mQClientFactory, DefaultMQPushConsumerImpl defaultMQPushConsumerImpl) {
+ super(consumerGroup, messageModel, allocateMessageQueueStrategy, mQClientFactory);
+ this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
+ }
+
+ @Override
+ public void messageQueueChanged(String topic, Set<MessageQueue> mqAll, Set<MessageQueue> mqDivided) {
+ }
+
+ @Override
+ public boolean removeUnnecessaryMessageQueue(MessageQueue mq, ProcessQueue pq) {
+ this.defaultMQPushConsumerImpl.getOffsetStore().persist(mq);
+ this.defaultMQPushConsumerImpl.getOffsetStore().removeOffset(mq);
+ if (this.defaultMQPushConsumerImpl.isConsumeOrderly()
+ && MessageModel.CLUSTERING.equals(this.defaultMQPushConsumerImpl.messageModel())) {
+ try {
+ if (pq.getLockConsume().tryLock(1000, TimeUnit.MILLISECONDS)) {
+ try {
+ return this.unlockDelay(mq, pq);
+ } finally {
+ pq.getLockConsume().unlock();
+ }
+ } else {
+ log.warn("[WRONG]mq is consuming, so can not unlock it, {}. maybe hanged for a while, {}", //
+ mq, //
+ pq.getTryUnlockTimes());
+
+ pq.incTryUnlockTimes();
+ }
+ } catch (Exception e) {
+ log.error("removeUnnecessaryMessageQueue Exception", e);
+ }
+
+ return false;
+ }
+ return true;
+ }
+
+ private boolean unlockDelay(final MessageQueue mq, final ProcessQueue pq) {
+
+ if (pq.hasTempMessage()) {
+ log.info("[{}]unlockDelay, begin {} ", mq.hashCode(), mq);
+ this.defaultMQPushConsumerImpl.getmQClientFactory().getScheduledExecutorService().schedule(new Runnable() {
+ @Override
+ public void run() {
+ log.info("[{}]unlockDelay, execute at once {}", mq.hashCode(), mq);
+ RebalancePushImpl.this.unlock(mq, true);
+ }
+ }, UNLOCK_DELAY_TIME_MILLS, TimeUnit.MILLISECONDS);
+ } else {
+ this.unlock(mq, true);
+ }
+ return true;
+ }
+
+ @Override
+ public ConsumeType consumeType() {
+ return ConsumeType.CONSUME_PASSIVELY;
+ }
+
+ @Override
+ public void removeDirtyOffset(final MessageQueue mq) {
+ this.defaultMQPushConsumerImpl.getOffsetStore().removeOffset(mq);
+ }
+
+ @Override
+ public long computePullFromWhere(MessageQueue mq) {
+ long result = -1;
+ final ConsumeFromWhere consumeFromWhere = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer().getConsumeFromWhere();
+ final OffsetStore offsetStore = this.defaultMQPushConsumerImpl.getOffsetStore();
+ switch (consumeFromWhere) {
+ case CONSUME_FROM_LAST_OFFSET_AND_FROM_MIN_WHEN_BOOT_FIRST:
+ case CONSUME_FROM_MIN_OFFSET:
+ case CONSUME_FROM_MAX_OFFSET:
+ case CONSUME_FROM_LAST_OFFSET: {
+ long lastOffset = offsetStore.readOffset(mq, ReadOffsetType.READ_FROM_STORE);
+ if (lastOffset >= 0) {
+ result = lastOffset;
+ }
+ // First start,no offset
+ else if (-1 == lastOffset) {
+ if (mq.getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
+ result = 0L;
+ } else {
+ try {
+ result = this.mQClientFactory.getMQAdminImpl().maxOffset(mq);
+ } catch (MQClientException e) {
+ result = -1;
+ }
+ }
+ } else {
+ result = -1;
+ }
+ break;
+ }
+ case CONSUME_FROM_FIRST_OFFSET: {
+ long lastOffset = offsetStore.readOffset(mq, ReadOffsetType.READ_FROM_STORE);
+ if (lastOffset >= 0) {
+ result = lastOffset;
+ } else if (-1 == lastOffset) {
+ result = 0L;
+ } else {
+ result = -1;
+ }
+ break;
+ }
+ case CONSUME_FROM_TIMESTAMP: {
+ long lastOffset = offsetStore.readOffset(mq, ReadOffsetType.READ_FROM_STORE);
+ if (lastOffset >= 0) {
+ result = lastOffset;
+ } else if (-1 == lastOffset) {
+ if (mq.getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
+ try {
+ result = this.mQClientFactory.getMQAdminImpl().maxOffset(mq);
+ } catch (MQClientException e) {
+ result = -1;
+ }
+ } else {
+ try {
+ long timestamp = UtilAll.parseDate(this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer().getConsumeTimestamp(),
+ UtilAll.YYYY_MMDD_HHMMSS).getTime();
+ result = this.mQClientFactory.getMQAdminImpl().searchOffset(mq, timestamp);
+ } catch (MQClientException e) {
+ result = -1;
+ }
+ }
+ } else {
+ result = -1;
+ }
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ return result;
+ }
+
+ @Override
+ public void dispatchPullRequest(List<PullRequest> pullRequestList) {
+ for (PullRequest pullRequest : pullRequestList) {
+ this.defaultMQPushConsumerImpl.executePullRequestImmediately(pullRequest);
+ log.info("doRebalance, {}, add a new pull request {}", consumerGroup, pullRequest);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
new file mode 100644
index 0000000..e6059fe
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
@@ -0,0 +1,58 @@
+/**
+ * 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.impl.consumer;
+
+import org.apache.rocketmq.client.impl.factory.MQClientInstance;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.ServiceThread;
+import org.slf4j.Logger;
+
+
+/**
+ * Rebalance Service
+ *
+ * @author shijia.wxr
+ */
+public class RebalanceService extends ServiceThread {
+ private static long waitInterval =
+ Long.parseLong(System.getProperty(
+ "rocketmq.client.rebalance.waitInterval", "20000"));
+ private final Logger log = ClientLogger.getLog();
+ private final MQClientInstance mqClientFactory;
+
+ public RebalanceService(MQClientInstance mqClientFactory) {
+ this.mqClientFactory = mqClientFactory;
+ }
+
+ @Override
+ public void run() {
+ log.info(this.getServiceName() + " service started");
+
+ while (!this.isStopped()) {
+ this.waitForRunning(waitInterval);
+ this.mqClientFactory.doRebalance();
+ }
+
+ log.info(this.getServiceName() + " service end");
+ }
+
+
+ @Override
+ public String getServiceName() {
+ return RebalanceService.class.getSimpleName();
+ }
+}
[59/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Remove
duplicated email suffix.
Posted by yu...@apache.org.
ROCKETMQ-18 Remove duplicated email suffix.
Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/commit/f98b1210
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/tree/f98b1210
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/diff/f98b1210
Branch: refs/heads/master
Commit: f98b1210c848f7bd45bace81b941b6a8e4e43951
Parents: c8ee328
Author: yukon <yu...@apache.org>
Authored: Wed Dec 28 10:47:10 2016 +0800
Committer: yukon <yu...@apache.org>
Committed: Wed Dec 28 10:47:10 2016 +0800
----------------------------------------------------------------------
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f98b1210/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index c32d424..f74b5e2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -85,7 +85,7 @@
<role>architect</role>
<role>committer</role>
</roles>
- <email>vongosling@apache.org@apache.org</email>
+ <email>vongosling@apache.org</email>
<url>https://github.com/vongosling@apache.org</url>
<timezone>+8</timezone>
</developer>
@@ -180,7 +180,7 @@
<version>2.2</version>
</plugin>
<plugin>
- <groupId>com.github.vongosling@apache.org</groupId>
+ <groupId>com.github.vongosling</groupId>
<artifactId>dependency-mediator-maven-plugin</artifactId>
<version>1.0.2</version>
</plugin>
[78/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java
index 88e20d9..71ff698 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header.namesrv;
@@ -21,7 +21,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNullable;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
/**
*
*/
@@ -29,17 +28,14 @@ public class GetKVConfigResponseHeader implements CommandCustomHeader {
@CFNullable
private String value;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getValue() {
return value;
}
-
public void setValue(String value) {
this.value = value;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java
index eea086e..32a3748 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header.namesrv;
@@ -21,7 +21,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
/**
*
*/
@@ -29,17 +28,14 @@ public class GetKVListByNamespaceRequestHeader implements CommandCustomHeader {
@CFNotNull
private String namespace;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getNamespace() {
return namespace;
}
-
public void setNamespace(String namespace) {
this.namespace = namespace;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
index 4c01d53..62abaec 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: GetRouteInfoRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,22 +26,18 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class GetRouteInfoRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
index 9b192d3..a122cea 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: GetRouteInfoResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -23,7 +25,6 @@ package org.apache.rocketmq.common.protocol.header.namesrv;
import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class GetRouteInfoResponseHeader implements CommandCustomHeader {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/PutKVConfigRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/PutKVConfigRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/PutKVConfigRequestHeader.java
index 01e9a5e..bdc35bb 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/PutKVConfigRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/PutKVConfigRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header.namesrv;
@@ -21,7 +21,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class PutKVConfigRequestHeader implements CommandCustomHeader {
@CFNotNull
private String namespace;
@@ -30,37 +29,30 @@ public class PutKVConfigRequestHeader implements CommandCustomHeader {
@CFNotNull
private String value;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getNamespace() {
return namespace;
}
-
public void setNamespace(String namespace) {
this.namespace = namespace;
}
-
public String getKey() {
return key;
}
-
public void setKey(String key) {
this.key = key;
}
-
public String getValue() {
return value;
}
-
public void setValue(String value) {
this.value = value;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
index 2ac0102..dbfecb1 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: RegisterBrokerRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,7 +26,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class RegisterBrokerRequestHeader implements CommandCustomHeader {
@CFNotNull
private String brokerName;
@@ -37,57 +38,46 @@ public class RegisterBrokerRequestHeader implements CommandCustomHeader {
@CFNotNull
private Long brokerId;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getBrokerName() {
return brokerName;
}
-
public void setBrokerName(String brokerName) {
this.brokerName = brokerName;
}
-
public String getBrokerAddr() {
return brokerAddr;
}
-
public void setBrokerAddr(String brokerAddr) {
this.brokerAddr = brokerAddr;
}
-
public String getClusterName() {
return clusterName;
}
-
public void setClusterName(String clusterName) {
this.clusterName = clusterName;
}
-
public String getHaServerAddr() {
return haServerAddr;
}
-
public void setHaServerAddr(String haServerAddr) {
this.haServerAddr = haServerAddr;
}
-
public Long getBrokerId() {
return brokerId;
}
-
public void setBrokerId(Long brokerId) {
this.brokerId = brokerId;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java
index 68b26ec..2e44046 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header.namesrv;
@@ -21,7 +21,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNullable;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
/**
*
*/
@@ -31,27 +30,22 @@ public class RegisterBrokerResponseHeader implements CommandCustomHeader {
@CFNullable
private String masterAddr;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getHaServerAddr() {
return haServerAddr;
}
-
public void setHaServerAddr(String haServerAddr) {
this.haServerAddr = haServerAddr;
}
-
public String getMasterAddr() {
return masterAddr;
}
-
public void setMasterAddr(String masterAddr) {
this.masterAddr = masterAddr;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
index 9381fa9..0e04c79 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: RegisterOrderTopicRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,35 +26,29 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class RegisterOrderTopicRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
@CFNotNull
private String orderTopicString;
-
@Override
public void checkFields() throws RemotingCommandException {
// TODO Auto-generated method stub
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public String getOrderTopicString() {
return orderTopicString;
}
-
public void setOrderTopicString(String orderTopicString) {
this.orderTopicString = orderTopicString;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
index e5bdd93..9f6fd27 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: UnRegisterBrokerRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,7 +26,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class UnRegisterBrokerRequestHeader implements CommandCustomHeader {
@CFNotNull
private String brokerName;
@@ -35,47 +36,38 @@ public class UnRegisterBrokerRequestHeader implements CommandCustomHeader {
@CFNotNull
private Long brokerId;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getBrokerName() {
return brokerName;
}
-
public void setBrokerName(String brokerName) {
this.brokerName = brokerName;
}
-
public String getBrokerAddr() {
return brokerAddr;
}
-
public void setBrokerAddr(String brokerAddr) {
this.brokerAddr = brokerAddr;
}
-
public String getClusterName() {
return clusterName;
}
-
public void setClusterName(String clusterName) {
this.clusterName = clusterName;
}
-
public Long getBrokerId() {
return brokerId;
}
-
public void setBrokerId(Long brokerId) {
this.brokerId = brokerId;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java
index 3f943d7..b94146b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header.namesrv;
@@ -20,7 +20,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
/**
*
*/
@@ -28,18 +27,15 @@ public class WipeWritePermOfBrokerRequestHeader implements CommandCustomHeader {
@CFNotNull
private String brokerName;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getBrokerName() {
return brokerName;
}
-
public void setBrokerName(String brokerName) {
this.brokerName = brokerName;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java
index 83d28b6..fd22393 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header.namesrv;
@@ -20,7 +20,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
/**
*
*/
@@ -28,17 +27,14 @@ public class WipeWritePermOfBrokerResponseHeader implements CommandCustomHeader
@CFNotNull
private Integer wipeTopicCount;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public Integer getWipeTopicCount() {
return wipeTopicCount;
}
-
public void setWipeTopicCount(Integer wipeTopicCount) {
this.wipeTopicCount = wipeTopicCount;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
index 923053b..49fe045 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: ConsumeType.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -32,7 +34,6 @@ public enum ConsumeType {
this.typeCN = typeCN;
}
-
public String getTypeCN() {
return typeCN;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
index 88d9972..c2a0107 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: ConsumerData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -20,11 +22,9 @@
*/
package org.apache.rocketmq.common.protocol.heartbeat;
-import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
-
import java.util.HashSet;
import java.util.Set;
-
+import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
public class ConsumerData {
private String groupName;
@@ -34,71 +34,58 @@ public class ConsumerData {
private Set<SubscriptionData> subscriptionDataSet = new HashSet<SubscriptionData>();
private boolean unitMode;
-
public String getGroupName() {
return groupName;
}
-
public void setGroupName(String groupName) {
this.groupName = groupName;
}
-
public ConsumeType getConsumeType() {
return consumeType;
}
-
public void setConsumeType(ConsumeType consumeType) {
this.consumeType = consumeType;
}
-
public MessageModel getMessageModel() {
return messageModel;
}
-
public void setMessageModel(MessageModel messageModel) {
this.messageModel = messageModel;
}
-
public ConsumeFromWhere getConsumeFromWhere() {
return consumeFromWhere;
}
-
public void setConsumeFromWhere(ConsumeFromWhere consumeFromWhere) {
this.consumeFromWhere = consumeFromWhere;
}
-
public Set<SubscriptionData> getSubscriptionDataSet() {
return subscriptionDataSet;
}
-
public void setSubscriptionDataSet(Set<SubscriptionData> subscriptionDataSet) {
this.subscriptionDataSet = subscriptionDataSet;
}
-
public boolean isUnitMode() {
return unitMode;
}
-
public void setUnitMode(boolean isUnitMode) {
this.unitMode = isUnitMode;
}
-
@Override
public String toString() {
return "ConsumerData [groupName=" + groupName + ", consumeType=" + consumeType + ", messageModel="
- + messageModel + ", consumeFromWhere=" + consumeFromWhere + ", unitMode=" + unitMode
- + ", subscriptionDataSet=" + subscriptionDataSet + "]";
+ + messageModel + ", consumeFromWhere=" + consumeFromWhere + ", unitMode=" + unitMode
+ + ", subscriptionDataSet=" + subscriptionDataSet + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
index 20a1927..5257174 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: HeartbeatData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -20,51 +22,42 @@
*/
package org.apache.rocketmq.common.protocol.heartbeat;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.HashSet;
import java.util.Set;
-
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
public class HeartbeatData extends RemotingSerializable {
private String clientID;
private Set<ProducerData> producerDataSet = new HashSet<ProducerData>();
private Set<ConsumerData> consumerDataSet = new HashSet<ConsumerData>();
-
public String getClientID() {
return clientID;
}
-
public void setClientID(String clientID) {
this.clientID = clientID;
}
-
public Set<ProducerData> getProducerDataSet() {
return producerDataSet;
}
-
public void setProducerDataSet(Set<ProducerData> producerDataSet) {
this.producerDataSet = producerDataSet;
}
-
public Set<ConsumerData> getConsumerDataSet() {
return consumerDataSet;
}
-
public void setConsumerDataSet(Set<ConsumerData> consumerDataSet) {
this.consumerDataSet = consumerDataSet;
}
-
@Override
public String toString() {
return "HeartbeatData [clientID=" + clientID + ", producerDataSet=" + producerDataSet
- + ", consumerDataSet=" + consumerDataSet + "]";
+ + ", consumerDataSet=" + consumerDataSet + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
index 858df3f..d710502 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: MessageModel.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -40,7 +42,6 @@ public enum MessageModel {
this.modeCN = modeCN;
}
-
public String getModeCN() {
return modeCN;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
index 7d3d054..b7d4c95 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: ProducerData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -23,17 +25,14 @@ package org.apache.rocketmq.common.protocol.heartbeat;
public class ProducerData {
private String groupName;
-
public String getGroupName() {
return groupName;
}
-
public void setGroupName(String groupName) {
this.groupName = groupName;
}
-
@Override
public String toString() {
return "ProducerData [groupName=" + groupName + "]";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
index c1c9f84..8c4292a 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: SubscriptionData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -21,11 +23,9 @@
package org.apache.rocketmq.common.protocol.heartbeat;
import com.alibaba.fastjson.annotation.JSONField;
-
import java.util.HashSet;
import java.util.Set;
-
public class SubscriptionData implements Comparable<SubscriptionData> {
public final static String SUB_ALL = "*";
private boolean classFilterMode = false;
@@ -38,12 +38,10 @@ public class SubscriptionData implements Comparable<SubscriptionData> {
@JSONField(serialize = false)
private String filterClassSource;
-
public SubscriptionData() {
}
-
public SubscriptionData(String topic, String subString) {
super();
this.topic = topic;
@@ -62,62 +60,50 @@ public class SubscriptionData implements Comparable<SubscriptionData> {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public String getSubString() {
return subString;
}
-
public void setSubString(String subString) {
this.subString = subString;
}
-
public Set<String> getTagsSet() {
return tagsSet;
}
-
public void setTagsSet(Set<String> tagsSet) {
this.tagsSet = tagsSet;
}
-
public long getSubVersion() {
return subVersion;
}
-
public void setSubVersion(long subVersion) {
this.subVersion = subVersion;
}
-
public Set<Integer> getCodeSet() {
return codeSet;
}
-
public void setCodeSet(Set<Integer> codeSet) {
this.codeSet = codeSet;
}
-
public boolean isClassFilterMode() {
return classFilterMode;
}
-
public void setClassFilterMode(boolean classFilterMode) {
this.classFilterMode = classFilterMode;
}
-
@Override
public int hashCode() {
final int prime = 31;
@@ -130,7 +116,6 @@ public class SubscriptionData implements Comparable<SubscriptionData> {
return result;
}
-
@Override
public boolean equals(Object obj) {
if (this == obj)
@@ -139,7 +124,7 @@ public class SubscriptionData implements Comparable<SubscriptionData> {
return false;
if (getClass() != obj.getClass())
return false;
- SubscriptionData other = (SubscriptionData) obj;
+ SubscriptionData other = (SubscriptionData)obj;
if (classFilterMode != other.classFilterMode)
return false;
if (codeSet == null) {
@@ -167,15 +152,13 @@ public class SubscriptionData implements Comparable<SubscriptionData> {
return true;
}
-
@Override
public String toString() {
return "SubscriptionData [classFilterMode=" + classFilterMode + ", topic=" + topic + ", subString="
- + subString + ", tagsSet=" + tagsSet + ", codeSet=" + codeSet + ", subVersion=" + subVersion
- + "]";
+ + subString + ", tagsSet=" + tagsSet + ", codeSet=" + codeSet + ", subVersion=" + subVersion
+ + "]";
}
-
@Override
public int compareTo(SubscriptionData other) {
String thisValue = this.topic + "@" + this.subString;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
index 08e82b1..f79bdb5 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: BrokerData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -20,11 +22,9 @@
*/
package org.apache.rocketmq.common.protocol.route;
-import org.apache.rocketmq.common.MixAll;
-
import java.util.HashMap;
import java.util.Map;
-
+import org.apache.rocketmq.common.MixAll;
/**
*
@@ -78,7 +78,7 @@ public class BrokerData implements Comparable<BrokerData> {
return false;
if (getClass() != obj.getClass())
return false;
- BrokerData other = (BrokerData) obj;
+ BrokerData other = (BrokerData)obj;
if (brokerAddrs == null) {
if (other.brokerAddrs != null)
return false;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java
index 3c72565..3fe3e2c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: QueueData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -79,7 +81,7 @@ public class QueueData implements Comparable<QueueData> {
return false;
if (getClass() != obj.getClass())
return false;
- QueueData other = (QueueData) obj;
+ QueueData other = (QueueData)obj;
if (brokerName == null) {
if (other.brokerName != null)
return false;
@@ -99,8 +101,8 @@ public class QueueData implements Comparable<QueueData> {
@Override
public String toString() {
return "QueueData [brokerName=" + brokerName + ", readQueueNums=" + readQueueNums
- + ", writeQueueNums=" + writeQueueNums + ", perm=" + perm + ", topicSynFlag=" + topicSynFlag
- + "]";
+ + ", writeQueueNums=" + writeQueueNums + ", perm=" + perm + ", topicSynFlag=" + topicSynFlag
+ + "]";
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
index 0061c25..64d9726 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: TopicRouteData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -20,12 +22,10 @@
*/
package org.apache.rocketmq.common.protocol.route;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
-
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
public class TopicRouteData extends RemotingSerializable {
private String orderTopicConf;
@@ -33,7 +33,6 @@ public class TopicRouteData extends RemotingSerializable {
private List<BrokerData> brokerDatas;
private HashMap<String/* brokerAddr */, List<String>/* Filter Server */> filterServerTable;
-
public TopicRouteData cloneTopicRouteData() {
TopicRouteData topicRouteData = new TopicRouteData();
topicRouteData.setQueueDatas(new ArrayList<QueueData>());
@@ -56,22 +55,18 @@ public class TopicRouteData extends RemotingSerializable {
return topicRouteData;
}
-
public List<QueueData> getQueueDatas() {
return queueDatas;
}
-
public void setQueueDatas(List<QueueData> queueDatas) {
this.queueDatas = queueDatas;
}
-
public List<BrokerData> getBrokerDatas() {
return brokerDatas;
}
-
public void setBrokerDatas(List<BrokerData> brokerDatas) {
this.brokerDatas = brokerDatas;
}
@@ -111,7 +106,7 @@ public class TopicRouteData extends RemotingSerializable {
return false;
if (getClass() != obj.getClass())
return false;
- TopicRouteData other = (TopicRouteData) obj;
+ TopicRouteData other = (TopicRouteData)obj;
if (brokerDatas == null) {
if (other.brokerDatas != null)
return false;
@@ -138,6 +133,6 @@ public class TopicRouteData extends RemotingSerializable {
@Override
public String toString() {
return "TopicRouteData [orderTopicConf=" + orderTopicConf + ", queueDatas=" + queueDatas
- + ", brokerDatas=" + brokerDatas + ", filterServerTable=" + filterServerTable + "]";
+ + ", brokerDatas=" + brokerDatas + ", filterServerTable=" + filterServerTable + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/topic/OffsetMovedEvent.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/topic/OffsetMovedEvent.java b/common/src/main/java/org/apache/rocketmq/common/protocol/topic/OffsetMovedEvent.java
index df5ec71..920685c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/topic/OffsetMovedEvent.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/topic/OffsetMovedEvent.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.topic;
@@ -20,57 +20,47 @@ package org.apache.rocketmq.common.protocol.topic;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
public class OffsetMovedEvent extends RemotingSerializable {
private String consumerGroup;
private MessageQueue messageQueue;
private long offsetRequest;
private long offsetNew;
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public MessageQueue getMessageQueue() {
return messageQueue;
}
-
public void setMessageQueue(MessageQueue messageQueue) {
this.messageQueue = messageQueue;
}
-
public long getOffsetRequest() {
return offsetRequest;
}
-
public void setOffsetRequest(long offsetRequest) {
this.offsetRequest = offsetRequest;
}
-
public long getOffsetNew() {
return offsetNew;
}
-
public void setOffsetNew(long offsetNew) {
this.offsetNew = offsetNew;
}
-
@Override
public String toString() {
return "OffsetMovedEvent [consumerGroup=" + consumerGroup + ", messageQueue=" + messageQueue
- + ", offsetRequest=" + offsetRequest + ", offsetNew=" + offsetNew + "]";
+ + ", offsetRequest=" + offsetRequest + ", offsetNew=" + offsetNew + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java b/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java
index 897988f..021ba83 100644
--- a/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java
+++ b/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java
@@ -6,26 +6,24 @@
* (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
+ * 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.
+ * 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.common.queue;
-import org.apache.rocketmq.common.constant.LoggerName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.locks.ReentrantLock;
-
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* thread safe
@@ -37,14 +35,12 @@ public class ConcurrentTreeMap<K, V> {
private TreeMap<K, V> tree;
private RoundQueue<K> roundQueue;
-
public ConcurrentTreeMap(int capacity, Comparator<? super K> comparator) {
tree = new TreeMap<K, V>(comparator);
roundQueue = new RoundQueue<K>(capacity);
lock = new ReentrantLock(true);
}
-
public Map.Entry<K, V> pollFirstEntry() {
lock.lock();
try {
@@ -54,7 +50,6 @@ public class ConcurrentTreeMap<K, V> {
}
}
-
public V putIfAbsentAndRetExsit(K key, V value) {
lock.lock();
try {
@@ -66,9 +61,7 @@ public class ConcurrentTreeMap<K, V> {
}
log.warn("putIfAbsentAndRetExsit success. {}", key);
return exsit;
- }
-
- else {
+ } else {
V exsit = tree.get(key);
return exsit;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.java b/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.java
index 11168e6..e9f2177 100644
--- a/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.java
+++ b/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.queue;
@@ -20,7 +20,6 @@ package org.apache.rocketmq.common.queue;
import java.util.LinkedList;
import java.util.Queue;
-
/**
* not thread safe
*
@@ -30,13 +29,11 @@ public class RoundQueue<E> {
private Queue<E> queue;
private int capacity;
-
public RoundQueue(int capacity) {
this.capacity = capacity;
queue = new LinkedList<E>();
}
-
public boolean put(E e) {
boolean ok = false;
if (!queue.contains(e)) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/running/RunningStats.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/running/RunningStats.java b/common/src/main/java/org/apache/rocketmq/common/running/RunningStats.java
index 106d111..6cfd4bf 100644
--- a/common/src/main/java/org/apache/rocketmq/common/running/RunningStats.java
+++ b/common/src/main/java/org/apache/rocketmq/common/running/RunningStats.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.running;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItem.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItem.java b/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItem.java
index 58eedb2..b9fcfb8 100644
--- a/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItem.java
+++ b/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItem.java
@@ -17,13 +17,11 @@
package org.apache.rocketmq.common.stats;
-import org.apache.rocketmq.common.UtilAll;
-import org.slf4j.Logger;
-
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
-
+import org.apache.rocketmq.common.UtilAll;
+import org.slf4j.Logger;
public class MomentStatsItem {
@@ -34,16 +32,14 @@ public class MomentStatsItem {
private final ScheduledExecutorService scheduledExecutorService;
private final Logger log;
-
public MomentStatsItem(String statsName, String statsKey,
- ScheduledExecutorService scheduledExecutorService, Logger log) {
+ ScheduledExecutorService scheduledExecutorService, Logger log) {
this.statsName = statsName;
this.statsKey = statsKey;
this.scheduledExecutorService = scheduledExecutorService;
this.log = log;
}
-
public void init() {
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
@@ -58,24 +54,21 @@ public class MomentStatsItem {
}, Math.abs(UtilAll.computNextMinutesTimeMillis() - System.currentTimeMillis()), 1000 * 60 * 5, TimeUnit.MILLISECONDS);
}
-
public void printAtMinutes() {
log.info(String.format("[%s] [%s] Stats Every 5 Minutes, Value: %d",
- this.statsName,
- this.statsKey,
- this.value.get()));
+ this.statsName,
+ this.statsKey,
+ this.value.get()));
}
public AtomicLong getValue() {
return value;
}
-
public String getStatsKey() {
return statsKey;
}
-
public String getStatsName() {
return statsName;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItemSet.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItemSet.java b/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItemSet.java
index aba61c7..44cc603 100644
--- a/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItemSet.java
+++ b/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItemSet.java
@@ -17,24 +17,21 @@
package org.apache.rocketmq.common.stats;
-import org.apache.rocketmq.common.UtilAll;
-import org.slf4j.Logger;
-
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-
+import org.apache.rocketmq.common.UtilAll;
+import org.slf4j.Logger;
public class MomentStatsItemSet {
private final ConcurrentHashMap<String/* key */, MomentStatsItem> statsItemTable =
- new ConcurrentHashMap<String, MomentStatsItem>(128);
+ new ConcurrentHashMap<String, MomentStatsItem>(128);
private final String statsName;
private final ScheduledExecutorService scheduledExecutorService;
private final Logger log;
-
public MomentStatsItemSet(String statsName, ScheduledExecutorService scheduledExecutorService, Logger log) {
this.statsName = statsName;
this.scheduledExecutorService = scheduledExecutorService;
@@ -80,7 +77,7 @@ public class MomentStatsItemSet {
MomentStatsItem statsItem = this.statsItemTable.get(statsKey);
if (null == statsItem) {
statsItem =
- new MomentStatsItem(this.statsName, statsKey, this.scheduledExecutorService, this.log);
+ new MomentStatsItem(this.statsName, statsKey, this.scheduledExecutorService, this.log);
MomentStatsItem prev = this.statsItemTable.put(statsKey, statsItem);
if (null == prev) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/stats/StatsItem.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/stats/StatsItem.java b/common/src/main/java/org/apache/rocketmq/common/stats/StatsItem.java
index 42bb561..b1703b1 100644
--- a/common/src/main/java/org/apache/rocketmq/common/stats/StatsItem.java
+++ b/common/src/main/java/org/apache/rocketmq/common/stats/StatsItem.java
@@ -17,14 +17,12 @@
package org.apache.rocketmq.common.stats;
-import org.apache.rocketmq.common.UtilAll;
-import org.slf4j.Logger;
-
import java.util.LinkedList;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
-
+import org.apache.rocketmq.common.UtilAll;
+import org.slf4j.Logger;
public class StatsItem {
@@ -34,10 +32,8 @@ public class StatsItem {
private final LinkedList<CallSnapshot> csListMinute = new LinkedList<CallSnapshot>();
-
private final LinkedList<CallSnapshot> csListHour = new LinkedList<CallSnapshot>();
-
private final LinkedList<CallSnapshot> csListDay = new LinkedList<CallSnapshot>();
private final String statsName;
@@ -45,19 +41,14 @@ public class StatsItem {
private final ScheduledExecutorService scheduledExecutorService;
private final Logger log;
-
public StatsItem(String statsName, String statsKey, ScheduledExecutorService scheduledExecutorService,
- Logger log) {
+ Logger log) {
this.statsName = statsName;
this.statsKey = statsKey;
this.scheduledExecutorService = scheduledExecutorService;
this.log = log;
}
- public StatsSnapshot getStatsDataInMinute() {
- return computeStatsData(this.csListMinute);
- }
-
private static StatsSnapshot computeStatsData(final LinkedList<CallSnapshot> csList) {
StatsSnapshot statsSnapshot = new StatsSnapshot();
synchronized (csList) {
@@ -84,6 +75,10 @@ public class StatsItem {
return statsSnapshot;
}
+ public StatsSnapshot getStatsDataInMinute() {
+ return computeStatsData(this.csListMinute);
+ }
+
public StatsSnapshot getStatsDataInHour() {
return computeStatsData(this.csListHour);
}
@@ -104,7 +99,6 @@ public class StatsItem {
}
}, 0, 10, TimeUnit.SECONDS);
-
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
@@ -115,7 +109,6 @@ public class StatsItem {
}
}, 0, 10, TimeUnit.MINUTES);
-
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
@@ -126,7 +119,6 @@ public class StatsItem {
}
}, 0, 1, TimeUnit.HOURS);
-
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
@@ -137,7 +129,6 @@ public class StatsItem {
}
}, Math.abs(UtilAll.computNextMinutesTimeMillis() - System.currentTimeMillis()), 1000 * 60, TimeUnit.MILLISECONDS);
-
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
@@ -148,7 +139,6 @@ public class StatsItem {
}
}, Math.abs(UtilAll.computNextHourTimeMillis() - System.currentTimeMillis()), 1000 * 60 * 60, TimeUnit.MILLISECONDS);
-
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
@@ -163,7 +153,7 @@ public class StatsItem {
public void samplingInSeconds() {
synchronized (this.csListMinute) {
this.csListMinute.add(new CallSnapshot(System.currentTimeMillis(), this.times.get(), this.value
- .get()));
+ .get()));
if (this.csListMinute.size() > 7) {
this.csListMinute.removeFirst();
}
@@ -173,7 +163,7 @@ public class StatsItem {
public void samplingInMinutes() {
synchronized (this.csListHour) {
this.csListHour.add(new CallSnapshot(System.currentTimeMillis(), this.times.get(), this.value
- .get()));
+ .get()));
if (this.csListHour.size() > 7) {
this.csListHour.removeFirst();
}
@@ -183,7 +173,7 @@ public class StatsItem {
public void samplingInHour() {
synchronized (this.csListDay) {
this.csListDay.add(new CallSnapshot(System.currentTimeMillis(), this.times.get(), this.value
- .get()));
+ .get()));
if (this.csListDay.size() > 25) {
this.csListDay.removeFirst();
}
@@ -193,61 +183,56 @@ public class StatsItem {
public void printAtMinutes() {
StatsSnapshot ss = computeStatsData(this.csListMinute);
log.info(String.format("[%s] [%s] Stats In One Minute, SUM: %d TPS: %.2f AVGPT: %.2f",
- this.statsName,
- this.statsKey,
- ss.getSum(),
- ss.getTps(),
- ss.getAvgpt()));
+ this.statsName,
+ this.statsKey,
+ ss.getSum(),
+ ss.getTps(),
+ ss.getAvgpt()));
}
public void printAtHour() {
StatsSnapshot ss = computeStatsData(this.csListHour);
log.info(String.format("[%s] [%s] Stats In One Hour, SUM: %d TPS: %.2f AVGPT: %.2f",
- this.statsName,
- this.statsKey,
- ss.getSum(),
- ss.getTps(),
- ss.getAvgpt()));
+ this.statsName,
+ this.statsKey,
+ ss.getSum(),
+ ss.getTps(),
+ ss.getAvgpt()));
}
public void printAtDay() {
StatsSnapshot ss = computeStatsData(this.csListDay);
log.info(String.format("[%s] [%s] Stats In One Day, SUM: %d TPS: %.2f AVGPT: %.2f",
- this.statsName,
- this.statsKey,
- ss.getSum(),
- ss.getTps(),
- ss.getAvgpt()));
+ this.statsName,
+ this.statsKey,
+ ss.getSum(),
+ ss.getTps(),
+ ss.getAvgpt()));
}
public AtomicLong getValue() {
return value;
}
-
public String getStatsKey() {
return statsKey;
}
-
public String getStatsName() {
return statsName;
}
-
public AtomicLong getTimes() {
return times;
}
}
-
class CallSnapshot {
private final long timestamp;
private final long times;
private final long value;
-
public CallSnapshot(long timestamp, long times, long value) {
super();
this.timestamp = timestamp;
@@ -255,17 +240,14 @@ class CallSnapshot {
this.value = value;
}
-
public long getTimestamp() {
return timestamp;
}
-
public long getTimes() {
return times;
}
-
public long getValue() {
return value;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/stats/StatsItemSet.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/stats/StatsItemSet.java b/common/src/main/java/org/apache/rocketmq/common/stats/StatsItemSet.java
index 919745d..726bf6a 100644
--- a/common/src/main/java/org/apache/rocketmq/common/stats/StatsItemSet.java
+++ b/common/src/main/java/org/apache/rocketmq/common/stats/StatsItemSet.java
@@ -17,25 +17,22 @@
package org.apache.rocketmq.common.stats;
-import org.apache.rocketmq.common.UtilAll;
-import org.slf4j.Logger;
-
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-
+import org.apache.rocketmq.common.UtilAll;
+import org.slf4j.Logger;
public class StatsItemSet {
private final ConcurrentHashMap<String/* key */, StatsItem> statsItemTable =
- new ConcurrentHashMap<String, StatsItem>(128);
+ new ConcurrentHashMap<String, StatsItem>(128);
private final String statsName;
private final ScheduledExecutorService scheduledExecutorService;
private final Logger log;
-
public StatsItemSet(String statsName, ScheduledExecutorService scheduledExecutorService, Logger log) {
this.statsName = statsName;
this.scheduledExecutorService = scheduledExecutorService;
@@ -55,7 +52,6 @@ public class StatsItemSet {
}
}, 0, 10, TimeUnit.SECONDS);
-
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
@@ -66,7 +62,6 @@ public class StatsItemSet {
}
}, 0, 10, TimeUnit.MINUTES);
-
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
@@ -77,7 +72,6 @@ public class StatsItemSet {
}
}, 0, 1, TimeUnit.HOURS);
-
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
@@ -88,7 +82,6 @@ public class StatsItemSet {
}
}, Math.abs(UtilAll.computNextMinutesTimeMillis() - System.currentTimeMillis()), 1000 * 60, TimeUnit.MILLISECONDS);
-
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
@@ -99,7 +92,6 @@ public class StatsItemSet {
}
}, Math.abs(UtilAll.computNextHourTimeMillis() - System.currentTimeMillis()), 1000 * 60 * 60, TimeUnit.MILLISECONDS);
-
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/stats/StatsSnapshot.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/stats/StatsSnapshot.java b/common/src/main/java/org/apache/rocketmq/common/stats/StatsSnapshot.java
index 652d214..4df39d1 100644
--- a/common/src/main/java/org/apache/rocketmq/common/stats/StatsSnapshot.java
+++ b/common/src/main/java/org/apache/rocketmq/common/stats/StatsSnapshot.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.stats;
@@ -22,32 +22,26 @@ public class StatsSnapshot {
private double tps;
private double avgpt;
-
public long getSum() {
return sum;
}
-
public void setSum(long sum) {
this.sum = sum;
}
-
public double getTps() {
return tps;
}
-
public void setTps(double tps) {
this.tps = tps;
}
-
public double getAvgpt() {
return avgpt;
}
-
public void setAvgpt(double avgpt) {
this.avgpt = avgpt;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java b/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
index 8fc14cd..9bf97fb 100644
--- a/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
+++ b/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
@@ -19,7 +19,6 @@ package org.apache.rocketmq.common.subscription;
import org.apache.rocketmq.common.MixAll;
-
public class SubscriptionGroupConfig {
private String groupName;
@@ -39,82 +38,66 @@ public class SubscriptionGroupConfig {
private boolean notifyConsumerIdsChangedEnable = true;
-
public String getGroupName() {
return groupName;
}
-
public void setGroupName(String groupName) {
this.groupName = groupName;
}
-
public boolean isConsumeEnable() {
return consumeEnable;
}
-
public void setConsumeEnable(boolean consumeEnable) {
this.consumeEnable = consumeEnable;
}
-
public boolean isConsumeFromMinEnable() {
return consumeFromMinEnable;
}
-
public void setConsumeFromMinEnable(boolean consumeFromMinEnable) {
this.consumeFromMinEnable = consumeFromMinEnable;
}
-
public boolean isConsumeBroadcastEnable() {
return consumeBroadcastEnable;
}
-
public void setConsumeBroadcastEnable(boolean consumeBroadcastEnable) {
this.consumeBroadcastEnable = consumeBroadcastEnable;
}
-
public int getRetryQueueNums() {
return retryQueueNums;
}
-
public void setRetryQueueNums(int retryQueueNums) {
this.retryQueueNums = retryQueueNums;
}
-
public int getRetryMaxTimes() {
return retryMaxTimes;
}
-
public void setRetryMaxTimes(int retryMaxTimes) {
this.retryMaxTimes = retryMaxTimes;
}
-
public long getBrokerId() {
return brokerId;
}
-
public void setBrokerId(long brokerId) {
this.brokerId = brokerId;
}
-
public long getWhichBrokerWhenConsumeSlowly() {
return whichBrokerWhenConsumeSlowly;
}
-
public void setWhichBrokerWhenConsumeSlowly(long whichBrokerWhenConsumeSlowly) {
this.whichBrokerWhenConsumeSlowly = whichBrokerWhenConsumeSlowly;
}
@@ -131,7 +114,7 @@ public class SubscriptionGroupConfig {
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + (int) (brokerId ^ (brokerId >>> 32));
+ result = prime * result + (int)(brokerId ^ (brokerId >>> 32));
result = prime * result + (consumeBroadcastEnable ? 1231 : 1237);
result = prime * result + (consumeEnable ? 1231 : 1237);
result = prime * result + (consumeFromMinEnable ? 1231 : 1237);
@@ -140,11 +123,10 @@ public class SubscriptionGroupConfig {
result = prime * result + retryMaxTimes;
result = prime * result + retryQueueNums;
result =
- prime * result + (int) (whichBrokerWhenConsumeSlowly ^ (whichBrokerWhenConsumeSlowly >>> 32));
+ prime * result + (int)(whichBrokerWhenConsumeSlowly ^ (whichBrokerWhenConsumeSlowly >>> 32));
return result;
}
-
@Override
public boolean equals(Object obj) {
if (this == obj)
@@ -153,7 +135,7 @@ public class SubscriptionGroupConfig {
return false;
if (getClass() != obj.getClass())
return false;
- SubscriptionGroupConfig other = (SubscriptionGroupConfig) obj;
+ SubscriptionGroupConfig other = (SubscriptionGroupConfig)obj;
if (brokerId != other.brokerId)
return false;
if (consumeBroadcastEnable != other.consumeBroadcastEnable)
@@ -178,14 +160,13 @@ public class SubscriptionGroupConfig {
return true;
}
-
@Override
public String toString() {
return "SubscriptionGroupConfig [groupName=" + groupName + ", consumeEnable=" + consumeEnable
- + ", consumeFromMinEnable=" + consumeFromMinEnable + ", consumeBroadcastEnable="
- + consumeBroadcastEnable + ", retryQueueNums=" + retryQueueNums + ", retryMaxTimes="
- + retryMaxTimes + ", brokerId=" + brokerId + ", whichBrokerWhenConsumeSlowly="
- + whichBrokerWhenConsumeSlowly + ", notifyConsumerIdsChangedEnable="
- + notifyConsumerIdsChangedEnable + "]";
+ + ", consumeFromMinEnable=" + consumeFromMinEnable + ", consumeBroadcastEnable="
+ + consumeBroadcastEnable + ", retryQueueNums=" + retryQueueNums + ", retryMaxTimes="
+ + retryMaxTimes + ", brokerId=" + brokerId + ", whichBrokerWhenConsumeSlowly="
+ + whichBrokerWhenConsumeSlowly + ", notifyConsumerIdsChangedEnable="
+ + notifyConsumerIdsChangedEnable + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java b/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java
index 4ccfef7..c213543 100644
--- a/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java
+++ b/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java
@@ -24,17 +24,14 @@ public class MessageSysFlag {
public final static int TRANSACTION_COMMIT_TYPE = 0x2 << 2;
public final static int TRANSACTION_ROLLBACK_TYPE = 0x3 << 2;
-
public static int getTransactionValue(final int flag) {
return flag & TRANSACTION_ROLLBACK_TYPE;
}
-
public static int resetTransactionValue(final int flag, final int type) {
return (flag & (~TRANSACTION_ROLLBACK_TYPE)) | type;
}
-
public static int clearCompressedFlag(final int flag) {
return flag & (~COMPRESSED_FLAG);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java b/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java
index 193459c..b659c52 100644
--- a/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java
+++ b/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.sysflag;
@@ -22,9 +22,8 @@ public class PullSysFlag {
private final static int FLAG_SUBSCRIPTION = 0x1 << 2;
private final static int FLAG_CLASS_FILTER = 0x1 << 3;
-
public static int buildSysFlag(final boolean commitOffset, final boolean suspend,
- final boolean subscription, final boolean classFilter) {
+ final boolean subscription, final boolean classFilter) {
int flag = 0;
if (commitOffset) {
@@ -46,27 +45,22 @@ public class PullSysFlag {
return flag;
}
-
public static int clearCommitOffsetFlag(final int sysFlag) {
return sysFlag & (~FLAG_COMMIT_OFFSET);
}
-
public static boolean hasCommitOffsetFlag(final int sysFlag) {
return (sysFlag & FLAG_COMMIT_OFFSET) == FLAG_COMMIT_OFFSET;
}
-
public static boolean hasSuspendFlag(final int sysFlag) {
return (sysFlag & FLAG_SUSPEND) == FLAG_SUSPEND;
}
-
public static boolean hasSubscriptionFlag(final int sysFlag) {
return (sysFlag & FLAG_SUBSCRIPTION) == FLAG_SUBSCRIPTION;
}
-
public static boolean hasClassFilterFlag(final int sysFlag) {
return (sysFlag & FLAG_CLASS_FILTER) == FLAG_CLASS_FILTER;
}
[38/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/MQPullConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/MQPullConsumer.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/MQPullConsumer.java
deleted file mode 100644
index 1125d09..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/MQPullConsumer.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/**
- * 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.client.consumer;
-
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.remoting.exception.RemotingException;
-
-import java.util.Set;
-
-
-/**
- * Pulling consumer interface
- *
- * @author shijia.wxr
- */
-public interface MQPullConsumer extends MQConsumer {
- /**
- * Start the consumer
- *
- * @throws MQClientException
- */
- void start() throws MQClientException;
-
-
- /**
- * Shutdown the consumer
- */
- void shutdown();
-
-
- /**
- * Register the message queue listener
- *
- * @param topic
- * @param listener
- */
- void registerMessageQueueListener(final String topic, final MessageQueueListener listener);
-
-
- /**
- * Pulling the messages,not blocking
- *
- * @param mq
- * from which message queue
- * @param subExpression
- * subscription expression.it only support or operation such as "tag1 || tag2 || tag3" <br>
- * if null or * expression,meaning subscribe all
- * @param offset
- * from where to pull
- * @param maxNums
- * max pulling numbers
- *
- * @return The resulting {@code PullRequest}
- *
- * @throws MQClientException
- * @throws InterruptedException
- * @throws MQBrokerException
- * @throws RemotingException
- */
- PullResult pull(final MessageQueue mq, final String subExpression, final long offset,
- final int maxNums) throws MQClientException, RemotingException, MQBrokerException,
- InterruptedException;
-
-
- /**
- * Pulling the messages in the specified timeout
- *
- * @param mq
- * @param subExpression
- * @param offset
- * @param maxNums
- * @param timeout
- *
- * @return The resulting {@code PullRequest}
- *
- * @throws MQClientException
- * @throws RemotingException
- * @throws MQBrokerException
- * @throws InterruptedException
- */
- PullResult pull(final MessageQueue mq, final String subExpression, final long offset,
- final int maxNums, final long timeout) throws MQClientException, RemotingException,
- MQBrokerException, InterruptedException;
-
-
- /**
- * Pulling the messages in a async. way
- *
- * @param mq
- * @param subExpression
- * @param offset
- * @param maxNums
- * @param pullCallback
- *
- * @throws MQClientException
- * @throws RemotingException
- * @throws InterruptedException
- */
- void pull(final MessageQueue mq, final String subExpression, final long offset, final int maxNums,
- final PullCallback pullCallback) throws MQClientException, RemotingException,
- InterruptedException;
-
- /**
- * Pulling the messages in a async. way
- *
- * @param mq
- * @param subExpression
- * @param offset
- * @param maxNums
- * @param pullCallback
- * @param timeout
- *
- * @throws MQClientException
- * @throws RemotingException
- * @throws InterruptedException
- */
- void pull(final MessageQueue mq, final String subExpression, final long offset, final int maxNums,
- final PullCallback pullCallback, long timeout) throws MQClientException, RemotingException,
- InterruptedException;
-
-
- /**
- * Pulling the messages,if no message arrival,blocking some time
- *
- * @param mq
- * @param subExpression
- * @param offset
- * @param maxNums
- *
- * @return The resulting {@code PullRequest}
- *
- * @throws MQClientException
- * @throws RemotingException
- * @throws MQBrokerException
- * @throws InterruptedException
- */
- PullResult pullBlockIfNotFound(final MessageQueue mq, final String subExpression,
- final long offset, final int maxNums) throws MQClientException, RemotingException,
- MQBrokerException, InterruptedException;
-
-
- /**
- * Pulling the messages through callback function,if no message arrival,blocking.
- *
- * @param mq
- * @param subExpression
- * @param offset
- * @param maxNums
- * @param pullCallback
- *
- * @throws MQClientException
- * @throws RemotingException
- * @throws InterruptedException
- */
- void pullBlockIfNotFound(final MessageQueue mq, final String subExpression, final long offset,
- final int maxNums, final PullCallback pullCallback) throws MQClientException, RemotingException,
- InterruptedException;
-
-
- /**
- * Update the offset
- *
- * @param mq
- * @param offset
- *
- * @throws MQClientException
- */
- void updateConsumeOffset(final MessageQueue mq, final long offset) throws MQClientException;
-
-
- /**
- * Fetch the offset
- *
- * @param mq
- * @param fromStore
- *
- * @return The fetched offset of given queue
- *
- * @throws MQClientException
- */
- long fetchConsumeOffset(final MessageQueue mq, final boolean fromStore) throws MQClientException;
-
-
- /**
- * Fetch the message queues according to the topic
- *
- * @param topic
- * message topic
- *
- * @return message queue set
- *
- * @throws MQClientException
- */
- Set<MessageQueue> fetchMessageQueuesInBalance(final String topic) throws MQClientException;
-
- /**
- * If consuming failure,message will be send back to the broker,and delay consuming in some time later.<br>
- * Mind! message can only be consumed in the same group.
- *
- * @param msg
- * @param delayLevel
- * @param brokerName
- * @param consumerGroup
- *
- * @throws RemotingException
- * @throws MQBrokerException
- * @throws InterruptedException
- * @throws MQClientException
- */
- void sendMessageBack(MessageExt msg, int delayLevel, String brokerName, String consumerGroup)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/MQPullConsumerScheduleService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/MQPullConsumerScheduleService.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/MQPullConsumerScheduleService.java
deleted file mode 100644
index d68b559..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/MQPullConsumerScheduleService.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/**
- * 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.client.consumer;
-
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.common.ThreadFactoryImpl;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.heartbeat.MessageModel;
-import org.slf4j.Logger;
-
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-
-/**
- * Schedule service for pull consumer
- *
- * @author shijia.wxr
- */
-public class MQPullConsumerScheduleService {
- private final Logger log = ClientLogger.getLog();
- private final MessageQueueListener messageQueueListener = new MessageQueueListenerImpl();
- private final ConcurrentHashMap<MessageQueue, PullTaskImpl> taskTable =
- new ConcurrentHashMap<MessageQueue, PullTaskImpl>();
- private DefaultMQPullConsumer defaultMQPullConsumer;
- private int pullThreadNums = 20;
- private ConcurrentHashMap<String /* topic */, PullTaskCallback> callbackTable =
- new ConcurrentHashMap<String, PullTaskCallback>();
- private ScheduledThreadPoolExecutor scheduledThreadPoolExecutor;
-
- public MQPullConsumerScheduleService(final String consumerGroup) {
- this.defaultMQPullConsumer = new DefaultMQPullConsumer(consumerGroup);
- this.defaultMQPullConsumer.setMessageModel(MessageModel.CLUSTERING);
- }
-
- public void putTask(String topic, Set<MessageQueue> mqNewSet) {
- Iterator<Entry<MessageQueue, PullTaskImpl>> it = this.taskTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<MessageQueue, PullTaskImpl> next = it.next();
- if (next.getKey().getTopic().equals(topic)) {
- if (!mqNewSet.contains(next.getKey())) {
- next.getValue().setCancelled(true);
- it.remove();
- }
- }
- }
-
- for (MessageQueue mq : mqNewSet) {
- if (!this.taskTable.containsKey(mq)) {
- PullTaskImpl command = new PullTaskImpl(mq);
- this.taskTable.put(mq, command);
- this.scheduledThreadPoolExecutor.schedule(command, 0, TimeUnit.MILLISECONDS);
-
- }
- }
- }
-
- public void start() throws MQClientException {
- final String group = this.defaultMQPullConsumer.getConsumerGroup();
- this.scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(
- this.pullThreadNums,
- new ThreadFactoryImpl("PullMsgThread-" + group)
- );
-
- this.defaultMQPullConsumer.setMessageQueueListener(this.messageQueueListener);
-
- this.defaultMQPullConsumer.start();
-
- log.info("MQPullConsumerScheduleService start OK, {} {}",
- this.defaultMQPullConsumer.getConsumerGroup(), this.callbackTable);
- }
-
- public void registerPullTaskCallback(final String topic, final PullTaskCallback callback) {
- this.callbackTable.put(topic, callback);
- this.defaultMQPullConsumer.registerMessageQueueListener(topic, null);
- }
-
- public void shutdown() {
- if (this.scheduledThreadPoolExecutor != null) {
- this.scheduledThreadPoolExecutor.shutdown();
- }
-
- if (this.defaultMQPullConsumer != null) {
- this.defaultMQPullConsumer.shutdown();
- }
- }
-
- public ConcurrentHashMap<String, PullTaskCallback> getCallbackTable() {
- return callbackTable;
- }
-
- public void setCallbackTable(ConcurrentHashMap<String, PullTaskCallback> callbackTable) {
- this.callbackTable = callbackTable;
- }
-
- public int getPullThreadNums() {
- return pullThreadNums;
- }
-
- public void setPullThreadNums(int pullThreadNums) {
- this.pullThreadNums = pullThreadNums;
- }
-
- public DefaultMQPullConsumer getDefaultMQPullConsumer() {
- return defaultMQPullConsumer;
- }
-
- public void setDefaultMQPullConsumer(DefaultMQPullConsumer defaultMQPullConsumer) {
- this.defaultMQPullConsumer = defaultMQPullConsumer;
- }
-
- public MessageModel getMessageModel() {
- return this.defaultMQPullConsumer.getMessageModel();
- }
-
- public void setMessageModel(MessageModel messageModel) {
- this.defaultMQPullConsumer.setMessageModel(messageModel);
- }
-
- class MessageQueueListenerImpl implements MessageQueueListener {
- @Override
- public void messageQueueChanged(String topic, Set<MessageQueue> mqAll, Set<MessageQueue> mqDivided) {
- MessageModel messageModel =
- MQPullConsumerScheduleService.this.defaultMQPullConsumer.getMessageModel();
- switch (messageModel) {
- case BROADCASTING:
- MQPullConsumerScheduleService.this.putTask(topic, mqAll);
- break;
- case CLUSTERING:
- MQPullConsumerScheduleService.this.putTask(topic, mqDivided);
- break;
- default:
- break;
- }
- }
- }
-
- class PullTaskImpl implements Runnable {
- private final MessageQueue messageQueue;
- private volatile boolean cancelled = false;
-
-
- public PullTaskImpl(final MessageQueue messageQueue) {
- this.messageQueue = messageQueue;
- }
-
-
- @Override
- public void run() {
- String topic = this.messageQueue.getTopic();
- if (!this.isCancelled()) {
- PullTaskCallback pullTaskCallback =
- MQPullConsumerScheduleService.this.callbackTable.get(topic);
- if (pullTaskCallback != null) {
- final PullTaskContext context = new PullTaskContext();
- context.setPullConsumer(MQPullConsumerScheduleService.this.defaultMQPullConsumer);
- try {
- pullTaskCallback.doPullTask(this.messageQueue, context);
- } catch (Throwable e) {
- context.setPullNextDelayTimeMillis(1000);
- log.error("doPullTask Exception", e);
- }
-
- if (!this.isCancelled()) {
- MQPullConsumerScheduleService.this.scheduledThreadPoolExecutor.schedule(this,
- context.getPullNextDelayTimeMillis(), TimeUnit.MILLISECONDS);
- } else {
- log.warn("The Pull Task is cancelled after doPullTask, {}", messageQueue);
- }
- } else {
- log.warn("Pull Task Callback not exist , {}", topic);
- }
- } else {
- log.warn("The Pull Task is cancelled, {}", messageQueue);
- }
- }
-
-
- public boolean isCancelled() {
- return cancelled;
- }
-
-
- public void setCancelled(boolean cancelled) {
- this.cancelled = cancelled;
- }
-
-
- public MessageQueue getMessageQueue() {
- return messageQueue;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/MQPushConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/MQPushConsumer.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/MQPushConsumer.java
deleted file mode 100644
index e47739d..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/MQPushConsumer.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * 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.client.consumer;
-
-import com.alibaba.rocketmq.client.consumer.listener.MessageListener;
-import com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
-import com.alibaba.rocketmq.client.consumer.listener.MessageListenerOrderly;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-
-
-/**
- * Push consumer
- *
- * @author shijia.wxr
- */
-public interface MQPushConsumer extends MQConsumer {
- /**
- * Start the consumer
- *
- * @throws MQClientException
- */
- void start() throws MQClientException;
-
-
- /**
- * Shutdown the consumer
- */
- void shutdown();
-
-
- /**
- * Register the message listener
- *
- * @param messageListener
- */
- @Deprecated
- void registerMessageListener(MessageListener messageListener);
-
-
- void registerMessageListener(final MessageListenerConcurrently messageListener);
-
-
- void registerMessageListener(final MessageListenerOrderly messageListener);
-
-
- /**
- * Subscribe some topic
- *
- * @param topic
- * @param subExpression
- * subscription expression.it only support or operation such as
- * "tag1 || tag2 || tag3" <br>
- * if null or * expression,meaning subscribe all
- *
- * @throws MQClientException
- */
- void subscribe(final String topic, final String subExpression) throws MQClientException;
-
-
- /**
- * Subscribe some topic
- *
- * @param topic
- * @param fullClassName
- * full class name,must extend
- * com.alibaba.rocketmq.common.filter. MessageFilter
- * @param filterClassSource
- * class source code,used UTF-8 file encoding,must be responsible
- * for your code safety
- *
- * @throws MQClientException
- */
- void subscribe(final String topic, final String fullClassName, final String filterClassSource) throws MQClientException;
-
-
- /**
- * Unsubscribe consumption some topic
- *
- * @param topic
- * message topic
- */
- void unsubscribe(final String topic);
-
-
- /**
- * Update the consumer thread pool size Dynamically
- *
- * @param corePoolSize
- */
- void updateCorePoolSize(int corePoolSize);
-
-
- /**
- * Suspend the consumption
- */
- void suspend();
-
-
- /**
- * Resume the consumption
- */
- void resume();
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/MessageQueueListener.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/MessageQueueListener.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/MessageQueueListener.java
deleted file mode 100644
index bb25a3a..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/MessageQueueListener.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.client.consumer;
-
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-import java.util.Set;
-
-
-/**
- * A MessageQueueListener is implemented by the application and may be specified when a message queue changed
- *
- * @author shijia.wxr
- * @author vongosling
- */
-public interface MessageQueueListener {
- /**
- * @param topic
- * message topic
- * @param mqAll
- * all queues in this message topic
- * @param mqDivided
- * collection of queues,assigned to the current consumer
- */
- void messageQueueChanged(final String topic, final Set<MessageQueue> mqAll,
- final Set<MessageQueue> mqDivided);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullCallback.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullCallback.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullCallback.java
deleted file mode 100644
index 545cff2..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullCallback.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * 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.client.consumer;
-
-/**
- * Async message pulling interface
- *
- * @author shijia.wxr
- */
-public interface PullCallback {
- public void onSuccess(final PullResult pullResult);
-
- public void onException(final Throwable e);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullResult.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullResult.java
deleted file mode 100644
index b485243..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullResult.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * 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.client.consumer;
-
-import com.alibaba.rocketmq.common.message.MessageExt;
-
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public class PullResult {
- private final PullStatus pullStatus;
- private final long nextBeginOffset;
- private final long minOffset;
- private final long maxOffset;
- private List<MessageExt> msgFoundList;
-
-
- public PullResult(PullStatus pullStatus, long nextBeginOffset, long minOffset, long maxOffset,
- List<MessageExt> msgFoundList) {
- super();
- this.pullStatus = pullStatus;
- this.nextBeginOffset = nextBeginOffset;
- this.minOffset = minOffset;
- this.maxOffset = maxOffset;
- this.msgFoundList = msgFoundList;
- }
-
-
- public PullStatus getPullStatus() {
- return pullStatus;
- }
-
-
- public long getNextBeginOffset() {
- return nextBeginOffset;
- }
-
-
- public long getMinOffset() {
- return minOffset;
- }
-
-
- public long getMaxOffset() {
- return maxOffset;
- }
-
-
- public List<MessageExt> getMsgFoundList() {
- return msgFoundList;
- }
-
-
- public void setMsgFoundList(List<MessageExt> msgFoundList) {
- this.msgFoundList = msgFoundList;
- }
-
-
- @Override
- public String toString() {
- return "PullResult [pullStatus=" + pullStatus + ", nextBeginOffset=" + nextBeginOffset
- + ", minOffset=" + minOffset + ", maxOffset=" + maxOffset + ", msgFoundList="
- + (msgFoundList == null ? 0 : msgFoundList.size()) + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullStatus.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullStatus.java
deleted file mode 100644
index 35166f3..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullStatus.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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.client.consumer;
-
-/**
- * @author shijia.wxr
- */
-public enum PullStatus {
- /**
- * Founded
- */
- FOUND,
- /**
- * No new message can be pull
- */
- NO_NEW_MSG,
- /**
- * Filtering results can not match
- */
- NO_MATCHED_MSG,
- /**
- * Illegal offset,may be too big or too small
- */
- OFFSET_ILLEGAL
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullTaskCallback.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullTaskCallback.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullTaskCallback.java
deleted file mode 100644
index 19d5bfc..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullTaskCallback.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * 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.client.consumer;
-
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-
-public interface PullTaskCallback {
- public void doPullTask(final MessageQueue mq, final PullTaskContext context);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullTaskContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullTaskContext.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullTaskContext.java
deleted file mode 100644
index 72c57d6..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/PullTaskContext.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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.client.consumer;
-
-public class PullTaskContext {
-
- private int pullNextDelayTimeMillis = 200;
-
- private MQPullConsumer pullConsumer;
-
-
- public int getPullNextDelayTimeMillis() {
- return pullNextDelayTimeMillis;
- }
-
-
- public void setPullNextDelayTimeMillis(int pullNextDelayTimeMillis) {
- this.pullNextDelayTimeMillis = pullNextDelayTimeMillis;
- }
-
-
- public MQPullConsumer getPullConsumer() {
- return pullConsumer;
- }
-
-
- public void setPullConsumer(MQPullConsumer pullConsumer) {
- this.pullConsumer = pullConsumer;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java
deleted file mode 100644
index 36fcf19..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * 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.client.consumer.listener;
-
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-
-/**
- * Consumer concurrent consumption context
- *
- * @author shijia.wxr
- */
-public class ConsumeConcurrentlyContext {
- private final MessageQueue messageQueue;
- /**
- * Message consume retry strategy<br>
- * -1,no retry,put into DLQ directly<br>
- * 0,broker control retry frequency<br>
- * >0,client control retry frequency
- */
- private int delayLevelWhenNextConsume = 0;
- private int ackIndex = Integer.MAX_VALUE;
-
- public ConsumeConcurrentlyContext(MessageQueue messageQueue) {
- this.messageQueue = messageQueue;
- }
-
-
- public int getDelayLevelWhenNextConsume() {
- return delayLevelWhenNextConsume;
- }
-
-
- public void setDelayLevelWhenNextConsume(int delayLevelWhenNextConsume) {
- this.delayLevelWhenNextConsume = delayLevelWhenNextConsume;
- }
-
-
- public MessageQueue getMessageQueue() {
- return messageQueue;
- }
-
-
- public int getAckIndex() {
- return ackIndex;
- }
-
-
- public void setAckIndex(int ackIndex) {
- this.ackIndex = ackIndex;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java
deleted file mode 100644
index d0d3bf4..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * 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.client.consumer.listener;
-
-/**
- * @author shijia.wxr
- */
-public enum ConsumeConcurrentlyStatus {
- /**
- * Success consumption
- */
- CONSUME_SUCCESS,
- /**
- * Failure consumption,later try to consume
- */
- RECONSUME_LATER;
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
deleted file mode 100644
index 26a3892..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * 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.client.consumer.listener;
-
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-
-/**
- * Consumer Orderly consumption context
- *
- * @author shijia.wxr
- */
-public class ConsumeOrderlyContext {
- private final MessageQueue messageQueue;
- private boolean autoCommit = true;
- private long suspendCurrentQueueTimeMillis = -1;
-
-
- public ConsumeOrderlyContext(MessageQueue messageQueue) {
- this.messageQueue = messageQueue;
- }
-
-
- public boolean isAutoCommit() {
- return autoCommit;
- }
-
-
- public void setAutoCommit(boolean autoCommit) {
- this.autoCommit = autoCommit;
- }
-
-
- public MessageQueue getMessageQueue() {
- return messageQueue;
- }
-
-
- public long getSuspendCurrentQueueTimeMillis() {
- return suspendCurrentQueueTimeMillis;
- }
-
-
- public void setSuspendCurrentQueueTimeMillis(long suspendCurrentQueueTimeMillis) {
- this.suspendCurrentQueueTimeMillis = suspendCurrentQueueTimeMillis;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java
deleted file mode 100644
index e490c5c..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.client.consumer.listener;
-
-/**
- * @author shijia.wxr
- */
-public enum ConsumeOrderlyStatus {
- /**
- * Success consumption
- */
- SUCCESS,
- /**
- * Rollback consumption(only for binlog consumption)
- */
- @Deprecated
- ROLLBACK,
- /**
- * Commit offset(only for binlog consumption)
- */
- @Deprecated
- COMMIT,
- /**
- * Suspend current queue a moment
- */
- SUSPEND_CURRENT_QUEUE_A_MOMENT;
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeReturnType.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeReturnType.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeReturnType.java
deleted file mode 100644
index 44f998e..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/ConsumeReturnType.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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.client.consumer.listener;
-
-/**
- * Created by alvin on 16-11-30.
- */
-public enum ConsumeReturnType {
- /**
- * consume return success
- */
- SUCCESS,
- /**
- * consume timeout ,even if success
- */
- TIME_OUT,
- /**
- * consume throw exception
- */
- EXCEPTION,
- /**
- * consume return null
- */
- RETURNNULL,
- /**
- * consume return failed
- */
- FAILED
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/MessageListener.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/MessageListener.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/MessageListener.java
deleted file mode 100644
index f34946e..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/MessageListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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.client.consumer.listener;
-
-/**
- * A MessageListener object is used to receive asynchronously delivered messages.
- *
- * @author shijia.wxr
- */
-public interface MessageListener {
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/MessageListenerConcurrently.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
deleted file mode 100644
index f0b0c61..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * 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.client.consumer.listener;
-
-import com.alibaba.rocketmq.common.message.MessageExt;
-
-import java.util.List;
-
-
-/**
- * A MessageListenerConcurrently object is used to receive asynchronously delivered messages concurrently
- *
- * @author shijia.wxr
- */
-public interface MessageListenerConcurrently extends MessageListener {
- /**
- * It is not recommend to throw exception,rather than returning ConsumeConcurrentlyStatus.RECONSUME_LATER if consumption failure
- *
- * @param msgs
- * msgs.size() >= 1<br>
- * DefaultMQPushConsumer.consumeMessageBatchMaxSize=1,you can modify here
- * @param context
- *
- * @return The consume status
- */
- ConsumeConcurrentlyStatus consumeMessage(final List<MessageExt> msgs,
- final ConsumeConcurrentlyContext context);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/MessageListenerOrderly.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/MessageListenerOrderly.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/MessageListenerOrderly.java
deleted file mode 100644
index d30cdfa..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/listener/MessageListenerOrderly.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * 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.client.consumer.listener;
-
-import com.alibaba.rocketmq.common.message.MessageExt;
-
-import java.util.List;
-
-
-/**
- * A MessageListenerConcurrently object is used to receive asynchronously delivered messages orderly.one queue,one thread
- *
- * @author shijia.wxr
- */
-public interface MessageListenerOrderly extends MessageListener {
- /**
- * It is not recommend to throw exception,rather than returning ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT if consumption failure
- *
- * @param msgs
- * msgs.size() >= 1<br>
- * DefaultMQPushConsumer.consumeMessageBatchMaxSize=1,you can modify here
- * @param context
- *
- * @return The consume status
- */
- ConsumeOrderlyStatus consumeMessage(final List<MessageExt> msgs,
- final ConsumeOrderlyContext context);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragely.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragely.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragely.java
deleted file mode 100644
index 413d646..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragely.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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.client.consumer.rebalance;
-
-import com.alibaba.rocketmq.client.consumer.AllocateMessageQueueStrategy;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import org.slf4j.Logger;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * Average Hashing queue algorithm
- *
- * @author manhong.yqd
- */
-public class AllocateMessageQueueAveragely implements AllocateMessageQueueStrategy {
- private final Logger log = ClientLogger.getLog();
-
- @Override
- public List<MessageQueue> allocate(String consumerGroup, String currentCID, List<MessageQueue> mqAll,
- List<String> cidAll) {
- if (currentCID == null || currentCID.length() < 1) {
- throw new IllegalArgumentException("currentCID is empty");
- }
- if (mqAll == null || mqAll.isEmpty()) {
- throw new IllegalArgumentException("mqAll is null or mqAll empty");
- }
- if (cidAll == null || cidAll.isEmpty()) {
- throw new IllegalArgumentException("cidAll is null or cidAll empty");
- }
-
- List<MessageQueue> result = new ArrayList<MessageQueue>();
- if (!cidAll.contains(currentCID)) {
- log.info("[BUG] ConsumerGroup: {} The consumerId: {} not in cidAll: {}",
- consumerGroup,
- currentCID,
- cidAll);
- return result;
- }
-
- int index = cidAll.indexOf(currentCID);
- int mod = mqAll.size() % cidAll.size();
- int averageSize =
- mqAll.size() <= cidAll.size() ? 1 : (mod > 0 && index < mod ? mqAll.size() / cidAll.size()
- + 1 : mqAll.size() / cidAll.size());
- int startIndex = (mod > 0 && index < mod) ? index * averageSize : index * averageSize + mod;
- int range = Math.min(averageSize, mqAll.size() - startIndex);
- for (int i = 0; i < range; i++) {
- result.add(mqAll.get((startIndex + i) % mqAll.size()));
- }
- return result;
- }
-
- @Override
- public String getName() {
- return "AVG";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragelyByCircle.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragelyByCircle.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragelyByCircle.java
deleted file mode 100644
index 17f4611..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragelyByCircle.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * 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.client.consumer.rebalance;
-
-import com.alibaba.rocketmq.client.consumer.AllocateMessageQueueStrategy;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import org.slf4j.Logger;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * Cycle average Hashing queue algorithm
- *
- * @author manhong.yqd
- */
-public class AllocateMessageQueueAveragelyByCircle implements AllocateMessageQueueStrategy {
- private final Logger log = ClientLogger.getLog();
-
- @Override
- public List<MessageQueue> allocate(String consumerGroup, String currentCID, List<MessageQueue> mqAll,
- List<String> cidAll) {
- if (currentCID == null || currentCID.length() < 1) {
- throw new IllegalArgumentException("currentCID is empty");
- }
- if (mqAll == null || mqAll.isEmpty()) {
- throw new IllegalArgumentException("mqAll is null or mqAll empty");
- }
- if (cidAll == null || cidAll.isEmpty()) {
- throw new IllegalArgumentException("cidAll is null or cidAll empty");
- }
-
- List<MessageQueue> result = new ArrayList<MessageQueue>();
- if (!cidAll.contains(currentCID)) {
- log.info("[BUG] ConsumerGroup: {} The consumerId: {} not in cidAll: {}",
- consumerGroup,
- currentCID,
- cidAll);
- return result;
- }
-
- int index = cidAll.indexOf(currentCID);
- for (int i = index; i < mqAll.size(); i++) {
- if (i % cidAll.size() == index) {
- result.add(mqAll.get(i));
- }
- }
- return result;
- }
-
- @Override
- public String getName() {
- return "AVG_BY_CIRCLE";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java
deleted file mode 100644
index 783678c..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * 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.client.consumer.rebalance;
-
-import com.alibaba.rocketmq.client.consumer.AllocateMessageQueueStrategy;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public class AllocateMessageQueueByConfig implements AllocateMessageQueueStrategy {
- private List<MessageQueue> messageQueueList;
-
- @Override
- public List<MessageQueue> allocate(String consumerGroup, String currentCID, List<MessageQueue> mqAll,
- List<String> cidAll) {
- return this.messageQueueList;
- }
-
- @Override
- public String getName() {
- return "CONFIG";
- }
-
- public List<MessageQueue> getMessageQueueList() {
- return messageQueueList;
- }
-
-
- public void setMessageQueueList(List<MessageQueue> messageQueueList) {
- this.messageQueueList = messageQueueList;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/rebalance/AllocateMessageQueueByMachineRoom.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/rebalance/AllocateMessageQueueByMachineRoom.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/rebalance/AllocateMessageQueueByMachineRoom.java
deleted file mode 100644
index 5464fe3..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/rebalance/AllocateMessageQueueByMachineRoom.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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.client.consumer.rebalance;
-
-import com.alibaba.rocketmq.client.consumer.AllocateMessageQueueStrategy;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-
-/**
- * Computer room Hashing queue algorithm, such as Alipay logic room
- */
-public class AllocateMessageQueueByMachineRoom implements AllocateMessageQueueStrategy {
- private Set<String> consumeridcs;
-
- @Override
- public List<MessageQueue> allocate(String consumerGroup, String currentCID, List<MessageQueue> mqAll,
- List<String> cidAll) {
- List<MessageQueue> result = new ArrayList<MessageQueue>();
- int currentIndex = cidAll.indexOf(currentCID);
- if (currentIndex < 0) {
- return result;
- }
- List<MessageQueue> premqAll = new ArrayList<MessageQueue>();
- for (MessageQueue mq : mqAll) {
- String[] temp = mq.getBrokerName().split("@");
- if (temp.length == 2 && consumeridcs.contains(temp[0])) {
- premqAll.add(mq);
- }
- }
- // Todo cid
- int mod = premqAll.size() / cidAll.size();
- int rem = premqAll.size() % cidAll.size();
- int startindex = mod * currentIndex;
- int endindex = startindex + mod;
- for (int i = startindex; i < endindex; i++) {
- result.add(mqAll.get(i));
- }
- if (rem > currentIndex) {
- result.add(premqAll.get(currentIndex + mod * cidAll.size()));
- }
- return result;
- }
-
- @Override
- public String getName() {
- return "MACHINE_ROOM";
- }
-
- public Set<String> getConsumeridcs() {
- return consumeridcs;
- }
-
-
- public void setConsumeridcs(Set<String> consumeridcs) {
- this.consumeridcs = consumeridcs;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/LocalFileOffsetStore.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/LocalFileOffsetStore.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/LocalFileOffsetStore.java
deleted file mode 100644
index 39aec12..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/LocalFileOffsetStore.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/**
- * 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.client.consumer.store;
-
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.impl.factory.MQClientInstance;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.help.FAQUrl;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.remoting.exception.RemotingException;
-import org.slf4j.Logger;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
-
-
-/**
- * Local storage implementation
- *
- * @author shijia.wxr
- */
-public class LocalFileOffsetStore implements OffsetStore {
- public final static String LOCAL_OFFSET_STORE_DIR = System.getProperty(
- "rocketmq.client.localOffsetStoreDir",
- System.getProperty("user.home") + File.separator + ".rocketmq_offsets");
- private final static Logger log = ClientLogger.getLog();
- private final MQClientInstance mQClientFactory;
- private final String groupName;
- private final String storePath;
- private ConcurrentHashMap<MessageQueue, AtomicLong> offsetTable =
- new ConcurrentHashMap<MessageQueue, AtomicLong>();
-
-
- public LocalFileOffsetStore(MQClientInstance mQClientFactory, String groupName) {
- this.mQClientFactory = mQClientFactory;
- this.groupName = groupName;
- this.storePath = LOCAL_OFFSET_STORE_DIR + File.separator + //
- this.mQClientFactory.getClientId() + File.separator + //
- this.groupName + File.separator + //
- "offsets.json";
- }
-
-
- @Override
- public void load() throws MQClientException {
- OffsetSerializeWrapper offsetSerializeWrapper = this.readLocalOffset();
- if (offsetSerializeWrapper != null && offsetSerializeWrapper.getOffsetTable() != null) {
- offsetTable.putAll(offsetSerializeWrapper.getOffsetTable());
-
- for (MessageQueue mq : offsetSerializeWrapper.getOffsetTable().keySet()) {
- AtomicLong offset = offsetSerializeWrapper.getOffsetTable().get(mq);
- log.info("load consumer's offset, {} {} {}",
- this.groupName,
- mq,
- offset.get());
- }
- }
- }
-
-
- @Override
- public void updateOffset(MessageQueue mq, long offset, boolean increaseOnly) {
- if (mq != null) {
- AtomicLong offsetOld = this.offsetTable.get(mq);
- if (null == offsetOld) {
- offsetOld = this.offsetTable.putIfAbsent(mq, new AtomicLong(offset));
- }
-
- if (null != offsetOld) {
- if (increaseOnly) {
- MixAll.compareAndIncreaseOnly(offsetOld, offset);
- } else {
- offsetOld.set(offset);
- }
- }
- }
- }
-
-
- @Override
- public long readOffset(final MessageQueue mq, final ReadOffsetType type) {
- if (mq != null) {
- switch (type) {
- case MEMORY_FIRST_THEN_STORE:
- case READ_FROM_MEMORY: {
- AtomicLong offset = this.offsetTable.get(mq);
- if (offset != null) {
- return offset.get();
- } else if (ReadOffsetType.READ_FROM_MEMORY == type) {
- return -1;
- }
- }
- case READ_FROM_STORE: {
- OffsetSerializeWrapper offsetSerializeWrapper;
- try {
- offsetSerializeWrapper = this.readLocalOffset();
- } catch (MQClientException e) {
- return -1;
- }
- if (offsetSerializeWrapper != null && offsetSerializeWrapper.getOffsetTable() != null) {
- AtomicLong offset = offsetSerializeWrapper.getOffsetTable().get(mq);
- if (offset != null) {
- this.updateOffset(mq, offset.get(), false);
- return offset.get();
- }
- }
- }
- default:
- break;
- }
- }
-
- return -1;
- }
-
-
- @Override
- public void persistAll(Set<MessageQueue> mqs) {
- if (null == mqs || mqs.isEmpty())
- return;
-
- OffsetSerializeWrapper offsetSerializeWrapper = new OffsetSerializeWrapper();
- for (Map.Entry<MessageQueue, AtomicLong> entry : this.offsetTable.entrySet()) {
- if (mqs.contains(entry.getKey())) {
- AtomicLong offset = entry.getValue();
- offsetSerializeWrapper.getOffsetTable().put(entry.getKey(), offset);
- }
- }
-
- String jsonString = offsetSerializeWrapper.toJson(true);
- if (jsonString != null) {
- try {
- MixAll.string2File(jsonString, this.storePath);
- } catch (IOException e) {
- log.error("persistAll consumer offset Exception, " + this.storePath, e);
- }
- }
- }
-
-
- @Override
- public void persist(MessageQueue mq) {
- }
-
- @Override
- public void removeOffset(MessageQueue mq) {
-
- }
-
- @Override
- public void updateConsumeOffsetToBroker(final MessageQueue mq, final long offset, final boolean isOneway)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
-
- }
-
- @Override
- public Map<MessageQueue, Long> cloneOffsetTable(String topic) {
- Map<MessageQueue, Long> cloneOffsetTable = new HashMap<MessageQueue, Long>();
- for (Map.Entry<MessageQueue, AtomicLong> entry : this.offsetTable.entrySet()) {
- MessageQueue mq = entry.getKey();
- if (!UtilAll.isBlank(topic) && !topic.equals(mq.getTopic())) {
- continue;
- }
- cloneOffsetTable.put(mq, entry.getValue().get());
-
- }
- return cloneOffsetTable;
- }
-
- private OffsetSerializeWrapper readLocalOffset() throws MQClientException {
- String content = MixAll.file2String(this.storePath);
- if (null == content || content.length() == 0) {
- return this.readLocalOffsetBak();
- } else {
- OffsetSerializeWrapper offsetSerializeWrapper = null;
- try {
- offsetSerializeWrapper =
- OffsetSerializeWrapper.fromJson(content, OffsetSerializeWrapper.class);
- } catch (Exception e) {
- log.warn("readLocalOffset Exception, and try to correct", e);
- return this.readLocalOffsetBak();
- }
-
- return offsetSerializeWrapper;
- }
- }
-
- private OffsetSerializeWrapper readLocalOffsetBak() throws MQClientException {
- String content = MixAll.file2String(this.storePath + ".bak");
- if (content != null && content.length() > 0) {
- OffsetSerializeWrapper offsetSerializeWrapper = null;
- try {
- offsetSerializeWrapper =
- OffsetSerializeWrapper.fromJson(content, OffsetSerializeWrapper.class);
- } catch (Exception e) {
- log.warn("readLocalOffset Exception", e);
- throw new MQClientException("readLocalOffset Exception, maybe fastjson version too low" //
- + FAQUrl.suggestTodo(FAQUrl.LOAD_JSON_EXCEPTION), //
- e);
- }
- return offsetSerializeWrapper;
- }
-
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/OffsetSerializeWrapper.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
deleted file mode 100644
index 4434b86..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * 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.client.consumer.store;
-
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
-
-
-/**
- * Wrapper class for offset serialization
- *
- * @author shijia.wxr
- */
-public class OffsetSerializeWrapper extends RemotingSerializable {
- private ConcurrentHashMap<MessageQueue, AtomicLong> offsetTable =
- new ConcurrentHashMap<MessageQueue, AtomicLong>();
-
- public ConcurrentHashMap<MessageQueue, AtomicLong> getOffsetTable() {
- return offsetTable;
- }
-
- public void setOffsetTable(ConcurrentHashMap<MessageQueue, AtomicLong> offsetTable) {
- this.offsetTable = offsetTable;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/OffsetStore.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/OffsetStore.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/OffsetStore.java
deleted file mode 100644
index 346beb1..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/OffsetStore.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * 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.client.consumer.store;
-
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.remoting.exception.RemotingException;
-
-import java.util.Map;
-import java.util.Set;
-
-
-/**
- * Offset store interface
- *
- * @author shijia.wxr
- */
-public interface OffsetStore {
- /**
- * Load
- *
- * @throws MQClientException
- */
- void load() throws MQClientException;
-
-
- /**
- * Update the offset,store it in memory
- *
- * @param mq
- * @param offset
- * @param increaseOnly
- */
- void updateOffset(final MessageQueue mq, final long offset, final boolean increaseOnly);
-
- /**
- * Get offset from local storage
- *
- * @param mq
- * @param type
- *
- * @return The fetched offset
- */
- long readOffset(final MessageQueue mq, final ReadOffsetType type);
-
- /**
- * Persist all offsets,may be in local storage or remote name server
- *
- * @param mqs
- */
- void persistAll(final Set<MessageQueue> mqs);
-
- /**
- * Persist the offset,may be in local storage or remote name server
- *
- * @param mq
- */
- void persist(final MessageQueue mq);
-
- /**
- * Remove offset
- *
- * @param mq
- */
- void removeOffset(MessageQueue mq);
-
- /**
- * @param topic
- *
- * @return The cloned offset table of given topic
- */
- Map<MessageQueue, Long> cloneOffsetTable(String topic);
-
- /**
- *
- * @param mq
- * @param offset
- * @param isOneway
- */
- void updateConsumeOffsetToBroker(MessageQueue mq, long offset, boolean isOneway) throws RemotingException,
- MQBrokerException, InterruptedException, MQClientException;
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/ReadOffsetType.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/ReadOffsetType.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/ReadOffsetType.java
deleted file mode 100644
index 3691a62..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/ReadOffsetType.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * 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.client.consumer.store;
-
-public enum ReadOffsetType {
- /**
- * From memory
- */
- READ_FROM_MEMORY,
- /**
- * From storage
- */
- READ_FROM_STORE,
- /**
- * From memory,then from storage
- */
- MEMORY_FIRST_THEN_STORE;
-}
[62/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Remove
author annotation.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java
index e445bb0..4be52ee 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java
@@ -22,9 +22,6 @@ import java.util.HashSet;
import java.util.Set;
-/**
- * @author vintagewang@apache.org
- */
public class TopicList extends RemotingSerializable {
private Set<String> topicList = new HashSet<String>();
private String brokerAddr;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java
index ae996c2..8142b12 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java
@@ -24,9 +24,6 @@ import java.util.HashSet;
import java.util.Set;
-/**
- * @author vintagewang@apache.org
- */
public class UnlockBatchRequestBody extends RemotingSerializable {
private String consumerGroup;
private String clientId;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
index b2775ad..5b6e67f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class CheckTransactionStateRequestHeader implements CommandCustomHeader {
@CFNotNull
private Long tranStateTableOffset;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
index 9fcec8b..805e3ac 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
@@ -26,9 +26,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class CheckTransactionStateResponseHeader implements CommandCustomHeader {
@CFNotNull
private String producerGroup;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
index 28b9f33..1752b88 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author manhong.yqd
- */
public class CloneGroupOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
private String srcGroup;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java
index 513a40c..d108f02 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java
@@ -24,7 +24,6 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author vintagewang@apache.org
*
*/
public class ConsumerSendMsgBackRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
index e8f4f05..fff2b99 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
@@ -26,9 +26,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class CreateTopicRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java
index 783b37c..cdb4358 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java
@@ -22,9 +22,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author manhong.yqd
- */
public class DeleteSubscriptionGroupRequestHeader implements CommandCustomHeader {
@CFNotNull
private String groupName;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
index e09146a..93e2dd4 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class DeleteTopicRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
index e05c1b4..2d93e62 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
@@ -27,9 +27,6 @@ import org.apache.rocketmq.remoting.annotation.CFNullable;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class EndTransactionRequestHeader implements CommandCustomHeader {
@CFNotNull
private String producerGroup;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
index 9f5e45b..85ad2e4 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
@@ -24,9 +24,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class EndTransactionResponseHeader implements CommandCustomHeader {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
index 2513c19..96030e5 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
@@ -24,9 +24,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class GetAllTopicConfigResponseHeader implements CommandCustomHeader {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
index 18983f6..d15b1e9 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class GetBrokerConfigResponseHeader implements CommandCustomHeader {
@CFNotNull
private String version;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
index fee6361..25d8041 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
@@ -21,9 +21,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class GetConsumeStatsRequestHeader implements CommandCustomHeader {
@CFNotNull
private String consumerGroup;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
index 583acd0..a31b8ab 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
@@ -24,7 +24,6 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
*
- * @author vintagewang@apache.org
*
*/
public class GetConsumerConnectionListRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java
index bc31cd8..0a7e4e4 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java
@@ -22,9 +22,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class GetConsumerListByGroupRequestHeader implements CommandCustomHeader {
@CFNotNull
private String consumerGroup;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java
index 4d2a9aa..0934831 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java
@@ -22,9 +22,6 @@ import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class GetConsumerListByGroupResponseBody extends RemotingSerializable {
private List<String> consumerIdList;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java
index 5a2161a..7e2a174 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java
@@ -21,9 +21,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class GetConsumerListByGroupResponseHeader implements CommandCustomHeader {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java
index c239cd0..e44a5ac 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java
@@ -23,9 +23,6 @@ import org.apache.rocketmq.remoting.annotation.CFNullable;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class GetConsumerRunningInfoRequestHeader implements CommandCustomHeader {
@CFNotNull
private String consumerGroup;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java
index 4fc057d..b577ac8 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java
@@ -24,7 +24,6 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author manhong.yqd
*
*/
public class GetConsumerStatusRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
index afc0462..9d5b75d 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class GetEarliestMsgStoretimeRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
index 1952467..658388a 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class GetEarliestMsgStoretimeResponseHeader implements CommandCustomHeader {
@CFNotNull
private Long timestamp;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
index 6c8519f..6d33dcb 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class GetMaxOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
index 765a35a..0143ef8 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class GetMaxOffsetResponseHeader implements CommandCustomHeader {
@CFNotNull
private Long offset;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
index b6db3f2..ce09727 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class GetMinOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
index 6acada7..366b513 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class GetMinOffsetResponseHeader implements CommandCustomHeader {
@CFNotNull
private Long offset;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java
index 0832a21..d6da4a7 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java
@@ -22,9 +22,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class GetProducerConnectionListRequestHeader implements CommandCustomHeader {
@CFNotNull
private String producerGroup;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java
index 02d828b..f49dee0 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java
@@ -23,7 +23,6 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author vintagewang@apache.org
*
*/
public class GetTopicStatsInfoRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicsByClusterRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicsByClusterRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicsByClusterRequestHeader.java
index 439c2ad..37f5ffa 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicsByClusterRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicsByClusterRequestHeader.java
@@ -23,7 +23,6 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author manhong.yqd
*
*/
public class GetTopicsByClusterRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java
index 31c07ba..35ac787 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java
@@ -22,9 +22,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class NotifyConsumerIdsChangedRequestHeader implements CommandCustomHeader {
@CFNotNull
private String consumerGroup;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
index efeed70..7e72ca1 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
@@ -26,9 +26,6 @@ import org.apache.rocketmq.remoting.annotation.CFNullable;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class PullMessageRequestHeader implements CommandCustomHeader {
@CFNotNull
private String consumerGroup;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
index 5a78f7d..576a1b4 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class PullMessageResponseHeader implements CommandCustomHeader {
@CFNotNull
private Long suggestWhichBrokerId;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumeTimeSpanRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumeTimeSpanRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumeTimeSpanRequestHeader.java
index fa3030c..2afdbd5 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumeTimeSpanRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumeTimeSpanRequestHeader.java
@@ -23,7 +23,6 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author manhong.yqd
*
*/
public class QueryConsumeTimeSpanRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
index 0da648f..f38f912 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class QueryConsumerOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
private String consumerGroup;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
index 268bc77..db13a39 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class QueryConsumerOffsetResponseHeader implements CommandCustomHeader {
@CFNotNull
private Long offset;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
index 81ad1ca..da2b200 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
@@ -27,7 +27,6 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
*
- * @author manhong.yqd
*
*/
public class QueryCorrectionOffsetHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
index e30f5fc..f7ab865 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class QueryMessageRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
index 1f5bcae..8e34c73 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class QueryMessageResponseHeader implements CommandCustomHeader {
@CFNotNull
private Long indexLastUpdateTimestamp;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
index 267144e..0d3e7f4 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class QueryTopicConsumeByWhoRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java
index c8294e7..678e85f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java
@@ -24,7 +24,6 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
*
- * @author manhong.yqd
*
*/
public class ResetOffsetRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
index 5e86e16..b355aec 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class SearchOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
index fbe6f00..9a74180 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class SearchOffsetResponseHeader implements CommandCustomHeader {
@CFNotNull
private Long offset;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
index c9a7c7d..d5af104 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
@@ -26,9 +26,6 @@ import org.apache.rocketmq.remoting.annotation.CFNullable;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class SendMessageRequestHeader implements CommandCustomHeader {
@CFNotNull
private String producerGroup;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
index 4206d0b..8bf956d 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
@@ -25,7 +25,6 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
* Use short variable name to speed up FastJson deserialization process.
- * @author vintagewang@apache.org
*/
public class SendMessageRequestHeaderV2 implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
index 58c6def..3457ea7 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class SendMessageResponseHeader implements CommandCustomHeader {
@CFNotNull
private String msgId;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
index d262f1f..4c5e6f1 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
@@ -26,9 +26,6 @@ import org.apache.rocketmq.remoting.annotation.CFNullable;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class UnregisterClientRequestHeader implements CommandCustomHeader {
@CFNotNull
private String clientID;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
index 01f5085..92758a1 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
@@ -24,9 +24,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class UnregisterClientResponseHeader implements CommandCustomHeader {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
index 6cf95a5..40861c1 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class UpdateConsumerOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
private String consumerGroup;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
index 7654a76..d24c5ad 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
@@ -24,9 +24,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class UpdateConsumerOffsetResponseHeader implements CommandCustomHeader {
@Override
public void checkFields() throws RemotingCommandException {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
index 710a87f..4e8d402 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class ViewMessageRequestHeader implements CommandCustomHeader {
@CFNotNull
private Long offset;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
index 1c03754..6c92dc0 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
@@ -24,9 +24,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class ViewMessageResponseHeader implements CommandCustomHeader {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java
index da4ce8a..ff19623 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java
@@ -23,7 +23,6 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author vintagewang@apache.org
*
*/
public class DeleteKVConfigRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java
index 5d897c0..44e8cb6 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java
@@ -22,7 +22,6 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author vintagewang@apache.org
*
*/
public class DeleteTopicInNamesrvRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java
index 9052ae2..b68976a 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java
@@ -23,7 +23,6 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author vintagewang@apache.org
*
*/
public class GetKVConfigRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java
index 4c20e25..88e20d9 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java
@@ -23,7 +23,6 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author vintagewang@apache.org
*
*/
public class GetKVConfigResponseHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java
index 4a614ff..eea086e 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java
@@ -23,7 +23,6 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author vintagewang@apache.org
*
*/
public class GetKVListByNamespaceRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
index b827e8c..4c01d53 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class GetRouteInfoRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
index 49a7c6c..9b192d3 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
@@ -24,9 +24,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class GetRouteInfoResponseHeader implements CommandCustomHeader {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
index be63e0e..2ac0102 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author lansheng.zj
- */
public class RegisterBrokerRequestHeader implements CommandCustomHeader {
@CFNotNull
private String brokerName;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java
index d742b83..68b26ec 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java
@@ -23,7 +23,6 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author vintagewang@apache.org
*
*/
public class RegisterBrokerResponseHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
index 89714f5..9381fa9 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public class RegisterOrderTopicRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
index d517f2d..e5bdd93 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author lansheng.zj
- */
public class UnRegisterBrokerRequestHeader implements CommandCustomHeader {
@CFNotNull
private String brokerName;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java
index 999b163..3f943d7 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java
@@ -22,7 +22,6 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author vintagewang@apache.org
*
*/
public class WipeWritePermOfBrokerRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java
index 1b82074..83d28b6 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java
@@ -22,7 +22,6 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author vintagewang@apache.org
*
*/
public class WipeWritePermOfBrokerResponseHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
index 5e8aeb3..923053b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
@@ -20,9 +20,6 @@
*/
package org.apache.rocketmq.common.protocol.heartbeat;
-/**
- * @author vintagewang@apache.org
- */
public enum ConsumeType {
CONSUME_ACTIVELY("PULL"),
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
index 3a42702..88d9972 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
@@ -26,9 +26,6 @@ import java.util.HashSet;
import java.util.Set;
-/**
- * @author vintagewang@apache.org
- */
public class ConsumerData {
private String groupName;
private ConsumeType consumeType;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
index a0768bb..20a1927 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
@@ -26,9 +26,6 @@ import java.util.HashSet;
import java.util.Set;
-/**
- * @author vintagewang@apache.org
- */
public class HeartbeatData extends RemotingSerializable {
private String clientID;
private Set<ProducerData> producerDataSet = new HashSet<ProducerData>();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
index 8dbb085..858df3f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
@@ -23,7 +23,6 @@ package org.apache.rocketmq.common.protocol.heartbeat;
/**
* Message model
*
- * @author vintagewang@apache.org
*/
public enum MessageModel {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
index cf2c244..7d3d054 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
@@ -20,9 +20,6 @@
*/
package org.apache.rocketmq.common.protocol.heartbeat;
-/**
- * @author vintagewang@apache.org
- */
public class ProducerData {
private String groupName;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
index 0cffabf..c1c9f84 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
@@ -26,9 +26,6 @@ import java.util.HashSet;
import java.util.Set;
-/**
- * @author vintagewang@apache.org
- */
public class SubscriptionData implements Comparable<SubscriptionData> {
public final static String SUB_ALL = "*";
private boolean classFilterMode = false;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
index e4020f3..08e82b1 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
@@ -27,7 +27,6 @@ import java.util.Map;
/**
- * @author vintagewang@apache.org
*
*/
public class BrokerData implements Comparable<BrokerData> {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
index 1ea624e..0061c25 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
@@ -27,9 +27,6 @@ import java.util.HashMap;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class TopicRouteData extends RemotingSerializable {
private String orderTopicConf;
private List<QueueData> queueDatas;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java b/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java
index 7036fdd..897988f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java
+++ b/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java
@@ -30,7 +30,6 @@ import java.util.concurrent.locks.ReentrantLock;
/**
* thread safe
*
- * @author lansheng.zj
*/
public class ConcurrentTreeMap<K, V> {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.java b/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.java
index f32569b..11168e6 100644
--- a/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.java
+++ b/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.java
@@ -24,7 +24,6 @@ import java.util.Queue;
/**
* not thread safe
*
- * @author lansheng.zj
*/
public class RoundQueue<E> {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java b/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
index 8a3bc2f..8fc14cd 100644
--- a/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
+++ b/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
@@ -20,9 +20,6 @@ package org.apache.rocketmq.common.subscription;
import org.apache.rocketmq.common.MixAll;
-/**
- * @author vintagewang@apache.org
- */
public class SubscriptionGroupConfig {
private String groupName;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java b/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java
index a32bc48..4ccfef7 100644
--- a/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java
+++ b/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.common.sysflag;
-/**
- * @author vintagewang@apache.org
- */
public class MessageSysFlag {
public final static int COMPRESSED_FLAG = 0x1;
public final static int MULTI_TAGS_FLAG = 0x1 << 1;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java b/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java
index 34f72b5..193459c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java
+++ b/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.common.sysflag;
-/**
- * @author vintagewang@apache.org
- */
public class PullSysFlag {
private final static int FLAG_COMMIT_OFFSET = 0x1 << 0;
private final static int FLAG_SUSPEND = 0x1 << 1;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/sysflag/SubscriptionSysFlag.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/sysflag/SubscriptionSysFlag.java b/common/src/main/java/org/apache/rocketmq/common/sysflag/SubscriptionSysFlag.java
index 2761a0b..da6401e 100644
--- a/common/src/main/java/org/apache/rocketmq/common/sysflag/SubscriptionSysFlag.java
+++ b/common/src/main/java/org/apache/rocketmq/common/sysflag/SubscriptionSysFlag.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.common.sysflag;
-/**
- * @author manhong.yqd
- */
public class SubscriptionSysFlag {
private final static int FLAG_UNIT = 0x1 << 0;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/sysflag/TopicSysFlag.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/sysflag/TopicSysFlag.java b/common/src/main/java/org/apache/rocketmq/common/sysflag/TopicSysFlag.java
index b12108a..1d804db 100644
--- a/common/src/main/java/org/apache/rocketmq/common/sysflag/TopicSysFlag.java
+++ b/common/src/main/java/org/apache/rocketmq/common/sysflag/TopicSysFlag.java
@@ -19,7 +19,6 @@ package org.apache.rocketmq.common.sysflag;
/**
*
- * @author manhong.yqd
*
*/
public class TopicSysFlag {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java b/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java
index 3284759..a5152f8 100644
--- a/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java
+++ b/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java
@@ -25,9 +25,6 @@ import java.util.ArrayList;
import java.util.List;
-/**
- * @author manhong.yqd
- */
public class IOTinyUtils {
static public String toString(InputStream input, String encoding) throws IOException {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java b/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java
index 6e7c17b..0006f74 100644
--- a/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java
+++ b/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java
@@ -24,9 +24,6 @@ import java.net.InetAddress;
import java.util.List;
-/**
- * @author lansheng.zj
- */
public class MixAllTest {
@Test
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java b/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java
index 5b2d629..cf26efd 100644
--- a/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java
+++ b/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java
@@ -23,7 +23,6 @@ import org.junit.Test;
/**
- * @author vintagewang@apache.org
*
*/
public class FilterAPITest {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
index 819e6e0..bd16e0d 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
@@ -31,9 +31,6 @@ import org.apache.rocketmq.remoting.netty.NettyRemotingClient;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-/**
- * @author vintagewang@apache.org
- */
public class FilterServerOuterAPI {
private final RemotingClient remotingClient;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java
index c4bb8c6..ca136e0 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java
@@ -37,9 +37,6 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-/**
- * @author vintagewang@apache.org
- */
public class FiltersrvController {
private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
index 2cde073..461c79c 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
@@ -39,9 +39,6 @@ import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
-/**
- * @author vintagewang@apache.org
- */
public class FiltersrvStartup {
public static Logger log;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
index 689e27d..f2c98ae 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
@@ -51,9 +51,6 @@ import java.util.ArrayList;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class DefaultRequestProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvController.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvController.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvController.java
index a9f8736..4c286e0 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvController.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvController.java
@@ -37,9 +37,6 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-/**
- * @author vintagewang@apache.org
- */
public class NamesrvController {
private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
index 6806ddf..be824cd 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
@@ -40,9 +40,6 @@ import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
-/**
- * @author vintagewang@apache.org
- */
public class NamesrvStartup {
public static Properties properties = null;
public static CommandLine commandLine = null;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java
index e3da731..c9e534f 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java
@@ -31,9 +31,6 @@ import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-/**
- * @author vintagewang@apache.org
- */
public class KVConfigManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigSerializeWrapper.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigSerializeWrapper.java
index 9f7e2b8..6465927 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigSerializeWrapper.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigSerializeWrapper.java
@@ -21,9 +21,6 @@ import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
import java.util.HashMap;
-/**
- * @author vintagewang@apache.org
- */
public class KVConfigSerializeWrapper extends RemotingSerializable {
private HashMap<String/* Namespace */, HashMap<String/* Key */, String/* Value */>> configTable;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessor.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessor.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessor.java
index c970e94..9ee56a4 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessor.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessor.java
@@ -32,9 +32,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- * @author manhong.yqd
- */
public class ClusterTestRequestProcessor extends DefaultRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
private final DefaultMQAdminExt adminExt;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java
index df78ee2..e47f300 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java
@@ -44,9 +44,6 @@ import java.util.Properties;
import java.util.concurrent.atomic.AtomicLong;
-/**
- * @author vintagewang@apache.org
- */
public class DefaultRequestProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/BrokerHousekeepingService.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/BrokerHousekeepingService.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/BrokerHousekeepingService.java
index b33f174..47e1dc9 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/BrokerHousekeepingService.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/BrokerHousekeepingService.java
@@ -24,9 +24,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- * @author vintagewang@apache.org
- */
public class BrokerHousekeepingService implements ChannelEventListener {
private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
private final NamesrvController namesrvController;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
index f628922..82b4cbf 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
@@ -41,9 +41,6 @@ import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-/**
- * @author vintagewang@apache.org
- */
public class RouteInfoManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
private final static long BROKER_CHANNEL_EXPIRED_TIME = 1000 * 60 * 2;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/ChannelEventListener.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/ChannelEventListener.java b/remoting/src/main/java/org/apache/rocketmq/remoting/ChannelEventListener.java
index 180c8f3..ba93f09 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/ChannelEventListener.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/ChannelEventListener.java
@@ -20,7 +20,6 @@ import io.netty.channel.Channel;
/**
- * @author vintagewang@apache.org
*
*/
public interface ChannelEventListener {
[12/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java b/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java
new file mode 100644
index 0000000..c9303b7
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java
@@ -0,0 +1,89 @@
+/**
+ * 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.common;
+
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public abstract class ConfigManager {
+ private static final Logger PLOG = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
+
+
+ public abstract String encode();
+
+ public boolean load() {
+ String fileName = null;
+ try {
+ fileName = this.configFilePath();
+ String jsonString = MixAll.file2String(fileName);
+
+ if (null == jsonString || jsonString.length() == 0) {
+ return this.loadBak();
+ } else {
+ this.decode(jsonString);
+ PLOG.info("load {} OK", fileName);
+ return true;
+ }
+ } catch (Exception e) {
+ PLOG.error("load " + fileName + " Failed, and try to load backup file", e);
+ return this.loadBak();
+ }
+ }
+
+ public abstract String configFilePath();
+
+ private boolean loadBak() {
+ String fileName = null;
+ try {
+ fileName = this.configFilePath();
+ String jsonString = MixAll.file2String(fileName + ".bak");
+ if (jsonString != null && jsonString.length() > 0) {
+ this.decode(jsonString);
+ PLOG.info("load " + fileName + " OK");
+ return true;
+ }
+ } catch (Exception e) {
+ PLOG.error("load " + fileName + " Failed", e);
+ return false;
+ }
+
+ return true;
+ }
+
+ public abstract void decode(final String jsonString);
+
+ public synchronized void persist() {
+ String jsonString = this.encode(true);
+ if (jsonString != null) {
+ String fileName = this.configFilePath();
+ try {
+ MixAll.string2File(jsonString, fileName);
+ } catch (IOException e) {
+ PLOG.error("persist file Exception, " + fileName, e);
+ }
+ }
+ }
+
+ public abstract String encode(final boolean prettyFormat);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/Configuration.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/Configuration.java b/common/src/main/java/org/apache/rocketmq/common/Configuration.java
new file mode 100644
index 0000000..0ab7c0d
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/Configuration.java
@@ -0,0 +1,310 @@
+/**
+ * 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.common;
+
+import org.slf4j.Logger;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ * @author xigu.lx
+ */
+public class Configuration {
+
+ private final Logger log;
+
+ private List<Object> configObjectList = new ArrayList<Object>(4);
+ private String storePath;
+ private boolean storePathFromConfig = false;
+ private Object storePathObject;
+ private Field storePathField;
+ private DataVersion dataVersion = new DataVersion();
+ private ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
+ /**
+ * All properties include configs in object and extend properties.
+ */
+ private Properties allConfigs = new Properties();
+
+ public Configuration(Logger log) {
+ this.log = log;
+ }
+
+ public Configuration(Logger log, Object... configObjects) {
+ this.log = log;
+ if (configObjects == null || configObjects.length == 0) {
+ return;
+ }
+ for (Object configObject : configObjects) {
+ registerConfig(configObject);
+ }
+ }
+
+ public Configuration(Logger log, String storePath, Object... configObjects) {
+ this(log, configObjects);
+ this.storePath = storePath;
+ }
+
+ /**
+ * register config object
+ *
+ * @param configObject
+ * @return the current Configuration object
+ */
+ public Configuration registerConfig(Object configObject) {
+ try {
+ readWriteLock.writeLock().lockInterruptibly();
+
+ try {
+
+ Properties registerProps = MixAll.object2Properties(configObject);
+
+ merge(registerProps, this.allConfigs);
+
+ configObjectList.add(configObject);
+ } finally {
+ readWriteLock.writeLock().unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("registerConfig lock error");
+ }
+ return this;
+ }
+
+ /**
+ * register config properties
+ *
+ * @param extProperties
+ * @return the current Configuration object
+ */
+ public Configuration registerConfig(Properties extProperties) {
+ if (extProperties == null) {
+ return this;
+ }
+
+ try {
+ readWriteLock.writeLock().lockInterruptibly();
+
+ try {
+ merge(extProperties, this.allConfigs);
+ } finally {
+ readWriteLock.writeLock().unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("register lock error. {}" + extProperties);
+ }
+
+ return this;
+ }
+
+ /**
+ * The store path will be gotten from the field of object.
+ *
+ * @param object
+ * @param fieldName
+ *
+ * @throws java.lang.RuntimeException if the field of object is not exist.
+ */
+ public void setStorePathFromConfig(Object object, String fieldName) {
+ assert object != null;
+
+ try {
+ readWriteLock.writeLock().lockInterruptibly();
+
+ try {
+ this.storePathFromConfig = true;
+ this.storePathObject = object;
+ // check
+ this.storePathField = object.getClass().getDeclaredField(fieldName);
+ assert this.storePathField != null
+ && !Modifier.isStatic(this.storePathField.getModifiers());
+ this.storePathField.setAccessible(true);
+ } catch (NoSuchFieldException e) {
+ throw new RuntimeException(e);
+ } finally {
+ readWriteLock.writeLock().unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("setStorePathFromConfig lock error");
+ }
+ }
+
+ private String getStorePath() {
+ String realStorePath = null;
+ try {
+ readWriteLock.readLock().lockInterruptibly();
+
+ try {
+ realStorePath = this.storePath;
+
+ if (this.storePathFromConfig) {
+ try {
+ realStorePath = (String) storePathField.get(this.storePathObject);
+ } catch (IllegalAccessException e) {
+ log.error("getStorePath error, ", e);
+ }
+ }
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("getStorePath lock error");
+ }
+
+ return realStorePath;
+ }
+
+ public void update(Properties properties) {
+ try {
+ readWriteLock.writeLock().lockInterruptibly();
+
+ try {
+ // the property must be exist when update
+ mergeIfExist(properties, this.allConfigs);
+
+ for (Object configObject : configObjectList) {
+ // not allConfigs to update...
+ MixAll.properties2Object(properties, configObject);
+ }
+
+ this.dataVersion.nextVersion();
+
+ } finally {
+ readWriteLock.writeLock().unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("update lock error, {}", properties);
+ return;
+ }
+
+ persist();
+ }
+
+ public void persist() {
+ try {
+ readWriteLock.readLock().lockInterruptibly();
+
+ try {
+ String allConfigs = getAllConfigsInternal();
+
+ MixAll.string2File(allConfigs, getStorePath());
+ } catch (IOException e) {
+ log.error("persist string2File error, ", e);
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("persist lock error");
+ }
+ }
+
+ public String getAllConfigsFormatString() {
+ try {
+ readWriteLock.readLock().lockInterruptibly();
+
+ try {
+
+ return getAllConfigsInternal();
+
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("getAllConfigsFormatString lock error");
+ }
+
+ return null;
+ }
+
+ public String getDataVersionJson() {
+ return this.dataVersion.toJson();
+ }
+
+ public Properties getAllConfigs() {
+ try {
+ readWriteLock.readLock().lockInterruptibly();
+
+ try {
+
+ return this.allConfigs;
+
+ } finally {
+ readWriteLock.readLock().unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("getAllConfigs lock error");
+ }
+
+ return null;
+ }
+
+ private String getAllConfigsInternal() {
+ StringBuilder stringBuilder = new StringBuilder();
+
+ // reload from config object ?
+ for (Object configObject : this.configObjectList) {
+ Properties properties = MixAll.object2Properties(configObject);
+ if (properties != null) {
+ merge(properties, this.allConfigs);
+ } else {
+ log.warn("getAllConfigsInternal object2Properties is null, {}", configObject.getClass());
+ }
+ }
+
+ {
+ stringBuilder.append(MixAll.properties2String(this.allConfigs));
+ }
+
+ return stringBuilder.toString();
+ }
+
+ public void setStorePath(final String storePath) {
+ this.storePath = storePath;
+ }
+
+ private void merge(Properties from, Properties to) {
+ for (Object key : from.keySet()) {
+ Object fromObj = from.get(key), toObj = to.get(key);
+ if (toObj != null && !toObj.equals(fromObj)) {
+ log.info("Replace, key: {}, value: {} -> {}", key, toObj, fromObj);
+ }
+ to.put(key, fromObj);
+ }
+ }
+
+ private void mergeIfExist(Properties from, Properties to) {
+ for (Object key : from.keySet()) {
+ if (!to.containsKey(key)) {
+ continue;
+ }
+
+ Object fromObj = from.get(key), toObj = to.get(key);
+ if (toObj != null && !toObj.equals(fromObj)) {
+ log.info("Replace, key: {}, value: {} -> {}", key, toObj, fromObj);
+ }
+ to.put(key, fromObj);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/CountDownLatch.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/CountDownLatch.java b/common/src/main/java/org/apache/rocketmq/common/CountDownLatch.java
new file mode 100644
index 0000000..971c0c7
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/CountDownLatch.java
@@ -0,0 +1,207 @@
+/**
+ * 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.common;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.AbstractQueuedSynchronizer;
+
+/**
+ * Add reset feature for @see java.util.concurrent.CountDownLatch
+ *
+ * @author xinyuzhou.zxy
+ */
+public class CountDownLatch {
+ /**
+ * Synchronization control For CountDownLatch.
+ * Uses AQS state to represent count.
+ */
+ private static final class Sync extends AbstractQueuedSynchronizer {
+ private static final long serialVersionUID = 4982264981922014374L;
+
+ private final int startCount;
+
+ Sync(int count) {
+ this.startCount = count;
+ setState(count);
+ }
+
+ int getCount() {
+ return getState();
+ }
+
+ protected int tryAcquireShared(int acquires) {
+ return (getState() == 0) ? 1 : -1;
+ }
+
+ protected boolean tryReleaseShared(int releases) {
+ // Decrement count; signal when transition to zero
+ for (;;) {
+ int c = getState();
+ if (c == 0)
+ return false;
+ int nextc = c - 1;
+ if (compareAndSetState(c, nextc))
+ return nextc == 0;
+ }
+ }
+
+ protected void reset() {
+ setState(startCount);
+ }
+ }
+
+ private final Sync sync;
+
+ /**
+ * Constructs a {@code CountDownLatch} initialized with the given count.
+ *
+ * @param count
+ * the number of times {@link #countDown} must be invoked
+ * before threads can pass through {@link #await}
+ *
+ * @throws IllegalArgumentException
+ * if {@code count} is negative
+ */
+ public CountDownLatch(int count) {
+ if (count < 0) throw new IllegalArgumentException("count < 0");
+ this.sync = new Sync(count);
+ }
+
+ /**
+ * Causes the current thread to wait until the latch has counted down to
+ * zero, unless the thread is {@linkplain Thread#interrupt interrupted}.
+ *
+ * <p>If the current count is zero then this method returns immediately.
+ *
+ * <p>If the current count is greater than zero then the current
+ * thread becomes disabled for thread scheduling purposes and lies
+ * dormant until one of two things happen:
+ * <ul>
+ * <li>The count reaches zero due to invocations of the
+ * {@link #countDown} method; or
+ * <li>Some other thread {@linkplain Thread#interrupt interrupts}
+ * the current thread.
+ * </ul>
+ *
+ * <p>If the current thread:
+ * <ul>
+ * <li>has its interrupted status set on entry to this method; or
+ * <li>is {@linkplain Thread#interrupt interrupted} while waiting,
+ * </ul>
+ * then {@link InterruptedException} is thrown and the current thread's
+ * interrupted status is cleared.
+ *
+ * @throws InterruptedException
+ * if the current thread is interrupted
+ * while waiting
+ */
+ public void await() throws InterruptedException {
+ sync.acquireSharedInterruptibly(1);
+ }
+
+ /**
+ * Causes the current thread to wait until the latch has counted down to
+ * zero, unless the thread is {@linkplain Thread#interrupt interrupted},
+ * or the specified waiting time elapses.
+ *
+ * <p>If the current count is zero then this method returns immediately
+ * with the value {@code true}.
+ *
+ * <p>If the current count is greater than zero then the current
+ * thread becomes disabled for thread scheduling purposes and lies
+ * dormant until one of three things happen:
+ * <ul>
+ * <li>The count reaches zero due to invocations of the
+ * {@link #countDown} method; or
+ * <li>Some other thread {@linkplain Thread#interrupt interrupts}
+ * the current thread; or
+ * <li>The specified waiting time elapses.
+ * </ul>
+ *
+ * <p>If the count reaches zero then the method returns with the
+ * value {@code true}.
+ *
+ * <p>If the current thread:
+ * <ul>
+ * <li>has its interrupted status set on entry to this method; or
+ * <li>is {@linkplain Thread#interrupt interrupted} while waiting,
+ * </ul>
+ * then {@link InterruptedException} is thrown and the current thread's
+ * interrupted status is cleared.
+ *
+ * <p>If the specified waiting time elapses then the value {@code false}
+ * is returned. If the time is less than or equal to zero, the method
+ * will not wait at all.
+ *
+ * @param timeout
+ * the maximum time to wait
+ * @param unit
+ * the time unit of the {@code timeout} argument
+ *
+ * @return {@code true} if the count reached zero and {@code false}
+ * if the waiting time elapsed before the count reached zero
+ *
+ * @throws InterruptedException
+ * if the current thread is interrupted
+ * while waiting
+ */
+ public boolean await(long timeout, TimeUnit unit)
+ throws InterruptedException {
+ return sync.tryAcquireSharedNanos(1, unit.toNanos(timeout));
+ }
+
+ /**
+ * Decrements the count of the latch, releasing all waiting threads if
+ * the count reaches zero.
+ *
+ * <p>If the current count is greater than zero then it is decremented.
+ * If the new count is zero then all waiting threads are re-enabled for
+ * thread scheduling purposes.
+ *
+ * <p>If the current count equals zero then nothing happens.
+ */
+ public void countDown() {
+ sync.releaseShared(1);
+ }
+
+ /**
+ * Returns the current count.
+ *
+ * <p>This method is typically used for debugging and testing purposes.
+ *
+ * @return the current count
+ */
+ public long getCount() {
+ return sync.getCount();
+ }
+
+ public void reset() {
+ sync.reset();
+ }
+
+ /**
+ * Returns a string identifying this latch, as well as its state.
+ * The state, in brackets, includes the String {@code "Count ="}
+ * followed by the current count.
+ *
+ * @return a string identifying this latch, as well as its state
+ */
+ public String toString() {
+ return super.toString() + "[Count = " + sync.getCount() + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/DataVersion.java b/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
new file mode 100644
index 0000000..94fd90b
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
@@ -0,0 +1,82 @@
+/**
+ * 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.common;
+
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class DataVersion extends RemotingSerializable {
+ private long timestatmp = System.currentTimeMillis();
+ private AtomicLong counter = new AtomicLong(0);
+
+
+ public void assignNewOne(final DataVersion dataVersion) {
+ this.timestatmp = dataVersion.timestatmp;
+ this.counter.set(dataVersion.counter.get());
+ }
+
+
+ public void nextVersion() {
+ this.timestatmp = System.currentTimeMillis();
+ this.counter.incrementAndGet();
+ }
+
+
+ public long getTimestatmp() {
+ return timestatmp;
+ }
+
+
+ public void setTimestatmp(long timestatmp) {
+ this.timestatmp = timestatmp;
+ }
+
+
+ public AtomicLong getCounter() {
+ return counter;
+ }
+
+
+ public void setCounter(AtomicLong counter) {
+ this.counter = counter;
+ }
+
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final DataVersion that = (DataVersion) o;
+
+ if (timestatmp != that.timestatmp) return false;
+ return counter != null ? counter.equals(that.counter) : that.counter == null;
+
+ }
+
+ @Override
+ public int hashCode() {
+ int result = (int) (timestatmp ^ (timestatmp >>> 32));
+ result = 31 * result + (counter != null ? counter.hashCode() : 0);
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/MQVersion.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/MQVersion.java b/common/src/main/java/org/apache/rocketmq/common/MQVersion.java
new file mode 100644
index 0000000..f53fc27
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/MQVersion.java
@@ -0,0 +1,362 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.common;
+
+/**
+ * @author shijia.wxr
+ */
+public class MQVersion {
+
+ public static final int CURRENT_VERSION = Version.V4_0_0_SNAPSHOT.ordinal();
+
+
+ public static String getVersionDesc(int value) {
+ try {
+ Version v = Version.values()[value];
+ return v.name();
+ } catch (Exception e) {
+ }
+
+ return "HigherVersion";
+ }
+
+
+ public static Version value2Version(int value) {
+ return Version.values()[value];
+ }
+
+ public enum Version {
+ V3_0_0_SNAPSHOT,
+ V3_0_0_ALPHA1,
+ V3_0_0_BETA1,
+ V3_0_0_BETA2,
+ V3_0_0_BETA3,
+ V3_0_0_BETA4,
+ V3_0_0_BETA5,
+ V3_0_0_BETA6_SNAPSHOT,
+ V3_0_0_BETA6,
+ V3_0_0_BETA7_SNAPSHOT,
+ V3_0_0_BETA7,
+ V3_0_0_BETA8_SNAPSHOT,
+ V3_0_0_BETA8,
+ V3_0_0_BETA9_SNAPSHOT,
+ V3_0_0_BETA9,
+ V3_0_0_FINAL,
+ V3_0_1_SNAPSHOT,
+ V3_0_1,
+ V3_0_2_SNAPSHOT,
+ V3_0_2,
+ V3_0_3_SNAPSHOT,
+ V3_0_3,
+ V3_0_4_SNAPSHOT,
+ V3_0_4,
+ V3_0_5_SNAPSHOT,
+ V3_0_5,
+ V3_0_6_SNAPSHOT,
+ V3_0_6,
+ V3_0_7_SNAPSHOT,
+ V3_0_7,
+ V3_0_8_SNAPSHOT,
+ V3_0_8,
+ V3_0_9_SNAPSHOT,
+ V3_0_9,
+
+ V3_0_10_SNAPSHOT,
+ V3_0_10,
+
+ V3_0_11_SNAPSHOT,
+ V3_0_11,
+
+ V3_0_12_SNAPSHOT,
+ V3_0_12,
+
+ V3_0_13_SNAPSHOT,
+ V3_0_13,
+
+ V3_0_14_SNAPSHOT,
+ V3_0_14,
+
+ V3_0_15_SNAPSHOT,
+ V3_0_15,
+
+ V3_1_0_SNAPSHOT,
+ V3_1_0,
+
+ V3_1_1_SNAPSHOT,
+ V3_1_1,
+
+ V3_1_2_SNAPSHOT,
+ V3_1_2,
+
+ V3_1_3_SNAPSHOT,
+ V3_1_3,
+
+ V3_1_4_SNAPSHOT,
+ V3_1_4,
+
+ V3_1_5_SNAPSHOT,
+ V3_1_5,
+
+ V3_1_6_SNAPSHOT,
+ V3_1_6,
+
+ V3_1_7_SNAPSHOT,
+ V3_1_7,
+
+ V3_1_8_SNAPSHOT,
+ V3_1_8,
+
+ V3_1_9_SNAPSHOT,
+ V3_1_9,
+
+ V3_2_0_SNAPSHOT,
+ V3_2_0,
+
+ V3_2_1_SNAPSHOT,
+ V3_2_1,
+
+ V3_2_2_SNAPSHOT,
+ V3_2_2,
+
+ V3_2_3_SNAPSHOT,
+ V3_2_3,
+
+ V3_2_4_SNAPSHOT,
+ V3_2_4,
+
+ V3_2_5_SNAPSHOT,
+ V3_2_5,
+
+ V3_2_6_SNAPSHOT,
+ V3_2_6,
+
+ V3_2_7_SNAPSHOT,
+ V3_2_7,
+
+ V3_2_8_SNAPSHOT,
+ V3_2_8,
+
+ V3_2_9_SNAPSHOT,
+ V3_2_9,
+
+ V3_3_1_SNAPSHOT,
+ V3_3_1,
+
+ V3_3_2_SNAPSHOT,
+ V3_3_2,
+
+ V3_3_3_SNAPSHOT,
+ V3_3_3,
+
+ V3_3_4_SNAPSHOT,
+ V3_3_4,
+
+ V3_3_5_SNAPSHOT,
+ V3_3_5,
+
+ V3_3_6_SNAPSHOT,
+ V3_3_6,
+
+ V3_3_7_SNAPSHOT,
+ V3_3_7,
+
+ V3_3_8_SNAPSHOT,
+ V3_3_8,
+
+ V3_3_9_SNAPSHOT,
+ V3_3_9,
+
+ V3_4_1_SNAPSHOT,
+ V3_4_1,
+
+ V3_4_2_SNAPSHOT,
+ V3_4_2,
+
+ V3_4_3_SNAPSHOT,
+ V3_4_3,
+
+ V3_4_4_SNAPSHOT,
+ V3_4_4,
+
+ V3_4_5_SNAPSHOT,
+ V3_4_5,
+
+ V3_4_6_SNAPSHOT,
+ V3_4_6,
+
+ V3_4_7_SNAPSHOT,
+ V3_4_7,
+
+ V3_4_8_SNAPSHOT,
+ V3_4_8,
+
+ V3_4_9_SNAPSHOT,
+ V3_4_9,
+ V3_5_1_SNAPSHOT,
+ V3_5_1,
+
+ V3_5_2_SNAPSHOT,
+ V3_5_2,
+
+ V3_5_3_SNAPSHOT,
+ V3_5_3,
+
+ V3_5_4_SNAPSHOT,
+ V3_5_4,
+
+ V3_5_5_SNAPSHOT,
+ V3_5_5,
+
+ V3_5_6_SNAPSHOT,
+ V3_5_6,
+
+ V3_5_7_SNAPSHOT,
+ V3_5_7,
+
+ V3_5_8_SNAPSHOT,
+ V3_5_8,
+
+ V3_5_9_SNAPSHOT,
+ V3_5_9,
+
+ V3_6_1_SNAPSHOT,
+ V3_6_1,
+
+ V3_6_2_SNAPSHOT,
+ V3_6_2,
+
+ V3_6_3_SNAPSHOT,
+ V3_6_3,
+
+ V3_6_4_SNAPSHOT,
+ V3_6_4,
+
+ V3_6_5_SNAPSHOT,
+ V3_6_5,
+
+ V3_6_6_SNAPSHOT,
+ V3_6_6,
+
+ V3_6_7_SNAPSHOT,
+ V3_6_7,
+
+ V3_6_8_SNAPSHOT,
+ V3_6_8,
+
+ V3_6_9_SNAPSHOT,
+ V3_6_9,
+
+ V3_7_1_SNAPSHOT,
+ V3_7_1,
+
+ V3_7_2_SNAPSHOT,
+ V3_7_2,
+
+ V3_7_3_SNAPSHOT,
+ V3_7_3,
+
+ V3_7_4_SNAPSHOT,
+ V3_7_4,
+
+ V3_7_5_SNAPSHOT,
+ V3_7_5,
+
+ V3_7_6_SNAPSHOT,
+ V3_7_6,
+
+ V3_7_7_SNAPSHOT,
+ V3_7_7,
+
+ V3_7_8_SNAPSHOT,
+ V3_7_8,
+
+ V3_7_9_SNAPSHOT,
+ V3_7_9,
+
+ V3_8_1_SNAPSHOT,
+ V3_8_1,
+
+ V3_8_2_SNAPSHOT,
+ V3_8_2,
+
+ V3_8_3_SNAPSHOT,
+ V3_8_3,
+
+ V3_8_4_SNAPSHOT,
+ V3_8_4,
+
+ V3_8_5_SNAPSHOT,
+ V3_8_5,
+
+ V3_8_6_SNAPSHOT,
+ V3_8_6,
+
+ V3_8_7_SNAPSHOT,
+ V3_8_7,
+
+ V3_8_8_SNAPSHOT,
+ V3_8_8,
+
+ V3_8_9_SNAPSHOT,
+ V3_8_9,
+
+ V3_9_1_SNAPSHOT,
+ V3_9_1,
+
+ V3_9_2_SNAPSHOT,
+ V3_9_2,
+
+ V3_9_3_SNAPSHOT,
+ V3_9_3,
+
+ V3_9_4_SNAPSHOT,
+ V3_9_4,
+
+ V3_9_5_SNAPSHOT,
+ V3_9_5,
+
+ V3_9_6_SNAPSHOT,
+ V3_9_6,
+
+ V3_9_7_SNAPSHOT,
+ V3_9_7,
+
+ V3_9_8_SNAPSHOT,
+ V3_9_8,
+
+ V3_9_9_SNAPSHOT,
+ V3_9_9,
+
+ V4_0_0_SNAPSHOT,
+ V4_0_0,
+
+ V4_1_0_SNAPSHOT,
+ V4_1_0,
+
+ V4_2_0_SNAPSHOT,
+ V4_2_0,
+
+ V4_3_0_SNAPSHOT,
+ V4_3_0,
+
+ V4_4_0_SNAPSHOT,
+ V4_4_0,
+
+ V4_5_0_SNAPSHOT,
+ V4_5_0,
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/MixAll.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/MixAll.java b/common/src/main/java/org/apache/rocketmq/common/MixAll.java
new file mode 100644
index 0000000..12fb65a
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/MixAll.java
@@ -0,0 +1,486 @@
+/**
+ * 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.common;
+
+import org.apache.rocketmq.common.annotation.ImportantField;
+import org.apache.rocketmq.common.help.FAQUrl;
+import org.slf4j.Logger;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class MixAll {
+ public static final String ROCKETMQ_HOME_ENV = "ROCKETMQ_HOME";
+ public static final String ROCKETMQ_HOME_PROPERTY = "rocketmq.home.dir";
+ public static final String NAMESRV_ADDR_ENV = "NAMESRV_ADDR";
+ public static final String NAMESRV_ADDR_PROPERTY = "rocketmq.namesrv.addr";
+ public static final String MESSAGE_COMPRESS_LEVEL = "rocketmq.message.compressLevel";
+ public static final String WS_DOMAIN_NAME = System.getProperty("rocketmq.namesrv.domain", "jmenv.tbsite.net");
+ public static final String WS_DOMAIN_SUBGROUP = System.getProperty("rocketmq.namesrv.domain.subgroup", "nsaddr");
+ // http://jmenv.tbsite.net:8080/rocketmq/nsaddr
+ public static final String WS_ADDR = "http://" + WS_DOMAIN_NAME + ":8080/rocketmq/" + WS_DOMAIN_SUBGROUP;
+ public static final String DEFAULT_TOPIC = "TBW102";
+ public static final String BENCHMARK_TOPIC = "BenchmarkTest";
+ public static final String DEFAULT_PRODUCER_GROUP = "DEFAULT_PRODUCER";
+ public static final String DEFAULT_CONSUMER_GROUP = "DEFAULT_CONSUMER";
+ public static final String TOOLS_CONSUMER_GROUP = "TOOLS_CONSUMER";
+ public static final String FILTERSRV_CONSUMER_GROUP = "FILTERSRV_CONSUMER";
+ public static final String MONITOR_CONSUMER_GROUP = "__MONITOR_CONSUMER";
+ public static final String CLIENT_INNER_PRODUCER_GROUP = "CLIENT_INNER_PRODUCER";
+ public static final String SELF_TEST_PRODUCER_GROUP = "SELF_TEST_P_GROUP";
+ public static final String SELF_TEST_CONSUMER_GROUP = "SELF_TEST_C_GROUP";
+ public static final String SELF_TEST_TOPIC = "SELF_TEST_TOPIC";
+ public static final String OFFSET_MOVED_EVENT = "OFFSET_MOVED_EVENT";
+ public static final String ONS_HTTP_PROXY_GROUP = "CID_ONS-HTTP-PROXY";
+ public static final String CID_ONSAPI_PERMISSION_GROUP = "CID_ONSAPI_PERMISSION";
+ public static final String CID_ONSAPI_OWNER_GROUP = "CID_ONSAPI_OWNER";
+ public static final String CID_ONSAPI_PULL_GROUP = "CID_ONSAPI_PULL";
+ public static final String CID_RMQ_SYS_PREFIX = "CID_RMQ_SYS_";
+
+ public static final List<String> LOCAL_INET_ADDRESS = getLocalInetAddress();
+ public static final String LOCALHOST = localhost();
+ public static final String DEFAULT_CHARSET = "UTF-8";
+ public static final long MASTER_ID = 0L;
+ public static final long CURRENT_JVM_PID = getPID();
+
+ public static final String RETRY_GROUP_TOPIC_PREFIX = "%RETRY%";
+
+ public static final String DLQ_GROUP_TOPIC_PREFIX = "%DLQ%";
+ public static final String SYSTEM_TOPIC_PREFIX = "rmq_sys_";
+ public static final String UNIQUE_MSG_QUERY_FLAG = "_UNIQUE_KEY_QUERY";
+ public static final String DEFAULT_TRACE_REGION_ID = "DefaultRegion";
+ public static final String CONSUME_CONTEXT_TYPE = "ConsumeContextType";
+
+ public static String getRetryTopic(final String consumerGroup) {
+ return RETRY_GROUP_TOPIC_PREFIX + consumerGroup;
+ }
+
+
+ public static boolean isSysConsumerGroup(final String consumerGroup) {
+ return consumerGroup.startsWith(CID_RMQ_SYS_PREFIX);
+ }
+
+ public static boolean isSystemTopic(final String topic) {
+ return topic.startsWith(SYSTEM_TOPIC_PREFIX);
+ }
+
+ public static String getDLQTopic(final String consumerGroup) {
+ return DLQ_GROUP_TOPIC_PREFIX + consumerGroup;
+ }
+
+
+ public static String brokerVIPChannel(final boolean isChange, final String brokerAddr) {
+ if (isChange) {
+ String[] ipAndPort = brokerAddr.split(":");
+ String brokerAddrNew = ipAndPort[0] + ":" + (Integer.parseInt(ipAndPort[1]) - 2);
+ return brokerAddrNew;
+ } else {
+ return brokerAddr;
+ }
+ }
+
+
+ public static long getPID() {
+ String processName = java.lang.management.ManagementFactory.getRuntimeMXBean().getName();
+ if (processName != null && processName.length() > 0) {
+ try {
+ return Long.parseLong(processName.split("@")[0]);
+ } catch (Exception e) {
+ return 0;
+ }
+ }
+
+ return 0;
+ }
+
+
+ public static long createBrokerId(final String ip, final int port) {
+ InetSocketAddress isa = new InetSocketAddress(ip, port);
+ byte[] ipArray = isa.getAddress().getAddress();
+ ByteBuffer bb = ByteBuffer.allocate(8);
+ bb.put(ipArray);
+ bb.putInt(port);
+ long value = bb.getLong(0);
+ return Math.abs(value);
+ }
+
+ public static final void string2File(final String str, final String fileName) throws IOException {
+
+ String tmpFile = fileName + ".tmp";
+ string2FileNotSafe(str, tmpFile);
+
+
+ String bakFile = fileName + ".bak";
+ String prevContent = file2String(fileName);
+ if (prevContent != null) {
+ string2FileNotSafe(prevContent, bakFile);
+ }
+
+
+ File file = new File(fileName);
+ file.delete();
+
+
+ file = new File(tmpFile);
+ file.renameTo(new File(fileName));
+ }
+
+
+ public static final void string2FileNotSafe(final String str, final String fileName) throws IOException {
+ File file = new File(fileName);
+ File fileParent = file.getParentFile();
+ if (fileParent != null) {
+ fileParent.mkdirs();
+ }
+ FileWriter fileWriter = null;
+
+ try {
+ fileWriter = new FileWriter(file);
+ fileWriter.write(str);
+ } catch (IOException e) {
+ throw e;
+ } finally {
+ if (fileWriter != null) {
+ try {
+ fileWriter.close();
+ } catch (IOException e) {
+ throw e;
+ }
+ }
+ }
+ }
+
+
+ public static final String file2String(final String fileName) {
+ File file = new File(fileName);
+ return file2String(file);
+ }
+
+ public static final String file2String(final File file) {
+ if (file.exists()) {
+ char[] data = new char[(int) file.length()];
+ boolean result = false;
+
+ FileReader fileReader = null;
+ try {
+ fileReader = new FileReader(file);
+ int len = fileReader.read(data);
+ result = len == data.length;
+ } catch (IOException e) {
+ // e.printStackTrace();
+ } finally {
+ if (fileReader != null) {
+ try {
+ fileReader.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ if (result) {
+ return new String(data);
+ }
+ }
+ return null;
+ }
+
+ public static final String file2String(final URL url) {
+ InputStream in = null;
+ try {
+ URLConnection urlConnection = url.openConnection();
+ urlConnection.setUseCaches(false);
+ in = urlConnection.getInputStream();
+ int len = in.available();
+ byte[] data = new byte[len];
+ in.read(data, 0, len);
+ return new String(data, "UTF-8");
+ } catch (Exception e) {
+ } finally {
+ if (null != in) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public static String findClassPath(Class<?> c) {
+ URL url = c.getProtectionDomain().getCodeSource().getLocation();
+ return url.getPath();
+ }
+
+
+ public static void printObjectProperties(final Logger log, final Object object) {
+ printObjectProperties(log, object, false);
+ }
+
+
+ public static void printObjectProperties(final Logger log, final Object object, final boolean onlyImportantField) {
+ Field[] fields = object.getClass().getDeclaredFields();
+ for (Field field : fields) {
+ if (!Modifier.isStatic(field.getModifiers())) {
+ String name = field.getName();
+ if (!name.startsWith("this")) {
+ Object value = null;
+ try {
+ field.setAccessible(true);
+ value = field.get(object);
+ if (null == value) {
+ value = "";
+ }
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+
+ if (onlyImportantField) {
+ Annotation annotation = field.getAnnotation(ImportantField.class);
+ if (null == annotation) {
+ continue;
+ }
+ }
+
+ if (log != null) {
+ log.info(name + "=" + value);
+ } else {
+ }
+ }
+ }
+ }
+ }
+
+
+ public static String properties2String(final Properties properties) {
+ StringBuilder sb = new StringBuilder();
+ for (Map.Entry<Object, Object> entry : properties.entrySet()) {
+ if (entry.getValue() != null) {
+ sb.append(entry.getKey().toString() + "=" + entry.getValue().toString() + "\n");
+ }
+ }
+ return sb.toString();
+ }
+
+ public static Properties string2Properties(final String str) {
+ Properties properties = new Properties();
+ try {
+ InputStream in = new ByteArrayInputStream(str.getBytes(DEFAULT_CHARSET));
+ properties.load(in);
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ return null;
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ return properties;
+ }
+
+ public static Properties object2Properties(final Object object) {
+ Properties properties = new Properties();
+
+ Field[] fields = object.getClass().getDeclaredFields();
+ for (Field field : fields) {
+ if (!Modifier.isStatic(field.getModifiers())) {
+ String name = field.getName();
+ if (!name.startsWith("this")) {
+ Object value = null;
+ try {
+ field.setAccessible(true);
+ value = field.get(object);
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+
+ if (value != null) {
+ properties.setProperty(name, value.toString());
+ }
+ }
+ }
+ }
+
+ return properties;
+ }
+
+ public static void properties2Object(final Properties p, final Object object) {
+ Method[] methods = object.getClass().getMethods();
+ for (Method method : methods) {
+ String mn = method.getName();
+ if (mn.startsWith("set")) {
+ try {
+ String tmp = mn.substring(4);
+ String first = mn.substring(3, 4);
+
+ String key = first.toLowerCase() + tmp;
+ String property = p.getProperty(key);
+ if (property != null) {
+ Class<?>[] pt = method.getParameterTypes();
+ if (pt != null && pt.length > 0) {
+ String cn = pt[0].getSimpleName();
+ Object arg = null;
+ if (cn.equals("int") || cn.equals("Integer")) {
+ arg = Integer.parseInt(property);
+ } else if (cn.equals("long") || cn.equals("Long")) {
+ arg = Long.parseLong(property);
+ } else if (cn.equals("double") || cn.equals("Double")) {
+ arg = Double.parseDouble(property);
+ } else if (cn.equals("boolean") || cn.equals("Boolean")) {
+ arg = Boolean.parseBoolean(property);
+ } else if (cn.equals("float") || cn.equals("Float")) {
+ arg = Float.parseFloat(property);
+ } else if (cn.equals("String")) {
+ arg = property;
+ } else {
+ continue;
+ }
+ method.invoke(object, new Object[]{arg});
+ }
+ }
+ } catch (Throwable e) {
+ }
+ }
+ }
+ }
+
+
+ public static boolean isPropertiesEqual(final Properties p1, final Properties p2) {
+ return p1.equals(p2);
+ }
+
+
+ public static List<String> getLocalInetAddress() {
+ List<String> inetAddressList = new ArrayList<String>();
+ try {
+ Enumeration<NetworkInterface> enumeration = NetworkInterface.getNetworkInterfaces();
+ while (enumeration.hasMoreElements()) {
+ NetworkInterface networkInterface = enumeration.nextElement();
+ Enumeration<InetAddress> addrs = networkInterface.getInetAddresses();
+ while (addrs.hasMoreElements()) {
+ inetAddressList.add(addrs.nextElement().getHostAddress());
+ }
+ }
+ } catch (SocketException e) {
+ throw new RuntimeException("get local inet address fail", e);
+ }
+
+ return inetAddressList;
+ }
+
+
+ public static boolean isLocalAddr(String address) {
+ for (String addr : LOCAL_INET_ADDRESS) {
+ if (address.contains(addr))
+ return true;
+ }
+ return false;
+ }
+
+
+ private static String localhost() {
+ try {
+ InetAddress addr = InetAddress.getLocalHost();
+ return addr.getHostAddress();
+ } catch (Throwable e) {
+ throw new RuntimeException("InetAddress java.net.InetAddress.getLocalHost() throws UnknownHostException"
+ + FAQUrl.suggestTodo(FAQUrl.UNKNOWN_HOST_EXCEPTION),
+ e);
+ }
+ }
+
+
+ public static boolean compareAndIncreaseOnly(final AtomicLong target, final long value) {
+ long prev = target.get();
+ while (value > prev) {
+ boolean updated = target.compareAndSet(prev, value);
+ if (updated)
+ return true;
+
+ prev = target.get();
+ }
+
+ return false;
+ }
+
+ public static String localhostName() {
+ try {
+ return InetAddress.getLocalHost().getHostName();
+ } catch (Throwable e) {
+ throw new RuntimeException("InetAddress java.net.InetAddress.getLocalHost() throws UnknownHostException"
+ + FAQUrl.suggestTodo(FAQUrl.UNKNOWN_HOST_EXCEPTION),
+ e);
+ }
+ }
+
+ public Set<String> list2Set(List<String> values) {
+ Set<String> result = new HashSet<String>();
+ for (String v : values) {
+ result.add(v);
+ }
+ return result;
+ }
+
+ public List<String> set2List(Set<String> values) {
+ List<String> result = new ArrayList<String>();
+ for (String v : values) {
+ result.add(v);
+ }
+ return result;
+ }
+
+ public static String humanReadableByteCount(long bytes, boolean si) {
+ int unit = si ? 1000 : 1024;
+ if (bytes < unit) return bytes + " B";
+ int exp = (int) (Math.log(bytes) / Math.log(unit));
+ String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i");
+ return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/Pair.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/Pair.java b/common/src/main/java/org/apache/rocketmq/common/Pair.java
new file mode 100644
index 0000000..ed6c246
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/Pair.java
@@ -0,0 +1,51 @@
+/**
+ * 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.common;
+
+/**
+ * @author shijia.wxr
+ */
+public class Pair<T1, T2> {
+ private T1 object1;
+ private T2 object2;
+
+
+ public Pair(T1 object1, T2 object2) {
+ this.object1 = object1;
+ this.object2 = object2;
+ }
+
+
+ public T1 getObject1() {
+ return object1;
+ }
+
+
+ public void setObject1(T1 object1) {
+ this.object1 = object1;
+ }
+
+
+ public T2 getObject2() {
+ return object2;
+ }
+
+
+ public void setObject2(T2 object2) {
+ this.object2 = object2;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/ServiceState.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/ServiceState.java b/common/src/main/java/org/apache/rocketmq/common/ServiceState.java
new file mode 100644
index 0000000..97f5b90
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/ServiceState.java
@@ -0,0 +1,39 @@
+/**
+ * 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.common;
+
+/**
+ * @author shijia.wxr
+ */
+public enum ServiceState {
+ /**
+ * Service just created,not start
+ */
+ CREATE_JUST,
+ /**
+ * Service Running
+ */
+ RUNNING,
+ /**
+ * Service shutdown
+ */
+ SHUTDOWN_ALREADY,
+ /**
+ * Service Start failure
+ */
+ START_FAILED;
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java b/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java
new file mode 100644
index 0000000..4fd5154
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java
@@ -0,0 +1,142 @@
+/**
+ * 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.common;
+
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * @author shijia.wxr
+ * @author xinyuzhou.zxy
+ */
+public abstract class ServiceThread implements Runnable {
+ private static final Logger STLOG = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
+ private static final long JOIN_TIME = 90 * 1000;
+
+ protected final Thread thread;
+
+ protected volatile AtomicBoolean hasNotified = new AtomicBoolean(false);
+
+ protected volatile boolean stopped = false;
+
+ protected final CountDownLatch waitPoint = new CountDownLatch(1);
+
+
+ public ServiceThread() {
+ this.thread = new Thread(this, this.getServiceName());
+ }
+
+
+ public abstract String getServiceName();
+
+
+ public void start() {
+ this.thread.start();
+ }
+
+
+ public void shutdown() {
+ this.shutdown(false);
+ }
+
+ public void shutdown(final boolean interrupt) {
+ this.stopped = true;
+ STLOG.info("shutdown thread " + this.getServiceName() + " interrupt " + interrupt);
+
+ if (hasNotified.compareAndSet(false, true)) {
+ waitPoint.countDown(); // notify
+ }
+
+ try {
+ if (interrupt) {
+ this.thread.interrupt();
+ }
+
+ long beginTime = System.currentTimeMillis();
+ if (!this.thread.isDaemon()) {
+ this.thread.join(this.getJointime());
+ }
+ long eclipseTime = System.currentTimeMillis() - beginTime;
+ STLOG.info("join thread " + this.getServiceName() + " eclipse time(ms) " + eclipseTime + " "
+ + this.getJointime());
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public long getJointime() {
+ return JOIN_TIME;
+ }
+
+ public void stop() {
+ this.stop(false);
+ }
+
+ public void stop(final boolean interrupt) {
+ this.stopped = true;
+ STLOG.info("stop thread " + this.getServiceName() + " interrupt " + interrupt);
+
+ if (hasNotified.compareAndSet(false, true)) {
+ waitPoint.countDown(); // notify
+ }
+
+ if (interrupt) {
+ this.thread.interrupt();
+ }
+ }
+
+ public void makeStop() {
+ this.stopped = true;
+ STLOG.info("makestop thread " + this.getServiceName());
+ }
+
+ public void wakeup() {
+ if (hasNotified.compareAndSet(false, true)) {
+ waitPoint.countDown(); // notify
+ }
+ }
+
+ protected void waitForRunning(long interval) {
+ if (hasNotified.compareAndSet(true, false)) {
+ this.onWaitEnd();
+ return;
+ }
+
+ //entry to wait
+ waitPoint.reset();
+
+ try {
+ waitPoint.await(interval, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } finally {
+ hasNotified.set(false);
+ this.onWaitEnd();
+ }
+ }
+
+ protected void onWaitEnd() {
+ }
+
+ public boolean isStopped() {
+ return stopped;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/SystemClock.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/SystemClock.java b/common/src/main/java/org/apache/rocketmq/common/SystemClock.java
new file mode 100644
index 0000000..f86a4f5
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/SystemClock.java
@@ -0,0 +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 org.apache.rocketmq.common;
+
+/**
+ * @author vintage.wang
+ */
+public class SystemClock {
+ public long now() {
+ return System.currentTimeMillis();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/ThreadFactoryImpl.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/ThreadFactoryImpl.java b/common/src/main/java/org/apache/rocketmq/common/ThreadFactoryImpl.java
new file mode 100644
index 0000000..43ab2f2
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/ThreadFactoryImpl.java
@@ -0,0 +1,39 @@
+/**
+ * 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.common;
+
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicLong;
+
+
+public class ThreadFactoryImpl implements ThreadFactory {
+ private final AtomicLong threadIndex = new AtomicLong(0);
+ private final String threadNamePrefix;
+
+
+ public ThreadFactoryImpl(final String threadNamePrefix) {
+ this.threadNamePrefix = threadNamePrefix;
+ }
+
+
+ @Override
+ public Thread newThread(Runnable r) {
+ return new Thread(r, threadNamePrefix + this.threadIndex.incrementAndGet());
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java b/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
new file mode 100644
index 0000000..1aef5e7
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
@@ -0,0 +1,206 @@
+/**
+ * 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.common;
+
+import org.apache.rocketmq.common.constant.PermName;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class TopicConfig {
+ private static final String SEPARATOR = " ";
+ public static int defaultReadQueueNums = 16;
+ public static int defaultWriteQueueNums = 16;
+ private String topicName;
+ private int readQueueNums = defaultReadQueueNums;
+ private int writeQueueNums = defaultWriteQueueNums;
+ private int perm = PermName.PERM_READ | PermName.PERM_WRITE;
+ private TopicFilterType topicFilterType = TopicFilterType.SINGLE_TAG;
+ private int topicSysFlag = 0;
+ private boolean order = false;
+
+
+ public TopicConfig() {
+ }
+
+
+ public TopicConfig(String topicName) {
+ this.topicName = topicName;
+ }
+
+
+ public TopicConfig(String topicName, int readQueueNums, int writeQueueNums, int perm) {
+ this.topicName = topicName;
+ this.readQueueNums = readQueueNums;
+ this.writeQueueNums = writeQueueNums;
+ this.perm = perm;
+ }
+
+
+ public String encode() {
+ StringBuilder sb = new StringBuilder();
+
+ // 1
+ sb.append(this.topicName);
+ sb.append(SEPARATOR);
+
+ // 2
+ sb.append(this.readQueueNums);
+ sb.append(SEPARATOR);
+
+ // 3
+ sb.append(this.writeQueueNums);
+ sb.append(SEPARATOR);
+
+ // 4
+ sb.append(this.perm);
+ sb.append(SEPARATOR);
+
+ // 5
+ sb.append(this.topicFilterType);
+
+ return sb.toString();
+ }
+
+
+ public boolean decode(final String in) {
+ String[] strs = in.split(SEPARATOR);
+ if (strs != null && strs.length == 5) {
+ this.topicName = strs[0];
+
+ this.readQueueNums = Integer.parseInt(strs[1]);
+
+ this.writeQueueNums = Integer.parseInt(strs[2]);
+
+ this.perm = Integer.parseInt(strs[3]);
+
+ this.topicFilterType = TopicFilterType.valueOf(strs[4]);
+
+ return true;
+ }
+
+ return false;
+ }
+
+
+ public String getTopicName() {
+ return topicName;
+ }
+
+
+ public void setTopicName(String topicName) {
+ this.topicName = topicName;
+ }
+
+
+ public int getReadQueueNums() {
+ return readQueueNums;
+ }
+
+
+ public void setReadQueueNums(int readQueueNums) {
+ this.readQueueNums = readQueueNums;
+ }
+
+
+ public int getWriteQueueNums() {
+ return writeQueueNums;
+ }
+
+
+ public void setWriteQueueNums(int writeQueueNums) {
+ this.writeQueueNums = writeQueueNums;
+ }
+
+
+ public int getPerm() {
+ return perm;
+ }
+
+
+ public void setPerm(int perm) {
+ this.perm = perm;
+ }
+
+
+ public TopicFilterType getTopicFilterType() {
+ return topicFilterType;
+ }
+
+
+ public void setTopicFilterType(TopicFilterType topicFilterType) {
+ this.topicFilterType = topicFilterType;
+ }
+
+
+ public int getTopicSysFlag() {
+ return topicSysFlag;
+ }
+
+
+ public void setTopicSysFlag(int topicSysFlag) {
+ this.topicSysFlag = topicSysFlag;
+ }
+
+
+ public boolean isOrder() {
+ return order;
+ }
+
+
+ public void setOrder(boolean isOrder) {
+ this.order = isOrder;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final TopicConfig that = (TopicConfig) o;
+
+ if (readQueueNums != that.readQueueNums) return false;
+ if (writeQueueNums != that.writeQueueNums) return false;
+ if (perm != that.perm) return false;
+ if (topicSysFlag != that.topicSysFlag) return false;
+ if (order != that.order) return false;
+ if (topicName != null ? !topicName.equals(that.topicName) : that.topicName != null) return false;
+ return topicFilterType == that.topicFilterType;
+
+ }
+
+ @Override
+ public int hashCode() {
+ int result = topicName != null ? topicName.hashCode() : 0;
+ result = 31 * result + readQueueNums;
+ result = 31 * result + writeQueueNums;
+ result = 31 * result + perm;
+ result = 31 * result + (topicFilterType != null ? topicFilterType.hashCode() : 0);
+ result = 31 * result + topicSysFlag;
+ result = 31 * result + (order ? 1 : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "TopicConfig [topicName=" + topicName + ", readQueueNums=" + readQueueNums
+ + ", writeQueueNums=" + writeQueueNums + ", perm=" + PermName.perm2String(perm)
+ + ", topicFilterType=" + topicFilterType + ", topicSysFlag=" + topicSysFlag + ", order="
+ + order + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java b/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java
new file mode 100644
index 0000000..771fcaf
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java
@@ -0,0 +1,25 @@
+/**
+ * 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.common;
+
+/**
+ * @author shijia.wxr
+ */
+public enum TopicFilterType {
+ SINGLE_TAG,
+ MULTI_TAG
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
new file mode 100644
index 0000000..2f9b72e
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
@@ -0,0 +1,525 @@
+/**
+ * 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.common;
+
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.zip.CRC32;
+import java.util.zip.DeflaterOutputStream;
+import java.util.zip.InflaterInputStream;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class UtilAll {
+ public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
+ public static final String YYYY_MM_DD_HH_MM_SS_SSS = "yyyy-MM-dd#HH:mm:ss:SSS";
+ public static final String YYYY_MMDD_HHMMSS = "yyyyMMddHHmmss";
+
+
+ public static int getPid() {
+ RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
+ String name = runtime.getName(); // format: "pid@hostname"
+ try {
+ return Integer.parseInt(name.substring(0, name.indexOf('@')));
+ } catch (Exception e) {
+ return -1;
+ }
+ }
+
+ public static String currentStackTrace() {
+ StringBuilder sb = new StringBuilder();
+ StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
+ for (StackTraceElement ste : stackTrace) {
+ sb.append("\n\t");
+ sb.append(ste.toString());
+ }
+
+ return sb.toString();
+ }
+
+ public static String offset2FileName(final long offset) {
+ final NumberFormat nf = NumberFormat.getInstance();
+ nf.setMinimumIntegerDigits(20);
+ nf.setMaximumFractionDigits(0);
+ nf.setGroupingUsed(false);
+ return nf.format(offset);
+ }
+
+ public static long computeEclipseTimeMilliseconds(final long beginTime) {
+ return System.currentTimeMillis() - beginTime;
+ }
+
+
+ public static boolean isItTimeToDo(final String when) {
+ String[] whiles = when.split(";");
+ if (whiles != null && whiles.length > 0) {
+ Calendar now = Calendar.getInstance();
+ for (String w : whiles) {
+ int nowHour = Integer.parseInt(w);
+ if (nowHour == now.get(Calendar.HOUR_OF_DAY)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+
+ public static String timeMillisToHumanString() {
+ return timeMillisToHumanString(System.currentTimeMillis());
+ }
+
+
+ public static String timeMillisToHumanString(final long t) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTimeInMillis(t);
+ return String.format("%04d%02d%02d%02d%02d%02d%03d", cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1,
+ cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND),
+ cal.get(Calendar.MILLISECOND));
+ }
+
+
+ public static long computNextMorningTimeMillis() {
+ Calendar cal = Calendar.getInstance();
+ cal.setTimeInMillis(System.currentTimeMillis());
+ cal.add(Calendar.DAY_OF_MONTH, 1);
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+
+ return cal.getTimeInMillis();
+ }
+
+
+ public static long computNextMinutesTimeMillis() {
+ Calendar cal = Calendar.getInstance();
+ cal.setTimeInMillis(System.currentTimeMillis());
+ cal.add(Calendar.DAY_OF_MONTH, 0);
+ cal.add(Calendar.HOUR_OF_DAY, 0);
+ cal.add(Calendar.MINUTE, 1);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+
+ return cal.getTimeInMillis();
+ }
+
+
+ public static long computNextHourTimeMillis() {
+ Calendar cal = Calendar.getInstance();
+ cal.setTimeInMillis(System.currentTimeMillis());
+ cal.add(Calendar.DAY_OF_MONTH, 0);
+ cal.add(Calendar.HOUR_OF_DAY, 1);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+
+ return cal.getTimeInMillis();
+ }
+
+
+ public static long computNextHalfHourTimeMillis() {
+ Calendar cal = Calendar.getInstance();
+ cal.setTimeInMillis(System.currentTimeMillis());
+ cal.add(Calendar.DAY_OF_MONTH, 0);
+ cal.add(Calendar.HOUR_OF_DAY, 1);
+ cal.set(Calendar.MINUTE, 30);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+
+ return cal.getTimeInMillis();
+ }
+
+
+ public static String timeMillisToHumanString2(final long t) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTimeInMillis(t);
+ return String.format("%04d-%02d-%02d %02d:%02d:%02d,%03d",
+ cal.get(Calendar.YEAR),
+ cal.get(Calendar.MONTH) + 1,
+ cal.get(Calendar.DAY_OF_MONTH),
+ cal.get(Calendar.HOUR_OF_DAY),
+ cal.get(Calendar.MINUTE),
+ cal.get(Calendar.SECOND),
+ cal.get(Calendar.MILLISECOND));
+ }
+
+
+ public static String timeMillisToHumanString3(final long t) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTimeInMillis(t);
+ return String.format("%04d%02d%02d%02d%02d%02d",
+ cal.get(Calendar.YEAR),
+ cal.get(Calendar.MONTH) + 1,
+ cal.get(Calendar.DAY_OF_MONTH),
+ cal.get(Calendar.HOUR_OF_DAY),
+ cal.get(Calendar.MINUTE),
+ cal.get(Calendar.SECOND));
+ }
+
+
+ public static double getDiskPartitionSpaceUsedPercent(final String path) {
+ if (null == path || path.isEmpty())
+ return -1;
+
+ try {
+ File file = new File(path);
+ if (!file.exists()) {
+ boolean result = file.mkdirs();
+ if (!result) {
+ }
+ }
+
+ long totalSpace = file.getTotalSpace();
+ long freeSpace = file.getFreeSpace();
+ long usedSpace = totalSpace - freeSpace;
+ if (totalSpace > 0) {
+ return usedSpace / (double) totalSpace;
+ }
+ } catch (Exception e) {
+ return -1;
+ }
+
+ return -1;
+ }
+
+
+ public static final int crc32(byte[] array) {
+ if (array != null) {
+ return crc32(array, 0, array.length);
+ }
+
+ return 0;
+ }
+
+
+ public static final int crc32(byte[] array, int offset, int length) {
+ CRC32 crc32 = new CRC32();
+ crc32.update(array, offset, length);
+ return (int) (crc32.getValue() & 0x7FFFFFFF);
+ }
+
+ final static char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
+
+ public static String bytes2string(byte[] src) {
+ char[] hexChars = new char[src.length * 2];
+ for (int j = 0; j < src.length; j++) {
+ int v = src[j] & 0xFF;
+ hexChars[j * 2] = HEX_ARRAY[v >>> 4];
+ hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
+ }
+ return new String(hexChars);
+ }
+
+ public static byte[] string2bytes(String hexString) {
+ if (hexString == null || hexString.equals("")) {
+ return null;
+ }
+ hexString = hexString.toUpperCase();
+ int length = hexString.length() / 2;
+ char[] hexChars = hexString.toCharArray();
+ byte[] d = new byte[length];
+ for (int i = 0; i < length; i++) {
+ int pos = i * 2;
+ d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
+ }
+ return d;
+ }
+
+
+ private static byte charToByte(char c) {
+ return (byte) "0123456789ABCDEF".indexOf(c);
+ }
+
+
+ public static byte[] uncompress(final byte[] src) throws IOException {
+ byte[] result = src;
+ byte[] uncompressData = new byte[src.length];
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(src);
+ InflaterInputStream inflaterInputStream = new InflaterInputStream(byteArrayInputStream);
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(src.length);
+
+ try {
+ while (true) {
+ int len = inflaterInputStream.read(uncompressData, 0, uncompressData.length);
+ if (len <= 0) {
+ break;
+ }
+ byteArrayOutputStream.write(uncompressData, 0, len);
+ }
+ byteArrayOutputStream.flush();
+ result = byteArrayOutputStream.toByteArray();
+ } catch (IOException e) {
+ throw e;
+ } finally {
+ try {
+ byteArrayInputStream.close();
+ } catch (IOException e) {
+ }
+ try {
+ inflaterInputStream.close();
+ } catch (IOException e) {
+ }
+ try {
+ byteArrayOutputStream.close();
+ } catch (IOException e) {
+ }
+ }
+
+ return result;
+ }
+
+
+ public static byte[] compress(final byte[] src, final int level) throws IOException {
+ byte[] result = src;
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(src.length);
+ java.util.zip.Deflater defeater = new java.util.zip.Deflater(level);
+ DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(byteArrayOutputStream, defeater);
+ try {
+ deflaterOutputStream.write(src);
+ deflaterOutputStream.finish();
+ deflaterOutputStream.close();
+ result = byteArrayOutputStream.toByteArray();
+ } catch (IOException e) {
+ defeater.end();
+ throw e;
+ } finally {
+ try {
+ byteArrayOutputStream.close();
+ } catch (IOException ignored) {
+ }
+
+ defeater.end();
+ }
+
+ return result;
+ }
+
+
+ public static int asInt(String str, int defaultValue) {
+ try {
+ return Integer.parseInt(str);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+
+ public static long asLong(String str, long defaultValue) {
+ try {
+ return Long.parseLong(str);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+
+ public static String formatDate(Date date, String pattern) {
+ SimpleDateFormat df = new SimpleDateFormat(pattern);
+ return df.format(date);
+ }
+
+
+ public static Date parseDate(String date, String pattern) {
+ SimpleDateFormat df = new SimpleDateFormat(pattern);
+ try {
+ return df.parse(date);
+ } catch (ParseException e) {
+ return null;
+ }
+ }
+
+
+ public static String responseCode2String(final int code) {
+ return Integer.toString(code);
+ }
+
+
+ public static String frontStringAtLeast(final String str, final int size) {
+ if (str != null) {
+ if (str.length() > size) {
+ return str.substring(0, size);
+ }
+ }
+
+ return str;
+ }
+
+
+ public static boolean isBlank(String str) {
+ int strLen;
+ if (str == null || (strLen = str.length()) == 0) {
+ return true;
+ }
+ for (int i = 0; i < strLen; i++) {
+ if (!Character.isWhitespace(str.charAt(i))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+ public static String jstack() {
+ return jstack(Thread.getAllStackTraces());
+ }
+
+
+ public static String jstack(Map<Thread, StackTraceElement[]> map) {
+ StringBuilder result = new StringBuilder();
+ try {
+ Iterator<Map.Entry<Thread, StackTraceElement[]>> ite = map.entrySet().iterator();
+ while (ite.hasNext()) {
+ Map.Entry<Thread, StackTraceElement[]> entry = ite.next();
+ StackTraceElement[] elements = entry.getValue();
+ Thread thread = entry.getKey();
+ if (elements != null && elements.length > 0) {
+ String threadName = entry.getKey().getName();
+ result.append(String.format("%-40sTID: %d STATE: %s%n", threadName, thread.getId(), thread.getState()));
+ for (StackTraceElement el : elements) {
+ result.append(String.format("%-40s%s%n", threadName, el.toString()));
+ }
+ result.append("\n");
+ }
+ }
+ } catch (Throwable e) {
+ result.append(RemotingHelper.exceptionSimpleDesc(e));
+ }
+
+ return result.toString();
+ }
+
+ public static boolean isInternalIP(byte[] ip) {
+ if (ip.length != 4) {
+ throw new RuntimeException("illegal ipv4 bytes");
+ }
+
+
+ //10.0.0.0~10.255.255.255
+ //172.16.0.0~172.31.255.255
+ //192.168.0.0~192.168.255.255
+ if (ip[0] == (byte) 10) {
+
+ return true;
+ } else if (ip[0] == (byte) 172) {
+ if (ip[1] >= (byte) 16 && ip[1] <= (byte) 31) {
+ return true;
+ }
+ } else if (ip[0] == (byte) 192) {
+ if (ip[1] == (byte) 168) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static boolean ipCheck(byte[] ip) {
+ if (ip.length != 4) {
+ throw new RuntimeException("illegal ipv4 bytes");
+ }
+
+// if (ip[0] == (byte)30 && ip[1] == (byte)10 && ip[2] == (byte)163 && ip[3] == (byte)120) {
+// }
+
+
+ if (ip[0] >= (byte) 1 && ip[0] <= (byte) 126) {
+ if (ip[1] == (byte) 1 && ip[2] == (byte) 1 && ip[3] == (byte) 1) {
+ return false;
+ }
+ if (ip[1] == (byte) 0 && ip[2] == (byte) 0 && ip[3] == (byte) 0) {
+ return false;
+ }
+ return true;
+ } else if (ip[0] >= (byte) 128 && ip[0] <= (byte) 191) {
+ if (ip[2] == (byte) 1 && ip[3] == (byte) 1) {
+ return false;
+ }
+ if (ip[2] == (byte) 0 && ip[3] == (byte) 0) {
+ return false;
+ }
+ return true;
+ } else if (ip[0] >= (byte) 192 && ip[0] <= (byte) 223) {
+ if (ip[3] == (byte) 1) {
+ return false;
+ }
+ if (ip[3] == (byte) 0) {
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public static String ipToIPv4Str(byte[] ip) {
+ if (ip.length != 4) {
+ return null;
+ }
+ return new StringBuilder().append(ip[0] & 0xFF).append(".").append(
+ ip[1] & 0xFF).append(".").append(ip[2] & 0xFF)
+ .append(".").append(ip[3] & 0xFF).toString();
+ }
+
+ public static byte[] getIP() {
+ try {
+ Enumeration allNetInterfaces = NetworkInterface.getNetworkInterfaces();
+ InetAddress ip = null;
+ byte[] internalIP = null;
+ while (allNetInterfaces.hasMoreElements()) {
+ NetworkInterface netInterface = (NetworkInterface) allNetInterfaces.nextElement();
+ Enumeration addresses = netInterface.getInetAddresses();
+ while (addresses.hasMoreElements()) {
+ ip = (InetAddress) addresses.nextElement();
+ if (ip != null && ip instanceof Inet4Address) {
+ byte[] ipByte = ip.getAddress();
+ if (ipByte.length == 4) {
+ if (ipCheck(ipByte)) {
+ if (!isInternalIP(ipByte)) {
+ return ipByte;
+ } else if (internalIP == null) {
+ internalIP = ipByte;
+ }
+ }
+ }
+ }
+ }
+ }
+ if (internalIP != null) {
+ return internalIP;
+ } else {
+ throw new RuntimeException("Can not get local ip");
+ }
+ } catch (Exception e) {
+ throw new RuntimeException("Can not get local ip", e);
+ }
+ }
+}
[65/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Add code
style settings and copyright.
Posted by yu...@apache.org.
ROCKETMQ-18 Add code style settings and copyright.
Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/commit/95cfb8d1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/tree/95cfb8d1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/diff/95cfb8d1
Branch: refs/heads/master
Commit: 95cfb8d19470ed758d427fb37d5f0abb6139754e
Parents: 8ca4657
Author: yukon <yu...@apache.org>
Authored: Wed Dec 28 15:32:07 2016 +0800
Committer: yukon <yu...@apache.org>
Committed: Wed Dec 28 15:32:07 2016 +0800
----------------------------------------------------------------------
style/copyright/Apache.xml | 6 ++
style/copyright/profiles_settings.xml | 44 +++++++++
style/rmq_codeStyle.xml | 140 +++++++++++++++++++++++++++++
3 files changed, 190 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/95cfb8d1/style/copyright/Apache.xml
----------------------------------------------------------------------
diff --git a/style/copyright/Apache.xml b/style/copyright/Apache.xml
new file mode 100644
index 0000000..f728d8a
--- /dev/null
+++ b/style/copyright/Apache.xml
@@ -0,0 +1,6 @@
+<component name="CopyrightManager">
+ <copyright>
+ <option name="myName" value="Apache" />
+ <option name="notice" value="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." />
+ </copyright>
+</component>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/95cfb8d1/style/copyright/profiles_settings.xml
----------------------------------------------------------------------
diff --git a/style/copyright/profiles_settings.xml b/style/copyright/profiles_settings.xml
new file mode 100644
index 0000000..0cba723
--- /dev/null
+++ b/style/copyright/profiles_settings.xml
@@ -0,0 +1,44 @@
+<component name="CopyrightManager">
+ <settings default="Apache">
+ <module2copyright>
+ <element module="All" copyright="Apache" />
+ </module2copyright>
+ <LanguageOptions name="GSP">
+ <option name="fileTypeOverride" value="3" />
+ <option name="prefixLines" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="HTML">
+ <option name="fileTypeOverride" value="3" />
+ <option name="prefixLines" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JAVA" />
+ <LanguageOptions name="JSP">
+ <option name="fileTypeOverride" value="3" />
+ <option name="prefixLines" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JSPX">
+ <option name="fileTypeOverride" value="3" />
+ <option name="prefixLines" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="MXML">
+ <option name="fileTypeOverride" value="3" />
+ <option name="prefixLines" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="Properties">
+ <option name="fileTypeOverride" value="3" />
+ <option name="block" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="SPI">
+ <option name="fileTypeOverride" value="3" />
+ <option name="block" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="XML">
+ <option name="fileTypeOverride" value="3" />
+ <option name="prefixLines" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="__TEMPLATE__">
+ <option name="separateBefore" value="true" />
+ <option name="lenBefore" value="1" />
+ </LanguageOptions>
+ </settings>
+</component>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/95cfb8d1/style/rmq_codeStyle.xml
----------------------------------------------------------------------
diff --git a/style/rmq_codeStyle.xml b/style/rmq_codeStyle.xml
new file mode 100644
index 0000000..e6a9b7d
--- /dev/null
+++ b/style/rmq_codeStyle.xml
@@ -0,0 +1,140 @@
+<code_scheme name="rocketmq">
+ <option name="USE_SAME_INDENTS" value="true" />
+ <option name="IGNORE_SAME_INDENTS_FOR_LANGUAGES" value="true" />
+ <option name="OTHER_INDENT_OPTIONS">
+ <value>
+ <option name="INDENT_SIZE" value="4" />
+ <option name="CONTINUATION_INDENT_SIZE" value="4" />
+ <option name="TAB_SIZE" value="4" />
+ <option name="USE_TAB_CHARACTER" value="false" />
+ <option name="SMART_TABS" value="false" />
+ <option name="LABEL_INDENT_SIZE" value="0" />
+ <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+ <option name="USE_RELATIVE_INDENTS" value="false" />
+ </value>
+ </option>
+ <option name="PREFER_LONGER_NAMES" value="false" />
+ <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="1000" />
+ <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="1000" />
+ <option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
+ <value />
+ </option>
+ <option name="IMPORT_LAYOUT_TABLE">
+ <value>
+ <package name="" withSubpackages="true" static="false" />
+ <emptyLine />
+ <package name="" withSubpackages="true" static="true" />
+ </value>
+ </option>
+ <option name="JD_ALIGN_PARAM_COMMENTS" value="false" />
+ <option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false" />
+ <option name="JD_P_AT_EMPTY_LINES" value="false" />
+ <option name="JD_KEEP_INVALID_TAGS" value="false" />
+ <option name="JD_DO_NOT_WRAP_ONE_LINE_COMMENTS" value="true" />
+ <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
+ <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
+ <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
+ <option name="ELSE_ON_NEW_LINE" value="true" />
+ <option name="WHILE_ON_NEW_LINE" value="true" />
+ <option name="CATCH_ON_NEW_LINE" value="true" />
+ <option name="FINALLY_ON_NEW_LINE" value="true" />
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
+ <option name="ALIGN_MULTILINE_FOR" value="false" />
+ <option name="SPACE_AFTER_TYPE_CAST" value="false" />
+ <option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" />
+ <option name="METHOD_PARAMETERS_WRAP" value="1" />
+ <option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
+ <option name="LABELED_STATEMENT_WRAP" value="1" />
+ <option name="WRAP_COMMENTS" value="true" />
+ <option name="METHOD_ANNOTATION_WRAP" value="1" />
+ <option name="CLASS_ANNOTATION_WRAP" value="1" />
+ <option name="FIELD_ANNOTATION_WRAP" value="1" />
+ <JavaCodeStyleSettings>
+ <option name="CLASS_NAMES_IN_JAVADOC" value="3" />
+ </JavaCodeStyleSettings>
+ <XML>
+ <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
+ </XML>
+ <ADDITIONAL_INDENT_OPTIONS fileType="haml">
+ <option name="INDENT_SIZE" value="2" />
+ </ADDITIONAL_INDENT_OPTIONS>
+ <codeStyleSettings language="Groovy">
+ <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
+ <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
+ <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
+ <option name="ELSE_ON_NEW_LINE" value="true" />
+ <option name="CATCH_ON_NEW_LINE" value="true" />
+ <option name="FINALLY_ON_NEW_LINE" value="true" />
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
+ <option name="ALIGN_MULTILINE_FOR" value="false" />
+ <option name="SPACE_AFTER_TYPE_CAST" value="false" />
+ <option name="METHOD_PARAMETERS_WRAP" value="1" />
+ <option name="METHOD_ANNOTATION_WRAP" value="1" />
+ <option name="CLASS_ANNOTATION_WRAP" value="1" />
+ <option name="FIELD_ANNOTATION_WRAP" value="1" />
+ <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ <indentOptions>
+ <option name="CONTINUATION_INDENT_SIZE" value="4" />
+ </indentOptions>
+ </codeStyleSettings>
+ <codeStyleSettings language="HOCON">
+ <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
+ <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ </codeStyleSettings>
+ <codeStyleSettings language="JAVA">
+ <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
+ <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
+ <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
+ <option name="ELSE_ON_NEW_LINE" value="true" />
+ <option name="WHILE_ON_NEW_LINE" value="true" />
+ <option name="CATCH_ON_NEW_LINE" value="true" />
+ <option name="FINALLY_ON_NEW_LINE" value="true" />
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
+ <option name="ALIGN_MULTILINE_FOR" value="false" />
+ <option name="SPACE_AFTER_TYPE_CAST" value="false" />
+ <option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" />
+ <option name="METHOD_PARAMETERS_WRAP" value="1" />
+ <option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
+ <option name="LABELED_STATEMENT_WRAP" value="1" />
+ <option name="METHOD_ANNOTATION_WRAP" value="1" />
+ <option name="CLASS_ANNOTATION_WRAP" value="1" />
+ <option name="FIELD_ANNOTATION_WRAP" value="1" />
+ <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ <indentOptions>
+ <option name="CONTINUATION_INDENT_SIZE" value="4" />
+ </indentOptions>
+ </codeStyleSettings>
+ <codeStyleSettings language="JSON">
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
+ <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ </codeStyleSettings>
+ <codeStyleSettings language="Scala">
+ <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
+ <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
+ <option name="ELSE_ON_NEW_LINE" value="true" />
+ <option name="WHILE_ON_NEW_LINE" value="true" />
+ <option name="CATCH_ON_NEW_LINE" value="true" />
+ <option name="FINALLY_ON_NEW_LINE" value="true" />
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
+ <option name="ALIGN_MULTILINE_FOR" value="false" />
+ <option name="METHOD_PARAMETERS_WRAP" value="1" />
+ <option name="METHOD_ANNOTATION_WRAP" value="1" />
+ <option name="CLASS_ANNOTATION_WRAP" value="1" />
+ <option name="FIELD_ANNOTATION_WRAP" value="1" />
+ <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ <indentOptions>
+ <option name="INDENT_SIZE" value="4" />
+ <option name="CONTINUATION_INDENT_SIZE" value="4" />
+ <option name="TAB_SIZE" value="4" />
+ </indentOptions>
+ </codeStyleSettings>
+ <codeStyleSettings language="XML">
+ <indentOptions>
+ <option name="CONTINUATION_INDENT_SIZE" value="4" />
+ </indentOptions>
+ </codeStyleSettings>
+</code_scheme>
\ No newline at end of file
[21/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
new file mode 100644
index 0000000..62af958
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
@@ -0,0 +1,1080 @@
+/**
+ * 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.impl.producer;
+
+import org.apache.rocketmq.client.QueryResult;
+import org.apache.rocketmq.client.Validators;
+import org.apache.rocketmq.client.common.ClientErrorCode;
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.hook.CheckForbiddenContext;
+import org.apache.rocketmq.client.hook.CheckForbiddenHook;
+import org.apache.rocketmq.client.hook.SendMessageContext;
+import org.apache.rocketmq.client.hook.SendMessageHook;
+import org.apache.rocketmq.client.impl.CommunicationMode;
+import org.apache.rocketmq.client.impl.MQClientManager;
+import org.apache.rocketmq.client.impl.factory.MQClientInstance;
+import org.apache.rocketmq.client.latency.MQFaultStrategy;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.ServiceState;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.help.FAQUrl;
+import org.apache.rocketmq.common.message.*;
+import org.apache.rocketmq.common.protocol.ResponseCode;
+import org.apache.rocketmq.common.protocol.header.CheckTransactionStateRequestHeader;
+import org.apache.rocketmq.common.protocol.header.EndTransactionRequestHeader;
+import org.apache.rocketmq.common.protocol.header.SendMessageRequestHeader;
+import org.apache.rocketmq.common.sysflag.MessageSysFlag;
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.exception.RemotingConnectException;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
+import org.apache.rocketmq.client.producer.*;
+import org.slf4j.Logger;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.*;
+import java.util.concurrent.*;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class DefaultMQProducerImpl implements MQProducerInner {
+ private final Logger log = ClientLogger.getLog();
+ private final Random random = new Random();
+ private final DefaultMQProducer defaultMQProducer;
+ private final ConcurrentHashMap<String/* topic */, TopicPublishInfo> topicPublishInfoTable =
+ new ConcurrentHashMap<String, TopicPublishInfo>();
+ private final ArrayList<SendMessageHook> sendMessageHookList = new ArrayList<SendMessageHook>();
+ private final RPCHook rpcHook;
+ protected BlockingQueue<Runnable> checkRequestQueue;
+ protected ExecutorService checkExecutor;
+ private ServiceState serviceState = ServiceState.CREATE_JUST;
+ private MQClientInstance mQClientFactory;
+ private ArrayList<CheckForbiddenHook> checkForbiddenHookList = new ArrayList<CheckForbiddenHook>();
+ private int zipCompressLevel = Integer.parseInt(System.getProperty(MixAll.MESSAGE_COMPRESS_LEVEL, "5"));
+
+ private MQFaultStrategy mqFaultStrategy = new MQFaultStrategy();
+
+
+ public DefaultMQProducerImpl(final DefaultMQProducer defaultMQProducer) {
+ this(defaultMQProducer, null);
+ }
+
+
+ public DefaultMQProducerImpl(final DefaultMQProducer defaultMQProducer, RPCHook rpcHook) {
+ this.defaultMQProducer = defaultMQProducer;
+ this.rpcHook = rpcHook;
+ }
+
+ public void registerCheckForbiddenHook(CheckForbiddenHook checkForbiddenHook) {
+ this.checkForbiddenHookList.add(checkForbiddenHook);
+ log.info("register a new checkForbiddenHook. hookName={}, allHookSize={}", checkForbiddenHook.hookName(),
+ checkForbiddenHookList.size());
+ }
+
+ public void initTransactionEnv() {
+ TransactionMQProducer producer = (TransactionMQProducer) this.defaultMQProducer;
+ this.checkRequestQueue = new LinkedBlockingQueue<Runnable>(producer.getCheckRequestHoldMax());
+ this.checkExecutor = new ThreadPoolExecutor(//
+ producer.getCheckThreadPoolMinSize(), //
+ producer.getCheckThreadPoolMaxSize(), //
+ 1000 * 60, //
+ TimeUnit.MILLISECONDS, //
+ this.checkRequestQueue);
+ }
+
+ public void destroyTransactionEnv() {
+ this.checkExecutor.shutdown();
+ this.checkRequestQueue.clear();
+ }
+
+ public void registerSendMessageHook(final SendMessageHook hook) {
+ this.sendMessageHookList.add(hook);
+ log.info("register sendMessage Hook, {}", hook.hookName());
+ }
+
+ public void start() throws MQClientException {
+ this.start(true);
+ }
+
+ public void start(final boolean startFactory) throws MQClientException {
+ switch (this.serviceState) {
+ case CREATE_JUST:
+ this.serviceState = ServiceState.START_FAILED;
+
+ this.checkConfig();
+
+ if (!this.defaultMQProducer.getProducerGroup().equals(MixAll.CLIENT_INNER_PRODUCER_GROUP)) {
+ this.defaultMQProducer.changeInstanceNameToPID();
+ }
+
+ this.mQClientFactory = MQClientManager.getInstance().getAndCreateMQClientInstance(this.defaultMQProducer, rpcHook);
+
+ boolean registerOK = mQClientFactory.registerProducer(this.defaultMQProducer.getProducerGroup(), this);
+ if (!registerOK) {
+ this.serviceState = ServiceState.CREATE_JUST;
+ throw new MQClientException("The producer group[" + this.defaultMQProducer.getProducerGroup()
+ + "] has been created before, specify another name please." + FAQUrl.suggestTodo(FAQUrl.GROUP_NAME_DUPLICATE_URL),
+ null);
+ }
+
+ this.topicPublishInfoTable.put(this.defaultMQProducer.getCreateTopicKey(), new TopicPublishInfo());
+
+ if (startFactory) {
+ mQClientFactory.start();
+ }
+
+ log.info("the producer [{}] start OK. sendMessageWithVIPChannel={}", this.defaultMQProducer.getProducerGroup(),
+ this.defaultMQProducer.isSendMessageWithVIPChannel());
+ this.serviceState = ServiceState.RUNNING;
+ break;
+ case RUNNING:
+ case START_FAILED:
+ case SHUTDOWN_ALREADY:
+ throw new MQClientException("The producer service state not OK, maybe started once, "//
+ + this.serviceState//
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
+ null);
+ default:
+ break;
+ }
+
+ this.mQClientFactory.sendHeartbeatToAllBrokerWithLock();
+ }
+
+ private void checkConfig() throws MQClientException {
+ Validators.checkGroup(this.defaultMQProducer.getProducerGroup());
+
+ if (null == this.defaultMQProducer.getProducerGroup()) {
+ throw new MQClientException("producerGroup is null", null);
+ }
+
+ if (this.defaultMQProducer.getProducerGroup().equals(MixAll.DEFAULT_PRODUCER_GROUP)) {
+ throw new MQClientException("producerGroup can not equal " + MixAll.DEFAULT_PRODUCER_GROUP + ", please specify another one.",
+ null);
+ }
+ }
+
+ public void shutdown() {
+ this.shutdown(true);
+ }
+
+ public void shutdown(final boolean shutdownFactory) {
+ switch (this.serviceState) {
+ case CREATE_JUST:
+ break;
+ case RUNNING:
+ this.mQClientFactory.unregisterProducer(this.defaultMQProducer.getProducerGroup());
+ if (shutdownFactory) {
+ this.mQClientFactory.shutdown();
+ }
+
+ log.info("the producer [{}] shutdown OK", this.defaultMQProducer.getProducerGroup());
+ this.serviceState = ServiceState.SHUTDOWN_ALREADY;
+ break;
+ case SHUTDOWN_ALREADY:
+ break;
+ default:
+ break;
+ }
+ }
+
+ @Override
+ public Set<String> getPublishTopicList() {
+ Set<String> topicList = new HashSet<String>();
+ for (String key : this.topicPublishInfoTable.keySet()) {
+ topicList.add(key);
+ }
+
+ return topicList;
+ }
+
+ @Override
+ public boolean isPublishTopicNeedUpdate(String topic) {
+ TopicPublishInfo prev = this.topicPublishInfoTable.get(topic);
+
+ return null == prev || !prev.ok();
+ }
+
+ @Override
+ public TransactionCheckListener checkListener() {
+ if (this.defaultMQProducer instanceof TransactionMQProducer) {
+ TransactionMQProducer producer = (TransactionMQProducer) defaultMQProducer;
+ return producer.getTransactionCheckListener();
+ }
+
+ return null;
+ }
+
+ @Override
+ public void checkTransactionState(final String addr, final MessageExt msg, final CheckTransactionStateRequestHeader header) {
+ Runnable request = new Runnable() {
+ private final String brokerAddr = addr;
+ private final MessageExt message = msg;
+ private final CheckTransactionStateRequestHeader checkRequestHeader = header;
+ private final String group = DefaultMQProducerImpl.this.defaultMQProducer.getProducerGroup();
+
+
+ @Override
+ public void run() {
+ TransactionCheckListener transactionCheckListener = DefaultMQProducerImpl.this.checkListener();
+ if (transactionCheckListener != null) {
+ LocalTransactionState localTransactionState = LocalTransactionState.UNKNOW;
+ Throwable exception = null;
+ try {
+ localTransactionState = transactionCheckListener.checkLocalTransactionState(message);
+ } catch (Throwable e) {
+ log.error("Broker call checkTransactionState, but checkLocalTransactionState exception", e);
+ exception = e;
+ }
+
+ this.processTransactionState(//
+ localTransactionState, //
+ group, //
+ exception);
+ } else {
+ log.warn("checkTransactionState, pick transactionCheckListener by group[{}] failed", group);
+ }
+ }
+
+
+ private void processTransactionState(//
+ final LocalTransactionState localTransactionState, //
+ final String producerGroup, //
+ final Throwable exception) {
+ final EndTransactionRequestHeader thisHeader = new EndTransactionRequestHeader();
+ thisHeader.setCommitLogOffset(checkRequestHeader.getCommitLogOffset());
+ thisHeader.setProducerGroup(producerGroup);
+ thisHeader.setTranStateTableOffset(checkRequestHeader.getTranStateTableOffset());
+ thisHeader.setFromTransactionCheck(true);
+
+ String uniqueKey = message.getProperties().get(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX);
+ if (uniqueKey == null) {
+ uniqueKey = message.getMsgId();
+ }
+ thisHeader.setMsgId(uniqueKey);
+ thisHeader.setTransactionId(checkRequestHeader.getTransactionId());
+ switch (localTransactionState) {
+ case COMMIT_MESSAGE:
+ thisHeader.setCommitOrRollback(MessageSysFlag.TRANSACTION_COMMIT_TYPE);
+ break;
+ case ROLLBACK_MESSAGE:
+ thisHeader.setCommitOrRollback(MessageSysFlag.TRANSACTION_ROLLBACK_TYPE);
+ log.warn("when broker check, client rollback this transaction, {}", thisHeader);
+ break;
+ case UNKNOW:
+ thisHeader.setCommitOrRollback(MessageSysFlag.TRANSACTION_NOT_TYPE);
+ log.warn("when broker check, client does not know this transaction state, {}", thisHeader);
+ break;
+ default:
+ break;
+ }
+
+ String remark = null;
+ if (exception != null) {
+ remark = "checkLocalTransactionState Exception: " + RemotingHelper.exceptionSimpleDesc(exception);
+ }
+
+ try {
+ DefaultMQProducerImpl.this.mQClientFactory.getMQClientAPIImpl().endTransactionOneway(brokerAddr, thisHeader, remark,
+ 3000);
+ } catch (Exception e) {
+ log.error("endTransactionOneway exception", e);
+ }
+ }
+ };
+
+ this.checkExecutor.submit(request);
+ }
+
+ @Override
+ public void updateTopicPublishInfo(final String topic, final TopicPublishInfo info) {
+ if (info != null && topic != null) {
+ TopicPublishInfo prev = this.topicPublishInfoTable.put(topic, info);
+ if (prev != null) {
+ log.info("updateTopicPublishInfo prev is not null, " + prev.toString());
+ }
+ }
+ }
+
+ @Override
+ public boolean isUnitMode() {
+ return this.defaultMQProducer.isUnitMode();
+ }
+
+ public void createTopic(String key, String newTopic, int queueNum) throws MQClientException {
+ createTopic(key, newTopic, queueNum, 0);
+ }
+
+ public void createTopic(String key, String newTopic, int queueNum, int topicSysFlag) throws MQClientException {
+ this.makeSureStateOK();
+ Validators.checkTopic(newTopic);
+
+ this.mQClientFactory.getMQAdminImpl().createTopic(key, newTopic, queueNum, topicSysFlag);
+ }
+
+ private void makeSureStateOK() throws MQClientException {
+ if (this.serviceState != ServiceState.RUNNING) {
+ throw new MQClientException("The producer service state not OK, "//
+ + this.serviceState//
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
+ null);
+ }
+ }
+
+ public List<MessageQueue> fetchPublishMessageQueues(String topic) throws MQClientException {
+ this.makeSureStateOK();
+ return this.mQClientFactory.getMQAdminImpl().fetchPublishMessageQueues(topic);
+ }
+
+ public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
+ this.makeSureStateOK();
+ return this.mQClientFactory.getMQAdminImpl().searchOffset(mq, timestamp);
+ }
+
+ public long maxOffset(MessageQueue mq) throws MQClientException {
+ this.makeSureStateOK();
+ return this.mQClientFactory.getMQAdminImpl().maxOffset(mq);
+ }
+
+ public long minOffset(MessageQueue mq) throws MQClientException {
+ this.makeSureStateOK();
+ return this.mQClientFactory.getMQAdminImpl().minOffset(mq);
+ }
+
+ public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
+ this.makeSureStateOK();
+ return this.mQClientFactory.getMQAdminImpl().earliestMsgStoreTime(mq);
+ }
+
+ public MessageExt viewMessage(String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ this.makeSureStateOK();
+
+ return this.mQClientFactory.getMQAdminImpl().viewMessage(msgId);
+ }
+
+ public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
+ throws MQClientException, InterruptedException {
+ this.makeSureStateOK();
+ return this.mQClientFactory.getMQAdminImpl().queryMessage(topic, key, maxNum, begin, end);
+ }
+
+ public MessageExt queryMessageByUniqKey(String topic, String uniqKey)
+ throws MQClientException, InterruptedException {
+ this.makeSureStateOK();
+ return this.mQClientFactory.getMQAdminImpl().queryMessageByUniqKey(topic, uniqKey);
+ }
+
+ /**
+ * DEFAULT ASYNC -------------------------------------------------------
+ */
+ public void send(Message msg, SendCallback sendCallback) throws MQClientException, RemotingException, InterruptedException {
+ send(msg, sendCallback, this.defaultMQProducer.getSendMsgTimeout());
+ }
+
+ public void send(Message msg, SendCallback sendCallback, long timeout)
+ throws MQClientException, RemotingException, InterruptedException {
+ try {
+ this.sendDefaultImpl(msg, CommunicationMode.ASYNC, sendCallback, timeout);
+ } catch (MQBrokerException e) {
+ throw new MQClientException("unknownn exception", e);
+ }
+ }
+
+ public MessageQueue selectOneMessageQueue(final TopicPublishInfo tpInfo, final String lastBrokerName) {
+ return this.mqFaultStrategy.selectOneMessageQueue(tpInfo, lastBrokerName);
+ }
+
+ public void updateFaultItem(final String brokerName, final long currentLatency, boolean isolation) {
+ this.mqFaultStrategy.updateFaultItem(brokerName, currentLatency, isolation);
+ }
+
+ private SendResult sendDefaultImpl(//
+ Message msg, //
+ final CommunicationMode communicationMode, //
+ final SendCallback sendCallback, //
+ final long timeout//
+ ) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ this.makeSureStateOK();
+ Validators.checkMessage(msg, this.defaultMQProducer);
+
+ final long invokeID = random.nextLong();
+ long beginTimestampFirst = System.currentTimeMillis();
+ long beginTimestampPrev = beginTimestampFirst;
+ long endTimestamp = beginTimestampFirst;
+ TopicPublishInfo topicPublishInfo = this.tryToFindTopicPublishInfo(msg.getTopic());
+ if (topicPublishInfo != null && topicPublishInfo.ok()) {
+ MessageQueue mq = null;
+ Exception exception = null;
+ SendResult sendResult = null;
+ int timesTotal = communicationMode == CommunicationMode.SYNC ? 1 + this.defaultMQProducer.getRetryTimesWhenSendFailed() : 1;
+ int times = 0;
+ String[] brokersSent = new String[timesTotal];
+ for (; times < timesTotal; times++) {
+ String lastBrokerName = null == mq ? null : mq.getBrokerName();
+ MessageQueue tmpmq = this.selectOneMessageQueue(topicPublishInfo, lastBrokerName);
+ if (tmpmq != null) {
+ mq = tmpmq;
+ brokersSent[times] = mq.getBrokerName();
+ try {
+ beginTimestampPrev = System.currentTimeMillis();
+ sendResult = this.sendKernelImpl(msg, mq, communicationMode, sendCallback, topicPublishInfo, timeout);
+ endTimestamp = System.currentTimeMillis();
+ this.updateFaultItem(mq.getBrokerName(), endTimestamp - beginTimestampPrev, false);
+ switch (communicationMode) {
+ case ASYNC:
+ return null;
+ case ONEWAY:
+ return null;
+ case SYNC:
+ if (sendResult.getSendStatus() != SendStatus.SEND_OK) {
+ if (this.defaultMQProducer.isRetryAnotherBrokerWhenNotStoreOK()) {
+ continue;
+ }
+ }
+
+ return sendResult;
+ default:
+ break;
+ }
+ } catch (RemotingException e) {
+ endTimestamp = System.currentTimeMillis();
+ this.updateFaultItem(mq.getBrokerName(), endTimestamp - beginTimestampPrev, true);
+ log.warn(String.format("sendKernelImpl exception, resend at once, InvokeID: %s, RT: %sms, Broker: %s", invokeID, endTimestamp - beginTimestampPrev, mq), e);
+ log.warn(msg.toString());
+ exception = e;
+ continue;
+ } catch (MQClientException e) {
+ endTimestamp = System.currentTimeMillis();
+ this.updateFaultItem(mq.getBrokerName(), endTimestamp - beginTimestampPrev, true);
+ log.warn(String.format("sendKernelImpl exception, resend at once, InvokeID: %s, RT: %sms, Broker: %s", invokeID, endTimestamp - beginTimestampPrev, mq), e);
+ log.warn(msg.toString());
+ exception = e;
+ continue;
+ } catch (MQBrokerException e) {
+ endTimestamp = System.currentTimeMillis();
+ this.updateFaultItem(mq.getBrokerName(), endTimestamp - beginTimestampPrev, true);
+ log.warn(String.format("sendKernelImpl exception, resend at once, InvokeID: %s, RT: %sms, Broker: %s", invokeID, endTimestamp - beginTimestampPrev, mq), e);
+ log.warn(msg.toString());
+ exception = e;
+ switch (e.getResponseCode()) {
+ case ResponseCode.TOPIC_NOT_EXIST:
+ case ResponseCode.SERVICE_NOT_AVAILABLE:
+ case ResponseCode.SYSTEM_ERROR:
+ case ResponseCode.NO_PERMISSION:
+ case ResponseCode.NO_BUYER_ID:
+ case ResponseCode.NOT_IN_CURRENT_UNIT:
+ continue;
+ default:
+ if (sendResult != null) {
+ return sendResult;
+ }
+
+ throw e;
+ }
+ } catch (InterruptedException e) {
+ endTimestamp = System.currentTimeMillis();
+ this.updateFaultItem(mq.getBrokerName(), endTimestamp - beginTimestampPrev, false);
+ log.warn(String.format("sendKernelImpl exception, throw exception, InvokeID: %s, RT: %sms, Broker: %s", invokeID, endTimestamp - beginTimestampPrev, mq), e);
+ log.warn(msg.toString());
+
+ log.warn("sendKernelImpl exception", e);
+ log.warn(msg.toString());
+ throw e;
+ }
+ } else {
+ break;
+ }
+ }
+
+ if (sendResult != null) {
+ return sendResult;
+ }
+
+ String info = String.format("Send [%d] times, still failed, cost [%d]ms, Topic: %s, BrokersSent: %s",
+ times,
+ System.currentTimeMillis() - beginTimestampFirst,
+ msg.getTopic(),
+ Arrays.toString(brokersSent));
+
+ info += FAQUrl.suggestTodo(FAQUrl.SEND_MSG_FAILED);
+
+ MQClientException mqClientException = new MQClientException(info, exception);
+ if (exception instanceof MQBrokerException) {
+ mqClientException.setResponseCode(((MQBrokerException) exception).getResponseCode());
+ } else if (exception instanceof RemotingConnectException) {
+ mqClientException.setResponseCode(ClientErrorCode.CONNECT_BROKER_EXCEPTION);
+ } else if (exception instanceof RemotingTimeoutException) {
+ mqClientException.setResponseCode(ClientErrorCode.ACCESS_BROKER_TIMEOUT);
+ } else if (exception instanceof MQClientException) {
+ mqClientException.setResponseCode(ClientErrorCode.BROKER_NOT_EXIST_EXCEPTION);
+ }
+
+ throw mqClientException;
+ }
+
+ List<String> nsList = this.getmQClientFactory().getMQClientAPIImpl().getNameServerAddressList();
+ if (null == nsList || nsList.isEmpty()) {
+ throw new MQClientException(
+ "No name server address, please set it." + FAQUrl.suggestTodo(FAQUrl.NAME_SERVER_ADDR_NOT_EXIST_URL), null).setResponseCode(ClientErrorCode.NO_NAME_SERVER_EXCEPTION);
+ }
+
+ throw new MQClientException("No route info of this topic, " + msg.getTopic() + FAQUrl.suggestTodo(FAQUrl.NO_TOPIC_ROUTE_INFO),
+ null).setResponseCode(ClientErrorCode.NOT_FOUND_TOPIC_EXCEPTION);
+ }
+
+ private TopicPublishInfo tryToFindTopicPublishInfo(final String topic) {
+ TopicPublishInfo topicPublishInfo = this.topicPublishInfoTable.get(topic);
+ if (null == topicPublishInfo || !topicPublishInfo.ok()) {
+ this.topicPublishInfoTable.putIfAbsent(topic, new TopicPublishInfo());
+ this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic);
+ topicPublishInfo = this.topicPublishInfoTable.get(topic);
+ }
+
+ if (topicPublishInfo.isHaveTopicRouterInfo() || topicPublishInfo.ok()) {
+ return topicPublishInfo;
+ } else {
+ this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic, true, this.defaultMQProducer);
+ topicPublishInfo = this.topicPublishInfoTable.get(topic);
+ return topicPublishInfo;
+ }
+ }
+
+ private SendResult sendKernelImpl(final Message msg, //
+ final MessageQueue mq, //
+ final CommunicationMode communicationMode, //
+ final SendCallback sendCallback, //
+ final TopicPublishInfo topicPublishInfo, //
+ final long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
+ if (null == brokerAddr) {
+ tryToFindTopicPublishInfo(mq.getTopic());
+ brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
+ }
+
+ SendMessageContext context = null;
+ if (brokerAddr != null) {
+ brokerAddr = MixAll.brokerVIPChannel(this.defaultMQProducer.isSendMessageWithVIPChannel(), brokerAddr);
+
+ byte[] prevBody = msg.getBody();
+ try {
+
+ MessageClientIDSetter.setUniqID(msg);
+
+ int sysFlag = 0;
+ if (this.tryToCompressMessage(msg)) {
+ sysFlag |= MessageSysFlag.COMPRESSED_FLAG;
+ }
+
+ final String tranMsg = msg.getProperty(MessageConst.PROPERTY_TRANSACTION_PREPARED);
+ if (tranMsg != null && Boolean.parseBoolean(tranMsg)) {
+ sysFlag |= MessageSysFlag.TRANSACTION_PREPARED_TYPE;
+ }
+
+ if (hasCheckForbiddenHook()) {
+ CheckForbiddenContext checkForbiddenContext = new CheckForbiddenContext();
+ checkForbiddenContext.setNameSrvAddr(this.defaultMQProducer.getNamesrvAddr());
+ checkForbiddenContext.setGroup(this.defaultMQProducer.getProducerGroup());
+ checkForbiddenContext.setCommunicationMode(communicationMode);
+ checkForbiddenContext.setBrokerAddr(brokerAddr);
+ checkForbiddenContext.setMessage(msg);
+ checkForbiddenContext.setMq(mq);
+ checkForbiddenContext.setUnitMode(this.isUnitMode());
+ this.executeCheckForbiddenHook(checkForbiddenContext);
+ }
+
+ if (this.hasSendMessageHook()) {
+ context = new SendMessageContext();
+ context.setProducer(this);
+ context.setProducerGroup(this.defaultMQProducer.getProducerGroup());
+ context.setCommunicationMode(communicationMode);
+ context.setBornHost(this.defaultMQProducer.getClientIP());
+ context.setBrokerAddr(brokerAddr);
+ context.setMessage(msg);
+ context.setMq(mq);
+ String isTrans = msg.getProperty(MessageConst.PROPERTY_TRANSACTION_PREPARED);
+ if (isTrans != null && isTrans.equals("true")) {
+ context.setMsgType(MessageType.Trans_Msg_Half);
+ }
+
+ if (msg.getProperty("__STARTDELIVERTIME") != null || msg.getProperty(MessageConst.PROPERTY_DELAY_TIME_LEVEL) != null) {
+ context.setMsgType(MessageType.Delay_Msg);
+ }
+ this.executeSendMessageHookBefore(context);
+ }
+
+ SendMessageRequestHeader requestHeader = new SendMessageRequestHeader();
+ requestHeader.setProducerGroup(this.defaultMQProducer.getProducerGroup());
+ requestHeader.setTopic(msg.getTopic());
+ requestHeader.setDefaultTopic(this.defaultMQProducer.getCreateTopicKey());
+ requestHeader.setDefaultTopicQueueNums(this.defaultMQProducer.getDefaultTopicQueueNums());
+ requestHeader.setQueueId(mq.getQueueId());
+ requestHeader.setSysFlag(sysFlag);
+ requestHeader.setBornTimestamp(System.currentTimeMillis());
+ requestHeader.setFlag(msg.getFlag());
+ requestHeader.setProperties(MessageDecoder.messageProperties2String(msg.getProperties()));
+ requestHeader.setReconsumeTimes(0);
+ requestHeader.setUnitMode(this.isUnitMode());
+ if (requestHeader.getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
+ String reconsumeTimes = MessageAccessor.getReconsumeTime(msg);
+ if (reconsumeTimes != null) {
+ requestHeader.setReconsumeTimes(Integer.valueOf(reconsumeTimes));
+ MessageAccessor.clearProperty(msg, MessageConst.PROPERTY_RECONSUME_TIME);
+ }
+
+ String maxReconsumeTimes = MessageAccessor.getMaxReconsumeTimes(msg);
+ if (maxReconsumeTimes != null) {
+ requestHeader.setMaxReconsumeTimes(Integer.valueOf(maxReconsumeTimes));
+ MessageAccessor.clearProperty(msg, MessageConst.PROPERTY_MAX_RECONSUME_TIMES);
+ }
+ }
+
+ SendResult sendResult = null;
+ switch (communicationMode) {
+ case ASYNC:
+ sendResult = this.mQClientFactory.getMQClientAPIImpl().sendMessage(//
+ brokerAddr, // 1
+ mq.getBrokerName(), // 2
+ msg, // 3
+ requestHeader, // 4
+ timeout, // 5
+ communicationMode, // 6
+ sendCallback, // 7
+ topicPublishInfo, // 8
+ this.mQClientFactory, // 9
+ this.defaultMQProducer.getRetryTimesWhenSendAsyncFailed(), // 10
+ context, //
+ this);
+ break;
+ case ONEWAY:
+ case SYNC:
+ sendResult = this.mQClientFactory.getMQClientAPIImpl().sendMessage(
+ brokerAddr,
+ mq.getBrokerName(),
+ msg,
+ requestHeader,
+ timeout,
+ communicationMode,
+ context,
+ this);
+ break;
+ default:
+ assert false;
+ break;
+ }
+
+ if (this.hasSendMessageHook()) {
+ context.setSendResult(sendResult);
+ this.executeSendMessageHookAfter(context);
+ }
+
+ return sendResult;
+ } catch (RemotingException e) {
+ if (this.hasSendMessageHook()) {
+ context.setException(e);
+ this.executeSendMessageHookAfter(context);
+ }
+ throw e;
+ } catch (MQBrokerException e) {
+ if (this.hasSendMessageHook()) {
+ context.setException(e);
+ this.executeSendMessageHookAfter(context);
+ }
+ throw e;
+ } catch (InterruptedException e) {
+ if (this.hasSendMessageHook()) {
+ context.setException(e);
+ this.executeSendMessageHookAfter(context);
+ }
+ throw e;
+ } finally {
+ msg.setBody(prevBody);
+ }
+ }
+
+ throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
+ }
+
+ public MQClientInstance getmQClientFactory() {
+ return mQClientFactory;
+ }
+
+ private boolean tryToCompressMessage(final Message msg) {
+ byte[] body = msg.getBody();
+ if (body != null) {
+ if (body.length >= this.defaultMQProducer.getCompressMsgBodyOverHowmuch()) {
+ try {
+ byte[] data = UtilAll.compress(body, zipCompressLevel);
+ if (data != null) {
+ msg.setBody(data);
+ return true;
+ }
+ } catch (IOException e) {
+ log.error("tryToCompressMessage exception", e);
+ log.warn(msg.toString());
+ }
+ }
+ }
+
+ return false;
+ }
+
+ public boolean hasCheckForbiddenHook() {
+ return !checkForbiddenHookList.isEmpty();
+ }
+
+ public void executeCheckForbiddenHook(final CheckForbiddenContext context) throws MQClientException {
+ if (hasCheckForbiddenHook()) {
+ for (CheckForbiddenHook hook : checkForbiddenHookList) {
+ hook.checkForbidden(context);
+ }
+ }
+ }
+
+ public boolean hasSendMessageHook() {
+ return !this.sendMessageHookList.isEmpty();
+ }
+
+ public void executeSendMessageHookBefore(final SendMessageContext context) {
+ if (!this.sendMessageHookList.isEmpty()) {
+ for (SendMessageHook hook : this.sendMessageHookList) {
+ try {
+ hook.sendMessageBefore(context);
+ } catch (Throwable e) {
+ log.warn("failed to executeSendMessageHookBefore", e);
+ }
+ }
+ }
+ }
+
+ public void executeSendMessageHookAfter(final SendMessageContext context) {
+ if (!this.sendMessageHookList.isEmpty()) {
+ for (SendMessageHook hook : this.sendMessageHookList) {
+ try {
+ hook.sendMessageAfter(context);
+ } catch (Throwable e) {
+ log.warn("failed to executeSendMessageHookAfter", e);
+ }
+ }
+ }
+ }
+
+ /**
+ * DEFAULT ONEWAY -------------------------------------------------------
+ */
+ public void sendOneway(Message msg) throws MQClientException, RemotingException, InterruptedException {
+ try {
+ this.sendDefaultImpl(msg, CommunicationMode.ONEWAY, null, this.defaultMQProducer.getSendMsgTimeout());
+ } catch (MQBrokerException e) {
+ throw new MQClientException("unknown exception", e);
+ }
+ }
+
+ /**
+ * KERNEL SYNC -------------------------------------------------------
+ */
+ public SendResult send(Message msg, MessageQueue mq)
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ return send(msg, mq, this.defaultMQProducer.getSendMsgTimeout());
+ }
+
+ public SendResult send(Message msg, MessageQueue mq, long timeout)
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ this.makeSureStateOK();
+ Validators.checkMessage(msg, this.defaultMQProducer);
+
+ if (!msg.getTopic().equals(mq.getTopic())) {
+ throw new MQClientException("message's topic not equal mq's topic", null);
+ }
+
+ return this.sendKernelImpl(msg, mq, CommunicationMode.SYNC, null, null, timeout);
+ }
+
+ /**
+ * KERNEL ASYNC -------------------------------------------------------
+ */
+ public void send(Message msg, MessageQueue mq, SendCallback sendCallback)
+ throws MQClientException, RemotingException, InterruptedException {
+ send(msg, mq, sendCallback, this.defaultMQProducer.getSendMsgTimeout());
+ }
+
+ public void send(Message msg, MessageQueue mq, SendCallback sendCallback, long timeout)
+ throws MQClientException, RemotingException, InterruptedException {
+ this.makeSureStateOK();
+ Validators.checkMessage(msg, this.defaultMQProducer);
+
+ if (!msg.getTopic().equals(mq.getTopic())) {
+ throw new MQClientException("message's topic not equal mq's topic", null);
+ }
+
+ try {
+ this.sendKernelImpl(msg, mq, CommunicationMode.ASYNC, sendCallback, null, timeout);
+ } catch (MQBrokerException e) {
+ throw new MQClientException("unknown exception", e);
+ }
+ }
+
+ /**
+ * KERNEL ONEWAY -------------------------------------------------------
+ */
+ public void sendOneway(Message msg, MessageQueue mq) throws MQClientException, RemotingException, InterruptedException {
+ this.makeSureStateOK();
+ Validators.checkMessage(msg, this.defaultMQProducer);
+
+ try {
+ this.sendKernelImpl(msg, mq, CommunicationMode.ONEWAY, null, null, this.defaultMQProducer.getSendMsgTimeout());
+ } catch (MQBrokerException e) {
+ throw new MQClientException("unknown exception", e);
+ }
+ }
+
+ /**
+ * SELECT SYNC -------------------------------------------------------
+ */
+ public SendResult send(Message msg, MessageQueueSelector selector, Object arg)
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ return send(msg, selector, arg, this.defaultMQProducer.getSendMsgTimeout());
+ }
+
+ public SendResult send(Message msg, MessageQueueSelector selector, Object arg, long timeout)
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ return this.sendSelectImpl(msg, selector, arg, CommunicationMode.SYNC, null, timeout);
+ }
+
+ private SendResult sendSelectImpl(//
+ Message msg, //
+ MessageQueueSelector selector, //
+ Object arg, //
+ final CommunicationMode communicationMode, //
+ final SendCallback sendCallback, final long timeout//
+ ) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ this.makeSureStateOK();
+ Validators.checkMessage(msg, this.defaultMQProducer);
+
+ TopicPublishInfo topicPublishInfo = this.tryToFindTopicPublishInfo(msg.getTopic());
+ if (topicPublishInfo != null && topicPublishInfo.ok()) {
+ MessageQueue mq = null;
+ try {
+ mq = selector.select(topicPublishInfo.getMessageQueueList(), msg, arg);
+ } catch (Throwable e) {
+ throw new MQClientException("select message queue throwed exception.", e);
+ }
+
+ if (mq != null) {
+ return this.sendKernelImpl(msg, mq, communicationMode, sendCallback, null, timeout);
+ } else {
+ throw new MQClientException("select message queue return null.", null);
+ }
+ }
+
+ throw new MQClientException("No route info for this topic, " + msg.getTopic(), null);
+ }
+
+ /**
+ * SELECT ASYNC -------------------------------------------------------
+ */
+ public void send(Message msg, MessageQueueSelector selector, Object arg, SendCallback sendCallback)
+ throws MQClientException, RemotingException, InterruptedException {
+ send(msg, selector, arg, sendCallback, this.defaultMQProducer.getSendMsgTimeout());
+ }
+
+ public void send(Message msg, MessageQueueSelector selector, Object arg, SendCallback sendCallback, long timeout)
+ throws MQClientException, RemotingException, InterruptedException {
+ try {
+ this.sendSelectImpl(msg, selector, arg, CommunicationMode.ASYNC, sendCallback, timeout);
+ } catch (MQBrokerException e) {
+ throw new MQClientException("unknownn exception", e);
+ }
+ }
+
+ /**
+ * SELECT ONEWAY -------------------------------------------------------
+ */
+ public void sendOneway(Message msg, MessageQueueSelector selector, Object arg)
+ throws MQClientException, RemotingException, InterruptedException {
+ try {
+ this.sendSelectImpl(msg, selector, arg, CommunicationMode.ONEWAY, null, this.defaultMQProducer.getSendMsgTimeout());
+ } catch (MQBrokerException e) {
+ throw new MQClientException("unknown exception", e);
+ }
+ }
+
+ public TransactionSendResult sendMessageInTransaction(final Message msg, final LocalTransactionExecuter tranExecuter, final Object arg)
+ throws MQClientException {
+ if (null == tranExecuter) {
+ throw new MQClientException("tranExecutor is null", null);
+ }
+ Validators.checkMessage(msg, this.defaultMQProducer);
+
+ SendResult sendResult = null;
+ MessageAccessor.putProperty(msg, MessageConst.PROPERTY_TRANSACTION_PREPARED, "true");
+ MessageAccessor.putProperty(msg, MessageConst.PROPERTY_PRODUCER_GROUP, this.defaultMQProducer.getProducerGroup());
+ try {
+ sendResult = this.send(msg);
+ } catch (Exception e) {
+ throw new MQClientException("send message Exception", e);
+ }
+
+ LocalTransactionState localTransactionState = LocalTransactionState.UNKNOW;
+ Throwable localException = null;
+ switch (sendResult.getSendStatus()) {
+ case SEND_OK: {
+ try {
+ if (sendResult.getTransactionId() != null) {
+ msg.putUserProperty("__transactionId__", sendResult.getTransactionId());
+ }
+ localTransactionState = tranExecuter.executeLocalTransactionBranch(msg, arg);
+ if (null == localTransactionState) {
+ localTransactionState = LocalTransactionState.UNKNOW;
+ }
+
+ if (localTransactionState != LocalTransactionState.COMMIT_MESSAGE) {
+ log.info("executeLocalTransactionBranch return {}", localTransactionState);
+ log.info(msg.toString());
+ }
+ } catch (Throwable e) {
+ log.info("executeLocalTransactionBranch exception", e);
+ log.info(msg.toString());
+ localException = e;
+ }
+ }
+ break;
+ case FLUSH_DISK_TIMEOUT:
+ case FLUSH_SLAVE_TIMEOUT:
+ case SLAVE_NOT_AVAILABLE:
+ localTransactionState = LocalTransactionState.ROLLBACK_MESSAGE;
+ break;
+ default:
+ break;
+ }
+
+ try {
+ this.endTransaction(sendResult, localTransactionState, localException);
+ } catch (Exception e) {
+ log.warn("local transaction execute " + localTransactionState + ", but end broker transaction failed", e);
+ }
+
+ TransactionSendResult transactionSendResult = new TransactionSendResult();
+ transactionSendResult.setSendStatus(sendResult.getSendStatus());
+ transactionSendResult.setMessageQueue(sendResult.getMessageQueue());
+ transactionSendResult.setMsgId(sendResult.getMsgId());
+ transactionSendResult.setQueueOffset(sendResult.getQueueOffset());
+ transactionSendResult.setTransactionId(sendResult.getTransactionId());
+ transactionSendResult.setLocalTransactionState(localTransactionState);
+ return transactionSendResult;
+ }
+
+ /**
+ * DEFAULT SYNC -------------------------------------------------------
+ */
+ public SendResult send(Message msg) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ return send(msg, this.defaultMQProducer.getSendMsgTimeout());
+ }
+
+ public void endTransaction(//
+ final SendResult sendResult, //
+ final LocalTransactionState localTransactionState, //
+ final Throwable localException) throws RemotingException, MQBrokerException, InterruptedException, UnknownHostException {
+ final MessageId id;
+ if (sendResult.getOffsetMsgId() != null) {
+ id = MessageDecoder.decodeMessageId(sendResult.getOffsetMsgId());
+ } else {
+ id = MessageDecoder.decodeMessageId(sendResult.getMsgId());
+ }
+ String transactionId = sendResult.getTransactionId();
+ final String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(sendResult.getMessageQueue().getBrokerName());
+ EndTransactionRequestHeader requestHeader = new EndTransactionRequestHeader();
+ requestHeader.setTransactionId(transactionId);
+ requestHeader.setCommitLogOffset(id.getOffset());
+ switch (localTransactionState) {
+ case COMMIT_MESSAGE:
+ requestHeader.setCommitOrRollback(MessageSysFlag.TRANSACTION_COMMIT_TYPE);
+ break;
+ case ROLLBACK_MESSAGE:
+ requestHeader.setCommitOrRollback(MessageSysFlag.TRANSACTION_ROLLBACK_TYPE);
+ break;
+ case UNKNOW:
+ requestHeader.setCommitOrRollback(MessageSysFlag.TRANSACTION_NOT_TYPE);
+ break;
+ default:
+ break;
+ }
+
+ requestHeader.setProducerGroup(this.defaultMQProducer.getProducerGroup());
+ requestHeader.setTranStateTableOffset(sendResult.getQueueOffset());
+ requestHeader.setMsgId(sendResult.getMsgId());
+ String remark = localException != null ? ("executeLocalTransactionBranch exception: " + localException.toString()) : null;
+ this.mQClientFactory.getMQClientAPIImpl().endTransactionOneway(brokerAddr, requestHeader, remark,
+ this.defaultMQProducer.getSendMsgTimeout());
+ }
+
+ public SendResult send(Message msg, long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ return this.sendDefaultImpl(msg, CommunicationMode.SYNC, null, timeout);
+ }
+
+ public ConcurrentHashMap<String, TopicPublishInfo> getTopicPublishInfoTable() {
+ return topicPublishInfoTable;
+ }
+
+ public int getZipCompressLevel() {
+ return zipCompressLevel;
+ }
+
+
+ public void setZipCompressLevel(int zipCompressLevel) {
+ this.zipCompressLevel = zipCompressLevel;
+ }
+
+
+ public ServiceState getServiceState() {
+ return serviceState;
+ }
+
+
+ public void setServiceState(ServiceState serviceState) {
+ this.serviceState = serviceState;
+ }
+
+ public long[] getNotAvailableDuration() {
+ return this.mqFaultStrategy.getNotAvailableDuration();
+ }
+
+ public void setNotAvailableDuration(final long[] notAvailableDuration) {
+ this.mqFaultStrategy.setNotAvailableDuration(notAvailableDuration);
+ }
+
+ public long[] getLatencyMax() {
+ return this.mqFaultStrategy.getLatencyMax();
+ }
+
+ public void setLatencyMax(final long[] latencyMax) {
+ this.mqFaultStrategy.setLatencyMax(latencyMax);
+ }
+
+ public boolean isSendLatencyFaultEnable() {
+ return this.mqFaultStrategy.isSendLatencyFaultEnable();
+ }
+
+ public void setSendLatencyFaultEnable(final boolean sendLatencyFaultEnable) {
+ this.mqFaultStrategy.setSendLatencyFaultEnable(sendLatencyFaultEnable);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java b/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java
new file mode 100644
index 0000000..c196a43
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java
@@ -0,0 +1,49 @@
+/**
+ * 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.impl.producer;
+
+import org.apache.rocketmq.client.producer.TransactionCheckListener;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.protocol.header.CheckTransactionStateRequestHeader;
+
+import java.util.Set;
+
+
+/**
+ * @author shijia.wxr
+ */
+public interface MQProducerInner {
+ Set<String> getPublishTopicList();
+
+
+ boolean isPublishTopicNeedUpdate(final String topic);
+
+
+ TransactionCheckListener checkListener();
+
+
+ void checkTransactionState(//
+ final String addr, //
+ final MessageExt msg, //
+ final CheckTransactionStateRequestHeader checkRequestHeader);
+
+
+ void updateTopicPublishInfo(final String topic, final TopicPublishInfo info);
+
+
+ boolean isUnitMode();
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java b/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
new file mode 100644
index 0000000..5267625
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
@@ -0,0 +1,133 @@
+/**
+ * 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.impl.producer;
+
+import org.apache.rocketmq.client.common.ThreadLocalIndex;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.route.QueueData;
+import org.apache.rocketmq.common.protocol.route.TopicRouteData;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class TopicPublishInfo {
+ private boolean orderTopic = false;
+ private boolean haveTopicRouterInfo = false;
+ private List<MessageQueue> messageQueueList = new ArrayList<MessageQueue>();
+ private volatile ThreadLocalIndex sendWhichQueue = new ThreadLocalIndex(0);
+ private TopicRouteData topicRouteData;
+
+
+ public boolean isOrderTopic() {
+ return orderTopic;
+ }
+
+ public void setOrderTopic(boolean orderTopic) {
+ this.orderTopic = orderTopic;
+ }
+
+ public boolean ok() {
+ return null != this.messageQueueList && !this.messageQueueList.isEmpty();
+ }
+
+ public List<MessageQueue> getMessageQueueList() {
+ return messageQueueList;
+ }
+
+
+ public void setMessageQueueList(List<MessageQueue> messageQueueList) {
+ this.messageQueueList = messageQueueList;
+ }
+
+
+ public ThreadLocalIndex getSendWhichQueue() {
+ return sendWhichQueue;
+ }
+
+
+ public void setSendWhichQueue(ThreadLocalIndex sendWhichQueue) {
+ this.sendWhichQueue = sendWhichQueue;
+ }
+
+
+ public boolean isHaveTopicRouterInfo() {
+ return haveTopicRouterInfo;
+ }
+
+
+ public void setHaveTopicRouterInfo(boolean haveTopicRouterInfo) {
+ this.haveTopicRouterInfo = haveTopicRouterInfo;
+ }
+
+
+ public MessageQueue selectOneMessageQueue(final String lastBrokerName) {
+ if (lastBrokerName == null) {
+ return selectOneMessageQueue();
+ } else {
+ int index = this.sendWhichQueue.getAndIncrement();
+ for (int i = 0; i < this.messageQueueList.size(); i++) {
+ int pos = Math.abs(index++) % this.messageQueueList.size();
+ if (pos < 0)
+ pos = 0;
+ MessageQueue mq = this.messageQueueList.get(pos);
+ if (!mq.getBrokerName().equals(lastBrokerName)) {
+ return mq;
+ }
+ }
+ return selectOneMessageQueue();
+ }
+ }
+
+
+ public MessageQueue selectOneMessageQueue() {
+ int index = this.sendWhichQueue.getAndIncrement();
+ int pos = Math.abs(index) % this.messageQueueList.size();
+ if (pos < 0)
+ pos = 0;
+ return this.messageQueueList.get(pos);
+ }
+
+ public int getQueueIdByBroker(final String brokerName) {
+ for (int i = 0; i < topicRouteData.getQueueDatas().size(); i++) {
+ final QueueData queueData = this.topicRouteData.getQueueDatas().get(i);
+ if (queueData.getBrokerName().equals(brokerName)) {
+ return queueData.getWriteQueueNums();
+ }
+ }
+
+ return -1;
+ }
+
+
+ @Override
+ public String toString() {
+ return "TopicPublishInfo [orderTopic=" + orderTopic + ", messageQueueList=" + messageQueueList
+ + ", sendWhichQueue=" + sendWhichQueue + ", haveTopicRouterInfo=" + haveTopicRouterInfo + "]";
+ }
+
+ public TopicRouteData getTopicRouteData() {
+ return topicRouteData;
+ }
+
+ public void setTopicRouteData(final TopicRouteData topicRouteData) {
+ this.topicRouteData = topicRouteData;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultTolerance.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultTolerance.java b/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultTolerance.java
new file mode 100644
index 0000000..c5e25ce
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultTolerance.java
@@ -0,0 +1,31 @@
+/**
+ * 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.latency;
+
+/**
+ * @author shijia.wxr
+ */
+public interface LatencyFaultTolerance<T> {
+ void updateFaultItem(final T name, final long currentLatency, final long notAvailableDuration);
+
+ boolean isAvailable(final T name);
+
+ void remove(final T name);
+
+ T pickOneAtLeast();
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java b/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
new file mode 100644
index 0000000..3bd7788
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
@@ -0,0 +1,191 @@
+/**
+ * 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.latency;
+
+import org.apache.rocketmq.client.common.ThreadLocalIndex;
+
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * @author shijia.wxr
+ */
+public class LatencyFaultToleranceImpl implements LatencyFaultTolerance<String> {
+ private final ConcurrentHashMap<String, FaultItem> faultItemTable = new ConcurrentHashMap<String, FaultItem>(16);
+
+ private final ThreadLocalIndex whichItemWorst = new ThreadLocalIndex(0);
+
+ @Override
+ public void updateFaultItem(final String name, final long currentLatency, final long notAvailableDuration) {
+ FaultItem old = this.faultItemTable.get(name);
+ if (null == old) {
+ final FaultItem faultItem = new FaultItem(name);
+ faultItem.setCurrentLatency(currentLatency);
+ faultItem.setStartTimestamp(System.currentTimeMillis() + notAvailableDuration);
+
+ old = this.faultItemTable.putIfAbsent(name, faultItem);
+ if (old != null) {
+ old.setCurrentLatency(currentLatency);
+ old.setStartTimestamp(System.currentTimeMillis() + notAvailableDuration);
+ }
+ } else {
+ old.setCurrentLatency(currentLatency);
+ old.setStartTimestamp(System.currentTimeMillis() + notAvailableDuration);
+ }
+ }
+
+ @Override
+ public boolean isAvailable(final String name) {
+ final FaultItem faultItem = this.faultItemTable.get(name);
+ if (faultItem != null) {
+ return faultItem.isAvailable();
+ }
+ return true;
+ }
+
+ @Override
+ public void remove(final String name) {
+ this.faultItemTable.remove(name);
+ }
+
+ @Override
+ public String pickOneAtLeast() {
+ final Enumeration<FaultItem> elements = this.faultItemTable.elements();
+ List<FaultItem> tmpList = new LinkedList<FaultItem>();
+ while (elements.hasMoreElements()) {
+ final FaultItem faultItem = elements.nextElement();
+ tmpList.add(faultItem);
+ }
+
+ if (!tmpList.isEmpty()) {
+ Collections.shuffle(tmpList);
+
+ Collections.sort(tmpList);
+
+ final int half = tmpList.size() / 2;
+ if (half <= 0) {
+ return tmpList.get(0).getName();
+ } else {
+ final int i = this.whichItemWorst.getAndIncrement() % half;
+ return tmpList.get(i).getName();
+ }
+ }
+
+ return null;
+ }
+
+ class FaultItem implements Comparable<FaultItem> {
+ private final String name;
+ private volatile long currentLatency;
+ private volatile long startTimestamp;
+
+ public FaultItem(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public int compareTo(final FaultItem other) {
+ if (this.isAvailable() != other.isAvailable()) {
+ if (this.isAvailable()) return -1;
+
+ if (other.isAvailable()) return 1;
+ }
+
+ if (this.currentLatency < other.currentLatency)
+ return -1;
+ else if (this.currentLatency > other.currentLatency) {
+ return 1;
+ }
+
+ if (this.startTimestamp < other.startTimestamp)
+ return -1;
+ else if (this.startTimestamp > other.startTimestamp) {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ public boolean isAvailable() {
+ return (System.currentTimeMillis() - startTimestamp) >= 0;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = getName() != null ? getName().hashCode() : 0;
+ result = 31 * result + (int) (getCurrentLatency() ^ (getCurrentLatency() >>> 32));
+ result = 31 * result + (int) (getStartTimestamp() ^ (getStartTimestamp() >>> 32));
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (!(o instanceof FaultItem)) return false;
+
+ final FaultItem faultItem = (FaultItem) o;
+
+ if (getCurrentLatency() != faultItem.getCurrentLatency()) return false;
+ if (getStartTimestamp() != faultItem.getStartTimestamp()) return false;
+ return getName() != null ? getName().equals(faultItem.getName()) : faultItem.getName() == null;
+
+ }
+
+ @Override
+ public String toString() {
+ return "FaultItem{" +
+ "name='" + name + '\'' +
+ ", currentLatency=" + currentLatency +
+ ", startTimestamp=" + startTimestamp +
+ '}';
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public long getCurrentLatency() {
+ return currentLatency;
+ }
+
+ public void setCurrentLatency(final long currentLatency) {
+ this.currentLatency = currentLatency;
+ }
+
+ public long getStartTimestamp() {
+ return startTimestamp;
+ }
+
+ public void setStartTimestamp(final long startTimestamp) {
+ this.startTimestamp = startTimestamp;
+ }
+
+
+ }
+
+ @Override
+ public String toString() {
+ return "LatencyFaultToleranceImpl{" +
+ "faultItemTable=" + faultItemTable +
+ ", whichItemWorst=" + whichItemWorst +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java b/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java
new file mode 100644
index 0000000..6d32105
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java
@@ -0,0 +1,108 @@
+/**
+ * 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.latency;
+
+import org.apache.rocketmq.client.impl.producer.TopicPublishInfo;
+import org.apache.rocketmq.common.message.MessageQueue;
+
+/**
+ * @author shijia.wxr
+ */
+public class MQFaultStrategy {
+ private final LatencyFaultTolerance<String> latencyFaultTolerance = new LatencyFaultToleranceImpl();
+
+ private boolean sendLatencyFaultEnable = false;
+
+ private long[] latencyMax = {50L, 100L, 550L, 1000L, 2000L, 3000L, 15000L};
+ private long[] notAvailableDuration = {0L, 0L, 30000L, 60000L, 120000L, 180000L, 600000L};
+
+ public long[] getNotAvailableDuration() {
+ return notAvailableDuration;
+ }
+
+ public void setNotAvailableDuration(final long[] notAvailableDuration) {
+ this.notAvailableDuration = notAvailableDuration;
+ }
+
+ public long[] getLatencyMax() {
+ return latencyMax;
+ }
+
+ public void setLatencyMax(final long[] latencyMax) {
+ this.latencyMax = latencyMax;
+ }
+
+ public boolean isSendLatencyFaultEnable() {
+ return sendLatencyFaultEnable;
+ }
+
+ public void setSendLatencyFaultEnable(final boolean sendLatencyFaultEnable) {
+ this.sendLatencyFaultEnable = sendLatencyFaultEnable;
+ }
+
+ public MessageQueue selectOneMessageQueue(final TopicPublishInfo tpInfo, final String lastBrokerName) {
+ if (this.sendLatencyFaultEnable) {
+ try {
+ int index = tpInfo.getSendWhichQueue().getAndIncrement();
+ for (int i = 0; i < tpInfo.getMessageQueueList().size(); i++) {
+ int pos = Math.abs(index++) % tpInfo.getMessageQueueList().size();
+ if (pos < 0)
+ pos = 0;
+ MessageQueue mq = tpInfo.getMessageQueueList().get(pos);
+ if (latencyFaultTolerance.isAvailable(mq.getBrokerName())) {
+ if (null == lastBrokerName || mq.getBrokerName().equals(lastBrokerName))
+ return mq;
+ }
+ }
+
+ final String notBestBroker = latencyFaultTolerance.pickOneAtLeast();
+ int writeQueueNums = tpInfo.getQueueIdByBroker(notBestBroker);
+ if (writeQueueNums > 0) {
+ final MessageQueue mq = tpInfo.selectOneMessageQueue();
+ if (notBestBroker != null) {
+ mq.setBrokerName(notBestBroker);
+ mq.setQueueId(tpInfo.getSendWhichQueue().getAndIncrement() % writeQueueNums);
+ }
+ return mq;
+ } else {
+ latencyFaultTolerance.remove(notBestBroker);
+ }
+ } catch (Exception e) {
+ }
+
+ return tpInfo.selectOneMessageQueue();
+ }
+
+ return tpInfo.selectOneMessageQueue(lastBrokerName);
+ }
+
+ public void updateFaultItem(final String brokerName, final long currentLatency, boolean isolation) {
+ if (this.sendLatencyFaultEnable) {
+ long duration = computeNotAvailableDuration(isolation ? 30000 : currentLatency);
+ this.latencyFaultTolerance.updateFaultItem(brokerName, currentLatency, duration);
+ }
+ }
+
+ private long computeNotAvailableDuration(final long currentLatency) {
+ for (int i = latencyMax.length - 1; i >= 0; i--) {
+ if (currentLatency >= latencyMax[i]) return this.notAvailableDuration[i];
+ }
+
+ return 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java b/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java
new file mode 100644
index 0000000..e4c5525
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java
@@ -0,0 +1,116 @@
+/**
+ * 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.log;
+
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.slf4j.ILoggerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Method;
+import java.net.URL;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ClientLogger {
+ private static Logger log;
+ public static final String CLIENT_LOG_ROOT = "rocketmq.client.logRoot";
+ public static final String CLIENT_LOG_MAXINDEX = "rocketmq.client.logFileMaxIndex";
+ public static final String CLIENT_LOG_LEVEL = "rocketmq.client.logLevel";
+
+ static {
+ log = createLogger(LoggerName.CLIENT_LOGGER_NAME);
+ }
+
+
+ private static Logger createLogger(final String loggerName) {
+ String logConfigFilePath =
+ System.getProperty("rocketmq.client.log.configFile",
+ System.getenv("ROCKETMQ_CLIENT_LOG_CONFIGFILE"));
+ Boolean isloadconfig =
+ Boolean.parseBoolean(System.getProperty("rocketmq.client.log.loadconfig", "true"));
+
+ final String log4JResourceFile =
+ System.getProperty("rocketmq.client.log4j.resource.fileName", "log4j_rocketmq_client.xml");
+
+ final String logbackResourceFile =
+ System.getProperty("rocketmq.client.logback.resource.fileName", "logback_rocketmq_client.xml");
+
+ String clientLogRoot = System.getProperty(CLIENT_LOG_ROOT, "${user.home}/logs/rocketmqlogs");
+ System.setProperty("client.logRoot", clientLogRoot);
+ String clientLogLevel = System.getProperty(CLIENT_LOG_LEVEL, "INFO");
+ System.setProperty("client.logLevel", clientLogLevel);
+ String clientLogMaxIndex = System.getProperty(CLIENT_LOG_MAXINDEX, "10");
+ System.setProperty("client.logFileMaxIndex", clientLogMaxIndex);
+
+ if (isloadconfig) {
+ try {
+ ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory();
+ Class classType = iLoggerFactory.getClass();
+ if (classType.getName().equals("org.slf4j.impl.Log4jLoggerFactory")) {
+ Class<?> domconfigurator;
+ Object domconfiguratorobj;
+ domconfigurator = Class.forName("org.apache.log4j.xml.DOMConfigurator");
+ domconfiguratorobj = domconfigurator.newInstance();
+ if (null == logConfigFilePath) {
+ Method configure = domconfiguratorobj.getClass().getMethod("configure", URL.class);
+ URL url = ClientLogger.class.getClassLoader().getResource(log4JResourceFile);
+ configure.invoke(domconfiguratorobj, url);
+ } else {
+ Method configure = domconfiguratorobj.getClass().getMethod("configure", String.class);
+ configure.invoke(domconfiguratorobj, logConfigFilePath);
+ }
+
+ } else if (classType.getName().equals("ch.qos.logback.classic.LoggerContext")) {
+ Class<?> joranConfigurator;
+ Class<?> context = Class.forName("ch.qos.logback.core.Context");
+ Object joranConfiguratoroObj;
+ joranConfigurator = Class.forName("ch.qos.logback.classic.joran.JoranConfigurator");
+ joranConfiguratoroObj = joranConfigurator.newInstance();
+ Method setContext = joranConfiguratoroObj.getClass().getMethod("setContext", context);
+ setContext.invoke(joranConfiguratoroObj, iLoggerFactory);
+ if (null == logConfigFilePath) {
+ URL url = ClientLogger.class.getClassLoader().getResource(logbackResourceFile);
+ Method doConfigure =
+ joranConfiguratoroObj.getClass().getMethod("doConfigure", URL.class);
+ doConfigure.invoke(joranConfiguratoroObj, url);
+ } else {
+ Method doConfigure =
+ joranConfiguratoroObj.getClass().getMethod("doConfigure", String.class);
+ doConfigure.invoke(joranConfiguratoroObj, logConfigFilePath);
+ }
+
+ }
+ } catch (Exception e) {
+ System.err.println(e);
+ }
+ }
+ return LoggerFactory.getLogger(LoggerName.CLIENT_LOGGER_NAME);
+ }
+
+
+ public static Logger getLog() {
+ return log;
+ }
+
+
+ public static void setLog(Logger log) {
+ ClientLogger.log = log;
+ }
+}
[81/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
index 6274d96..fa2745d 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
@@ -6,68 +6,58 @@
* (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
+ * 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.
+ * 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.common.message;
import java.io.Serializable;
-
public class MessageQueue implements Comparable<MessageQueue>, Serializable {
private static final long serialVersionUID = 6191200464116433425L;
private String topic;
private String brokerName;
private int queueId;
-
public MessageQueue() {
}
-
public MessageQueue(String topic, String brokerName, int queueId) {
this.topic = topic;
this.brokerName = brokerName;
this.queueId = queueId;
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public String getBrokerName() {
return brokerName;
}
-
public void setBrokerName(String brokerName) {
this.brokerName = brokerName;
}
-
public int getQueueId() {
return queueId;
}
-
public void setQueueId(int queueId) {
this.queueId = queueId;
}
-
@Override
public int hashCode() {
final int prime = 31;
@@ -78,7 +68,6 @@ public class MessageQueue implements Comparable<MessageQueue>, Serializable {
return result;
}
-
@Override
public boolean equals(Object obj) {
if (this == obj)
@@ -87,7 +76,7 @@ public class MessageQueue implements Comparable<MessageQueue>, Serializable {
return false;
if (getClass() != obj.getClass())
return false;
- MessageQueue other = (MessageQueue) obj;
+ MessageQueue other = (MessageQueue)obj;
if (brokerName == null) {
if (other.brokerName != null)
return false;
@@ -103,13 +92,11 @@ public class MessageQueue implements Comparable<MessageQueue>, Serializable {
return true;
}
-
@Override
public String toString() {
return "MessageQueue [topic=" + topic + ", brokerName=" + brokerName + ", queueId=" + queueId + "]";
}
-
@Override
public int compareTo(MessageQueue o) {
{
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java
index 4a8fb6f..f5c43c9 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java
@@ -6,20 +6,19 @@
* (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
+ * 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.
+ * 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.common.message;
import java.io.Serializable;
-
public class MessageQueueForC implements Comparable<MessageQueueForC>, Serializable {
private static final long serialVersionUID = 5320967846569962104L;
@@ -28,7 +27,6 @@ public class MessageQueueForC implements Comparable<MessageQueueForC>, Serializa
private int queueId;
private long offset;
-
public MessageQueueForC(String topic, String brokerName, int queueId, long offset) {
this.topic = topic;
this.brokerName = brokerName;
@@ -36,7 +34,6 @@ public class MessageQueueForC implements Comparable<MessageQueueForC>, Serializa
this.offset = offset;
}
-
@Override
public int compareTo(MessageQueueForC o) {
int result = this.topic.compareTo(o.topic);
@@ -60,7 +57,6 @@ public class MessageQueueForC implements Comparable<MessageQueueForC>, Serializa
}
}
-
@Override
public int hashCode() {
final int prime = 31;
@@ -71,7 +67,6 @@ public class MessageQueueForC implements Comparable<MessageQueueForC>, Serializa
return result;
}
-
@Override
public boolean equals(Object obj) {
if (this == obj)
@@ -80,7 +75,7 @@ public class MessageQueueForC implements Comparable<MessageQueueForC>, Serializa
return false;
if (getClass() != obj.getClass())
return false;
- MessageQueueForC other = (MessageQueueForC) obj;
+ MessageQueueForC other = (MessageQueueForC)obj;
if (brokerName == null) {
if (other.brokerName != null)
return false;
@@ -100,49 +95,40 @@ public class MessageQueueForC implements Comparable<MessageQueueForC>, Serializa
return true;
}
-
@Override
public String toString() {
return "MessageQueueForC [topic=" + topic + ", brokerName=" + brokerName + ", queueId=" + queueId
- + ", offset=" + offset + "]";
+ + ", offset=" + offset + "]";
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public String getBrokerName() {
return brokerName;
}
-
public void setBrokerName(String brokerName) {
this.brokerName = brokerName;
}
-
public int getQueueId() {
return queueId;
}
-
public void setQueueId(int queueId) {
this.queueId = queueId;
}
-
public long getOffset() {
return offset;
}
-
public void setOffset(long offset) {
this.offset = offset;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/message/MessageType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageType.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageType.java
index a1913a5..c649744 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageType.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageType.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.message;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
index fe3e8e3..d58ccf2 100644
--- a/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
+++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: NamesrvConfig.java 1839 2013-05-16 02:12:02Z vintagewang@apache.org $
*/
/**
@@ -20,14 +22,12 @@
*/
package org.apache.rocketmq.common.namesrv;
+import java.io.File;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.constant.LoggerName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-
-
/**
*
*/
@@ -53,37 +53,30 @@ public class NamesrvConfig {
return rocketmqHome;
}
-
public void setRocketmqHome(String rocketmqHome) {
this.rocketmqHome = rocketmqHome;
}
-
public String getKvConfigPath() {
return kvConfigPath;
}
-
public void setKvConfigPath(String kvConfigPath) {
this.kvConfigPath = kvConfigPath;
}
-
public String getProductEnvName() {
return productEnvName;
}
-
public void setProductEnvName(String productEnvName) {
this.productEnvName = productEnvName;
}
-
public boolean isClusterTest() {
return clusterTest;
}
-
public void setClusterTest(boolean clusterTest) {
this.clusterTest = clusterTest;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java
index 2b0a1ed..33ac4bd 100644
--- a/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java
+++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.namesrv;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java
index d74b477..f94d138 100644
--- a/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java
+++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java
@@ -6,51 +6,44 @@
* (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
+ * 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.
+ * 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.common.namesrv;
import org.apache.rocketmq.common.protocol.body.KVTable;
-
public class RegisterBrokerResult {
private String haServerAddr;
private String masterAddr;
private KVTable kvTable;
-
public String getHaServerAddr() {
return haServerAddr;
}
-
public void setHaServerAddr(String haServerAddr) {
this.haServerAddr = haServerAddr;
}
-
public String getMasterAddr() {
return masterAddr;
}
-
public void setMasterAddr(String masterAddr) {
this.masterAddr = masterAddr;
}
-
public KVTable getKvTable() {
return kvTable;
}
-
public void setKvTable(KVTable kvTable) {
this.kvTable = kvTable;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
index 15a2f13..4f0dfce 100644
--- a/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
+++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: TopAddressing.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
@@ -20,6 +22,7 @@
*/
package org.apache.rocketmq.common.namesrv;
+import java.io.IOException;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.constant.LoggerName;
@@ -28,26 +31,36 @@ import org.apache.rocketmq.common.utils.HttpTinyClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-
-
public class TopAddressing {
private static final Logger log = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
private String nsAddr;
private String wsAddr;
private String unitName;
-
public TopAddressing(final String wsAddr) {
this(wsAddr, null);
}
-
public TopAddressing(final String wsAddr, final String unitName) {
this.wsAddr = wsAddr;
this.unitName = unitName;
}
+ private static String clearNewLine(final String str) {
+ String newString = str.trim();
+ int index = newString.indexOf("\r");
+ if (index != -1) {
+ return newString.substring(0, index);
+ }
+
+ index = newString.indexOf("\n");
+ if (index != -1) {
+ return newString.substring(0, index);
+ }
+
+ return newString;
+ }
+
public final String fetchNSAddr() {
return fetchNSAddr(true, 3000);
}
@@ -77,7 +90,7 @@ public class TopAddressing {
if (verbose) {
String errorMsg =
- "connect to " + url + " failed, maybe the domain name " + MixAll.WS_DOMAIN_NAME + " not bind in /etc/hosts";
+ "connect to " + url + " failed, maybe the domain name " + MixAll.WS_DOMAIN_NAME + " not bind in /etc/hosts";
errorMsg += FAQUrl.suggestTodo(FAQUrl.NAME_SERVER_ADDR_NOT_EXIST_URL);
log.warn(errorMsg);
@@ -85,26 +98,10 @@ public class TopAddressing {
return null;
}
- private static String clearNewLine(final String str) {
- String newString = str.trim();
- int index = newString.indexOf("\r");
- if (index != -1) {
- return newString.substring(0, index);
- }
-
- index = newString.indexOf("\n");
- if (index != -1) {
- return newString.substring(0, index);
- }
-
- return newString;
- }
-
public String getNsAddr() {
return nsAddr;
}
-
public void setNsAddr(String nsAddr) {
this.nsAddr = nsAddr;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java b/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java
index 0ea12eb..bbe80f0 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol;
@@ -24,15 +24,14 @@ import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-
public class MQProtosHelper {
public static boolean registerBrokerToNameServer(final String nsaddr, final String brokerAddr,
- final long timeoutMillis) {
+ final long timeoutMillis) {
RegisterBrokerRequestHeader requestHeader = new RegisterBrokerRequestHeader();
requestHeader.setBrokerAddr(brokerAddr);
RemotingCommand request =
- RemotingCommand.createRequestCommand(RequestCode.REGISTER_BROKER, requestHeader);
+ RemotingCommand.createRequestCommand(RequestCode.REGISTER_BROKER, requestHeader);
try {
RemotingCommand response = RemotingHelper.invokeSync(nsaddr, request, timeoutMillis);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/RequestCode.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/RequestCode.java b/common/src/main/java/org/apache/rocketmq/common/protocol/RequestCode.java
index d878726..217dba5 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/RequestCode.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/RequestCode.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol;
@@ -87,7 +87,6 @@ public class RequestCode {
public static final int GET_PRODUCER_CONNECTION_LIST = 204;
public static final int WIPE_WRITE_PERM_OF_BROKER = 205;
-
public static final int GET_ALL_TOPIC_LIST_FROM_NAMESERVER = 206;
public static final int DELETE_SUBSCRIPTIONGROUP = 207;
@@ -103,13 +102,11 @@ public class RequestCode {
public static final int WHO_CONSUME_THE_MESSAGE = 214;
-
public static final int DELETE_TOPIC_IN_BROKER = 215;
public static final int DELETE_TOPIC_IN_NAMESRV = 216;
public static final int GET_KVLIST_BY_NAMESPACE = 219;
-
public static final int RESET_CONSUMER_CLIENT_OFFSET = 220;
public static final int GET_CONSUMER_STATUS_FROM_CLIENT = 221;
@@ -118,7 +115,6 @@ public class RequestCode {
public static final int INVOKE_BROKER_TO_GET_CONSUMER_STATUS = 223;
-
public static final int QUERY_TOPIC_CONSUME_BY_WHO = 300;
public static final int GET_TOPICS_BY_CLUSTER = 224;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/ResponseCode.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/ResponseCode.java b/common/src/main/java/org/apache/rocketmq/common/protocol/ResponseCode.java
index a5b4e2e..11ed9c3 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/ResponseCode.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/ResponseCode.java
@@ -6,20 +6,19 @@
* (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
+ * 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.
+ * 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.common.protocol;
import org.apache.rocketmq.remoting.protocol.RemotingSysResponseCode;
-
public class ResponseCode extends RemotingSysResponseCode {
public static final int FLUSH_DISK_TIMEOUT = 10;
@@ -63,15 +62,11 @@ public class ResponseCode extends RemotingSysResponseCode {
public static final int TRANSACTION_STATE_GROUP_WRONG = 203;
public static final int NO_BUYER_ID = 204;
-
public static final int NOT_IN_CURRENT_UNIT = 205;
-
public static final int CONSUMER_NOT_ONLINE = 206;
-
public static final int CONSUME_MSG_TIMEOUT = 207;
-
public static final int NO_MESSAGE = 208;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/BrokerStatsData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/BrokerStatsData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/BrokerStatsData.java
index f1ac124..4aa3279 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/BrokerStatsData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/BrokerStatsData.java
@@ -6,20 +6,19 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
public class BrokerStatsData extends RemotingSerializable {
private BrokerStatsItem statsMinute;
@@ -28,32 +27,26 @@ public class BrokerStatsData extends RemotingSerializable {
private BrokerStatsItem statsDay;
-
public BrokerStatsItem getStatsMinute() {
return statsMinute;
}
-
public void setStatsMinute(BrokerStatsItem statsMinute) {
this.statsMinute = statsMinute;
}
-
public BrokerStatsItem getStatsHour() {
return statsHour;
}
-
public void setStatsHour(BrokerStatsItem statsHour) {
this.statsHour = statsHour;
}
-
public BrokerStatsItem getStatsDay() {
return statsDay;
}
-
public void setStatsDay(BrokerStatsItem statsDay) {
this.statsDay = statsDay;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/BrokerStatsItem.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/BrokerStatsItem.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/BrokerStatsItem.java
index 904770f..e789e0a 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/BrokerStatsItem.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/BrokerStatsItem.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
@@ -22,32 +22,26 @@ public class BrokerStatsItem {
private double tps;
private double avgpt;
-
public long getSum() {
return sum;
}
-
public void setSum(long sum) {
this.sum = sum;
}
-
public double getTps() {
return tps;
}
-
public void setTps(double tps) {
this.tps = tps;
}
-
public double getAvgpt() {
return avgpt;
}
-
public void setAvgpt(double avgpt) {
this.avgpt = avgpt;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/CMResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/CMResult.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/CMResult.java
index 85eda7b..7dee8fb 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/CMResult.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/CMResult.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java
index a88616f..dfb045d 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java
@@ -6,51 +6,44 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
-import org.apache.rocketmq.common.protocol.route.BrokerData;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
-
+import org.apache.rocketmq.common.protocol.route.BrokerData;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
public class ClusterInfo extends RemotingSerializable {
private HashMap<String/* brokerName */, BrokerData> brokerAddrTable;
private HashMap<String/* clusterName */, Set<String/* brokerName */>> clusterAddrTable;
-
public HashMap<String, BrokerData> getBrokerAddrTable() {
return brokerAddrTable;
}
-
public void setBrokerAddrTable(HashMap<String, BrokerData> brokerAddrTable) {
this.brokerAddrTable = brokerAddrTable;
}
-
public HashMap<String, Set<String>> getClusterAddrTable() {
return clusterAddrTable;
}
-
public void setClusterAddrTable(HashMap<String, Set<String>> clusterAddrTable) {
this.clusterAddrTable = clusterAddrTable;
}
-
public String[] retrieveAllAddrByCluster(String cluster) {
List<String> addrs = new ArrayList<String>();
if (clusterAddrTable.containsKey(cluster)) {
@@ -63,11 +56,10 @@ public class ClusterInfo extends RemotingSerializable {
}
}
- return addrs.toArray(new String[]{});
+ return addrs.toArray(new String[] {});
}
-
public String[] retrieveAllClusterNames() {
- return clusterAddrTable.keySet().toArray(new String[]{});
+ return clusterAddrTable.keySet().toArray(new String[] {});
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java
index 76f0921..c9da104 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java
@@ -6,62 +6,53 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
import org.apache.rocketmq.remoting.protocol.LanguageCode;
-
public class Connection {
private String clientId;
private String clientAddr;
private LanguageCode language;
private int version;
-
public String getClientId() {
return clientId;
}
-
public void setClientId(String clientId) {
this.clientId = clientId;
}
-
public String getClientAddr() {
return clientAddr;
}
-
public void setClientAddr(String clientAddr) {
this.clientAddr = clientAddr;
}
-
public LanguageCode getLanguage() {
return language;
}
-
public void setLanguage(LanguageCode language) {
this.language = language;
}
-
public int getVersion() {
return version;
}
-
public void setVersion(int version) {
this.version = version;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java
index 8342144..8eb62a1 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java
@@ -6,20 +6,18 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.HashSet;
-
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
/**
*
@@ -31,52 +29,42 @@ public class ConsumeByWho extends RemotingSerializable {
private int queueId;
private long offset;
-
public HashSet<String> getConsumedGroup() {
return consumedGroup;
}
-
public void setConsumedGroup(HashSet<String> consumedGroup) {
this.consumedGroup = consumedGroup;
}
-
public HashSet<String> getNotConsumedGroup() {
return notConsumedGroup;
}
-
public void setNotConsumedGroup(HashSet<String> notConsumedGroup) {
this.notConsumedGroup = notConsumedGroup;
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public int getQueueId() {
return queueId;
}
-
public void setQueueId(int queueId) {
this.queueId = queueId;
}
-
public long getOffset() {
return offset;
}
-
public void setOffset(long offset) {
this.offset = offset;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeMessageDirectlyResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeMessageDirectlyResult.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeMessageDirectlyResult.java
index 9c63010..2020659 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeMessageDirectlyResult.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeMessageDirectlyResult.java
@@ -6,20 +6,19 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
public class ConsumeMessageDirectlyResult extends RemotingSerializable {
private boolean order = false;
private boolean autoCommit = true;
@@ -27,61 +26,50 @@ public class ConsumeMessageDirectlyResult extends RemotingSerializable {
private String remark;
private long spentTimeMills;
-
public boolean isOrder() {
return order;
}
-
public void setOrder(boolean order) {
this.order = order;
}
-
public boolean isAutoCommit() {
return autoCommit;
}
-
public void setAutoCommit(boolean autoCommit) {
this.autoCommit = autoCommit;
}
-
public String getRemark() {
return remark;
}
-
public void setRemark(String remark) {
this.remark = remark;
}
-
public CMResult getConsumeResult() {
return consumeResult;
}
-
public void setConsumeResult(CMResult consumeResult) {
this.consumeResult = consumeResult;
}
-
public long getSpentTimeMills() {
return spentTimeMills;
}
-
public void setSpentTimeMills(long spentTimeMills) {
this.spentTimeMills = spentTimeMills;
}
-
@Override
public String toString() {
return "ConsumeMessageDirectlyResult [order=" + order + ", autoCommit=" + autoCommit
- + ", consumeResult=" + consumeResult + ", remark=" + remark + ", spentTimeMills="
- + spentTimeMills + "]";
+ + ", consumeResult=" + consumeResult + ", remark=" + remark + ", spentTimeMills="
+ + spentTimeMills + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java
index c907555..07dc3e4 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java
@@ -6,23 +6,21 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
-import org.apache.rocketmq.common.admin.ConsumeStats;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-
+import org.apache.rocketmq.common.admin.ConsumeStats;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
public class ConsumeStatsList extends RemotingSerializable {
private List<Map<String/*subscriptionGroupName*/, List<ConsumeStats>>> consumeStatsList = new ArrayList<Map<String/*subscriptionGroupName*/, List<ConsumeStats>>>();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatus.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatus.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatus.java
index 35b6a02..a227645 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatus.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatus.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
@@ -26,62 +26,50 @@ public class ConsumeStatus {
private long consumeFailedMsgs;
-
public double getPullRT() {
return pullRT;
}
-
public void setPullRT(double pullRT) {
this.pullRT = pullRT;
}
-
public double getPullTPS() {
return pullTPS;
}
-
public void setPullTPS(double pullTPS) {
this.pullTPS = pullTPS;
}
-
public double getConsumeRT() {
return consumeRT;
}
-
public void setConsumeRT(double consumeRT) {
this.consumeRT = consumeRT;
}
-
public double getConsumeOKTPS() {
return consumeOKTPS;
}
-
public void setConsumeOKTPS(double consumeOKTPS) {
this.consumeOKTPS = consumeOKTPS;
}
-
public double getConsumeFailedTPS() {
return consumeFailedTPS;
}
-
public void setConsumeFailedTPS(double consumeFailedTPS) {
this.consumeFailedTPS = consumeFailedTPS;
}
-
public long getConsumeFailedMsgs() {
return consumeFailedMsgs;
}
-
public void setConsumeFailedMsgs(long consumeFailedMsgs) {
this.consumeFailedMsgs = consumeFailedMsgs;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java
index bc2acad..1de12e1 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java
@@ -6,36 +6,33 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
+import java.util.HashSet;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-import java.util.HashSet;
-import java.util.concurrent.ConcurrentHashMap;
-
-
public class ConsumerConnection extends RemotingSerializable {
private HashSet<Connection> connectionSet = new HashSet<Connection>();
private ConcurrentHashMap<String/* Topic */, SubscriptionData> subscriptionTable =
- new ConcurrentHashMap<String, SubscriptionData>();
+ new ConcurrentHashMap<String, SubscriptionData>();
private ConsumeType consumeType;
private MessageModel messageModel;
private ConsumeFromWhere consumeFromWhere;
-
public int computeMinVersion() {
int minVersion = Integer.MAX_VALUE;
for (Connection c : this.connectionSet) {
@@ -47,52 +44,42 @@ public class ConsumerConnection extends RemotingSerializable {
return minVersion;
}
-
public HashSet<Connection> getConnectionSet() {
return connectionSet;
}
-
public void setConnectionSet(HashSet<Connection> connectionSet) {
this.connectionSet = connectionSet;
}
-
public ConcurrentHashMap<String, SubscriptionData> getSubscriptionTable() {
return subscriptionTable;
}
-
public void setSubscriptionTable(ConcurrentHashMap<String, SubscriptionData> subscriptionTable) {
this.subscriptionTable = subscriptionTable;
}
-
public ConsumeType getConsumeType() {
return consumeType;
}
-
public void setConsumeType(ConsumeType consumeType) {
this.consumeType = consumeType;
}
-
public MessageModel getMessageModel() {
return messageModel;
}
-
public void setMessageModel(MessageModel messageModel) {
this.messageModel = messageModel;
}
-
public ConsumeFromWhere getConsumeFromWhere() {
return consumeFromWhere;
}
-
public void setConsumeFromWhere(ConsumeFromWhere consumeFromWhere) {
this.consumeFromWhere = consumeFromWhere;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerOffsetSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerOffsetSerializeWrapper.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerOffsetSerializeWrapper.java
index 1ce7cf4..520a99b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerOffsetSerializeWrapper.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerOffsetSerializeWrapper.java
@@ -6,32 +6,28 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.concurrent.ConcurrentHashMap;
-
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
public class ConsumerOffsetSerializeWrapper extends RemotingSerializable {
private ConcurrentHashMap<String/* topic@group */, ConcurrentHashMap<Integer, Long>> offsetTable =
- new ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>>(512);
-
+ new ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>>(512);
public ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>> getOffsetTable() {
return offsetTable;
}
-
public void setOffsetTable(ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>> offsetTable) {
this.offsetTable = offsetTable;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerRunningInfo.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerRunningInfo.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerRunningInfo.java
index 9b0b383..9836b8d 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerRunningInfo.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerRunningInfo.java
@@ -17,14 +17,16 @@
package org.apache.rocketmq.common.protocol.body;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.TreeMap;
+import java.util.TreeSet;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-import java.util.*;
-import java.util.Map.Entry;
-
public class ConsumerRunningInfo extends RemotingSerializable {
public static final String PROP_NAMESERVER_ADDR = "PROP_NAMESERVER_ADDR";
public static final String PROP_THREADPOOL_CORE_SIZE = "PROP_THREADPOOL_CORE_SIZE";
@@ -33,7 +35,6 @@ public class ConsumerRunningInfo extends RemotingSerializable {
public static final String PROP_CLIENT_VERSION = "PROP_CLIENT_VERSION";
public static final String PROP_CONSUMER_START_TIMESTAMP = "PROP_CONSUMER_START_TIMESTAMP";
-
private Properties properties = new Properties();
private TreeSet<SubscriptionData> subscriptionSet = new TreeSet<SubscriptionData>();
@@ -52,7 +53,7 @@ public class ConsumerRunningInfo extends RemotingSerializable {
String property = prev.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUME_TYPE);
if (property == null) {
- property = ((ConsumeType) prev.getProperties().get(ConsumerRunningInfo.PROP_CONSUME_TYPE)).name();
+ property = ((ConsumeType)prev.getProperties().get(ConsumerRunningInfo.PROP_CONSUME_TYPE)).name();
}
push = ConsumeType.valueOf(property) == ConsumeType.CONSUME_PASSIVELY;
}
@@ -97,22 +98,6 @@ public class ConsumerRunningInfo extends RemotingSerializable {
return true;
}
- public Properties getProperties() {
- return properties;
- }
-
- public void setProperties(Properties properties) {
- this.properties = properties;
- }
-
- public TreeSet<SubscriptionData> getSubscriptionSet() {
- return subscriptionSet;
- }
-
- public void setSubscriptionSet(TreeSet<SubscriptionData> subscriptionSet) {
- this.subscriptionSet = subscriptionSet;
- }
-
public static boolean analyzeRebalance(final TreeMap<String/* clientId */, ConsumerRunningInfo> criTable) {
return true;
}
@@ -124,7 +109,7 @@ public class ConsumerRunningInfo extends RemotingSerializable {
String property = info.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUME_TYPE);
if (property == null) {
- property = ((ConsumeType) info.getProperties().get(ConsumerRunningInfo.PROP_CONSUME_TYPE)).name();
+ property = ((ConsumeType)info.getProperties().get(ConsumerRunningInfo.PROP_CONSUME_TYPE)).name();
}
push = ConsumeType.valueOf(property) == ConsumeType.CONSUME_PASSIVELY;
}
@@ -142,32 +127,30 @@ public class ConsumerRunningInfo extends RemotingSerializable {
MessageQueue mq = next.getKey();
ProcessQueueInfo pq = next.getValue();
-
if (orderMsg) {
if (!pq.isLocked()) {
sb.append(String.format("%s %s can't lock for a while, %dms%n", //
- clientId, //
- mq, //
- System.currentTimeMillis() - pq.getLastLockTimestamp()));
+ clientId, //
+ mq, //
+ System.currentTimeMillis() - pq.getLastLockTimestamp()));
} else {
if (pq.isDroped() && (pq.getTryUnlockTimes() > 0)) {
sb.append(String.format("%s %s unlock %d times, still failed%n", //
- clientId, //
- mq, //
- pq.getTryUnlockTimes()));
+ clientId, //
+ mq, //
+ pq.getTryUnlockTimes()));
}
}
-
} else {
long diff = System.currentTimeMillis() - pq.getLastConsumeTimestamp();
if (diff > (1000 * 60) && pq.getCachedMsgCount() > 0) {
sb.append(String.format("%s %s can't consume for a while, maybe blocked, %dms%n", //
- clientId, //
- mq, //
- diff));
+ clientId, //
+ mq, //
+ diff));
}
}
}
@@ -176,6 +159,22 @@ public class ConsumerRunningInfo extends RemotingSerializable {
return sb.toString();
}
+ public Properties getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Properties properties) {
+ this.properties = properties;
+ }
+
+ public TreeSet<SubscriptionData> getSubscriptionSet() {
+ return subscriptionSet;
+ }
+
+ public void setSubscriptionSet(TreeSet<SubscriptionData> subscriptionSet) {
+ this.subscriptionSet = subscriptionSet;
+ }
+
public TreeMap<MessageQueue, ProcessQueueInfo> getMqTable() {
return mqTable;
}
@@ -213,10 +212,10 @@ public class ConsumerRunningInfo extends RemotingSerializable {
while (it.hasNext()) {
SubscriptionData next = it.next();
String item = String.format("%03d Topic: %-40s ClassFilter: %-8s SubExpression: %s%n", //
- ++i, //
- next.getTopic(), //
- next.isClassFilterMode(), //
- next.getSubString());
+ ++i, //
+ next.getTopic(), //
+ next.isClassFilterMode(), //
+ next.getSubString());
sb.append(item);
}
@@ -225,20 +224,20 @@ public class ConsumerRunningInfo extends RemotingSerializable {
{
sb.append("\n\n#Consumer Offset#\n");
sb.append(String.format("%-32s %-32s %-4s %-20s%n", //
- "#Topic", //
- "#Broker Name", //
- "#QID", //
- "#Consumer Offset"//
+ "#Topic", //
+ "#Broker Name", //
+ "#QID", //
+ "#Consumer Offset"//
));
Iterator<Entry<MessageQueue, ProcessQueueInfo>> it = this.mqTable.entrySet().iterator();
while (it.hasNext()) {
Entry<MessageQueue, ProcessQueueInfo> next = it.next();
String item = String.format("%-32s %-32s %-4d %-20d%n", //
- next.getKey().getTopic(), //
- next.getKey().getBrokerName(), //
- next.getKey().getQueueId(), //
- next.getValue().getCommitOffset());
+ next.getKey().getTopic(), //
+ next.getKey().getBrokerName(), //
+ next.getKey().getQueueId(), //
+ next.getValue().getCommitOffset());
sb.append(item);
}
@@ -247,20 +246,20 @@ public class ConsumerRunningInfo extends RemotingSerializable {
{
sb.append("\n\n#Consumer MQ Detail#\n");
sb.append(String.format("%-32s %-32s %-4s %-20s%n", //
- "#Topic", //
- "#Broker Name", //
- "#QID", //
- "#ProcessQueueInfo"//
+ "#Topic", //
+ "#Broker Name", //
+ "#QID", //
+ "#ProcessQueueInfo"//
));
Iterator<Entry<MessageQueue, ProcessQueueInfo>> it = this.mqTable.entrySet().iterator();
while (it.hasNext()) {
Entry<MessageQueue, ProcessQueueInfo> next = it.next();
String item = String.format("%-32s %-32s %-4d %s%n", //
- next.getKey().getTopic(), //
- next.getKey().getBrokerName(), //
- next.getKey().getQueueId(), //
- next.getValue().toString());
+ next.getKey().getTopic(), //
+ next.getKey().getBrokerName(), //
+ next.getKey().getQueueId(), //
+ next.getValue().toString());
sb.append(item);
}
@@ -269,26 +268,26 @@ public class ConsumerRunningInfo extends RemotingSerializable {
{
sb.append("\n\n#Consumer RT&TPS#\n");
sb.append(String.format("%-32s %14s %14s %14s %14s %18s %25s%n", //
- "#Topic", //
- "#Pull RT", //
- "#Pull TPS", //
- "#Consume RT", //
- "#ConsumeOK TPS", //
- "#ConsumeFailed TPS", //
- "#ConsumeFailedMsgsInHour"//
+ "#Topic", //
+ "#Pull RT", //
+ "#Pull TPS", //
+ "#Consume RT", //
+ "#ConsumeOK TPS", //
+ "#ConsumeFailed TPS", //
+ "#ConsumeFailedMsgsInHour"//
));
Iterator<Entry<String, ConsumeStatus>> it = this.statusTable.entrySet().iterator();
while (it.hasNext()) {
Entry<String, ConsumeStatus> next = it.next();
String item = String.format("%-32s %14.2f %14.2f %14.2f %14.2f %18.2f %25d%n", //
- next.getKey(), //
- next.getValue().getPullRT(), //
- next.getValue().getPullTPS(), //
- next.getValue().getConsumeRT(), //
- next.getValue().getConsumeOKTPS(), //
- next.getValue().getConsumeFailedTPS(), //
- next.getValue().getConsumeFailedMsgs()//
+ next.getKey(), //
+ next.getValue().getPullRT(), //
+ next.getValue().getPullTPS(), //
+ next.getValue().getConsumeRT(), //
+ next.getValue().getConsumeOKTPS(), //
+ next.getValue().getConsumeFailedTPS(), //
+ next.getValue().getConsumeFailedMsgs()//
);
sb.append(item);
@@ -307,7 +306,6 @@ public class ConsumerRunningInfo extends RemotingSerializable {
return jstack;
}
-
public void setJstack(String jstack) {
this.jstack = jstack;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/GetConsumerStatusBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/GetConsumerStatusBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/GetConsumerStatusBody.java
index d37116c..1bbd631 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/GetConsumerStatusBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/GetConsumerStatusBody.java
@@ -6,46 +6,40 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
-import org.apache.rocketmq.common.message.MessageQueue;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.HashMap;
import java.util.Map;
-
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
@Deprecated
public class GetConsumerStatusBody extends RemotingSerializable {
private Map<MessageQueue, Long> messageQueueTable = new HashMap<MessageQueue, Long>();
private Map<String, Map<MessageQueue, Long>> consumerTable =
- new HashMap<String, Map<MessageQueue, Long>>();
-
+ new HashMap<String, Map<MessageQueue, Long>>();
public Map<MessageQueue, Long> getMessageQueueTable() {
return messageQueueTable;
}
-
public void setMessageQueueTable(Map<MessageQueue, Long> messageQueueTable) {
this.messageQueueTable = messageQueueTable;
}
-
public Map<String, Map<MessageQueue, Long>> getConsumerTable() {
return consumerTable;
}
-
public void setConsumerTable(Map<String, Map<MessageQueue, Long>> consumerTable) {
this.consumerTable = consumerTable;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java
index e67dd8c..9f4918b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java
@@ -6,20 +6,18 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.HashSet;
-
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
/**
*
@@ -27,12 +25,10 @@ import java.util.HashSet;
public class GroupList extends RemotingSerializable {
private HashSet<String> groupList = new HashSet<String>();
-
public HashSet<String> getGroupList() {
return groupList;
}
-
public void setGroupList(HashSet<String> groupList) {
this.groupList = groupList;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java
index 18b20a2..7904f76 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java
@@ -6,20 +6,18 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.HashMap;
-
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
/**
*
@@ -27,12 +25,10 @@ import java.util.HashMap;
public class KVTable extends RemotingSerializable {
private HashMap<String, String> table = new HashMap<String, String>();
-
public HashMap<String, String> getTable() {
return table;
}
-
public void setTable(HashMap<String, String> table) {
this.table = table;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java
index 59768ff..97fac5a 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java
@@ -6,23 +6,21 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
-import org.apache.rocketmq.common.message.MessageQueue;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.HashSet;
import java.util.Set;
-
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
/**
*
@@ -32,32 +30,26 @@ public class LockBatchRequestBody extends RemotingSerializable {
private String clientId;
private Set<MessageQueue> mqSet = new HashSet<MessageQueue>();
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public String getClientId() {
return clientId;
}
-
public void setClientId(String clientId) {
this.clientId = clientId;
}
-
public Set<MessageQueue> getMqSet() {
return mqSet;
}
-
public void setMqSet(Set<MessageQueue> mqSet) {
this.mqSet = mqSet;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java
index e1a5117..5108438 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java
@@ -6,23 +6,21 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
-import org.apache.rocketmq.common.message.MessageQueue;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.HashSet;
import java.util.Set;
-
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
/**
*
@@ -31,12 +29,10 @@ public class LockBatchResponseBody extends RemotingSerializable {
private Set<MessageQueue> lockOKMQSet = new HashSet<MessageQueue>();
-
public Set<MessageQueue> getLockOKMQSet() {
return lockOKMQSet;
}
-
public void setLockOKMQSet(Set<MessageQueue> lockOKMQSet) {
this.lockOKMQSet = lockOKMQSet;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProcessQueueInfo.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProcessQueueInfo.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProcessQueueInfo.java
index 0ceaa69..65703f3 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProcessQueueInfo.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProcessQueueInfo.java
@@ -6,20 +6,19 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
import org.apache.rocketmq.common.UtilAll;
-
public class ProcessQueueInfo {
private long commitOffset;
@@ -39,147 +38,120 @@ public class ProcessQueueInfo {
private long lastPullTimestamp;
private long lastConsumeTimestamp;
-
public long getCommitOffset() {
return commitOffset;
}
-
public void setCommitOffset(long commitOffset) {
this.commitOffset = commitOffset;
}
-
public long getCachedMsgMinOffset() {
return cachedMsgMinOffset;
}
-
public void setCachedMsgMinOffset(long cachedMsgMinOffset) {
this.cachedMsgMinOffset = cachedMsgMinOffset;
}
-
public long getCachedMsgMaxOffset() {
return cachedMsgMaxOffset;
}
-
public void setCachedMsgMaxOffset(long cachedMsgMaxOffset) {
this.cachedMsgMaxOffset = cachedMsgMaxOffset;
}
-
public int getCachedMsgCount() {
return cachedMsgCount;
}
-
public void setCachedMsgCount(int cachedMsgCount) {
this.cachedMsgCount = cachedMsgCount;
}
-
public long getTransactionMsgMinOffset() {
return transactionMsgMinOffset;
}
-
public void setTransactionMsgMinOffset(long transactionMsgMinOffset) {
this.transactionMsgMinOffset = transactionMsgMinOffset;
}
-
public long getTransactionMsgMaxOffset() {
return transactionMsgMaxOffset;
}
-
public void setTransactionMsgMaxOffset(long transactionMsgMaxOffset) {
this.transactionMsgMaxOffset = transactionMsgMaxOffset;
}
-
public int getTransactionMsgCount() {
return transactionMsgCount;
}
-
public void setTransactionMsgCount(int transactionMsgCount) {
this.transactionMsgCount = transactionMsgCount;
}
-
public boolean isLocked() {
return locked;
}
-
public void setLocked(boolean locked) {
this.locked = locked;
}
-
public long getTryUnlockTimes() {
return tryUnlockTimes;
}
-
public void setTryUnlockTimes(long tryUnlockTimes) {
this.tryUnlockTimes = tryUnlockTimes;
}
-
public long getLastLockTimestamp() {
return lastLockTimestamp;
}
-
public void setLastLockTimestamp(long lastLockTimestamp) {
this.lastLockTimestamp = lastLockTimestamp;
}
-
public boolean isDroped() {
return droped;
}
-
public void setDroped(boolean droped) {
this.droped = droped;
}
-
public long getLastPullTimestamp() {
return lastPullTimestamp;
}
-
public void setLastPullTimestamp(long lastPullTimestamp) {
this.lastPullTimestamp = lastPullTimestamp;
}
-
public long getLastConsumeTimestamp() {
return lastConsumeTimestamp;
}
-
public void setLastConsumeTimestamp(long lastConsumeTimestamp) {
this.lastConsumeTimestamp = lastConsumeTimestamp;
}
-
@Override
public String toString() {
return "ProcessQueueInfo [commitOffset=" + commitOffset + ", cachedMsgMinOffset="
- + cachedMsgMinOffset + ", cachedMsgMaxOffset=" + cachedMsgMaxOffset + ", cachedMsgCount="
- + cachedMsgCount + ", transactionMsgMinOffset=" + transactionMsgMinOffset
- + ", transactionMsgMaxOffset=" + transactionMsgMaxOffset + ", transactionMsgCount="
- + transactionMsgCount + ", locked=" + locked + ", tryUnlockTimes=" + tryUnlockTimes
- + ", lastLockTimestamp=" + UtilAll.timeMillisToHumanString(lastLockTimestamp) + ", droped="
- + droped + ", lastPullTimestamp=" + UtilAll.timeMillisToHumanString(lastPullTimestamp)
- + ", lastConsumeTimestamp=" + UtilAll.timeMillisToHumanString(lastConsumeTimestamp) + "]";
+ + cachedMsgMinOffset + ", cachedMsgMaxOffset=" + cachedMsgMaxOffset + ", cachedMsgCount="
+ + cachedMsgCount + ", transactionMsgMinOffset=" + transactionMsgMinOffset
+ + ", transactionMsgMaxOffset=" + transactionMsgMaxOffset + ", transactionMsgCount="
+ + transactionMsgCount + ", locked=" + locked + ", tryUnlockTimes=" + tryUnlockTimes
+ + ", lastLockTimestamp=" + UtilAll.timeMillisToHumanString(lastLockTimestamp) + ", droped="
+ + droped + ", lastPullTimestamp=" + UtilAll.timeMillisToHumanString(lastPullTimestamp)
+ + ", lastConsumeTimestamp=" + UtilAll.timeMillisToHumanString(lastConsumeTimestamp) + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java
index 99ac6ba..bc04337 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java
@@ -6,31 +6,27 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.HashSet;
-
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
public class ProducerConnection extends RemotingSerializable {
private HashSet<Connection> connectionSet = new HashSet<Connection>();
-
public HashSet<Connection> getConnectionSet() {
return connectionSet;
}
-
public void setConnectionSet(HashSet<Connection> connectionSet) {
this.connectionSet = connectionSet;
}
[99/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Remove
empty class doc.
Posted by yu...@apache.org.
ROCKETMQ-18 Remove empty class doc.
Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/commit/2eae25c6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/tree/2eae25c6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/diff/2eae25c6
Branch: refs/heads/master
Commit: 2eae25c6aaa7aaa4ed0ec38ecb656744f51ca5a1
Parents: 853b167
Author: yukon <yu...@apache.org>
Authored: Wed Dec 28 17:09:13 2016 +0800
Committer: yukon <yu...@apache.org>
Committed: Wed Dec 28 17:09:13 2016 +0800
----------------------------------------------------------------------
.../main/java/org/apache/rocketmq/common/admin/ConsumeStats.java | 4 ----
.../java/org/apache/rocketmq/common/admin/OffsetWrapper.java | 4 ----
.../main/java/org/apache/rocketmq/common/admin/TopicOffset.java | 4 ----
.../java/org/apache/rocketmq/common/admin/TopicStatsTable.java | 4 ----
.../java/org/apache/rocketmq/common/hook/FilterCheckHook.java | 4 ----
.../main/java/org/apache/rocketmq/common/message/Message.java | 4 ----
.../protocol/header/GetConsumerConnectionListRequestHeader.java | 4 ----
.../common/protocol/header/QueryCorrectionOffsetHeader.java | 4 ----
.../common/protocol/header/ResetOffsetRequestHeader.java | 4 ----
.../src/main/java/org/apache/rocketmq/store/index/IndexFile.java | 4 +---
.../rocketmq/tools/command/message/QueryMsgByKeySubCommand.java | 4 ----
.../rocketmq/tools/command/namesrv/DeleteKvConfigCommand.java | 4 ----
.../rocketmq/tools/command/namesrv/UpdateKvConfigCommand.java | 4 ----
.../tools/command/offset/ResetOffsetByTimeOldCommand.java | 4 ----
.../rocketmq/tools/command/topic/DeleteTopicSubCommand.java | 4 ----
.../rocketmq/tools/command/topic/TopicClusterSubCommand.java | 4 ----
.../apache/rocketmq/tools/command/topic/TopicListSubCommand.java | 4 ----
.../rocketmq/tools/command/topic/TopicRouteSubCommand.java | 4 ----
.../rocketmq/tools/command/topic/TopicStatusSubCommand.java | 4 ----
.../rocketmq/tools/command/topic/UpdateOrderConfCommand.java | 4 ----
20 files changed, 1 insertion(+), 79 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java b/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
index 1fc8897..f3fd11c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
@@ -22,10 +22,6 @@ import java.util.Map.Entry;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-/**
- *
- *
- */
public class ConsumeStats extends RemotingSerializable {
private HashMap<MessageQueue, OffsetWrapper> offsetTable = new HashMap<MessageQueue, OffsetWrapper>();
private double consumeTps = 0;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java b/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
index a5697ec..f255d30 100644
--- a/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
@@ -16,10 +16,6 @@
*/
package org.apache.rocketmq.common.admin;
-/**
- *
- *
- */
public class OffsetWrapper {
private long brokerOffset;
private long consumerOffset;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java b/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
index 8147d63..d0af7d5 100644
--- a/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
@@ -16,10 +16,6 @@
*/
package org.apache.rocketmq.common.admin;
-/**
- *
- *
- */
public class TopicOffset {
private long minOffset;
private long maxOffset;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java b/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
index 01f4557..d9ca9e4 100644
--- a/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
@@ -20,10 +20,6 @@ import java.util.HashMap;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-/**
- *
- *
- */
public class TopicStatsTable extends RemotingSerializable {
private HashMap<MessageQueue, TopicOffset> offsetTable = new HashMap<MessageQueue, TopicOffset>();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java b/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java
index a0a7925..5f70120 100644
--- a/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java
+++ b/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java
@@ -19,10 +19,6 @@ package org.apache.rocketmq.common.hook;
import java.nio.ByteBuffer;
-/**
- *
- *
- */
public interface FilterCheckHook {
public String hookName();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/common/src/main/java/org/apache/rocketmq/common/message/Message.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/Message.java b/common/src/main/java/org/apache/rocketmq/common/message/Message.java
index 00cb6d1..a35774f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/Message.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/Message.java
@@ -21,10 +21,6 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-/**
- *
- *
- */
public class Message implements Serializable {
private static final long serialVersionUID = 8445773977080406428L;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
index 8f12c79..6c6f368 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
@@ -21,10 +21,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- *
- *
- */
public class GetConsumerConnectionListRequestHeader implements CommandCustomHeader {
@CFNotNull
private String consumerGroup;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
index db5b306..4342035 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
@@ -28,10 +28,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- *
- *
- */
public class QueryCorrectionOffsetHeader implements CommandCustomHeader {
private String filterGroups;
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java
index 920760b..a8881e3 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java
@@ -21,10 +21,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- *
- *
- */
public class ResetOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java b/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
index 97f3920..9cec902 100644
--- a/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
+++ b/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
@@ -180,9 +180,7 @@ public class IndexFile {
}
public boolean isTimeMatched(final long begin, final long end) {
- boolean result =
- begin < this.indexHeader.getBeginTimestamp() && end > this.indexHeader.getEndTimestamp();
-
+ boolean result = begin < this.indexHeader.getBeginTimestamp() && end > this.indexHeader.getEndTimestamp();
result = result || (begin >= this.indexHeader.getBeginTimestamp() && begin <= this.indexHeader.getEndTimestamp());
result = result || (end >= this.indexHeader.getBeginTimestamp() && end <= this.indexHeader.getEndTimestamp());
return result;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java
index 159bd6e..a779466 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java
@@ -26,10 +26,6 @@ import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-/**
- *
- *
- */
public class QueryMsgByKeySubCommand implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/DeleteKvConfigCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/DeleteKvConfigCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/DeleteKvConfigCommand.java
index b4fb7dd..3487c50 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/DeleteKvConfigCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/DeleteKvConfigCommand.java
@@ -23,10 +23,6 @@ import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-/**
- *
- *
- */
public class DeleteKvConfigCommand implements SubCommand {
@Override
public String commandName() {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateKvConfigCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateKvConfigCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateKvConfigCommand.java
index 9d5f7a9..5c58aa3 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateKvConfigCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateKvConfigCommand.java
@@ -23,10 +23,6 @@ import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-/**
- *
- *
- */
public class UpdateKvConfigCommand implements SubCommand {
@Override
public String commandName() {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeOldCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeOldCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeOldCommand.java
index 9b30474..f7428d3 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeOldCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeOldCommand.java
@@ -31,10 +31,6 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-/**
- *
- *
- */
public class ResetOffsetByTimeOldCommand implements SubCommand {
public static void resetOffset(DefaultMQAdminExt defaultMQAdminExt, String consumerGroup, String topic, long timestamp, boolean force,
String timeStampStr) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java
index 69cbc99..95f276e 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java
@@ -31,10 +31,6 @@ import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.CommandUtil;
import org.apache.rocketmq.tools.command.SubCommand;
-/**
- *
- *
- */
public class DeleteTopicSubCommand implements SubCommand {
public static void deleteTopic(final DefaultMQAdminExt adminExt,
final String clusterName,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicClusterSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicClusterSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicClusterSubCommand.java
index 6a267a5..3e2eb20 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicClusterSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicClusterSubCommand.java
@@ -24,10 +24,6 @@ import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-/**
- *
- *
- */
public class TopicClusterSubCommand implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java
index 5e23a96..2359fe1 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java
@@ -35,10 +35,6 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-/**
- *
- *
- */
public class TopicListSubCommand implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java
index b7a180f..ca356cc 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java
@@ -24,10 +24,6 @@ import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-/**
- *
- *
- */
public class TopicRouteSubCommand implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java
index 76d9cbc..460feb3 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java
@@ -30,10 +30,6 @@ import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-/**
- *
- *
- */
public class TopicStatusSubCommand implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/2eae25c6/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateOrderConfCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateOrderConfCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateOrderConfCommand.java
index f9f4f1f..896c125 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateOrderConfCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateOrderConfCommand.java
@@ -26,10 +26,6 @@ import org.apache.rocketmq.srvutil.ServerUtil;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-/**
- *
- *
- */
public class UpdateOrderConfCommand implements SubCommand {
@Override
[86/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java
index 3cc2fdf..9fd1b34 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java
@@ -6,36 +6,32 @@
* (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
+ * 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.
+ * 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.impl;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
import org.apache.rocketmq.client.ClientConfig;
import org.apache.rocketmq.client.impl.factory.MQClientInstance;
import org.apache.rocketmq.remoting.RPCHook;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
-
public class MQClientManager {
private static MQClientManager instance = new MQClientManager();
private AtomicInteger factoryIndexGenerator = new AtomicInteger();
private ConcurrentHashMap<String/* clientId */, MQClientInstance> factoryTable =
- new ConcurrentHashMap<String, MQClientInstance>();
-
+ new ConcurrentHashMap<String, MQClientInstance>();
private MQClientManager() {
}
-
public static MQClientManager getInstance() {
return instance;
}
@@ -49,8 +45,8 @@ public class MQClientManager {
MQClientInstance instance = this.factoryTable.get(clientId);
if (null == instance) {
instance =
- new MQClientInstance(clientConfig.cloneClientConfig(),
- this.factoryIndexGenerator.getAndIncrement(), clientId, rpcHook);
+ new MQClientInstance(clientConfig.cloneClientConfig(),
+ this.factoryIndexGenerator.getAndIncrement(), clientId, rpcHook);
MQClientInstance prev = this.factoryTable.putIfAbsent(clientId, instance);
if (prev != null) {
instance = prev;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
index e02bd4f..e7a6ca3 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
@@ -16,6 +16,19 @@
*/
package org.apache.rocketmq.client.impl.consumer;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
@@ -35,10 +48,6 @@ import org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.slf4j.Logger;
-import java.util.*;
-import java.util.concurrent.*;
-
-
public class ConsumeMessageConcurrentlyService implements ConsumeMessageService {
private static final Logger log = ClientLogger.getLog();
private final DefaultMQPushConsumerImpl defaultMQPushConsumerImpl;
@@ -51,9 +60,8 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
private final ScheduledExecutorService scheduledExecutorService;
private final ScheduledExecutorService cleanExpireMsgExecutors;
-
public ConsumeMessageConcurrentlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl,
- MessageListenerConcurrently messageListener) {
+ MessageListenerConcurrently messageListener) {
this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
this.messageListener = messageListener;
@@ -62,18 +70,17 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();
this.consumeExecutor = new ThreadPoolExecutor(//
- this.defaultMQPushConsumer.getConsumeThreadMin(), //
- this.defaultMQPushConsumer.getConsumeThreadMax(), //
- 1000 * 60, //
- TimeUnit.MILLISECONDS, //
- this.consumeRequestQueue, //
- new ThreadFactoryImpl("ConsumeMessageThread_"));
+ this.defaultMQPushConsumer.getConsumeThreadMin(), //
+ this.defaultMQPushConsumer.getConsumeThreadMax(), //
+ 1000 * 60, //
+ TimeUnit.MILLISECONDS, //
+ this.consumeRequestQueue, //
+ new ThreadFactoryImpl("ConsumeMessageThread_"));
this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
this.cleanExpireMsgExecutors = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("CleanExpireMsgScheduledThread_"));
}
-
public void start() {
this.cleanExpireMsgExecutors.scheduleAtFixedRate(new Runnable() {
@@ -85,7 +92,6 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
}, this.defaultMQPushConsumer.getConsumeTimeout(), this.defaultMQPushConsumer.getConsumeTimeout(), TimeUnit.MINUTES);
}
-
public void shutdown() {
this.scheduledExecutorService.shutdown();
this.consumeExecutor.shutdown();
@@ -95,8 +101,8 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
@Override
public void updateCorePoolSize(int corePoolSize) {
if (corePoolSize > 0 //
- && corePoolSize <= Short.MAX_VALUE //
- && corePoolSize < this.defaultMQPushConsumer.getConsumeThreadMax()) {
+ && corePoolSize <= Short.MAX_VALUE //
+ && corePoolSize < this.defaultMQPushConsumer.getConsumeThreadMax()) {
this.consumeExecutor.setCorePoolSize(corePoolSize);
}
}
@@ -180,10 +186,10 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
result.setRemark(RemotingHelper.exceptionSimpleDesc(e));
log.warn(String.format("consumeMessageDirectly exception: %s Group: %s Msgs: %s MQ: %s", //
- RemotingHelper.exceptionSimpleDesc(e), //
- ConsumeMessageConcurrentlyService.this.consumerGroup, //
- msgs, //
- mq), e);
+ RemotingHelper.exceptionSimpleDesc(e), //
+ ConsumeMessageConcurrentlyService.this.consumerGroup, //
+ msgs, //
+ mq), e);
}
result.setSpentTimeMills(System.currentTimeMillis() - beginTime);
@@ -195,10 +201,10 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
@Override
public void submitConsumeRequest(//
- final List<MessageExt> msgs, //
- final ProcessQueue processQueue, //
- final MessageQueue messageQueue, //
- final boolean dispatchToConsume) {
+ final List<MessageExt> msgs, //
+ final ProcessQueue processQueue, //
+ final MessageQueue messageQueue, //
+ final boolean dispatchToConsume) {
final int consumeBatchSize = this.defaultMQPushConsumer.getConsumeMessageBatchMaxSize();
if (msgs.size() <= consumeBatchSize) {
ConsumeRequest consumeRequest = new ConsumeRequest(msgs, processQueue, messageQueue);
@@ -244,7 +250,7 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
private void cleanExpireMsg() {
Iterator<Map.Entry<MessageQueue, ProcessQueue>> it =
- this.defaultMQPushConsumerImpl.getRebalanceImpl().getProcessQueueTable().entrySet().iterator();
+ this.defaultMQPushConsumerImpl.getRebalanceImpl().getProcessQueueTable().entrySet().iterator();
while (it.hasNext()) {
Map.Entry<MessageQueue, ProcessQueue> next = it.next();
ProcessQueue pq = next.getValue();
@@ -253,9 +259,9 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
}
public void processConsumeResult(//
- final ConsumeConcurrentlyStatus status, //
- final ConsumeConcurrentlyContext context, //
- final ConsumeRequest consumeRequest//
+ final ConsumeConcurrentlyStatus status, //
+ final ConsumeConcurrentlyContext context, //
+ final ConsumeRequest consumeRequest//
) {
int ackIndex = context.getAckIndex();
@@ -275,7 +281,7 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
case RECONSUME_LATER:
ackIndex = -1;
this.getConsumerStatsManager().incConsumeFailedTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(),
- consumeRequest.getMsgs().size());
+ consumeRequest.getMsgs().size());
break;
default:
break;
@@ -333,9 +339,9 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
}
private void submitConsumeRequestLater(//
- final List<MessageExt> msgs, //
- final ProcessQueue processQueue, //
- final MessageQueue messageQueue//
+ final List<MessageExt> msgs, //
+ final ProcessQueue processQueue, //
+ final MessageQueue messageQueue//
) {
this.scheduledExecutorService.schedule(new Runnable() {
@@ -364,7 +370,6 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
private final ProcessQueue processQueue;
private final MessageQueue messageQueue;
-
public ConsumeRequest(List<MessageExt> msgs, ProcessQueue processQueue, MessageQueue messageQueue) {
this.msgs = msgs;
this.processQueue = processQueue;
@@ -414,10 +419,10 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
status = listener.consumeMessage(Collections.unmodifiableList(msgs), context);
} catch (Throwable e) {
log.warn("consumeMessage exception: {} Group: {} Msgs: {} MQ: {}",
- RemotingHelper.exceptionSimpleDesc(e), //
- ConsumeMessageConcurrentlyService.this.consumerGroup,
- msgs,
- messageQueue);
+ RemotingHelper.exceptionSimpleDesc(e), //
+ ConsumeMessageConcurrentlyService.this.consumerGroup,
+ msgs,
+ messageQueue);
hasException = true;
}
long consumeRT = System.currentTimeMillis() - beginTimestamp;
@@ -437,9 +442,9 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
consumeMessageContext.getProps().put(MixAll.CONSUME_CONTEXT_TYPE, returnType.name());
if (null == status) {
log.warn("consumeMessage return null, Group: {} Msgs: {} MQ: {}",
- ConsumeMessageConcurrentlyService.this.consumerGroup,
- msgs,
- messageQueue);
+ ConsumeMessageConcurrentlyService.this.consumerGroup,
+ msgs,
+ messageQueue);
status = ConsumeConcurrentlyStatus.RECONSUME_LATER;
}
@@ -450,7 +455,7 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
}
ConsumeMessageConcurrentlyService.this.getConsumerStatsManager()
- .incConsumeRT(ConsumeMessageConcurrentlyService.this.consumerGroup, messageQueue.getTopic(), consumeRT);
+ .incConsumeRT(ConsumeMessageConcurrentlyService.this.consumerGroup, messageQueue.getTopic(), consumeRT);
if (!processQueue.isDropped()) {
ConsumeMessageConcurrentlyService.this.processConsumeResult(status, context, this);
@@ -463,6 +468,5 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
return messageQueue;
}
-
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
index f6a1e4d..3def223 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
@@ -16,35 +16,42 @@
*/
package org.apache.rocketmq.client.impl.consumer;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
+import org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyContext;
import org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyStatus;
import org.apache.rocketmq.client.consumer.listener.ConsumeReturnType;
+import org.apache.rocketmq.client.consumer.listener.MessageListenerOrderly;
import org.apache.rocketmq.client.hook.ConsumeMessageContext;
import org.apache.rocketmq.client.log.ClientLogger;
import org.apache.rocketmq.client.stat.ConsumerStatsManager;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.ThreadFactoryImpl;
import org.apache.rocketmq.common.UtilAll;
-import org.apache.rocketmq.common.message.*;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageAccessor;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.body.CMResult;
import org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
import org.apache.rocketmq.remoting.common.RemotingHelper;
-import org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyContext;
-import org.apache.rocketmq.client.consumer.listener.MessageListenerOrderly;
import org.slf4j.Logger;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.concurrent.*;
-
-
public class ConsumeMessageOrderlyService implements ConsumeMessageService {
private static final Logger log = ClientLogger.getLog();
private final static long MAX_TIME_CONSUME_CONTINUOUSLY =
- Long.parseLong(System.getProperty("rocketmq.client.maxTimeConsumeContinuously", "60000"));
+ Long.parseLong(System.getProperty("rocketmq.client.maxTimeConsumeContinuously", "60000"));
private final DefaultMQPushConsumerImpl defaultMQPushConsumerImpl;
private final DefaultMQPushConsumer defaultMQPushConsumer;
private final MessageListenerOrderly messageListener;
@@ -55,7 +62,6 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
private final ScheduledExecutorService scheduledExecutorService;
private volatile boolean stopped = false;
-
public ConsumeMessageOrderlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl, MessageListenerOrderly messageListener) {
this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
this.messageListener = messageListener;
@@ -65,17 +71,16 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();
this.consumeExecutor = new ThreadPoolExecutor(//
- this.defaultMQPushConsumer.getConsumeThreadMin(), //
- this.defaultMQPushConsumer.getConsumeThreadMax(), //
- 1000 * 60, //
- TimeUnit.MILLISECONDS, //
- this.consumeRequestQueue, //
- new ThreadFactoryImpl("ConsumeMessageThread_"));
+ this.defaultMQPushConsumer.getConsumeThreadMin(), //
+ this.defaultMQPushConsumer.getConsumeThreadMax(), //
+ 1000 * 60, //
+ TimeUnit.MILLISECONDS, //
+ this.consumeRequestQueue, //
+ new ThreadFactoryImpl("ConsumeMessageThread_"));
this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
}
-
public void start() {
if (MessageModel.CLUSTERING.equals(ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.messageModel())) {
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@@ -87,7 +92,6 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
}
}
-
public void shutdown() {
this.stopped = true;
this.scheduledExecutorService.shutdown();
@@ -97,7 +101,6 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
}
}
-
public synchronized void unlockAllMQ() {
this.defaultMQPushConsumerImpl.getRebalanceImpl().unlockAll(false);
}
@@ -105,8 +108,8 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
@Override
public void updateCorePoolSize(int corePoolSize) {
if (corePoolSize > 0 //
- && corePoolSize <= Short.MAX_VALUE //
- && corePoolSize < this.defaultMQPushConsumer.getConsumeThreadMax()) {
+ && corePoolSize <= Short.MAX_VALUE //
+ && corePoolSize < this.defaultMQPushConsumer.getConsumeThreadMax()) {
this.consumeExecutor.setCorePoolSize(corePoolSize);
}
}
@@ -169,10 +172,10 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
result.setRemark(RemotingHelper.exceptionSimpleDesc(e));
log.warn(String.format("consumeMessageDirectly exception: %s Group: %s Msgs: %s MQ: %s", //
- RemotingHelper.exceptionSimpleDesc(e), //
- ConsumeMessageOrderlyService.this.consumerGroup, //
- msgs, //
- mq), e);
+ RemotingHelper.exceptionSimpleDesc(e), //
+ ConsumeMessageOrderlyService.this.consumerGroup, //
+ msgs, //
+ mq), e);
}
result.setAutoCommit(context.isAutoCommit());
@@ -185,10 +188,10 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
@Override
public void submitConsumeRequest(//
- final List<MessageExt> msgs, //
- final ProcessQueue processQueue, //
- final MessageQueue messageQueue, //
- final boolean dispathToConsume) {
+ final List<MessageExt> msgs, //
+ final ProcessQueue processQueue, //
+ final MessageQueue messageQueue, //
+ final boolean dispathToConsume) {
if (dispathToConsume) {
ConsumeRequest consumeRequest = new ConsumeRequest(processQueue, messageQueue);
this.consumeExecutor.submit(consumeRequest);
@@ -224,9 +227,9 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
}
private void submitConsumeRequestLater(//
- final ProcessQueue processQueue, //
- final MessageQueue messageQueue, //
- final long suspendTimeMillis//
+ final ProcessQueue processQueue, //
+ final MessageQueue messageQueue, //
+ final long suspendTimeMillis//
) {
long timeMillis = suspendTimeMillis;
if (timeMillis == -1) {
@@ -249,10 +252,10 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
}
public boolean processConsumeResult(//
- final List<MessageExt> msgs, //
- final ConsumeOrderlyStatus status, //
- final ConsumeOrderlyContext context, //
- final ConsumeRequest consumeRequest//
+ final List<MessageExt> msgs, //
+ final ConsumeOrderlyStatus status, //
+ final ConsumeOrderlyContext context, //
+ final ConsumeRequest consumeRequest//
) {
boolean continueConsume = true;
long commitOffset = -1L;
@@ -261,7 +264,7 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
case COMMIT:
case ROLLBACK:
log.warn("the message queue consume result is illegal, we think you want to ack these message {}",
- consumeRequest.getMessageQueue());
+ consumeRequest.getMessageQueue());
case SUCCESS:
commitOffset = consumeRequest.getProcessQueue().commit();
this.getConsumerStatsManager().incConsumeOKTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(), msgs.size());
@@ -271,9 +274,9 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
if (checkReconsumeTimes(msgs)) {
consumeRequest.getProcessQueue().makeMessageToCosumeAgain(msgs);
this.submitConsumeRequestLater(//
- consumeRequest.getProcessQueue(), //
- consumeRequest.getMessageQueue(), //
- context.getSuspendCurrentQueueTimeMillis());
+ consumeRequest.getProcessQueue(), //
+ consumeRequest.getMessageQueue(), //
+ context.getSuspendCurrentQueueTimeMillis());
continueConsume = false;
} else {
commitOffset = consumeRequest.getProcessQueue().commit();
@@ -293,9 +296,9 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
case ROLLBACK:
consumeRequest.getProcessQueue().rollback();
this.submitConsumeRequestLater(//
- consumeRequest.getProcessQueue(), //
- consumeRequest.getMessageQueue(), //
- context.getSuspendCurrentQueueTimeMillis());
+ consumeRequest.getProcessQueue(), //
+ consumeRequest.getMessageQueue(), //
+ context.getSuspendCurrentQueueTimeMillis());
continueConsume = false;
break;
case SUSPEND_CURRENT_QUEUE_A_MOMENT:
@@ -303,9 +306,9 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
if (checkReconsumeTimes(msgs)) {
consumeRequest.getProcessQueue().makeMessageToCosumeAgain(msgs);
this.submitConsumeRequestLater(//
- consumeRequest.getProcessQueue(), //
- consumeRequest.getMessageQueue(), //
- context.getSuspendCurrentQueueTimeMillis());
+ consumeRequest.getProcessQueue(), //
+ consumeRequest.getMessageQueue(), //
+ context.getSuspendCurrentQueueTimeMillis());
continueConsume = false;
}
break;
@@ -379,7 +382,6 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
private final ProcessQueue processQueue;
private final MessageQueue messageQueue;
-
public ConsumeRequest(ProcessQueue processQueue, MessageQueue messageQueue) {
this.processQueue = processQueue;
this.messageQueue = messageQueue;
@@ -403,7 +405,7 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
final Object objLock = messageQueueLock.fetchLockObject(this.messageQueue);
synchronized (objLock) {
if (MessageModel.BROADCASTING.equals(ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.messageModel())
- || (this.processQueue.isLocked() && !this.processQueue.isLockExpired())) {
+ || (this.processQueue.isLocked() && !this.processQueue.isLockExpired())) {
final long beginTime = System.currentTimeMillis();
for (boolean continueConsume = true; continueConsume; ) {
if (this.processQueue.isDropped()) {
@@ -412,14 +414,14 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
}
if (MessageModel.CLUSTERING.equals(ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.messageModel())
- && !this.processQueue.isLocked()) {
+ && !this.processQueue.isLocked()) {
log.warn("the message queue not locked, so consume later, {}", this.messageQueue);
ConsumeMessageOrderlyService.this.tryLockLaterAndReconsume(this.messageQueue, this.processQueue, 10);
break;
}
if (MessageModel.CLUSTERING.equals(ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.messageModel())
- && this.processQueue.isLockExpired()) {
+ && this.processQueue.isLockExpired()) {
log.warn("the message queue lock expired, so consume later, {}", this.messageQueue);
ConsumeMessageOrderlyService.this.tryLockLaterAndReconsume(this.messageQueue, this.processQueue, 10);
break;
@@ -432,7 +434,7 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
}
final int consumeBatchSize =
- ConsumeMessageOrderlyService.this.defaultMQPushConsumer.getConsumeMessageBatchMaxSize();
+ ConsumeMessageOrderlyService.this.defaultMQPushConsumer.getConsumeMessageBatchMaxSize();
List<MessageExt> msgs = this.processQueue.takeMessags(consumeBatchSize);
if (!msgs.isEmpty()) {
@@ -444,7 +446,7 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
if (ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.hasHook()) {
consumeMessageContext = new ConsumeMessageContext();
consumeMessageContext
- .setConsumerGroup(ConsumeMessageOrderlyService.this.defaultMQPushConsumer.getConsumerGroup());
+ .setConsumerGroup(ConsumeMessageOrderlyService.this.defaultMQPushConsumer.getConsumerGroup());
consumeMessageContext.setMq(messageQueue);
consumeMessageContext.setMsgList(msgs);
consumeMessageContext.setSuccess(false);
@@ -460,29 +462,29 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
this.processQueue.getLockConsume().lock();
if (this.processQueue.isDropped()) {
log.warn("consumeMessage, the message queue not be able to consume, because it's dropped. {}",
- this.messageQueue);
+ this.messageQueue);
break;
}
status = messageListener.consumeMessage(Collections.unmodifiableList(msgs), context);
} catch (Throwable e) {
log.warn("consumeMessage exception: {} Group: {} Msgs: {} MQ: {}", //
- RemotingHelper.exceptionSimpleDesc(e), //
- ConsumeMessageOrderlyService.this.consumerGroup, //
- msgs, //
- messageQueue);
+ RemotingHelper.exceptionSimpleDesc(e), //
+ ConsumeMessageOrderlyService.this.consumerGroup, //
+ msgs, //
+ messageQueue);
hasException = true;
} finally {
this.processQueue.getLockConsume().unlock();
}
if (null == status //
- || ConsumeOrderlyStatus.ROLLBACK == status//
- || ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT == status) {
+ || ConsumeOrderlyStatus.ROLLBACK == status//
+ || ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT == status) {
log.warn("consumeMessage Orderly return not OK, Group: {} Msgs: {} MQ: {}", //
- ConsumeMessageOrderlyService.this.consumerGroup, //
- msgs, //
- messageQueue);
+ ConsumeMessageOrderlyService.this.consumerGroup, //
+ msgs, //
+ messageQueue);
}
long consumeRT = System.currentTimeMillis() - beginTimestamp;
@@ -507,12 +509,12 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
if (ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.hasHook()) {
consumeMessageContext.setStatus(status.toString());
consumeMessageContext
- .setSuccess(ConsumeOrderlyStatus.SUCCESS == status || ConsumeOrderlyStatus.COMMIT == status);
+ .setSuccess(ConsumeOrderlyStatus.SUCCESS == status || ConsumeOrderlyStatus.COMMIT == status);
ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.executeHookAfter(consumeMessageContext);
}
ConsumeMessageOrderlyService.this.getConsumerStatsManager()
- .incConsumeRT(ConsumeMessageOrderlyService.this.consumerGroup, messageQueue.getTopic(), consumeRT);
+ .incConsumeRT(ConsumeMessageOrderlyService.this.consumerGroup, messageQueue.getTopic(), consumeRT);
continueConsume = ConsumeMessageOrderlyService.this.processConsumeResult(msgs, status, context, this);
} else {
@@ -530,7 +532,6 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
}
}
-
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java
index 3dc768c..a59ab98 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java
@@ -6,48 +6,39 @@
* (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
+ * 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.
+ * 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.impl.consumer;
+import java.util.List;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
-import java.util.List;
-
-
public interface ConsumeMessageService {
void start();
-
void shutdown();
-
void updateCorePoolSize(int corePoolSize);
-
void incCorePoolSize();
-
void decCorePoolSize();
-
int getCorePoolSize();
-
ConsumeMessageDirectlyResult consumeMessageDirectly(final MessageExt msg, final String brokerName);
-
void submitConsumeRequest(//
- final List<MessageExt> msgs, //
- final ProcessQueue processQueue, //
- final MessageQueue messageQueue, //
- final boolean dispathToConsume);
+ final List<MessageExt> msgs, //
+ final ProcessQueue processQueue, //
+ final MessageQueue messageQueue, //
+ final boolean dispathToConsume);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
index f216533..7c1b4d6 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
@@ -16,6 +16,13 @@
*/
package org.apache.rocketmq.client.impl.consumer;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.rocketmq.client.QueryResult;
import org.apache.rocketmq.client.Validators;
import org.apache.rocketmq.client.consumer.DefaultMQPullConsumer;
@@ -41,7 +48,11 @@ import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import org.apache.rocketmq.common.filter.FilterAPI;
import org.apache.rocketmq.common.help.FAQUrl;
-import org.apache.rocketmq.common.message.*;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageAccessor;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
@@ -52,10 +63,6 @@ import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.apache.rocketmq.remoting.exception.RemotingException;
import org.slf4j.Logger;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-
-
public class DefaultMQPullConsumerImpl implements MQConsumerInner {
private final Logger log = ClientLogger.getLog();
private final DefaultMQPullConsumer defaultMQPullConsumer;
@@ -69,7 +76,6 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
private OffsetStore offsetStore;
private RebalanceImpl rebalanceImpl = new RebalancePullImpl(this);
-
public DefaultMQPullConsumerImpl(final DefaultMQPullConsumer defaultMQPullConsumer, final RPCHook rpcHook) {
this.defaultMQPullConsumer = defaultMQPullConsumer;
this.rpcHook = rpcHook;
@@ -92,9 +98,9 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
private void makeSureStateOK() throws MQClientException {
if (this.serviceState != ServiceState.RUNNING) {
throw new MQClientException("The consumer service state not OK, "//
- + this.serviceState//
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
- null);
+ + this.serviceState//
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
+ null);
}
}
@@ -146,17 +152,17 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
}
public PullResult pull(MessageQueue mq, String subExpression, long offset, int maxNums)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return pull(mq, subExpression, offset, maxNums, this.defaultMQPullConsumer.getConsumerPullTimeoutMillis());
}
public PullResult pull(MessageQueue mq, String subExpression, long offset, int maxNums, long timeout)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.pullSyncImpl(mq, subExpression, offset, maxNums, false, timeout);
}
private PullResult pullSyncImpl(MessageQueue mq, String subExpression, long offset, int maxNums, boolean block, long timeout)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
this.makeSureStateOK();
if (null == mq) {
@@ -179,7 +185,7 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
SubscriptionData subscriptionData;
try {
subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(), //
- mq.getTopic(), subExpression);
+ mq.getTopic(), subExpression);
} catch (Exception e) {
throw new MQClientException("parse subscription error", e);
}
@@ -187,17 +193,17 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
long timeoutMillis = block ? this.defaultMQPullConsumer.getConsumerTimeoutMillisWhenSuspend() : timeout;
PullResult pullResult = this.pullAPIWrapper.pullKernelImpl(//
- mq, // 1
- subscriptionData.getSubString(), // 2
- 0L, // 3
- offset, // 4
- maxNums, // 5
- sysFlag, // 6
- 0, // 7
- this.defaultMQPullConsumer.getBrokerSuspendMaxTimeMillis(), // 8
- timeoutMillis, // 9
- CommunicationMode.SYNC, // 10
- null// 11
+ mq, // 1
+ subscriptionData.getSubString(), // 2
+ 0L, // 3
+ offset, // 4
+ maxNums, // 5
+ sysFlag, // 6
+ 0, // 7
+ this.defaultMQPullConsumer.getBrokerSuspendMaxTimeMillis(), // 8
+ timeoutMillis, // 9
+ CommunicationMode.SYNC, // 10
+ null// 11
);
this.pullAPIWrapper.processPullResult(mq, pullResult, subscriptionData);
if (!this.consumeMessageHookList.isEmpty()) {
@@ -219,7 +225,7 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
if (!this.rebalanceImpl.getSubscriptionInner().containsKey(topic)) {
try {
SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(), //
- topic, SubscriptionData.SUB_ALL);
+ topic, SubscriptionData.SUB_ALL);
this.rebalanceImpl.subscriptionInner.putIfAbsent(topic, subscriptionData);
} catch (Exception e) {
}
@@ -357,23 +363,23 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
}
public void pull(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback)
- throws MQClientException, RemotingException, InterruptedException {
+ throws MQClientException, RemotingException, InterruptedException {
pull(mq, subExpression, offset, maxNums, pullCallback, this.defaultMQPullConsumer.getConsumerPullTimeoutMillis());
}
public void pull(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback, long timeout)
- throws MQClientException, RemotingException, InterruptedException {
+ throws MQClientException, RemotingException, InterruptedException {
this.pullAsyncImpl(mq, subExpression, offset, maxNums, pullCallback, false, timeout);
}
private void pullAsyncImpl(//
- final MessageQueue mq, //
- final String subExpression, //
- final long offset, //
- final int maxNums, //
- final PullCallback pullCallback, //
- final boolean block, //
- final long timeout) throws MQClientException, RemotingException, InterruptedException {
+ final MessageQueue mq, //
+ final String subExpression, //
+ final long offset, //
+ final int maxNums, //
+ final PullCallback pullCallback, //
+ final boolean block, //
+ final long timeout) throws MQClientException, RemotingException, InterruptedException {
this.makeSureStateOK();
if (null == mq) {
@@ -400,7 +406,7 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
final SubscriptionData subscriptionData;
try {
subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(), //
- mq.getTopic(), subExpression);
+ mq.getTopic(), subExpression);
} catch (Exception e) {
throw new MQClientException("parse subscription error", e);
}
@@ -408,36 +414,36 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
long timeoutMillis = block ? this.defaultMQPullConsumer.getConsumerTimeoutMillisWhenSuspend() : timeout;
this.pullAPIWrapper.pullKernelImpl(//
- mq, // 1
- subscriptionData.getSubString(), // 2
- 0L, // 3
- offset, // 4
- maxNums, // 5
- sysFlag, // 6
- 0, // 7
- this.defaultMQPullConsumer.getBrokerSuspendMaxTimeMillis(), // 8
- timeoutMillis, // 9
- CommunicationMode.ASYNC, // 10
- new PullCallback() {
-
- @Override
- public void onSuccess(PullResult pullResult) {
- pullCallback
- .onSuccess(DefaultMQPullConsumerImpl.this.pullAPIWrapper.processPullResult(mq, pullResult, subscriptionData));
- }
-
- @Override
- public void onException(Throwable e) {
- pullCallback.onException(e);
- }
- });
+ mq, // 1
+ subscriptionData.getSubString(), // 2
+ 0L, // 3
+ offset, // 4
+ maxNums, // 5
+ sysFlag, // 6
+ 0, // 7
+ this.defaultMQPullConsumer.getBrokerSuspendMaxTimeMillis(), // 8
+ timeoutMillis, // 9
+ CommunicationMode.ASYNC, // 10
+ new PullCallback() {
+
+ @Override
+ public void onSuccess(PullResult pullResult) {
+ pullCallback
+ .onSuccess(DefaultMQPullConsumerImpl.this.pullAPIWrapper.processPullResult(mq, pullResult, subscriptionData));
+ }
+
+ @Override
+ public void onException(Throwable e) {
+ pullCallback.onException(e);
+ }
+ });
} catch (MQBrokerException e) {
throw new MQClientException("pullAsync unknow exception", e);
}
}
public PullResult pullBlockIfNotFound(MessageQueue mq, String subExpression, long offset, int maxNums)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.pullSyncImpl(mq, subExpression, offset, maxNums, true, this.getDefaultMQPullConsumer().getConsumerPullTimeoutMillis());
}
@@ -446,19 +452,19 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
}
public void pullBlockIfNotFound(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback)
- throws MQClientException, RemotingException, InterruptedException {
+ throws MQClientException, RemotingException, InterruptedException {
this.pullAsyncImpl(mq, subExpression, offset, maxNums, pullCallback, true,
- this.getDefaultMQPullConsumer().getConsumerPullTimeoutMillis());
+ this.getDefaultMQPullConsumer().getConsumerPullTimeoutMillis());
}
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
- throws MQClientException, InterruptedException {
+ throws MQClientException, InterruptedException {
this.makeSureStateOK();
return this.mQClientFactory.getMQAdminImpl().queryMessage(topic, key, maxNum, begin, end);
}
public MessageExt queryMessageByUniqKey(String topic, String uniqKey)
- throws MQClientException, InterruptedException {
+ throws MQClientException, InterruptedException {
this.makeSureStateOK();
return this.mQClientFactory.getMQAdminImpl().queryMessageByUniqKey(topic, uniqKey);
}
@@ -469,27 +475,27 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
}
public void sendMessageBack(MessageExt msg, int delayLevel, final String brokerName)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
sendMessageBack(msg, delayLevel, brokerName, this.defaultMQPullConsumer.getConsumerGroup());
}
public void updateConsumeOffsetToBroker(MessageQueue mq, long offset, boolean isOneway) throws RemotingException,
- MQBrokerException, InterruptedException, MQClientException {
+ MQBrokerException, InterruptedException, MQClientException {
this.offsetStore.updateConsumeOffsetToBroker(mq, offset, isOneway);
}
public void sendMessageBack(MessageExt msg, int delayLevel, final String brokerName, String consumerGroup)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
try {
String brokerAddr = (null != brokerName) ? this.mQClientFactory.findBrokerAddressInPublish(brokerName)
- : RemotingHelper.parseSocketAddressAddr(msg.getStoreHost());
+ : RemotingHelper.parseSocketAddressAddr(msg.getStoreHost());
if (UtilAll.isBlank(consumerGroup)) {
consumerGroup = this.defaultMQPullConsumer.getConsumerGroup();
}
this.mQClientFactory.getMQClientAPIImpl().consumerSendMessageBack(brokerAddr, msg, consumerGroup, delayLevel, 3000,
- this.defaultMQPullConsumer.getMaxReconsumeTimes());
+ this.defaultMQPullConsumer.getMaxReconsumeTimes());
} catch (Exception e) {
log.error("sendMessageBack Exception, " + this.defaultMQPullConsumer.getConsumerGroup(), e);
@@ -545,8 +551,8 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
this.rebalanceImpl.setmQClientFactory(this.mQClientFactory);
this.pullAPIWrapper = new PullAPIWrapper(//
- mQClientFactory, //
- this.defaultMQPullConsumer.getConsumerGroup(), isUnitMode());
+ mQClientFactory, //
+ this.defaultMQPullConsumer.getConsumerGroup(), isUnitMode());
this.pullAPIWrapper.registerFilterMessageHook(filterMessageHookList);
if (this.defaultMQPullConsumer.getOffsetStore() != null) {
@@ -571,8 +577,8 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
this.serviceState = ServiceState.CREATE_JUST;
throw new MQClientException("The consumer group[" + this.defaultMQPullConsumer.getConsumerGroup()
- + "] has been created before, specify another name please." + FAQUrl.suggestTodo(FAQUrl.GROUP_NAME_DUPLICATE_URL),
- null);
+ + "] has been created before, specify another name please." + FAQUrl.suggestTodo(FAQUrl.GROUP_NAME_DUPLICATE_URL),
+ null);
}
mQClientFactory.start();
@@ -583,9 +589,9 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
case START_FAILED:
case SHUTDOWN_ALREADY:
throw new MQClientException("The PullConsumer service state not OK, maybe started once, "//
- + this.serviceState//
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
- null);
+ + this.serviceState//
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
+ null);
default:
break;
}
@@ -598,43 +604,43 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
// consumerGroup
if (null == this.defaultMQPullConsumer.getConsumerGroup()) {
throw new MQClientException(
- "consumerGroup is null" //
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
- null);
+ "consumerGroup is null" //
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
+ null);
}
// consumerGroup
if (this.defaultMQPullConsumer.getConsumerGroup().equals(MixAll.DEFAULT_CONSUMER_GROUP)) {
throw new MQClientException(
- "consumerGroup can not equal "//
- + MixAll.DEFAULT_CONSUMER_GROUP //
- + ", please specify another one."//
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
- null);
+ "consumerGroup can not equal "//
+ + MixAll.DEFAULT_CONSUMER_GROUP //
+ + ", please specify another one."//
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
+ null);
}
// messageModel
if (null == this.defaultMQPullConsumer.getMessageModel()) {
throw new MQClientException(
- "messageModel is null" //
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
- null);
+ "messageModel is null" //
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
+ null);
}
// allocateMessageQueueStrategy
if (null == this.defaultMQPullConsumer.getAllocateMessageQueueStrategy()) {
throw new MQClientException(
- "allocateMessageQueueStrategy is null" //
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
- null);
+ "allocateMessageQueueStrategy is null" //
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
+ null);
}
// allocateMessageQueueStrategy
if (this.defaultMQPullConsumer.getConsumerTimeoutMillisWhenSuspend() < this.defaultMQPullConsumer.getBrokerSuspendMaxTimeMillis()) {
throw new MQClientException(
- "Long polling mode, the consumer consumerTimeoutMillisWhenSuspend must greater than brokerSuspendMaxTimeMillis" //
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
- null);
+ "Long polling mode, the consumer consumerTimeoutMillisWhenSuspend must greater than brokerSuspendMaxTimeMillis" //
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
+ null);
}
}
@@ -644,7 +650,7 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
if (registerTopics != null) {
for (final String topic : registerTopics) {
SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(), //
- topic, SubscriptionData.SUB_ALL);
+ topic, SubscriptionData.SUB_ALL);
this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData);
}
}
@@ -696,7 +702,6 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
return consumerStartTimestamp;
}
-
public RebalanceImpl getRebalanceImpl() {
return rebalanceImpl;
}
[96/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Fix the
conflicts between code and check style.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
index dbfecb1..1e421ea 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: RegisterBrokerRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: RegisterBrokerRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
index 0e04c79..a0bad3e 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: RegisterOrderTopicRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: RegisterOrderTopicRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
index 9f6fd27..070874f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: UnRegisterBrokerRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: UnRegisterBrokerRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
index 49fe045..248b715 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: ConsumeType.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: ConsumeType.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
index c2a0107..75e2f9e 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: ConsumerData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: ConsumerData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
index 5257174..35202b9 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: HeartbeatData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: HeartbeatData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
index d710502..bf27e93 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: MessageModel.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: MessageModel.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
index b7d4c95..f30e154 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: ProducerData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: ProducerData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
index 8c4292a..a03bdc4 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: SubscriptionData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: SubscriptionData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -124,7 +126,7 @@ public class SubscriptionData implements Comparable<SubscriptionData> {
return false;
if (getClass() != obj.getClass())
return false;
- SubscriptionData other = (SubscriptionData)obj;
+ SubscriptionData other = (SubscriptionData) obj;
if (classFilterMode != other.classFilterMode)
return false;
if (codeSet == null) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
index f79bdb5..1382b24 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: BrokerData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: BrokerData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -78,7 +80,7 @@ public class BrokerData implements Comparable<BrokerData> {
return false;
if (getClass() != obj.getClass())
return false;
- BrokerData other = (BrokerData)obj;
+ BrokerData other = (BrokerData) obj;
if (brokerAddrs == null) {
if (other.brokerAddrs != null)
return false;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java
index 3fe3e2c..94328ae 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: QueueData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: QueueData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -81,7 +83,7 @@ public class QueueData implements Comparable<QueueData> {
return false;
if (getClass() != obj.getClass())
return false;
- QueueData other = (QueueData)obj;
+ QueueData other = (QueueData) obj;
if (brokerName == null) {
if (other.brokerName != null)
return false;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
index 64d9726..b4fd25a 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: TopicRouteData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: TopicRouteData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -106,7 +108,7 @@ public class TopicRouteData extends RemotingSerializable {
return false;
if (getClass() != obj.getClass())
return false;
- TopicRouteData other = (TopicRouteData)obj;
+ TopicRouteData other = (TopicRouteData) obj;
if (brokerDatas == null) {
if (other.brokerDatas != null)
return false;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java b/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java
index 021ba83..106384c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java
+++ b/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java
@@ -27,7 +27,6 @@ import org.slf4j.LoggerFactory;
/**
* thread safe
- *
*/
public class ConcurrentTreeMap<K, V> {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.java b/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.java
index e9f2177..7d6d47f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.java
+++ b/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.java
@@ -22,7 +22,6 @@ import java.util.Queue;
/**
* not thread safe
- *
*/
public class RoundQueue<E> {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java b/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
index 9bf97fb..315c18d 100644
--- a/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
+++ b/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
@@ -114,7 +114,7 @@ public class SubscriptionGroupConfig {
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + (int)(brokerId ^ (brokerId >>> 32));
+ result = prime * result + (int) (brokerId ^ (brokerId >>> 32));
result = prime * result + (consumeBroadcastEnable ? 1231 : 1237);
result = prime * result + (consumeEnable ? 1231 : 1237);
result = prime * result + (consumeFromMinEnable ? 1231 : 1237);
@@ -123,7 +123,7 @@ public class SubscriptionGroupConfig {
result = prime * result + retryMaxTimes;
result = prime * result + retryQueueNums;
result =
- prime * result + (int)(whichBrokerWhenConsumeSlowly ^ (whichBrokerWhenConsumeSlowly >>> 32));
+ prime * result + (int) (whichBrokerWhenConsumeSlowly ^ (whichBrokerWhenConsumeSlowly >>> 32));
return result;
}
@@ -135,7 +135,7 @@ public class SubscriptionGroupConfig {
return false;
if (getClass() != obj.getClass())
return false;
- SubscriptionGroupConfig other = (SubscriptionGroupConfig)obj;
+ SubscriptionGroupConfig other = (SubscriptionGroupConfig) obj;
if (brokerId != other.brokerId)
return false;
if (consumeBroadcastEnable != other.consumeBroadcastEnable)
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/utils/ChannelUtil.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/utils/ChannelUtil.java b/common/src/main/java/org/apache/rocketmq/common/utils/ChannelUtil.java
index dcb9187..52c3e48 100644
--- a/common/src/main/java/org/apache/rocketmq/common/utils/ChannelUtil.java
+++ b/common/src/main/java/org/apache/rocketmq/common/utils/ChannelUtil.java
@@ -23,7 +23,7 @@ import java.net.InetSocketAddress;
public class ChannelUtil {
public static String getRemoteIp(Channel channel) {
- InetSocketAddress inetSocketAddress = (InetSocketAddress)channel.remoteAddress();
+ InetSocketAddress inetSocketAddress = (InetSocketAddress) channel.remoteAddress();
if (inetSocketAddress == null) {
return "";
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/utils/HttpTinyClient.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/utils/HttpTinyClient.java b/common/src/main/java/org/apache/rocketmq/common/utils/HttpTinyClient.java
index 0cc3463..7cc9446 100755
--- a/common/src/main/java/org/apache/rocketmq/common/utils/HttpTinyClient.java
+++ b/common/src/main/java/org/apache/rocketmq/common/utils/HttpTinyClient.java
@@ -36,10 +36,10 @@ public class HttpTinyClient {
HttpURLConnection conn = null;
try {
- conn = (HttpURLConnection)new URL(url).openConnection();
+ conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestMethod("GET");
- conn.setConnectTimeout((int)readTimeoutMs);
- conn.setReadTimeout((int)readTimeoutMs);
+ conn.setConnectTimeout((int) readTimeoutMs);
+ conn.setReadTimeout((int) readTimeoutMs);
setHeaders(conn, headers, encoding);
conn.connect();
@@ -90,20 +90,12 @@ public class HttpTinyClient {
}
/**
-
- *
* @param url
* @param headers
-
* @param paramValues
-
* @param encoding
-
* @param readTimeoutMs
-
- *
* @return the http response of given http post request
- *
* @throws java.io.IOException
*/
static public HttpResult httpPost(String url, List<String> headers, List<String> paramValues,
@@ -112,10 +104,10 @@ public class HttpTinyClient {
HttpURLConnection conn = null;
try {
- conn = (HttpURLConnection)new URL(url).openConnection();
+ conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestMethod("POST");
conn.setConnectTimeout(3000);
- conn.setReadTimeout((int)readTimeoutMs);
+ conn.setReadTimeout((int) readTimeoutMs);
conn.setDoOutput(true);
conn.setDoInput(true);
setHeaders(conn, headers, encoding);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java b/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java
index b569c24..e2e7cba 100644
--- a/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java
+++ b/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java
@@ -56,14 +56,11 @@ public class IOTinyUtils {
return count;
}
- /**
-
- */
static public List<String> readLines(Reader input) throws IOException {
BufferedReader reader = toBufferedReader(input);
List<String> list = new ArrayList<String>();
- String line = null;
- for (; ; ) {
+ String line;
+ for (;;) {
line = reader.readLine();
if (null != line) {
list.add(line);
@@ -75,7 +72,7 @@ public class IOTinyUtils {
}
static private BufferedReader toBufferedReader(Reader reader) {
- return reader instanceof BufferedReader ? (BufferedReader)reader : new BufferedReader(reader);
+ return reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader);
}
static public void copyFile(String source, String target) throws IOException {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/example/src/main/java/org/apache/rocketmq/example/benchmark/Consumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/benchmark/Consumer.java b/example/src/main/java/org/apache/rocketmq/example/benchmark/Consumer.java
index f810f5a..a3e06aa 100644
--- a/example/src/main/java/org/apache/rocketmq/example/benchmark/Consumer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/benchmark/Consumer.java
@@ -76,9 +76,9 @@ public class Consumer {
Long[] end = snapshotList.getLast();
final long consumeTps =
- (long)(((end[1] - begin[1]) / (double)(end[0] - begin[0])) * 1000L);
- final double averageB2CRT = (end[2] - begin[2]) / (double)(end[1] - begin[1]);
- final double averageS2CRT = (end[3] - begin[3]) / (double)(end[1] - begin[1]);
+ (long) (((end[1] - begin[1]) / (double) (end[0] - begin[0])) * 1000L);
+ final double averageB2CRT = (end[2] - begin[2]) / (double) (end[1] - begin[1]);
+ final double averageS2CRT = (end[3] - begin[3]) / (double) (end[1] - begin[1]);
System.out.printf("Consume TPS: %d Average(B2C) RT: %7.3f Average(S2C) RT: %7.3f MAX(B2C) RT: %d MAX(S2C) RT: %d%n",
consumeTps, averageB2CRT, averageS2CRT, end[4], end[5]
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java b/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java
index 88e9a4f..8a1dd31 100644
--- a/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java
@@ -81,8 +81,8 @@ public class Producer {
Long[] begin = snapshotList.getFirst();
Long[] end = snapshotList.getLast();
- final long sendTps = (long)(((end[3] - begin[3]) / (double)(end[0] - begin[0])) * 1000L);
- final double averageRT = (end[5] - begin[5]) / (double)(end[3] - begin[3]);
+ final long sendTps = (long) (((end[3] - begin[3]) / (double) (end[0] - begin[0])) * 1000L);
+ final double averageRT = (end[5] - begin[5]) / (double) (end[3] - begin[3]);
System.out.printf("Send TPS: %d Max RT: %d Average RT: %7.3f Send Failed: %d Response Failed: %d%n",
sendTps, statsBenchmark.getSendMessageMaxRT().get(), averageRT, end[2], end[4]);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/example/src/main/java/org/apache/rocketmq/example/benchmark/TransactionProducer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/benchmark/TransactionProducer.java b/example/src/main/java/org/apache/rocketmq/example/benchmark/TransactionProducer.java
index ce4b1ab..2a62b10 100644
--- a/example/src/main/java/org/apache/rocketmq/example/benchmark/TransactionProducer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/benchmark/TransactionProducer.java
@@ -73,8 +73,8 @@ public class TransactionProducer {
Long[] end = snapshotList.getLast();
final long sendTps =
- (long)(((end[3] - begin[3]) / (double)(end[0] - begin[0])) * 1000L);
- final double averageRT = (end[5] - begin[5]) / (double)(end[3] - begin[3]);
+ (long) (((end[3] - begin[3]) / (double) (end[0] - begin[0])) * 1000L);
+ final double averageRT = (end[5] - begin[5]) / (double) (end[3] - begin[3]);
System.out.printf(
"Send TPS: %d Max RT: %d Average RT: %7.3f Send Failed: %d Response Failed: %d transaction checkCount: %d %n",
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/example/src/main/java/org/apache/rocketmq/example/ordermessage/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/ordermessage/Producer.java b/example/src/main/java/org/apache/rocketmq/example/ordermessage/Producer.java
index 7abbb5a..9680780 100644
--- a/example/src/main/java/org/apache/rocketmq/example/ordermessage/Producer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/ordermessage/Producer.java
@@ -44,7 +44,7 @@ public class Producer {
SendResult sendResult = producer.send(msg, new MessageQueueSelector() {
@Override
public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
- Integer id = (Integer)arg;
+ Integer id = (Integer) arg;
int index = id % mqs.size();
return mqs.get(index);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
index 32b8bad..c01aadc 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
@@ -60,7 +60,7 @@ public class FilterServerOuterAPI {
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
RegisterFilterServerResponseHeader responseHeader =
- (RegisterFilterServerResponseHeader)response
+ (RegisterFilterServerResponseHeader) response
.decodeCommandCustomHeader(RegisterFilterServerResponseHeader.class);
return responseHeader;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
index f239caf..7df4748 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
@@ -120,7 +120,7 @@ public class FiltersrvStartup {
System.exit(-2);
}
- LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory();
+ LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/DynaCode.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/DynaCode.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/DynaCode.java
index 11102d0..e3b3441 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/DynaCode.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/DynaCode.java
@@ -95,7 +95,7 @@ public class DynaCode {
StringBuffer buf = new StringBuffer();
while (cl != null) {
if (cl instanceof URLClassLoader) {
- URL urls[] = ((URLClassLoader)cl).getURLs();
+ URL urls[] = ((URLClassLoader) cl).getURLs();
for (int i = 0; i < urls.length; i++) {
if (buf.length() > 0) {
buf.append(File.pathSeparatorChar);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassManager.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassManager.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassManager.java
index 66389e0..e4e6deb 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassManager.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassManager.java
@@ -84,7 +84,7 @@ public class FilterClassManager {
Class<?> newClass =
DynaCode.compileAndLoadClass(filterClassInfo.getClassName(), javaSource);
Object newInstance = newClass.newInstance();
- filterClassInfo.setMessageFilter((MessageFilter)newInstance);
+ filterClassInfo.setMessageFilter((MessageFilter) newInstance);
filterClassInfo.setClassCRC(classCRC);
log.info("fetch Remote class File OK, {} {}", next.getKey(),
@@ -134,7 +134,7 @@ public class FilterClassManager {
String javaSource = new String(filterSourceBinary, MixAll.DEFAULT_CHARSET);
Class<?> newClass = DynaCode.compileAndLoadClass(className, javaSource);
Object newInstance = newClass.newInstance();
- filterClassInfoNew.setMessageFilter((MessageFilter)newInstance);
+ filterClassInfoNew.setMessageFilter((MessageFilter) newInstance);
filterClassInfoNew.setClassCRC(classCRC);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
index 1d56ac1..2740b21 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
@@ -85,7 +85,7 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
private RemotingCommand registerMessageFilterClass(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final RegisterMessageFilterClassRequestHeader requestHeader =
- (RegisterMessageFilterClassRequestHeader)request.decodeCommandCustomHeader(RegisterMessageFilterClassRequestHeader.class);
+ (RegisterMessageFilterClassRequestHeader) request.decodeCommandCustomHeader(RegisterMessageFilterClassRequestHeader.class);
try {
boolean ok = this.filtersrvController.getFilterClassManager().registerFilterClass(requestHeader.getConsumerGroup(),
@@ -109,9 +109,9 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
private RemotingCommand pullMessageForward(final ChannelHandlerContext ctx, final RemotingCommand request) throws Exception {
final RemotingCommand response = RemotingCommand.createResponseCommand(PullMessageResponseHeader.class);
- final PullMessageResponseHeader responseHeader = (PullMessageResponseHeader)response.readCustomHeader();
+ final PullMessageResponseHeader responseHeader = (PullMessageResponseHeader) response.readCustomHeader();
final PullMessageRequestHeader requestHeader =
- (PullMessageRequestHeader)request.decodeCommandCustomHeader(PullMessageRequestHeader.class);
+ (PullMessageRequestHeader) request.decodeCommandCustomHeader(PullMessageRequestHeader.class);
final FilterContext filterContext = new FilterContext();
filterContext.setConsumerGroup(requestHeader.getConsumerGroup());
@@ -331,10 +331,10 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
if (bodyLength > 0)
msgStoreItemMemory.put(msgInner.getBody());
// 16 TOPIC
- msgStoreItemMemory.put((byte)topicLength);
+ msgStoreItemMemory.put((byte) topicLength);
msgStoreItemMemory.put(topicData);
// 17 PROPERTIES
- msgStoreItemMemory.putShort((short)propertiesLength);
+ msgStoreItemMemory.putShort((short) propertiesLength);
if (propertiesLength > 0)
msgStoreItemMemory.put(propertiesData);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
index 0eb9a52..eb1afc8 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
@@ -102,7 +102,7 @@ public class NamesrvStartup {
System.exit(-2);
}
- LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory();
+ LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessor.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessor.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessor.java
index 95410fa..d66b3e8 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessor.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessor.java
@@ -53,7 +53,7 @@ public class ClusterTestRequestProcessor extends DefaultRequestProcessor {
public RemotingCommand getRouteInfoByTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetRouteInfoRequestHeader requestHeader =
- (GetRouteInfoRequestHeader)request.decodeCommandCustomHeader(GetRouteInfoRequestHeader.class);
+ (GetRouteInfoRequestHeader) request.decodeCommandCustomHeader(GetRouteInfoRequestHeader.class);
TopicRouteData topicRouteData = this.namesrvController.getRouteInfoManager().pickupTopicRouteData(requestHeader.getTopic());
if (topicRouteData != null) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java
index 0135274..213b096 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java
@@ -127,7 +127,7 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
public RemotingCommand putKVConfig(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final PutKVConfigRequestHeader requestHeader =
- (PutKVConfigRequestHeader)request.decodeCommandCustomHeader(PutKVConfigRequestHeader.class);
+ (PutKVConfigRequestHeader) request.decodeCommandCustomHeader(PutKVConfigRequestHeader.class);
this.namesrvController.getKvConfigManager().putKVConfig(
requestHeader.getNamespace(),
@@ -142,9 +142,9 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
public RemotingCommand getKVConfig(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(GetKVConfigResponseHeader.class);
- final GetKVConfigResponseHeader responseHeader = (GetKVConfigResponseHeader)response.readCustomHeader();
+ final GetKVConfigResponseHeader responseHeader = (GetKVConfigResponseHeader) response.readCustomHeader();
final GetKVConfigRequestHeader requestHeader =
- (GetKVConfigRequestHeader)request.decodeCommandCustomHeader(GetKVConfigRequestHeader.class);
+ (GetKVConfigRequestHeader) request.decodeCommandCustomHeader(GetKVConfigRequestHeader.class);
String value = this.namesrvController.getKvConfigManager().getKVConfig(
requestHeader.getNamespace(),
@@ -166,7 +166,7 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
public RemotingCommand deleteKVConfig(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final DeleteKVConfigRequestHeader requestHeader =
- (DeleteKVConfigRequestHeader)request.decodeCommandCustomHeader(DeleteKVConfigRequestHeader.class);
+ (DeleteKVConfigRequestHeader) request.decodeCommandCustomHeader(DeleteKVConfigRequestHeader.class);
this.namesrvController.getKvConfigManager().deleteKVConfig(
requestHeader.getNamespace(),
@@ -181,9 +181,9 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
public RemotingCommand registerBrokerWithFilterServer(ChannelHandlerContext ctx, RemotingCommand request)
throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterBrokerResponseHeader.class);
- final RegisterBrokerResponseHeader responseHeader = (RegisterBrokerResponseHeader)response.readCustomHeader();
+ final RegisterBrokerResponseHeader responseHeader = (RegisterBrokerResponseHeader) response.readCustomHeader();
final RegisterBrokerRequestHeader requestHeader =
- (RegisterBrokerRequestHeader)request.decodeCommandCustomHeader(RegisterBrokerRequestHeader.class);
+ (RegisterBrokerRequestHeader) request.decodeCommandCustomHeader(RegisterBrokerRequestHeader.class);
RegisterBrokerBody registerBrokerBody = new RegisterBrokerBody();
@@ -217,9 +217,9 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
public RemotingCommand registerBroker(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterBrokerResponseHeader.class);
- final RegisterBrokerResponseHeader responseHeader = (RegisterBrokerResponseHeader)response.readCustomHeader();
+ final RegisterBrokerResponseHeader responseHeader = (RegisterBrokerResponseHeader) response.readCustomHeader();
final RegisterBrokerRequestHeader requestHeader =
- (RegisterBrokerRequestHeader)request.decodeCommandCustomHeader(RegisterBrokerRequestHeader.class);
+ (RegisterBrokerRequestHeader) request.decodeCommandCustomHeader(RegisterBrokerRequestHeader.class);
TopicConfigSerializeWrapper topicConfigWrapper;
if (request.getBody() != null) {
@@ -254,7 +254,7 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
public RemotingCommand unregisterBroker(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final UnRegisterBrokerRequestHeader requestHeader =
- (UnRegisterBrokerRequestHeader)request.decodeCommandCustomHeader(UnRegisterBrokerRequestHeader.class);
+ (UnRegisterBrokerRequestHeader) request.decodeCommandCustomHeader(UnRegisterBrokerRequestHeader.class);
this.namesrvController.getRouteInfoManager().unregisterBroker(
requestHeader.getClusterName(),
@@ -270,7 +270,7 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
public RemotingCommand getRouteInfoByTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetRouteInfoRequestHeader requestHeader =
- (GetRouteInfoRequestHeader)request.decodeCommandCustomHeader(GetRouteInfoRequestHeader.class);
+ (GetRouteInfoRequestHeader) request.decodeCommandCustomHeader(GetRouteInfoRequestHeader.class);
TopicRouteData topicRouteData = this.namesrvController.getRouteInfoManager().pickupTopicRouteData(requestHeader.getTopic());
@@ -308,9 +308,9 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
private RemotingCommand wipeWritePermOfBroker(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(WipeWritePermOfBrokerResponseHeader.class);
- final WipeWritePermOfBrokerResponseHeader responseHeader = (WipeWritePermOfBrokerResponseHeader)response.readCustomHeader();
+ final WipeWritePermOfBrokerResponseHeader responseHeader = (WipeWritePermOfBrokerResponseHeader) response.readCustomHeader();
final WipeWritePermOfBrokerRequestHeader requestHeader =
- (WipeWritePermOfBrokerRequestHeader)request.decodeCommandCustomHeader(WipeWritePermOfBrokerRequestHeader.class);
+ (WipeWritePermOfBrokerRequestHeader) request.decodeCommandCustomHeader(WipeWritePermOfBrokerRequestHeader.class);
int wipeTopicCnt = this.namesrvController.getRouteInfoManager().wipeWritePermOfBrokerByLock(requestHeader.getBrokerName());
@@ -339,7 +339,7 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
private RemotingCommand deleteTopicInNamesrv(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final DeleteTopicInNamesrvRequestHeader requestHeader =
- (DeleteTopicInNamesrvRequestHeader)request.decodeCommandCustomHeader(DeleteTopicInNamesrvRequestHeader.class);
+ (DeleteTopicInNamesrvRequestHeader) request.decodeCommandCustomHeader(DeleteTopicInNamesrvRequestHeader.class);
this.namesrvController.getRouteInfoManager().deleteTopic(requestHeader.getTopic());
@@ -351,7 +351,7 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
private RemotingCommand getKVListByNamespace(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetKVListByNamespaceRequestHeader requestHeader =
- (GetKVListByNamespaceRequestHeader)request.decodeCommandCustomHeader(GetKVListByNamespaceRequestHeader.class);
+ (GetKVListByNamespaceRequestHeader) request.decodeCommandCustomHeader(GetKVListByNamespaceRequestHeader.class);
byte[] jsonValue = this.namesrvController.getKvConfigManager().getKVListByNamespace(
requestHeader.getNamespace());
@@ -370,7 +370,7 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
private RemotingCommand getTopicsByCluster(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetTopicsByClusterRequestHeader requestHeader =
- (GetTopicsByClusterRequestHeader)request.decodeCommandCustomHeader(GetTopicsByClusterRequestHeader.class);
+ (GetTopicsByClusterRequestHeader) request.decodeCommandCustomHeader(GetTopicsByClusterRequestHeader.class);
byte[] body = this.namesrvController.getRouteInfoManager().getTopicsByCluster(requestHeader.getCluster());
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
index e440e61..95dca3a 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
@@ -385,7 +385,7 @@ public class RouteInfoManager {
if (null != brokerData) {
BrokerData brokerDataClone = new BrokerData();
brokerDataClone.setBrokerName(brokerData.getBrokerName());
- brokerDataClone.setBrokerAddrs((HashMap<Long, String>)brokerData
+ brokerDataClone.setBrokerAddrs((HashMap<Long, String>) brokerData
.getBrokerAddrs().clone());
brokerDataList.add(brokerDataClone);
foundBrokerData = true;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index f74b5e2..76acc20 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,7 +16,7 @@
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
@@ -309,7 +309,7 @@
<id>verify</id>
<phase>verify</phase>
<configuration>
- <configLocation>checkstyle/checkstyle.xml</configLocation>
+ <configLocation>style/rmq_checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java
index 8d189e7..4fb4ed6 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java
@@ -67,7 +67,7 @@ public class RemotingHelper {
socketChannel.configureBlocking(true);
//bugfix http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4614802
- socketChannel.socket().setSoTimeout((int)timeoutMillis);
+ socketChannel.socket().setSoTimeout((int) timeoutMillis);
ByteBuffer byteBufferRequest = request.encode();
while (byteBufferRequest.hasRemaining()) {
@@ -168,7 +168,7 @@ public class RemotingHelper {
if (null == channel) {
return "";
}
- final InetSocketAddress remote = (InetSocketAddress)channel.remoteAddress();
+ final InetSocketAddress remote = (InetSocketAddress) channel.remoteAddress();
if (remote != null) {
return remote.getAddress().getHostName();
}
@@ -188,7 +188,7 @@ public class RemotingHelper {
public static String parseSocketAddressName(SocketAddress socketAddress) {
- final InetSocketAddress addrs = (InetSocketAddress)socketAddress;
+ final InetSocketAddress addrs = (InetSocketAddress) socketAddress;
if (addrs != null) {
return addrs.getAddress().getHostName();
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingUtil.java
----------------------------------------------------------------------
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 bcc2232..5589c04 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
@@ -67,7 +67,7 @@ public class RemotingUtil {
try {
final Method method = providerClazz.getMethod("provider");
if (method != null) {
- final SelectorProvider selectorProvider = (SelectorProvider)method.invoke(null);
+ final SelectorProvider selectorProvider = (SelectorProvider) method.invoke(null);
if (selectorProvider != null) {
result = selectorProvider.openSelector();
}
@@ -155,7 +155,7 @@ public class RemotingUtil {
public static String socketAddress2String(final SocketAddress addr) {
StringBuilder sb = new StringBuilder();
- InetSocketAddress inetSocketAddress = (InetSocketAddress)addr;
+ InetSocketAddress inetSocketAddress = (InetSocketAddress) addr;
sb.append(inetSocketAddress.getAddress().getHostAddress());
sb.append(":");
sb.append(inetSocketAddress.getPort());
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java
index 9cccaaf..62b26ba 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java
@@ -21,8 +21,6 @@ import org.slf4j.LoggerFactory;
/**
* Base class for background thread
- *
- *
*/
public abstract class ServiceThread implements Runnable {
private static final Logger STLOG = LoggerFactory.getLogger(RemotingHelper.ROCKETMQ_REMOTING);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
index 73d7f2b..106e55c 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
@@ -42,7 +42,7 @@ public class NettyDecoder extends LengthFieldBasedFrameDecoder {
public Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
ByteBuf frame = null;
try {
- frame = (ByteBuf)super.decode(ctx, in);
+ frame = (ByteBuf) super.decode(ctx, in);
if (null == frame) {
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
index db7815a..cd8ef97 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
@@ -637,7 +637,7 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof IdleStateEvent) {
- IdleStateEvent evnet = (IdleStateEvent)evt;
+ IdleStateEvent evnet = (IdleStateEvent) evt;
if (evnet.state().equals(IdleState.ALL_IDLE)) {
final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ctx.channel());
log.warn("NETTY CLIENT PIPELINE: IDLE exception [{}]", remoteAddress);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
index f109086..58ba617 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
@@ -171,7 +171,7 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
try {
ChannelFuture sync = this.serverBootstrap.bind().sync();
- InetSocketAddress addr = (InetSocketAddress)sync.channel().localAddress();
+ InetSocketAddress addr = (InetSocketAddress) sync.channel().localAddress();
this.port = addr.getPort();
} catch (InterruptedException e1) {
throw new RuntimeException("this.serverBootstrap.bind().sync() InterruptedException", e1);
@@ -337,7 +337,7 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof IdleStateEvent) {
- IdleStateEvent evnet = (IdleStateEvent)evt;
+ IdleStateEvent evnet = (IdleStateEvent) evt;
if (evnet.state().equals(IdleState.ALL_IDLE)) {
final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ctx.channel());
log.warn("NETTY SERVER PIPELINE: IDLE exception [{}]", remoteAddress);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java
index c6251e9..020124b 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java
@@ -21,8 +21,6 @@ import org.apache.rocketmq.remoting.protocol.RemotingCommand;
/**
* Common remoting command processor
- *
- *
*/
public interface NettyRequestProcessor {
RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request)
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
index f69fded..8424da6 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
@@ -133,6 +133,6 @@ public class NettyServerConfig implements Cloneable {
@Override
public Object clone() throws CloneNotSupportedException {
- return (NettyServerConfig)super.clone();
+ return (NettyServerConfig) super.clone();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/RequestTask.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/RequestTask.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/RequestTask.java
index 0443b43..d1fbbfe 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/RequestTask.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/RequestTask.java
@@ -36,7 +36,7 @@ public class RequestTask implements Runnable {
@Override
public int hashCode() {
int result = runnable != null ? runnable.hashCode() : 0;
- result = 31 * result + (int)(getCreateTimestamp() ^ (getCreateTimestamp() >>> 32));
+ result = 31 * result + (int) (getCreateTimestamp() ^ (getCreateTimestamp() >>> 32));
result = 31 * result + (channel != null ? channel.hashCode() : 0);
result = 31 * result + (request != null ? request.hashCode() : 0);
result = 31 * result + (isStopRun() ? 1 : 0);
@@ -50,7 +50,7 @@ public class RequestTask implements Runnable {
if (!(o instanceof RequestTask))
return false;
- final RequestTask that = (RequestTask)o;
+ final RequestTask that = (RequestTask) o;
if (getCreateTimestamp() != that.getCreateTimestamp())
return false;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/LanguageCode.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/LanguageCode.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/LanguageCode.java
index bdb02c6..cc5e8ec 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/LanguageCode.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/LanguageCode.java
@@ -18,15 +18,15 @@
package org.apache.rocketmq.remoting.protocol;
public enum LanguageCode {
- JAVA((byte)0),
- CPP((byte)1),
- DOTNET((byte)2),
- PYTHON((byte)3),
- DELPHI((byte)4),
- ERLANG((byte)5),
- RUBY((byte)6),
- OTHER((byte)7),
- HTTP((byte)8);
+ JAVA((byte) 0),
+ CPP((byte) 1),
+ DOTNET((byte) 2),
+ PYTHON((byte) 3),
+ DELPHI((byte) 4),
+ ERLANG((byte) 5),
+ RUBY((byte) 6),
+ OTHER((byte) 7),
+ HTTP((byte) 8);
private byte code;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
index 6b253dc..cffa072 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
@@ -195,7 +195,7 @@ public class RemotingCommand {
}
public static SerializeType getProtocolType(int source) {
- return SerializeType.valueOf((byte)((source >> 24) & 0xFF));
+ return SerializeType.valueOf((byte) ((source >> 24) & 0xFF));
}
public static int createNewRequestId() {
@@ -223,9 +223,9 @@ public class RemotingCommand {
byte[] result = new byte[4];
result[0] = type.getCode();
- result[1] = (byte)((source >> 16) & 0xFF);
- result[2] = (byte)((source >> 8) & 0xFF);
- result[3] = (byte)(source & 0xFF);
+ result[1] = (byte) ((source >> 16) & 0xFF);
+ result[2] = (byte) ((source >> 8) & 0xFF);
+ result[3] = (byte) (source & 0xFF);
return result;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java
index 64b37db..b773c1d 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java
@@ -51,11 +51,11 @@ public class RocketMQSerializable {
// ################### content
ByteBuffer headerBuffer = ByteBuffer.allocate(totalLen);
// int code(~32767)
- headerBuffer.putShort((short)cmd.getCode());
+ headerBuffer.putShort((short) cmd.getCode());
// LanguageCode language
headerBuffer.put(cmd.getLanguage().getCode());
// int version(~32767)
- headerBuffer.putShort((short)cmd.getVersion());
+ headerBuffer.putShort((short) cmd.getVersion());
// int opaque
headerBuffer.putInt(cmd.getOpaque());
// int flag
@@ -109,7 +109,7 @@ public class RocketMQSerializable {
key = entry.getKey().getBytes(RemotingSerializable.CHARSET_UTF8);
val = entry.getValue().getBytes(RemotingSerializable.CHARSET_UTF8);
- content.putShort((short)key.length);
+ content.putShort((short) key.length);
content.put(key);
content.putInt(val.length);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/SerializeType.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/SerializeType.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/SerializeType.java
index 6bfd42c..4ca6357 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/SerializeType.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/SerializeType.java
@@ -18,8 +18,8 @@
package org.apache.rocketmq.remoting.protocol;
public enum SerializeType {
- JSON((byte)0),
- ROCKETMQ((byte)1);
+ JSON((byte) 0),
+ ROCKETMQ((byte) 1);
private byte code;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
index 984ecd1..db165c2 100644
--- a/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
+++ b/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: MixTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
+ *
+ * $Id: MixTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
index 15a9aa3..1cfb8bc 100644
--- a/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
+++ b/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: NettyRPCTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
+ *
+ * $Id: NettyRPCTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
@@ -37,11 +39,16 @@ import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
import org.apache.rocketmq.remoting.netty.NettyServerConfig;
import org.apache.rocketmq.remoting.netty.ResponseFuture;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
public class NettyRPCTest {
+ private static RemotingServer remotingServer;
+ private static RemotingClient remotingClient;
+
public static RemotingServer createRemotingServer() throws InterruptedException {
NettyServerConfig config = new NettyServerConfig();
RemotingServer remotingServer = new NettyRemotingServer(config);
@@ -71,84 +78,70 @@ public class NettyRPCTest {
return client;
}
+ @BeforeClass
+ public static void initialize() throws InterruptedException {
+ remotingServer = createRemotingServer();
+ remotingClient = createRemotingClient();
+ }
+
+ @AfterClass
+ public static void destroy() {
+ remotingClient.shutdown();
+ remotingServer.shutdown();
+ }
+
@Test
public void test_RPC_Sync() throws InterruptedException, RemotingConnectException,
RemotingSendRequestException, RemotingTimeoutException {
- RemotingServer server = createRemotingServer();
- RemotingClient client = createRemotingClient();
for (int i = 0; i < 100; i++) {
TestRequestHeader requestHeader = new TestRequestHeader();
requestHeader.setCount(i);
requestHeader.setMessageTitle("HelloMessageTitle");
RemotingCommand request = RemotingCommand.createRequestCommand(0, requestHeader);
- RemotingCommand response = client.invokeSync("localhost:8888", request, 1000 * 3000);
+ RemotingCommand response = remotingClient.invokeSync("localhost:8888", request, 1000 * 3000);
System.out.println("invoke result = " + response);
assertTrue(response != null);
}
-
- client.shutdown();
- server.shutdown();
- System.out.println("-----------------------------------------------------------------");
}
@Test
public void test_RPC_Oneway() throws InterruptedException, RemotingConnectException,
RemotingTimeoutException, RemotingTooMuchRequestException, RemotingSendRequestException {
- RemotingServer server = createRemotingServer();
- RemotingClient client = createRemotingClient();
for (int i = 0; i < 100; i++) {
RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
request.setRemark(String.valueOf(i));
- client.invokeOneway("localhost:8888", request, 1000 * 3);
+ remotingClient.invokeOneway("localhost:8888", request, 1000 * 3);
}
-
- client.shutdown();
- server.shutdown();
- System.out.println("-----------------------------------------------------------------");
}
@Test
public void test_RPC_Async() throws InterruptedException, RemotingConnectException,
RemotingTimeoutException, RemotingTooMuchRequestException, RemotingSendRequestException {
- RemotingServer server = createRemotingServer();
- RemotingClient client = createRemotingClient();
for (int i = 0; i < 100; i++) {
RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
request.setRemark(String.valueOf(i));
- client.invokeAsync("localhost:8888", request, 1000 * 3, new InvokeCallback() {
+ remotingClient.invokeAsync("localhost:8888", request, 1000 * 3, new InvokeCallback() {
@Override
public void operationComplete(ResponseFuture responseFuture) {
System.out.println(responseFuture.getResponseCommand());
}
});
}
-
- Thread.sleep(1000 * 3);
-
- client.shutdown();
- server.shutdown();
- System.out.println("-----------------------------------------------------------------");
}
@Test
public void test_server_call_client() throws InterruptedException, RemotingConnectException,
RemotingSendRequestException, RemotingTimeoutException {
- final RemotingServer server = createRemotingServer();
- final RemotingClient client = createRemotingClient();
- server.registerProcessor(0, new NettyRequestProcessor() {
+ remotingServer.registerProcessor(0, new NettyRequestProcessor() {
@Override
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) {
try {
- return server.invokeSync(ctx.channel(), request, 1000 * 10);
- } catch (InterruptedException e) {
- e.printStackTrace();
- } catch (RemotingSendRequestException e) {
- e.printStackTrace();
- } catch (RemotingTimeoutException e) {
+ return remotingServer.invokeSync(ctx.channel(), request, 1000 * 10);
+ } catch (InterruptedException | RemotingSendRequestException | RemotingTimeoutException e) {
e.printStackTrace();
}
@@ -161,7 +154,7 @@ public class NettyRPCTest {
}
}, Executors.newCachedThreadPool());
- client.registerProcessor(0, new NettyRequestProcessor() {
+ remotingClient.registerProcessor(0, new NettyRequestProcessor() {
@Override
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) {
System.out.println("client receive server request = " + request);
@@ -177,14 +170,10 @@ public class NettyRPCTest {
for (int i = 0; i < 3; i++) {
RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
- RemotingCommand response = client.invokeSync("localhost:8888", request, 1000 * 3);
+ RemotingCommand response = remotingClient.invokeSync("localhost:8888", request, 1000 * 3);
System.out.println("invoke result = " + response);
assertTrue(response != null);
}
-
- client.shutdown();
- server.shutdown();
- System.out.println("-----------------------------------------------------------------");
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java b/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
index 27b957f..f33af76 100644
--- a/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
@@ -306,7 +306,7 @@ public class AllocateMappedFileService extends ServiceThread {
return false;
if (getClass() != obj.getClass())
return false;
- AllocateRequest other = (AllocateRequest)obj;
+ AllocateRequest other = (AllocateRequest) obj;
if (filePath == null) {
if (other.filePath != null)
return false;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java b/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java
index 6d158d3..59c9a38 100644
--- a/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java
+++ b/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java
@@ -20,8 +20,6 @@ import java.nio.ByteBuffer;
/**
* Write messages callback interface
- *
- *
*/
public interface AppendMessageCallback {
@@ -31,7 +29,6 @@ public interface AppendMessageCallback {
* @param byteBuffer
* @param maxBlank
* @param msg
- *
* @return How many bytes to write
*/
AppendMessageResult doAppend(final long fileFromOffset, final ByteBuffer byteBuffer,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java b/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java
index 965097f..1fda351 100644
--- a/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java
@@ -18,7 +18,6 @@ package org.apache.rocketmq.store;
/**
* When write a message to the commit log, returns results
- *
*/
public class AppendMessageResult {
// Return code
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java b/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java
index 39cf9fa..30725f3 100644
--- a/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java
+++ b/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java
@@ -18,8 +18,6 @@ package org.apache.rocketmq.store;
/**
* When write a message to the commit log, returns code
- *
- *
*/
public enum AppendMessageStatus {
PUT_OK,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/CommitLog.java b/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
index 17625f4..06df287 100644
--- a/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
+++ b/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
@@ -143,7 +143,7 @@ public class CommitLog {
int mappedFileSize = this.defaultMessageStore.getMessageStoreConfig().getMapedFileSizeCommitLog();
MappedFile mappedFile = this.mappedFileQueue.findMappedFileByOffset(offset, returnFirstOnNotFound);
if (mappedFile != null) {
- int pos = (int)(offset % mappedFileSize);
+ int pos = (int) (offset % mappedFileSize);
SelectMappedBufferResult result = mappedFile.selectMappedBuffer(pos);
return result;
}
@@ -637,7 +637,7 @@ public class CommitLog {
// Synchronization flush
if (FlushDiskType.SYNC_FLUSH == this.defaultMessageStore.getMessageStoreConfig().getFlushDiskType()) {
- final GroupCommitService service = (GroupCommitService)this.flushCommitLogService;
+ final GroupCommitService service = (GroupCommitService) this.flushCommitLogService;
if (msg.isWaitStoreMsgOK()) {
request = new GroupCommitRequest(result.getWroteOffset() + result.getWroteBytes());
service.putRequest(request);
@@ -729,7 +729,7 @@ public class CommitLog {
int mappedFileSize = this.defaultMessageStore.getMessageStoreConfig().getMapedFileSizeCommitLog();
MappedFile mappedFile = this.mappedFileQueue.findMappedFileByOffset(offset, offset == 0);
if (mappedFile != null) {
- int pos = (int)(offset % mappedFileSize);
+ int pos = (int) (offset % mappedFileSize);
return mappedFile.selectMappedBuffer(pos, size);
}
return null;
@@ -1150,7 +1150,7 @@ public class CommitLog {
final byte[] propertiesData =
msgInner.getPropertiesString() == null ? null : msgInner.getPropertiesString().getBytes(MessageDecoder.CHARSET_UTF8);
- final short propertiesLength = propertiesData == null ? 0 : (short)propertiesData.length;
+ final short propertiesLength = propertiesData == null ? 0 : (short) propertiesData.length;
if (propertiesLength > Short.MAX_VALUE) {
log.warn("putMessage message properties length too long. length={}", propertiesData.length);
@@ -1226,7 +1226,7 @@ public class CommitLog {
if (bodyLength > 0)
this.msgStoreItemMemory.put(msgInner.getBody());
// 16 TOPIC
- this.msgStoreItemMemory.put((byte)topicLength);
+ this.msgStoreItemMemory.put((byte) topicLength);
this.msgStoreItemMemory.put(topicData);
// 17 PROPERTIES
this.msgStoreItemMemory.putShort(propertiesLength);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java b/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
index d9e2f03..a060638 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
@@ -131,7 +131,7 @@ public class ConsumeQueue {
if (mappedFile != null) {
long offset = 0;
int low =
- minLogicOffset > mappedFile.getFileFromOffset() ? (int)(minLogicOffset - mappedFile
+ minLogicOffset > mappedFile.getFileFromOffset() ? (int) (minLogicOffset - mappedFile
.getFileFromOffset()) : 0;
int high = 0;
int midOffset = -1, targetOffset = -1, leftOffset = -1, rightOffset = -1;
@@ -407,7 +407,7 @@ public class ConsumeQueue {
byteBuffer.putInt(Integer.MAX_VALUE);
byteBuffer.putLong(0L);
- int until = (int)(untilWhere % this.mappedFileQueue.getMappedFileSize());
+ int until = (int) (untilWhere % this.mappedFileQueue.getMappedFileSize());
for (int i = 0; i < until; i += CQ_STORE_UNIT_SIZE) {
mappedFile.appendMessage(byteBuffer.array());
}
@@ -419,7 +419,7 @@ public class ConsumeQueue {
if (offset >= this.getMinLogicOffset()) {
MappedFile mappedFile = this.mappedFileQueue.findMappedFileByOffset(offset);
if (mappedFile != null) {
- SelectMappedBufferResult result = mappedFile.selectMappedBuffer((int)(offset % mappedFileSize));
+ SelectMappedBufferResult result = mappedFile.selectMappedBuffer((int) (offset % mappedFileSize));
return result;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
index 7e3af19..6d182e6 100644
--- a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
+++ b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
@@ -459,7 +459,7 @@ public class DefaultMessageStore implements MessageStore {
nextBeginOffset = offset + (i / ConsumeQueue.CQ_STORE_UNIT_SIZE);
long diff = maxOffsetPy - maxPhyOffsetPulling;
- long memory = (long)(StoreUtil.TOTAL_PHYSICAL_MEMORY_SIZE
+ long memory = (long) (StoreUtil.TOTAL_PHYSICAL_MEMORY_SIZE
* (this.messageStoreConfig.getAccessMessageInMemoryMaxRatio() / 100.0));
getResult.setSuggestPullingFromSlave(diff > memory);
} finally {
@@ -1016,7 +1016,7 @@ public class DefaultMessageStore implements MessageStore {
}
private boolean checkInDiskByCommitOffset(long offsetPy, long maxOffsetPy) {
- long memory = (long)(StoreUtil.TOTAL_PHYSICAL_MEMORY_SIZE * (this.messageStoreConfig.getAccessMessageInMemoryMaxRatio() / 100.0));
+ long memory = (long) (StoreUtil.TOTAL_PHYSICAL_MEMORY_SIZE * (this.messageStoreConfig.getAccessMessageInMemoryMaxRatio() / 100.0));
return (maxOffsetPy - offsetPy) > memory;
}
@@ -1288,6 +1288,24 @@ public class DefaultMessageStore implements MessageStore {
return brokerStatsManager;
}
+ public int remainTransientStoreBufferNumbs() {
+ return this.transientStorePool.remainBufferNumbs();
+ }
+
+ @Override
+ public boolean isTransientStorePoolDeficient() {
+ return remainTransientStoreBufferNumbs() == 0;
+ }
+
+ public void unlockMappedFile(final MappedFile mappedFile) {
+ this.scheduledExecutorService.schedule(new Runnable() {
+ @Override
+ public void run() {
+ mappedFile.munlock();
+ }
+ }, 6, TimeUnit.SECONDS);
+ }
+
class CleanCommitLogService {
private final static int MAX_MANUAL_DELETE_FILE_TIMES = 20;
@@ -1565,6 +1583,10 @@ public class DefaultMessageStore implements MessageStore {
return reputFromOffset;
}
+ public void setReputFromOffset(long reputFromOffset) {
+ this.reputFromOffset = reputFromOffset;
+ }
+
@Override
public void shutdown() {
for (int i = 0; i < 50 && this.isCommitLogAvailable(); i++) {
@@ -1582,10 +1604,6 @@ public class DefaultMessageStore implements MessageStore {
super.shutdown();
}
- public void setReputFromOffset(long reputFromOffset) {
- this.reputFromOffset = reputFromOffset;
- }
-
public long behind() {
return DefaultMessageStore.this.commitLog.getMaxOffset() - this.reputFromOffset;
}
@@ -1683,22 +1701,4 @@ public class DefaultMessageStore implements MessageStore {
}
}
-
- public int remainTransientStoreBufferNumbs() {
- return this.transientStorePool.remainBufferNumbs();
- }
-
- @Override
- public boolean isTransientStorePoolDeficient() {
- return remainTransientStoreBufferNumbs() == 0;
- }
-
- public void unlockMappedFile(final MappedFile mappedFile) {
- this.scheduledExecutorService.schedule(new Runnable() {
- @Override
- public void run() {
- mappedFile.munlock();
- }
- }, 6, TimeUnit.SECONDS);
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java b/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java
index b7d33f3..3c7e007 100644
--- a/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java
@@ -86,7 +86,7 @@ public class GetMessageResult {
this.messageMapedList.add(mapedBuffer);
this.messageBufferList.add(mapedBuffer.getByteBuffer());
this.bufferTotalSize += mapedBuffer.getSize();
- this.msgCount4Commercial += (int)Math.ceil(
+ this.msgCount4Commercial += (int) Math.ceil(
mapedBuffer.getSize() / BrokerStatsManager.SIZE_PER_COUNT);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/main/java/org/apache/rocketmq/store/MappedFile.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/MappedFile.java b/store/src/main/java/org/apache/rocketmq/store/MappedFile.java
index 6803ec9..7c2d703 100644
--- a/store/src/main/java/org/apache/rocketmq/store/MappedFile.java
+++ b/store/src/main/java/org/apache/rocketmq/store/MappedFile.java
@@ -125,7 +125,7 @@ public class MappedFile extends ReferenceResource {
}
}
- ByteBuffer viewedBuffer = (ByteBuffer)invoke(buffer, methodName);
+ ByteBuffer viewedBuffer = (ByteBuffer) invoke(buffer, methodName);
if (viewedBuffer == null)
return buffer;
else
@@ -463,7 +463,7 @@ public class MappedFile extends ReferenceResource {
int flush = 0;
long time = System.currentTimeMillis();
for (int i = 0, j = 0; i < this.fileSize; i += MappedFile.OS_PAGE_SIZE, j++) {
- byteBuffer.put(i, (byte)0);
+ byteBuffer.put(i, (byte) 0);
// force flush when flush disk type is sync
if (type == FlushDiskType.SYNC_FLUSH) {
if ((i / OS_PAGE_SIZE) - (flush / OS_PAGE_SIZE) >= pages) {
@@ -522,7 +522,7 @@ public class MappedFile extends ReferenceResource {
public void mlock() {
final long beginTime = System.currentTimeMillis();
- final long address = ((DirectBuffer)(this.mappedByteBuffer)).address();
+ final long address = ((DirectBuffer) (this.mappedByteBuffer)).address();
Pointer pointer = new Pointer(address);
{
int ret = LibC.INSTANCE.mlock(pointer, new NativeLong(this.fileSize));
@@ -537,7 +537,7 @@ public class MappedFile extends ReferenceResource {
public void munlock() {
final long beginTime = System.currentTimeMillis();
- final long address = ((DirectBuffer)(this.mappedByteBuffer)).address();
+ final long address = ((DirectBuffer) (this.mappedByteBuffer)).address();
Pointer pointer = new Pointer(address);
int ret = LibC.INSTANCE.munlock(pointer, new NativeLong(this.fileSize));
log.info("munlock {} {} {} ret = {} time consuming = {}", address, this.fileName, this.fileSize, ret, System.currentTimeMillis() - beginTime);
[83/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java b/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java
index 0fce69e..a9dadcc 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java
@@ -19,7 +19,6 @@ package org.apache.rocketmq.client.producer;
import com.alibaba.fastjson.JSON;
import org.apache.rocketmq.common.message.MessageQueue;
-
public class SendResult {
private SendStatus sendStatus;
private String msgId;
@@ -41,7 +40,8 @@ public class SendResult {
this.queueOffset = queueOffset;
}
- public SendResult(final SendStatus sendStatus, final String msgId, final MessageQueue messageQueue, final long queueOffset, final String transactionId, final String offsetMsgId, final String regionId) {
+ public SendResult(final SendStatus sendStatus, final String msgId, final MessageQueue messageQueue, final long queueOffset, final String transactionId,
+ final String offsetMsgId, final String regionId) {
this.sendStatus = sendStatus;
this.msgId = msgId;
this.messageQueue = messageQueue;
@@ -51,6 +51,14 @@ public class SendResult {
this.regionId = regionId;
}
+ public static String encoderSendResultToJson(final Object obj) {
+ return JSON.toJSONString(obj);
+ }
+
+ public static SendResult decoderSendResultFromJson(String json) {
+ return JSON.parseObject(json, SendResult.class);
+ }
+
public boolean isTraceOn() {
return traceOn;
}
@@ -67,59 +75,42 @@ public class SendResult {
this.regionId = regionId;
}
- public static String encoderSendResultToJson(final Object obj) {
- return JSON.toJSONString(obj);
- }
-
- public static SendResult decoderSendResultFromJson(String json) {
- return JSON.parseObject(json, SendResult.class);
- }
-
public String getMsgId() {
return msgId;
}
-
public void setMsgId(String msgId) {
this.msgId = msgId;
}
-
public SendStatus getSendStatus() {
return sendStatus;
}
-
public void setSendStatus(SendStatus sendStatus) {
this.sendStatus = sendStatus;
}
-
public MessageQueue getMessageQueue() {
return messageQueue;
}
-
public void setMessageQueue(MessageQueue messageQueue) {
this.messageQueue = messageQueue;
}
-
public long getQueueOffset() {
return queueOffset;
}
-
public void setQueueOffset(long queueOffset) {
this.queueOffset = queueOffset;
}
-
public String getTransactionId() {
return transactionId;
}
-
public void setTransactionId(String transactionId) {
this.transactionId = transactionId;
}
@@ -135,6 +126,6 @@ public class SendResult {
@Override
public String toString() {
return "SendResult [sendStatus=" + sendStatus + ", msgId=" + msgId + ", offsetMsgId=" + offsetMsgId + ", messageQueue=" + messageQueue
- + ", queueOffset=" + queueOffset + "]";
+ + ", queueOffset=" + queueOffset + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java b/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java
index a12c689..95a2711 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.producer;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java
index 6da0737..bf312aa 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java
@@ -6,19 +6,18 @@
* (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
+ * 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.
+ * 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.producer;
import org.apache.rocketmq.common.message.MessageExt;
-
public interface TransactionCheckListener {
LocalTransactionState checkLocalTransactionState(final MessageExt msg);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java
index b404216..1ea28e3 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.producer;
@@ -20,18 +20,15 @@ import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.RPCHook;
-
public class TransactionMQProducer extends DefaultMQProducer {
private TransactionCheckListener transactionCheckListener;
private int checkThreadPoolMinSize = 1;
private int checkThreadPoolMaxSize = 1;
private int checkRequestHoldMax = 2000;
-
public TransactionMQProducer() {
}
-
public TransactionMQProducer(final String producerGroup) {
super(producerGroup);
}
@@ -46,17 +43,15 @@ public class TransactionMQProducer extends DefaultMQProducer {
super.start();
}
-
@Override
public void shutdown() {
super.shutdown();
this.defaultMQProducerImpl.destroyTransactionEnv();
}
-
@Override
public TransactionSendResult sendMessageInTransaction(final Message msg,
- final LocalTransactionExecuter tranExecuter, final Object arg) throws MQClientException {
+ final LocalTransactionExecuter tranExecuter, final Object arg) throws MQClientException {
if (null == this.transactionCheckListener) {
throw new MQClientException("localTransactionBranchCheckListener is null", null);
}
@@ -64,42 +59,34 @@ public class TransactionMQProducer extends DefaultMQProducer {
return this.defaultMQProducerImpl.sendMessageInTransaction(msg, tranExecuter, arg);
}
-
public TransactionCheckListener getTransactionCheckListener() {
return transactionCheckListener;
}
-
public void setTransactionCheckListener(TransactionCheckListener transactionCheckListener) {
this.transactionCheckListener = transactionCheckListener;
}
-
public int getCheckThreadPoolMinSize() {
return checkThreadPoolMinSize;
}
-
public void setCheckThreadPoolMinSize(int checkThreadPoolMinSize) {
this.checkThreadPoolMinSize = checkThreadPoolMinSize;
}
-
public int getCheckThreadPoolMaxSize() {
return checkThreadPoolMaxSize;
}
-
public void setCheckThreadPoolMaxSize(int checkThreadPoolMaxSize) {
this.checkThreadPoolMaxSize = checkThreadPoolMaxSize;
}
-
public int getCheckRequestHoldMax() {
return checkRequestHoldMax;
}
-
public void setCheckRequestHoldMax(int checkRequestHoldMax) {
this.checkRequestHoldMax = checkRequestHoldMax;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java
index ca9e713..c2395ab 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java
@@ -6,29 +6,26 @@
* (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
+ * 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.
+ * 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.producer;
public class TransactionSendResult extends SendResult {
private LocalTransactionState localTransactionState;
-
public TransactionSendResult() {
}
-
public LocalTransactionState getLocalTransactionState() {
return localTransactionState;
}
-
public void setLocalTransactionState(LocalTransactionState localTransactionState) {
this.localTransactionState = localTransactionState;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java
index 15c7e55..3574039 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java
@@ -6,23 +6,21 @@
* (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
+ * 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.
+ * 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.producer.selector;
+import java.util.List;
import org.apache.rocketmq.client.producer.MessageQueueSelector;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageQueue;
-import java.util.List;
-
-
public class SelectMessageQueueByHash implements MessageQueueSelector {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java
index d2bf6f3..07f8b70 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java
@@ -6,39 +6,34 @@
* (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
+ * 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.
+ * 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.producer.selector;
+import java.util.List;
+import java.util.Set;
import org.apache.rocketmq.client.producer.MessageQueueSelector;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageQueue;
-import java.util.List;
-import java.util.Set;
-
-
public class SelectMessageQueueByMachineRoom implements MessageQueueSelector {
private Set<String> consumeridcs;
-
@Override
public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
return null;
}
-
public Set<String> getConsumeridcs() {
return consumeridcs;
}
-
public void setConsumeridcs(Set<String> consumeridcs) {
this.consumeridcs = consumeridcs;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java
index 38d04c1..685afc9 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java
@@ -6,28 +6,25 @@
* (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
+ * 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.
+ * 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.producer.selector;
+import java.util.List;
+import java.util.Random;
import org.apache.rocketmq.client.producer.MessageQueueSelector;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageQueue;
-import java.util.List;
-import java.util.Random;
-
-
public class SelectMessageQueueByRandoom implements MessageQueueSelector {
private Random random = new Random(System.currentTimeMillis());
-
@Override
public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
int value = random.nextInt();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/stat/ConsumerStatsManager.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/stat/ConsumerStatsManager.java b/client/src/main/java/org/apache/rocketmq/client/stat/ConsumerStatsManager.java
index 3234ada..c723951 100644
--- a/client/src/main/java/org/apache/rocketmq/client/stat/ConsumerStatsManager.java
+++ b/client/src/main/java/org/apache/rocketmq/client/stat/ConsumerStatsManager.java
@@ -6,17 +6,18 @@
* (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
+ * 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.
+ * 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.stat;
+import java.util.concurrent.ScheduledExecutorService;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.common.protocol.body.ConsumeStatus;
import org.apache.rocketmq.common.stats.StatsItemSet;
@@ -24,9 +25,6 @@ import org.apache.rocketmq.common.stats.StatsSnapshot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.concurrent.ScheduledExecutorService;
-
-
public class ConsumerStatsManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.CLIENT_LOGGER_NAME);
@@ -42,53 +40,45 @@ public class ConsumerStatsManager {
private final StatsItemSet topicAndGroupPullTPS;
private final StatsItemSet topicAndGroupPullRT;
-
public ConsumerStatsManager(final ScheduledExecutorService scheduledExecutorService) {
this.topicAndGroupConsumeOKTPS =
- new StatsItemSet(TOPIC_AND_GROUP_CONSUME_OK_TPS, scheduledExecutorService, log);
+ new StatsItemSet(TOPIC_AND_GROUP_CONSUME_OK_TPS, scheduledExecutorService, log);
this.topicAndGroupConsumeRT =
- new StatsItemSet(TOPIC_AND_GROUP_CONSUME_RT, scheduledExecutorService, log);
+ new StatsItemSet(TOPIC_AND_GROUP_CONSUME_RT, scheduledExecutorService, log);
this.topicAndGroupConsumeFailedTPS =
- new StatsItemSet(TOPIC_AND_GROUP_CONSUME_FAILED_TPS, scheduledExecutorService, log);
+ new StatsItemSet(TOPIC_AND_GROUP_CONSUME_FAILED_TPS, scheduledExecutorService, log);
this.topicAndGroupPullTPS = new StatsItemSet(TOPIC_AND_GROUP_PULL_TPS, scheduledExecutorService, log);
this.topicAndGroupPullRT = new StatsItemSet(TOPIC_AND_GROUP_PULL_RT, scheduledExecutorService, log);
}
-
public void start() {
}
-
public void shutdown() {
}
-
public void incPullRT(final String group, final String topic, final long rt) {
- this.topicAndGroupPullRT.addValue(topic + "@" + group, (int) rt, 1);
+ this.topicAndGroupPullRT.addValue(topic + "@" + group, (int)rt, 1);
}
-
public void incPullTPS(final String group, final String topic, final long msgs) {
- this.topicAndGroupPullTPS.addValue(topic + "@" + group, (int) msgs, 1);
+ this.topicAndGroupPullTPS.addValue(topic + "@" + group, (int)msgs, 1);
}
-
public void incConsumeRT(final String group, final String topic, final long rt) {
- this.topicAndGroupConsumeRT.addValue(topic + "@" + group, (int) rt, 1);
+ this.topicAndGroupConsumeRT.addValue(topic + "@" + group, (int)rt, 1);
}
-
public void incConsumeOKTPS(final String group, final String topic, final long msgs) {
- this.topicAndGroupConsumeOKTPS.addValue(topic + "@" + group, (int) msgs, 1);
+ this.topicAndGroupConsumeOKTPS.addValue(topic + "@" + group, (int)msgs, 1);
}
-
public void incConsumeFailedTPS(final String group, final String topic, final long msgs) {
- this.topicAndGroupConsumeFailedTPS.addValue(topic + "@" + group, (int) msgs, 1);
+ this.topicAndGroupConsumeFailedTPS.addValue(topic + "@" + group, (int)msgs, 1);
}
public ConsumeStatus consumeStatus(final String group, final String topic) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/resources/logback_rocketmq_client.xml
----------------------------------------------------------------------
diff --git a/client/src/main/resources/logback_rocketmq_client.xml b/client/src/main/resources/logback_rocketmq_client.xml
index a845ee4..94688ab 100644
--- a/client/src/main/resources/logback_rocketmq_client.xml
+++ b/client/src/main/resources/logback_rocketmq_client.xml
@@ -28,7 +28,7 @@
<maxIndex>${client.logFileMaxIndex}</maxIndex>
</rollingPolicy>
<triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>
<encoder>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/test/java/org/apache/rocketmq/client/ValidatorsTest.java
----------------------------------------------------------------------
diff --git a/client/src/test/java/org/apache/rocketmq/client/ValidatorsTest.java b/client/src/test/java/org/apache/rocketmq/client/ValidatorsTest.java
index a3daba5..d4530c0 100644
--- a/client/src/test/java/org/apache/rocketmq/client/ValidatorsTest.java
+++ b/client/src/test/java/org/apache/rocketmq/client/ValidatorsTest.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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;
@@ -20,7 +20,6 @@ package org.apache.rocketmq.client;
import org.apache.rocketmq.client.exception.MQClientException;
import org.junit.Test;
-
public class ValidatorsTest {
@Test
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/pom.xml
----------------------------------------------------------------------
diff --git a/common/pom.xml b/common/pom.xml
index ec95a76..b46d2d5 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -15,7 +15,7 @@
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.rocketmq</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java b/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java
index e11122a..aaaa0c1 100644
--- a/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java
+++ b/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java
@@ -16,14 +16,12 @@
*/
package org.apache.rocketmq.common;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import org.apache.rocketmq.common.annotation.ImportantField;
import org.apache.rocketmq.common.constant.PermName;
import org.apache.rocketmq.remoting.common.RemotingUtil;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-
public class BrokerConfig {
private String rocketmqHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV));
@ImportantField
@@ -87,7 +85,6 @@ public class BrokerConfig {
private boolean transferMsgByHeap = true;
private int maxDelayTime = 40;
-
private String regionId = MixAll.DEFAULT_TRACE_REGION_ID;
private int registerBrokerTimeoutMills = 6000;
@@ -102,6 +99,16 @@ public class BrokerConfig {
private boolean traceOn = true;
+ public static String localHostName() {
+ try {
+ return InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ }
+
+ return "DEFAULT_BROKER";
+ }
+
public boolean isTraceOn() {
return traceOn;
}
@@ -150,16 +157,6 @@ public class BrokerConfig {
this.slaveReadEnable = slaveReadEnable;
}
- public static String localHostName() {
- try {
- return InetAddress.getLocalHost().getHostName();
- } catch (UnknownHostException e) {
- e.printStackTrace();
- }
-
- return "DEFAULT_BROKER";
- }
-
public int getRegisterBrokerTimeoutMills() {
return registerBrokerTimeoutMills;
}
@@ -196,87 +193,70 @@ public class BrokerConfig {
return highSpeedMode;
}
-
public void setHighSpeedMode(final boolean highSpeedMode) {
this.highSpeedMode = highSpeedMode;
}
-
public String getRocketmqHome() {
return rocketmqHome;
}
-
public void setRocketmqHome(String rocketmqHome) {
this.rocketmqHome = rocketmqHome;
}
-
public String getBrokerName() {
return brokerName;
}
-
public void setBrokerName(String brokerName) {
this.brokerName = brokerName;
}
-
public int getBrokerPermission() {
return brokerPermission;
}
-
public void setBrokerPermission(int brokerPermission) {
this.brokerPermission = brokerPermission;
}
-
public int getDefaultTopicQueueNums() {
return defaultTopicQueueNums;
}
-
public void setDefaultTopicQueueNums(int defaultTopicQueueNums) {
this.defaultTopicQueueNums = defaultTopicQueueNums;
}
-
public boolean isAutoCreateTopicEnable() {
return autoCreateTopicEnable;
}
-
public void setAutoCreateTopicEnable(boolean autoCreateTopic) {
this.autoCreateTopicEnable = autoCreateTopic;
}
-
public String getBrokerClusterName() {
return brokerClusterName;
}
-
public void setBrokerClusterName(String brokerClusterName) {
this.brokerClusterName = brokerClusterName;
}
-
public String getBrokerIP1() {
return brokerIP1;
}
-
public void setBrokerIP1(String brokerIP1) {
this.brokerIP1 = brokerIP1;
}
-
public String getBrokerIP2() {
return brokerIP2;
}
-
public void setBrokerIP2(String brokerIP2) {
this.brokerIP2 = brokerIP2;
}
@@ -289,192 +269,154 @@ public class BrokerConfig {
this.sendMessageThreadPoolNums = sendMessageThreadPoolNums;
}
-
public int getPullMessageThreadPoolNums() {
return pullMessageThreadPoolNums;
}
-
public void setPullMessageThreadPoolNums(int pullMessageThreadPoolNums) {
this.pullMessageThreadPoolNums = pullMessageThreadPoolNums;
}
-
public int getAdminBrokerThreadPoolNums() {
return adminBrokerThreadPoolNums;
}
-
public void setAdminBrokerThreadPoolNums(int adminBrokerThreadPoolNums) {
this.adminBrokerThreadPoolNums = adminBrokerThreadPoolNums;
}
-
public int getFlushConsumerOffsetInterval() {
return flushConsumerOffsetInterval;
}
-
public void setFlushConsumerOffsetInterval(int flushConsumerOffsetInterval) {
this.flushConsumerOffsetInterval = flushConsumerOffsetInterval;
}
-
public int getFlushConsumerOffsetHistoryInterval() {
return flushConsumerOffsetHistoryInterval;
}
-
public void setFlushConsumerOffsetHistoryInterval(int flushConsumerOffsetHistoryInterval) {
this.flushConsumerOffsetHistoryInterval = flushConsumerOffsetHistoryInterval;
}
-
public boolean isClusterTopicEnable() {
return clusterTopicEnable;
}
-
public void setClusterTopicEnable(boolean clusterTopicEnable) {
this.clusterTopicEnable = clusterTopicEnable;
}
-
public String getNamesrvAddr() {
return namesrvAddr;
}
-
public void setNamesrvAddr(String namesrvAddr) {
this.namesrvAddr = namesrvAddr;
}
-
public long getBrokerId() {
return brokerId;
}
-
public void setBrokerId(long brokerId) {
this.brokerId = brokerId;
}
-
public boolean isAutoCreateSubscriptionGroup() {
return autoCreateSubscriptionGroup;
}
-
public void setAutoCreateSubscriptionGroup(boolean autoCreateSubscriptionGroup) {
this.autoCreateSubscriptionGroup = autoCreateSubscriptionGroup;
}
-
public boolean isRejectTransactionMessage() {
return rejectTransactionMessage;
}
-
public void setRejectTransactionMessage(boolean rejectTransactionMessage) {
this.rejectTransactionMessage = rejectTransactionMessage;
}
-
public boolean isFetchNamesrvAddrByAddressServer() {
return fetchNamesrvAddrByAddressServer;
}
-
public void setFetchNamesrvAddrByAddressServer(boolean fetchNamesrvAddrByAddressServer) {
this.fetchNamesrvAddrByAddressServer = fetchNamesrvAddrByAddressServer;
}
-
public int getSendThreadPoolQueueCapacity() {
return sendThreadPoolQueueCapacity;
}
-
public void setSendThreadPoolQueueCapacity(int sendThreadPoolQueueCapacity) {
this.sendThreadPoolQueueCapacity = sendThreadPoolQueueCapacity;
}
-
public int getPullThreadPoolQueueCapacity() {
return pullThreadPoolQueueCapacity;
}
-
public void setPullThreadPoolQueueCapacity(int pullThreadPoolQueueCapacity) {
this.pullThreadPoolQueueCapacity = pullThreadPoolQueueCapacity;
}
-
public boolean isBrokerTopicEnable() {
return brokerTopicEnable;
}
-
public void setBrokerTopicEnable(boolean brokerTopicEnable) {
this.brokerTopicEnable = brokerTopicEnable;
}
-
public int getFilterServerNums() {
return filterServerNums;
}
-
public void setFilterServerNums(int filterServerNums) {
this.filterServerNums = filterServerNums;
}
-
public boolean isLongPollingEnable() {
return longPollingEnable;
}
-
public void setLongPollingEnable(boolean longPollingEnable) {
this.longPollingEnable = longPollingEnable;
}
-
public boolean isNotifyConsumerIdsChangedEnable() {
return notifyConsumerIdsChangedEnable;
}
-
public void setNotifyConsumerIdsChangedEnable(boolean notifyConsumerIdsChangedEnable) {
this.notifyConsumerIdsChangedEnable = notifyConsumerIdsChangedEnable;
}
-
public long getShortPollingTimeMills() {
return shortPollingTimeMills;
}
-
public void setShortPollingTimeMills(long shortPollingTimeMills) {
this.shortPollingTimeMills = shortPollingTimeMills;
}
-
public int getClientManageThreadPoolNums() {
return clientManageThreadPoolNums;
}
-
public void setClientManageThreadPoolNums(int clientManageThreadPoolNums) {
this.clientManageThreadPoolNums = clientManageThreadPoolNums;
}
-
public boolean isCommercialEnable() {
return commercialEnable;
}
-
public void setCommercialEnable(final boolean commercialEnable) {
this.commercialEnable = commercialEnable;
}
@@ -507,7 +449,6 @@ public class BrokerConfig {
return maxDelayTime;
}
-
public void setMaxDelayTime(final int maxDelayTime) {
this.maxDelayTime = maxDelayTime;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/BrokerConfigSingleton.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/BrokerConfigSingleton.java b/common/src/main/java/org/apache/rocketmq/common/BrokerConfigSingleton.java
index fc73b71..1dae6d4 100644
--- a/common/src/main/java/org/apache/rocketmq/common/BrokerConfigSingleton.java
+++ b/common/src/main/java/org/apache/rocketmq/common/BrokerConfigSingleton.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java b/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java
index 1ade521..0510b08 100644
--- a/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java
+++ b/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java
@@ -6,27 +6,24 @@
* (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
+ * 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.
+ * 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.common;
+import java.io.IOException;
import org.apache.rocketmq.common.constant.LoggerName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-
-
public abstract class ConfigManager {
private static final Logger PLOG = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
-
public abstract String encode();
public boolean load() {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/Configuration.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/Configuration.java b/common/src/main/java/org/apache/rocketmq/common/Configuration.java
index 1f81ba6..5402057 100644
--- a/common/src/main/java/org/apache/rocketmq/common/Configuration.java
+++ b/common/src/main/java/org/apache/rocketmq/common/Configuration.java
@@ -6,19 +6,17 @@
* (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
+ * 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.
+ * 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.common;
-import org.slf4j.Logger;
-
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@@ -27,6 +25,7 @@ import java.util.List;
import java.util.Properties;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import org.slf4j.Logger;
public class Configuration {
@@ -135,7 +134,7 @@ public class Configuration {
// check
this.storePathField = object.getClass().getDeclaredField(fieldName);
assert this.storePathField != null
- && !Modifier.isStatic(this.storePathField.getModifiers());
+ && !Modifier.isStatic(this.storePathField.getModifiers());
this.storePathField.setAccessible(true);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
@@ -157,7 +156,7 @@ public class Configuration {
if (this.storePathFromConfig) {
try {
- realStorePath = (String) storePathField.get(this.storePathObject);
+ realStorePath = (String)storePathField.get(this.storePathObject);
} catch (IllegalAccessException e) {
log.error("getStorePath error, ", e);
}
@@ -172,6 +171,10 @@ public class Configuration {
return realStorePath;
}
+ public void setStorePath(final String storePath) {
+ this.storePath = storePath;
+ }
+
public void update(Properties properties) {
try {
readWriteLock.writeLock().lockInterruptibly();
@@ -276,10 +279,6 @@ public class Configuration {
return stringBuilder.toString();
}
- public void setStorePath(final String storePath) {
- this.storePath = storePath;
- }
-
private void merge(Properties from, Properties to) {
for (Object key : from.keySet()) {
Object fromObj = from.get(key), toObj = to.get(key);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java b/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java
index 23c27ac..c3e3372 100644
--- a/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java
+++ b/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java
@@ -22,62 +22,19 @@ import java.util.concurrent.locks.AbstractQueuedSynchronizer;
/**
* Add reset feature for @see java.util.concurrent.CountDownLatch2
- *
*/
public class CountDownLatch2 {
- /**
- * Synchronization control For CountDownLatch2.
- * Uses AQS state to represent count.
- */
- private static final class Sync extends AbstractQueuedSynchronizer {
- private static final long serialVersionUID = 4982264981922014374L;
-
- private final int startCount;
-
- Sync(int count) {
- this.startCount = count;
- setState(count);
- }
-
- int getCount() {
- return getState();
- }
-
- protected int tryAcquireShared(int acquires) {
- return (getState() == 0) ? 1 : -1;
- }
-
- protected boolean tryReleaseShared(int releases) {
- // Decrement count; signal when transition to zero
- for (;;) {
- int c = getState();
- if (c == 0)
- return false;
- int nextc = c - 1;
- if (compareAndSetState(c, nextc))
- return nextc == 0;
- }
- }
-
- protected void reset() {
- setState(startCount);
- }
- }
-
private final Sync sync;
/**
* Constructs a {@code CountDownLatch2} initialized with the given count.
*
- * @param count
- * the number of times {@link #countDown} must be invoked
- * before threads can pass through {@link #await}
- *
- * @throws IllegalArgumentException
- * if {@code count} is negative
+ * @param count the number of times {@link #countDown} must be invoked before threads can pass through {@link #await}
+ * @throws IllegalArgumentException if {@code count} is negative
*/
public CountDownLatch2(int count) {
- if (count < 0) throw new IllegalArgumentException("count < 0");
+ if (count < 0)
+ throw new IllegalArgumentException("count < 0");
this.sync = new Sync(count);
}
@@ -105,9 +62,7 @@ public class CountDownLatch2 {
* then {@link InterruptedException} is thrown and the current thread's
* interrupted status is cleared.
*
- * @throws InterruptedException
- * if the current thread is interrupted
- * while waiting
+ * @throws InterruptedException if the current thread is interrupted while waiting
*/
public void await() throws InterruptedException {
sync.acquireSharedInterruptibly(1);
@@ -147,20 +102,13 @@ public class CountDownLatch2 {
* is returned. If the time is less than or equal to zero, the method
* will not wait at all.
*
- * @param timeout
- * the maximum time to wait
- * @param unit
- * the time unit of the {@code timeout} argument
- *
- * @return {@code true} if the count reached zero and {@code false}
- * if the waiting time elapsed before the count reached zero
- *
- * @throws InterruptedException
- * if the current thread is interrupted
- * while waiting
+ * @param timeout the maximum time to wait
+ * @param unit the time unit of the {@code timeout} argument
+ * @return {@code true} if the count reached zero and {@code false} if the waiting time elapsed before the count reached zero
+ * @throws InterruptedException if the current thread is interrupted while waiting
*/
public boolean await(long timeout, TimeUnit unit)
- throws InterruptedException {
+ throws InterruptedException {
return sync.tryAcquireSharedNanos(1, unit.toNanos(timeout));
}
@@ -203,4 +151,43 @@ public class CountDownLatch2 {
public String toString() {
return super.toString() + "[Count = " + sync.getCount() + "]";
}
+
+ /**
+ * Synchronization control For CountDownLatch2.
+ * Uses AQS state to represent count.
+ */
+ private static final class Sync extends AbstractQueuedSynchronizer {
+ private static final long serialVersionUID = 4982264981922014374L;
+
+ private final int startCount;
+
+ Sync(int count) {
+ this.startCount = count;
+ setState(count);
+ }
+
+ int getCount() {
+ return getState();
+ }
+
+ protected int tryAcquireShared(int acquires) {
+ return (getState() == 0) ? 1 : -1;
+ }
+
+ protected boolean tryReleaseShared(int releases) {
+ // Decrement count; signal when transition to zero
+ for (; ; ) {
+ int c = getState();
+ if (c == 0)
+ return false;
+ int nextc = c - 1;
+ if (compareAndSetState(c, nextc))
+ return nextc == 0;
+ }
+ }
+
+ protected void reset() {
+ setState(startCount);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/DataVersion.java b/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
index 1bb223f..f3e4615 100644
--- a/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
+++ b/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
@@ -6,73 +6,67 @@
* (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
+ * 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.
+ * 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.common;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.concurrent.atomic.AtomicLong;
-
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
public class DataVersion extends RemotingSerializable {
private long timestatmp = System.currentTimeMillis();
private AtomicLong counter = new AtomicLong(0);
-
public void assignNewOne(final DataVersion dataVersion) {
this.timestatmp = dataVersion.timestatmp;
this.counter.set(dataVersion.counter.get());
}
-
public void nextVersion() {
this.timestatmp = System.currentTimeMillis();
this.counter.incrementAndGet();
}
-
public long getTimestatmp() {
return timestatmp;
}
-
public void setTimestatmp(long timestatmp) {
this.timestatmp = timestatmp;
}
-
public AtomicLong getCounter() {
return counter;
}
-
public void setCounter(AtomicLong counter) {
this.counter = counter;
}
-
@Override
public boolean equals(final Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
- final DataVersion that = (DataVersion) o;
+ final DataVersion that = (DataVersion)o;
- if (timestatmp != that.timestatmp) return false;
+ if (timestatmp != that.timestatmp)
+ return false;
return counter != null ? counter.equals(that.counter) : that.counter == null;
}
@Override
public int hashCode() {
- int result = (int) (timestatmp ^ (timestatmp >>> 32));
+ int result = (int)(timestatmp ^ (timestatmp >>> 32));
result = 31 * result + (counter != null ? counter.hashCode() : 0);
return result;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/MQVersion.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/MQVersion.java b/common/src/main/java/org/apache/rocketmq/common/MQVersion.java
index 3543161..d12ee55 100644
--- a/common/src/main/java/org/apache/rocketmq/common/MQVersion.java
+++ b/common/src/main/java/org/apache/rocketmq/common/MQVersion.java
@@ -20,7 +20,6 @@ public class MQVersion {
public static final int CURRENT_VERSION = Version.V4_0_0_SNAPSHOT.ordinal();
-
public static String getVersionDesc(int value) {
try {
Version v = Version.values()[value];
@@ -31,7 +30,6 @@ public class MQVersion {
return "HigherVersion";
}
-
public static Version value2Version(int value) {
return Version.values()[value];
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/MixAll.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/MixAll.java b/common/src/main/java/org/apache/rocketmq/common/MixAll.java
index bca55f5..8307dd5 100644
--- a/common/src/main/java/org/apache/rocketmq/common/MixAll.java
+++ b/common/src/main/java/org/apache/rocketmq/common/MixAll.java
@@ -16,10 +16,6 @@
*/
package org.apache.rocketmq.common;
-import org.apache.rocketmq.common.annotation.ImportantField;
-import org.apache.rocketmq.common.help.FAQUrl;
-import org.slf4j.Logger;
-
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileReader;
@@ -46,7 +42,9 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
-
+import org.apache.rocketmq.common.annotation.ImportantField;
+import org.apache.rocketmq.common.help.FAQUrl;
+import org.slf4j.Logger;
public class MixAll {
public static final String ROCKETMQ_HOME_ENV = "ROCKETMQ_HOME";
@@ -94,7 +92,6 @@ public class MixAll {
return RETRY_GROUP_TOPIC_PREFIX + consumerGroup;
}
-
public static boolean isSysConsumerGroup(final String consumerGroup) {
return consumerGroup.startsWith(CID_RMQ_SYS_PREFIX);
}
@@ -107,7 +104,6 @@ public class MixAll {
return DLQ_GROUP_TOPIC_PREFIX + consumerGroup;
}
-
public static String brokerVIPChannel(final boolean isChange, final String brokerAddr) {
if (isChange) {
String[] ipAndPort = brokerAddr.split(":");
@@ -118,7 +114,6 @@ public class MixAll {
}
}
-
public static long getPID() {
String processName = java.lang.management.ManagementFactory.getRuntimeMXBean().getName();
if (processName != null && processName.length() > 0) {
@@ -132,7 +127,6 @@ public class MixAll {
return 0;
}
-
public static long createBrokerId(final String ip, final int port) {
InetSocketAddress isa = new InetSocketAddress(ip, port);
byte[] ipArray = isa.getAddress().getAddress();
@@ -148,23 +142,19 @@ public class MixAll {
String tmpFile = fileName + ".tmp";
string2FileNotSafe(str, tmpFile);
-
String bakFile = fileName + ".bak";
String prevContent = file2String(fileName);
if (prevContent != null) {
string2FileNotSafe(prevContent, bakFile);
}
-
File file = new File(fileName);
file.delete();
-
file = new File(tmpFile);
file.renameTo(new File(fileName));
}
-
public static final void string2FileNotSafe(final String str, final String fileName) throws IOException {
File file = new File(fileName);
File fileParent = file.getParentFile();
@@ -189,7 +179,6 @@ public class MixAll {
}
}
-
public static final String file2String(final String fileName) {
File file = new File(fileName);
return file2String(file);
@@ -197,7 +186,7 @@ public class MixAll {
public static final String file2String(final File file) {
if (file.exists()) {
- char[] data = new char[(int) file.length()];
+ char[] data = new char[(int)file.length()];
boolean result = false;
FileReader fileReader = null;
@@ -252,12 +241,10 @@ public class MixAll {
return url.getPath();
}
-
public static void printObjectProperties(final Logger log, final Object object) {
printObjectProperties(log, object, false);
}
-
public static void printObjectProperties(final Logger log, final Object object, final boolean onlyImportantField) {
Field[] fields = object.getClass().getDeclaredFields();
for (Field field : fields) {
@@ -293,7 +280,6 @@ public class MixAll {
}
}
-
public static String properties2String(final Properties properties) {
StringBuilder sb = new StringBuilder();
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
@@ -379,7 +365,7 @@ public class MixAll {
} else {
continue;
}
- method.invoke(object, new Object[]{arg});
+ method.invoke(object, new Object[] {arg});
}
}
} catch (Throwable e) {
@@ -388,12 +374,10 @@ public class MixAll {
}
}
-
public static boolean isPropertiesEqual(final Properties p1, final Properties p2) {
return p1.equals(p2);
}
-
public static List<String> getLocalInetAddress() {
List<String> inetAddressList = new ArrayList<String>();
try {
@@ -412,7 +396,6 @@ public class MixAll {
return inetAddressList;
}
-
public static boolean isLocalAddr(String address) {
for (String addr : LOCAL_INET_ADDRESS) {
if (address.contains(addr))
@@ -421,19 +404,17 @@ public class MixAll {
return false;
}
-
private static String localhost() {
try {
InetAddress addr = InetAddress.getLocalHost();
return addr.getHostAddress();
} catch (Throwable e) {
throw new RuntimeException("InetAddress java.net.InetAddress.getLocalHost() throws UnknownHostException"
- + FAQUrl.suggestTodo(FAQUrl.UNKNOWN_HOST_EXCEPTION),
- e);
+ + FAQUrl.suggestTodo(FAQUrl.UNKNOWN_HOST_EXCEPTION),
+ e);
}
}
-
public static boolean compareAndIncreaseOnly(final AtomicLong target, final long value) {
long prev = target.get();
while (value > prev) {
@@ -452,11 +433,20 @@ public class MixAll {
return InetAddress.getLocalHost().getHostName();
} catch (Throwable e) {
throw new RuntimeException("InetAddress java.net.InetAddress.getLocalHost() throws UnknownHostException"
- + FAQUrl.suggestTodo(FAQUrl.UNKNOWN_HOST_EXCEPTION),
- e);
+ + FAQUrl.suggestTodo(FAQUrl.UNKNOWN_HOST_EXCEPTION),
+ e);
}
}
+ public static String humanReadableByteCount(long bytes, boolean si) {
+ int unit = si ? 1000 : 1024;
+ if (bytes < unit)
+ return bytes + " B";
+ int exp = (int)(Math.log(bytes) / Math.log(unit));
+ String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i");
+ return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
+ }
+
public Set<String> list2Set(List<String> values) {
Set<String> result = new HashSet<String>();
for (String v : values) {
@@ -472,12 +462,4 @@ public class MixAll {
}
return result;
}
-
- public static String humanReadableByteCount(long bytes, boolean si) {
- int unit = si ? 1000 : 1024;
- if (bytes < unit) return bytes + " B";
- int exp = (int) (Math.log(bytes) / Math.log(unit));
- String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i");
- return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/Pair.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/Pair.java b/common/src/main/java/org/apache/rocketmq/common/Pair.java
index 45f6dee..805d0a3 100644
--- a/common/src/main/java/org/apache/rocketmq/common/Pair.java
+++ b/common/src/main/java/org/apache/rocketmq/common/Pair.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common;
@@ -20,28 +20,23 @@ public class Pair<T1, T2> {
private T1 object1;
private T2 object2;
-
public Pair(T1 object1, T2 object2) {
this.object1 = object1;
this.object2 = object2;
}
-
public T1 getObject1() {
return object1;
}
-
public void setObject1(T1 object1) {
this.object1 = object1;
}
-
public T2 getObject2() {
return object2;
}
-
public void setObject2(T2 object2) {
this.object2 = object2;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/ServiceState.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/ServiceState.java b/common/src/main/java/org/apache/rocketmq/common/ServiceState.java
index c8fbfea..53dd75b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/ServiceState.java
+++ b/common/src/main/java/org/apache/rocketmq/common/ServiceState.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java b/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java
index c0ae430..7d29868 100644
--- a/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java
+++ b/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java
@@ -6,49 +6,41 @@
* (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
+ * 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.
+ * 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.common;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.rocketmq.common.constant.LoggerName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
public abstract class ServiceThread implements Runnable {
private static final Logger STLOG = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
private static final long JOIN_TIME = 90 * 1000;
protected final Thread thread;
-
+ protected final CountDownLatch2 waitPoint = new CountDownLatch2(1);
protected volatile AtomicBoolean hasNotified = new AtomicBoolean(false);
-
protected volatile boolean stopped = false;
- protected final CountDownLatch2 waitPoint = new CountDownLatch2(1);
-
-
public ServiceThread() {
this.thread = new Thread(this, this.getServiceName());
}
-
public abstract String getServiceName();
-
public void start() {
this.thread.start();
}
-
public void shutdown() {
this.shutdown(false);
}
@@ -72,7 +64,7 @@ public abstract class ServiceThread implements Runnable {
}
long eclipseTime = System.currentTimeMillis() - beginTime;
STLOG.info("join thread " + this.getServiceName() + " eclipse time(ms) " + eclipseTime + " "
- + this.getJointime());
+ + this.getJointime());
} catch (InterruptedException e) {
e.printStackTrace();
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/SystemClock.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/SystemClock.java b/common/src/main/java/org/apache/rocketmq/common/SystemClock.java
index 5abc805..ff14915 100644
--- a/common/src/main/java/org/apache/rocketmq/common/SystemClock.java
+++ b/common/src/main/java/org/apache/rocketmq/common/SystemClock.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/ThreadFactoryImpl.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/ThreadFactoryImpl.java b/common/src/main/java/org/apache/rocketmq/common/ThreadFactoryImpl.java
index 43ab2f2..e417da8 100644
--- a/common/src/main/java/org/apache/rocketmq/common/ThreadFactoryImpl.java
+++ b/common/src/main/java/org/apache/rocketmq/common/ThreadFactoryImpl.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common;
@@ -20,17 +20,14 @@ package org.apache.rocketmq.common;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicLong;
-
public class ThreadFactoryImpl implements ThreadFactory {
private final AtomicLong threadIndex = new AtomicLong(0);
private final String threadNamePrefix;
-
public ThreadFactoryImpl(final String threadNamePrefix) {
this.threadNamePrefix = threadNamePrefix;
}
-
@Override
public Thread newThread(Runnable r) {
return new Thread(r, threadNamePrefix + this.threadIndex.incrementAndGet());
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java b/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
index 9eec278..2582b9f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
+++ b/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
@@ -6,19 +6,18 @@
* (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
+ * 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.
+ * 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.common;
import org.apache.rocketmq.common.constant.PermName;
-
public class TopicConfig {
private static final String SEPARATOR = " ";
public static int defaultReadQueueNums = 16;
@@ -31,16 +30,13 @@ public class TopicConfig {
private int topicSysFlag = 0;
private boolean order = false;
-
public TopicConfig() {
}
-
public TopicConfig(String topicName) {
this.topicName = topicName;
}
-
public TopicConfig(String topicName, int readQueueNums, int writeQueueNums, int perm) {
this.topicName = topicName;
this.readQueueNums = readQueueNums;
@@ -48,7 +44,6 @@ public class TopicConfig {
this.perm = perm;
}
-
public String encode() {
StringBuilder sb = new StringBuilder();
@@ -74,7 +69,6 @@ public class TopicConfig {
return sb.toString();
}
-
public boolean decode(final String in) {
String[] strs = in.split(SEPARATOR);
if (strs != null && strs.length == 5) {
@@ -94,89 +88,83 @@ public class TopicConfig {
return false;
}
-
public String getTopicName() {
return topicName;
}
-
public void setTopicName(String topicName) {
this.topicName = topicName;
}
-
public int getReadQueueNums() {
return readQueueNums;
}
-
public void setReadQueueNums(int readQueueNums) {
this.readQueueNums = readQueueNums;
}
-
public int getWriteQueueNums() {
return writeQueueNums;
}
-
public void setWriteQueueNums(int writeQueueNums) {
this.writeQueueNums = writeQueueNums;
}
-
public int getPerm() {
return perm;
}
-
public void setPerm(int perm) {
this.perm = perm;
}
-
public TopicFilterType getTopicFilterType() {
return topicFilterType;
}
-
public void setTopicFilterType(TopicFilterType topicFilterType) {
this.topicFilterType = topicFilterType;
}
-
public int getTopicSysFlag() {
return topicSysFlag;
}
-
public void setTopicSysFlag(int topicSysFlag) {
this.topicSysFlag = topicSysFlag;
}
-
public boolean isOrder() {
return order;
}
-
public void setOrder(boolean isOrder) {
this.order = isOrder;
}
@Override
public boolean equals(final Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- final TopicConfig that = (TopicConfig) o;
-
- if (readQueueNums != that.readQueueNums) return false;
- if (writeQueueNums != that.writeQueueNums) return false;
- if (perm != that.perm) return false;
- if (topicSysFlag != that.topicSysFlag) return false;
- if (order != that.order) return false;
- if (topicName != null ? !topicName.equals(that.topicName) : that.topicName != null) return false;
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ final TopicConfig that = (TopicConfig)o;
+
+ if (readQueueNums != that.readQueueNums)
+ return false;
+ if (writeQueueNums != that.writeQueueNums)
+ return false;
+ if (perm != that.perm)
+ return false;
+ if (topicSysFlag != that.topicSysFlag)
+ return false;
+ if (order != that.order)
+ return false;
+ if (topicName != null ? !topicName.equals(that.topicName) : that.topicName != null)
+ return false;
return topicFilterType == that.topicFilterType;
}
@@ -196,8 +184,8 @@ public class TopicConfig {
@Override
public String toString() {
return "TopicConfig [topicName=" + topicName + ", readQueueNums=" + readQueueNums
- + ", writeQueueNums=" + writeQueueNums + ", perm=" + PermName.perm2String(perm)
- + ", topicFilterType=" + topicFilterType + ", topicSysFlag=" + topicSysFlag + ", order="
- + order + "]";
+ + ", writeQueueNums=" + writeQueueNums + ", perm=" + PermName.perm2String(perm)
+ + ", topicFilterType=" + topicFilterType + ", topicSysFlag=" + topicSysFlag + ", order="
+ + order + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java b/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java
index cd3490a..182ecc7 100644
--- a/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java
+++ b/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common;
[57/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Remove bad
practices in broker.
Posted by yu...@apache.org.
ROCKETMQ-18 Remove bad practices in broker.
Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/commit/9165667a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/tree/9165667a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/diff/9165667a
Branch: refs/heads/master
Commit: 9165667aa3975900ed1f79fd6c612cfd2e05a01f
Parents: f56e038
Author: yukon <yu...@apache.org>
Authored: Tue Dec 27 21:49:37 2016 +0800
Committer: yukon <yu...@apache.org>
Committed: Tue Dec 27 21:49:37 2016 +0800
----------------------------------------------------------------------
.../rocketmq/broker/client/net/Broker2Client.java | 4 ++--
.../rocketmq/broker/filtersrv/FilterServerUtil.java | 3 +--
.../rocketmq/broker/latency/BrokerFastFailure.java | 2 +-
.../broker/offset/ConsumerOffsetManager.java | 12 ++++--------
.../apache/rocketmq/broker/out/BrokerOuterAPI.java | 11 +++++------
.../rocketmq/broker/plugin/MessageStoreFactory.java | 3 +--
.../processor/AbstractSendMessageProcessor.java | 10 ++++++----
.../broker/processor/AdminBrokerProcessor.java | 10 ++++------
.../broker/processor/PullMessageProcessor.java | 2 +-
.../broker/processor/QueryMessageProcessor.java | 4 ++--
.../broker/processor/SendMessageProcessor.java | 1 +
.../broker/transaction/TransactionStore.java | 16 ++++++++--------
12 files changed, 36 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/9165667a/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java b/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
index 152f373..70027cd 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
@@ -202,7 +202,7 @@ public class Broker2Client {
try {
this.brokerController.getRemotingServer().invokeOneway(entry.getKey(), request, 5000);
log.info("[reset-offset] reset offset success. topic={}, group={}, clientId={}",
- new Object[]{topic, group, entry.getValue().getClientId()});
+ topic, group, entry.getValue().getClientId());
} catch (Exception e) {
log.error("[reset-offset] reset offset exception. topic={}, group={}",
new Object[]{topic, group}, e);
@@ -290,7 +290,7 @@ public class Broker2Client {
consumerStatusTable.put(clientId, body.getMessageQueueTable());
log.info(
"[get-consumer-status] get consumer status success. topic={}, group={}, channelRemoteAddr={}",
- new Object[]{topic, group, clientId});
+ topic, group, clientId);
}
}
default:
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/9165667a/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerUtil.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerUtil.java b/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerUtil.java
index 1c40c0e..de4cc37 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerUtil.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerUtil.java
@@ -37,7 +37,6 @@ public class FilterServerUtil {
}
private static String[] splitShellString(final String shellString) {
- String[] split = shellString.split(" ");
- return split;
+ return shellString.split(" ");
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/9165667a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
index 4810d77..2f4b568 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
@@ -77,7 +77,7 @@ public class BrokerFastFailure {
break;
}
final RequestTask rt = castRunnable(runnable);
- if (rt.isStopRun()) {
+ if (rt == null || rt.isStopRun()) {
break;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/9165667a/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java b/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
index ef9065e..7188e8d 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
@@ -58,7 +58,7 @@ public class ConsumerOffsetManager extends ConfigManager {
Entry<String, ConcurrentHashMap<Integer, Long>> next = it.next();
String topicAtGroup = next.getKey();
String[] arrays = topicAtGroup.split(TOPIC_GROUP_SEPARATOR);
- if (arrays != null && arrays.length == 2) {
+ if (arrays.length == 2) {
String topic = arrays[0];
String group = arrays[1];
@@ -80,11 +80,7 @@ public class ConsumerOffsetManager extends ConfigManager {
Entry<Integer, Long> next = it.next();
long minOffsetInStore = this.brokerController.getMessageStore().getMinOffsetInQuque(topic, next.getKey());
long offsetInPersist = next.getValue();
- if (offsetInPersist > minOffsetInStore) {
- result = false;
- } else {
- result = true;
- }
+ result = offsetInPersist <= minOffsetInStore;
}
return result;
@@ -99,7 +95,7 @@ public class ConsumerOffsetManager extends ConfigManager {
Entry<String, ConcurrentHashMap<Integer, Long>> next = it.next();
String topicAtGroup = next.getKey();
String[] arrays = topicAtGroup.split(TOPIC_GROUP_SEPARATOR);
- if (arrays != null && arrays.length == 2) {
+ if (arrays.length == 2) {
if (group.equals(arrays[1])) {
topics.add(arrays[0]);
}
@@ -118,7 +114,7 @@ public class ConsumerOffsetManager extends ConfigManager {
Entry<String, ConcurrentHashMap<Integer, Long>> next = it.next();
String topicAtGroup = next.getKey();
String[] arrays = topicAtGroup.split(TOPIC_GROUP_SEPARATOR);
- if (arrays != null && arrays.length == 2) {
+ if (arrays.length == 2) {
if (topic.equals(arrays[0])) {
groups.add(arrays[1]);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/9165667a/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java b/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
index ab02ceb..335c105 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
@@ -88,13 +88,11 @@ public class BrokerOuterAPI {
public void updateNameServerAddressList(final String addrs) {
List<String> lst = new ArrayList<String>();
String[] addrArray = addrs.split(";");
- if (addrArray != null) {
- for (String addr : addrArray) {
- lst.add(addr);
- }
-
- this.remotingClient.updateNameServerAddressList(lst);
+ for (String addr : addrArray) {
+ lst.add(addr);
}
+
+ this.remotingClient.updateNameServerAddressList(lst);
}
public RegisterBrokerResult registerBrokerAll(
@@ -159,6 +157,7 @@ public class BrokerOuterAPI {
try {
this.remotingClient.invokeOneway(namesrvAddr, request, timeoutMills);
} catch (RemotingTooMuchRequestException e) {
+ // Ignore
}
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/9165667a/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java b/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java
index d27b6aa..42793ae 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java
@@ -37,8 +37,7 @@ public final class MessageStoreFactory {
@SuppressWarnings("unchecked")
Class<AbstractPluginMessageStore> clazz = (Class<AbstractPluginMessageStore>) Class.forName(pluginClass);
Constructor<AbstractPluginMessageStore> construct = clazz.getConstructor(MessageStorePluginContext.class, MessageStore.class);
- AbstractPluginMessageStore pluginMessageStore = (AbstractPluginMessageStore) construct.newInstance(context, messageStore);
- messageStore = pluginMessageStore;
+ messageStore = construct.newInstance(context, messageStore);
} catch (Throwable e) {
throw new RuntimeException(String.format(
"Initialize plugin's class %s not found!", pluginClass), e);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/9165667a/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
index 81a239b..8a285e8 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
@@ -176,8 +176,7 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
return response;
}
if (!this.brokerController.getTopicConfigManager().isTopicCanSendMessage(requestHeader.getTopic())) {
- String errorMsg =
- "the topic[" + requestHeader.getTopic() + "] is conflict with system reserved words.";
+ String errorMsg = "the topic[" + requestHeader.getTopic() + "] is conflict with system reserved words.";
log.warn(errorMsg);
response.setCode(ResponseCode.SYSTEM_ERROR);
response.setRemark(errorMsg);
@@ -273,8 +272,11 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
}
hook.sendMessageBefore(context);
- requestHeader.setProperties(context.getMsgProps());
+ if (requestHeader != null) {
+ requestHeader.setProperties(context.getMsgProps());
+ }
} catch (Throwable e) {
+ // Ignore
}
}
}
@@ -319,7 +321,7 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
}
hook.sendMessageAfter(context);
} catch (Throwable e) {
-
+ // Ignore
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/9165667a/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
index 94aa414..4588d2d 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
@@ -722,8 +722,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
final ResetOffsetRequestHeader requestHeader =
(ResetOffsetRequestHeader) request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
log.info("[reset-offset] reset offset started by {}. topic={}, group={}, timestamp={}, isForce={}",
- new Object[]{RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
- requestHeader.getTimestamp(), requestHeader.isForce()});
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
+ requestHeader.getTimestamp(), requestHeader.isForce());
boolean isC = false;
LanguageCode language = request.getLanguage();
switch (language) {
@@ -740,7 +740,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
(GetConsumerStatusRequestHeader) request.decodeCommandCustomHeader(GetConsumerStatusRequestHeader.class);
log.info("[get-consumer-status] get consumer status by {}. topic={}, group={}",
- new Object[]{RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup()});
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup());
return this.brokerController.getBroker2Client().getConsumeStatus(requestHeader.getTopic(), requestHeader.getGroup(),
requestHeader.getClientAddr());
@@ -1193,9 +1193,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
newRequest.setExtFields(request.getExtFields());
newRequest.setBody(request.getBody());
- RemotingCommand consumerResponse =
- this.brokerController.getBroker2Client().callClient(clientChannelInfo.getChannel(), newRequest);
- return consumerResponse;
+ return this.brokerController.getBroker2Client().callClient(clientChannelInfo.getChannel(), newRequest);
} catch (RemotingTimeoutException e) {
response.setCode(ResponseCode.CONSUME_MSG_TIMEOUT);
response
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/9165667a/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
index 7f88593..7625d21 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
@@ -528,7 +528,7 @@ public class PullMessageProcessor implements NettyRequestProcessor {
}
}
} catch (RemotingCommandException e1) {
- LOG.error("excuteRequestWhenWakeup run", e1);
+ LOG.error("executeRequestWhenWakeup run", e1);
}
}
};
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/9165667a/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
index b41e0a5..5c60255 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
@@ -116,7 +116,7 @@ public class QueryMessageProcessor implements NettyRequestProcessor {
public void operationComplete(ChannelFuture future) throws Exception {
queryMessageResult.release();
if (!future.isSuccess()) {
- log.error("transfer query message by pagecache failed, ", future.cause());
+ log.error("transfer query message by page cache failed, ", future.cause());
}
}
});
@@ -158,7 +158,7 @@ public class QueryMessageProcessor implements NettyRequestProcessor {
public void operationComplete(ChannelFuture future) throws Exception {
selectMappedBufferResult.release();
if (!future.isSuccess()) {
- log.error("transfer one message by pagecache failed, ", future.cause());
+ log.error("transfer one message by page cache failed, ", future.cause());
}
}
});
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/9165667a/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
index defe7e3..5cebd0e 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
@@ -467,6 +467,7 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
try {
hook.consumeMessageAfter(context);
} catch (Throwable e) {
+ // Ignore
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/9165667a/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionStore.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionStore.java b/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionStore.java
index 758eeed..d6e897a 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionStore.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/transaction/TransactionStore.java
@@ -21,26 +21,26 @@ import java.util.List;
public interface TransactionStore {
- public boolean open();
+ boolean open();
- public void close();
+ void close();
- public boolean put(final List<TransactionRecord> trs);
+ boolean put(final List<TransactionRecord> trs);
- public void remove(final List<Long> pks);
+ void remove(final List<Long> pks);
- public List<TransactionRecord> traverse(final long pk, final int nums);
+ List<TransactionRecord> traverse(final long pk, final int nums);
- public long totalRecords();
+ long totalRecords();
- public long minPK();
+ long minPK();
- public long maxPK();
+ long maxPK();
}
[28/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java
new file mode 100644
index 0000000..3784752
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java
@@ -0,0 +1,50 @@
+/**
+ * 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.consumer.rebalance;
+
+import org.apache.rocketmq.client.consumer.AllocateMessageQueueStrategy;
+import org.apache.rocketmq.common.message.MessageQueue;
+
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class AllocateMessageQueueByConfig implements AllocateMessageQueueStrategy {
+ private List<MessageQueue> messageQueueList;
+
+ @Override
+ public List<MessageQueue> allocate(String consumerGroup, String currentCID, List<MessageQueue> mqAll,
+ List<String> cidAll) {
+ return this.messageQueueList;
+ }
+
+ @Override
+ public String getName() {
+ return "CONFIG";
+ }
+
+ public List<MessageQueue> getMessageQueueList() {
+ return messageQueueList;
+ }
+
+
+ public void setMessageQueueList(List<MessageQueue> messageQueueList) {
+ this.messageQueueList = messageQueueList;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByMachineRoom.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByMachineRoom.java b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByMachineRoom.java
new file mode 100644
index 0000000..d3448c9
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByMachineRoom.java
@@ -0,0 +1,75 @@
+/**
+ * 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.consumer.rebalance;
+
+import org.apache.rocketmq.client.consumer.AllocateMessageQueueStrategy;
+import org.apache.rocketmq.common.message.MessageQueue;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+
+/**
+ * Computer room Hashing queue algorithm, such as Alipay logic room
+ */
+public class AllocateMessageQueueByMachineRoom implements AllocateMessageQueueStrategy {
+ private Set<String> consumeridcs;
+
+ @Override
+ public List<MessageQueue> allocate(String consumerGroup, String currentCID, List<MessageQueue> mqAll,
+ List<String> cidAll) {
+ List<MessageQueue> result = new ArrayList<MessageQueue>();
+ int currentIndex = cidAll.indexOf(currentCID);
+ if (currentIndex < 0) {
+ return result;
+ }
+ List<MessageQueue> premqAll = new ArrayList<MessageQueue>();
+ for (MessageQueue mq : mqAll) {
+ String[] temp = mq.getBrokerName().split("@");
+ if (temp.length == 2 && consumeridcs.contains(temp[0])) {
+ premqAll.add(mq);
+ }
+ }
+ // Todo cid
+ int mod = premqAll.size() / cidAll.size();
+ int rem = premqAll.size() % cidAll.size();
+ int startindex = mod * currentIndex;
+ int endindex = startindex + mod;
+ for (int i = startindex; i < endindex; i++) {
+ result.add(mqAll.get(i));
+ }
+ if (rem > currentIndex) {
+ result.add(premqAll.get(currentIndex + mod * cidAll.size()));
+ }
+ return result;
+ }
+
+ @Override
+ public String getName() {
+ return "MACHINE_ROOM";
+ }
+
+ public Set<String> getConsumeridcs() {
+ return consumeridcs;
+ }
+
+
+ public void setConsumeridcs(Set<String> consumeridcs) {
+ this.consumeridcs = consumeridcs;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
new file mode 100644
index 0000000..f4d87e7
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
@@ -0,0 +1,228 @@
+/**
+ * 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.consumer.store;
+
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.impl.factory.MQClientInstance;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.help.FAQUrl;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+import org.slf4j.Logger;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicLong;
+
+
+/**
+ * Local storage implementation
+ *
+ * @author shijia.wxr
+ */
+public class LocalFileOffsetStore implements OffsetStore {
+ public final static String LOCAL_OFFSET_STORE_DIR = System.getProperty(
+ "rocketmq.client.localOffsetStoreDir",
+ System.getProperty("user.home") + File.separator + ".rocketmq_offsets");
+ private final static Logger log = ClientLogger.getLog();
+ private final MQClientInstance mQClientFactory;
+ private final String groupName;
+ private final String storePath;
+ private ConcurrentHashMap<MessageQueue, AtomicLong> offsetTable =
+ new ConcurrentHashMap<MessageQueue, AtomicLong>();
+
+
+ public LocalFileOffsetStore(MQClientInstance mQClientFactory, String groupName) {
+ this.mQClientFactory = mQClientFactory;
+ this.groupName = groupName;
+ this.storePath = LOCAL_OFFSET_STORE_DIR + File.separator + //
+ this.mQClientFactory.getClientId() + File.separator + //
+ this.groupName + File.separator + //
+ "offsets.json";
+ }
+
+
+ @Override
+ public void load() throws MQClientException {
+ OffsetSerializeWrapper offsetSerializeWrapper = this.readLocalOffset();
+ if (offsetSerializeWrapper != null && offsetSerializeWrapper.getOffsetTable() != null) {
+ offsetTable.putAll(offsetSerializeWrapper.getOffsetTable());
+
+ for (MessageQueue mq : offsetSerializeWrapper.getOffsetTable().keySet()) {
+ AtomicLong offset = offsetSerializeWrapper.getOffsetTable().get(mq);
+ log.info("load consumer's offset, {} {} {}",
+ this.groupName,
+ mq,
+ offset.get());
+ }
+ }
+ }
+
+
+ @Override
+ public void updateOffset(MessageQueue mq, long offset, boolean increaseOnly) {
+ if (mq != null) {
+ AtomicLong offsetOld = this.offsetTable.get(mq);
+ if (null == offsetOld) {
+ offsetOld = this.offsetTable.putIfAbsent(mq, new AtomicLong(offset));
+ }
+
+ if (null != offsetOld) {
+ if (increaseOnly) {
+ MixAll.compareAndIncreaseOnly(offsetOld, offset);
+ } else {
+ offsetOld.set(offset);
+ }
+ }
+ }
+ }
+
+
+ @Override
+ public long readOffset(final MessageQueue mq, final ReadOffsetType type) {
+ if (mq != null) {
+ switch (type) {
+ case MEMORY_FIRST_THEN_STORE:
+ case READ_FROM_MEMORY: {
+ AtomicLong offset = this.offsetTable.get(mq);
+ if (offset != null) {
+ return offset.get();
+ } else if (ReadOffsetType.READ_FROM_MEMORY == type) {
+ return -1;
+ }
+ }
+ case READ_FROM_STORE: {
+ OffsetSerializeWrapper offsetSerializeWrapper;
+ try {
+ offsetSerializeWrapper = this.readLocalOffset();
+ } catch (MQClientException e) {
+ return -1;
+ }
+ if (offsetSerializeWrapper != null && offsetSerializeWrapper.getOffsetTable() != null) {
+ AtomicLong offset = offsetSerializeWrapper.getOffsetTable().get(mq);
+ if (offset != null) {
+ this.updateOffset(mq, offset.get(), false);
+ return offset.get();
+ }
+ }
+ }
+ default:
+ break;
+ }
+ }
+
+ return -1;
+ }
+
+
+ @Override
+ public void persistAll(Set<MessageQueue> mqs) {
+ if (null == mqs || mqs.isEmpty())
+ return;
+
+ OffsetSerializeWrapper offsetSerializeWrapper = new OffsetSerializeWrapper();
+ for (Map.Entry<MessageQueue, AtomicLong> entry : this.offsetTable.entrySet()) {
+ if (mqs.contains(entry.getKey())) {
+ AtomicLong offset = entry.getValue();
+ offsetSerializeWrapper.getOffsetTable().put(entry.getKey(), offset);
+ }
+ }
+
+ String jsonString = offsetSerializeWrapper.toJson(true);
+ if (jsonString != null) {
+ try {
+ MixAll.string2File(jsonString, this.storePath);
+ } catch (IOException e) {
+ log.error("persistAll consumer offset Exception, " + this.storePath, e);
+ }
+ }
+ }
+
+
+ @Override
+ public void persist(MessageQueue mq) {
+ }
+
+ @Override
+ public void removeOffset(MessageQueue mq) {
+
+ }
+
+ @Override
+ public void updateConsumeOffsetToBroker(final MessageQueue mq, final long offset, final boolean isOneway)
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+
+ }
+
+ @Override
+ public Map<MessageQueue, Long> cloneOffsetTable(String topic) {
+ Map<MessageQueue, Long> cloneOffsetTable = new HashMap<MessageQueue, Long>();
+ for (Map.Entry<MessageQueue, AtomicLong> entry : this.offsetTable.entrySet()) {
+ MessageQueue mq = entry.getKey();
+ if (!UtilAll.isBlank(topic) && !topic.equals(mq.getTopic())) {
+ continue;
+ }
+ cloneOffsetTable.put(mq, entry.getValue().get());
+
+ }
+ return cloneOffsetTable;
+ }
+
+ private OffsetSerializeWrapper readLocalOffset() throws MQClientException {
+ String content = MixAll.file2String(this.storePath);
+ if (null == content || content.length() == 0) {
+ return this.readLocalOffsetBak();
+ } else {
+ OffsetSerializeWrapper offsetSerializeWrapper = null;
+ try {
+ offsetSerializeWrapper =
+ OffsetSerializeWrapper.fromJson(content, OffsetSerializeWrapper.class);
+ } catch (Exception e) {
+ log.warn("readLocalOffset Exception, and try to correct", e);
+ return this.readLocalOffsetBak();
+ }
+
+ return offsetSerializeWrapper;
+ }
+ }
+
+ private OffsetSerializeWrapper readLocalOffsetBak() throws MQClientException {
+ String content = MixAll.file2String(this.storePath + ".bak");
+ if (content != null && content.length() > 0) {
+ OffsetSerializeWrapper offsetSerializeWrapper = null;
+ try {
+ offsetSerializeWrapper =
+ OffsetSerializeWrapper.fromJson(content, OffsetSerializeWrapper.class);
+ } catch (Exception e) {
+ log.warn("readLocalOffset Exception", e);
+ throw new MQClientException("readLocalOffset Exception, maybe fastjson version too low" //
+ + FAQUrl.suggestTodo(FAQUrl.LOAD_JSON_EXCEPTION), //
+ e);
+ }
+ return offsetSerializeWrapper;
+ }
+
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
new file mode 100644
index 0000000..e69ad23
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
@@ -0,0 +1,42 @@
+/**
+ * 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.consumer.store;
+
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicLong;
+
+
+/**
+ * Wrapper class for offset serialization
+ *
+ * @author shijia.wxr
+ */
+public class OffsetSerializeWrapper extends RemotingSerializable {
+ private ConcurrentHashMap<MessageQueue, AtomicLong> offsetTable =
+ new ConcurrentHashMap<MessageQueue, AtomicLong>();
+
+ public ConcurrentHashMap<MessageQueue, AtomicLong> getOffsetTable() {
+ return offsetTable;
+ }
+
+ public void setOffsetTable(ConcurrentHashMap<MessageQueue, AtomicLong> offsetTable) {
+ this.offsetTable = offsetTable;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
new file mode 100644
index 0000000..7c7ccc6
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
@@ -0,0 +1,97 @@
+/**
+ * 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.consumer.store;
+
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+
+import java.util.Map;
+import java.util.Set;
+
+
+/**
+ * Offset store interface
+ *
+ * @author shijia.wxr
+ */
+public interface OffsetStore {
+ /**
+ * Load
+ *
+ * @throws MQClientException
+ */
+ void load() throws MQClientException;
+
+
+ /**
+ * Update the offset,store it in memory
+ *
+ * @param mq
+ * @param offset
+ * @param increaseOnly
+ */
+ void updateOffset(final MessageQueue mq, final long offset, final boolean increaseOnly);
+
+ /**
+ * Get offset from local storage
+ *
+ * @param mq
+ * @param type
+ *
+ * @return The fetched offset
+ */
+ long readOffset(final MessageQueue mq, final ReadOffsetType type);
+
+ /**
+ * Persist all offsets,may be in local storage or remote name server
+ *
+ * @param mqs
+ */
+ void persistAll(final Set<MessageQueue> mqs);
+
+ /**
+ * Persist the offset,may be in local storage or remote name server
+ *
+ * @param mq
+ */
+ void persist(final MessageQueue mq);
+
+ /**
+ * Remove offset
+ *
+ * @param mq
+ */
+ void removeOffset(MessageQueue mq);
+
+ /**
+ * @param topic
+ *
+ * @return The cloned offset table of given topic
+ */
+ Map<MessageQueue, Long> cloneOffsetTable(String topic);
+
+ /**
+ *
+ * @param mq
+ * @param offset
+ * @param isOneway
+ */
+ void updateConsumeOffsetToBroker(MessageQueue mq, long offset, boolean isOneway) throws RemotingException,
+ MQBrokerException, InterruptedException, MQClientException;
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/store/ReadOffsetType.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/ReadOffsetType.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/ReadOffsetType.java
new file mode 100644
index 0000000..c2ee9b7
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/ReadOffsetType.java
@@ -0,0 +1,32 @@
+/**
+ * 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.consumer.store;
+
+public enum ReadOffsetType {
+ /**
+ * From memory
+ */
+ READ_FROM_MEMORY,
+ /**
+ * From storage
+ */
+ READ_FROM_STORE,
+ /**
+ * From memory,then from storage
+ */
+ MEMORY_FIRST_THEN_STORE;
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
new file mode 100644
index 0000000..082e7e8
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
@@ -0,0 +1,261 @@
+/**
+ * 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.consumer.store;
+
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.impl.FindBrokerResult;
+import org.apache.rocketmq.client.impl.factory.MQClientInstance;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.header.QueryConsumerOffsetRequestHeader;
+import org.apache.rocketmq.common.protocol.header.UpdateConsumerOffsetRequestHeader;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+import org.slf4j.Logger;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicLong;
+
+
+/**
+ * Remote storage implementation
+ *
+ * @author shijia.wxr
+ */
+public class RemoteBrokerOffsetStore implements OffsetStore {
+ private final static Logger log = ClientLogger.getLog();
+ private final MQClientInstance mQClientFactory;
+ private final String groupName;
+ private ConcurrentHashMap<MessageQueue, AtomicLong> offsetTable =
+ new ConcurrentHashMap<MessageQueue, AtomicLong>();
+
+
+ public RemoteBrokerOffsetStore(MQClientInstance mQClientFactory, String groupName) {
+ this.mQClientFactory = mQClientFactory;
+ this.groupName = groupName;
+ }
+
+
+ @Override
+ public void load() {
+ }
+
+
+ @Override
+ public void updateOffset(MessageQueue mq, long offset, boolean increaseOnly) {
+ if (mq != null) {
+ AtomicLong offsetOld = this.offsetTable.get(mq);
+ if (null == offsetOld) {
+ offsetOld = this.offsetTable.putIfAbsent(mq, new AtomicLong(offset));
+ }
+
+ if (null != offsetOld) {
+ if (increaseOnly) {
+ MixAll.compareAndIncreaseOnly(offsetOld, offset);
+ } else {
+ offsetOld.set(offset);
+ }
+ }
+ }
+ }
+
+
+ @Override
+ public long readOffset(final MessageQueue mq, final ReadOffsetType type) {
+ if (mq != null) {
+ switch (type) {
+ case MEMORY_FIRST_THEN_STORE:
+ case READ_FROM_MEMORY: {
+ AtomicLong offset = this.offsetTable.get(mq);
+ if (offset != null) {
+ return offset.get();
+ } else if (ReadOffsetType.READ_FROM_MEMORY == type) {
+ return -1;
+ }
+ }
+ case READ_FROM_STORE: {
+ try {
+ long brokerOffset = this.fetchConsumeOffsetFromBroker(mq);
+ AtomicLong offset = new AtomicLong(brokerOffset);
+ this.updateOffset(mq, offset.get(), false);
+ return brokerOffset;
+ }
+ // No offset in broker
+ catch (MQBrokerException e) {
+ return -1;
+ }
+ //Other exceptions
+ catch (Exception e) {
+ log.warn("fetchConsumeOffsetFromBroker exception, " + mq, e);
+ return -2;
+ }
+ }
+ default:
+ break;
+ }
+ }
+
+ return -1;
+ }
+
+
+ @Override
+ public void persistAll(Set<MessageQueue> mqs) {
+ if (null == mqs || mqs.isEmpty())
+ return;
+
+ final HashSet<MessageQueue> unusedMQ = new HashSet<MessageQueue>();
+ if (mqs != null && !mqs.isEmpty()) {
+ for (Map.Entry<MessageQueue, AtomicLong> entry : this.offsetTable.entrySet()) {
+ MessageQueue mq = entry.getKey();
+ AtomicLong offset = entry.getValue();
+ if (offset != null) {
+ if (mqs.contains(mq)) {
+ try {
+ this.updateConsumeOffsetToBroker(mq, offset.get());
+ log.info("[persistAll] Group: {} ClientId: {} updateConsumeOffsetToBroker {} {}",
+ this.groupName,
+ this.mQClientFactory.getClientId(),
+ mq,
+ offset.get());
+ } catch (Exception e) {
+ log.error("updateConsumeOffsetToBroker exception, " + mq.toString(), e);
+ }
+ } else {
+ unusedMQ.add(mq);
+ }
+ }
+ }
+ }
+
+ if (!unusedMQ.isEmpty()) {
+ for (MessageQueue mq : unusedMQ) {
+ this.offsetTable.remove(mq);
+ log.info("remove unused mq, {}, {}", mq, this.groupName);
+ }
+ }
+ }
+
+
+ @Override
+ public void persist(MessageQueue mq) {
+ AtomicLong offset = this.offsetTable.get(mq);
+ if (offset != null) {
+ try {
+ this.updateConsumeOffsetToBroker(mq, offset.get());
+ log.info("[persist] Group: {} ClientId: {} updateConsumeOffsetToBroker {} {}",
+ this.groupName,
+ this.mQClientFactory.getClientId(),
+ mq,
+ offset.get());
+ } catch (Exception e) {
+ log.error("updateConsumeOffsetToBroker exception, " + mq.toString(), e);
+ }
+ }
+ }
+
+ public void removeOffset(MessageQueue mq) {
+ if (mq != null) {
+ this.offsetTable.remove(mq);
+ log.info("remove unnecessary messageQueue offset. group={}, mq={}, offsetTableSize={}", this.groupName, mq,
+ offsetTable.size());
+ }
+ }
+
+ @Override
+ public Map<MessageQueue, Long> cloneOffsetTable(String topic) {
+ Map<MessageQueue, Long> cloneOffsetTable = new HashMap<MessageQueue, Long>();
+ for (Map.Entry<MessageQueue, AtomicLong> entry : this.offsetTable.entrySet()) {
+ MessageQueue mq = entry.getKey();
+ if (!UtilAll.isBlank(topic) && !topic.equals(mq.getTopic())) {
+ continue;
+ }
+ cloneOffsetTable.put(mq, entry.getValue().get());
+ }
+ return cloneOffsetTable;
+ }
+
+ /**
+ * Update the Consumer Offset in one way, once the Master is off, updated to Slave,
+ * here need to be optimized.
+ */
+ private void updateConsumeOffsetToBroker(MessageQueue mq, long offset) throws RemotingException,
+ MQBrokerException, InterruptedException, MQClientException {
+ updateConsumeOffsetToBroker(mq, offset, true);
+ }
+
+ /**
+ * Update the Consumer Offset synchronously, once the Master is off, updated to Slave,
+ * here need to be optimized.
+ */
+ @Override
+ public void updateConsumeOffsetToBroker(MessageQueue mq, long offset, boolean isOneway) throws RemotingException,
+ MQBrokerException, InterruptedException, MQClientException {
+ FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInAdmin(mq.getBrokerName());
+ if (null == findBrokerResult) {
+ // TODO Here may be heavily overhead for Name Server,need tuning
+ this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
+ findBrokerResult = this.mQClientFactory.findBrokerAddressInAdmin(mq.getBrokerName());
+ }
+
+ if (findBrokerResult != null) {
+ UpdateConsumerOffsetRequestHeader requestHeader = new UpdateConsumerOffsetRequestHeader();
+ requestHeader.setTopic(mq.getTopic());
+ requestHeader.setConsumerGroup(this.groupName);
+ requestHeader.setQueueId(mq.getQueueId());
+ requestHeader.setCommitOffset(offset);
+
+ if (isOneway) {
+ this.mQClientFactory.getMQClientAPIImpl().updateConsumerOffsetOneway(
+ findBrokerResult.getBrokerAddr(), requestHeader, 1000 * 5);
+ } else {
+ this.mQClientFactory.getMQClientAPIImpl().updateConsumerOffset(
+ findBrokerResult.getBrokerAddr(), requestHeader, 1000 * 5);
+ }
+ } else {
+ throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
+ }
+ }
+
+ private long fetchConsumeOffsetFromBroker(MessageQueue mq) throws RemotingException, MQBrokerException,
+ InterruptedException, MQClientException {
+ FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInAdmin(mq.getBrokerName());
+ if (null == findBrokerResult) {
+ // TODO Here may be heavily overhead for Name Server,need tuning
+ this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
+ findBrokerResult = this.mQClientFactory.findBrokerAddressInAdmin(mq.getBrokerName());
+ }
+
+ if (findBrokerResult != null) {
+ QueryConsumerOffsetRequestHeader requestHeader = new QueryConsumerOffsetRequestHeader();
+ requestHeader.setTopic(mq.getTopic());
+ requestHeader.setConsumerGroup(this.groupName);
+ requestHeader.setQueueId(mq.getQueueId());
+
+ return this.mQClientFactory.getMQClientAPIImpl().queryConsumerOffset(
+ findBrokerResult.getBrokerAddr(), requestHeader, 1000 * 5);
+ } else {
+ throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java b/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java
new file mode 100644
index 0000000..5e8d1b9
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java
@@ -0,0 +1,48 @@
+/**
+ * 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.exception;
+
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.help.FAQUrl;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class MQBrokerException extends Exception {
+ private static final long serialVersionUID = 5975020272601250368L;
+ private final int responseCode;
+ private final String errorMessage;
+
+
+ public MQBrokerException(int responseCode, String errorMessage) {
+ super(FAQUrl.attachDefaultURL("CODE: " + UtilAll.responseCode2String(responseCode) + " DESC: "
+ + errorMessage));
+ this.responseCode = responseCode;
+ this.errorMessage = errorMessage;
+ }
+
+
+ public int getResponseCode() {
+ return responseCode;
+ }
+
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java b/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java
new file mode 100644
index 0000000..5f32d12
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java
@@ -0,0 +1,62 @@
+/**
+ * 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.exception;
+
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.help.FAQUrl;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class MQClientException extends Exception {
+ private static final long serialVersionUID = -5758410930844185841L;
+ private int responseCode;
+ private String errorMessage;
+
+
+ public MQClientException(String errorMessage, Throwable cause) {
+ super(FAQUrl.attachDefaultURL(errorMessage), cause);
+ this.responseCode = -1;
+ this.errorMessage = errorMessage;
+ }
+
+
+ public MQClientException(int responseCode, String errorMessage) {
+ super(FAQUrl.attachDefaultURL("CODE: " + UtilAll.responseCode2String(responseCode) + " DESC: "
+ + errorMessage));
+ this.responseCode = responseCode;
+ this.errorMessage = errorMessage;
+ }
+
+ public int getResponseCode() {
+ return responseCode;
+ }
+
+ public MQClientException setResponseCode(final int responseCode) {
+ this.responseCode = responseCode;
+ return this;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(final String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenContext.java b/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenContext.java
new file mode 100644
index 0000000..8cb4ca9
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenContext.java
@@ -0,0 +1,148 @@
+/**
+ * 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.hook;
+
+import org.apache.rocketmq.client.impl.CommunicationMode;
+import org.apache.rocketmq.client.producer.SendResult;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageQueue;
+
+
+/**
+ * @author manhong.yqd
+ */
+public class CheckForbiddenContext {
+ private String nameSrvAddr;
+ private String group;
+ private Message message;
+ private MessageQueue mq;
+ private String brokerAddr;
+ private CommunicationMode communicationMode;
+ private SendResult sendResult;
+ private Exception exception;
+ private Object arg;
+ private boolean unitMode = false;
+
+
+ public String getGroup() {
+ return group;
+ }
+
+
+ public void setGroup(String group) {
+ this.group = group;
+ }
+
+
+ public Message getMessage() {
+ return message;
+ }
+
+
+ public void setMessage(Message message) {
+ this.message = message;
+ }
+
+
+ public MessageQueue getMq() {
+ return mq;
+ }
+
+
+ public void setMq(MessageQueue mq) {
+ this.mq = mq;
+ }
+
+
+ public String getBrokerAddr() {
+ return brokerAddr;
+ }
+
+
+ public void setBrokerAddr(String brokerAddr) {
+ this.brokerAddr = brokerAddr;
+ }
+
+
+ public CommunicationMode getCommunicationMode() {
+ return communicationMode;
+ }
+
+
+ public void setCommunicationMode(CommunicationMode communicationMode) {
+ this.communicationMode = communicationMode;
+ }
+
+
+ public SendResult getSendResult() {
+ return sendResult;
+ }
+
+
+ public void setSendResult(SendResult sendResult) {
+ this.sendResult = sendResult;
+ }
+
+
+ public Exception getException() {
+ return exception;
+ }
+
+
+ public void setException(Exception exception) {
+ this.exception = exception;
+ }
+
+
+ public Object getArg() {
+ return arg;
+ }
+
+
+ public void setArg(Object arg) {
+ this.arg = arg;
+ }
+
+
+ public boolean isUnitMode() {
+ return unitMode;
+ }
+
+
+ public void setUnitMode(boolean isUnitMode) {
+ this.unitMode = isUnitMode;
+ }
+
+
+ public String getNameSrvAddr() {
+ return nameSrvAddr;
+ }
+
+
+ public void setNameSrvAddr(String nameSrvAddr) {
+ this.nameSrvAddr = nameSrvAddr;
+ }
+
+
+ @Override
+ public String toString() {
+ return "SendMessageContext [nameSrvAddr=" + nameSrvAddr + ", group=" + group + ", message=" + message
+ + ", mq=" + mq + ", brokerAddr=" + brokerAddr + ", communicationMode=" + communicationMode
+ + ", sendResult=" + sendResult + ", exception=" + exception + ", unitMode=" + unitMode
+ + ", arg=" + arg + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java b/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java
new file mode 100644
index 0000000..41ed088
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java
@@ -0,0 +1,31 @@
+/**
+ * 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.hook;
+
+import org.apache.rocketmq.client.exception.MQClientException;
+
+
+/**
+ * @author manhong.yqd
+ */
+public interface CheckForbiddenHook {
+ public String hookName();
+
+
+ public void checkForbidden(final CheckForbiddenContext context) throws MQClientException;
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageContext.java b/client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageContext.java
new file mode 100644
index 0000000..f141fac
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageContext.java
@@ -0,0 +1,104 @@
+/**
+ * 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.hook;
+
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
+
+import java.util.List;
+import java.util.Map;
+
+
+public class ConsumeMessageContext {
+ private String consumerGroup;
+ private List<MessageExt> msgList;
+ private MessageQueue mq;
+ private boolean success;
+ private String status;
+ private Object mqTraceContext;
+ private Map<String, String> props;
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+
+ public List<MessageExt> getMsgList() {
+ return msgList;
+ }
+
+
+ public void setMsgList(List<MessageExt> msgList) {
+ this.msgList = msgList;
+ }
+
+
+ public MessageQueue getMq() {
+ return mq;
+ }
+
+
+ public void setMq(MessageQueue mq) {
+ this.mq = mq;
+ }
+
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+
+ public Object getMqTraceContext() {
+ return mqTraceContext;
+ }
+
+
+ public void setMqTraceContext(Object mqTraceContext) {
+ this.mqTraceContext = mqTraceContext;
+ }
+
+
+ public Map<String, String> getProps() {
+ return props;
+ }
+
+
+ public void setProps(Map<String, String> props) {
+ this.props = props;
+ }
+
+
+ public String getStatus() {
+ return status;
+ }
+
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageHook.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageHook.java b/client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageHook.java
new file mode 100644
index 0000000..8161d2e
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageHook.java
@@ -0,0 +1,25 @@
+/**
+ * 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.hook;
+
+public interface ConsumeMessageHook {
+ String hookName();
+
+ void consumeMessageBefore(final ConsumeMessageContext context);
+
+ void consumeMessageAfter(final ConsumeMessageContext context);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageContext.java b/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageContext.java
new file mode 100644
index 0000000..942fd71
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageContext.java
@@ -0,0 +1,91 @@
+/**
+ * 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.hook;
+
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
+
+import java.util.List;
+
+
+/**
+ * @author manhong.yqd
+ */
+public class FilterMessageContext {
+ private String consumerGroup;
+ private List<MessageExt> msgList;
+ private MessageQueue mq;
+ private Object arg;
+ private boolean unitMode;
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+
+ public List<MessageExt> getMsgList() {
+ return msgList;
+ }
+
+
+ public void setMsgList(List<MessageExt> msgList) {
+ this.msgList = msgList;
+ }
+
+
+ public MessageQueue getMq() {
+ return mq;
+ }
+
+
+ public void setMq(MessageQueue mq) {
+ this.mq = mq;
+ }
+
+
+ public Object getArg() {
+ return arg;
+ }
+
+
+ public void setArg(Object arg) {
+ this.arg = arg;
+ }
+
+
+ public boolean isUnitMode() {
+ return unitMode;
+ }
+
+
+ public void setUnitMode(boolean isUnitMode) {
+ this.unitMode = isUnitMode;
+ }
+
+
+ @Override
+ public String toString() {
+ return "ConsumeMessageContext [consumerGroup=" + consumerGroup + ", msgList=" + msgList + ", mq="
+ + mq + ", arg=" + arg + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java b/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java
new file mode 100644
index 0000000..016ff56
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java
@@ -0,0 +1,27 @@
+/**
+ * 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.hook;
+
+/**
+ * @author manhong.yqd
+ */
+public interface FilterMessageHook {
+ public String hookName();
+
+
+ public void filterMessage(final FilterMessageContext context);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/hook/SendMessageContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/SendMessageContext.java b/client/src/main/java/org/apache/rocketmq/client/hook/SendMessageContext.java
new file mode 100644
index 0000000..bfb4a47
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/SendMessageContext.java
@@ -0,0 +1,157 @@
+/**
+ * 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.hook;
+
+import org.apache.rocketmq.client.impl.CommunicationMode;
+import org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl;
+import org.apache.rocketmq.client.producer.SendResult;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.message.MessageType;
+
+import java.util.Map;
+
+
+public class SendMessageContext {
+ private String producerGroup;
+ private Message message;
+ private MessageQueue mq;
+ private String brokerAddr;
+ private String bornHost;
+ private CommunicationMode communicationMode;
+ private SendResult sendResult;
+ private Exception exception;
+ private Object mqTraceContext;
+ private Map<String, String> props;
+ private DefaultMQProducerImpl producer;
+ private MessageType msgType = MessageType.Normal_Msg;
+
+ public MessageType getMsgType() {
+ return msgType;
+ }
+
+ public void setMsgType(final MessageType msgType) {
+ this.msgType = msgType;
+ }
+
+ public DefaultMQProducerImpl getProducer() {
+ return producer;
+ }
+
+ public void setProducer(final DefaultMQProducerImpl producer) {
+ this.producer = producer;
+ }
+
+ public String getProducerGroup() {
+ return producerGroup;
+ }
+
+
+ public void setProducerGroup(String producerGroup) {
+ this.producerGroup = producerGroup;
+ }
+
+
+ public Message getMessage() {
+ return message;
+ }
+
+
+ public void setMessage(Message message) {
+ this.message = message;
+ }
+
+
+ public MessageQueue getMq() {
+ return mq;
+ }
+
+
+ public void setMq(MessageQueue mq) {
+ this.mq = mq;
+ }
+
+
+ public String getBrokerAddr() {
+ return brokerAddr;
+ }
+
+
+ public void setBrokerAddr(String brokerAddr) {
+ this.brokerAddr = brokerAddr;
+ }
+
+
+ public CommunicationMode getCommunicationMode() {
+ return communicationMode;
+ }
+
+
+ public void setCommunicationMode(CommunicationMode communicationMode) {
+ this.communicationMode = communicationMode;
+ }
+
+
+ public SendResult getSendResult() {
+ return sendResult;
+ }
+
+
+ public void setSendResult(SendResult sendResult) {
+ this.sendResult = sendResult;
+ }
+
+
+ public Exception getException() {
+ return exception;
+ }
+
+
+ public void setException(Exception exception) {
+ this.exception = exception;
+ }
+
+
+ public Object getMqTraceContext() {
+ return mqTraceContext;
+ }
+
+
+ public void setMqTraceContext(Object mqTraceContext) {
+ this.mqTraceContext = mqTraceContext;
+ }
+
+
+ public Map<String, String> getProps() {
+ return props;
+ }
+
+
+ public void setProps(Map<String, String> props) {
+ this.props = props;
+ }
+
+
+ public String getBornHost() {
+ return bornHost;
+ }
+
+
+ public void setBornHost(String bornHost) {
+ this.bornHost = bornHost;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/hook/SendMessageHook.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/SendMessageHook.java b/client/src/main/java/org/apache/rocketmq/client/hook/SendMessageHook.java
new file mode 100644
index 0000000..c040831
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/SendMessageHook.java
@@ -0,0 +1,25 @@
+/**
+ * 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.hook;
+
+public interface SendMessageHook {
+ String hookName();
+
+ void sendMessageBefore(final SendMessageContext context);
+
+ void sendMessageAfter(final SendMessageContext context);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java b/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
new file mode 100644
index 0000000..50e9b45
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
@@ -0,0 +1,199 @@
+/**
+ * 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.impl;
+
+import org.apache.rocketmq.client.impl.factory.MQClientInstance;
+import org.apache.rocketmq.client.impl.producer.MQProducerInner;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageDecoder;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.RequestCode;
+import org.apache.rocketmq.common.protocol.ResponseCode;
+import org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
+import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
+import org.apache.rocketmq.common.protocol.body.GetConsumerStatusBody;
+import org.apache.rocketmq.common.protocol.body.ResetOffsetBody;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import io.netty.channel.ChannelHandlerContext;
+import org.apache.rocketmq.common.protocol.header.*;
+import org.slf4j.Logger;
+
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ClientRemotingProcessor implements NettyRequestProcessor {
+ private final Logger log = ClientLogger.getLog();
+ private final MQClientInstance mqClientFactory;
+
+
+ public ClientRemotingProcessor(final MQClientInstance mqClientFactory) {
+ this.mqClientFactory = mqClientFactory;
+ }
+
+
+ @Override
+ public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ switch (request.getCode()) {
+ case RequestCode.CHECK_TRANSACTION_STATE:
+ return this.checkTransactionState(ctx, request);
+ case RequestCode.NOTIFY_CONSUMER_IDS_CHANGED:
+ return this.notifyConsumerIdsChanged(ctx, request);
+ case RequestCode.RESET_CONSUMER_CLIENT_OFFSET:
+ return this.resetOffset(ctx, request);
+ case RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT:
+ return this.getConsumeStatus(ctx, request);
+
+ case RequestCode.GET_CONSUMER_RUNNING_INFO:
+ return this.getConsumerRunningInfo(ctx, request);
+
+ case RequestCode.CONSUME_MESSAGE_DIRECTLY:
+ return this.consumeMessageDirectly(ctx, request);
+ default:
+ break;
+ }
+ return null;
+ }
+
+ @Override
+ public boolean rejectRequest() {
+ return false;
+ }
+
+ public RemotingCommand checkTransactionState(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final CheckTransactionStateRequestHeader requestHeader =
+ (CheckTransactionStateRequestHeader) request.decodeCommandCustomHeader(CheckTransactionStateRequestHeader.class);
+ final ByteBuffer byteBuffer = ByteBuffer.wrap(request.getBody());
+ final MessageExt messageExt = MessageDecoder.decode(byteBuffer);
+ if (messageExt != null) {
+ final String group = messageExt.getProperty(MessageConst.PROPERTY_PRODUCER_GROUP);
+ if (group != null) {
+ MQProducerInner producer = this.mqClientFactory.selectProducer(group);
+ if (producer != null) {
+ final String addr = RemotingHelper.parseChannelRemoteAddr(ctx.channel());
+ producer.checkTransactionState(addr, messageExt, requestHeader);
+ } else {
+ log.debug("checkTransactionState, pick producer by group[{}] failed", group);
+ }
+ } else {
+ log.warn("checkTransactionState, pick producer group failed");
+ }
+ } else {
+ log.warn("checkTransactionState, decode message failed");
+ }
+
+ return null;
+ }
+
+ public RemotingCommand notifyConsumerIdsChanged(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ try {
+ final NotifyConsumerIdsChangedRequestHeader requestHeader =
+ (NotifyConsumerIdsChangedRequestHeader) request.decodeCommandCustomHeader(NotifyConsumerIdsChangedRequestHeader.class);
+ log.info("receive broker's notification[{}], the consumer group: {} changed, rebalance immediately",
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
+ requestHeader.getConsumerGroup());
+ this.mqClientFactory.rebalanceImmediately();
+ } catch (Exception e) {
+ log.error("notifyConsumerIdsChanged exception", RemotingHelper.exceptionSimpleDesc(e));
+ }
+ return null;
+ }
+
+ public RemotingCommand resetOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final ResetOffsetRequestHeader requestHeader =
+ (ResetOffsetRequestHeader) request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
+ log.info("invoke reset offset operation from broker. brokerAddr={}, topic={}, group={}, timestamp={}",
+ new Object[]{RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
+ requestHeader.getTimestamp()});
+ Map<MessageQueue, Long> offsetTable = new HashMap<MessageQueue, Long>();
+ if (request.getBody() != null) {
+ ResetOffsetBody body = ResetOffsetBody.decode(request.getBody(), ResetOffsetBody.class);
+ offsetTable = body.getOffsetTable();
+ }
+ this.mqClientFactory.resetOffset(requestHeader.getTopic(), requestHeader.getGroup(), offsetTable);
+ return null;
+ }
+
+ @Deprecated
+ public RemotingCommand getConsumeStatus(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ final GetConsumerStatusRequestHeader requestHeader =
+ (GetConsumerStatusRequestHeader) request.decodeCommandCustomHeader(GetConsumerStatusRequestHeader.class);
+
+ Map<MessageQueue, Long> offsetTable = this.mqClientFactory.getConsumerStatus(requestHeader.getTopic(), requestHeader.getGroup());
+ GetConsumerStatusBody body = new GetConsumerStatusBody();
+ body.setMessageQueueTable(offsetTable);
+ response.setBody(body.encode());
+ response.setCode(ResponseCode.SUCCESS);
+ return response;
+ }
+
+ private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ final GetConsumerRunningInfoRequestHeader requestHeader =
+ (GetConsumerRunningInfoRequestHeader) request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);
+
+ ConsumerRunningInfo consumerRunningInfo = this.mqClientFactory.consumerRunningInfo(requestHeader.getConsumerGroup());
+ if (null != consumerRunningInfo) {
+ if (requestHeader.isJstackEnable()) {
+ Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces();
+ String jstack = UtilAll.jstack(map);
+ consumerRunningInfo.setJstack(jstack);
+ }
+
+ response.setCode(ResponseCode.SUCCESS);
+ response.setBody(consumerRunningInfo.encode());
+ } else {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark(String.format("The Consumer Group <%s> not exist in this consumer", requestHeader.getConsumerGroup()));
+ }
+
+ return response;
+ }
+
+ private RemotingCommand consumeMessageDirectly(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ final ConsumeMessageDirectlyResultRequestHeader requestHeader =
+ (ConsumeMessageDirectlyResultRequestHeader) request
+ .decodeCommandCustomHeader(ConsumeMessageDirectlyResultRequestHeader.class);
+
+ final MessageExt msg = MessageDecoder.decode(ByteBuffer.wrap(request.getBody()));
+
+ ConsumeMessageDirectlyResult result =
+ this.mqClientFactory.consumeMessageDirectly(msg, requestHeader.getConsumerGroup(), requestHeader.getBrokerName());
+
+ if (null != result) {
+ response.setCode(ResponseCode.SUCCESS);
+ response.setBody(result.encode());
+ } else {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark(String.format("The Consumer Group <%s> not exist in this consumer", requestHeader.getConsumerGroup()));
+ }
+
+ return response;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java b/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java
new file mode 100644
index 0000000..0f57339
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java
@@ -0,0 +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 org.apache.rocketmq.client.impl;
+
+/**
+ * @author shijia.wxr
+ */
+public enum CommunicationMode {
+ SYNC,
+ ASYNC,
+ ONEWAY,
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java b/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java
new file mode 100644
index 0000000..56528ef
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java
@@ -0,0 +1,41 @@
+/**
+ * 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.impl;
+
+/**
+ * @author shijia.wxr
+ */
+public class FindBrokerResult {
+ private final String brokerAddr;
+ private final boolean slave;
+
+
+ public FindBrokerResult(String brokerAddr, boolean slave) {
+ this.brokerAddr = brokerAddr;
+ this.slave = slave;
+ }
+
+
+ public String getBrokerAddr() {
+ return brokerAddr;
+ }
+
+
+ public boolean isSlave() {
+ return slave;
+ }
+}
[07/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerResponseHeader.java
new file mode 100644
index 0000000..a2a52f0
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerResponseHeader.java
@@ -0,0 +1,55 @@
+/**
+ * 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.common.protocol.header.filtersrv;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+public class RegisterFilterServerResponseHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String brokerName;
+ @CFNotNull
+ private long brokerId;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public long getBrokerId() {
+ return brokerId;
+ }
+
+
+ public void setBrokerId(long brokerId) {
+ this.brokerId = brokerId;
+ }
+
+
+ public String getBrokerName() {
+ return brokerName;
+ }
+
+
+ public void setBrokerName(String brokerName) {
+ this.brokerName = brokerName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterMessageFilterClassRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterMessageFilterClassRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterMessageFilterClassRequestHeader.java
new file mode 100644
index 0000000..1fc94a9
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterMessageFilterClassRequestHeader.java
@@ -0,0 +1,79 @@
+/**
+ * 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.common.protocol.header.filtersrv;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+public class RegisterMessageFilterClassRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String consumerGroup;
+ @CFNotNull
+ private String topic;
+ @CFNotNull
+ private String className;
+ @CFNotNull
+ private Integer classCRC;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public String getClassName() {
+ return className;
+ }
+
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+
+ public Integer getClassCRC() {
+ return classCRC;
+ }
+
+
+ public void setClassCRC(Integer classCRC) {
+ this.classCRC = classCRC;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java
new file mode 100644
index 0000000..47ec4b1
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java
@@ -0,0 +1,59 @@
+/**
+ * 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.common.protocol.header.namesrv;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ *
+ */
+public class DeleteKVConfigRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String namespace;
+ @CFNotNull
+ private String key;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+
+ public String getKey() {
+ return key;
+ }
+
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java
new file mode 100644
index 0000000..5bd0632
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java
@@ -0,0 +1,46 @@
+/**
+ * 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.common.protocol.header.namesrv;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ *
+ */
+public class DeleteTopicInNamesrvRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String topic;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java
new file mode 100644
index 0000000..29e4db4
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java
@@ -0,0 +1,59 @@
+/**
+ * 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.common.protocol.header.namesrv;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ *
+ */
+public class GetKVConfigRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String namespace;
+ @CFNotNull
+ private String key;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+
+ public String getKey() {
+ return key;
+ }
+
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java
new file mode 100644
index 0000000..3280ff5
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java
@@ -0,0 +1,47 @@
+/**
+ * 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.common.protocol.header.namesrv;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNullable;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ *
+ */
+public class GetKVConfigResponseHeader implements CommandCustomHeader {
+ @CFNullable
+ private String value;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getValue() {
+ return value;
+ }
+
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java
new file mode 100644
index 0000000..bd2816e
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java
@@ -0,0 +1,47 @@
+/**
+ * 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.common.protocol.header.namesrv;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ *
+ */
+public class GetKVListByNamespaceRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String namespace;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
new file mode 100644
index 0000000..972cf35
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
@@ -0,0 +1,49 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: GetRouteInfoRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header.namesrv;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class GetRouteInfoRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String topic;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
new file mode 100644
index 0000000..8bb681e
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
@@ -0,0 +1,37 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: GetRouteInfoResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header.namesrv;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class GetRouteInfoResponseHeader implements CommandCustomHeader {
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ // TODO Auto-generated method stub
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/PutKVConfigRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/PutKVConfigRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/PutKVConfigRequestHeader.java
new file mode 100644
index 0000000..01e9a5e
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/PutKVConfigRequestHeader.java
@@ -0,0 +1,67 @@
+/**
+ * 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.common.protocol.header.namesrv;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+public class PutKVConfigRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String namespace;
+ @CFNotNull
+ private String key;
+ @CFNotNull
+ private String value;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+
+ public String getKey() {
+ return key;
+ }
+
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+
+ public String getValue() {
+ return value;
+ }
+
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
new file mode 100644
index 0000000..4c0fca5
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
@@ -0,0 +1,97 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: RegisterBrokerRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header.namesrv;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author lansheng.zj
+ */
+public class RegisterBrokerRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String brokerName;
+ @CFNotNull
+ private String brokerAddr;
+ @CFNotNull
+ private String clusterName;
+ @CFNotNull
+ private String haServerAddr;
+ @CFNotNull
+ private Long brokerId;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getBrokerName() {
+ return brokerName;
+ }
+
+
+ public void setBrokerName(String brokerName) {
+ this.brokerName = brokerName;
+ }
+
+
+ public String getBrokerAddr() {
+ return brokerAddr;
+ }
+
+
+ public void setBrokerAddr(String brokerAddr) {
+ this.brokerAddr = brokerAddr;
+ }
+
+
+ public String getClusterName() {
+ return clusterName;
+ }
+
+
+ public void setClusterName(String clusterName) {
+ this.clusterName = clusterName;
+ }
+
+
+ public String getHaServerAddr() {
+ return haServerAddr;
+ }
+
+
+ public void setHaServerAddr(String haServerAddr) {
+ this.haServerAddr = haServerAddr;
+ }
+
+
+ public Long getBrokerId() {
+ return brokerId;
+ }
+
+
+ public void setBrokerId(Long brokerId) {
+ this.brokerId = brokerId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java
new file mode 100644
index 0000000..9796054
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java
@@ -0,0 +1,59 @@
+/**
+ * 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.common.protocol.header.namesrv;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNullable;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ *
+ */
+public class RegisterBrokerResponseHeader implements CommandCustomHeader {
+ @CFNullable
+ private String haServerAddr;
+ @CFNullable
+ private String masterAddr;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getHaServerAddr() {
+ return haServerAddr;
+ }
+
+
+ public void setHaServerAddr(String haServerAddr) {
+ this.haServerAddr = haServerAddr;
+ }
+
+
+ public String getMasterAddr() {
+ return masterAddr;
+ }
+
+
+ public void setMasterAddr(String masterAddr) {
+ this.masterAddr = masterAddr;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
new file mode 100644
index 0000000..cb5b3d9
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
@@ -0,0 +1,62 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: RegisterOrderTopicRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header.namesrv;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class RegisterOrderTopicRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String topic;
+ @CFNotNull
+ private String orderTopicString;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ // TODO Auto-generated method stub
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public String getOrderTopicString() {
+ return orderTopicString;
+ }
+
+
+ public void setOrderTopicString(String orderTopicString) {
+ this.orderTopicString = orderTopicString;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
new file mode 100644
index 0000000..f2d174a
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
@@ -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.
+ */
+
+/**
+ * $Id: UnRegisterBrokerRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header.namesrv;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author lansheng.zj
+ */
+public class UnRegisterBrokerRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String brokerName;
+ @CFNotNull
+ private String brokerAddr;
+ @CFNotNull
+ private String clusterName;
+ @CFNotNull
+ private Long brokerId;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getBrokerName() {
+ return brokerName;
+ }
+
+
+ public void setBrokerName(String brokerName) {
+ this.brokerName = brokerName;
+ }
+
+
+ public String getBrokerAddr() {
+ return brokerAddr;
+ }
+
+
+ public void setBrokerAddr(String brokerAddr) {
+ this.brokerAddr = brokerAddr;
+ }
+
+
+ public String getClusterName() {
+ return clusterName;
+ }
+
+
+ public void setClusterName(String clusterName) {
+ this.clusterName = clusterName;
+ }
+
+
+ public Long getBrokerId() {
+ return brokerId;
+ }
+
+
+ public void setBrokerId(Long brokerId) {
+ this.brokerId = brokerId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java
new file mode 100644
index 0000000..f5aebb9
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java
@@ -0,0 +1,47 @@
+/**
+ * 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.common.protocol.header.namesrv;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ *
+ */
+public class WipeWritePermOfBrokerRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String brokerName;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+
+ }
+
+
+ public String getBrokerName() {
+ return brokerName;
+ }
+
+
+ public void setBrokerName(String brokerName) {
+ this.brokerName = brokerName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java
new file mode 100644
index 0000000..e50641b
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java
@@ -0,0 +1,46 @@
+/**
+ * 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.common.protocol.header.namesrv;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ *
+ */
+public class WipeWritePermOfBrokerResponseHeader implements CommandCustomHeader {
+ @CFNotNull
+ private Integer wipeTopicCount;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public Integer getWipeTopicCount() {
+ return wipeTopicCount;
+ }
+
+
+ public void setWipeTopicCount(Integer wipeTopicCount) {
+ this.wipeTopicCount = wipeTopicCount;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
new file mode 100644
index 0000000..115a885
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
@@ -0,0 +1,42 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: ConsumeType.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.heartbeat;
+
+/**
+ * @author shijia.wxr
+ */
+public enum ConsumeType {
+
+ CONSUME_ACTIVELY("PULL"),
+
+ CONSUME_PASSIVELY("PUSH");
+
+ private String typeCN;
+
+ ConsumeType(String typeCN) {
+ this.typeCN = typeCN;
+ }
+
+
+ public String getTypeCN() {
+ return typeCN;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
new file mode 100644
index 0000000..233da6c
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
@@ -0,0 +1,107 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: ConsumerData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.heartbeat;
+
+import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
+
+import java.util.HashSet;
+import java.util.Set;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ConsumerData {
+ private String groupName;
+ private ConsumeType consumeType;
+ private MessageModel messageModel;
+ private ConsumeFromWhere consumeFromWhere;
+ private Set<SubscriptionData> subscriptionDataSet = new HashSet<SubscriptionData>();
+ private boolean unitMode;
+
+
+ public String getGroupName() {
+ return groupName;
+ }
+
+
+ public void setGroupName(String groupName) {
+ this.groupName = groupName;
+ }
+
+
+ public ConsumeType getConsumeType() {
+ return consumeType;
+ }
+
+
+ public void setConsumeType(ConsumeType consumeType) {
+ this.consumeType = consumeType;
+ }
+
+
+ public MessageModel getMessageModel() {
+ return messageModel;
+ }
+
+
+ public void setMessageModel(MessageModel messageModel) {
+ this.messageModel = messageModel;
+ }
+
+
+ public ConsumeFromWhere getConsumeFromWhere() {
+ return consumeFromWhere;
+ }
+
+
+ public void setConsumeFromWhere(ConsumeFromWhere consumeFromWhere) {
+ this.consumeFromWhere = consumeFromWhere;
+ }
+
+
+ public Set<SubscriptionData> getSubscriptionDataSet() {
+ return subscriptionDataSet;
+ }
+
+
+ public void setSubscriptionDataSet(Set<SubscriptionData> subscriptionDataSet) {
+ this.subscriptionDataSet = subscriptionDataSet;
+ }
+
+
+ public boolean isUnitMode() {
+ return unitMode;
+ }
+
+
+ public void setUnitMode(boolean isUnitMode) {
+ this.unitMode = isUnitMode;
+ }
+
+
+ @Override
+ public String toString() {
+ return "ConsumerData [groupName=" + groupName + ", consumeType=" + consumeType + ", messageModel="
+ + messageModel + ", consumeFromWhere=" + consumeFromWhere + ", unitMode=" + unitMode
+ + ", subscriptionDataSet=" + subscriptionDataSet + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
new file mode 100644
index 0000000..8fa5b17
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
@@ -0,0 +1,73 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: HeartbeatData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.heartbeat;
+
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.HashSet;
+import java.util.Set;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class HeartbeatData extends RemotingSerializable {
+ private String clientID;
+ private Set<ProducerData> producerDataSet = new HashSet<ProducerData>();
+ private Set<ConsumerData> consumerDataSet = new HashSet<ConsumerData>();
+
+
+ public String getClientID() {
+ return clientID;
+ }
+
+
+ public void setClientID(String clientID) {
+ this.clientID = clientID;
+ }
+
+
+ public Set<ProducerData> getProducerDataSet() {
+ return producerDataSet;
+ }
+
+
+ public void setProducerDataSet(Set<ProducerData> producerDataSet) {
+ this.producerDataSet = producerDataSet;
+ }
+
+
+ public Set<ConsumerData> getConsumerDataSet() {
+ return consumerDataSet;
+ }
+
+
+ public void setConsumerDataSet(Set<ConsumerData> consumerDataSet) {
+ this.consumerDataSet = consumerDataSet;
+ }
+
+
+ @Override
+ public String toString() {
+ return "HeartbeatData [clientID=" + clientID + ", producerDataSet=" + producerDataSet
+ + ", consumerDataSet=" + consumerDataSet + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
new file mode 100644
index 0000000..4600c6f
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
@@ -0,0 +1,48 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: MessageModel.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.heartbeat;
+
+/**
+ * Message model
+ *
+ * @author shijia.wxr
+ */
+public enum MessageModel {
+ /**
+ * broadcast
+ */
+ BROADCASTING("BROADCASTING"),
+ /**
+ * clustering
+ */
+ CLUSTERING("CLUSTERING");
+
+ private String modeCN;
+
+ MessageModel(String modeCN) {
+ this.modeCN = modeCN;
+ }
+
+
+ public String getModeCN() {
+ return modeCN;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
new file mode 100644
index 0000000..c83b14c
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
@@ -0,0 +1,44 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: ProducerData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.heartbeat;
+
+/**
+ * @author shijia.wxr
+ */
+public class ProducerData {
+ private String groupName;
+
+
+ public String getGroupName() {
+ return groupName;
+ }
+
+
+ public void setGroupName(String groupName) {
+ this.groupName = groupName;
+ }
+
+
+ @Override
+ public String toString() {
+ return "ProducerData [groupName=" + groupName + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
new file mode 100644
index 0000000..28b49f1
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
@@ -0,0 +1,188 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: SubscriptionData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.heartbeat;
+
+import com.alibaba.fastjson.annotation.JSONField;
+
+import java.util.HashSet;
+import java.util.Set;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class SubscriptionData implements Comparable<SubscriptionData> {
+ public final static String SUB_ALL = "*";
+ private boolean classFilterMode = false;
+ private String topic;
+ private String subString;
+ private Set<String> tagsSet = new HashSet<String>();
+ private Set<Integer> codeSet = new HashSet<Integer>();
+ private long subVersion = System.currentTimeMillis();
+
+ @JSONField(serialize = false)
+ private String filterClassSource;
+
+
+ public SubscriptionData() {
+
+ }
+
+
+ public SubscriptionData(String topic, String subString) {
+ super();
+ this.topic = topic;
+ this.subString = subString;
+ }
+
+ public String getFilterClassSource() {
+ return filterClassSource;
+ }
+
+ public void setFilterClassSource(String filterClassSource) {
+ this.filterClassSource = filterClassSource;
+ }
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public String getSubString() {
+ return subString;
+ }
+
+
+ public void setSubString(String subString) {
+ this.subString = subString;
+ }
+
+
+ public Set<String> getTagsSet() {
+ return tagsSet;
+ }
+
+
+ public void setTagsSet(Set<String> tagsSet) {
+ this.tagsSet = tagsSet;
+ }
+
+
+ public long getSubVersion() {
+ return subVersion;
+ }
+
+
+ public void setSubVersion(long subVersion) {
+ this.subVersion = subVersion;
+ }
+
+
+ public Set<Integer> getCodeSet() {
+ return codeSet;
+ }
+
+
+ public void setCodeSet(Set<Integer> codeSet) {
+ this.codeSet = codeSet;
+ }
+
+
+ public boolean isClassFilterMode() {
+ return classFilterMode;
+ }
+
+
+ public void setClassFilterMode(boolean classFilterMode) {
+ this.classFilterMode = classFilterMode;
+ }
+
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (classFilterMode ? 1231 : 1237);
+ result = prime * result + ((codeSet == null) ? 0 : codeSet.hashCode());
+ result = prime * result + ((subString == null) ? 0 : subString.hashCode());
+ result = prime * result + ((tagsSet == null) ? 0 : tagsSet.hashCode());
+ result = prime * result + ((topic == null) ? 0 : topic.hashCode());
+ return result;
+ }
+
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ SubscriptionData other = (SubscriptionData) obj;
+ if (classFilterMode != other.classFilterMode)
+ return false;
+ if (codeSet == null) {
+ if (other.codeSet != null)
+ return false;
+ } else if (!codeSet.equals(other.codeSet))
+ return false;
+ if (subString == null) {
+ if (other.subString != null)
+ return false;
+ } else if (!subString.equals(other.subString))
+ return false;
+ if (subVersion != other.subVersion)
+ return false;
+ if (tagsSet == null) {
+ if (other.tagsSet != null)
+ return false;
+ } else if (!tagsSet.equals(other.tagsSet))
+ return false;
+ if (topic == null) {
+ if (other.topic != null)
+ return false;
+ } else if (!topic.equals(other.topic))
+ return false;
+ return true;
+ }
+
+
+ @Override
+ public String toString() {
+ return "SubscriptionData [classFilterMode=" + classFilterMode + ", topic=" + topic + ", subString="
+ + subString + ", tagsSet=" + tagsSet + ", codeSet=" + codeSet + ", subVersion=" + subVersion
+ + "]";
+ }
+
+
+ @Override
+ public int compareTo(SubscriptionData other) {
+ String thisValue = this.topic + "@" + this.subString;
+ String otherValue = other.topic + "@" + other.subString;
+ return thisValue.compareTo(otherValue);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
new file mode 100644
index 0000000..1696cd6
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
@@ -0,0 +1,113 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: BrokerData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.route;
+
+import org.apache.rocketmq.common.MixAll;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * @author shijia.wxr
+ *
+ */
+public class BrokerData implements Comparable<BrokerData> {
+ private String cluster;
+ private String brokerName;
+ private HashMap<Long/* brokerId */, String/* broker address */> brokerAddrs;
+
+ public String selectBrokerAddr() {
+ String value = this.brokerAddrs.get(MixAll.MASTER_ID);
+ if (null == value) {
+ for (Map.Entry<Long, String> entry : this.brokerAddrs.entrySet()) {
+ return entry.getValue();
+ }
+ }
+
+ return value;
+ }
+
+ public HashMap<Long, String> getBrokerAddrs() {
+ return brokerAddrs;
+ }
+
+ public void setBrokerAddrs(HashMap<Long, String> brokerAddrs) {
+ this.brokerAddrs = brokerAddrs;
+ }
+
+ public String getCluster() {
+ return cluster;
+ }
+
+ public void setCluster(String cluster) {
+ this.cluster = cluster;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((brokerAddrs == null) ? 0 : brokerAddrs.hashCode());
+ result = prime * result + ((brokerName == null) ? 0 : brokerName.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ BrokerData other = (BrokerData) obj;
+ if (brokerAddrs == null) {
+ if (other.brokerAddrs != null)
+ return false;
+ } else if (!brokerAddrs.equals(other.brokerAddrs))
+ return false;
+ if (brokerName == null) {
+ if (other.brokerName != null)
+ return false;
+ } else if (!brokerName.equals(other.brokerName))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "BrokerData [brokerName=" + brokerName + ", brokerAddrs=" + brokerAddrs + "]";
+ }
+
+ @Override
+ public int compareTo(BrokerData o) {
+ return this.brokerName.compareTo(o.getBrokerName());
+ }
+
+ public String getBrokerName() {
+ return brokerName;
+ }
+
+ public void setBrokerName(String brokerName) {
+ this.brokerName = brokerName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java
new file mode 100644
index 0000000..de736be
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java
@@ -0,0 +1,118 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: QueueData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.route;
+
+public class QueueData implements Comparable<QueueData> {
+ private String brokerName;
+ private int readQueueNums;
+ private int writeQueueNums;
+ private int perm;
+ private int topicSynFlag;
+
+ public int getReadQueueNums() {
+ return readQueueNums;
+ }
+
+ public void setReadQueueNums(int readQueueNums) {
+ this.readQueueNums = readQueueNums;
+ }
+
+ public int getWriteQueueNums() {
+ return writeQueueNums;
+ }
+
+ public void setWriteQueueNums(int writeQueueNums) {
+ this.writeQueueNums = writeQueueNums;
+ }
+
+ public int getPerm() {
+ return perm;
+ }
+
+ public void setPerm(int perm) {
+ this.perm = perm;
+ }
+
+ public int getTopicSynFlag() {
+ return topicSynFlag;
+ }
+
+ public void setTopicSynFlag(int topicSynFlag) {
+ this.topicSynFlag = topicSynFlag;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((brokerName == null) ? 0 : brokerName.hashCode());
+ result = prime * result + perm;
+ result = prime * result + readQueueNums;
+ result = prime * result + writeQueueNums;
+ result = prime * result + topicSynFlag;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ QueueData other = (QueueData) obj;
+ if (brokerName == null) {
+ if (other.brokerName != null)
+ return false;
+ } else if (!brokerName.equals(other.brokerName))
+ return false;
+ if (perm != other.perm)
+ return false;
+ if (readQueueNums != other.readQueueNums)
+ return false;
+ if (writeQueueNums != other.writeQueueNums)
+ return false;
+ if (topicSynFlag != other.topicSynFlag)
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "QueueData [brokerName=" + brokerName + ", readQueueNums=" + readQueueNums
+ + ", writeQueueNums=" + writeQueueNums + ", perm=" + perm + ", topicSynFlag=" + topicSynFlag
+ + "]";
+ }
+
+ @Override
+ public int compareTo(QueueData o) {
+ return this.brokerName.compareTo(o.getBrokerName());
+ }
+
+ public String getBrokerName() {
+ return brokerName;
+ }
+
+ public void setBrokerName(String brokerName) {
+ this.brokerName = brokerName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
new file mode 100644
index 0000000..13c5273
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
@@ -0,0 +1,146 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: TopicRouteData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.route;
+
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class TopicRouteData extends RemotingSerializable {
+ private String orderTopicConf;
+ private List<QueueData> queueDatas;
+ private List<BrokerData> brokerDatas;
+ private HashMap<String/* brokerAddr */, List<String>/* Filter Server */> filterServerTable;
+
+
+ public TopicRouteData cloneTopicRouteData() {
+ TopicRouteData topicRouteData = new TopicRouteData();
+ topicRouteData.setQueueDatas(new ArrayList<QueueData>());
+ topicRouteData.setBrokerDatas(new ArrayList<BrokerData>());
+ topicRouteData.setFilterServerTable(new HashMap<String, List<String>>());
+ topicRouteData.setOrderTopicConf(this.orderTopicConf);
+
+ if (this.queueDatas != null) {
+ topicRouteData.getQueueDatas().addAll(this.queueDatas);
+ }
+
+ if (this.brokerDatas != null) {
+ topicRouteData.getBrokerDatas().addAll(this.brokerDatas);
+ }
+
+ if (this.filterServerTable != null) {
+ topicRouteData.getFilterServerTable().putAll(this.filterServerTable);
+ }
+
+ return topicRouteData;
+ }
+
+
+ public List<QueueData> getQueueDatas() {
+ return queueDatas;
+ }
+
+
+ public void setQueueDatas(List<QueueData> queueDatas) {
+ this.queueDatas = queueDatas;
+ }
+
+
+ public List<BrokerData> getBrokerDatas() {
+ return brokerDatas;
+ }
+
+
+ public void setBrokerDatas(List<BrokerData> brokerDatas) {
+ this.brokerDatas = brokerDatas;
+ }
+
+ public HashMap<String, List<String>> getFilterServerTable() {
+ return filterServerTable;
+ }
+
+ public void setFilterServerTable(HashMap<String, List<String>> filterServerTable) {
+ this.filterServerTable = filterServerTable;
+ }
+
+ public String getOrderTopicConf() {
+ return orderTopicConf;
+ }
+
+ public void setOrderTopicConf(String orderTopicConf) {
+ this.orderTopicConf = orderTopicConf;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((brokerDatas == null) ? 0 : brokerDatas.hashCode());
+ result = prime * result + ((orderTopicConf == null) ? 0 : orderTopicConf.hashCode());
+ result = prime * result + ((queueDatas == null) ? 0 : queueDatas.hashCode());
+ result = prime * result + ((filterServerTable == null) ? 0 : filterServerTable.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ TopicRouteData other = (TopicRouteData) obj;
+ if (brokerDatas == null) {
+ if (other.brokerDatas != null)
+ return false;
+ } else if (!brokerDatas.equals(other.brokerDatas))
+ return false;
+ if (orderTopicConf == null) {
+ if (other.orderTopicConf != null)
+ return false;
+ } else if (!orderTopicConf.equals(other.orderTopicConf))
+ return false;
+ if (queueDatas == null) {
+ if (other.queueDatas != null)
+ return false;
+ } else if (!queueDatas.equals(other.queueDatas))
+ return false;
+ if (filterServerTable == null) {
+ if (other.filterServerTable != null)
+ return false;
+ } else if (!filterServerTable.equals(other.filterServerTable))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "TopicRouteData [orderTopicConf=" + orderTopicConf + ", queueDatas=" + queueDatas
+ + ", brokerDatas=" + brokerDatas + ", filterServerTable=" + filterServerTable + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/topic/OffsetMovedEvent.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/topic/OffsetMovedEvent.java b/common/src/main/java/org/apache/rocketmq/common/protocol/topic/OffsetMovedEvent.java
new file mode 100644
index 0000000..df5ec71
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/topic/OffsetMovedEvent.java
@@ -0,0 +1,76 @@
+/**
+ * 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.common.protocol.topic;
+
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+
+public class OffsetMovedEvent extends RemotingSerializable {
+ private String consumerGroup;
+ private MessageQueue messageQueue;
+ private long offsetRequest;
+ private long offsetNew;
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+
+ public MessageQueue getMessageQueue() {
+ return messageQueue;
+ }
+
+
+ public void setMessageQueue(MessageQueue messageQueue) {
+ this.messageQueue = messageQueue;
+ }
+
+
+ public long getOffsetRequest() {
+ return offsetRequest;
+ }
+
+
+ public void setOffsetRequest(long offsetRequest) {
+ this.offsetRequest = offsetRequest;
+ }
+
+
+ public long getOffsetNew() {
+ return offsetNew;
+ }
+
+
+ public void setOffsetNew(long offsetNew) {
+ this.offsetNew = offsetNew;
+ }
+
+
+ @Override
+ public String toString() {
+ return "OffsetMovedEvent [consumerGroup=" + consumerGroup + ", messageQueue=" + messageQueue
+ + ", offsetRequest=" + offsetRequest + ", offsetNew=" + offsetNew + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java b/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java
new file mode 100644
index 0000000..7036fdd
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/queue/ConcurrentTreeMap.java
@@ -0,0 +1,81 @@
+/**
+ * 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.common.queue;
+
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Comparator;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.concurrent.locks.ReentrantLock;
+
+
+/**
+ * thread safe
+ *
+ * @author lansheng.zj
+ */
+public class ConcurrentTreeMap<K, V> {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+ private final ReentrantLock lock;
+ private TreeMap<K, V> tree;
+ private RoundQueue<K> roundQueue;
+
+
+ public ConcurrentTreeMap(int capacity, Comparator<? super K> comparator) {
+ tree = new TreeMap<K, V>(comparator);
+ roundQueue = new RoundQueue<K>(capacity);
+ lock = new ReentrantLock(true);
+ }
+
+
+ public Map.Entry<K, V> pollFirstEntry() {
+ lock.lock();
+ try {
+ return tree.pollFirstEntry();
+ } finally {
+ lock.unlock();
+ }
+ }
+
+
+ public V putIfAbsentAndRetExsit(K key, V value) {
+ lock.lock();
+ try {
+ if (roundQueue.put(key)) {
+ V exsit = tree.get(key);
+ if (null == exsit) {
+ tree.put(key, value);
+ exsit = value;
+ }
+ log.warn("putIfAbsentAndRetExsit success. {}", key);
+ return exsit;
+ }
+
+ else {
+ V exsit = tree.get(key);
+ return exsit;
+ }
+ } finally {
+ lock.unlock();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.java b/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.java
new file mode 100644
index 0000000..f32569b
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/queue/RoundQueue.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 org.apache.rocketmq.common.queue;
+
+import java.util.LinkedList;
+import java.util.Queue;
+
+
+/**
+ * not thread safe
+ *
+ * @author lansheng.zj
+ */
+public class RoundQueue<E> {
+
+ private Queue<E> queue;
+ private int capacity;
+
+
+ public RoundQueue(int capacity) {
+ this.capacity = capacity;
+ queue = new LinkedList<E>();
+ }
+
+
+ public boolean put(E e) {
+ boolean ok = false;
+ if (!queue.contains(e)) {
+ if (queue.size() >= capacity) {
+ queue.poll();
+ }
+ queue.add(e);
+ ok = true;
+ }
+
+ return ok;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/running/RunningStats.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/running/RunningStats.java b/common/src/main/java/org/apache/rocketmq/common/running/RunningStats.java
new file mode 100644
index 0000000..106d111
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/running/RunningStats.java
@@ -0,0 +1,25 @@
+/**
+ * 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.common.running;
+
+public enum RunningStats {
+ commitLogMaxOffset,
+ commitLogMinOffset,
+ commitLogDiskRatio,
+ consumeQueueDiskRatio,
+ scheduleMessageOffset,
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItem.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItem.java b/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItem.java
new file mode 100644
index 0000000..58eedb2
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItem.java
@@ -0,0 +1,82 @@
+/**
+ * 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.common.stats;
+
+import org.apache.rocketmq.common.UtilAll;
+import org.slf4j.Logger;
+
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+
+public class MomentStatsItem {
+
+ private final AtomicLong value = new AtomicLong(0);
+
+ private final String statsName;
+ private final String statsKey;
+ private final ScheduledExecutorService scheduledExecutorService;
+ private final Logger log;
+
+
+ public MomentStatsItem(String statsName, String statsKey,
+ ScheduledExecutorService scheduledExecutorService, Logger log) {
+ this.statsName = statsName;
+ this.statsKey = statsKey;
+ this.scheduledExecutorService = scheduledExecutorService;
+ this.log = log;
+ }
+
+
+ public void init() {
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ printAtMinutes();
+
+ MomentStatsItem.this.value.set(0);
+ } catch (Throwable e) {
+ }
+ }
+ }, Math.abs(UtilAll.computNextMinutesTimeMillis() - System.currentTimeMillis()), 1000 * 60 * 5, TimeUnit.MILLISECONDS);
+ }
+
+
+ public void printAtMinutes() {
+ log.info(String.format("[%s] [%s] Stats Every 5 Minutes, Value: %d",
+ this.statsName,
+ this.statsKey,
+ this.value.get()));
+ }
+
+ public AtomicLong getValue() {
+ return value;
+ }
+
+
+ public String getStatsKey() {
+ return statsKey;
+ }
+
+
+ public String getStatsName() {
+ return statsName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItemSet.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItemSet.java b/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItemSet.java
new file mode 100644
index 0000000..aba61c7
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/stats/MomentStatsItemSet.java
@@ -0,0 +1,94 @@
+/**
+ * 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.common.stats;
+
+import org.apache.rocketmq.common.UtilAll;
+import org.slf4j.Logger;
+
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+
+public class MomentStatsItemSet {
+ private final ConcurrentHashMap<String/* key */, MomentStatsItem> statsItemTable =
+ new ConcurrentHashMap<String, MomentStatsItem>(128);
+ private final String statsName;
+ private final ScheduledExecutorService scheduledExecutorService;
+ private final Logger log;
+
+
+ public MomentStatsItemSet(String statsName, ScheduledExecutorService scheduledExecutorService, Logger log) {
+ this.statsName = statsName;
+ this.scheduledExecutorService = scheduledExecutorService;
+ this.log = log;
+ this.init();
+ }
+
+ public ConcurrentHashMap<String, MomentStatsItem> getStatsItemTable() {
+ return statsItemTable;
+ }
+
+ public String getStatsName() {
+ return statsName;
+ }
+
+ public void init() {
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ printAtMinutes();
+ } catch (Throwable e) {
+ }
+ }
+ }, Math.abs(UtilAll.computNextMinutesTimeMillis() - System.currentTimeMillis()), 1000 * 60 * 5, TimeUnit.MILLISECONDS);
+ }
+
+ private void printAtMinutes() {
+ Iterator<Entry<String, MomentStatsItem>> it = this.statsItemTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, MomentStatsItem> next = it.next();
+ next.getValue().printAtMinutes();
+ }
+ }
+
+ public void setValue(final String statsKey, final int value) {
+ MomentStatsItem statsItem = this.getAndCreateStatsItem(statsKey);
+ statsItem.getValue().set(value);
+ }
+
+ public MomentStatsItem getAndCreateStatsItem(final String statsKey) {
+ MomentStatsItem statsItem = this.statsItemTable.get(statsKey);
+ if (null == statsItem) {
+ statsItem =
+ new MomentStatsItem(this.statsName, statsKey, this.scheduledExecutorService, this.log);
+ MomentStatsItem prev = this.statsItemTable.put(statsKey, statsItem);
+
+ if (null == prev) {
+
+ // statsItem.init();
+ }
+ }
+
+ return statsItem;
+ }
+}
[54/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Use apache
email as author.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
index 4a39a25..2513c19 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: GetAllTopicConfigResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: GetAllTopicConfigResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -25,7 +25,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class GetAllTopicConfigResponseHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
index 67cc8eb..18983f6 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: GetBrokerConfigResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: GetBrokerConfigResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class GetBrokerConfigResponseHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
index 2a84db6..fee6361 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
@@ -22,7 +22,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class GetConsumeStatsRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
index e49f775..583acd0 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
@@ -24,7 +24,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class GetConsumerConnectionListRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java
index 45d3a2c..bc31cd8 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java
@@ -23,7 +23,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class GetConsumerListByGroupRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java
index 6563ed5..4d2a9aa 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java
@@ -23,7 +23,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class GetConsumerListByGroupResponseBody extends RemotingSerializable {
private List<String> consumerIdList;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java
index 8719826..5a2161a 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java
@@ -22,7 +22,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class GetConsumerListByGroupResponseHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java
index fd1e589..c239cd0 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java
@@ -24,7 +24,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class GetConsumerRunningInfoRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
index 00e2d84..afc0462 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: GetEarliestMsgStoretimeRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: GetEarliestMsgStoretimeRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class GetEarliestMsgStoretimeRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
index 84e6925..1952467 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: GetEarliestMsgStoretimeResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: GetEarliestMsgStoretimeResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class GetEarliestMsgStoretimeResponseHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
index 1fff0b8..6c8519f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: GetMaxOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: GetMaxOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class GetMaxOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
index 577e405..765a35a 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: GetMaxOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: GetMaxOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class GetMaxOffsetResponseHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
index 687f003..b6db3f2 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: GetMinOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: GetMinOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class GetMinOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
index 4c788db..6acada7 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: GetMinOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: GetMinOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class GetMinOffsetResponseHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java
index 078d632..0832a21 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java
@@ -23,7 +23,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class GetProducerConnectionListRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java
index 5c65c33..02d828b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java
@@ -23,7 +23,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class GetTopicStatsInfoRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java
index bbd812f..31c07ba 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java
@@ -23,7 +23,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class NotifyConsumerIdsChangedRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
index f8cd7d6..efeed70 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: PullMessageRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: PullMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -27,7 +27,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class PullMessageRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
index f532735..5a78f7d 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: PullMessageResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: PullMessageResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class PullMessageResponseHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
index 9449c57..0da648f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: QueryConsumerOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: QueryConsumerOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class QueryConsumerOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
index 55f41e5..268bc77 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: QueryConsumerOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: QueryConsumerOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class QueryConsumerOffsetResponseHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
index 5ddb27a..81ad1ca 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: GetMinOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: GetMinOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
index a72d33d..e30f5fc 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: QueryMessageRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: QueryMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class QueryMessageRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
index 978101f..1f5bcae 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: QueryMessageResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: QueryMessageResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class QueryMessageResponseHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
index 8b97a4f..267144e 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: QueryMessageRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: QueryMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class QueryTopicConsumeByWhoRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
index 963d10d..5e86e16 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: SearchOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: SearchOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class SearchOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
index 422c6d4..fbe6f00 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: SearchOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: SearchOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class SearchOffsetResponseHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
index 589f4fc..c9a7c7d 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: SendMessageRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: SendMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -27,7 +27,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class SendMessageRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
index e467d9f..4206d0b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
@@ -25,7 +25,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
* Use short variable name to speed up FastJson deserialization process.
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class SendMessageRequestHeaderV2 implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
index 32c55c0..58c6def 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: SendMessageResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: SendMessageResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class SendMessageResponseHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
index 1fac7b6..d262f1f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
@@ -27,7 +27,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class UnregisterClientRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
index a6d016c..01f5085 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
@@ -25,7 +25,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class UnregisterClientResponseHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
index 7fc015e..6cf95a5 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: UpdateConsumerOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: UpdateConsumerOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class UpdateConsumerOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
index 3d5454a..7654a76 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: UpdateConsumerOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: UpdateConsumerOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -25,7 +25,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class UpdateConsumerOffsetResponseHeader implements CommandCustomHeader {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
index 716d418..710a87f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: ViewMessageRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: ViewMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ViewMessageRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
index c9284f9..1c03754 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: ViewMessageResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: ViewMessageResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header;
@@ -25,7 +25,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ViewMessageResponseHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java
index 47ec4b1..da4ce8a 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java
@@ -23,7 +23,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class DeleteKVConfigRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java
index 5bd0632..5d897c0 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java
@@ -22,7 +22,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class DeleteTopicInNamesrvRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java
index 29e4db4..9052ae2 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java
@@ -23,7 +23,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class GetKVConfigRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java
index 3280ff5..4c20e25 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java
@@ -23,7 +23,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class GetKVConfigResponseHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java
index bd2816e..4a614ff 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java
@@ -23,7 +23,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class GetKVListByNamespaceRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
index 972cf35..b827e8c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: GetRouteInfoRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: GetRouteInfoRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header.namesrv;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class GetRouteInfoRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
index 8bb681e..49a7c6c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: GetRouteInfoResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: GetRouteInfoResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header.namesrv;
@@ -25,7 +25,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class GetRouteInfoResponseHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
index 4c0fca5..be63e0e 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: RegisterBrokerRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: RegisterBrokerRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header.namesrv;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java
index 9796054..d742b83 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java
@@ -23,7 +23,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class RegisterBrokerResponseHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
index cb5b3d9..89714f5 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: RegisterOrderTopicRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: RegisterOrderTopicRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header.namesrv;
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class RegisterOrderTopicRequestHeader implements CommandCustomHeader {
@CFNotNull
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
index f2d174a..d517f2d 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: UnRegisterBrokerRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: UnRegisterBrokerRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.header.namesrv;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java
index f5aebb9..999b163 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java
@@ -22,7 +22,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class WipeWritePermOfBrokerRequestHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java
index e50641b..1b82074 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java
@@ -22,7 +22,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class WipeWritePermOfBrokerResponseHeader implements CommandCustomHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
index 115a885..5e8aeb3 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumeType.java
@@ -16,12 +16,12 @@
*/
/**
- * $Id: ConsumeType.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: ConsumeType.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.heartbeat;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public enum ConsumeType {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
index 233da6c..3a42702 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ConsumerData.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: ConsumerData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: ConsumerData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.heartbeat;
@@ -27,7 +27,7 @@ import java.util.Set;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ConsumerData {
private String groupName;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
index 8fa5b17..a0768bb 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/HeartbeatData.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: HeartbeatData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: HeartbeatData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.heartbeat;
@@ -27,7 +27,7 @@ import java.util.Set;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class HeartbeatData extends RemotingSerializable {
private String clientID;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
index 4600c6f..8dbb085 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/MessageModel.java
@@ -16,14 +16,14 @@
*/
/**
- * $Id: MessageModel.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: MessageModel.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.heartbeat;
/**
* Message model
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public enum MessageModel {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
index c83b14c..cf2c244 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/ProducerData.java
@@ -16,12 +16,12 @@
*/
/**
- * $Id: ProducerData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: ProducerData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.heartbeat;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ProducerData {
private String groupName;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
index 28b49f1..0cffabf 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/heartbeat/SubscriptionData.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: SubscriptionData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: SubscriptionData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.heartbeat;
@@ -27,7 +27,7 @@ import java.util.Set;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class SubscriptionData implements Comparable<SubscriptionData> {
public final static String SUB_ALL = "*";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
index 1696cd6..e4020f3 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/route/BrokerData.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: BrokerData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: BrokerData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.route;
@@ -27,7 +27,7 @@ import java.util.Map;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class BrokerData implements Comparable<BrokerData> {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java
index de736be..3c72565 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/route/QueueData.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: QueueData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: QueueData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.route;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
index 13c5273..1ea624e 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/route/TopicRouteData.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: TopicRouteData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ * $Id: TopicRouteData.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package org.apache.rocketmq.common.protocol.route;
@@ -28,7 +28,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class TopicRouteData extends RemotingSerializable {
private String orderTopicConf;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java b/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
index 5c3a3c3..8a3bc2f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
+++ b/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
@@ -21,7 +21,7 @@ import org.apache.rocketmq.common.MixAll;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class SubscriptionGroupConfig {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java b/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java
index 8a069e5..a32bc48 100644
--- a/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java
+++ b/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.common.sysflag;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MessageSysFlag {
public final static int COMPRESSED_FLAG = 0x1;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java b/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java
index cc2a5c8..34f72b5 100644
--- a/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java
+++ b/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.common.sysflag;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class PullSysFlag {
private final static int FLAG_COMMIT_OFFSET = 0x1 << 0;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java b/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java
index b67c59a..5b2d629 100644
--- a/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java
+++ b/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java
@@ -23,7 +23,7 @@ import org.junit.Test;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class FilterAPITest {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
index 1663dfc..819e6e0 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
@@ -32,7 +32,7 @@ import org.apache.rocketmq.remoting.protocol.RemotingCommand;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class FilterServerOuterAPI {
private final RemotingClient remotingClient;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java
index cb862a6..c4bb8c6 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java
@@ -38,7 +38,7 @@ import java.util.concurrent.TimeUnit;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class FiltersrvController {
private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
index 4e1fbc4..2cde073 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
@@ -40,7 +40,7 @@ import java.util.concurrent.atomic.AtomicInteger;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class FiltersrvStartup {
public static Logger log;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
index 5553952..689e27d 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
@@ -52,7 +52,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class DefaultRequestProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvController.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvController.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvController.java
index 88607cc..a9f8736 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvController.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvController.java
@@ -38,7 +38,7 @@ import java.util.concurrent.TimeUnit;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class NamesrvController {
private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
index 370daf6..6806ddf 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
@@ -41,7 +41,7 @@ import java.util.concurrent.atomic.AtomicInteger;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class NamesrvStartup {
public static Properties properties = null;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java
index 2518c4e..e3da731 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java
@@ -32,7 +32,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class KVConfigManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigSerializeWrapper.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigSerializeWrapper.java
index 291a5c7..9f7e2b8 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigSerializeWrapper.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigSerializeWrapper.java
@@ -22,7 +22,7 @@ import java.util.HashMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class KVConfigSerializeWrapper extends RemotingSerializable {
private HashMap<String/* Namespace */, HashMap<String/* Key */, String/* Value */>> configTable;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java
index f173ad6..df78ee2 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java
@@ -45,7 +45,7 @@ import java.util.concurrent.atomic.AtomicLong;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class DefaultRequestProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/BrokerHousekeepingService.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/BrokerHousekeepingService.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/BrokerHousekeepingService.java
index c2f5425..b33f174 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/BrokerHousekeepingService.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/BrokerHousekeepingService.java
@@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class BrokerHousekeepingService implements ChannelEventListener {
private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
index 3930460..f628922 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
@@ -42,7 +42,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class RouteInfoManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 39ea763..c32d424 100644
--- a/pom.xml
+++ b/pom.xml
@@ -79,14 +79,14 @@
<timezone>8</timezone>
</developer>
<developer>
- <id>vongosling</id>
- <name>vongosling</name>
+ <id>vongosling@apache.org</id>
+ <name>vongosling@apache.org</name>
<roles>
<role>architect</role>
<role>committer</role>
</roles>
- <email>vongosling@apache.org</email>
- <url>https://github.com/vongosling</url>
+ <email>vongosling@apache.org@apache.org</email>
+ <url>https://github.com/vongosling@apache.org</url>
<timezone>+8</timezone>
</developer>
<developer>
@@ -180,7 +180,7 @@
<version>2.2</version>
</plugin>
<plugin>
- <groupId>com.github.vongosling</groupId>
+ <groupId>com.github.vongosling@apache.org</groupId>
<artifactId>dependency-mediator-maven-plugin</artifactId>
<version>1.0.2</version>
</plugin>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/ChannelEventListener.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/ChannelEventListener.java b/remoting/src/main/java/org/apache/rocketmq/remoting/ChannelEventListener.java
index a25a373..180c8f3 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/ChannelEventListener.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/ChannelEventListener.java
@@ -20,7 +20,7 @@ import io.netty.channel.Channel;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public interface ChannelEventListener {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/CommandCustomHeader.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/CommandCustomHeader.java b/remoting/src/main/java/org/apache/rocketmq/remoting/CommandCustomHeader.java
index 6bbd9a0..1cd1c66 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/CommandCustomHeader.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/CommandCustomHeader.java
@@ -20,7 +20,7 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface CommandCustomHeader {
void checkFields() throws RemotingCommandException;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/InvokeCallback.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/InvokeCallback.java b/remoting/src/main/java/org/apache/rocketmq/remoting/InvokeCallback.java
index ace5377..24835b9 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/InvokeCallback.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/InvokeCallback.java
@@ -20,7 +20,7 @@ import org.apache.rocketmq.remoting.netty.ResponseFuture;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public interface InvokeCallback {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClient.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClient.java b/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClient.java
index 5905c1a..c0bc679 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClient.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClient.java
@@ -28,7 +28,7 @@ import java.util.concurrent.ExecutorService;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public interface RemotingClient extends RemotingService {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServer.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServer.java b/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServer.java
index 7202c18..8579d75 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServer.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServer.java
@@ -28,7 +28,7 @@ import java.util.concurrent.ExecutorService;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public interface RemotingServer extends RemotingService {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNotNull.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNotNull.java b/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNotNull.java
index d4afa90..1486465 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNotNull.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNotNull.java
@@ -23,7 +23,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNullable.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNullable.java b/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNullable.java
index aa4af0a..caa2a39 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNullable.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNullable.java
@@ -23,7 +23,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/common/Pair.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/Pair.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/Pair.java
index 91d38d3..b670368 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/Pair.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/Pair.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.remoting.common;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class Pair<T1, T2> {
private T1 object1;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java
index 68637b9..ec594ec 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java
@@ -30,7 +30,7 @@ import java.nio.channels.SocketChannel;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class RemotingHelper {
public static final String ROCKETMQ_REMOTING = "RocketmqRemoting";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingUtil.java
----------------------------------------------------------------------
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 fdbff02..c26da10 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
@@ -39,7 +39,7 @@ import java.util.Enumeration;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class RemotingUtil {
public static final String OS_NAME = System.getProperty("os.name");
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnce.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnce.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnce.java
index 4db34e3..2f3b8b9 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnce.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnce.java
@@ -21,7 +21,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class SemaphoreReleaseOnlyOnce {
private final AtomicBoolean released = new AtomicBoolean(false);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java
index eda4376..7912609 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java
@@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
/**
* Base class for background thread
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public abstract class ServiceThread implements Runnable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingCommandException.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingCommandException.java b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingCommandException.java
index 705f455..450f660 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingCommandException.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingCommandException.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.remoting.exception;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class RemotingCommandException extends RemotingException {
private static final long serialVersionUID = -6061365915274953096L;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingConnectException.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingConnectException.java b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingConnectException.java
index 51a8585..6f47c22 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingConnectException.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingConnectException.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.remoting.exception;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class RemotingConnectException extends RemotingException {
private static final long serialVersionUID = -5565366231695911316L;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingException.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingException.java b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingException.java
index a3599c9..b1380f9 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingException.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingException.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.remoting.exception;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class RemotingException extends Exception {
private static final long serialVersionUID = -5690687334570505110L;
[19/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/BrokerConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/BrokerConfig.java b/common/src/main/java/com/alibaba/rocketmq/common/BrokerConfig.java
deleted file mode 100644
index ba80a3f..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/BrokerConfig.java
+++ /dev/null
@@ -1,549 +0,0 @@
-/**
- * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.common;
-
-import com.alibaba.rocketmq.common.annotation.ImportantField;
-import com.alibaba.rocketmq.common.constant.PermName;
-import com.alibaba.rocketmq.remoting.common.RemotingUtil;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-
-/**
- * @author shijia.wxr
- */
-public class BrokerConfig {
- private String rocketmqHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV));
- @ImportantField
- private String namesrvAddr = System.getProperty(MixAll.NAMESRV_ADDR_PROPERTY, System.getenv(MixAll.NAMESRV_ADDR_ENV));
- @ImportantField
- private String brokerIP1 = RemotingUtil.getLocalAddress();
- private String brokerIP2 = RemotingUtil.getLocalAddress();
- @ImportantField
- private String brokerName = localHostName();
- @ImportantField
- private String brokerClusterName = "DefaultCluster";
- @ImportantField
- private long brokerId = MixAll.MASTER_ID;
- private int brokerPermission = PermName.PERM_READ | PermName.PERM_WRITE;
- private int defaultTopicQueueNums = 8;
- @ImportantField
- private boolean autoCreateTopicEnable = true;
-
- private boolean clusterTopicEnable = true;
-
- private boolean brokerTopicEnable = true;
- @ImportantField
- private boolean autoCreateSubscriptionGroup = true;
- private String messageStorePlugIn = "";
-
- private int sendMessageThreadPoolNums = 1; //16 + Runtime.getRuntime().availableProcessors() * 4;
- private int pullMessageThreadPoolNums = 16 + Runtime.getRuntime().availableProcessors() * 2;
- private int adminBrokerThreadPoolNums = 16;
- private int clientManageThreadPoolNums = 32;
- private int consumerManageThreadPoolNums = 32;
-
- private int flushConsumerOffsetInterval = 1000 * 5;
-
- private int flushConsumerOffsetHistoryInterval = 1000 * 60;
-
- @ImportantField
- private boolean rejectTransactionMessage = false;
- @ImportantField
- private boolean fetchNamesrvAddrByAddressServer = false;
- private int sendThreadPoolQueueCapacity = 10000;
- private int pullThreadPoolQueueCapacity = 100000;
- private int clientManagerThreadPoolQueueCapacity = 1000000;
- private int consumerManagerThreadPoolQueueCapacity = 1000000;
-
- private int filterServerNums = 0;
-
- private boolean longPollingEnable = true;
-
- private long shortPollingTimeMills = 1000;
-
- private boolean notifyConsumerIdsChangedEnable = true;
-
- private boolean highSpeedMode = false;
-
- private boolean commercialEnable = true;
- private int commercialTimerCount = 1;
- private int commercialTransCount = 1;
- private int commercialBigCount = 1;
- private int commercialBaseCount = 1;
-
- private boolean transferMsgByHeap = true;
- private int maxDelayTime = 40;
-
-
- private String regionId = MixAll.DEFAULT_TRACE_REGION_ID;
- private int registerBrokerTimeoutMills = 6000;
-
- private boolean slaveReadEnable = false;
-
- private boolean disableConsumeIfConsumerReadSlowly = false;
- private long consumerFallbehindThreshold = 1024 * 1024 * 1024 * 16;
-
- private long waitTimeMillsInSendQueue = 200;
-
- private long startAcceptSendRequestTimeStamp = 0L;
-
- private boolean traceOn = true;
-
- public boolean isTraceOn() {
- return traceOn;
- }
-
- public void setTraceOn(final boolean traceOn) {
- this.traceOn = traceOn;
- }
-
- public long getStartAcceptSendRequestTimeStamp() {
- return startAcceptSendRequestTimeStamp;
- }
-
- public void setStartAcceptSendRequestTimeStamp(final long startAcceptSendRequestTimeStamp) {
- this.startAcceptSendRequestTimeStamp = startAcceptSendRequestTimeStamp;
- }
-
- public long getWaitTimeMillsInSendQueue() {
- return waitTimeMillsInSendQueue;
- }
-
- public void setWaitTimeMillsInSendQueue(final long waitTimeMillsInSendQueue) {
- this.waitTimeMillsInSendQueue = waitTimeMillsInSendQueue;
- }
-
- public long getConsumerFallbehindThreshold() {
- return consumerFallbehindThreshold;
- }
-
- public void setConsumerFallbehindThreshold(final long consumerFallbehindThreshold) {
- this.consumerFallbehindThreshold = consumerFallbehindThreshold;
- }
-
- public boolean isDisableConsumeIfConsumerReadSlowly() {
- return disableConsumeIfConsumerReadSlowly;
- }
-
- public void setDisableConsumeIfConsumerReadSlowly(final boolean disableConsumeIfConsumerReadSlowly) {
- this.disableConsumeIfConsumerReadSlowly = disableConsumeIfConsumerReadSlowly;
- }
-
- public boolean isSlaveReadEnable() {
- return slaveReadEnable;
- }
-
- public void setSlaveReadEnable(final boolean slaveReadEnable) {
- this.slaveReadEnable = slaveReadEnable;
- }
-
- public static String localHostName() {
- try {
- return InetAddress.getLocalHost().getHostName();
- } catch (UnknownHostException e) {
- e.printStackTrace();
- }
-
- return "DEFAULT_BROKER";
- }
-
- public int getRegisterBrokerTimeoutMills() {
- return registerBrokerTimeoutMills;
- }
-
- public void setRegisterBrokerTimeoutMills(final int registerBrokerTimeoutMills) {
- this.registerBrokerTimeoutMills = registerBrokerTimeoutMills;
- }
-
- public String getRegionId() {
- return regionId;
- }
-
- public void setRegionId(final String regionId) {
- this.regionId = regionId;
- }
-
- public boolean isTransferMsgByHeap() {
- return transferMsgByHeap;
- }
-
- public void setTransferMsgByHeap(final boolean transferMsgByHeap) {
- this.transferMsgByHeap = transferMsgByHeap;
- }
-
- public String getMessageStorePlugIn() {
- return messageStorePlugIn;
- }
-
- public void setMessageStorePlugIn(String messageStorePlugIn) {
- this.messageStorePlugIn = messageStorePlugIn;
- }
-
- public boolean isHighSpeedMode() {
- return highSpeedMode;
- }
-
-
- public void setHighSpeedMode(final boolean highSpeedMode) {
- this.highSpeedMode = highSpeedMode;
- }
-
-
- public String getRocketmqHome() {
- return rocketmqHome;
- }
-
-
- public void setRocketmqHome(String rocketmqHome) {
- this.rocketmqHome = rocketmqHome;
- }
-
-
- public String getBrokerName() {
- return brokerName;
- }
-
-
- public void setBrokerName(String brokerName) {
- this.brokerName = brokerName;
- }
-
-
- public int getBrokerPermission() {
- return brokerPermission;
- }
-
-
- public void setBrokerPermission(int brokerPermission) {
- this.brokerPermission = brokerPermission;
- }
-
-
- public int getDefaultTopicQueueNums() {
- return defaultTopicQueueNums;
- }
-
-
- public void setDefaultTopicQueueNums(int defaultTopicQueueNums) {
- this.defaultTopicQueueNums = defaultTopicQueueNums;
- }
-
-
- public boolean isAutoCreateTopicEnable() {
- return autoCreateTopicEnable;
- }
-
-
- public void setAutoCreateTopicEnable(boolean autoCreateTopic) {
- this.autoCreateTopicEnable = autoCreateTopic;
- }
-
-
- public String getBrokerClusterName() {
- return brokerClusterName;
- }
-
-
- public void setBrokerClusterName(String brokerClusterName) {
- this.brokerClusterName = brokerClusterName;
- }
-
-
- public String getBrokerIP1() {
- return brokerIP1;
- }
-
-
- public void setBrokerIP1(String brokerIP1) {
- this.brokerIP1 = brokerIP1;
- }
-
-
- public String getBrokerIP2() {
- return brokerIP2;
- }
-
-
- public void setBrokerIP2(String brokerIP2) {
- this.brokerIP2 = brokerIP2;
- }
-
- public int getSendMessageThreadPoolNums() {
- return sendMessageThreadPoolNums;
- }
-
- public void setSendMessageThreadPoolNums(int sendMessageThreadPoolNums) {
- this.sendMessageThreadPoolNums = sendMessageThreadPoolNums;
- }
-
-
- public int getPullMessageThreadPoolNums() {
- return pullMessageThreadPoolNums;
- }
-
-
- public void setPullMessageThreadPoolNums(int pullMessageThreadPoolNums) {
- this.pullMessageThreadPoolNums = pullMessageThreadPoolNums;
- }
-
-
- public int getAdminBrokerThreadPoolNums() {
- return adminBrokerThreadPoolNums;
- }
-
-
- public void setAdminBrokerThreadPoolNums(int adminBrokerThreadPoolNums) {
- this.adminBrokerThreadPoolNums = adminBrokerThreadPoolNums;
- }
-
-
- public int getFlushConsumerOffsetInterval() {
- return flushConsumerOffsetInterval;
- }
-
-
- public void setFlushConsumerOffsetInterval(int flushConsumerOffsetInterval) {
- this.flushConsumerOffsetInterval = flushConsumerOffsetInterval;
- }
-
-
- public int getFlushConsumerOffsetHistoryInterval() {
- return flushConsumerOffsetHistoryInterval;
- }
-
-
- public void setFlushConsumerOffsetHistoryInterval(int flushConsumerOffsetHistoryInterval) {
- this.flushConsumerOffsetHistoryInterval = flushConsumerOffsetHistoryInterval;
- }
-
-
- public boolean isClusterTopicEnable() {
- return clusterTopicEnable;
- }
-
-
- public void setClusterTopicEnable(boolean clusterTopicEnable) {
- this.clusterTopicEnable = clusterTopicEnable;
- }
-
-
- public String getNamesrvAddr() {
- return namesrvAddr;
- }
-
-
- public void setNamesrvAddr(String namesrvAddr) {
- this.namesrvAddr = namesrvAddr;
- }
-
-
- public long getBrokerId() {
- return brokerId;
- }
-
-
- public void setBrokerId(long brokerId) {
- this.brokerId = brokerId;
- }
-
-
- public boolean isAutoCreateSubscriptionGroup() {
- return autoCreateSubscriptionGroup;
- }
-
-
- public void setAutoCreateSubscriptionGroup(boolean autoCreateSubscriptionGroup) {
- this.autoCreateSubscriptionGroup = autoCreateSubscriptionGroup;
- }
-
-
- public boolean isRejectTransactionMessage() {
- return rejectTransactionMessage;
- }
-
-
- public void setRejectTransactionMessage(boolean rejectTransactionMessage) {
- this.rejectTransactionMessage = rejectTransactionMessage;
- }
-
-
- public boolean isFetchNamesrvAddrByAddressServer() {
- return fetchNamesrvAddrByAddressServer;
- }
-
-
- public void setFetchNamesrvAddrByAddressServer(boolean fetchNamesrvAddrByAddressServer) {
- this.fetchNamesrvAddrByAddressServer = fetchNamesrvAddrByAddressServer;
- }
-
-
- public int getSendThreadPoolQueueCapacity() {
- return sendThreadPoolQueueCapacity;
- }
-
-
- public void setSendThreadPoolQueueCapacity(int sendThreadPoolQueueCapacity) {
- this.sendThreadPoolQueueCapacity = sendThreadPoolQueueCapacity;
- }
-
-
- public int getPullThreadPoolQueueCapacity() {
- return pullThreadPoolQueueCapacity;
- }
-
-
- public void setPullThreadPoolQueueCapacity(int pullThreadPoolQueueCapacity) {
- this.pullThreadPoolQueueCapacity = pullThreadPoolQueueCapacity;
- }
-
-
- public boolean isBrokerTopicEnable() {
- return brokerTopicEnable;
- }
-
-
- public void setBrokerTopicEnable(boolean brokerTopicEnable) {
- this.brokerTopicEnable = brokerTopicEnable;
- }
-
-
- public int getFilterServerNums() {
- return filterServerNums;
- }
-
-
- public void setFilterServerNums(int filterServerNums) {
- this.filterServerNums = filterServerNums;
- }
-
-
- public boolean isLongPollingEnable() {
- return longPollingEnable;
- }
-
-
- public void setLongPollingEnable(boolean longPollingEnable) {
- this.longPollingEnable = longPollingEnable;
- }
-
-
- public boolean isNotifyConsumerIdsChangedEnable() {
- return notifyConsumerIdsChangedEnable;
- }
-
-
- public void setNotifyConsumerIdsChangedEnable(boolean notifyConsumerIdsChangedEnable) {
- this.notifyConsumerIdsChangedEnable = notifyConsumerIdsChangedEnable;
- }
-
-
- public long getShortPollingTimeMills() {
- return shortPollingTimeMills;
- }
-
-
- public void setShortPollingTimeMills(long shortPollingTimeMills) {
- this.shortPollingTimeMills = shortPollingTimeMills;
- }
-
-
- public int getClientManageThreadPoolNums() {
- return clientManageThreadPoolNums;
- }
-
-
- public void setClientManageThreadPoolNums(int clientManageThreadPoolNums) {
- this.clientManageThreadPoolNums = clientManageThreadPoolNums;
- }
-
-
- public boolean isCommercialEnable() {
- return commercialEnable;
- }
-
-
- public void setCommercialEnable(final boolean commercialEnable) {
- this.commercialEnable = commercialEnable;
- }
-
- public int getCommercialTimerCount() {
- return commercialTimerCount;
- }
-
- public void setCommercialTimerCount(final int commercialTimerCount) {
- this.commercialTimerCount = commercialTimerCount;
- }
-
- public int getCommercialTransCount() {
- return commercialTransCount;
- }
-
- public void setCommercialTransCount(final int commercialTransCount) {
- this.commercialTransCount = commercialTransCount;
- }
-
- public int getCommercialBigCount() {
- return commercialBigCount;
- }
-
- public void setCommercialBigCount(final int commercialBigCount) {
- this.commercialBigCount = commercialBigCount;
- }
-
- public int getMaxDelayTime() {
- return maxDelayTime;
- }
-
-
- public void setMaxDelayTime(final int maxDelayTime) {
- this.maxDelayTime = maxDelayTime;
- }
-
- public int getClientManagerThreadPoolQueueCapacity() {
- return clientManagerThreadPoolQueueCapacity;
- }
-
- public void setClientManagerThreadPoolQueueCapacity(int clientManagerThreadPoolQueueCapacity) {
- this.clientManagerThreadPoolQueueCapacity = clientManagerThreadPoolQueueCapacity;
- }
-
- public int getConsumerManagerThreadPoolQueueCapacity() {
- return consumerManagerThreadPoolQueueCapacity;
- }
-
- public void setConsumerManagerThreadPoolQueueCapacity(int consumerManagerThreadPoolQueueCapacity) {
- this.consumerManagerThreadPoolQueueCapacity = consumerManagerThreadPoolQueueCapacity;
- }
-
- public int getConsumerManageThreadPoolNums() {
- return consumerManageThreadPoolNums;
- }
-
- public void setConsumerManageThreadPoolNums(int consumerManageThreadPoolNums) {
- this.consumerManageThreadPoolNums = consumerManageThreadPoolNums;
- }
-
- public int getCommercialBaseCount() {
- return commercialBaseCount;
- }
-
- public void setCommercialBaseCount(int commercialBaseCount) {
- this.commercialBaseCount = commercialBaseCount;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/BrokerConfigSingleton.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/BrokerConfigSingleton.java b/common/src/main/java/com/alibaba/rocketmq/common/BrokerConfigSingleton.java
deleted file mode 100644
index f1bc453..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/BrokerConfigSingleton.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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.common;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-
-public class BrokerConfigSingleton {
- private static AtomicBoolean isInit = new AtomicBoolean();
- private static BrokerConfig brokerConfig;
-
- public static BrokerConfig getBrokerConfig() {
- if (brokerConfig == null) {
- throw new IllegalArgumentException("brokerConfig Cannot be null !");
- }
- return brokerConfig;
- }
-
- public static void setBrokerConfig(BrokerConfig brokerConfig) {
- if (!isInit.compareAndSet(false, true)) {
- throw new IllegalArgumentException("broker config have inited !");
- }
- BrokerConfigSingleton.brokerConfig = brokerConfig;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/ConfigManager.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/ConfigManager.java b/common/src/main/java/com/alibaba/rocketmq/common/ConfigManager.java
deleted file mode 100644
index 3191509..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/ConfigManager.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * 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.common;
-
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-
-
-/**
- * @author shijia.wxr
- */
-public abstract class ConfigManager {
- private static final Logger PLOG = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
-
-
- public abstract String encode();
-
- public boolean load() {
- String fileName = null;
- try {
- fileName = this.configFilePath();
- String jsonString = MixAll.file2String(fileName);
-
- if (null == jsonString || jsonString.length() == 0) {
- return this.loadBak();
- } else {
- this.decode(jsonString);
- PLOG.info("load {} OK", fileName);
- return true;
- }
- } catch (Exception e) {
- PLOG.error("load " + fileName + " Failed, and try to load backup file", e);
- return this.loadBak();
- }
- }
-
- public abstract String configFilePath();
-
- private boolean loadBak() {
- String fileName = null;
- try {
- fileName = this.configFilePath();
- String jsonString = MixAll.file2String(fileName + ".bak");
- if (jsonString != null && jsonString.length() > 0) {
- this.decode(jsonString);
- PLOG.info("load " + fileName + " OK");
- return true;
- }
- } catch (Exception e) {
- PLOG.error("load " + fileName + " Failed", e);
- return false;
- }
-
- return true;
- }
-
- public abstract void decode(final String jsonString);
-
- public synchronized void persist() {
- String jsonString = this.encode(true);
- if (jsonString != null) {
- String fileName = this.configFilePath();
- try {
- MixAll.string2File(jsonString, fileName);
- } catch (IOException e) {
- PLOG.error("persist file Exception, " + fileName, e);
- }
- }
- }
-
- public abstract String encode(final boolean prettyFormat);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/Configuration.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/Configuration.java b/common/src/main/java/com/alibaba/rocketmq/common/Configuration.java
deleted file mode 100644
index 8b69c1f..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/Configuration.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/**
- * 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.common;
-
-import org.slf4j.Logger;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-/**
- * @author xigu.lx
- */
-public class Configuration {
-
- private final Logger log;
-
- private List<Object> configObjectList = new ArrayList<Object>(4);
- private String storePath;
- private boolean storePathFromConfig = false;
- private Object storePathObject;
- private Field storePathField;
- private DataVersion dataVersion = new DataVersion();
- private ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
- /**
- * All properties include configs in object and extend properties.
- */
- private Properties allConfigs = new Properties();
-
- public Configuration(Logger log) {
- this.log = log;
- }
-
- public Configuration(Logger log, Object... configObjects) {
- this.log = log;
- if (configObjects == null || configObjects.length == 0) {
- return;
- }
- for (Object configObject : configObjects) {
- registerConfig(configObject);
- }
- }
-
- public Configuration(Logger log, String storePath, Object... configObjects) {
- this(log, configObjects);
- this.storePath = storePath;
- }
-
- /**
- * register config object
- *
- * @param configObject
- * @return the current Configuration object
- */
- public Configuration registerConfig(Object configObject) {
- try {
- readWriteLock.writeLock().lockInterruptibly();
-
- try {
-
- Properties registerProps = MixAll.object2Properties(configObject);
-
- merge(registerProps, this.allConfigs);
-
- configObjectList.add(configObject);
- } finally {
- readWriteLock.writeLock().unlock();
- }
- } catch (InterruptedException e) {
- log.error("registerConfig lock error");
- }
- return this;
- }
-
- /**
- * register config properties
- *
- * @param extProperties
- * @return the current Configuration object
- */
- public Configuration registerConfig(Properties extProperties) {
- if (extProperties == null) {
- return this;
- }
-
- try {
- readWriteLock.writeLock().lockInterruptibly();
-
- try {
- merge(extProperties, this.allConfigs);
- } finally {
- readWriteLock.writeLock().unlock();
- }
- } catch (InterruptedException e) {
- log.error("register lock error. {}" + extProperties);
- }
-
- return this;
- }
-
- /**
- * The store path will be gotten from the field of object.
- *
- * @param object
- * @param fieldName
- *
- * @throws java.lang.RuntimeException if the field of object is not exist.
- */
- public void setStorePathFromConfig(Object object, String fieldName) {
- assert object != null;
-
- try {
- readWriteLock.writeLock().lockInterruptibly();
-
- try {
- this.storePathFromConfig = true;
- this.storePathObject = object;
- // check
- this.storePathField = object.getClass().getDeclaredField(fieldName);
- assert this.storePathField != null
- && !Modifier.isStatic(this.storePathField.getModifiers());
- this.storePathField.setAccessible(true);
- } catch (NoSuchFieldException e) {
- throw new RuntimeException(e);
- } finally {
- readWriteLock.writeLock().unlock();
- }
- } catch (InterruptedException e) {
- log.error("setStorePathFromConfig lock error");
- }
- }
-
- private String getStorePath() {
- String realStorePath = null;
- try {
- readWriteLock.readLock().lockInterruptibly();
-
- try {
- realStorePath = this.storePath;
-
- if (this.storePathFromConfig) {
- try {
- realStorePath = (String) storePathField.get(this.storePathObject);
- } catch (IllegalAccessException e) {
- log.error("getStorePath error, ", e);
- }
- }
- } finally {
- readWriteLock.readLock().unlock();
- }
- } catch (InterruptedException e) {
- log.error("getStorePath lock error");
- }
-
- return realStorePath;
- }
-
- public void update(Properties properties) {
- try {
- readWriteLock.writeLock().lockInterruptibly();
-
- try {
- // the property must be exist when update
- mergeIfExist(properties, this.allConfigs);
-
- for (Object configObject : configObjectList) {
- // not allConfigs to update...
- MixAll.properties2Object(properties, configObject);
- }
-
- this.dataVersion.nextVersion();
-
- } finally {
- readWriteLock.writeLock().unlock();
- }
- } catch (InterruptedException e) {
- log.error("update lock error, {}", properties);
- return;
- }
-
- persist();
- }
-
- public void persist() {
- try {
- readWriteLock.readLock().lockInterruptibly();
-
- try {
- String allConfigs = getAllConfigsInternal();
-
- MixAll.string2File(allConfigs, getStorePath());
- } catch (IOException e) {
- log.error("persist string2File error, ", e);
- } finally {
- readWriteLock.readLock().unlock();
- }
- } catch (InterruptedException e) {
- log.error("persist lock error");
- }
- }
-
- public String getAllConfigsFormatString() {
- try {
- readWriteLock.readLock().lockInterruptibly();
-
- try {
-
- return getAllConfigsInternal();
-
- } finally {
- readWriteLock.readLock().unlock();
- }
- } catch (InterruptedException e) {
- log.error("getAllConfigsFormatString lock error");
- }
-
- return null;
- }
-
- public String getDataVersionJson() {
- return this.dataVersion.toJson();
- }
-
- public Properties getAllConfigs() {
- try {
- readWriteLock.readLock().lockInterruptibly();
-
- try {
-
- return this.allConfigs;
-
- } finally {
- readWriteLock.readLock().unlock();
- }
- } catch (InterruptedException e) {
- log.error("getAllConfigs lock error");
- }
-
- return null;
- }
-
- private String getAllConfigsInternal() {
- StringBuilder stringBuilder = new StringBuilder();
-
- // reload from config object ?
- for (Object configObject : this.configObjectList) {
- Properties properties = MixAll.object2Properties(configObject);
- if (properties != null) {
- merge(properties, this.allConfigs);
- } else {
- log.warn("getAllConfigsInternal object2Properties is null, {}", configObject.getClass());
- }
- }
-
- {
- stringBuilder.append(MixAll.properties2String(this.allConfigs));
- }
-
- return stringBuilder.toString();
- }
-
- public void setStorePath(final String storePath) {
- this.storePath = storePath;
- }
-
- private void merge(Properties from, Properties to) {
- for (Object key : from.keySet()) {
- Object fromObj = from.get(key), toObj = to.get(key);
- if (toObj != null && !toObj.equals(fromObj)) {
- log.info("Replace, key: {}, value: {} -> {}", key, toObj, fromObj);
- }
- to.put(key, fromObj);
- }
- }
-
- private void mergeIfExist(Properties from, Properties to) {
- for (Object key : from.keySet()) {
- if (!to.containsKey(key)) {
- continue;
- }
-
- Object fromObj = from.get(key), toObj = to.get(key);
- if (toObj != null && !toObj.equals(fromObj)) {
- log.info("Replace, key: {}, value: {} -> {}", key, toObj, fromObj);
- }
- to.put(key, fromObj);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/CountDownLatch.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/CountDownLatch.java b/common/src/main/java/com/alibaba/rocketmq/common/CountDownLatch.java
deleted file mode 100644
index a5cc9a1..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/CountDownLatch.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/**
- * 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.common;
-
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.AbstractQueuedSynchronizer;
-
-/**
- * Add reset feature for @see java.util.concurrent.CountDownLatch
- *
- * @author xinyuzhou.zxy
- */
-public class CountDownLatch {
- /**
- * Synchronization control For CountDownLatch.
- * Uses AQS state to represent count.
- */
- private static final class Sync extends AbstractQueuedSynchronizer {
- private static final long serialVersionUID = 4982264981922014374L;
-
- private final int startCount;
-
- Sync(int count) {
- this.startCount = count;
- setState(count);
- }
-
- int getCount() {
- return getState();
- }
-
- protected int tryAcquireShared(int acquires) {
- return (getState() == 0) ? 1 : -1;
- }
-
- protected boolean tryReleaseShared(int releases) {
- // Decrement count; signal when transition to zero
- for (;;) {
- int c = getState();
- if (c == 0)
- return false;
- int nextc = c - 1;
- if (compareAndSetState(c, nextc))
- return nextc == 0;
- }
- }
-
- protected void reset() {
- setState(startCount);
- }
- }
-
- private final Sync sync;
-
- /**
- * Constructs a {@code CountDownLatch} initialized with the given count.
- *
- * @param count
- * the number of times {@link #countDown} must be invoked
- * before threads can pass through {@link #await}
- *
- * @throws IllegalArgumentException
- * if {@code count} is negative
- */
- public CountDownLatch(int count) {
- if (count < 0) throw new IllegalArgumentException("count < 0");
- this.sync = new Sync(count);
- }
-
- /**
- * Causes the current thread to wait until the latch has counted down to
- * zero, unless the thread is {@linkplain Thread#interrupt interrupted}.
- *
- * <p>If the current count is zero then this method returns immediately.
- *
- * <p>If the current count is greater than zero then the current
- * thread becomes disabled for thread scheduling purposes and lies
- * dormant until one of two things happen:
- * <ul>
- * <li>The count reaches zero due to invocations of the
- * {@link #countDown} method; or
- * <li>Some other thread {@linkplain Thread#interrupt interrupts}
- * the current thread.
- * </ul>
- *
- * <p>If the current thread:
- * <ul>
- * <li>has its interrupted status set on entry to this method; or
- * <li>is {@linkplain Thread#interrupt interrupted} while waiting,
- * </ul>
- * then {@link InterruptedException} is thrown and the current thread's
- * interrupted status is cleared.
- *
- * @throws InterruptedException
- * if the current thread is interrupted
- * while waiting
- */
- public void await() throws InterruptedException {
- sync.acquireSharedInterruptibly(1);
- }
-
- /**
- * Causes the current thread to wait until the latch has counted down to
- * zero, unless the thread is {@linkplain Thread#interrupt interrupted},
- * or the specified waiting time elapses.
- *
- * <p>If the current count is zero then this method returns immediately
- * with the value {@code true}.
- *
- * <p>If the current count is greater than zero then the current
- * thread becomes disabled for thread scheduling purposes and lies
- * dormant until one of three things happen:
- * <ul>
- * <li>The count reaches zero due to invocations of the
- * {@link #countDown} method; or
- * <li>Some other thread {@linkplain Thread#interrupt interrupts}
- * the current thread; or
- * <li>The specified waiting time elapses.
- * </ul>
- *
- * <p>If the count reaches zero then the method returns with the
- * value {@code true}.
- *
- * <p>If the current thread:
- * <ul>
- * <li>has its interrupted status set on entry to this method; or
- * <li>is {@linkplain Thread#interrupt interrupted} while waiting,
- * </ul>
- * then {@link InterruptedException} is thrown and the current thread's
- * interrupted status is cleared.
- *
- * <p>If the specified waiting time elapses then the value {@code false}
- * is returned. If the time is less than or equal to zero, the method
- * will not wait at all.
- *
- * @param timeout
- * the maximum time to wait
- * @param unit
- * the time unit of the {@code timeout} argument
- *
- * @return {@code true} if the count reached zero and {@code false}
- * if the waiting time elapsed before the count reached zero
- *
- * @throws InterruptedException
- * if the current thread is interrupted
- * while waiting
- */
- public boolean await(long timeout, TimeUnit unit)
- throws InterruptedException {
- return sync.tryAcquireSharedNanos(1, unit.toNanos(timeout));
- }
-
- /**
- * Decrements the count of the latch, releasing all waiting threads if
- * the count reaches zero.
- *
- * <p>If the current count is greater than zero then it is decremented.
- * If the new count is zero then all waiting threads are re-enabled for
- * thread scheduling purposes.
- *
- * <p>If the current count equals zero then nothing happens.
- */
- public void countDown() {
- sync.releaseShared(1);
- }
-
- /**
- * Returns the current count.
- *
- * <p>This method is typically used for debugging and testing purposes.
- *
- * @return the current count
- */
- public long getCount() {
- return sync.getCount();
- }
-
- public void reset() {
- sync.reset();
- }
-
- /**
- * Returns a string identifying this latch, as well as its state.
- * The state, in brackets, includes the String {@code "Count ="}
- * followed by the current count.
- *
- * @return a string identifying this latch, as well as its state
- */
- public String toString() {
- return super.toString() + "[Count = " + sync.getCount() + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/DataVersion.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/DataVersion.java b/common/src/main/java/com/alibaba/rocketmq/common/DataVersion.java
deleted file mode 100644
index eb78ba1..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/DataVersion.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * 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.common;
-
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.concurrent.atomic.AtomicLong;
-
-
-/**
- * @author shijia.wxr
- */
-public class DataVersion extends RemotingSerializable {
- private long timestatmp = System.currentTimeMillis();
- private AtomicLong counter = new AtomicLong(0);
-
-
- public void assignNewOne(final DataVersion dataVersion) {
- this.timestatmp = dataVersion.timestatmp;
- this.counter.set(dataVersion.counter.get());
- }
-
-
- public void nextVersion() {
- this.timestatmp = System.currentTimeMillis();
- this.counter.incrementAndGet();
- }
-
-
- public long getTimestatmp() {
- return timestatmp;
- }
-
-
- public void setTimestatmp(long timestatmp) {
- this.timestatmp = timestatmp;
- }
-
-
- public AtomicLong getCounter() {
- return counter;
- }
-
-
- public void setCounter(AtomicLong counter) {
- this.counter = counter;
- }
-
-
- @Override
- public boolean equals(final Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- final DataVersion that = (DataVersion) o;
-
- if (timestatmp != that.timestatmp) return false;
- return counter != null ? counter.equals(that.counter) : that.counter == null;
-
- }
-
- @Override
- public int hashCode() {
- int result = (int) (timestatmp ^ (timestatmp >>> 32));
- result = 31 * result + (counter != null ? counter.hashCode() : 0);
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/MQVersion.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/MQVersion.java b/common/src/main/java/com/alibaba/rocketmq/common/MQVersion.java
deleted file mode 100644
index 19afb09..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/MQVersion.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/**
- * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.common;
-
-/**
- * @author shijia.wxr
- */
-public class MQVersion {
-
- public static final int CURRENT_VERSION = Version.V4_0_0_SNAPSHOT.ordinal();
-
-
- public static String getVersionDesc(int value) {
- try {
- Version v = Version.values()[value];
- return v.name();
- } catch (Exception e) {
- }
-
- return "HigherVersion";
- }
-
-
- public static Version value2Version(int value) {
- return Version.values()[value];
- }
-
- public enum Version {
- V3_0_0_SNAPSHOT,
- V3_0_0_ALPHA1,
- V3_0_0_BETA1,
- V3_0_0_BETA2,
- V3_0_0_BETA3,
- V3_0_0_BETA4,
- V3_0_0_BETA5,
- V3_0_0_BETA6_SNAPSHOT,
- V3_0_0_BETA6,
- V3_0_0_BETA7_SNAPSHOT,
- V3_0_0_BETA7,
- V3_0_0_BETA8_SNAPSHOT,
- V3_0_0_BETA8,
- V3_0_0_BETA9_SNAPSHOT,
- V3_0_0_BETA9,
- V3_0_0_FINAL,
- V3_0_1_SNAPSHOT,
- V3_0_1,
- V3_0_2_SNAPSHOT,
- V3_0_2,
- V3_0_3_SNAPSHOT,
- V3_0_3,
- V3_0_4_SNAPSHOT,
- V3_0_4,
- V3_0_5_SNAPSHOT,
- V3_0_5,
- V3_0_6_SNAPSHOT,
- V3_0_6,
- V3_0_7_SNAPSHOT,
- V3_0_7,
- V3_0_8_SNAPSHOT,
- V3_0_8,
- V3_0_9_SNAPSHOT,
- V3_0_9,
-
- V3_0_10_SNAPSHOT,
- V3_0_10,
-
- V3_0_11_SNAPSHOT,
- V3_0_11,
-
- V3_0_12_SNAPSHOT,
- V3_0_12,
-
- V3_0_13_SNAPSHOT,
- V3_0_13,
-
- V3_0_14_SNAPSHOT,
- V3_0_14,
-
- V3_0_15_SNAPSHOT,
- V3_0_15,
-
- V3_1_0_SNAPSHOT,
- V3_1_0,
-
- V3_1_1_SNAPSHOT,
- V3_1_1,
-
- V3_1_2_SNAPSHOT,
- V3_1_2,
-
- V3_1_3_SNAPSHOT,
- V3_1_3,
-
- V3_1_4_SNAPSHOT,
- V3_1_4,
-
- V3_1_5_SNAPSHOT,
- V3_1_5,
-
- V3_1_6_SNAPSHOT,
- V3_1_6,
-
- V3_1_7_SNAPSHOT,
- V3_1_7,
-
- V3_1_8_SNAPSHOT,
- V3_1_8,
-
- V3_1_9_SNAPSHOT,
- V3_1_9,
-
- V3_2_0_SNAPSHOT,
- V3_2_0,
-
- V3_2_1_SNAPSHOT,
- V3_2_1,
-
- V3_2_2_SNAPSHOT,
- V3_2_2,
-
- V3_2_3_SNAPSHOT,
- V3_2_3,
-
- V3_2_4_SNAPSHOT,
- V3_2_4,
-
- V3_2_5_SNAPSHOT,
- V3_2_5,
-
- V3_2_6_SNAPSHOT,
- V3_2_6,
-
- V3_2_7_SNAPSHOT,
- V3_2_7,
-
- V3_2_8_SNAPSHOT,
- V3_2_8,
-
- V3_2_9_SNAPSHOT,
- V3_2_9,
-
- V3_3_1_SNAPSHOT,
- V3_3_1,
-
- V3_3_2_SNAPSHOT,
- V3_3_2,
-
- V3_3_3_SNAPSHOT,
- V3_3_3,
-
- V3_3_4_SNAPSHOT,
- V3_3_4,
-
- V3_3_5_SNAPSHOT,
- V3_3_5,
-
- V3_3_6_SNAPSHOT,
- V3_3_6,
-
- V3_3_7_SNAPSHOT,
- V3_3_7,
-
- V3_3_8_SNAPSHOT,
- V3_3_8,
-
- V3_3_9_SNAPSHOT,
- V3_3_9,
-
- V3_4_1_SNAPSHOT,
- V3_4_1,
-
- V3_4_2_SNAPSHOT,
- V3_4_2,
-
- V3_4_3_SNAPSHOT,
- V3_4_3,
-
- V3_4_4_SNAPSHOT,
- V3_4_4,
-
- V3_4_5_SNAPSHOT,
- V3_4_5,
-
- V3_4_6_SNAPSHOT,
- V3_4_6,
-
- V3_4_7_SNAPSHOT,
- V3_4_7,
-
- V3_4_8_SNAPSHOT,
- V3_4_8,
-
- V3_4_9_SNAPSHOT,
- V3_4_9,
- V3_5_1_SNAPSHOT,
- V3_5_1,
-
- V3_5_2_SNAPSHOT,
- V3_5_2,
-
- V3_5_3_SNAPSHOT,
- V3_5_3,
-
- V3_5_4_SNAPSHOT,
- V3_5_4,
-
- V3_5_5_SNAPSHOT,
- V3_5_5,
-
- V3_5_6_SNAPSHOT,
- V3_5_6,
-
- V3_5_7_SNAPSHOT,
- V3_5_7,
-
- V3_5_8_SNAPSHOT,
- V3_5_8,
-
- V3_5_9_SNAPSHOT,
- V3_5_9,
-
- V3_6_1_SNAPSHOT,
- V3_6_1,
-
- V3_6_2_SNAPSHOT,
- V3_6_2,
-
- V3_6_3_SNAPSHOT,
- V3_6_3,
-
- V3_6_4_SNAPSHOT,
- V3_6_4,
-
- V3_6_5_SNAPSHOT,
- V3_6_5,
-
- V3_6_6_SNAPSHOT,
- V3_6_6,
-
- V3_6_7_SNAPSHOT,
- V3_6_7,
-
- V3_6_8_SNAPSHOT,
- V3_6_8,
-
- V3_6_9_SNAPSHOT,
- V3_6_9,
-
- V3_7_1_SNAPSHOT,
- V3_7_1,
-
- V3_7_2_SNAPSHOT,
- V3_7_2,
-
- V3_7_3_SNAPSHOT,
- V3_7_3,
-
- V3_7_4_SNAPSHOT,
- V3_7_4,
-
- V3_7_5_SNAPSHOT,
- V3_7_5,
-
- V3_7_6_SNAPSHOT,
- V3_7_6,
-
- V3_7_7_SNAPSHOT,
- V3_7_7,
-
- V3_7_8_SNAPSHOT,
- V3_7_8,
-
- V3_7_9_SNAPSHOT,
- V3_7_9,
-
- V3_8_1_SNAPSHOT,
- V3_8_1,
-
- V3_8_2_SNAPSHOT,
- V3_8_2,
-
- V3_8_3_SNAPSHOT,
- V3_8_3,
-
- V3_8_4_SNAPSHOT,
- V3_8_4,
-
- V3_8_5_SNAPSHOT,
- V3_8_5,
-
- V3_8_6_SNAPSHOT,
- V3_8_6,
-
- V3_8_7_SNAPSHOT,
- V3_8_7,
-
- V3_8_8_SNAPSHOT,
- V3_8_8,
-
- V3_8_9_SNAPSHOT,
- V3_8_9,
-
- V3_9_1_SNAPSHOT,
- V3_9_1,
-
- V3_9_2_SNAPSHOT,
- V3_9_2,
-
- V3_9_3_SNAPSHOT,
- V3_9_3,
-
- V3_9_4_SNAPSHOT,
- V3_9_4,
-
- V3_9_5_SNAPSHOT,
- V3_9_5,
-
- V3_9_6_SNAPSHOT,
- V3_9_6,
-
- V3_9_7_SNAPSHOT,
- V3_9_7,
-
- V3_9_8_SNAPSHOT,
- V3_9_8,
-
- V3_9_9_SNAPSHOT,
- V3_9_9,
-
- V4_0_0_SNAPSHOT,
- V4_0_0,
-
- V4_1_0_SNAPSHOT,
- V4_1_0,
-
- V4_2_0_SNAPSHOT,
- V4_2_0,
-
- V4_3_0_SNAPSHOT,
- V4_3_0,
-
- V4_4_0_SNAPSHOT,
- V4_4_0,
-
- V4_5_0_SNAPSHOT,
- V4_5_0,
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/MixAll.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/MixAll.java b/common/src/main/java/com/alibaba/rocketmq/common/MixAll.java
deleted file mode 100644
index 508111c..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/MixAll.java
+++ /dev/null
@@ -1,486 +0,0 @@
-/**
- * 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.common;
-
-import com.alibaba.rocketmq.common.annotation.ImportantField;
-import com.alibaba.rocketmq.common.help.FAQUrl;
-import org.slf4j.Logger;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicLong;
-
-
-/**
- * @author shijia.wxr
- */
-public class MixAll {
- public static final String ROCKETMQ_HOME_ENV = "ROCKETMQ_HOME";
- public static final String ROCKETMQ_HOME_PROPERTY = "rocketmq.home.dir";
- public static final String NAMESRV_ADDR_ENV = "NAMESRV_ADDR";
- public static final String NAMESRV_ADDR_PROPERTY = "rocketmq.namesrv.addr";
- public static final String MESSAGE_COMPRESS_LEVEL = "rocketmq.message.compressLevel";
- public static final String WS_DOMAIN_NAME = System.getProperty("rocketmq.namesrv.domain", "jmenv.tbsite.net");
- public static final String WS_DOMAIN_SUBGROUP = System.getProperty("rocketmq.namesrv.domain.subgroup", "nsaddr");
- // http://jmenv.tbsite.net:8080/rocketmq/nsaddr
- public static final String WS_ADDR = "http://" + WS_DOMAIN_NAME + ":8080/rocketmq/" + WS_DOMAIN_SUBGROUP;
- public static final String DEFAULT_TOPIC = "TBW102";
- public static final String BENCHMARK_TOPIC = "BenchmarkTest";
- public static final String DEFAULT_PRODUCER_GROUP = "DEFAULT_PRODUCER";
- public static final String DEFAULT_CONSUMER_GROUP = "DEFAULT_CONSUMER";
- public static final String TOOLS_CONSUMER_GROUP = "TOOLS_CONSUMER";
- public static final String FILTERSRV_CONSUMER_GROUP = "FILTERSRV_CONSUMER";
- public static final String MONITOR_CONSUMER_GROUP = "__MONITOR_CONSUMER";
- public static final String CLIENT_INNER_PRODUCER_GROUP = "CLIENT_INNER_PRODUCER";
- public static final String SELF_TEST_PRODUCER_GROUP = "SELF_TEST_P_GROUP";
- public static final String SELF_TEST_CONSUMER_GROUP = "SELF_TEST_C_GROUP";
- public static final String SELF_TEST_TOPIC = "SELF_TEST_TOPIC";
- public static final String OFFSET_MOVED_EVENT = "OFFSET_MOVED_EVENT";
- public static final String ONS_HTTP_PROXY_GROUP = "CID_ONS-HTTP-PROXY";
- public static final String CID_ONSAPI_PERMISSION_GROUP = "CID_ONSAPI_PERMISSION";
- public static final String CID_ONSAPI_OWNER_GROUP = "CID_ONSAPI_OWNER";
- public static final String CID_ONSAPI_PULL_GROUP = "CID_ONSAPI_PULL";
- public static final String CID_RMQ_SYS_PREFIX = "CID_RMQ_SYS_";
-
- public static final List<String> LOCAL_INET_ADDRESS = getLocalInetAddress();
- public static final String LOCALHOST = localhost();
- public static final String DEFAULT_CHARSET = "UTF-8";
- public static final long MASTER_ID = 0L;
- public static final long CURRENT_JVM_PID = getPID();
-
- public static final String RETRY_GROUP_TOPIC_PREFIX = "%RETRY%";
-
- public static final String DLQ_GROUP_TOPIC_PREFIX = "%DLQ%";
- public static final String SYSTEM_TOPIC_PREFIX = "rmq_sys_";
- public static final String UNIQUE_MSG_QUERY_FLAG = "_UNIQUE_KEY_QUERY";
- public static final String DEFAULT_TRACE_REGION_ID = "DefaultRegion";
- public static final String CONSUME_CONTEXT_TYPE = "ConsumeContextType";
-
- public static String getRetryTopic(final String consumerGroup) {
- return RETRY_GROUP_TOPIC_PREFIX + consumerGroup;
- }
-
-
- public static boolean isSysConsumerGroup(final String consumerGroup) {
- return consumerGroup.startsWith(CID_RMQ_SYS_PREFIX);
- }
-
- public static boolean isSystemTopic(final String topic) {
- return topic.startsWith(SYSTEM_TOPIC_PREFIX);
- }
-
- public static String getDLQTopic(final String consumerGroup) {
- return DLQ_GROUP_TOPIC_PREFIX + consumerGroup;
- }
-
-
- public static String brokerVIPChannel(final boolean isChange, final String brokerAddr) {
- if (isChange) {
- String[] ipAndPort = brokerAddr.split(":");
- String brokerAddrNew = ipAndPort[0] + ":" + (Integer.parseInt(ipAndPort[1]) - 2);
- return brokerAddrNew;
- } else {
- return brokerAddr;
- }
- }
-
-
- public static long getPID() {
- String processName = java.lang.management.ManagementFactory.getRuntimeMXBean().getName();
- if (processName != null && processName.length() > 0) {
- try {
- return Long.parseLong(processName.split("@")[0]);
- } catch (Exception e) {
- return 0;
- }
- }
-
- return 0;
- }
-
-
- public static long createBrokerId(final String ip, final int port) {
- InetSocketAddress isa = new InetSocketAddress(ip, port);
- byte[] ipArray = isa.getAddress().getAddress();
- ByteBuffer bb = ByteBuffer.allocate(8);
- bb.put(ipArray);
- bb.putInt(port);
- long value = bb.getLong(0);
- return Math.abs(value);
- }
-
- public static final void string2File(final String str, final String fileName) throws IOException {
-
- String tmpFile = fileName + ".tmp";
- string2FileNotSafe(str, tmpFile);
-
-
- String bakFile = fileName + ".bak";
- String prevContent = file2String(fileName);
- if (prevContent != null) {
- string2FileNotSafe(prevContent, bakFile);
- }
-
-
- File file = new File(fileName);
- file.delete();
-
-
- file = new File(tmpFile);
- file.renameTo(new File(fileName));
- }
-
-
- public static final void string2FileNotSafe(final String str, final String fileName) throws IOException {
- File file = new File(fileName);
- File fileParent = file.getParentFile();
- if (fileParent != null) {
- fileParent.mkdirs();
- }
- FileWriter fileWriter = null;
-
- try {
- fileWriter = new FileWriter(file);
- fileWriter.write(str);
- } catch (IOException e) {
- throw e;
- } finally {
- if (fileWriter != null) {
- try {
- fileWriter.close();
- } catch (IOException e) {
- throw e;
- }
- }
- }
- }
-
-
- public static final String file2String(final String fileName) {
- File file = new File(fileName);
- return file2String(file);
- }
-
- public static final String file2String(final File file) {
- if (file.exists()) {
- char[] data = new char[(int) file.length()];
- boolean result = false;
-
- FileReader fileReader = null;
- try {
- fileReader = new FileReader(file);
- int len = fileReader.read(data);
- result = len == data.length;
- } catch (IOException e) {
- // e.printStackTrace();
- } finally {
- if (fileReader != null) {
- try {
- fileReader.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
- if (result) {
- return new String(data);
- }
- }
- return null;
- }
-
- public static final String file2String(final URL url) {
- InputStream in = null;
- try {
- URLConnection urlConnection = url.openConnection();
- urlConnection.setUseCaches(false);
- in = urlConnection.getInputStream();
- int len = in.available();
- byte[] data = new byte[len];
- in.read(data, 0, len);
- return new String(data, "UTF-8");
- } catch (Exception e) {
- } finally {
- if (null != in) {
- try {
- in.close();
- } catch (IOException e) {
- }
- }
- }
-
- return null;
- }
-
- public static String findClassPath(Class<?> c) {
- URL url = c.getProtectionDomain().getCodeSource().getLocation();
- return url.getPath();
- }
-
-
- public static void printObjectProperties(final Logger log, final Object object) {
- printObjectProperties(log, object, false);
- }
-
-
- public static void printObjectProperties(final Logger log, final Object object, final boolean onlyImportantField) {
- Field[] fields = object.getClass().getDeclaredFields();
- for (Field field : fields) {
- if (!Modifier.isStatic(field.getModifiers())) {
- String name = field.getName();
- if (!name.startsWith("this")) {
- Object value = null;
- try {
- field.setAccessible(true);
- value = field.get(object);
- if (null == value) {
- value = "";
- }
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
-
- if (onlyImportantField) {
- Annotation annotation = field.getAnnotation(ImportantField.class);
- if (null == annotation) {
- continue;
- }
- }
-
- if (log != null) {
- log.info(name + "=" + value);
- } else {
- }
- }
- }
- }
- }
-
-
- public static String properties2String(final Properties properties) {
- StringBuilder sb = new StringBuilder();
- for (Map.Entry<Object, Object> entry : properties.entrySet()) {
- if (entry.getValue() != null) {
- sb.append(entry.getKey().toString() + "=" + entry.getValue().toString() + "\n");
- }
- }
- return sb.toString();
- }
-
- public static Properties string2Properties(final String str) {
- Properties properties = new Properties();
- try {
- InputStream in = new ByteArrayInputStream(str.getBytes(DEFAULT_CHARSET));
- properties.load(in);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- return null;
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
-
- return properties;
- }
-
- public static Properties object2Properties(final Object object) {
- Properties properties = new Properties();
-
- Field[] fields = object.getClass().getDeclaredFields();
- for (Field field : fields) {
- if (!Modifier.isStatic(field.getModifiers())) {
- String name = field.getName();
- if (!name.startsWith("this")) {
- Object value = null;
- try {
- field.setAccessible(true);
- value = field.get(object);
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
-
- if (value != null) {
- properties.setProperty(name, value.toString());
- }
- }
- }
- }
-
- return properties;
- }
-
- public static void properties2Object(final Properties p, final Object object) {
- Method[] methods = object.getClass().getMethods();
- for (Method method : methods) {
- String mn = method.getName();
- if (mn.startsWith("set")) {
- try {
- String tmp = mn.substring(4);
- String first = mn.substring(3, 4);
-
- String key = first.toLowerCase() + tmp;
- String property = p.getProperty(key);
- if (property != null) {
- Class<?>[] pt = method.getParameterTypes();
- if (pt != null && pt.length > 0) {
- String cn = pt[0].getSimpleName();
- Object arg = null;
- if (cn.equals("int") || cn.equals("Integer")) {
- arg = Integer.parseInt(property);
- } else if (cn.equals("long") || cn.equals("Long")) {
- arg = Long.parseLong(property);
- } else if (cn.equals("double") || cn.equals("Double")) {
- arg = Double.parseDouble(property);
- } else if (cn.equals("boolean") || cn.equals("Boolean")) {
- arg = Boolean.parseBoolean(property);
- } else if (cn.equals("float") || cn.equals("Float")) {
- arg = Float.parseFloat(property);
- } else if (cn.equals("String")) {
- arg = property;
- } else {
- continue;
- }
- method.invoke(object, new Object[]{arg});
- }
- }
- } catch (Throwable e) {
- }
- }
- }
- }
-
-
- public static boolean isPropertiesEqual(final Properties p1, final Properties p2) {
- return p1.equals(p2);
- }
-
-
- public static List<String> getLocalInetAddress() {
- List<String> inetAddressList = new ArrayList<String>();
- try {
- Enumeration<NetworkInterface> enumeration = NetworkInterface.getNetworkInterfaces();
- while (enumeration.hasMoreElements()) {
- NetworkInterface networkInterface = enumeration.nextElement();
- Enumeration<InetAddress> addrs = networkInterface.getInetAddresses();
- while (addrs.hasMoreElements()) {
- inetAddressList.add(addrs.nextElement().getHostAddress());
- }
- }
- } catch (SocketException e) {
- throw new RuntimeException("get local inet address fail", e);
- }
-
- return inetAddressList;
- }
-
-
- public static boolean isLocalAddr(String address) {
- for (String addr : LOCAL_INET_ADDRESS) {
- if (address.contains(addr))
- return true;
- }
- return false;
- }
-
-
- private static String localhost() {
- try {
- InetAddress addr = InetAddress.getLocalHost();
- return addr.getHostAddress();
- } catch (Throwable e) {
- throw new RuntimeException("InetAddress java.net.InetAddress.getLocalHost() throws UnknownHostException"
- + FAQUrl.suggestTodo(FAQUrl.UNKNOWN_HOST_EXCEPTION),
- e);
- }
- }
-
-
- public static boolean compareAndIncreaseOnly(final AtomicLong target, final long value) {
- long prev = target.get();
- while (value > prev) {
- boolean updated = target.compareAndSet(prev, value);
- if (updated)
- return true;
-
- prev = target.get();
- }
-
- return false;
- }
-
- public static String localhostName() {
- try {
- return InetAddress.getLocalHost().getHostName();
- } catch (Throwable e) {
- throw new RuntimeException("InetAddress java.net.InetAddress.getLocalHost() throws UnknownHostException"
- + FAQUrl.suggestTodo(FAQUrl.UNKNOWN_HOST_EXCEPTION),
- e);
- }
- }
-
- public Set<String> list2Set(List<String> values) {
- Set<String> result = new HashSet<String>();
- for (String v : values) {
- result.add(v);
- }
- return result;
- }
-
- public List<String> set2List(Set<String> values) {
- List<String> result = new ArrayList<String>();
- for (String v : values) {
- result.add(v);
- }
- return result;
- }
-
- public static String humanReadableByteCount(long bytes, boolean si) {
- int unit = si ? 1000 : 1024;
- if (bytes < unit) return bytes + " B";
- int exp = (int) (Math.log(bytes) / Math.log(unit));
- String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i");
- return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/Pair.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/Pair.java b/common/src/main/java/com/alibaba/rocketmq/common/Pair.java
deleted file mode 100644
index ada6144..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/Pair.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * 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.common;
-
-/**
- * @author shijia.wxr
- */
-public class Pair<T1, T2> {
- private T1 object1;
- private T2 object2;
-
-
- public Pair(T1 object1, T2 object2) {
- this.object1 = object1;
- this.object2 = object2;
- }
-
-
- public T1 getObject1() {
- return object1;
- }
-
-
- public void setObject1(T1 object1) {
- this.object1 = object1;
- }
-
-
- public T2 getObject2() {
- return object2;
- }
-
-
- public void setObject2(T2 object2) {
- this.object2 = object2;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/ServiceState.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/ServiceState.java b/common/src/main/java/com/alibaba/rocketmq/common/ServiceState.java
deleted file mode 100644
index a580cf4..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/ServiceState.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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.common;
-
-/**
- * @author shijia.wxr
- */
-public enum ServiceState {
- /**
- * Service just created,not start
- */
- CREATE_JUST,
- /**
- * Service Running
- */
- RUNNING,
- /**
- * Service shutdown
- */
- SHUTDOWN_ALREADY,
- /**
- * Service Start failure
- */
- START_FAILED;
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/ServiceThread.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/ServiceThread.java b/common/src/main/java/com/alibaba/rocketmq/common/ServiceThread.java
deleted file mode 100644
index d6da0e3..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/ServiceThread.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- * 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.common;
-
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * @author shijia.wxr
- * @author xinyuzhou.zxy
- */
-public abstract class ServiceThread implements Runnable {
- private static final Logger STLOG = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
- private static final long JOIN_TIME = 90 * 1000;
-
- protected final Thread thread;
-
- protected volatile AtomicBoolean hasNotified = new AtomicBoolean(false);
-
- protected volatile boolean stopped = false;
-
- protected final CountDownLatch waitPoint = new CountDownLatch(1);
-
-
- public ServiceThread() {
- this.thread = new Thread(this, this.getServiceName());
- }
-
-
- public abstract String getServiceName();
-
-
- public void start() {
- this.thread.start();
- }
-
-
- public void shutdown() {
- this.shutdown(false);
- }
-
- public void shutdown(final boolean interrupt) {
- this.stopped = true;
- STLOG.info("shutdown thread " + this.getServiceName() + " interrupt " + interrupt);
-
- if (hasNotified.compareAndSet(false, true)) {
- waitPoint.countDown(); // notify
- }
-
- try {
- if (interrupt) {
- this.thread.interrupt();
- }
-
- long beginTime = System.currentTimeMillis();
- if (!this.thread.isDaemon()) {
- this.thread.join(this.getJointime());
- }
- long eclipseTime = System.currentTimeMillis() - beginTime;
- STLOG.info("join thread " + this.getServiceName() + " eclipse time(ms) " + eclipseTime + " "
- + this.getJointime());
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- public long getJointime() {
- return JOIN_TIME;
- }
-
- public void stop() {
- this.stop(false);
- }
-
- public void stop(final boolean interrupt) {
- this.stopped = true;
- STLOG.info("stop thread " + this.getServiceName() + " interrupt " + interrupt);
-
- if (hasNotified.compareAndSet(false, true)) {
- waitPoint.countDown(); // notify
- }
-
- if (interrupt) {
- this.thread.interrupt();
- }
- }
-
- public void makeStop() {
- this.stopped = true;
- STLOG.info("makestop thread " + this.getServiceName());
- }
-
- public void wakeup() {
- if (hasNotified.compareAndSet(false, true)) {
- waitPoint.countDown(); // notify
- }
- }
-
- protected void waitForRunning(long interval) {
- if (hasNotified.compareAndSet(true, false)) {
- this.onWaitEnd();
- return;
- }
-
- //entry to wait
- waitPoint.reset();
-
- try {
- waitPoint.await(interval, TimeUnit.MILLISECONDS);
- } catch (InterruptedException e) {
- e.printStackTrace();
- } finally {
- hasNotified.set(false);
- this.onWaitEnd();
- }
- }
-
- protected void onWaitEnd() {
- }
-
- public boolean isStopped() {
- return stopped;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/SystemClock.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/SystemClock.java b/common/src/main/java/com/alibaba/rocketmq/common/SystemClock.java
deleted file mode 100644
index 36c0448..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/SystemClock.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * 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.common;
-
-/**
- * @author vintage.wang
- */
-public class SystemClock {
- public long now() {
- return System.currentTimeMillis();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/ThreadFactoryImpl.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/ThreadFactoryImpl.java b/common/src/main/java/com/alibaba/rocketmq/common/ThreadFactoryImpl.java
deleted file mode 100644
index b4d85cd..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/ThreadFactoryImpl.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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.common;
-
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.atomic.AtomicLong;
-
-
-public class ThreadFactoryImpl implements ThreadFactory {
- private final AtomicLong threadIndex = new AtomicLong(0);
- private final String threadNamePrefix;
-
-
- public ThreadFactoryImpl(final String threadNamePrefix) {
- this.threadNamePrefix = threadNamePrefix;
- }
-
-
- @Override
- public Thread newThread(Runnable r) {
- return new Thread(r, threadNamePrefix + this.threadIndex.incrementAndGet());
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/TopicConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/TopicConfig.java b/common/src/main/java/com/alibaba/rocketmq/common/TopicConfig.java
deleted file mode 100644
index 16019df..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/TopicConfig.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/**
- * 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.common;
-
-import com.alibaba.rocketmq.common.constant.PermName;
-
-
-/**
- * @author shijia.wxr
- */
-public class TopicConfig {
- private static final String SEPARATOR = " ";
- public static int defaultReadQueueNums = 16;
- public static int defaultWriteQueueNums = 16;
- private String topicName;
- private int readQueueNums = defaultReadQueueNums;
- private int writeQueueNums = defaultWriteQueueNums;
- private int perm = PermName.PERM_READ | PermName.PERM_WRITE;
- private TopicFilterType topicFilterType = TopicFilterType.SINGLE_TAG;
- private int topicSysFlag = 0;
- private boolean order = false;
-
-
- public TopicConfig() {
- }
-
-
- public TopicConfig(String topicName) {
- this.topicName = topicName;
- }
-
-
- public TopicConfig(String topicName, int readQueueNums, int writeQueueNums, int perm) {
- this.topicName = topicName;
- this.readQueueNums = readQueueNums;
- this.writeQueueNums = writeQueueNums;
- this.perm = perm;
- }
-
-
- public String encode() {
- StringBuilder sb = new StringBuilder();
-
- // 1
- sb.append(this.topicName);
- sb.append(SEPARATOR);
-
- // 2
- sb.append(this.readQueueNums);
- sb.append(SEPARATOR);
-
- // 3
- sb.append(this.writeQueueNums);
- sb.append(SEPARATOR);
-
- // 4
- sb.append(this.perm);
- sb.append(SEPARATOR);
-
- // 5
- sb.append(this.topicFilterType);
-
- return sb.toString();
- }
-
-
- public boolean decode(final String in) {
- String[] strs = in.split(SEPARATOR);
- if (strs != null && strs.length == 5) {
- this.topicName = strs[0];
-
- this.readQueueNums = Integer.parseInt(strs[1]);
-
- this.writeQueueNums = Integer.parseInt(strs[2]);
-
- this.perm = Integer.parseInt(strs[3]);
-
- this.topicFilterType = TopicFilterType.valueOf(strs[4]);
-
- return true;
- }
-
- return false;
- }
-
-
- public String getTopicName() {
- return topicName;
- }
-
-
- public void setTopicName(String topicName) {
- this.topicName = topicName;
- }
-
-
- public int getReadQueueNums() {
- return readQueueNums;
- }
-
-
- public void setReadQueueNums(int readQueueNums) {
- this.readQueueNums = readQueueNums;
- }
-
-
- public int getWriteQueueNums() {
- return writeQueueNums;
- }
-
-
- public void setWriteQueueNums(int writeQueueNums) {
- this.writeQueueNums = writeQueueNums;
- }
-
-
- public int getPerm() {
- return perm;
- }
-
-
- public void setPerm(int perm) {
- this.perm = perm;
- }
-
-
- public TopicFilterType getTopicFilterType() {
- return topicFilterType;
- }
-
-
- public void setTopicFilterType(TopicFilterType topicFilterType) {
- this.topicFilterType = topicFilterType;
- }
-
-
- public int getTopicSysFlag() {
- return topicSysFlag;
- }
-
-
- public void setTopicSysFlag(int topicSysFlag) {
- this.topicSysFlag = topicSysFlag;
- }
-
-
- public boolean isOrder() {
- return order;
- }
-
-
- public void setOrder(boolean isOrder) {
- this.order = isOrder;
- }
-
- @Override
- public boolean equals(final Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- final TopicConfig that = (TopicConfig) o;
-
- if (readQueueNums != that.readQueueNums) return false;
- if (writeQueueNums != that.writeQueueNums) return false;
- if (perm != that.perm) return false;
- if (topicSysFlag != that.topicSysFlag) return false;
- if (order != that.order) return false;
- if (topicName != null ? !topicName.equals(that.topicName) : that.topicName != null) return false;
- return topicFilterType == that.topicFilterType;
-
- }
-
- @Override
- public int hashCode() {
- int result = topicName != null ? topicName.hashCode() : 0;
- result = 31 * result + readQueueNums;
- result = 31 * result + writeQueueNums;
- result = 31 * result + perm;
- result = 31 * result + (topicFilterType != null ? topicFilterType.hashCode() : 0);
- result = 31 * result + topicSysFlag;
- result = 31 * result + (order ? 1 : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return "TopicConfig [topicName=" + topicName + ", readQueueNums=" + readQueueNums
- + ", writeQueueNums=" + writeQueueNums + ", perm=" + PermName.perm2String(perm)
- + ", topicFilterType=" + topicFilterType + ", topicSysFlag=" + topicSysFlag + ", order="
- + order + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/TopicFilterType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/TopicFilterType.java b/common/src/main/java/com/alibaba/rocketmq/common/TopicFilterType.java
deleted file mode 100644
index 7a20dc9..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/TopicFilterType.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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.common;
-
-/**
- * @author shijia.wxr
- */
-public enum TopicFilterType {
- SINGLE_TAG,
- MULTI_TAG
-}
[75/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java
index c9e534f..4705bed 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java
@@ -6,30 +6,28 @@
* (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
+ * 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.
+ * 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.namesrv.kvconfig;
-import org.apache.rocketmq.common.MixAll;
-import org.apache.rocketmq.common.constant.LoggerName;
-import org.apache.rocketmq.common.protocol.body.KVTable;
-import org.apache.rocketmq.namesrv.NamesrvController;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.protocol.body.KVTable;
+import org.apache.rocketmq.namesrv.NamesrvController;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class KVConfigManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
@@ -38,19 +36,17 @@ public class KVConfigManager {
private final ReadWriteLock lock = new ReentrantReadWriteLock();
private final HashMap<String/* Namespace */, HashMap<String/* Key */, String/* Value */>> configTable =
- new HashMap<String, HashMap<String, String>>();
-
+ new HashMap<String, HashMap<String, String>>();
public KVConfigManager(NamesrvController namesrvController) {
this.namesrvController = namesrvController;
}
-
public void load() {
String content = MixAll.file2String(this.namesrvController.getNamesrvConfig().getKvConfigPath());
if (content != null) {
KVConfigSerializeWrapper kvConfigSerializeWrapper =
- KVConfigSerializeWrapper.fromJson(content, KVConfigSerializeWrapper.class);
+ KVConfigSerializeWrapper.fromJson(content, KVConfigSerializeWrapper.class);
if (null != kvConfigSerializeWrapper) {
this.configTable.putAll(kvConfigSerializeWrapper.getConfigTable());
log.info("load KV config table OK");
@@ -58,7 +54,6 @@ public class KVConfigManager {
}
}
-
public void putKVConfig(final String namespace, final String key, final String value) {
try {
this.lock.writeLock().lockInterruptibly();
@@ -73,10 +68,10 @@ public class KVConfigManager {
final String prev = kvTable.put(key, value);
if (null != prev) {
log.info("putKVConfig update config item, Namespace: {} Key: {} Value: {}", //
- namespace, key, value);
+ namespace, key, value);
} else {
log.info("putKVConfig create new config item, Namespace: {} Key: {} Value: {}", //
- namespace, key, value);
+ namespace, key, value);
}
} finally {
this.lock.writeLock().unlock();
@@ -102,7 +97,7 @@ public class KVConfigManager {
}
} catch (IOException e) {
log.error("persist kvconfig Exception, "
- + this.namesrvController.getNamesrvConfig().getKvConfigPath(), e);
+ + this.namesrvController.getNamesrvConfig().getKvConfigPath(), e);
} finally {
this.lock.readLock().unlock();
}
@@ -120,7 +115,7 @@ public class KVConfigManager {
if (null != kvTable) {
String value = kvTable.remove(key);
log.info("deleteKVConfig delete a config item, Namespace: {} Key: {} Value: {}", //
- namespace, key, value);
+ namespace, key, value);
}
} finally {
this.lock.writeLock().unlock();
@@ -179,14 +174,14 @@ public class KVConfigManager {
{
log.info("configTable SIZE: {}", this.configTable.size());
Iterator<Entry<String, HashMap<String, String>>> it =
- this.configTable.entrySet().iterator();
+ this.configTable.entrySet().iterator();
while (it.hasNext()) {
Entry<String, HashMap<String, String>> next = it.next();
Iterator<Entry<String, String>> itSub = next.getValue().entrySet().iterator();
while (itSub.hasNext()) {
Entry<String, String> nextSub = itSub.next();
log.info("configTable NS: {} Key: {} Value: {}", next.getKey(), nextSub.getKey(),
- nextSub.getValue());
+ nextSub.getValue());
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigSerializeWrapper.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigSerializeWrapper.java
index 6465927..e35a37c 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigSerializeWrapper.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigSerializeWrapper.java
@@ -6,30 +6,26 @@
* (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
+ * 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.
+ * 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.namesrv.kvconfig;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.HashMap;
-
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
public class KVConfigSerializeWrapper extends RemotingSerializable {
private HashMap<String/* Namespace */, HashMap<String/* Key */, String/* Value */>> configTable;
-
public HashMap<String, HashMap<String, String>> getConfigTable() {
return configTable;
}
-
public void setConfigTable(HashMap<String, HashMap<String, String>> configTable) {
this.configTable = configTable;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessor.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessor.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessor.java
index 9ee56a4..95410fa 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessor.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/ClusterTestRequestProcessor.java
@@ -6,16 +6,17 @@
* (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
+ * 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.
+ * 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.namesrv.processor;
+import io.netty.channel.ChannelHandlerContext;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.common.help.FAQUrl;
@@ -27,17 +28,14 @@ import org.apache.rocketmq.namesrv.NamesrvController;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
-import io.netty.channel.ChannelHandlerContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
public class ClusterTestRequestProcessor extends DefaultRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
private final DefaultMQAdminExt adminExt;
private final String productEnvName;
-
public ClusterTestRequestProcessor(NamesrvController namesrvController, String productEnvName) {
super(namesrvController);
this.productEnvName = productEnvName;
@@ -51,18 +49,17 @@ public class ClusterTestRequestProcessor extends DefaultRequestProcessor {
}
}
-
@Override
public RemotingCommand getRouteInfoByTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetRouteInfoRequestHeader requestHeader =
- (GetRouteInfoRequestHeader) request.decodeCommandCustomHeader(GetRouteInfoRequestHeader.class);
+ (GetRouteInfoRequestHeader)request.decodeCommandCustomHeader(GetRouteInfoRequestHeader.class);
TopicRouteData topicRouteData = this.namesrvController.getRouteInfoManager().pickupTopicRouteData(requestHeader.getTopic());
if (topicRouteData != null) {
String orderTopicConf =
- this.namesrvController.getKvConfigManager().getKVConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG,
- requestHeader.getTopic());
+ this.namesrvController.getKvConfigManager().getKVConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG,
+ requestHeader.getTopic());
topicRouteData.setOrderTopicConf(orderTopicConf);
} else {
try {
@@ -82,7 +79,7 @@ public class ClusterTestRequestProcessor extends DefaultRequestProcessor {
response.setCode(ResponseCode.TOPIC_NOT_EXIST);
response.setRemark("No topic route info in name server for the topic: " + requestHeader.getTopic()
- + FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
+ + FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
return response;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java
index e47f300..0135274 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessor.java
@@ -6,16 +6,20 @@
* (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
+ * 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.
+ * 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.namesrv.processor;
+import io.netty.channel.ChannelHandlerContext;
+import java.io.UnsupportedEncodingException;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicLong;
import org.apache.rocketmq.common.MQVersion;
import org.apache.rocketmq.common.MQVersion.Version;
import org.apache.rocketmq.common.MixAll;
@@ -28,40 +32,43 @@ import org.apache.rocketmq.common.protocol.ResponseCode;
import org.apache.rocketmq.common.protocol.body.RegisterBrokerBody;
import org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper;
import org.apache.rocketmq.common.protocol.header.GetTopicsByClusterRequestHeader;
-import org.apache.rocketmq.common.protocol.header.namesrv.*;
+import org.apache.rocketmq.common.protocol.header.namesrv.DeleteKVConfigRequestHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.DeleteTopicInNamesrvRequestHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigRequestHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigResponseHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.GetKVListByNamespaceRequestHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.GetRouteInfoRequestHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.PutKVConfigRequestHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerRequestHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerResponseHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.UnRegisterBrokerRequestHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.WipeWritePermOfBrokerRequestHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.WipeWritePermOfBrokerResponseHeader;
import org.apache.rocketmq.common.protocol.route.TopicRouteData;
import org.apache.rocketmq.namesrv.NamesrvController;
import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-import io.netty.channel.ChannelHandlerContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.UnsupportedEncodingException;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicLong;
-
-
public class DefaultRequestProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
protected final NamesrvController namesrvController;
-
public DefaultRequestProcessor(NamesrvController namesrvController) {
this.namesrvController = namesrvController;
}
-
@Override
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
if (log.isDebugEnabled()) {
log.debug("receive request, {} {} {}",
- request.getCode(),
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
- request);
+ request.getCode(),
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
+ request);
}
switch (request.getCode()) {
@@ -75,8 +82,7 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
Version brokerVersion = MQVersion.value2Version(request.getVersion());
if (brokerVersion.ordinal() >= MQVersion.Version.V3_0_11.ordinal()) {
return this.registerBrokerWithFilterServer(ctx, request);
- }
- else {
+ } else {
return this.registerBroker(ctx, request);
}
case RequestCode.UNREGISTER_BROKER:
@@ -121,12 +127,12 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
public RemotingCommand putKVConfig(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final PutKVConfigRequestHeader requestHeader =
- (PutKVConfigRequestHeader) request.decodeCommandCustomHeader(PutKVConfigRequestHeader.class);
+ (PutKVConfigRequestHeader)request.decodeCommandCustomHeader(PutKVConfigRequestHeader.class);
this.namesrvController.getKvConfigManager().putKVConfig(
- requestHeader.getNamespace(),
- requestHeader.getKey(),
- requestHeader.getValue()
+ requestHeader.getNamespace(),
+ requestHeader.getKey(),
+ requestHeader.getValue()
);
response.setCode(ResponseCode.SUCCESS);
@@ -136,13 +142,13 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
public RemotingCommand getKVConfig(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(GetKVConfigResponseHeader.class);
- final GetKVConfigResponseHeader responseHeader = (GetKVConfigResponseHeader) response.readCustomHeader();
+ final GetKVConfigResponseHeader responseHeader = (GetKVConfigResponseHeader)response.readCustomHeader();
final GetKVConfigRequestHeader requestHeader =
- (GetKVConfigRequestHeader) request.decodeCommandCustomHeader(GetKVConfigRequestHeader.class);
+ (GetKVConfigRequestHeader)request.decodeCommandCustomHeader(GetKVConfigRequestHeader.class);
String value = this.namesrvController.getKvConfigManager().getKVConfig(
- requestHeader.getNamespace(),
- requestHeader.getKey()
+ requestHeader.getNamespace(),
+ requestHeader.getKey()
);
if (value != null) {
@@ -160,11 +166,11 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
public RemotingCommand deleteKVConfig(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final DeleteKVConfigRequestHeader requestHeader =
- (DeleteKVConfigRequestHeader) request.decodeCommandCustomHeader(DeleteKVConfigRequestHeader.class);
+ (DeleteKVConfigRequestHeader)request.decodeCommandCustomHeader(DeleteKVConfigRequestHeader.class);
this.namesrvController.getKvConfigManager().deleteKVConfig(
- requestHeader.getNamespace(),
- requestHeader.getKey()
+ requestHeader.getNamespace(),
+ requestHeader.getKey()
);
response.setCode(ResponseCode.SUCCESS);
@@ -173,11 +179,11 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
}
public RemotingCommand registerBrokerWithFilterServer(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
+ throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterBrokerResponseHeader.class);
- final RegisterBrokerResponseHeader responseHeader = (RegisterBrokerResponseHeader) response.readCustomHeader();
+ final RegisterBrokerResponseHeader responseHeader = (RegisterBrokerResponseHeader)response.readCustomHeader();
final RegisterBrokerRequestHeader requestHeader =
- (RegisterBrokerRequestHeader) request.decodeCommandCustomHeader(RegisterBrokerRequestHeader.class);
+ (RegisterBrokerRequestHeader)request.decodeCommandCustomHeader(RegisterBrokerRequestHeader.class);
RegisterBrokerBody registerBrokerBody = new RegisterBrokerBody();
@@ -189,19 +195,18 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
}
RegisterBrokerResult result = this.namesrvController.getRouteInfoManager().registerBroker(
- requestHeader.getClusterName(),
- requestHeader.getBrokerAddr(),
- requestHeader.getBrokerName(),
- requestHeader.getBrokerId(),
- requestHeader.getHaServerAddr(),
- registerBrokerBody.getTopicConfigSerializeWrapper(),
- registerBrokerBody.getFilterServerList(),
- ctx.channel());
+ requestHeader.getClusterName(),
+ requestHeader.getBrokerAddr(),
+ requestHeader.getBrokerName(),
+ requestHeader.getBrokerId(),
+ requestHeader.getHaServerAddr(),
+ registerBrokerBody.getTopicConfigSerializeWrapper(),
+ registerBrokerBody.getFilterServerList(),
+ ctx.channel());
responseHeader.setHaServerAddr(result.getHaServerAddr());
responseHeader.setMasterAddr(result.getMasterAddr());
-
byte[] jsonValue = this.namesrvController.getKvConfigManager().getKVListByNamespace(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG);
response.setBody(jsonValue);
@@ -212,9 +217,9 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
public RemotingCommand registerBroker(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterBrokerResponseHeader.class);
- final RegisterBrokerResponseHeader responseHeader = (RegisterBrokerResponseHeader) response.readCustomHeader();
+ final RegisterBrokerResponseHeader responseHeader = (RegisterBrokerResponseHeader)response.readCustomHeader();
final RegisterBrokerRequestHeader requestHeader =
- (RegisterBrokerRequestHeader) request.decodeCommandCustomHeader(RegisterBrokerRequestHeader.class);
+ (RegisterBrokerRequestHeader)request.decodeCommandCustomHeader(RegisterBrokerRequestHeader.class);
TopicConfigSerializeWrapper topicConfigWrapper;
if (request.getBody() != null) {
@@ -226,20 +231,19 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
}
RegisterBrokerResult result = this.namesrvController.getRouteInfoManager().registerBroker(
- requestHeader.getClusterName(),
- requestHeader.getBrokerAddr(),
- requestHeader.getBrokerName(),
- requestHeader.getBrokerId(),
- requestHeader.getHaServerAddr(),
- topicConfigWrapper,
- null,
- ctx.channel()
+ requestHeader.getClusterName(),
+ requestHeader.getBrokerAddr(),
+ requestHeader.getBrokerName(),
+ requestHeader.getBrokerId(),
+ requestHeader.getHaServerAddr(),
+ topicConfigWrapper,
+ null,
+ ctx.channel()
);
responseHeader.setHaServerAddr(result.getHaServerAddr());
responseHeader.setMasterAddr(result.getMasterAddr());
-
byte[] jsonValue = this.namesrvController.getKvConfigManager().getKVListByNamespace(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG);
response.setBody(jsonValue);
response.setCode(ResponseCode.SUCCESS);
@@ -250,13 +254,13 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
public RemotingCommand unregisterBroker(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final UnRegisterBrokerRequestHeader requestHeader =
- (UnRegisterBrokerRequestHeader) request.decodeCommandCustomHeader(UnRegisterBrokerRequestHeader.class);
+ (UnRegisterBrokerRequestHeader)request.decodeCommandCustomHeader(UnRegisterBrokerRequestHeader.class);
this.namesrvController.getRouteInfoManager().unregisterBroker(
- requestHeader.getClusterName(),
- requestHeader.getBrokerAddr(),
- requestHeader.getBrokerName(),
- requestHeader.getBrokerId());
+ requestHeader.getClusterName(),
+ requestHeader.getBrokerAddr(),
+ requestHeader.getBrokerName(),
+ requestHeader.getBrokerId());
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
@@ -266,15 +270,15 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
public RemotingCommand getRouteInfoByTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetRouteInfoRequestHeader requestHeader =
- (GetRouteInfoRequestHeader) request.decodeCommandCustomHeader(GetRouteInfoRequestHeader.class);
+ (GetRouteInfoRequestHeader)request.decodeCommandCustomHeader(GetRouteInfoRequestHeader.class);
TopicRouteData topicRouteData = this.namesrvController.getRouteInfoManager().pickupTopicRouteData(requestHeader.getTopic());
if (topicRouteData != null) {
if (this.namesrvController.getNamesrvConfig().isOrderMessageEnable()) {
String orderTopicConf =
- this.namesrvController.getKvConfigManager().getKVConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG,
- requestHeader.getTopic());
+ this.namesrvController.getKvConfigManager().getKVConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG,
+ requestHeader.getTopic());
topicRouteData.setOrderTopicConf(orderTopicConf);
}
@@ -287,7 +291,7 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
response.setCode(ResponseCode.TOPIC_NOT_EXIST);
response.setRemark("No topic route info in name server for the topic: " + requestHeader.getTopic()
- + FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
+ + FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
return response;
}
@@ -304,16 +308,16 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
private RemotingCommand wipeWritePermOfBroker(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(WipeWritePermOfBrokerResponseHeader.class);
- final WipeWritePermOfBrokerResponseHeader responseHeader = (WipeWritePermOfBrokerResponseHeader) response.readCustomHeader();
+ final WipeWritePermOfBrokerResponseHeader responseHeader = (WipeWritePermOfBrokerResponseHeader)response.readCustomHeader();
final WipeWritePermOfBrokerRequestHeader requestHeader =
- (WipeWritePermOfBrokerRequestHeader) request.decodeCommandCustomHeader(WipeWritePermOfBrokerRequestHeader.class);
+ (WipeWritePermOfBrokerRequestHeader)request.decodeCommandCustomHeader(WipeWritePermOfBrokerRequestHeader.class);
int wipeTopicCnt = this.namesrvController.getRouteInfoManager().wipeWritePermOfBrokerByLock(requestHeader.getBrokerName());
log.info("wipe write perm of broker[{}], client: {}, {}",
- requestHeader.getBrokerName(),
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
- wipeTopicCnt);
+ requestHeader.getBrokerName(),
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
+ wipeTopicCnt);
responseHeader.setWipeTopicCount(wipeTopicCnt);
response.setCode(ResponseCode.SUCCESS);
@@ -335,7 +339,7 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
private RemotingCommand deleteTopicInNamesrv(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final DeleteTopicInNamesrvRequestHeader requestHeader =
- (DeleteTopicInNamesrvRequestHeader) request.decodeCommandCustomHeader(DeleteTopicInNamesrvRequestHeader.class);
+ (DeleteTopicInNamesrvRequestHeader)request.decodeCommandCustomHeader(DeleteTopicInNamesrvRequestHeader.class);
this.namesrvController.getRouteInfoManager().deleteTopic(requestHeader.getTopic());
@@ -347,10 +351,10 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
private RemotingCommand getKVListByNamespace(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetKVListByNamespaceRequestHeader requestHeader =
- (GetKVListByNamespaceRequestHeader) request.decodeCommandCustomHeader(GetKVListByNamespaceRequestHeader.class);
+ (GetKVListByNamespaceRequestHeader)request.decodeCommandCustomHeader(GetKVListByNamespaceRequestHeader.class);
byte[] jsonValue = this.namesrvController.getKvConfigManager().getKVListByNamespace(
- requestHeader.getNamespace());
+ requestHeader.getNamespace());
if (null != jsonValue) {
response.setBody(jsonValue);
response.setCode(ResponseCode.SUCCESS);
@@ -366,7 +370,7 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
private RemotingCommand getTopicsByCluster(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetTopicsByClusterRequestHeader requestHeader =
- (GetTopicsByClusterRequestHeader) request.decodeCommandCustomHeader(GetTopicsByClusterRequestHeader.class);
+ (GetTopicsByClusterRequestHeader)request.decodeCommandCustomHeader(GetTopicsByClusterRequestHeader.class);
byte[] body = this.namesrvController.getRouteInfoManager().getTopicsByCluster(requestHeader.getCluster());
@@ -376,7 +380,6 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return response;
}
-
private RemotingCommand getSystemTopicListFromNs(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
@@ -388,7 +391,6 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return response;
}
-
private RemotingCommand getUnitTopicList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
@@ -400,7 +402,6 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return response;
}
-
private RemotingCommand getHasUnitSubTopicList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
@@ -412,9 +413,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
return response;
}
-
private RemotingCommand getHasUnitSubUnUnitTopicList(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
+ throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
byte[] body = this.namesrvController.getRouteInfoManager().getHasUnitSubUnUnitTopicList();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/BrokerHousekeepingService.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/BrokerHousekeepingService.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/BrokerHousekeepingService.java
index 47e1dc9..f4bbf24 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/BrokerHousekeepingService.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/BrokerHousekeepingService.java
@@ -6,51 +6,45 @@
* (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
+ * 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.
+ * 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.namesrv.routeinfo;
+import io.netty.channel.Channel;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.namesrv.NamesrvController;
import org.apache.rocketmq.remoting.ChannelEventListener;
-import io.netty.channel.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
public class BrokerHousekeepingService implements ChannelEventListener {
private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
private final NamesrvController namesrvController;
-
public BrokerHousekeepingService(NamesrvController namesrvController) {
this.namesrvController = namesrvController;
}
-
@Override
public void onChannelConnect(String remoteAddr, Channel channel) {
}
-
@Override
public void onChannelClose(String remoteAddr, Channel channel) {
this.namesrvController.getRouteInfoManager().onChannelDestroy(remoteAddr, channel);
}
-
@Override
public void onChannelException(String remoteAddr, Channel channel) {
this.namesrvController.getRouteInfoManager().onChannelDestroy(remoteAddr, channel);
}
-
@Override
public void onChannelIdle(String remoteAddr, Channel channel) {
this.namesrvController.getRouteInfoManager().onChannelDestroy(remoteAddr, channel);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
index 82b4cbf..e440e61 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
@@ -16,6 +16,18 @@
*/
package org.apache.rocketmq.namesrv.routeinfo;
+import io.netty.channel.Channel;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.rocketmq.common.DataVersion;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.TopicConfig;
@@ -30,17 +42,9 @@ import org.apache.rocketmq.common.protocol.route.QueueData;
import org.apache.rocketmq.common.protocol.route.TopicRouteData;
import org.apache.rocketmq.common.sysflag.TopicSysFlag;
import org.apache.rocketmq.remoting.common.RemotingUtil;
-import io.netty.channel.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-
public class RouteInfoManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
private final static long BROKER_CHANNEL_EXPIRED_TIME = 1000 * 60 * 2;
@@ -51,7 +55,6 @@ public class RouteInfoManager {
private final HashMap<String/* brokerAddr */, BrokerLiveInfo> brokerLiveTable;
private final HashMap<String/* brokerAddr */, List<String>/* Filter Server */> filterServerTable;
-
public RouteInfoManager() {
this.topicQueueTable = new HashMap<String, List<QueueData>>(1024);
this.brokerAddrTable = new HashMap<String, BrokerData>(128);
@@ -97,20 +100,19 @@ public class RouteInfoManager {
}
public RegisterBrokerResult registerBroker(
- final String clusterName,
- final String brokerAddr,
- final String brokerName,
- final long brokerId,
- final String haServerAddr,
- final TopicConfigSerializeWrapper topicConfigWrapper,
- final List<String> filterServerList,
- final Channel channel) {
+ final String clusterName,
+ final String brokerAddr,
+ final String brokerName,
+ final long brokerId,
+ final String haServerAddr,
+ final TopicConfigSerializeWrapper topicConfigWrapper,
+ final List<String> filterServerList,
+ final Channel channel) {
RegisterBrokerResult result = new RegisterBrokerResult();
try {
try {
this.lock.writeLock().lockInterruptibly();
-
Set<String> brokerNames = this.clusterAddrTable.get(clusterName);
if (null == brokerNames) {
brokerNames = new HashSet<String>();
@@ -120,7 +122,6 @@ public class RouteInfoManager {
boolean registerFirst = false;
-
BrokerData brokerData = this.brokerAddrTable.get(brokerName);
if (null == brokerData) {
registerFirst = true;
@@ -134,13 +135,12 @@ public class RouteInfoManager {
String oldAddr = brokerData.getBrokerAddrs().put(brokerId, brokerAddr);
registerFirst = registerFirst || (null == oldAddr);
-
if (null != topicConfigWrapper //
- && MixAll.MASTER_ID == brokerId) {
+ && MixAll.MASTER_ID == brokerId) {
if (this.isBrokerTopicConfigChanged(brokerAddr, topicConfigWrapper.getDataVersion())//
- || registerFirst) {
+ || registerFirst) {
ConcurrentHashMap<String, TopicConfig> tcTable =
- topicConfigWrapper.getTopicConfigTable();
+ topicConfigWrapper.getTopicConfigTable();
if (tcTable != null) {
for (Map.Entry<String, TopicConfig> entry : tcTable.entrySet()) {
this.createAndUpdateQueueData(brokerName, entry.getValue());
@@ -149,18 +149,16 @@ public class RouteInfoManager {
}
}
-
BrokerLiveInfo prevBrokerLiveInfo = this.brokerLiveTable.put(brokerAddr,
- new BrokerLiveInfo(
- System.currentTimeMillis(),
- topicConfigWrapper.getDataVersion(),
- channel,
- haServerAddr));
+ new BrokerLiveInfo(
+ System.currentTimeMillis(),
+ topicConfigWrapper.getDataVersion(),
+ channel,
+ haServerAddr));
if (null == prevBrokerLiveInfo) {
log.info("new broker registerd, {} HAServer: {}", brokerAddr, haServerAddr);
}
-
if (filterServerList != null) {
if (filterServerList.isEmpty()) {
this.filterServerTable.remove(brokerAddr);
@@ -169,7 +167,6 @@ public class RouteInfoManager {
}
}
-
if (MixAll.MASTER_ID != brokerId) {
String masterAddr = brokerData.getBrokerAddrs().get(MixAll.MASTER_ID);
if (masterAddr != null) {
@@ -224,7 +221,7 @@ public class RouteInfoManager {
addNewOne = false;
} else {
log.info("topic changed, {} OLD: {} NEW: {}", topicConfig.getTopicName(), qd,
- queueData);
+ queueData);
it.remove();
}
}
@@ -274,18 +271,18 @@ public class RouteInfoManager {
}
public void unregisterBroker(
- final String clusterName,
- final String brokerAddr,
- final String brokerName,
- final long brokerId) {
+ final String clusterName,
+ final String brokerAddr,
+ final String brokerName,
+ final long brokerId) {
try {
try {
this.lock.writeLock().lockInterruptibly();
BrokerLiveInfo brokerLiveInfo = this.brokerLiveTable.remove(brokerAddr);
if (brokerLiveInfo != null) {
log.info("unregisterBroker, remove from brokerLiveTable {}, {}",
- brokerLiveInfo != null ? "OK" : "Failed",
- brokerAddr
+ brokerLiveInfo != null ? "OK" : "Failed",
+ brokerAddr
);
}
@@ -296,14 +293,14 @@ public class RouteInfoManager {
if (null != brokerData) {
String addr = brokerData.getBrokerAddrs().remove(brokerId);
log.info("unregisterBroker, remove addr from brokerAddrTable {}, {}",
- addr != null ? "OK" : "Failed",
- brokerAddr
+ addr != null ? "OK" : "Failed",
+ brokerAddr
);
if (brokerData.getBrokerAddrs().isEmpty()) {
this.brokerAddrTable.remove(brokerName);
log.info("unregisterBroker, remove name from brokerAddrTable OK, {}",
- brokerName
+ brokerName
);
removeBrokerName = true;
@@ -315,13 +312,13 @@ public class RouteInfoManager {
if (nameSet != null) {
boolean removed = nameSet.remove(brokerName);
log.info("unregisterBroker, remove name from clusterAddrTable {}, {}",
- removed ? "OK" : "Failed",
- brokerName);
+ removed ? "OK" : "Failed",
+ brokerName);
if (nameSet.isEmpty()) {
this.clusterAddrTable.remove(clusterName);
log.info("unregisterBroker, remove cluster from clusterAddrTable {}",
- clusterName
+ clusterName
);
}
}
@@ -377,7 +374,6 @@ public class RouteInfoManager {
topicRouteData.setQueueDatas(queueDataList);
foundQueueData = true;
-
Iterator<QueueData> it = queueDataList.iterator();
while (it.hasNext()) {
QueueData qd = it.next();
@@ -389,8 +385,8 @@ public class RouteInfoManager {
if (null != brokerData) {
BrokerData brokerDataClone = new BrokerData();
brokerDataClone.setBrokerName(brokerData.getBrokerName());
- brokerDataClone.setBrokerAddrs((HashMap<Long, String>) brokerData
- .getBrokerAddrs().clone());
+ brokerDataClone.setBrokerAddrs((HashMap<Long, String>)brokerData
+ .getBrokerAddrs().clone());
brokerDataList.add(brokerDataClone);
foundBrokerData = true;
for (final String brokerAddr : brokerDataClone.getBrokerAddrs().values()) {
@@ -439,7 +435,7 @@ public class RouteInfoManager {
try {
this.lock.readLock().lockInterruptibly();
Iterator<Entry<String, BrokerLiveInfo>> itBrokerLiveTable =
- this.brokerLiveTable.entrySet().iterator();
+ this.brokerLiveTable.entrySet().iterator();
while (itBrokerLiveTable.hasNext()) {
Entry<String, BrokerLiveInfo> entry = itBrokerLiveTable.next();
if (entry.getValue().getChannel() == channel) {
@@ -461,7 +457,6 @@ public class RouteInfoManager {
log.info("the broker's channel destroyed, {}, clean it's data structure at once", brokerAddrFound);
}
-
if (brokerAddrFound != null && brokerAddrFound.length() > 0) {
try {
@@ -472,7 +467,7 @@ public class RouteInfoManager {
String brokerNameFound = null;
boolean removeBrokerName = false;
Iterator<Entry<String, BrokerData>> itBrokerAddrTable =
- this.brokerAddrTable.entrySet().iterator();
+ this.brokerAddrTable.entrySet().iterator();
while (itBrokerAddrTable.hasNext() && (null == brokerNameFound)) {
BrokerData brokerData = itBrokerAddrTable.next().getValue();
@@ -485,7 +480,7 @@ public class RouteInfoManager {
brokerNameFound = brokerData.getBrokerName();
it.remove();
log.info("remove brokerAddr[{}, {}] from brokerAddrTable, because channel destroyed",
- brokerId, brokerAddr);
+ brokerId, brokerAddr);
break;
}
}
@@ -494,7 +489,7 @@ public class RouteInfoManager {
removeBrokerName = true;
itBrokerAddrTable.remove();
log.info("remove brokerName[{}] from brokerAddrTable, because channel destroyed",
- brokerData.getBrokerName());
+ brokerData.getBrokerName());
}
}
@@ -507,12 +502,11 @@ public class RouteInfoManager {
boolean removed = brokerNames.remove(brokerNameFound);
if (removed) {
log.info("remove brokerName[{}], clusterName[{}] from clusterAddrTable, because channel destroyed",
- brokerNameFound, clusterName);
-
+ brokerNameFound, clusterName);
if (brokerNames.isEmpty()) {
log.info("remove the clusterName[{}] from clusterAddrTable, because channel destroyed and no broker in this cluster",
- clusterName);
+ clusterName);
it.remove();
}
@@ -523,7 +517,7 @@ public class RouteInfoManager {
if (removeBrokerName) {
Iterator<Entry<String, List<QueueData>>> itTopicQueueTable =
- this.topicQueueTable.entrySet().iterator();
+ this.topicQueueTable.entrySet().iterator();
while (itTopicQueueTable.hasNext()) {
Entry<String, List<QueueData>> entry = itTopicQueueTable.next();
String topic = entry.getKey();
@@ -535,14 +529,14 @@ public class RouteInfoManager {
if (queueData.getBrokerName().equals(brokerNameFound)) {
itQueueData.remove();
log.info("remove topic[{} {}], from topicQueueTable, because channel destroyed",
- topic, queueData);
+ topic, queueData);
}
}
if (queueDataList.isEmpty()) {
itTopicQueueTable.remove();
log.info("remove topic[{}] all queue, from topicQueueTable, because channel destroyed",
- topic);
+ topic);
}
}
}
@@ -603,7 +597,6 @@ public class RouteInfoManager {
}
}
-
public byte[] getSystemTopicList() {
TopicList topicList = new TopicList();
try {
@@ -644,7 +637,7 @@ public class RouteInfoManager {
Set<String> brokerNameSet = this.clusterAddrTable.get(cluster);
for (String brokerName : brokerNameSet) {
Iterator<Entry<String, List<QueueData>>> topicTableIt =
- this.topicQueueTable.entrySet().iterator();
+ this.topicQueueTable.entrySet().iterator();
while (topicTableIt.hasNext()) {
Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
String topic = topicEntry.getKey();
@@ -673,13 +666,13 @@ public class RouteInfoManager {
try {
this.lock.readLock().lockInterruptibly();
Iterator<Entry<String, List<QueueData>>> topicTableIt =
- this.topicQueueTable.entrySet().iterator();
+ this.topicQueueTable.entrySet().iterator();
while (topicTableIt.hasNext()) {
Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
String topic = topicEntry.getKey();
List<QueueData> queueDatas = topicEntry.getValue();
if (queueDatas != null && queueDatas.size() > 0
- && TopicSysFlag.hasUnitFlag(queueDatas.get(0).getTopicSynFlag())) {
+ && TopicSysFlag.hasUnitFlag(queueDatas.get(0).getTopicSynFlag())) {
topicList.getTopicList().add(topic);
}
}
@@ -699,13 +692,13 @@ public class RouteInfoManager {
try {
this.lock.readLock().lockInterruptibly();
Iterator<Entry<String, List<QueueData>>> topicTableIt =
- this.topicQueueTable.entrySet().iterator();
+ this.topicQueueTable.entrySet().iterator();
while (topicTableIt.hasNext()) {
Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
String topic = topicEntry.getKey();
List<QueueData> queueDatas = topicEntry.getValue();
if (queueDatas != null && queueDatas.size() > 0
- && TopicSysFlag.hasUnitSubFlag(queueDatas.get(0).getTopicSynFlag())) {
+ && TopicSysFlag.hasUnitSubFlag(queueDatas.get(0).getTopicSynFlag())) {
topicList.getTopicList().add(topic);
}
}
@@ -725,14 +718,14 @@ public class RouteInfoManager {
try {
this.lock.readLock().lockInterruptibly();
Iterator<Entry<String, List<QueueData>>> topicTableIt =
- this.topicQueueTable.entrySet().iterator();
+ this.topicQueueTable.entrySet().iterator();
while (topicTableIt.hasNext()) {
Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
String topic = topicEntry.getKey();
List<QueueData> queueDatas = topicEntry.getValue();
if (queueDatas != null && queueDatas.size() > 0
- && !TopicSysFlag.hasUnitFlag(queueDatas.get(0).getTopicSynFlag())
- && TopicSysFlag.hasUnitSubFlag(queueDatas.get(0).getTopicSynFlag())) {
+ && !TopicSysFlag.hasUnitFlag(queueDatas.get(0).getTopicSynFlag())
+ && TopicSysFlag.hasUnitSubFlag(queueDatas.get(0).getTopicSynFlag())) {
topicList.getTopicList().add(topic);
}
}
@@ -747,66 +740,55 @@ public class RouteInfoManager {
}
}
-
class BrokerLiveInfo {
private long lastUpdateTimestamp;
private DataVersion dataVersion;
private Channel channel;
private String haServerAddr;
-
public BrokerLiveInfo(long lastUpdateTimestamp, DataVersion dataVersion, Channel channel,
- String haServerAddr) {
+ String haServerAddr) {
this.lastUpdateTimestamp = lastUpdateTimestamp;
this.dataVersion = dataVersion;
this.channel = channel;
this.haServerAddr = haServerAddr;
}
-
public long getLastUpdateTimestamp() {
return lastUpdateTimestamp;
}
-
public void setLastUpdateTimestamp(long lastUpdateTimestamp) {
this.lastUpdateTimestamp = lastUpdateTimestamp;
}
-
public DataVersion getDataVersion() {
return dataVersion;
}
-
public void setDataVersion(DataVersion dataVersion) {
this.dataVersion = dataVersion;
}
-
public Channel getChannel() {
return channel;
}
-
public void setChannel(Channel channel) {
this.channel = channel;
}
-
public String getHaServerAddr() {
return haServerAddr;
}
-
public void setHaServerAddr(String haServerAddr) {
this.haServerAddr = haServerAddr;
}
-
@Override
public String toString() {
return "BrokerLiveInfo [lastUpdateTimestamp=" + lastUpdateTimestamp + ", dataVersion=" + dataVersion
- + ", channel=" + channel + ", haServerAddr=" + haServerAddr + "]";
+ + ", channel=" + channel + ", haServerAddr=" + haServerAddr + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/pom.xml
----------------------------------------------------------------------
diff --git a/remoting/pom.xml b/remoting/pom.xml
index 6e75c54..15f4443 100644
--- a/remoting/pom.xml
+++ b/remoting/pom.xml
@@ -15,7 +15,7 @@
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.rocketmq</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/ChannelEventListener.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/ChannelEventListener.java b/remoting/src/main/java/org/apache/rocketmq/remoting/ChannelEventListener.java
index ba93f09..98cbb53 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/ChannelEventListener.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/ChannelEventListener.java
@@ -6,31 +6,27 @@
* (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
+ * 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.
+ * 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.remoting;
import io.netty.channel.Channel;
-
/**
*
*/
public interface ChannelEventListener {
void onChannelConnect(final String remoteAddr, final Channel channel);
-
void onChannelClose(final String remoteAddr, final Channel channel);
-
void onChannelException(final String remoteAddr, final Channel channel);
-
void onChannelIdle(final String remoteAddr, final Channel channel);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/CommandCustomHeader.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/CommandCustomHeader.java b/remoting/src/main/java/org/apache/rocketmq/remoting/CommandCustomHeader.java
index de7d3b0..bd1d122 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/CommandCustomHeader.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/CommandCustomHeader.java
@@ -6,19 +6,18 @@
* (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
+ * 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.
+ * 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.remoting;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public interface CommandCustomHeader {
void checkFields() throws RemotingCommandException;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/InvokeCallback.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/InvokeCallback.java b/remoting/src/main/java/org/apache/rocketmq/remoting/InvokeCallback.java
index 3db5f69..c3bcd87 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/InvokeCallback.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/InvokeCallback.java
@@ -6,19 +6,18 @@
* (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
+ * 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.
+ * 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.remoting;
import org.apache.rocketmq.remoting.netty.ResponseFuture;
-
/**
*
*/
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/RPCHook.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/RPCHook.java b/remoting/src/main/java/org/apache/rocketmq/remoting/RPCHook.java
index c489f1d..c118180 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/RPCHook.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/RPCHook.java
@@ -19,11 +19,9 @@ package org.apache.rocketmq.remoting;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-
public interface RPCHook {
void doBeforeRequest(final String remoteAddr, final RemotingCommand request);
-
void doAfterResponse(final String remoteAddr, final RemotingCommand request,
- final RemotingCommand response);
+ final RemotingCommand response);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClient.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClient.java b/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClient.java
index 5f96a34..6c7f7a9 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClient.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClient.java
@@ -6,16 +6,18 @@
* (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
+ * 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.
+ * 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.remoting;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
import org.apache.rocketmq.remoting.exception.RemotingConnectException;
import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
@@ -23,10 +25,6 @@ import org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException;
import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-
-
/**
*
*/
@@ -34,28 +32,22 @@ public interface RemotingClient extends RemotingService {
public void updateNameServerAddressList(final List<String> addrs);
-
public List<String> getNameServerAddressList();
-
public RemotingCommand invokeSync(final String addr, final RemotingCommand request,
- final long timeoutMillis) throws InterruptedException, RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException;
-
+ final long timeoutMillis) throws InterruptedException, RemotingConnectException,
+ RemotingSendRequestException, RemotingTimeoutException;
public void invokeAsync(final String addr, final RemotingCommand request, final long timeoutMillis,
- final InvokeCallback invokeCallback) throws InterruptedException, RemotingConnectException,
- RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException;
-
+ final InvokeCallback invokeCallback) throws InterruptedException, RemotingConnectException,
+ RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException;
public void invokeOneway(final String addr, final RemotingCommand request, final long timeoutMillis)
- throws InterruptedException, RemotingConnectException, RemotingTooMuchRequestException,
- RemotingTimeoutException, RemotingSendRequestException;
-
+ throws InterruptedException, RemotingConnectException, RemotingTooMuchRequestException,
+ RemotingTimeoutException, RemotingSendRequestException;
public void registerProcessor(final int requestCode, final NettyRequestProcessor processor,
- final ExecutorService executor);
-
+ final ExecutorService executor);
public boolean isChannelWriteable(final String addr);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServer.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServer.java b/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServer.java
index 98270ec..d0b13fc 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServer.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServer.java
@@ -16,16 +16,14 @@
*/
package org.apache.rocketmq.remoting;
+import io.netty.channel.Channel;
+import java.util.concurrent.ExecutorService;
import org.apache.rocketmq.remoting.common.Pair;
import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
import org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException;
import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-import io.netty.channel.Channel;
-
-import java.util.concurrent.ExecutorService;
-
/**
*
@@ -33,30 +31,24 @@ import java.util.concurrent.ExecutorService;
public interface RemotingServer extends RemotingService {
void registerProcessor(final int requestCode, final NettyRequestProcessor processor,
- final ExecutorService executor);
-
+ final ExecutorService executor);
void registerDefaultProcessor(final NettyRequestProcessor processor, final ExecutorService executor);
-
int localListenPort();
-
Pair<NettyRequestProcessor, ExecutorService> getProcessorPair(final int requestCode);
-
RemotingCommand invokeSync(final Channel channel, final RemotingCommand request,
- final long timeoutMillis) throws InterruptedException, RemotingSendRequestException,
- RemotingTimeoutException;
-
+ final long timeoutMillis) throws InterruptedException, RemotingSendRequestException,
+ RemotingTimeoutException;
void invokeAsync(final Channel channel, final RemotingCommand request, final long timeoutMillis,
- final InvokeCallback invokeCallback) throws InterruptedException,
- RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException;
-
+ final InvokeCallback invokeCallback) throws InterruptedException,
+ RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException;
void invokeOneway(final Channel channel, final RemotingCommand request, final long timeoutMillis)
- throws InterruptedException, RemotingTooMuchRequestException, RemotingTimeoutException,
- RemotingSendRequestException;
+ throws InterruptedException, RemotingTooMuchRequestException, RemotingTimeoutException,
+ RemotingSendRequestException;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingService.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingService.java b/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingService.java
index 1af2b16..50e89d0 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingService.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingService.java
@@ -20,9 +20,7 @@ package org.apache.rocketmq.remoting;
public interface RemotingService {
void start();
-
void shutdown();
-
void registerRPCHook(RPCHook rpcHook);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNullable.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNullable.java b/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNullable.java
index b552057..fabc06b 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNullable.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNullable.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.remoting.annotation;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/common/Pair.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/Pair.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/Pair.java
index 180348c..2f2fc77 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/Pair.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/Pair.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.remoting.common;
@@ -20,28 +20,23 @@ public class Pair<T1, T2> {
private T1 object1;
private T2 object2;
-
public Pair(T1 object1, T2 object2) {
this.object1 = object1;
this.object2 = object2;
}
-
public T1 getObject1() {
return object1;
}
-
public void setObject1(T1 object1) {
this.object1 = object1;
}
-
public T2 getObject2() {
return object2;
}
-
public void setObject2(T2 object2) {
this.object2 = object2;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java
index 4300537..8d189e7 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java
@@ -6,28 +6,26 @@
* (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
+ * 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.
+ * 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.remoting.common;
-import org.apache.rocketmq.remoting.exception.RemotingConnectException;
-import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
-import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
-import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import io.netty.channel.Channel;
-
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
-
+import org.apache.rocketmq.remoting.exception.RemotingConnectException;
+import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
+import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
public class RemotingHelper {
public static final String ROCKETMQ_REMOTING = "RocketmqRemoting";
@@ -56,8 +54,8 @@ public class RemotingHelper {
}
public static RemotingCommand invokeSync(final String addr, final RemotingCommand request,
- final long timeoutMillis) throws InterruptedException, RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException {
+ final long timeoutMillis) throws InterruptedException, RemotingConnectException,
+ RemotingSendRequestException, RemotingTimeoutException {
long beginTime = System.currentTimeMillis();
SocketAddress socketAddress = RemotingUtil.string2SocketAddress(addr);
SocketChannel socketChannel = RemotingUtil.connect(socketAddress);
@@ -69,8 +67,7 @@ public class RemotingHelper {
socketChannel.configureBlocking(true);
//bugfix http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4614802
- socketChannel.socket().setSoTimeout((int) timeoutMillis);
-
+ socketChannel.socket().setSoTimeout((int)timeoutMillis);
ByteBuffer byteBufferRequest = request.encode();
while (byteBufferRequest.hasRemaining()) {
@@ -86,7 +83,6 @@ public class RemotingHelper {
throw new RemotingSendRequestException(addr);
}
-
Thread.sleep(1);
}
@@ -106,7 +102,6 @@ public class RemotingHelper {
throw new RemotingTimeoutException(addr, timeoutMillis);
}
-
Thread.sleep(1);
}
@@ -125,11 +120,9 @@ public class RemotingHelper {
throw new RemotingTimeoutException(addr, timeoutMillis);
}
-
Thread.sleep(1);
}
-
byteBufferBody.flip();
return RemotingCommand.decode(byteBufferBody);
} catch (IOException e) {
@@ -152,7 +145,6 @@ public class RemotingHelper {
}
}
-
public static String parseChannelRemoteAddr(final Channel channel) {
if (null == channel) {
return "";
@@ -172,19 +164,17 @@ public class RemotingHelper {
return "";
}
-
public static String parseChannelRemoteName(final Channel channel) {
if (null == channel) {
return "";
}
- final InetSocketAddress remote = (InetSocketAddress) channel.remoteAddress();
+ final InetSocketAddress remote = (InetSocketAddress)channel.remoteAddress();
if (remote != null) {
return remote.getAddress().getHostName();
}
return "";
}
-
public static String parseSocketAddressAddr(SocketAddress socketAddress) {
if (socketAddress != null) {
final String addr = socketAddress.toString();
@@ -196,10 +186,9 @@ public class RemotingHelper {
return "";
}
-
public static String parseSocketAddressName(SocketAddress socketAddress) {
- final InetSocketAddress addrs = (InetSocketAddress) socketAddress;
+ final InetSocketAddress addrs = (InetSocketAddress)socketAddress;
if (addrs != null) {
return addrs.getAddress().getHostName();
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingUtil.java
----------------------------------------------------------------------
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 005471e..bcc2232 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
@@ -6,22 +6,19 @@
* (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
+ * 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.
+ * 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.remoting.common;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.Inet6Address;
@@ -36,7 +33,8 @@ import java.nio.channels.SocketChannel;
import java.nio.channels.spi.SelectorProvider;
import java.util.ArrayList;
import java.util.Enumeration;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class RemotingUtil {
public static final String OS_NAME = System.getProperty("os.name");
@@ -69,7 +67,7 @@ public class RemotingUtil {
try {
final Method method = providerClazz.getMethod("provider");
if (method != null) {
- final SelectorProvider selectorProvider = (SelectorProvider) method.invoke(null);
+ final SelectorProvider selectorProvider = (SelectorProvider)method.invoke(null);
if (selectorProvider != null) {
result = selectorProvider.openSelector();
}
@@ -141,7 +139,6 @@ public class RemotingUtil {
return null;
}
-
public static String normalizeHostAddress(final InetAddress localHost) {
if (localHost instanceof Inet6Address) {
return "[" + localHost.getHostAddress() + "]";
@@ -156,22 +153,19 @@ public class RemotingUtil {
return isa;
}
-
public static String socketAddress2String(final SocketAddress addr) {
StringBuilder sb = new StringBuilder();
- InetSocketAddress inetSocketAddress = (InetSocketAddress) addr;
+ InetSocketAddress inetSocketAddress = (InetSocketAddress)addr;
sb.append(inetSocketAddress.getAddress().getHostAddress());
sb.append(":");
sb.append(inetSocketAddress.getPort());
return sb.toString();
}
-
public static SocketChannel connect(SocketAddress remote) {
return connect(remote, 1000 * 5);
}
-
public static SocketChannel connect(SocketAddress remote, final int timeoutMillis) {
SocketChannel sc = null;
try {
@@ -197,14 +191,13 @@ public class RemotingUtil {
return null;
}
-
public static void closeChannel(Channel channel) {
final String addrRemote = RemotingHelper.parseChannelRemoteAddr(channel);
channel.close().addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
log.info("closeChannel: close the connection to remote address[{}] result: {}", addrRemote,
- future.isSuccess());
+ future.isSuccess());
}
});
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnce.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnce.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnce.java
index 7734f86..c8d594e 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnce.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnce.java
@@ -6,30 +6,27 @@
* (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
+ * 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.
+ * 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.remoting.common;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicBoolean;
-
public class SemaphoreReleaseOnlyOnce {
private final AtomicBoolean released = new AtomicBoolean(false);
private final Semaphore semaphore;
-
public SemaphoreReleaseOnlyOnce(Semaphore semaphore) {
this.semaphore = semaphore;
}
-
public void release() {
if (this.semaphore != null) {
if (this.released.compareAndSet(false, true)) {
@@ -38,7 +35,6 @@ public class SemaphoreReleaseOnlyOnce {
}
}
-
public Semaphore getSemaphore() {
return semaphore;
}
[04/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/transaction/TransactionCheckListenerImpl.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/transaction/TransactionCheckListenerImpl.java b/example/src/main/java/com/alibaba/rocketmq/example/transaction/TransactionCheckListenerImpl.java
deleted file mode 100644
index 2e91e34..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/transaction/TransactionCheckListenerImpl.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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.example.transaction;
-
-import com.alibaba.rocketmq.client.producer.LocalTransactionState;
-import com.alibaba.rocketmq.client.producer.TransactionCheckListener;
-import com.alibaba.rocketmq.common.message.MessageExt;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-
-public class TransactionCheckListenerImpl implements TransactionCheckListener {
- private AtomicInteger transactionIndex = new AtomicInteger(0);
-
-
- @Override
- public LocalTransactionState checkLocalTransactionState(MessageExt msg) {
- System.out.printf("server checking TrMsg " + msg.toString() + "%n");
-
- int value = transactionIndex.getAndIncrement();
- if ((value % 6) == 0) {
- throw new RuntimeException("Could not find db");
- } else if ((value % 5) == 0) {
- return LocalTransactionState.ROLLBACK_MESSAGE;
- } else if ((value % 4) == 0) {
- return LocalTransactionState.COMMIT_MESSAGE;
- }
-
- return LocalTransactionState.UNKNOW;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/transaction/TransactionExecuterImpl.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/transaction/TransactionExecuterImpl.java b/example/src/main/java/com/alibaba/rocketmq/example/transaction/TransactionExecuterImpl.java
deleted file mode 100644
index cda523a..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/transaction/TransactionExecuterImpl.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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.example.transaction;
-
-import com.alibaba.rocketmq.client.producer.LocalTransactionExecuter;
-import com.alibaba.rocketmq.client.producer.LocalTransactionState;
-import com.alibaba.rocketmq.common.message.Message;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class TransactionExecuterImpl implements LocalTransactionExecuter {
- private AtomicInteger transactionIndex = new AtomicInteger(1);
-
-
- @Override
- public LocalTransactionState executeLocalTransactionBranch(final Message msg, final Object arg) {
- int value = transactionIndex.getAndIncrement();
-
- if (value == 0) {
- throw new RuntimeException("Could not find db");
- } else if ((value % 5) == 0) {
- return LocalTransactionState.ROLLBACK_MESSAGE;
- } else if ((value % 4) == 0) {
- return LocalTransactionState.COMMIT_MESSAGE;
- }
-
- return LocalTransactionState.UNKNOW;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/com/alibaba/rocketmq/example/transaction/TransactionProducer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/com/alibaba/rocketmq/example/transaction/TransactionProducer.java b/example/src/main/java/com/alibaba/rocketmq/example/transaction/TransactionProducer.java
deleted file mode 100644
index 2c4745f..0000000
--- a/example/src/main/java/com/alibaba/rocketmq/example/transaction/TransactionProducer.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * 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.example.transaction;
-
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.producer.SendResult;
-import com.alibaba.rocketmq.client.producer.TransactionCheckListener;
-import com.alibaba.rocketmq.client.producer.TransactionMQProducer;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-
-import java.io.UnsupportedEncodingException;
-
-public class TransactionProducer {
- public static void main(String[] args) throws MQClientException, InterruptedException {
- TransactionCheckListener transactionCheckListener = new TransactionCheckListenerImpl();
- TransactionMQProducer producer = new TransactionMQProducer("please_rename_unique_group_name");
- producer.setCheckThreadPoolMinSize(2);
- producer.setCheckThreadPoolMaxSize(2);
- producer.setCheckRequestHoldMax(2000);
- producer.setTransactionCheckListener(transactionCheckListener);
- producer.start();
-
- String[] tags = new String[]{"TagA", "TagB", "TagC", "TagD", "TagE"};
- TransactionExecuterImpl tranExecuter = new TransactionExecuterImpl();
- for (int i = 0; i < 100; i++) {
- try {
- Message msg =
- new Message("TopicTest", tags[i % tags.length], "KEY" + i,
- ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET));
- SendResult sendResult = producer.sendMessageInTransaction(msg, tranExecuter, null);
- System.out.printf("%s%n", sendResult);
-
- Thread.sleep(10);
- } catch (MQClientException e) {
- e.printStackTrace();
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
-
- for (int i = 0; i < 100000; i++) {
- Thread.sleep(1000);
- }
- producer.shutdown();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/benchmark/Consumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/benchmark/Consumer.java b/example/src/main/java/org/apache/rocketmq/example/benchmark/Consumer.java
new file mode 100644
index 0000000..1fbb8a4
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/benchmark/Consumer.java
@@ -0,0 +1,214 @@
+/**
+ * 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.example.benchmark;
+
+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.common.message.MessageExt;
+import org.apache.rocketmq.srvutil.ServerUtil;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.PosixParser;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class Consumer {
+
+ public static void main(String[] args) throws MQClientException {
+ Options options = ServerUtil.buildCommandlineOptions(new Options());
+ CommandLine commandLine = ServerUtil.parseCmdLine("benchmarkConsumer", args, buildCommandlineOptions(options), new PosixParser());
+ if (null == commandLine) {
+ System.exit(-1);
+ }
+
+ final String topic = commandLine.hasOption('t') ? commandLine.getOptionValue('t').trim() : "BenchmarkTest";
+ final String groupPrefix = commandLine.hasOption('g') ? commandLine.getOptionValue('g').trim() : "benchmark_consumer";
+ final String isPrefixEnable = commandLine.hasOption('p') ? commandLine.getOptionValue('p').trim() : "true";
+ String group = groupPrefix;
+ if (Boolean.parseBoolean(isPrefixEnable)) {
+ group = groupPrefix + "_" + Long.toString(System.currentTimeMillis() % 100);
+ }
+
+ System.out.printf("topic %s group %s prefix %s%n", topic, group, isPrefixEnable);
+
+ final StatsBenchmarkConsumer statsBenchmarkConsumer = new StatsBenchmarkConsumer();
+
+ final Timer timer = new Timer("BenchmarkTimerThread", true);
+
+ final LinkedList<Long[]> snapshotList = new LinkedList<Long[]>();
+
+ timer.scheduleAtFixedRate(new TimerTask() {
+ @Override
+ public void run() {
+ snapshotList.addLast(statsBenchmarkConsumer.createSnapshot());
+ if (snapshotList.size() > 10) {
+ snapshotList.removeFirst();
+ }
+ }
+ }, 1000, 1000);
+
+ timer.scheduleAtFixedRate(new TimerTask() {
+ private void printStats() {
+ if (snapshotList.size() >= 10) {
+ Long[] begin = snapshotList.getFirst();
+ Long[] end = snapshotList.getLast();
+
+ final long consumeTps =
+ (long) (((end[1] - begin[1]) / (double) (end[0] - begin[0])) * 1000L);
+ final double averageB2CRT = (end[2] - begin[2]) / (double) (end[1] - begin[1]);
+ final double averageS2CRT = (end[3] - begin[3]) / (double) (end[1] - begin[1]);
+
+ System.out.printf("Consume TPS: %d Average(B2C) RT: %7.3f Average(S2C) RT: %7.3f MAX(B2C) RT: %d MAX(S2C) RT: %d%n",
+ consumeTps, averageB2CRT, averageS2CRT, end[4], end[5]
+ );
+ }
+ }
+
+
+ @Override
+ public void run() {
+ try {
+ this.printStats();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }, 10000, 10000);
+
+ DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(group);
+ consumer.setInstanceName(Long.toString(System.currentTimeMillis()));
+
+ consumer.subscribe(topic, "*");
+
+ consumer.registerMessageListener(new MessageListenerConcurrently() {
+ @Override
+ public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
+ ConsumeConcurrentlyContext context) {
+ MessageExt msg = msgs.get(0);
+ long now = System.currentTimeMillis();
+
+ statsBenchmarkConsumer.getReceiveMessageTotalCount().incrementAndGet();
+
+ long born2ConsumerRT = now - msg.getBornTimestamp();
+ statsBenchmarkConsumer.getBorn2ConsumerTotalRT().addAndGet(born2ConsumerRT);
+
+ long store2ConsumerRT = now - msg.getStoreTimestamp();
+ statsBenchmarkConsumer.getStore2ConsumerTotalRT().addAndGet(store2ConsumerRT);
+
+ compareAndSetMax(statsBenchmarkConsumer.getBorn2ConsumerMaxRT(), born2ConsumerRT);
+
+ compareAndSetMax(statsBenchmarkConsumer.getStore2ConsumerMaxRT(), store2ConsumerRT);
+
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }
+ });
+
+ consumer.start();
+
+ System.out.printf("Consumer Started.%n");
+ }
+
+ public static Options buildCommandlineOptions(final Options options) {
+ Option opt = new Option("t", "topic", true, "Topic name, Default: BenchmarkTest");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+ opt = new Option("g", "group", true, "Consumer group name, Default: benchmark_consumer");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+
+ opt = new Option("p", "group prefix enable", true, "Consumer group name, Default: false");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+ return options;
+ }
+
+
+ public static void compareAndSetMax(final AtomicLong target, final long value) {
+ long prev = target.get();
+ while (value > prev) {
+ boolean updated = target.compareAndSet(prev, value);
+ if (updated)
+ break;
+
+ prev = target.get();
+ }
+ }
+}
+
+
+class StatsBenchmarkConsumer {
+ private final AtomicLong receiveMessageTotalCount = new AtomicLong(0L);
+
+ private final AtomicLong born2ConsumerTotalRT = new AtomicLong(0L);
+
+ private final AtomicLong store2ConsumerTotalRT = new AtomicLong(0L);
+
+ private final AtomicLong born2ConsumerMaxRT = new AtomicLong(0L);
+
+ private final AtomicLong store2ConsumerMaxRT = new AtomicLong(0L);
+
+
+ public Long[] createSnapshot() {
+ Long[] snap = new Long[]{
+ System.currentTimeMillis(),
+ this.receiveMessageTotalCount.get(),
+ this.born2ConsumerTotalRT.get(),
+ this.store2ConsumerTotalRT.get(),
+ this.born2ConsumerMaxRT.get(),
+ this.store2ConsumerMaxRT.get(),
+ };
+
+ return snap;
+ }
+
+
+ public AtomicLong getReceiveMessageTotalCount() {
+ return receiveMessageTotalCount;
+ }
+
+
+ public AtomicLong getBorn2ConsumerTotalRT() {
+ return born2ConsumerTotalRT;
+ }
+
+
+ public AtomicLong getStore2ConsumerTotalRT() {
+ return store2ConsumerTotalRT;
+ }
+
+
+ public AtomicLong getBorn2ConsumerMaxRT() {
+ return born2ConsumerMaxRT;
+ }
+
+
+ public AtomicLong getStore2ConsumerMaxRT() {
+ return store2ConsumerMaxRT;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java b/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java
new file mode 100644
index 0000000..3b13f94
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java
@@ -0,0 +1,262 @@
+/**
+ * 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.example.benchmark;
+
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.client.producer.DefaultMQProducer;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+import org.apache.rocketmq.srvutil.ServerUtil;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.PosixParser;
+import org.slf4j.Logger;
+
+import java.io.UnsupportedEncodingException;
+import java.util.LinkedList;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class Producer {
+ public static void main(String[] args) throws MQClientException, UnsupportedEncodingException {
+
+ Options options = ServerUtil.buildCommandlineOptions(new Options());
+ CommandLine commandLine = ServerUtil.parseCmdLine("benchmarkProducer", args, buildCommandlineOptions(options), new PosixParser());
+ if (null == commandLine) {
+ System.exit(-1);
+ }
+
+ final String topic = commandLine.hasOption('t') ? commandLine.getOptionValue('t').trim() : "BenchmarkTest";
+ final int threadCount = commandLine.hasOption('w') ? Integer.parseInt(commandLine.getOptionValue('w')) : 64;
+ final int messageSize = commandLine.hasOption('s') ? Integer.parseInt(commandLine.getOptionValue('s')) : 128;
+ final boolean keyEnable = commandLine.hasOption('k') ? Boolean.parseBoolean(commandLine.getOptionValue('k')) : false;
+
+ System.out.printf("topic %s threadCount %d messageSize %d keyEnable %s%n", topic, threadCount, messageSize, keyEnable);
+
+ final Logger log = ClientLogger.getLog();
+
+ final Message msg = buildMessage(messageSize, topic);
+
+ final ExecutorService sendThreadPool = Executors.newFixedThreadPool(threadCount);
+
+ final StatsBenchmarkProducer statsBenchmark = new StatsBenchmarkProducer();
+
+ final Timer timer = new Timer("BenchmarkTimerThread", true);
+
+ final LinkedList<Long[]> snapshotList = new LinkedList<Long[]>();
+
+ timer.scheduleAtFixedRate(new TimerTask() {
+ @Override
+ public void run() {
+ snapshotList.addLast(statsBenchmark.createSnapshot());
+ if (snapshotList.size() > 10) {
+ snapshotList.removeFirst();
+ }
+ }
+ }, 1000, 1000);
+
+ timer.scheduleAtFixedRate(new TimerTask() {
+ private void printStats() {
+ if (snapshotList.size() >= 10) {
+ Long[] begin = snapshotList.getFirst();
+ Long[] end = snapshotList.getLast();
+
+ final long sendTps = (long) (((end[3] - begin[3]) / (double) (end[0] - begin[0])) * 1000L);
+ final double averageRT = (end[5] - begin[5]) / (double) (end[3] - begin[3]);
+
+ System.out.printf("Send TPS: %d Max RT: %d Average RT: %7.3f Send Failed: %d Response Failed: %d%n",
+ sendTps, statsBenchmark.getSendMessageMaxRT().get(), averageRT, end[2], end[4]);
+ }
+ }
+
+
+ @Override
+ public void run() {
+ try {
+ this.printStats();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }, 10000, 10000);
+
+ final DefaultMQProducer producer = new DefaultMQProducer("benchmark_producer");
+ producer.setInstanceName(Long.toString(System.currentTimeMillis()));
+
+ if (commandLine.hasOption('n')) {
+ String ns = commandLine.getOptionValue('n');
+ producer.setNamesrvAddr(ns);
+ }
+
+ producer.setCompressMsgBodyOverHowmuch(Integer.MAX_VALUE);
+
+ producer.start();
+
+ for (int i = 0; i < threadCount; i++) {
+ sendThreadPool.execute(new Runnable() {
+ @Override
+ public void run() {
+ while (true) {
+ try {
+ final long beginTimestamp = System.currentTimeMillis();
+ if (keyEnable) {
+ msg.setKeys(String.valueOf(beginTimestamp / 1000));
+ }
+ producer.send(msg);
+ statsBenchmark.getSendRequestSuccessCount().incrementAndGet();
+ statsBenchmark.getReceiveResponseSuccessCount().incrementAndGet();
+ final long currentRT = System.currentTimeMillis() - beginTimestamp;
+ statsBenchmark.getSendMessageSuccessTimeTotal().addAndGet(currentRT);
+ long prevMaxRT = statsBenchmark.getSendMessageMaxRT().get();
+ while (currentRT > prevMaxRT) {
+ boolean updated = statsBenchmark.getSendMessageMaxRT().compareAndSet(prevMaxRT, currentRT);
+ if (updated)
+ break;
+
+ prevMaxRT = statsBenchmark.getSendMessageMaxRT().get();
+ }
+ } catch (RemotingException e) {
+ statsBenchmark.getSendRequestFailedCount().incrementAndGet();
+ log.error("[BENCHMARK_PRODUCER] Send Exception", e);
+
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e1) {
+ }
+ } catch (InterruptedException e) {
+ statsBenchmark.getSendRequestFailedCount().incrementAndGet();
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e1) {
+ }
+ } catch (MQClientException e) {
+ statsBenchmark.getSendRequestFailedCount().incrementAndGet();
+ log.error("[BENCHMARK_PRODUCER] Send Exception", e);
+ } catch (MQBrokerException e) {
+ statsBenchmark.getReceiveResponseFailedCount().incrementAndGet();
+ log.error("[BENCHMARK_PRODUCER] Send Exception", e);
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e1) {
+ }
+ }
+ }
+ }
+ });
+ }
+ }
+
+ public static Options buildCommandlineOptions(final Options options) {
+ Option opt = new Option("w", "threadCount", true, "Thread count, Default: 64");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+ opt = new Option("s", "messageSize", true, "Message Size, Default: 128");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+ opt = new Option("k", "keyEnable", true, "Message Key Enable, Default: false");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+ opt = new Option("t", "topic", true, "Topic name, Default: BenchmarkTest");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+ return options;
+ }
+
+ private static Message buildMessage(final int messageSize, final String topic) throws UnsupportedEncodingException {
+ Message msg = new Message();
+ msg.setTopic(topic);
+
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < messageSize; i += 10) {
+ sb.append("hello baby");
+ }
+
+ msg.setBody(sb.toString().getBytes(RemotingHelper.DEFAULT_CHARSET));
+
+ return msg;
+ }
+}
+
+
+class StatsBenchmarkProducer {
+ private final AtomicLong sendRequestSuccessCount = new AtomicLong(0L);
+
+ private final AtomicLong sendRequestFailedCount = new AtomicLong(0L);
+
+ private final AtomicLong receiveResponseSuccessCount = new AtomicLong(0L);
+
+ private final AtomicLong receiveResponseFailedCount = new AtomicLong(0L);
+
+ private final AtomicLong sendMessageSuccessTimeTotal = new AtomicLong(0L);
+
+ private final AtomicLong sendMessageMaxRT = new AtomicLong(0L);
+
+
+ public Long[] createSnapshot() {
+ Long[] snap = new Long[]{
+ System.currentTimeMillis(),
+ this.sendRequestSuccessCount.get(),
+ this.sendRequestFailedCount.get(),
+ this.receiveResponseSuccessCount.get(),
+ this.receiveResponseFailedCount.get(),
+ this.sendMessageSuccessTimeTotal.get(),
+ };
+
+ return snap;
+ }
+
+
+ public AtomicLong getSendRequestSuccessCount() {
+ return sendRequestSuccessCount;
+ }
+
+
+ public AtomicLong getSendRequestFailedCount() {
+ return sendRequestFailedCount;
+ }
+
+
+ public AtomicLong getReceiveResponseSuccessCount() {
+ return receiveResponseSuccessCount;
+ }
+
+
+ public AtomicLong getReceiveResponseFailedCount() {
+ return receiveResponseFailedCount;
+ }
+
+
+ public AtomicLong getSendMessageSuccessTimeTotal() {
+ return sendMessageSuccessTimeTotal;
+ }
+
+
+ public AtomicLong getSendMessageMaxRT() {
+ return sendMessageMaxRT;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/benchmark/TransactionProducer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/benchmark/TransactionProducer.java b/example/src/main/java/org/apache/rocketmq/example/benchmark/TransactionProducer.java
new file mode 100644
index 0000000..43f159b
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/benchmark/TransactionProducer.java
@@ -0,0 +1,265 @@
+/**
+ * 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.example.benchmark;
+
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.client.producer.*;
+
+import java.io.UnsupportedEncodingException;
+import java.util.LinkedList;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class TransactionProducer {
+ private static int threadCount;
+ private static int messageSize;
+ private static boolean ischeck;
+ private static boolean ischeckffalse;
+
+
+ public static void main(String[] args) throws MQClientException, UnsupportedEncodingException {
+ threadCount = args.length >= 1 ? Integer.parseInt(args[0]) : 32;
+ messageSize = args.length >= 2 ? Integer.parseInt(args[1]) : 1024 * 2;
+ ischeck = args.length >= 3 ? Boolean.parseBoolean(args[2]) : false;
+ ischeckffalse = args.length >= 4 ? Boolean.parseBoolean(args[3]) : false;
+
+ final Message msg = buildMessage(messageSize);
+
+ final ExecutorService sendThreadPool = Executors.newFixedThreadPool(threadCount);
+
+ final StatsBenchmarkTProducer statsBenchmark = new StatsBenchmarkTProducer();
+
+ final Timer timer = new Timer("BenchmarkTimerThread", true);
+
+ final LinkedList<Long[]> snapshotList = new LinkedList<Long[]>();
+
+ timer.scheduleAtFixedRate(new TimerTask() {
+ @Override
+ public void run() {
+ snapshotList.addLast(statsBenchmark.createSnapshot());
+ while (snapshotList.size() > 10) {
+ snapshotList.removeFirst();
+ }
+ }
+ }, 1000, 1000);
+
+ timer.scheduleAtFixedRate(new TimerTask() {
+ private void printStats() {
+ if (snapshotList.size() >= 10) {
+ Long[] begin = snapshotList.getFirst();
+ Long[] end = snapshotList.getLast();
+
+ final long sendTps =
+ (long) (((end[3] - begin[3]) / (double) (end[0] - begin[0])) * 1000L);
+ final double averageRT = (end[5] - begin[5]) / (double) (end[3] - begin[3]);
+
+ System.out.printf(
+ "Send TPS: %d Max RT: %d Average RT: %7.3f Send Failed: %d Response Failed: %d transaction checkCount: %d %n",
+ sendTps, statsBenchmark.getSendMessageMaxRT().get(), averageRT, end[2], end[4], end[6]);
+ }
+ }
+
+
+ @Override
+ public void run() {
+ try {
+ this.printStats();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }, 10000, 10000);
+
+ final TransactionCheckListener transactionCheckListener =
+ new TransactionCheckListenerBImpl(ischeckffalse, statsBenchmark);
+ final TransactionMQProducer producer = new TransactionMQProducer("benchmark_transaction_producer");
+ producer.setInstanceName(Long.toString(System.currentTimeMillis()));
+ producer.setTransactionCheckListener(transactionCheckListener);
+ producer.setDefaultTopicQueueNums(1000);
+ producer.start();
+
+ final TransactionExecuterBImpl tranExecuter = new TransactionExecuterBImpl(ischeck);
+
+ for (int i = 0; i < threadCount; i++) {
+ sendThreadPool.execute(new Runnable() {
+ @Override
+ public void run() {
+ while (true) {
+ try {
+ // Thread.sleep(1000);
+ final long beginTimestamp = System.currentTimeMillis();
+ SendResult sendResult =
+ producer.sendMessageInTransaction(msg, tranExecuter, null);
+ if (sendResult != null) {
+ statsBenchmark.getSendRequestSuccessCount().incrementAndGet();
+ statsBenchmark.getReceiveResponseSuccessCount().incrementAndGet();
+ }
+
+ final long currentRT = System.currentTimeMillis() - beginTimestamp;
+ statsBenchmark.getSendMessageSuccessTimeTotal().addAndGet(currentRT);
+ long prevMaxRT = statsBenchmark.getSendMessageMaxRT().get();
+ while (currentRT > prevMaxRT) {
+ boolean updated =
+ statsBenchmark.getSendMessageMaxRT().compareAndSet(prevMaxRT,
+ currentRT);
+ if (updated)
+ break;
+
+ prevMaxRT = statsBenchmark.getSendMessageMaxRT().get();
+ }
+ } catch (MQClientException e) {
+ statsBenchmark.getSendRequestFailedCount().incrementAndGet();
+ }
+ }
+ }
+ });
+ }
+ }
+
+
+ private static Message buildMessage(final int messageSize) throws UnsupportedEncodingException {
+ Message msg = new Message();
+ msg.setTopic("BenchmarkTest");
+
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < messageSize; i += 10) {
+ sb.append("hello baby");
+ }
+
+ msg.setBody(sb.toString().getBytes(RemotingHelper.DEFAULT_CHARSET));
+
+ return msg;
+ }
+}
+
+
+class TransactionExecuterBImpl implements LocalTransactionExecuter {
+
+ private boolean ischeck;
+
+
+ public TransactionExecuterBImpl(boolean ischeck) {
+ this.ischeck = ischeck;
+ }
+
+
+ @Override
+ public LocalTransactionState executeLocalTransactionBranch(final Message msg, final Object arg) {
+ if (ischeck) {
+ return LocalTransactionState.UNKNOW;
+ }
+ return LocalTransactionState.COMMIT_MESSAGE;
+ }
+}
+
+
+class TransactionCheckListenerBImpl implements TransactionCheckListener {
+ private boolean ischeckffalse;
+ private StatsBenchmarkTProducer statsBenchmarkTProducer;
+
+
+ public TransactionCheckListenerBImpl(boolean ischeckffalse,
+ StatsBenchmarkTProducer statsBenchmarkTProducer) {
+ this.ischeckffalse = ischeckffalse;
+ this.statsBenchmarkTProducer = statsBenchmarkTProducer;
+ }
+
+
+ @Override
+ public LocalTransactionState checkLocalTransactionState(MessageExt msg) {
+ statsBenchmarkTProducer.getCheckRequestSuccessCount().incrementAndGet();
+ if (ischeckffalse) {
+
+ return LocalTransactionState.ROLLBACK_MESSAGE;
+ }
+
+ return LocalTransactionState.COMMIT_MESSAGE;
+ }
+}
+
+
+class StatsBenchmarkTProducer {
+ private final AtomicLong sendRequestSuccessCount = new AtomicLong(0L);
+
+ private final AtomicLong sendRequestFailedCount = new AtomicLong(0L);
+
+ private final AtomicLong receiveResponseSuccessCount = new AtomicLong(0L);
+
+ private final AtomicLong receiveResponseFailedCount = new AtomicLong(0L);
+
+ private final AtomicLong sendMessageSuccessTimeTotal = new AtomicLong(0L);
+
+ private final AtomicLong sendMessageMaxRT = new AtomicLong(0L);
+
+ private final AtomicLong checkRequestSuccessCount = new AtomicLong(0L);
+
+
+ public Long[] createSnapshot() {
+ Long[] snap = new Long[]{
+ System.currentTimeMillis(),
+ this.sendRequestSuccessCount.get(),
+ this.sendRequestFailedCount.get(),
+ this.receiveResponseSuccessCount.get(),
+ this.receiveResponseFailedCount.get(),
+ this.sendMessageSuccessTimeTotal.get(),
+ this.checkRequestSuccessCount.get()};
+
+ return snap;
+ }
+
+
+ public AtomicLong getSendRequestSuccessCount() {
+ return sendRequestSuccessCount;
+ }
+
+
+ public AtomicLong getSendRequestFailedCount() {
+ return sendRequestFailedCount;
+ }
+
+
+ public AtomicLong getReceiveResponseSuccessCount() {
+ return receiveResponseSuccessCount;
+ }
+
+
+ public AtomicLong getReceiveResponseFailedCount() {
+ return receiveResponseFailedCount;
+ }
+
+
+ public AtomicLong getSendMessageSuccessTimeTotal() {
+ return sendMessageSuccessTimeTotal;
+ }
+
+
+ public AtomicLong getSendMessageMaxRT() {
+ return sendMessageMaxRT;
+ }
+
+
+ public AtomicLong getCheckRequestSuccessCount() {
+ return checkRequestSuccessCount;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/broadcast/PushConsumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/broadcast/PushConsumer.java b/example/src/main/java/org/apache/rocketmq/example/broadcast/PushConsumer.java
new file mode 100644
index 0000000..aa62a1e
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/broadcast/PushConsumer.java
@@ -0,0 +1,54 @@
+/**
+ * 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.example.broadcast;
+
+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.common.consumer.ConsumeFromWhere;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+
+import java.util.List;
+
+public class PushConsumer {
+
+ public static void main(String[] args) throws InterruptedException, MQClientException {
+ DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("please_rename_unique_group_name_1");
+
+ consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
+
+ consumer.setMessageModel(MessageModel.BROADCASTING);
+
+ consumer.subscribe("TopicTest", "TagA || TagC || TagD");
+
+ consumer.registerMessageListener(new MessageListenerConcurrently() {
+
+ @Override
+ public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
+ ConsumeConcurrentlyContext context) {
+ System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n");
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }
+ });
+
+ consumer.start();
+ System.out.printf("Broadcast Consumer Started.%n");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/filter/Consumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/filter/Consumer.java b/example/src/main/java/org/apache/rocketmq/example/filter/Consumer.java
new file mode 100644
index 0000000..d0a41f1
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/filter/Consumer.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 org.apache.rocketmq.example.filter;
+
+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.common.MixAll;
+import org.apache.rocketmq.common.message.MessageExt;
+
+import java.util.List;
+
+
+public class Consumer {
+
+ public static void main(String[] args) throws InterruptedException, MQClientException {
+ DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("ConsumerGroupNamecc4");
+
+ String filterCode = MixAll.file2String("/home/admin/MessageFilterImpl.java");
+ consumer.subscribe("TopicFilter7", "org.apache.rocketmq.example.filter.MessageFilterImpl",
+ filterCode);
+
+ consumer.registerMessageListener(new MessageListenerConcurrently() {
+
+ @Override
+ public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
+ ConsumeConcurrentlyContext context) {
+ System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n");
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }
+ });
+
+ consumer.start();
+
+ System.out.printf("Consumer Started.%n");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/filter/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/filter/Producer.java b/example/src/main/java/org/apache/rocketmq/example/filter/Producer.java
new file mode 100644
index 0000000..d58c28d
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/filter/Producer.java
@@ -0,0 +1,46 @@
+/**
+ * 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.example.filter;
+
+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.message.Message;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+
+public class Producer {
+ public static void main(String[] args) throws MQClientException, InterruptedException {
+ DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName");
+ producer.start();
+
+ try {
+ for (int i = 0; i < 6000000; i++) {
+ Message msg = new Message("TopicFilter7",
+ "TagA",
+ "OrderID001",
+ "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
+
+ msg.putUserProperty("SequenceId", String.valueOf(i));
+ SendResult sendResult = producer.send(msg);
+ System.out.printf("%s%n", sendResult);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ producer.shutdown();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/operation/Consumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/operation/Consumer.java b/example/src/main/java/org/apache/rocketmq/example/operation/Consumer.java
new file mode 100644
index 0000000..a6a3aca
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/operation/Consumer.java
@@ -0,0 +1,114 @@
+/**
+ * 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.example.operation;
+
+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.common.message.MessageExt;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.PosixParser;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+
+public class Consumer {
+
+ public static void main(String[] args) throws InterruptedException, MQClientException {
+ CommandLine commandLine = buildCommandline(args);
+ if (commandLine != null) {
+ String group = commandLine.getOptionValue('g');
+ String topic = commandLine.getOptionValue('t');
+ String subscription = commandLine.getOptionValue('s');
+ final String returnFailedHalf = commandLine.getOptionValue('f');
+
+ DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(group);
+ consumer.setInstanceName(Long.toString(System.currentTimeMillis()));
+
+ consumer.subscribe(topic, subscription);
+
+ consumer.registerMessageListener(new MessageListenerConcurrently() {
+ AtomicLong consumeTimes = new AtomicLong(0);
+
+
+ @Override
+ public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
+ ConsumeConcurrentlyContext context) {
+ long currentTimes = this.consumeTimes.incrementAndGet();
+ System.out.printf("%-8d %s%n", currentTimes, msgs);
+ if (Boolean.parseBoolean(returnFailedHalf)) {
+ if ((currentTimes % 2) == 0) {
+ return ConsumeConcurrentlyStatus.RECONSUME_LATER;
+ }
+ }
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }
+ });
+
+ consumer.start();
+
+ System.out.printf("Consumer Started.%n");
+ }
+ }
+
+ public static CommandLine buildCommandline(String[] args) {
+ final Options options = new Options();
+ Option opt = new Option("h", "help", false, "Print help");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+ opt = new Option("g", "consumerGroup", true, "Consumer Group Name");
+ opt.setRequired(true);
+ options.addOption(opt);
+
+ opt = new Option("t", "topic", true, "Topic Name");
+ opt.setRequired(true);
+ options.addOption(opt);
+
+ opt = new Option("s", "subscription", true, "subscription");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+ opt = new Option("f", "returnFailedHalf", true, "return failed result, for half message");
+ opt.setRequired(true);
+ options.addOption(opt);
+
+ PosixParser parser = new PosixParser();
+ HelpFormatter hf = new HelpFormatter();
+ hf.setWidth(110);
+ CommandLine commandLine = null;
+ try {
+ commandLine = parser.parse(options, args);
+ if (commandLine.hasOption('h')) {
+ hf.printHelp("producer", options, true);
+ return null;
+ }
+ } catch (ParseException e) {
+ hf.printHelp("producer", options, true);
+ return null;
+ }
+
+ return commandLine;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/operation/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/operation/Producer.java b/example/src/main/java/org/apache/rocketmq/example/operation/Producer.java
new file mode 100644
index 0000000..54e256b
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/operation/Producer.java
@@ -0,0 +1,104 @@
+/**
+ * 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.example.operation;
+
+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.message.Message;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.commons.cli.*;
+
+public class Producer {
+
+ public static void main(String[] args) throws MQClientException, InterruptedException {
+ CommandLine commandLine = buildCommandline(args);
+ if (commandLine != null) {
+ String group = commandLine.getOptionValue('g');
+ String topic = commandLine.getOptionValue('t');
+ String tags = commandLine.getOptionValue('a');
+ String keys = commandLine.getOptionValue('k');
+ String msgCount = commandLine.getOptionValue('c');
+
+ DefaultMQProducer producer = new DefaultMQProducer(group);
+ producer.setInstanceName(Long.toString(System.currentTimeMillis()));
+
+ producer.start();
+
+ for (int i = 0; i < Integer.parseInt(msgCount); i++) {
+ try {
+ Message msg = new Message(
+ topic,
+ tags,
+ keys,
+ ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET));
+ SendResult sendResult = producer.send(msg);
+ System.out.printf("%-8d %s%n", i, sendResult);
+ } catch (Exception e) {
+ e.printStackTrace();
+ Thread.sleep(1000);
+ }
+ }
+
+ producer.shutdown();
+ }
+ }
+
+ public static CommandLine buildCommandline(String[] args) {
+ final Options options = new Options();
+ Option opt = new Option("h", "help", false, "Print help");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+ opt = new Option("g", "producerGroup", true, "Producer Group Name");
+ opt.setRequired(true);
+ options.addOption(opt);
+
+ opt = new Option("t", "topic", true, "Topic Name");
+ opt.setRequired(true);
+ options.addOption(opt);
+
+ opt = new Option("a", "tags", true, "Tags Name");
+ opt.setRequired(true);
+ options.addOption(opt);
+
+ opt = new Option("k", "keys", true, "Keys Name");
+ opt.setRequired(true);
+ options.addOption(opt);
+
+ opt = new Option("c", "msgCount", true, "Message Count");
+ opt.setRequired(true);
+ options.addOption(opt);
+
+ PosixParser parser = new PosixParser();
+ HelpFormatter hf = new HelpFormatter();
+ hf.setWidth(110);
+ CommandLine commandLine = null;
+ try {
+ commandLine = parser.parse(options, args);
+ if (commandLine.hasOption('h')) {
+ hf.printHelp("producer", options, true);
+ return null;
+ }
+ } catch (ParseException e) {
+ hf.printHelp("producer", options, true);
+ return null;
+ }
+
+ return commandLine;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/ordermessage/Consumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/ordermessage/Consumer.java b/example/src/main/java/org/apache/rocketmq/example/ordermessage/Consumer.java
new file mode 100644
index 0000000..7ddfbf7
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/ordermessage/Consumer.java
@@ -0,0 +1,67 @@
+/**
+ * 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.example.ordermessage;
+
+import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
+import org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyContext;
+import org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyStatus;
+import org.apache.rocketmq.client.consumer.listener.MessageListenerOrderly;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
+import org.apache.rocketmq.common.message.MessageExt;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+
+public class Consumer {
+
+ public static void main(String[] args) throws MQClientException {
+ DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("please_rename_unique_group_name_3");
+
+ consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
+
+ consumer.subscribe("TopicTest", "TagA || TagC || TagD");
+
+ consumer.registerMessageListener(new MessageListenerOrderly() {
+ AtomicLong consumeTimes = new AtomicLong(0);
+
+ @Override
+ public ConsumeOrderlyStatus consumeMessage(List<MessageExt> msgs, ConsumeOrderlyContext context) {
+ context.setAutoCommit(false);
+ System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n");
+ this.consumeTimes.incrementAndGet();
+ if ((this.consumeTimes.get() % 2) == 0) {
+ return ConsumeOrderlyStatus.SUCCESS;
+ } else if ((this.consumeTimes.get() % 3) == 0) {
+ return ConsumeOrderlyStatus.ROLLBACK;
+ } else if ((this.consumeTimes.get() % 4) == 0) {
+ return ConsumeOrderlyStatus.COMMIT;
+ } else if ((this.consumeTimes.get() % 5) == 0) {
+ context.setSuspendCurrentQueueTimeMillis(3000);
+ return ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT;
+ }
+
+ return ConsumeOrderlyStatus.SUCCESS;
+ }
+ });
+
+ consumer.start();
+ System.out.printf("Consumer Started.%n");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/ordermessage/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/ordermessage/Producer.java b/example/src/main/java/org/apache/rocketmq/example/ordermessage/Producer.java
new file mode 100644
index 0000000..84c1da4
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/ordermessage/Producer.java
@@ -0,0 +1,68 @@
+/**
+ * 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.example.ordermessage;
+
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.producer.DefaultMQProducer;
+import org.apache.rocketmq.client.producer.MQProducer;
+import org.apache.rocketmq.client.producer.MessageQueueSelector;
+import org.apache.rocketmq.client.producer.SendResult;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+
+public class Producer {
+ public static void main(String[] args) throws UnsupportedEncodingException {
+ try {
+ MQProducer producer = new DefaultMQProducer("please_rename_unique_group_name");
+ producer.start();
+
+ String[] tags = new String[]{"TagA", "TagB", "TagC", "TagD", "TagE"};
+ for (int i = 0; i < 100; i++) {
+ int orderId = i % 10;
+ Message msg =
+ new Message("TopicTestjjj", tags[i % tags.length], "KEY" + i,
+ ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET));
+ SendResult sendResult = producer.send(msg, new MessageQueueSelector() {
+ @Override
+ public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
+ Integer id = (Integer) arg;
+ int index = id % mqs.size();
+ return mqs.get(index);
+ }
+ }, orderId);
+
+ System.out.printf("%s%n", sendResult);
+ }
+
+ producer.shutdown();
+ } catch (MQClientException e) {
+ e.printStackTrace();
+ } catch (RemotingException e) {
+ e.printStackTrace();
+ } catch (MQBrokerException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/quickstart/Consumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/quickstart/Consumer.java b/example/src/main/java/org/apache/rocketmq/example/quickstart/Consumer.java
new file mode 100644
index 0000000..43566f0
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/quickstart/Consumer.java
@@ -0,0 +1,51 @@
+/**
+ * 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.example.quickstart;
+
+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.common.consumer.ConsumeFromWhere;
+import org.apache.rocketmq.common.message.MessageExt;
+
+import java.util.List;
+
+public class Consumer {
+
+ public static void main(String[] args) throws InterruptedException, MQClientException {
+ DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("please_rename_unique_group_name_4");
+
+ consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
+
+ consumer.subscribe("TopicTest", "*");
+
+ consumer.registerMessageListener(new MessageListenerConcurrently() {
+
+ @Override
+ public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
+ ConsumeConcurrentlyContext context) {
+ System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n");
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }
+ });
+
+ consumer.start();
+ System.out.printf("Consumer Started.%n");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/quickstart/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/quickstart/Producer.java b/example/src/main/java/org/apache/rocketmq/example/quickstart/Producer.java
new file mode 100644
index 0000000..f6bd5df
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/quickstart/Producer.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 org.apache.rocketmq.example.quickstart;
+
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.producer.DefaultMQProducer;
+import org.apache.rocketmq.client.producer.LocalTransactionExecuter;
+import org.apache.rocketmq.client.producer.LocalTransactionState;
+import org.apache.rocketmq.client.producer.SendResult;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+
+public class Producer {
+ public static void main(String[] args) throws MQClientException, InterruptedException {
+ DefaultMQProducer producer = new DefaultMQProducer("please_rename_unique_group_name");
+ producer.start();
+
+ for (int i = 0; i < 1000; i++) {
+ try {
+ Message msg = new Message("TopicTest",
+ "TagA",
+ ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET)
+ );
+ SendResult sendResult = producer.send(msg);
+ LocalTransactionExecuter tranExecuter = new LocalTransactionExecuter() {
+ @Override
+ public LocalTransactionState executeLocalTransactionBranch(Message msg, Object arg) {
+ return null;
+ }
+ };
+ System.out.printf("%s%n", sendResult);
+ } catch (Exception e) {
+ e.printStackTrace();
+ Thread.sleep(1000);
+ }
+ }
+ producer.shutdown();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/simple/AsyncProducer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/AsyncProducer.java b/example/src/main/java/org/apache/rocketmq/example/simple/AsyncProducer.java
new file mode 100644
index 0000000..68dbb67
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/AsyncProducer.java
@@ -0,0 +1,61 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.example.simple;
+
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.producer.DefaultMQProducer;
+import org.apache.rocketmq.client.producer.SendCallback;
+import org.apache.rocketmq.client.producer.SendResult;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+
+import java.io.UnsupportedEncodingException;
+
+
+public class AsyncProducer {
+ public static void main(String[] args) throws MQClientException, InterruptedException, UnsupportedEncodingException {
+
+ DefaultMQProducer producer = new DefaultMQProducer("Jodie_Daily_test");
+ producer.start();
+ producer.setRetryTimesWhenSendAsyncFailed(0);
+
+ for (int i = 0; i < 10000000; i++) {
+ try {
+ final int index = i;
+ Message msg = new Message("Jodie_topic_1023",
+ "TagA",
+ "OrderID188",
+ "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
+ producer.send(msg, new SendCallback() {
+ @Override
+ public void onSuccess(SendResult sendResult) {
+ System.out.printf("%-10d OK %s %n", index, sendResult.getMsgId());
+ }
+
+ @Override
+ public void onException(Throwable e) {
+ System.out.printf("%-10d Exception %s %n", index, e);
+ e.printStackTrace();
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ producer.shutdown();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/simple/CachedQueue.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/CachedQueue.java b/example/src/main/java/org/apache/rocketmq/example/simple/CachedQueue.java
new file mode 100644
index 0000000..2b4ce23
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/CachedQueue.java
@@ -0,0 +1,32 @@
+/**
+ * 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.example.simple;
+
+import org.apache.rocketmq.common.message.MessageExt;
+
+import java.util.TreeMap;
+
+
+public class CachedQueue {
+ private final TreeMap<Long, MessageExt> msgCachedTable = new TreeMap<Long, MessageExt>();
+
+
+ public TreeMap<Long, MessageExt> getMsgCachedTable() {
+ return msgCachedTable;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/simple/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/Producer.java b/example/src/main/java/org/apache/rocketmq/example/simple/Producer.java
new file mode 100644
index 0000000..b035d57
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/Producer.java
@@ -0,0 +1,50 @@
+/**
+ * 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.example.simple;
+
+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.message.Message;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+
+
+public class Producer {
+ public static void main(String[] args) throws MQClientException, InterruptedException {
+
+ DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName");
+
+ producer.start();
+
+ for (int i = 0; i < 10000000; i++)
+ try {
+ {
+ Message msg = new Message("TopicTest",
+ "TagA",
+ "OrderID188",
+ "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
+ SendResult sendResult = producer.send(msg);
+ System.out.printf("%s%n", sendResult);
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ producer.shutdown();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/simple/PullConsumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/PullConsumer.java b/example/src/main/java/org/apache/rocketmq/example/simple/PullConsumer.java
new file mode 100644
index 0000000..8c9ba15
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/PullConsumer.java
@@ -0,0 +1,80 @@
+/**
+ * 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.example.simple;
+
+import org.apache.rocketmq.client.consumer.DefaultMQPullConsumer;
+import org.apache.rocketmq.client.consumer.PullResult;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.common.message.MessageQueue;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+public class PullConsumer {
+ private static final Map<MessageQueue, Long> OFFSE_TABLE = new HashMap<MessageQueue, Long>();
+
+
+ public static void main(String[] args) throws MQClientException {
+ DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("please_rename_unique_group_name_5");
+
+ consumer.start();
+
+ Set<MessageQueue> mqs = consumer.fetchSubscribeMessageQueues("TopicTest1");
+ for (MessageQueue mq : mqs) {
+ System.out.printf("Consume from the queue: " + mq + "%n");
+ SINGLE_MQ:
+ while (true) {
+ try {
+ PullResult pullResult =
+ consumer.pullBlockIfNotFound(mq, null, getMessageQueueOffset(mq), 32);
+ System.out.printf("%s%n", pullResult);
+ putMessageQueueOffset(mq, pullResult.getNextBeginOffset());
+ switch (pullResult.getPullStatus()) {
+ case FOUND:
+ break;
+ case NO_MATCHED_MSG:
+ break;
+ case NO_NEW_MSG:
+ break SINGLE_MQ;
+ case OFFSET_ILLEGAL:
+ break;
+ default:
+ break;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ consumer.shutdown();
+ }
+
+ private static long getMessageQueueOffset(MessageQueue mq) {
+ Long offset = OFFSE_TABLE.get(mq);
+ if (offset != null)
+ return offset;
+
+ return 0;
+ }
+
+ private static void putMessageQueueOffset(MessageQueue mq, long offset) {
+ OFFSE_TABLE.put(mq, offset);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/simple/PullConsumerTest.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/PullConsumerTest.java b/example/src/main/java/org/apache/rocketmq/example/simple/PullConsumerTest.java
new file mode 100644
index 0000000..c2d7468
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/PullConsumerTest.java
@@ -0,0 +1,47 @@
+/**
+ * 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.example.simple;
+
+import org.apache.rocketmq.client.consumer.DefaultMQPullConsumer;
+import org.apache.rocketmq.client.consumer.PullResult;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.common.message.MessageQueue;
+
+public class PullConsumerTest {
+ public static void main(String[] args) throws MQClientException {
+ DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("please_rename_unique_group_name_5");
+ consumer.start();
+
+ try {
+ MessageQueue mq = new MessageQueue();
+ mq.setQueueId(0);
+ mq.setTopic("TopicTest3");
+ mq.setBrokerName("vivedeMacBook-Pro.local");
+
+ long offset = 26;
+
+ long beginTime = System.currentTimeMillis();
+ PullResult pullResult = consumer.pullBlockIfNotFound(mq, null, offset, 32);
+ System.out.printf("%s%n", System.currentTimeMillis() - beginTime);
+ System.out.printf("%s%n", pullResult);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ consumer.shutdown();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/simple/PullScheduleService.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/PullScheduleService.java b/example/src/main/java/org/apache/rocketmq/example/simple/PullScheduleService.java
new file mode 100644
index 0000000..d38d679
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/PullScheduleService.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.rocketmq.example.simple;
+
+import org.apache.rocketmq.client.consumer.MQPullConsumer;
+import org.apache.rocketmq.client.consumer.MQPullConsumerScheduleService;
+import org.apache.rocketmq.client.consumer.PullResult;
+import org.apache.rocketmq.client.consumer.PullTaskCallback;
+import org.apache.rocketmq.client.consumer.PullTaskContext;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+
+
+public class PullScheduleService {
+
+ public static void main(String[] args) throws MQClientException {
+ final MQPullConsumerScheduleService scheduleService = new MQPullConsumerScheduleService("GroupName1");
+
+ scheduleService.setMessageModel(MessageModel.CLUSTERING);
+ scheduleService.registerPullTaskCallback("TopicTest1", new PullTaskCallback() {
+
+ @Override
+ public void doPullTask(MessageQueue mq, PullTaskContext context) {
+ MQPullConsumer consumer = context.getPullConsumer();
+ try {
+
+ long offset = consumer.fetchConsumeOffset(mq, false);
+ if (offset < 0)
+ offset = 0;
+
+ PullResult pullResult = consumer.pull(mq, "*", offset, 32);
+ System.out.printf("%s%n", offset + "\t" + mq + "\t" + pullResult);
+ switch (pullResult.getPullStatus()) {
+ case FOUND:
+ break;
+ case NO_MATCHED_MSG:
+ break;
+ case NO_NEW_MSG:
+ case OFFSET_ILLEGAL:
+ break;
+ default:
+ break;
+ }
+ consumer.updateConsumeOffset(mq, pullResult.getNextBeginOffset());
+
+
+ context.setPullNextDelayTimeMillis(100);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ scheduleService.start();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/simple/PushConsumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/PushConsumer.java b/example/src/main/java/org/apache/rocketmq/example/simple/PushConsumer.java
new file mode 100644
index 0000000..5929aff
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/PushConsumer.java
@@ -0,0 +1,50 @@
+/**
+ * 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.example.simple;
+
+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.common.consumer.ConsumeFromWhere;
+import org.apache.rocketmq.common.message.MessageExt;
+
+import java.util.List;
+
+
+public class PushConsumer {
+
+ public static void main(String[] args) throws InterruptedException, MQClientException {
+ DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("CID_JODIE_1");
+ consumer.subscribe("Jodie_topic_1023", "*");
+ consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
+ consumer.registerMessageListener(new MessageListenerConcurrently() {
+
+ /**
+
+ */
+ @Override
+ public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
+ System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n");
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }
+ });
+ consumer.start();
+ System.out.printf("Consumer Started.%n");
+ }
+}
[10/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
new file mode 100644
index 0000000..db50672
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
@@ -0,0 +1,238 @@
+/**
+ * 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.common.message;
+
+import org.apache.rocketmq.common.TopicFilterType;
+import org.apache.rocketmq.common.sysflag.MessageSysFlag;
+
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.nio.ByteBuffer;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class MessageExt extends Message {
+ private static final long serialVersionUID = 5720810158625748049L;
+
+ private int queueId;
+
+ private int storeSize;
+
+ private long queueOffset;
+ private int sysFlag;
+ private long bornTimestamp;
+ private SocketAddress bornHost;
+
+ private long storeTimestamp;
+ private SocketAddress storeHost;
+ private String msgId;
+ private long commitLogOffset;
+ private int bodyCRC;
+ private int reconsumeTimes;
+
+ private long preparedTransactionOffset;
+
+
+ public MessageExt() {
+ }
+
+
+ public MessageExt(int queueId, long bornTimestamp, SocketAddress bornHost, long storeTimestamp,
+ SocketAddress storeHost, String msgId) {
+ this.queueId = queueId;
+ this.bornTimestamp = bornTimestamp;
+ this.bornHost = bornHost;
+ this.storeTimestamp = storeTimestamp;
+ this.storeHost = storeHost;
+ this.msgId = msgId;
+ }
+
+ public static TopicFilterType parseTopicFilterType(final int sysFlag) {
+ if ((sysFlag & MessageSysFlag.MULTI_TAGS_FLAG) == MessageSysFlag.MULTI_TAGS_FLAG) {
+ return TopicFilterType.MULTI_TAG;
+ }
+
+ return TopicFilterType.SINGLE_TAG;
+ }
+
+ public ByteBuffer getBornHostBytes() {
+ return socketAddress2ByteBuffer(this.bornHost);
+ }
+
+ public ByteBuffer getBornHostBytes(ByteBuffer byteBuffer) {
+ return socketAddress2ByteBuffer(this.bornHost, byteBuffer);
+ }
+
+ private static ByteBuffer socketAddress2ByteBuffer(final SocketAddress socketAddress, final ByteBuffer byteBuffer) {
+ InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
+ byteBuffer.put(inetSocketAddress.getAddress().getAddress(), 0, 4);
+ byteBuffer.putInt(inetSocketAddress.getPort());
+ byteBuffer.flip();
+ return byteBuffer;
+ }
+
+ public static ByteBuffer socketAddress2ByteBuffer(SocketAddress socketAddress) {
+ ByteBuffer byteBuffer = ByteBuffer.allocate(8);
+ return socketAddress2ByteBuffer(socketAddress, byteBuffer);
+ }
+
+ public ByteBuffer getStoreHostBytes() {
+ return socketAddress2ByteBuffer(this.storeHost);
+ }
+
+ public ByteBuffer getStoreHostBytes(ByteBuffer byteBuffer) {
+ return socketAddress2ByteBuffer(this.storeHost, byteBuffer);
+ }
+
+ public int getQueueId() {
+ return queueId;
+ }
+
+ public void setQueueId(int queueId) {
+ this.queueId = queueId;
+ }
+
+ public long getBornTimestamp() {
+ return bornTimestamp;
+ }
+
+ public void setBornTimestamp(long bornTimestamp) {
+ this.bornTimestamp = bornTimestamp;
+ }
+
+ public SocketAddress getBornHost() {
+ return bornHost;
+ }
+
+ public void setBornHost(SocketAddress bornHost) {
+ this.bornHost = bornHost;
+ }
+
+ public String getBornHostString() {
+ if (this.bornHost != null) {
+ InetSocketAddress inetSocketAddress = (InetSocketAddress) this.bornHost;
+ return inetSocketAddress.getAddress().getHostAddress();
+ }
+
+ return null;
+ }
+
+ public String getBornHostNameString() {
+ if (this.bornHost != null) {
+ InetSocketAddress inetSocketAddress = (InetSocketAddress) this.bornHost;
+ return inetSocketAddress.getAddress().getHostName();
+ }
+
+ return null;
+ }
+
+ public long getStoreTimestamp() {
+ return storeTimestamp;
+ }
+
+ public void setStoreTimestamp(long storeTimestamp) {
+ this.storeTimestamp = storeTimestamp;
+ }
+
+ public SocketAddress getStoreHost() {
+ return storeHost;
+ }
+
+ public void setStoreHost(SocketAddress storeHost) {
+ this.storeHost = storeHost;
+ }
+
+ public String getMsgId() {
+ return msgId;
+ }
+
+ public void setMsgId(String msgId) {
+ this.msgId = msgId;
+ }
+
+ public int getSysFlag() {
+ return sysFlag;
+ }
+
+ public void setSysFlag(int sysFlag) {
+ this.sysFlag = sysFlag;
+ }
+
+ public int getBodyCRC() {
+ return bodyCRC;
+ }
+
+ public void setBodyCRC(int bodyCRC) {
+ this.bodyCRC = bodyCRC;
+ }
+
+ public long getQueueOffset() {
+ return queueOffset;
+ }
+
+ public void setQueueOffset(long queueOffset) {
+ this.queueOffset = queueOffset;
+ }
+
+ public long getCommitLogOffset() {
+ return commitLogOffset;
+ }
+
+ public void setCommitLogOffset(long physicOffset) {
+ this.commitLogOffset = physicOffset;
+ }
+
+ public int getStoreSize() {
+ return storeSize;
+ }
+
+ public void setStoreSize(int storeSize) {
+ this.storeSize = storeSize;
+ }
+
+ public int getReconsumeTimes() {
+ return reconsumeTimes;
+ }
+
+
+ public void setReconsumeTimes(int reconsumeTimes) {
+ this.reconsumeTimes = reconsumeTimes;
+ }
+
+
+ public long getPreparedTransactionOffset() {
+ return preparedTransactionOffset;
+ }
+
+
+ public void setPreparedTransactionOffset(long preparedTransactionOffset) {
+ this.preparedTransactionOffset = preparedTransactionOffset;
+ }
+
+
+ @Override
+ public String toString() {
+ return "MessageExt [queueId=" + queueId + ", storeSize=" + storeSize + ", queueOffset=" + queueOffset
+ + ", sysFlag=" + sysFlag + ", bornTimestamp=" + bornTimestamp + ", bornHost=" + bornHost
+ + ", storeTimestamp=" + storeTimestamp + ", storeHost=" + storeHost + ", msgId=" + msgId
+ + ", commitLogOffset=" + commitLogOffset + ", bodyCRC=" + bodyCRC + ", reconsumeTimes="
+ + reconsumeTimes + ", preparedTransactionOffset=" + preparedTransactionOffset
+ + ", toString()=" + super.toString() + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java
new file mode 100644
index 0000000..95fe2f9
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java
@@ -0,0 +1,54 @@
+/**
+ * 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.common.message;
+
+import java.net.SocketAddress;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class MessageId {
+ private SocketAddress address;
+ private long offset;
+
+
+ public MessageId(SocketAddress address, long offset) {
+ this.address = address;
+ this.offset = offset;
+ }
+
+
+ public SocketAddress getAddress() {
+ return address;
+ }
+
+
+ public void setAddress(SocketAddress address) {
+ this.address = address;
+ }
+
+
+ public long getOffset() {
+ return offset;
+ }
+
+
+ public void setOffset(long offset) {
+ this.offset = offset;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
new file mode 100644
index 0000000..3c341e6
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
@@ -0,0 +1,134 @@
+/**
+ * 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.common.message;
+
+import java.io.Serializable;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class MessageQueue implements Comparable<MessageQueue>, Serializable {
+ private static final long serialVersionUID = 6191200464116433425L;
+ private String topic;
+ private String brokerName;
+ private int queueId;
+
+
+ public MessageQueue() {
+
+ }
+
+
+ public MessageQueue(String topic, String brokerName, int queueId) {
+ this.topic = topic;
+ this.brokerName = brokerName;
+ this.queueId = queueId;
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public String getBrokerName() {
+ return brokerName;
+ }
+
+
+ public void setBrokerName(String brokerName) {
+ this.brokerName = brokerName;
+ }
+
+
+ public int getQueueId() {
+ return queueId;
+ }
+
+
+ public void setQueueId(int queueId) {
+ this.queueId = queueId;
+ }
+
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((brokerName == null) ? 0 : brokerName.hashCode());
+ result = prime * result + queueId;
+ result = prime * result + ((topic == null) ? 0 : topic.hashCode());
+ return result;
+ }
+
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ MessageQueue other = (MessageQueue) obj;
+ if (brokerName == null) {
+ if (other.brokerName != null)
+ return false;
+ } else if (!brokerName.equals(other.brokerName))
+ return false;
+ if (queueId != other.queueId)
+ return false;
+ if (topic == null) {
+ if (other.topic != null)
+ return false;
+ } else if (!topic.equals(other.topic))
+ return false;
+ return true;
+ }
+
+
+ @Override
+ public String toString() {
+ return "MessageQueue [topic=" + topic + ", brokerName=" + brokerName + ", queueId=" + queueId + "]";
+ }
+
+
+ @Override
+ public int compareTo(MessageQueue o) {
+ {
+ int result = this.topic.compareTo(o.topic);
+ if (result != 0) {
+ return result;
+ }
+ }
+
+ {
+ int result = this.brokerName.compareTo(o.brokerName);
+ if (result != 0) {
+ return result;
+ }
+ }
+
+ return this.queueId - o.queueId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java
new file mode 100644
index 0000000..27b5e07
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java
@@ -0,0 +1,152 @@
+/**
+ * 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.common.message;
+
+import java.io.Serializable;
+
+
+/**
+ * @author lansheng.zj
+ */
+public class MessageQueueForC implements Comparable<MessageQueueForC>, Serializable {
+
+ private static final long serialVersionUID = 5320967846569962104L;
+ private String topic;
+ private String brokerName;
+ private int queueId;
+ private long offset;
+
+
+ public MessageQueueForC(String topic, String brokerName, int queueId, long offset) {
+ this.topic = topic;
+ this.brokerName = brokerName;
+ this.queueId = queueId;
+ this.offset = offset;
+ }
+
+
+ @Override
+ public int compareTo(MessageQueueForC o) {
+ int result = this.topic.compareTo(o.topic);
+ if (result != 0) {
+ return result;
+ }
+ result = this.brokerName.compareTo(o.brokerName);
+ if (result != 0) {
+ return result;
+ }
+ result = this.queueId - o.queueId;
+ if (result != 0) {
+ return result;
+ }
+ if ((this.offset - o.offset) > 0) {
+ return 1;
+ } else if ((this.offset - o.offset) == 0) {
+ return 0;
+ } else {
+ return -1;
+ }
+ }
+
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((brokerName == null) ? 0 : brokerName.hashCode());
+ result = prime * result + queueId;
+ result = prime * result + ((topic == null) ? 0 : topic.hashCode());
+ return result;
+ }
+
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ MessageQueueForC other = (MessageQueueForC) obj;
+ if (brokerName == null) {
+ if (other.brokerName != null)
+ return false;
+ } else if (!brokerName.equals(other.brokerName))
+ return false;
+ if (queueId != other.queueId)
+ return false;
+ if (topic == null) {
+ if (other.topic != null)
+ return false;
+ } else if (!topic.equals(other.topic))
+ return false;
+
+ if (offset != other.offset) {
+ return false;
+ }
+ return true;
+ }
+
+
+ @Override
+ public String toString() {
+ return "MessageQueueForC [topic=" + topic + ", brokerName=" + brokerName + ", queueId=" + queueId
+ + ", offset=" + offset + "]";
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public String getBrokerName() {
+ return brokerName;
+ }
+
+
+ public void setBrokerName(String brokerName) {
+ this.brokerName = brokerName;
+ }
+
+
+ public int getQueueId() {
+ return queueId;
+ }
+
+
+ public void setQueueId(int queueId) {
+ this.queueId = queueId;
+ }
+
+
+ public long getOffset() {
+ return offset;
+ }
+
+
+ public void setOffset(long offset) {
+ this.offset = offset;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/message/MessageType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageType.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageType.java
new file mode 100644
index 0000000..a1913a5
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageType.java
@@ -0,0 +1,25 @@
+/**
+ * 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.common.message;
+
+public enum MessageType {
+ Normal_Msg,
+ Trans_Msg_Half,
+ Trans_msg_Commit,
+ Delay_Msg,
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
new file mode 100644
index 0000000..d71e6b0
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
@@ -0,0 +1,100 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: NamesrvConfig.java 1839 2013-05-16 02:12:02Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.namesrv;
+
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+
+
+/**
+ *
+ * @author shijia.wxr
+ * @author lansheng.zj
+ */
+public class NamesrvConfig {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
+ private String rocketmqHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV));
+
+ private String kvConfigPath = System.getProperty("user.home") + File.separator + "namesrv" + File.separator + "kvConfig.json";
+ private String configStorePath = System.getProperty("user.home") + File.separator + "namesrv" + File.separator + "namesrv.properties";
+ private String productEnvName = "center";
+ private boolean clusterTest = false;
+ private boolean orderMessageEnable = false;
+
+ public boolean isOrderMessageEnable() {
+ return orderMessageEnable;
+ }
+
+ public void setOrderMessageEnable(boolean orderMessageEnable) {
+ this.orderMessageEnable = orderMessageEnable;
+ }
+
+ public String getRocketmqHome() {
+ return rocketmqHome;
+ }
+
+
+ public void setRocketmqHome(String rocketmqHome) {
+ this.rocketmqHome = rocketmqHome;
+ }
+
+
+ public String getKvConfigPath() {
+ return kvConfigPath;
+ }
+
+
+ public void setKvConfigPath(String kvConfigPath) {
+ this.kvConfigPath = kvConfigPath;
+ }
+
+
+ public String getProductEnvName() {
+ return productEnvName;
+ }
+
+
+ public void setProductEnvName(String productEnvName) {
+ this.productEnvName = productEnvName;
+ }
+
+
+ public boolean isClusterTest() {
+ return clusterTest;
+ }
+
+
+ public void setClusterTest(boolean clusterTest) {
+ this.clusterTest = clusterTest;
+ }
+
+ public String getConfigStorePath() {
+ return configStorePath;
+ }
+
+ public void setConfigStorePath(final String configStorePath) {
+ this.configStorePath = configStorePath;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java
new file mode 100644
index 0000000..fb854f8
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java
@@ -0,0 +1,25 @@
+/**
+ * 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.common.namesrv;
+
+/**
+ * @author shijia.wxr
+ */
+public class NamesrvUtil {
+ public static final String NAMESPACE_ORDER_TOPIC_CONFIG = "ORDER_TOPIC_CONFIG";
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java
new file mode 100644
index 0000000..10c811e
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java
@@ -0,0 +1,60 @@
+/**
+ * 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.common.namesrv;
+
+import org.apache.rocketmq.common.protocol.body.KVTable;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class RegisterBrokerResult {
+ private String haServerAddr;
+ private String masterAddr;
+ private KVTable kvTable;
+
+
+ public String getHaServerAddr() {
+ return haServerAddr;
+ }
+
+
+ public void setHaServerAddr(String haServerAddr) {
+ this.haServerAddr = haServerAddr;
+ }
+
+
+ public String getMasterAddr() {
+ return masterAddr;
+ }
+
+
+ public void setMasterAddr(String masterAddr) {
+ this.masterAddr = masterAddr;
+ }
+
+
+ public KVTable getKvTable() {
+ return kvTable;
+ }
+
+
+ public void setKvTable(KVTable kvTable) {
+ this.kvTable = kvTable;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
new file mode 100644
index 0000000..5836c05
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
@@ -0,0 +1,115 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: TopAddressing.java 1831 2013-05-16 01:39:51Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.namesrv;
+
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.help.FAQUrl;
+import org.apache.rocketmq.common.utils.HttpTinyClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+
+/**
+ * @author shijia.wxr
+ * @author manhong.yqd
+ */
+public class TopAddressing {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
+ private String nsAddr;
+ private String wsAddr;
+ private String unitName;
+
+
+ public TopAddressing(final String wsAddr) {
+ this(wsAddr, null);
+ }
+
+
+ public TopAddressing(final String wsAddr, final String unitName) {
+ this.wsAddr = wsAddr;
+ this.unitName = unitName;
+ }
+
+ public final String fetchNSAddr() {
+ return fetchNSAddr(true, 3000);
+ }
+
+ public final String fetchNSAddr(boolean verbose, long timeoutMills) {
+ String url = this.wsAddr;
+ try {
+ if (!UtilAll.isBlank(this.unitName)) {
+ url = url + "-" + this.unitName + "?nofix=1";
+ }
+ HttpTinyClient.HttpResult result = HttpTinyClient.httpGet(url, null, null, "UTF-8", timeoutMills);
+ if (200 == result.code) {
+ String responseStr = result.content;
+ if (responseStr != null) {
+ return clearNewLine(responseStr);
+ } else {
+ log.error("fetch nameserver address is null");
+ }
+ } else {
+ log.error("fetch nameserver address failed. statusCode={}", result.code);
+ }
+ } catch (IOException e) {
+ if (verbose) {
+ log.error("fetch name server address exception", e);
+ }
+ }
+
+ if (verbose) {
+ String errorMsg =
+ "connect to " + url + " failed, maybe the domain name " + MixAll.WS_DOMAIN_NAME + " not bind in /etc/hosts";
+ errorMsg += FAQUrl.suggestTodo(FAQUrl.NAME_SERVER_ADDR_NOT_EXIST_URL);
+
+ log.warn(errorMsg);
+ }
+ return null;
+ }
+
+ private static String clearNewLine(final String str) {
+ String newString = str.trim();
+ int index = newString.indexOf("\r");
+ if (index != -1) {
+ return newString.substring(0, index);
+ }
+
+ index = newString.indexOf("\n");
+ if (index != -1) {
+ return newString.substring(0, index);
+ }
+
+ return newString;
+ }
+
+ public String getNsAddr() {
+ return nsAddr;
+ }
+
+
+ public void setNsAddr(String nsAddr) {
+ this.nsAddr = nsAddr;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java b/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java
new file mode 100644
index 0000000..44e2e4f
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java
@@ -0,0 +1,57 @@
+/**
+ * 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.common.protocol;
+
+import org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerRequestHeader;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.exception.RemotingConnectException;
+import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
+import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class MQProtosHelper {
+ public static boolean registerBrokerToNameServer(final String nsaddr, final String brokerAddr,
+ final long timeoutMillis) {
+ RegisterBrokerRequestHeader requestHeader = new RegisterBrokerRequestHeader();
+ requestHeader.setBrokerAddr(brokerAddr);
+
+ RemotingCommand request =
+ RemotingCommand.createRequestCommand(RequestCode.REGISTER_BROKER, requestHeader);
+
+ try {
+ RemotingCommand response = RemotingHelper.invokeSync(nsaddr, request, timeoutMillis);
+ if (response != null) {
+ return ResponseCode.SUCCESS == response.getCode();
+ }
+ } catch (RemotingConnectException e) {
+ e.printStackTrace();
+ } catch (RemotingSendRequestException e) {
+ e.printStackTrace();
+ } catch (RemotingTimeoutException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/RequestCode.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/RequestCode.java b/common/src/main/java/org/apache/rocketmq/common/protocol/RequestCode.java
new file mode 100644
index 0000000..d878726
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/RequestCode.java
@@ -0,0 +1,166 @@
+/**
+ * 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.common.protocol;
+
+public class RequestCode {
+
+ public static final int SEND_MESSAGE = 10;
+
+ public static final int PULL_MESSAGE = 11;
+
+ public static final int QUERY_MESSAGE = 12;
+ public static final int QUERY_BROKER_OFFSET = 13;
+ public static final int QUERY_CONSUMER_OFFSET = 14;
+ public static final int UPDATE_CONSUMER_OFFSET = 15;
+ public static final int UPDATE_AND_CREATE_TOPIC = 17;
+ public static final int GET_ALL_TOPIC_CONFIG = 21;
+ public static final int GET_TOPIC_CONFIG_LIST = 22;
+
+ public static final int GET_TOPIC_NAME_LIST = 23;
+
+ public static final int UPDATE_BROKER_CONFIG = 25;
+
+ public static final int GET_BROKER_CONFIG = 26;
+
+ public static final int TRIGGER_DELETE_FILES = 27;
+
+ public static final int GET_BROKER_RUNTIME_INFO = 28;
+ public static final int SEARCH_OFFSET_BY_TIMESTAMP = 29;
+ public static final int GET_MAX_OFFSET = 30;
+ public static final int GET_MIN_OFFSET = 31;
+
+ public static final int GET_EARLIEST_MSG_STORETIME = 32;
+
+ public static final int VIEW_MESSAGE_BY_ID = 33;
+
+ public static final int HEART_BEAT = 34;
+
+ public static final int UNREGISTER_CLIENT = 35;
+
+ public static final int CONSUMER_SEND_MSG_BACK = 36;
+
+ public static final int END_TRANSACTION = 37;
+ public static final int GET_CONSUMER_LIST_BY_GROUP = 38;
+
+ public static final int CHECK_TRANSACTION_STATE = 39;
+
+ public static final int NOTIFY_CONSUMER_IDS_CHANGED = 40;
+
+ public static final int LOCK_BATCH_MQ = 41;
+
+ public static final int UNLOCK_BATCH_MQ = 42;
+ public static final int GET_ALL_CONSUMER_OFFSET = 43;
+
+ public static final int GET_ALL_DELAY_OFFSET = 45;
+
+ public static final int PUT_KV_CONFIG = 100;
+
+ public static final int GET_KV_CONFIG = 101;
+
+ public static final int DELETE_KV_CONFIG = 102;
+
+ public static final int REGISTER_BROKER = 103;
+
+ public static final int UNREGISTER_BROKER = 104;
+ public static final int GET_ROUTEINTO_BY_TOPIC = 105;
+
+ public static final int GET_BROKER_CLUSTER_INFO = 106;
+ public static final int UPDATE_AND_CREATE_SUBSCRIPTIONGROUP = 200;
+ public static final int GET_ALL_SUBSCRIPTIONGROUP_CONFIG = 201;
+ public static final int GET_TOPIC_STATS_INFO = 202;
+ public static final int GET_CONSUMER_CONNECTION_LIST = 203;
+ public static final int GET_PRODUCER_CONNECTION_LIST = 204;
+ public static final int WIPE_WRITE_PERM_OF_BROKER = 205;
+
+
+ public static final int GET_ALL_TOPIC_LIST_FROM_NAMESERVER = 206;
+
+ public static final int DELETE_SUBSCRIPTIONGROUP = 207;
+ public static final int GET_CONSUME_STATS = 208;
+
+ public static final int SUSPEND_CONSUMER = 209;
+
+ public static final int RESUME_CONSUMER = 210;
+ public static final int RESET_CONSUMER_OFFSET_IN_CONSUMER = 211;
+ public static final int RESET_CONSUMER_OFFSET_IN_BROKER = 212;
+
+ public static final int ADJUST_CONSUMER_THREAD_POOL = 213;
+
+ public static final int WHO_CONSUME_THE_MESSAGE = 214;
+
+
+ public static final int DELETE_TOPIC_IN_BROKER = 215;
+
+ public static final int DELETE_TOPIC_IN_NAMESRV = 216;
+ public static final int GET_KVLIST_BY_NAMESPACE = 219;
+
+
+ public static final int RESET_CONSUMER_CLIENT_OFFSET = 220;
+
+ public static final int GET_CONSUMER_STATUS_FROM_CLIENT = 221;
+
+ public static final int INVOKE_BROKER_TO_RESET_OFFSET = 222;
+
+ public static final int INVOKE_BROKER_TO_GET_CONSUMER_STATUS = 223;
+
+
+ public static final int QUERY_TOPIC_CONSUME_BY_WHO = 300;
+
+ public static final int GET_TOPICS_BY_CLUSTER = 224;
+
+ public static final int REGISTER_FILTER_SERVER = 301;
+ public static final int REGISTER_MESSAGE_FILTER_CLASS = 302;
+
+ public static final int QUERY_CONSUME_TIME_SPAN = 303;
+
+ public static final int GET_SYSTEM_TOPIC_LIST_FROM_NS = 304;
+ public static final int GET_SYSTEM_TOPIC_LIST_FROM_BROKER = 305;
+
+ public static final int CLEAN_EXPIRED_CONSUMEQUEUE = 306;
+
+ public static final int GET_CONSUMER_RUNNING_INFO = 307;
+
+ public static final int QUERY_CORRECTION_OFFSET = 308;
+ public static final int CONSUME_MESSAGE_DIRECTLY = 309;
+
+ public static final int SEND_MESSAGE_V2 = 310;
+
+ public static final int GET_UNIT_TOPIC_LIST = 311;
+
+ public static final int GET_HAS_UNIT_SUB_TOPIC_LIST = 312;
+
+ public static final int GET_HAS_UNIT_SUB_UNUNIT_TOPIC_LIST = 313;
+
+ public static final int CLONE_GROUP_OFFSET = 314;
+
+ public static final int VIEW_BROKER_STATS_DATA = 315;
+
+ public static final int CLEAN_UNUSED_TOPIC = 316;
+
+ public static final int GET_BROKER_CONSUME_STATS = 317;
+
+ /**
+ * update the config of name server
+ */
+ public static final int UPDATE_NAMESRV_CONFIG = 318;
+
+ /**
+ * get config from name server
+ */
+ public static final int GET_NAMESRV_CONFIG = 319;
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/ResponseCode.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/ResponseCode.java b/common/src/main/java/org/apache/rocketmq/common/protocol/ResponseCode.java
new file mode 100644
index 0000000..a5b4e2e
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/ResponseCode.java
@@ -0,0 +1,77 @@
+/**
+ * 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.common.protocol;
+
+import org.apache.rocketmq.remoting.protocol.RemotingSysResponseCode;
+
+
+public class ResponseCode extends RemotingSysResponseCode {
+
+ public static final int FLUSH_DISK_TIMEOUT = 10;
+
+ public static final int SLAVE_NOT_AVAILABLE = 11;
+
+ public static final int FLUSH_SLAVE_TIMEOUT = 12;
+
+ public static final int MESSAGE_ILLEGAL = 13;
+
+ public static final int SERVICE_NOT_AVAILABLE = 14;
+
+ public static final int VERSION_NOT_SUPPORTED = 15;
+
+ public static final int NO_PERMISSION = 16;
+
+ public static final int TOPIC_NOT_EXIST = 17;
+ public static final int TOPIC_EXIST_ALREADY = 18;
+ public static final int PULL_NOT_FOUND = 19;
+
+ public static final int PULL_RETRY_IMMEDIATELY = 20;
+
+ public static final int PULL_OFFSET_MOVED = 21;
+
+ public static final int QUERY_NOT_FOUND = 22;
+
+ public static final int SUBSCRIPTION_PARSE_FAILED = 23;
+
+ public static final int SUBSCRIPTION_NOT_EXIST = 24;
+
+ public static final int SUBSCRIPTION_NOT_LATEST = 25;
+
+ public static final int SUBSCRIPTION_GROUP_NOT_EXIST = 26;
+
+ public static final int TRANSACTION_SHOULD_COMMIT = 200;
+
+ public static final int TRANSACTION_SHOULD_ROLLBACK = 201;
+
+ public static final int TRANSACTION_STATE_UNKNOW = 202;
+
+ public static final int TRANSACTION_STATE_GROUP_WRONG = 203;
+ public static final int NO_BUYER_ID = 204;
+
+
+ public static final int NOT_IN_CURRENT_UNIT = 205;
+
+
+ public static final int CONSUMER_NOT_ONLINE = 206;
+
+
+ public static final int CONSUME_MSG_TIMEOUT = 207;
+
+
+ public static final int NO_MESSAGE = 208;
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/BrokerStatsData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/BrokerStatsData.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/BrokerStatsData.java
new file mode 100644
index 0000000..f1ac124
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/BrokerStatsData.java
@@ -0,0 +1,60 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+
+public class BrokerStatsData extends RemotingSerializable {
+
+ private BrokerStatsItem statsMinute;
+
+ private BrokerStatsItem statsHour;
+
+ private BrokerStatsItem statsDay;
+
+
+ public BrokerStatsItem getStatsMinute() {
+ return statsMinute;
+ }
+
+
+ public void setStatsMinute(BrokerStatsItem statsMinute) {
+ this.statsMinute = statsMinute;
+ }
+
+
+ public BrokerStatsItem getStatsHour() {
+ return statsHour;
+ }
+
+
+ public void setStatsHour(BrokerStatsItem statsHour) {
+ this.statsHour = statsHour;
+ }
+
+
+ public BrokerStatsItem getStatsDay() {
+ return statsDay;
+ }
+
+
+ public void setStatsDay(BrokerStatsItem statsDay) {
+ this.statsDay = statsDay;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/BrokerStatsItem.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/BrokerStatsItem.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/BrokerStatsItem.java
new file mode 100644
index 0000000..904770f
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/BrokerStatsItem.java
@@ -0,0 +1,54 @@
+/**
+ * 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.common.protocol.body;
+
+public class BrokerStatsItem {
+ private long sum;
+ private double tps;
+ private double avgpt;
+
+
+ public long getSum() {
+ return sum;
+ }
+
+
+ public void setSum(long sum) {
+ this.sum = sum;
+ }
+
+
+ public double getTps() {
+ return tps;
+ }
+
+
+ public void setTps(double tps) {
+ this.tps = tps;
+ }
+
+
+ public double getAvgpt() {
+ return avgpt;
+ }
+
+
+ public void setAvgpt(double avgpt) {
+ this.avgpt = avgpt;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/CMResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/CMResult.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/CMResult.java
new file mode 100644
index 0000000..85eda7b
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/CMResult.java
@@ -0,0 +1,27 @@
+/**
+ * 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.common.protocol.body;
+
+public enum CMResult {
+ CR_SUCCESS,
+ CR_LATER,
+ CR_ROLLBACK,
+ CR_COMMIT,
+ CR_THROW_EXCEPTION,
+ CR_RETURN_NULL,
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java
new file mode 100644
index 0000000..461d28c
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java
@@ -0,0 +1,76 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.common.protocol.route.BrokerData;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ClusterInfo extends RemotingSerializable {
+ private HashMap<String/* brokerName */, BrokerData> brokerAddrTable;
+ private HashMap<String/* clusterName */, Set<String/* brokerName */>> clusterAddrTable;
+
+
+ public HashMap<String, BrokerData> getBrokerAddrTable() {
+ return brokerAddrTable;
+ }
+
+
+ public void setBrokerAddrTable(HashMap<String, BrokerData> brokerAddrTable) {
+ this.brokerAddrTable = brokerAddrTable;
+ }
+
+
+ public HashMap<String, Set<String>> getClusterAddrTable() {
+ return clusterAddrTable;
+ }
+
+
+ public void setClusterAddrTable(HashMap<String, Set<String>> clusterAddrTable) {
+ this.clusterAddrTable = clusterAddrTable;
+ }
+
+
+ public String[] retrieveAllAddrByCluster(String cluster) {
+ List<String> addrs = new ArrayList<String>();
+ if (clusterAddrTable.containsKey(cluster)) {
+ Set<String> brokerNames = clusterAddrTable.get(cluster);
+ for (String brokerName : brokerNames) {
+ BrokerData brokerData = brokerAddrTable.get(brokerName);
+ if (null != brokerData) {
+ addrs.addAll(brokerData.getBrokerAddrs().values());
+ }
+ }
+ }
+
+ return addrs.toArray(new String[]{});
+ }
+
+
+ public String[] retrieveAllClusterNames() {
+ return clusterAddrTable.keySet().toArray(new String[]{});
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java
new file mode 100644
index 0000000..ed8d9b4
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java
@@ -0,0 +1,71 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.remoting.protocol.LanguageCode;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class Connection {
+ private String clientId;
+ private String clientAddr;
+ private LanguageCode language;
+ private int version;
+
+
+ public String getClientId() {
+ return clientId;
+ }
+
+
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
+
+ public String getClientAddr() {
+ return clientAddr;
+ }
+
+
+ public void setClientAddr(String clientAddr) {
+ this.clientAddr = clientAddr;
+ }
+
+
+ public LanguageCode getLanguage() {
+ return language;
+ }
+
+
+ public void setLanguage(LanguageCode language) {
+ this.language = language;
+ }
+
+
+ public int getVersion() {
+ return version;
+ }
+
+
+ public void setVersion(int version) {
+ this.version = version;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java
new file mode 100644
index 0000000..e6d2cad
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java
@@ -0,0 +1,84 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.HashSet;
+
+
+/**
+ * @author shijia.wxr
+ *
+ */
+public class ConsumeByWho extends RemotingSerializable {
+ private HashSet<String> consumedGroup = new HashSet<String>();
+ private HashSet<String> notConsumedGroup = new HashSet<String>();
+ private String topic;
+ private int queueId;
+ private long offset;
+
+
+ public HashSet<String> getConsumedGroup() {
+ return consumedGroup;
+ }
+
+
+ public void setConsumedGroup(HashSet<String> consumedGroup) {
+ this.consumedGroup = consumedGroup;
+ }
+
+
+ public HashSet<String> getNotConsumedGroup() {
+ return notConsumedGroup;
+ }
+
+
+ public void setNotConsumedGroup(HashSet<String> notConsumedGroup) {
+ this.notConsumedGroup = notConsumedGroup;
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public int getQueueId() {
+ return queueId;
+ }
+
+
+ public void setQueueId(int queueId) {
+ this.queueId = queueId;
+ }
+
+
+ public long getOffset() {
+ return offset;
+ }
+
+
+ public void setOffset(long offset) {
+ this.offset = offset;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeMessageDirectlyResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeMessageDirectlyResult.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeMessageDirectlyResult.java
new file mode 100644
index 0000000..9c63010
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeMessageDirectlyResult.java
@@ -0,0 +1,87 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+
+public class ConsumeMessageDirectlyResult extends RemotingSerializable {
+ private boolean order = false;
+ private boolean autoCommit = true;
+ private CMResult consumeResult;
+ private String remark;
+ private long spentTimeMills;
+
+
+ public boolean isOrder() {
+ return order;
+ }
+
+
+ public void setOrder(boolean order) {
+ this.order = order;
+ }
+
+
+ public boolean isAutoCommit() {
+ return autoCommit;
+ }
+
+
+ public void setAutoCommit(boolean autoCommit) {
+ this.autoCommit = autoCommit;
+ }
+
+
+ public String getRemark() {
+ return remark;
+ }
+
+
+ public void setRemark(String remark) {
+ this.remark = remark;
+ }
+
+
+ public CMResult getConsumeResult() {
+ return consumeResult;
+ }
+
+
+ public void setConsumeResult(CMResult consumeResult) {
+ this.consumeResult = consumeResult;
+ }
+
+
+ public long getSpentTimeMills() {
+ return spentTimeMills;
+ }
+
+
+ public void setSpentTimeMills(long spentTimeMills) {
+ this.spentTimeMills = spentTimeMills;
+ }
+
+
+ @Override
+ public String toString() {
+ return "ConsumeMessageDirectlyResult [order=" + order + ", autoCommit=" + autoCommit
+ + ", consumeResult=" + consumeResult + ", remark=" + remark + ", spentTimeMills="
+ + spentTimeMills + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java
new file mode 100644
index 0000000..8d1396a
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java
@@ -0,0 +1,58 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.common.admin.ConsumeStats;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ConsumeStatsList extends RemotingSerializable {
+ private List<Map<String/*subscriptionGroupName*/, List<ConsumeStats>>> consumeStatsList = new ArrayList<Map<String/*subscriptionGroupName*/, List<ConsumeStats>>>();
+ private String brokerAddr;
+ private long totalDiff;
+
+ public List<Map<String, List<ConsumeStats>>> getConsumeStatsList() {
+ return consumeStatsList;
+ }
+
+ public void setConsumeStatsList(List<Map<String, List<ConsumeStats>>> consumeStatsList) {
+ this.consumeStatsList = consumeStatsList;
+ }
+
+ public String getBrokerAddr() {
+ return brokerAddr;
+ }
+
+ public void setBrokerAddr(String brokerAddr) {
+ this.brokerAddr = brokerAddr;
+ }
+
+ public long getTotalDiff() {
+ return totalDiff;
+ }
+
+ public void setTotalDiff(long totalDiff) {
+ this.totalDiff = totalDiff;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatus.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatus.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatus.java
new file mode 100644
index 0000000..35b6a02
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatus.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.common.protocol.body;
+
+public class ConsumeStatus {
+ private double pullRT;
+ private double pullTPS;
+ private double consumeRT;
+ private double consumeOKTPS;
+ private double consumeFailedTPS;
+
+ private long consumeFailedMsgs;
+
+
+ public double getPullRT() {
+ return pullRT;
+ }
+
+
+ public void setPullRT(double pullRT) {
+ this.pullRT = pullRT;
+ }
+
+
+ public double getPullTPS() {
+ return pullTPS;
+ }
+
+
+ public void setPullTPS(double pullTPS) {
+ this.pullTPS = pullTPS;
+ }
+
+
+ public double getConsumeRT() {
+ return consumeRT;
+ }
+
+
+ public void setConsumeRT(double consumeRT) {
+ this.consumeRT = consumeRT;
+ }
+
+
+ public double getConsumeOKTPS() {
+ return consumeOKTPS;
+ }
+
+
+ public void setConsumeOKTPS(double consumeOKTPS) {
+ this.consumeOKTPS = consumeOKTPS;
+ }
+
+
+ public double getConsumeFailedTPS() {
+ return consumeFailedTPS;
+ }
+
+
+ public void setConsumeFailedTPS(double consumeFailedTPS) {
+ this.consumeFailedTPS = consumeFailedTPS;
+ }
+
+
+ public long getConsumeFailedMsgs() {
+ return consumeFailedMsgs;
+ }
+
+
+ public void setConsumeFailedMsgs(long consumeFailedMsgs) {
+ this.consumeFailedMsgs = consumeFailedMsgs;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java
new file mode 100644
index 0000000..fc3ce46
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java
@@ -0,0 +1,102 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
+import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.HashSet;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ConsumerConnection extends RemotingSerializable {
+ private HashSet<Connection> connectionSet = new HashSet<Connection>();
+ private ConcurrentHashMap<String/* Topic */, SubscriptionData> subscriptionTable =
+ new ConcurrentHashMap<String, SubscriptionData>();
+ private ConsumeType consumeType;
+ private MessageModel messageModel;
+ private ConsumeFromWhere consumeFromWhere;
+
+
+ public int computeMinVersion() {
+ int minVersion = Integer.MAX_VALUE;
+ for (Connection c : this.connectionSet) {
+ if (c.getVersion() < minVersion) {
+ minVersion = c.getVersion();
+ }
+ }
+
+ return minVersion;
+ }
+
+
+ public HashSet<Connection> getConnectionSet() {
+ return connectionSet;
+ }
+
+
+ public void setConnectionSet(HashSet<Connection> connectionSet) {
+ this.connectionSet = connectionSet;
+ }
+
+
+ public ConcurrentHashMap<String, SubscriptionData> getSubscriptionTable() {
+ return subscriptionTable;
+ }
+
+
+ public void setSubscriptionTable(ConcurrentHashMap<String, SubscriptionData> subscriptionTable) {
+ this.subscriptionTable = subscriptionTable;
+ }
+
+
+ public ConsumeType getConsumeType() {
+ return consumeType;
+ }
+
+
+ public void setConsumeType(ConsumeType consumeType) {
+ this.consumeType = consumeType;
+ }
+
+
+ public MessageModel getMessageModel() {
+ return messageModel;
+ }
+
+
+ public void setMessageModel(MessageModel messageModel) {
+ this.messageModel = messageModel;
+ }
+
+
+ public ConsumeFromWhere getConsumeFromWhere() {
+ return consumeFromWhere;
+ }
+
+
+ public void setConsumeFromWhere(ConsumeFromWhere consumeFromWhere) {
+ this.consumeFromWhere = consumeFromWhere;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerOffsetSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerOffsetSerializeWrapper.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerOffsetSerializeWrapper.java
new file mode 100644
index 0000000..5b4c6fb
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerOffsetSerializeWrapper.java
@@ -0,0 +1,41 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * @author manhong.yqd
+ */
+public class ConsumerOffsetSerializeWrapper extends RemotingSerializable {
+ private ConcurrentHashMap<String/* topic@group */, ConcurrentHashMap<Integer, Long>> offsetTable =
+ new ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>>(512);
+
+
+ public ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>> getOffsetTable() {
+ return offsetTable;
+ }
+
+
+ public void setOffsetTable(ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>> offsetTable) {
+ this.offsetTable = offsetTable;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerRunningInfo.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerRunningInfo.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerRunningInfo.java
new file mode 100644
index 0000000..9b0b383
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerRunningInfo.java
@@ -0,0 +1,315 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.*;
+import java.util.Map.Entry;
+
+public class ConsumerRunningInfo extends RemotingSerializable {
+ public static final String PROP_NAMESERVER_ADDR = "PROP_NAMESERVER_ADDR";
+ public static final String PROP_THREADPOOL_CORE_SIZE = "PROP_THREADPOOL_CORE_SIZE";
+ public static final String PROP_CONSUME_ORDERLY = "PROP_CONSUMEORDERLY";
+ public static final String PROP_CONSUME_TYPE = "PROP_CONSUME_TYPE";
+ public static final String PROP_CLIENT_VERSION = "PROP_CLIENT_VERSION";
+ public static final String PROP_CONSUMER_START_TIMESTAMP = "PROP_CONSUMER_START_TIMESTAMP";
+
+
+ private Properties properties = new Properties();
+
+ private TreeSet<SubscriptionData> subscriptionSet = new TreeSet<SubscriptionData>();
+
+ private TreeMap<MessageQueue, ProcessQueueInfo> mqTable = new TreeMap<MessageQueue, ProcessQueueInfo>();
+
+ private TreeMap<String/* Topic */, ConsumeStatus> statusTable = new TreeMap<String, ConsumeStatus>();
+
+ private String jstack;
+
+ public static boolean analyzeSubscription(final TreeMap<String/* clientId */, ConsumerRunningInfo> criTable) {
+ ConsumerRunningInfo prev = criTable.firstEntry().getValue();
+
+ boolean push = false;
+ {
+ String property = prev.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUME_TYPE);
+
+ if (property == null) {
+ property = ((ConsumeType) prev.getProperties().get(ConsumerRunningInfo.PROP_CONSUME_TYPE)).name();
+ }
+ push = ConsumeType.valueOf(property) == ConsumeType.CONSUME_PASSIVELY;
+ }
+
+ boolean startForAWhile = false;
+ {
+
+ String property = prev.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP);
+ if (property == null) {
+ property = String.valueOf(prev.getProperties().get(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP));
+ }
+ startForAWhile = (System.currentTimeMillis() - Long.parseLong(property)) > (1000 * 60 * 2);
+ }
+
+ if (push && startForAWhile) {
+
+ {
+ Iterator<Entry<String, ConsumerRunningInfo>> it = criTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, ConsumerRunningInfo> next = it.next();
+ ConsumerRunningInfo current = next.getValue();
+ boolean equals = current.getSubscriptionSet().equals(prev.getSubscriptionSet());
+
+ if (!equals) {
+ // Different subscription in the same group of consumer
+ return false;
+ }
+
+ prev = next.getValue();
+ }
+
+ if (prev != null) {
+
+ if (prev.getSubscriptionSet().isEmpty()) {
+ // Subscription empty!
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public Properties getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Properties properties) {
+ this.properties = properties;
+ }
+
+ public TreeSet<SubscriptionData> getSubscriptionSet() {
+ return subscriptionSet;
+ }
+
+ public void setSubscriptionSet(TreeSet<SubscriptionData> subscriptionSet) {
+ this.subscriptionSet = subscriptionSet;
+ }
+
+ public static boolean analyzeRebalance(final TreeMap<String/* clientId */, ConsumerRunningInfo> criTable) {
+ return true;
+ }
+
+ public static String analyzeProcessQueue(final String clientId, ConsumerRunningInfo info) {
+ StringBuilder sb = new StringBuilder();
+ boolean push = false;
+ {
+ String property = info.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUME_TYPE);
+
+ if (property == null) {
+ property = ((ConsumeType) info.getProperties().get(ConsumerRunningInfo.PROP_CONSUME_TYPE)).name();
+ }
+ push = ConsumeType.valueOf(property) == ConsumeType.CONSUME_PASSIVELY;
+ }
+
+ boolean orderMsg = false;
+ {
+ String property = info.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUME_ORDERLY);
+ orderMsg = Boolean.parseBoolean(property);
+ }
+
+ if (push) {
+ Iterator<Entry<MessageQueue, ProcessQueueInfo>> it = info.getMqTable().entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<MessageQueue, ProcessQueueInfo> next = it.next();
+ MessageQueue mq = next.getKey();
+ ProcessQueueInfo pq = next.getValue();
+
+
+ if (orderMsg) {
+
+ if (!pq.isLocked()) {
+ sb.append(String.format("%s %s can't lock for a while, %dms%n", //
+ clientId, //
+ mq, //
+ System.currentTimeMillis() - pq.getLastLockTimestamp()));
+ } else {
+ if (pq.isDroped() && (pq.getTryUnlockTimes() > 0)) {
+ sb.append(String.format("%s %s unlock %d times, still failed%n", //
+ clientId, //
+ mq, //
+ pq.getTryUnlockTimes()));
+ }
+ }
+
+
+ } else {
+ long diff = System.currentTimeMillis() - pq.getLastConsumeTimestamp();
+
+ if (diff > (1000 * 60) && pq.getCachedMsgCount() > 0) {
+ sb.append(String.format("%s %s can't consume for a while, maybe blocked, %dms%n", //
+ clientId, //
+ mq, //
+ diff));
+ }
+ }
+ }
+ }
+
+ return sb.toString();
+ }
+
+ public TreeMap<MessageQueue, ProcessQueueInfo> getMqTable() {
+ return mqTable;
+ }
+
+ public void setMqTable(TreeMap<MessageQueue, ProcessQueueInfo> mqTable) {
+ this.mqTable = mqTable;
+ }
+
+ public TreeMap<String, ConsumeStatus> getStatusTable() {
+ return statusTable;
+ }
+
+ public void setStatusTable(TreeMap<String, ConsumeStatus> statusTable) {
+ this.statusTable = statusTable;
+ }
+
+ public String formatString() {
+ StringBuilder sb = new StringBuilder();
+
+ {
+ sb.append("#Consumer Properties#\n");
+ Iterator<Entry<Object, Object>> it = this.properties.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<Object, Object> next = it.next();
+ String item = String.format("%-40s: %s%n", next.getKey().toString(), next.getValue().toString());
+ sb.append(item);
+ }
+ }
+
+ {
+ sb.append("\n\n#Consumer Subscription#\n");
+
+ Iterator<SubscriptionData> it = this.subscriptionSet.iterator();
+ int i = 0;
+ while (it.hasNext()) {
+ SubscriptionData next = it.next();
+ String item = String.format("%03d Topic: %-40s ClassFilter: %-8s SubExpression: %s%n", //
+ ++i, //
+ next.getTopic(), //
+ next.isClassFilterMode(), //
+ next.getSubString());
+
+ sb.append(item);
+ }
+ }
+
+ {
+ sb.append("\n\n#Consumer Offset#\n");
+ sb.append(String.format("%-32s %-32s %-4s %-20s%n", //
+ "#Topic", //
+ "#Broker Name", //
+ "#QID", //
+ "#Consumer Offset"//
+ ));
+
+ Iterator<Entry<MessageQueue, ProcessQueueInfo>> it = this.mqTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<MessageQueue, ProcessQueueInfo> next = it.next();
+ String item = String.format("%-32s %-32s %-4d %-20d%n", //
+ next.getKey().getTopic(), //
+ next.getKey().getBrokerName(), //
+ next.getKey().getQueueId(), //
+ next.getValue().getCommitOffset());
+
+ sb.append(item);
+ }
+ }
+
+ {
+ sb.append("\n\n#Consumer MQ Detail#\n");
+ sb.append(String.format("%-32s %-32s %-4s %-20s%n", //
+ "#Topic", //
+ "#Broker Name", //
+ "#QID", //
+ "#ProcessQueueInfo"//
+ ));
+
+ Iterator<Entry<MessageQueue, ProcessQueueInfo>> it = this.mqTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<MessageQueue, ProcessQueueInfo> next = it.next();
+ String item = String.format("%-32s %-32s %-4d %s%n", //
+ next.getKey().getTopic(), //
+ next.getKey().getBrokerName(), //
+ next.getKey().getQueueId(), //
+ next.getValue().toString());
+
+ sb.append(item);
+ }
+ }
+
+ {
+ sb.append("\n\n#Consumer RT&TPS#\n");
+ sb.append(String.format("%-32s %14s %14s %14s %14s %18s %25s%n", //
+ "#Topic", //
+ "#Pull RT", //
+ "#Pull TPS", //
+ "#Consume RT", //
+ "#ConsumeOK TPS", //
+ "#ConsumeFailed TPS", //
+ "#ConsumeFailedMsgsInHour"//
+ ));
+
+ Iterator<Entry<String, ConsumeStatus>> it = this.statusTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, ConsumeStatus> next = it.next();
+ String item = String.format("%-32s %14.2f %14.2f %14.2f %14.2f %18.2f %25d%n", //
+ next.getKey(), //
+ next.getValue().getPullRT(), //
+ next.getValue().getPullTPS(), //
+ next.getValue().getConsumeRT(), //
+ next.getValue().getConsumeOKTPS(), //
+ next.getValue().getConsumeFailedTPS(), //
+ next.getValue().getConsumeFailedMsgs()//
+ );
+
+ sb.append(item);
+ }
+ }
+
+ if (this.jstack != null) {
+ sb.append("\n\n#Consumer jstack#\n");
+ sb.append(this.jstack);
+ }
+
+ return sb.toString();
+ }
+
+ public String getJstack() {
+ return jstack;
+ }
+
+
+ public void setJstack(String jstack) {
+ this.jstack = jstack;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/GetConsumerStatusBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/GetConsumerStatusBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/GetConsumerStatusBody.java
new file mode 100644
index 0000000..71d8667
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/GetConsumerStatusBody.java
@@ -0,0 +1,55 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * @author manhong.yqd
+ */
+@Deprecated
+public class GetConsumerStatusBody extends RemotingSerializable {
+ private Map<MessageQueue, Long> messageQueueTable = new HashMap<MessageQueue, Long>();
+ private Map<String, Map<MessageQueue, Long>> consumerTable =
+ new HashMap<String, Map<MessageQueue, Long>>();
+
+
+ public Map<MessageQueue, Long> getMessageQueueTable() {
+ return messageQueueTable;
+ }
+
+
+ public void setMessageQueueTable(Map<MessageQueue, Long> messageQueueTable) {
+ this.messageQueueTable = messageQueueTable;
+ }
+
+
+ public Map<String, Map<MessageQueue, Long>> getConsumerTable() {
+ return consumerTable;
+ }
+
+
+ public void setConsumerTable(Map<String, Map<MessageQueue, Long>> consumerTable) {
+ this.consumerTable = consumerTable;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java
new file mode 100644
index 0000000..db7e071
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java
@@ -0,0 +1,40 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.HashSet;
+
+
+/**
+ * @author shijia.wxr
+ *
+ */
+public class GroupList extends RemotingSerializable {
+ private HashSet<String> groupList = new HashSet<String>();
+
+
+ public HashSet<String> getGroupList() {
+ return groupList;
+ }
+
+
+ public void setGroupList(HashSet<String> groupList) {
+ this.groupList = groupList;
+ }
+}
[22/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java b/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
new file mode 100644
index 0000000..fcadd9a
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
@@ -0,0 +1,1147 @@
+/**
+ * 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.impl.factory;
+
+import org.apache.rocketmq.client.ClientConfig;
+import org.apache.rocketmq.client.admin.MQAdminExtInner;
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.impl.*;
+import org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl;
+import org.apache.rocketmq.client.impl.producer.MQProducerInner;
+import org.apache.rocketmq.client.impl.producer.TopicPublishInfo;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.client.producer.DefaultMQProducer;
+import org.apache.rocketmq.client.stat.ConsumerStatsManager;
+import org.apache.rocketmq.common.MQVersion;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.ServiceState;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.constant.PermName;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
+import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
+import org.apache.rocketmq.common.protocol.heartbeat.*;
+import org.apache.rocketmq.common.protocol.route.BrokerData;
+import org.apache.rocketmq.common.protocol.route.QueueData;
+import org.apache.rocketmq.common.protocol.route.TopicRouteData;
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+import org.apache.rocketmq.remoting.netty.NettyClientConfig;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.apache.rocketmq.client.impl.consumer.*;
+import org.slf4j.Logger;
+
+import java.io.UnsupportedEncodingException;
+import java.net.DatagramSocket;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class MQClientInstance {
+ private final static long LOCK_TIMEOUT_MILLIS = 3000;
+ private final Logger log = ClientLogger.getLog();
+ private final ClientConfig clientConfig;
+ private final int instanceIndex;
+ private final String clientId;
+ private final long bootTimestamp = System.currentTimeMillis();
+ private final ConcurrentHashMap<String/* group */, MQProducerInner> producerTable = new ConcurrentHashMap<String, MQProducerInner>();
+ private final ConcurrentHashMap<String/* group */, MQConsumerInner> consumerTable = new ConcurrentHashMap<String, MQConsumerInner>();
+ private final ConcurrentHashMap<String/* group */, MQAdminExtInner> adminExtTable = new ConcurrentHashMap<String, MQAdminExtInner>();
+ private final NettyClientConfig nettyClientConfig;
+ private final MQClientAPIImpl mQClientAPIImpl;
+ private final MQAdminImpl mQAdminImpl;
+ private final ConcurrentHashMap<String/* Topic */, TopicRouteData> topicRouteTable = new ConcurrentHashMap<String, TopicRouteData>();
+ private final Lock lockNamesrv = new ReentrantLock();
+ private final Lock lockHeartbeat = new ReentrantLock();
+ private final ConcurrentHashMap<String/* Broker Name */, HashMap<Long/* brokerId */, String/* address */>> brokerAddrTable =
+ new ConcurrentHashMap<String, HashMap<Long, String>>();
+ private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
+ @Override
+ public Thread newThread(Runnable r) {
+ return new Thread(r, "MQClientFactoryScheduledThread");
+ }
+ });
+ private final ClientRemotingProcessor clientRemotingProcessor;
+ private final PullMessageService pullMessageService;
+ private final RebalanceService rebalanceService;
+ private final DefaultMQProducer defaultMQProducer;
+ private final ConsumerStatsManager consumerStatsManager;
+ private final AtomicLong storeTimesTotal = new AtomicLong(0);
+ private ServiceState serviceState = ServiceState.CREATE_JUST;
+ private DatagramSocket datagramSocket;
+ private Random random = new Random();
+
+
+ public MQClientInstance(ClientConfig clientConfig, int instanceIndex, String clientId) {
+ this(clientConfig, instanceIndex, clientId, null);
+ }
+
+
+ public MQClientInstance(ClientConfig clientConfig, int instanceIndex, String clientId, RPCHook rpcHook) {
+ this.clientConfig = clientConfig;
+ this.instanceIndex = instanceIndex;
+ this.nettyClientConfig = new NettyClientConfig();
+ this.nettyClientConfig.setClientCallbackExecutorThreads(clientConfig.getClientCallbackExecutorThreads());
+ this.clientRemotingProcessor = new ClientRemotingProcessor(this);
+ this.mQClientAPIImpl = new MQClientAPIImpl(this.nettyClientConfig, this.clientRemotingProcessor, rpcHook, clientConfig);
+
+ if (this.clientConfig.getNamesrvAddr() != null) {
+ this.mQClientAPIImpl.updateNameServerAddressList(this.clientConfig.getNamesrvAddr());
+ log.info("user specified name server address: {}", this.clientConfig.getNamesrvAddr());
+ }
+
+ this.clientId = clientId;
+
+ this.mQAdminImpl = new MQAdminImpl(this);
+
+ this.pullMessageService = new PullMessageService(this);
+
+ this.rebalanceService = new RebalanceService(this);
+
+ this.defaultMQProducer = new DefaultMQProducer(MixAll.CLIENT_INNER_PRODUCER_GROUP);
+ this.defaultMQProducer.resetClientConfig(clientConfig);
+
+ this.consumerStatsManager = new ConsumerStatsManager(this.scheduledExecutorService);
+
+ log.info("created a new client Instance, FactoryIndex: {} ClinetID: {} {} {}, serializeType={}", //
+ this.instanceIndex, //
+ this.clientId, //
+ this.clientConfig, //
+ MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION), RemotingCommand.getSerializeTypeConfigInThisServer());
+ }
+
+ public void start() throws MQClientException {
+
+ synchronized (this) {
+ switch (this.serviceState) {
+ case CREATE_JUST:
+ this.serviceState = ServiceState.START_FAILED;
+ // If not specified,looking address from name server
+ if (null == this.clientConfig.getNamesrvAddr()) {
+ this.clientConfig.setNamesrvAddr(this.mQClientAPIImpl.fetchNameServerAddr());
+ }
+ // Start request-response channel
+ this.mQClientAPIImpl.start();
+ // Start various schedule tasks
+ this.startScheduledTask();
+ // Start pull service
+ this.pullMessageService.start();
+ // Start rebalance service
+ this.rebalanceService.start();
+ // Start push service
+ this.defaultMQProducer.getDefaultMQProducerImpl().start(false);
+ log.info("the client factory [{}] start OK", this.clientId);
+ this.serviceState = ServiceState.RUNNING;
+ break;
+ case RUNNING:
+ break;
+ case SHUTDOWN_ALREADY:
+ break;
+ case START_FAILED:
+ throw new MQClientException("The Factory object[" + this.getClientId() + "] has been created before, and failed.", null);
+ default:
+ break;
+ }
+ }
+ }
+
+
+ private void startScheduledTask() {
+ if (null == this.clientConfig.getNamesrvAddr()) {
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ MQClientInstance.this.mQClientAPIImpl.fetchNameServerAddr();
+ } catch (Exception e) {
+ log.error("ScheduledTask fetchNameServerAddr exception", e);
+ }
+ }
+ }, 1000 * 10, 1000 * 60 * 2, TimeUnit.MILLISECONDS);
+ }
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ MQClientInstance.this.updateTopicRouteInfoFromNameServer();
+ } catch (Exception e) {
+ log.error("ScheduledTask updateTopicRouteInfoFromNameServer exception", e);
+ }
+ }
+ }, 10, this.clientConfig.getPollNameServerInteval(), TimeUnit.MILLISECONDS);
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ MQClientInstance.this.cleanOfflineBroker();
+ MQClientInstance.this.sendHeartbeatToAllBrokerWithLock();
+ } catch (Exception e) {
+ log.error("ScheduledTask sendHeartbeatToAllBroker exception", e);
+ }
+ }
+ }, 1000, this.clientConfig.getHeartbeatBrokerInterval(), TimeUnit.MILLISECONDS);
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ MQClientInstance.this.persistAllConsumerOffset();
+ } catch (Exception e) {
+ log.error("ScheduledTask persistAllConsumerOffset exception", e);
+ }
+ }
+ }, 1000 * 10, this.clientConfig.getPersistConsumerOffsetInterval(), TimeUnit.MILLISECONDS);
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ MQClientInstance.this.adjustThreadPool();
+ } catch (Exception e) {
+ log.error("ScheduledTask adjustThreadPool exception", e);
+ }
+ }
+ }, 1, 1, TimeUnit.MINUTES);
+ }
+
+ public String getClientId() {
+ return clientId;
+ }
+
+ public void updateTopicRouteInfoFromNameServer() {
+ Set<String> topicList = new HashSet<String>();
+
+ // Consumer
+ {
+ Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, MQConsumerInner> entry = it.next();
+ MQConsumerInner impl = entry.getValue();
+ if (impl != null) {
+ Set<SubscriptionData> subList = impl.subscriptions();
+ if (subList != null) {
+ for (SubscriptionData subData : subList) {
+ topicList.add(subData.getTopic());
+ }
+ }
+ }
+ }
+ }
+
+ // Producer
+ {
+ Iterator<Entry<String, MQProducerInner>> it = this.producerTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, MQProducerInner> entry = it.next();
+ MQProducerInner impl = entry.getValue();
+ if (impl != null) {
+ Set<String> lst = impl.getPublishTopicList();
+ topicList.addAll(lst);
+ }
+ }
+ }
+
+ for (String topic : topicList) {
+ this.updateTopicRouteInfoFromNameServer(topic);
+ }
+ }
+
+ /**
+ * Remove offline broker
+ */
+ private void cleanOfflineBroker() {
+ try {
+ if (this.lockNamesrv.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS))
+ try {
+ ConcurrentHashMap<String, HashMap<Long, String>> updatedTable = new ConcurrentHashMap<String, HashMap<Long, String>>();
+
+ Iterator<Entry<String, HashMap<Long, String>>> itBrokerTable = this.brokerAddrTable.entrySet().iterator();
+ while (itBrokerTable.hasNext()) {
+ Entry<String, HashMap<Long, String>> entry = itBrokerTable.next();
+ String brokerName = entry.getKey();
+ HashMap<Long, String> oneTable = entry.getValue();
+
+ HashMap<Long, String> cloneAddrTable = new HashMap<Long, String>();
+ cloneAddrTable.putAll(oneTable);
+
+ Iterator<Entry<Long, String>> it = cloneAddrTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<Long, String> ee = it.next();
+ String addr = ee.getValue();
+ if (!this.isBrokerAddrExistInTopicRouteTable(addr)) {
+ it.remove();
+ log.info("the broker addr[{} {}] is offline, remove it", brokerName, addr);
+ }
+ }
+
+ if (cloneAddrTable.isEmpty()) {
+ itBrokerTable.remove();
+ log.info("the broker[{}] name's host is offline, remove it", brokerName);
+ } else {
+ updatedTable.put(brokerName, cloneAddrTable);
+ }
+ }
+
+ if (!updatedTable.isEmpty()) {
+ this.brokerAddrTable.putAll(updatedTable);
+ }
+ } finally {
+ this.lockNamesrv.unlock();
+ }
+ } catch (InterruptedException e) {
+ log.warn("cleanOfflineBroker Exception", e);
+ }
+ }
+
+ public void sendHeartbeatToAllBrokerWithLock() {
+ if (this.lockHeartbeat.tryLock()) {
+ try {
+ this.sendHeartbeatToAllBroker();
+ this.uploadFilterClassSource();
+ } catch (final Exception e) {
+ log.error("sendHeartbeatToAllBroker exception", e);
+ } finally {
+ this.lockHeartbeat.unlock();
+ }
+ } else {
+ log.warn("lock heartBeat, but failed.");
+ }
+ }
+
+ private void persistAllConsumerOffset() {
+ Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, MQConsumerInner> entry = it.next();
+ MQConsumerInner impl = entry.getValue();
+ impl.persistConsumerOffset();
+ }
+ }
+
+ public void adjustThreadPool() {
+ Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, MQConsumerInner> entry = it.next();
+ MQConsumerInner impl = entry.getValue();
+ if (impl != null) {
+ try {
+ if (impl instanceof DefaultMQPushConsumerImpl) {
+ DefaultMQPushConsumerImpl dmq = (DefaultMQPushConsumerImpl) impl;
+ dmq.adjustThreadPool();
+ }
+ } catch (Exception e) {
+ }
+ }
+ }
+ }
+
+ public boolean updateTopicRouteInfoFromNameServer(final String topic) {
+ return updateTopicRouteInfoFromNameServer(topic, false, null);
+ }
+
+ private boolean isBrokerAddrExistInTopicRouteTable(final String addr) {
+ Iterator<Entry<String, TopicRouteData>> it = this.topicRouteTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, TopicRouteData> entry = it.next();
+ TopicRouteData topicRouteData = entry.getValue();
+ List<BrokerData> bds = topicRouteData.getBrokerDatas();
+ for (BrokerData bd : bds) {
+ if (bd.getBrokerAddrs() != null) {
+ boolean exist = bd.getBrokerAddrs().containsValue(addr);
+ if (exist)
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private void sendHeartbeatToAllBroker() {
+ final HeartbeatData heartbeatData = this.prepareHeartbeatData();
+ final boolean producerEmpty = heartbeatData.getProducerDataSet().isEmpty();
+ final boolean consumerEmpty = heartbeatData.getConsumerDataSet().isEmpty();
+ if (producerEmpty && consumerEmpty) {
+ log.warn("sending hearbeat, but no consumer and no producer");
+ return;
+ }
+
+ long times = this.storeTimesTotal.getAndIncrement();
+ Iterator<Entry<String, HashMap<Long, String>>> it = this.brokerAddrTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, HashMap<Long, String>> entry = it.next();
+ String brokerName = entry.getKey();
+ HashMap<Long, String> oneTable = entry.getValue();
+ if (oneTable != null) {
+ for (Map.Entry<Long, String> entry1 : oneTable.entrySet()) {
+ Long id = entry1.getKey();
+ String addr = entry1.getValue();
+ if (addr != null) {
+ if (consumerEmpty) {
+ if (id != MixAll.MASTER_ID)
+ continue;
+ }
+
+ try {
+ this.mQClientAPIImpl.sendHearbeat(addr, heartbeatData, 3000);
+ if (times % 20 == 0) {
+ log.info("send heart beat to broker[{} {} {}] success", brokerName, id, addr);
+ log.info(heartbeatData.toString());
+ }
+ } catch (Exception e) {
+ if (this.isBrokerInNameServer(addr)) {
+ log.error("send heart beat to broker exception", e);
+ } else {
+ log.info("send heart beat to broker[{} {} {}] exception, because the broker not up, forget it", brokerName,
+ id, addr);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void uploadFilterClassSource() {
+ Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, MQConsumerInner> next = it.next();
+ MQConsumerInner consumer = next.getValue();
+ if (ConsumeType.CONSUME_PASSIVELY == consumer.consumeType()) {
+ Set<SubscriptionData> subscriptions = consumer.subscriptions();
+ for (SubscriptionData sub : subscriptions) {
+ if (sub.isClassFilterMode() && sub.getFilterClassSource() != null) {
+ final String consumerGroup = consumer.groupName();
+ final String className = sub.getSubString();
+ final String topic = sub.getTopic();
+ final String filterClassSource = sub.getFilterClassSource();
+ try {
+ this.uploadFilterClassToAllFilterServer(consumerGroup, className, topic, filterClassSource);
+ } catch (Exception e) {
+ log.error("uploadFilterClassToAllFilterServer Exception", e);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public boolean updateTopicRouteInfoFromNameServer(final String topic, boolean isDefault, DefaultMQProducer defaultMQProducer) {
+ try {
+ if (this.lockNamesrv.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
+ try {
+ TopicRouteData topicRouteData;
+ if (isDefault && defaultMQProducer != null) {
+ topicRouteData = this.mQClientAPIImpl.getDefaultTopicRouteInfoFromNameServer(defaultMQProducer.getCreateTopicKey(),
+ 1000 * 3);
+ if (topicRouteData != null) {
+ for (QueueData data : topicRouteData.getQueueDatas()) {
+ int queueNums = Math.min(defaultMQProducer.getDefaultTopicQueueNums(), data.getReadQueueNums());
+ data.setReadQueueNums(queueNums);
+ data.setWriteQueueNums(queueNums);
+ }
+ }
+ } else {
+ topicRouteData = this.mQClientAPIImpl.getTopicRouteInfoFromNameServer(topic, 1000 * 3);
+ }
+ if (topicRouteData != null) {
+ TopicRouteData old = this.topicRouteTable.get(topic);
+ boolean changed = topicRouteDataIsChange(old, topicRouteData);
+ if (!changed) {
+ changed = this.isNeedUpdateTopicRouteInfo(topic);
+ } else {
+ log.info("the topic[{}] route info changed, old[{}] ,new[{}]", topic, old, topicRouteData);
+ }
+
+ if (changed) {
+ TopicRouteData cloneTopicRouteData = topicRouteData.cloneTopicRouteData();
+
+ for (BrokerData bd : topicRouteData.getBrokerDatas()) {
+ this.brokerAddrTable.put(bd.getBrokerName(), bd.getBrokerAddrs());
+ }
+
+ // Update Pub info
+ {
+ TopicPublishInfo publishInfo = topicRouteData2TopicPublishInfo(topic, topicRouteData);
+ publishInfo.setHaveTopicRouterInfo(true);
+ Iterator<Entry<String, MQProducerInner>> it = this.producerTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, MQProducerInner> entry = it.next();
+ MQProducerInner impl = entry.getValue();
+ if (impl != null) {
+ impl.updateTopicPublishInfo(topic, publishInfo);
+ }
+ }
+ }
+
+ // Update sub info
+ {
+ Set<MessageQueue> subscribeInfo = topicRouteData2TopicSubscribeInfo(topic, topicRouteData);
+ Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, MQConsumerInner> entry = it.next();
+ MQConsumerInner impl = entry.getValue();
+ if (impl != null) {
+ impl.updateTopicSubscribeInfo(topic, subscribeInfo);
+ }
+ }
+ }
+ log.info("topicRouteTable.put TopicRouteData[{}]", cloneTopicRouteData);
+ this.topicRouteTable.put(topic, cloneTopicRouteData);
+ return true;
+ }
+ } else {
+ log.warn("updateTopicRouteInfoFromNameServer, getTopicRouteInfoFromNameServer return null, Topic: {}", topic);
+ }
+ } catch (Exception e) {
+ if (!topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX) && !topic.equals(MixAll.DEFAULT_TOPIC)) {
+ log.warn("updateTopicRouteInfoFromNameServer Exception", e);
+ }
+ } finally {
+ this.lockNamesrv.unlock();
+ }
+ } else {
+ log.warn("updateTopicRouteInfoFromNameServer tryLock timeout {}ms", LOCK_TIMEOUT_MILLIS);
+ }
+ } catch (InterruptedException e) {
+ log.warn("updateTopicRouteInfoFromNameServer Exception", e);
+ }
+
+ return false;
+ }
+
+ private HeartbeatData prepareHeartbeatData() {
+ HeartbeatData heartbeatData = new HeartbeatData();
+
+ // clientID
+ heartbeatData.setClientID(this.clientId);
+
+ // Consumer
+ for (Map.Entry<String, MQConsumerInner> entry : this.consumerTable.entrySet()) {
+ MQConsumerInner impl = entry.getValue();
+ if (impl != null) {
+ ConsumerData consumerData = new ConsumerData();
+ consumerData.setGroupName(impl.groupName());
+ consumerData.setConsumeType(impl.consumeType());
+ consumerData.setMessageModel(impl.messageModel());
+ consumerData.setConsumeFromWhere(impl.consumeFromWhere());
+ consumerData.getSubscriptionDataSet().addAll(impl.subscriptions());
+ consumerData.setUnitMode(impl.isUnitMode());
+
+ heartbeatData.getConsumerDataSet().add(consumerData);
+ }
+ }
+
+
+ // Producer
+ for (Map.Entry<String/* group */, MQProducerInner> entry : this.producerTable.entrySet()) {
+ MQProducerInner impl = entry.getValue();
+ if (impl != null) {
+ ProducerData producerData = new ProducerData();
+ producerData.setGroupName(entry.getKey());
+
+ heartbeatData.getProducerDataSet().add(producerData);
+ }
+ }
+
+ return heartbeatData;
+ }
+
+ private boolean isBrokerInNameServer(final String brokerAddr) {
+ Iterator<Entry<String, TopicRouteData>> it = this.topicRouteTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, TopicRouteData> itNext = it.next();
+ List<BrokerData> brokerDatas = itNext.getValue().getBrokerDatas();
+ for (BrokerData bd : brokerDatas) {
+ boolean contain = bd.getBrokerAddrs().containsValue(brokerAddr);
+ if (contain)
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private void uploadFilterClassToAllFilterServer(final String consumerGroup, final String fullClassName, final String topic,
+ final String filterClassSource) throws UnsupportedEncodingException {
+ byte[] classBody = null;
+ int classCRC = 0;
+ try {
+ classBody = filterClassSource.getBytes(MixAll.DEFAULT_CHARSET);
+ classCRC = UtilAll.crc32(classBody);
+ } catch (Exception e1) {
+ log.warn("uploadFilterClassToAllFilterServer Exception, ClassName: {} {}", //
+ fullClassName, //
+ RemotingHelper.exceptionSimpleDesc(e1));
+ }
+
+ TopicRouteData topicRouteData = this.topicRouteTable.get(topic);
+ if (topicRouteData != null //
+ && topicRouteData.getFilterServerTable() != null && !topicRouteData.getFilterServerTable().isEmpty()) {
+ Iterator<Entry<String, List<String>>> it = topicRouteData.getFilterServerTable().entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, List<String>> next = it.next();
+ List<String> value = next.getValue();
+ for (final String fsAddr : value) {
+ try {
+ this.mQClientAPIImpl.registerMessageFilterClass(fsAddr, consumerGroup, topic, fullClassName, classCRC, classBody,
+ 5000);
+
+ log.info("register message class filter to {} OK, ConsumerGroup: {} Topic: {} ClassName: {}", fsAddr, consumerGroup,
+ topic, fullClassName);
+
+ } catch (Exception e) {
+ log.error("uploadFilterClassToAllFilterServer Exception", e);
+ }
+ }
+ }
+ } else {
+ log.warn("register message class filter failed, because no filter server, ConsumerGroup: {} Topic: {} ClassName: {}",
+ consumerGroup, topic, fullClassName);
+ }
+ }
+
+ private boolean topicRouteDataIsChange(TopicRouteData olddata, TopicRouteData nowdata) {
+ if (olddata == null || nowdata == null)
+ return true;
+ TopicRouteData old = olddata.cloneTopicRouteData();
+ TopicRouteData now = nowdata.cloneTopicRouteData();
+ Collections.sort(old.getQueueDatas());
+ Collections.sort(old.getBrokerDatas());
+ Collections.sort(now.getQueueDatas());
+ Collections.sort(now.getBrokerDatas());
+ return !old.equals(now);
+
+ }
+
+ private boolean isNeedUpdateTopicRouteInfo(final String topic) {
+ boolean result = false;
+ {
+ Iterator<Entry<String, MQProducerInner>> it = this.producerTable.entrySet().iterator();
+ while (it.hasNext() && !result) {
+ Entry<String, MQProducerInner> entry = it.next();
+ MQProducerInner impl = entry.getValue();
+ if (impl != null) {
+ result = impl.isPublishTopicNeedUpdate(topic);
+ }
+ }
+ }
+
+ {
+ Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator();
+ while (it.hasNext() && !result) {
+ Entry<String, MQConsumerInner> entry = it.next();
+ MQConsumerInner impl = entry.getValue();
+ if (impl != null) {
+ result = impl.isSubscribeTopicNeedUpdate(topic);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public static TopicPublishInfo topicRouteData2TopicPublishInfo(final String topic, final TopicRouteData route) {
+ TopicPublishInfo info = new TopicPublishInfo();
+ info.setTopicRouteData(route);
+ if (route.getOrderTopicConf() != null && route.getOrderTopicConf().length() > 0) {
+ String[] brokers = route.getOrderTopicConf().split(";");
+ for (String broker : brokers) {
+ String[] item = broker.split(":");
+ int nums = Integer.parseInt(item[1]);
+ for (int i = 0; i < nums; i++) {
+ MessageQueue mq = new MessageQueue(topic, item[0], i);
+ info.getMessageQueueList().add(mq);
+ }
+ }
+
+ info.setOrderTopic(true);
+ } else {
+ List<QueueData> qds = route.getQueueDatas();
+ Collections.sort(qds);
+ for (QueueData qd : qds) {
+ if (PermName.isWriteable(qd.getPerm())) {
+ BrokerData brokerData = null;
+ for (BrokerData bd : route.getBrokerDatas()) {
+ if (bd.getBrokerName().equals(qd.getBrokerName())) {
+ brokerData = bd;
+ break;
+ }
+ }
+
+ if (null == brokerData) {
+ continue;
+ }
+
+ if (!brokerData.getBrokerAddrs().containsKey(MixAll.MASTER_ID)) {
+ continue;
+ }
+
+ for (int i = 0; i < qd.getWriteQueueNums(); i++) {
+ MessageQueue mq = new MessageQueue(topic, qd.getBrokerName(), i);
+ info.getMessageQueueList().add(mq);
+ }
+ }
+ }
+
+ info.setOrderTopic(false);
+ }
+
+ return info;
+ }
+
+ public static Set<MessageQueue> topicRouteData2TopicSubscribeInfo(final String topic, final TopicRouteData route) {
+ Set<MessageQueue> mqList = new HashSet<MessageQueue>();
+ List<QueueData> qds = route.getQueueDatas();
+ for (QueueData qd : qds) {
+ if (PermName.isReadable(qd.getPerm())) {
+ for (int i = 0; i < qd.getReadQueueNums(); i++) {
+ MessageQueue mq = new MessageQueue(topic, qd.getBrokerName(), i);
+ mqList.add(mq);
+ }
+ }
+ }
+
+ return mqList;
+ }
+
+ public void shutdown() {
+ // Consumer
+ if (!this.consumerTable.isEmpty())
+ return;
+
+ // AdminExt
+ if (!this.adminExtTable.isEmpty())
+ return;
+
+ // Producer
+ if (this.producerTable.size() > 1)
+ return;
+
+ synchronized (this) {
+ switch (this.serviceState) {
+ case CREATE_JUST:
+ break;
+ case RUNNING:
+ this.defaultMQProducer.getDefaultMQProducerImpl().shutdown(false);
+
+ this.serviceState = ServiceState.SHUTDOWN_ALREADY;
+ this.pullMessageService.shutdown(true);
+ this.scheduledExecutorService.shutdown();
+ this.mQClientAPIImpl.shutdown();
+ this.rebalanceService.shutdown();
+
+ if (this.datagramSocket != null) {
+ this.datagramSocket.close();
+ this.datagramSocket = null;
+ }
+ MQClientManager.getInstance().removeClientFactory(this.clientId);
+ log.info("the client factory [{}] shutdown OK", this.clientId);
+ break;
+ case SHUTDOWN_ALREADY:
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ public boolean registerConsumer(final String group, final MQConsumerInner consumer) {
+ if (null == group || null == consumer) {
+ return false;
+ }
+
+ MQConsumerInner prev = this.consumerTable.putIfAbsent(group, consumer);
+ if (prev != null) {
+ log.warn("the consumer group[" + group + "] exist already.");
+ return false;
+ }
+
+ return true;
+ }
+
+ public void unregisterConsumer(final String group) {
+ this.consumerTable.remove(group);
+ this.unregisterClientWithLock(null, group);
+ }
+
+ private void unregisterClientWithLock(final String producerGroup, final String consumerGroup) {
+ try {
+ if (this.lockHeartbeat.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
+ try {
+ this.unregisterClient(producerGroup, consumerGroup);
+ } catch (Exception e) {
+ log.error("unregisterClient exception", e);
+ } finally {
+ this.lockHeartbeat.unlock();
+ }
+ } else {
+ log.warn("lock heartBeat, but failed.");
+ }
+ } catch (InterruptedException e) {
+ log.warn("unregisterClientWithLock exception", e);
+ }
+ }
+
+ private void unregisterClient(final String producerGroup, final String consumerGroup) {
+ Iterator<Entry<String, HashMap<Long, String>>> it = this.brokerAddrTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, HashMap<Long, String>> entry = it.next();
+ String brokerName = entry.getKey();
+ HashMap<Long, String> oneTable = entry.getValue();
+
+ if (oneTable != null) {
+ for (Map.Entry<Long, String> entry1 : oneTable.entrySet()) {
+ String addr = entry1.getValue();
+ if (addr != null) {
+ try {
+ this.mQClientAPIImpl.unregisterClient(addr, this.clientId, producerGroup, consumerGroup, 3000);
+ log.info("unregister client[Producer: {} Consumer: {}] from broker[{} {} {}] success", producerGroup,
+ consumerGroup, brokerName, entry1.getKey(), addr);
+ } catch (RemotingException e) {
+ log.error("unregister client exception from broker: " + addr, e);
+ } catch (MQBrokerException e) {
+ log.error("unregister client exception from broker: " + addr, e);
+ } catch (InterruptedException e) {
+ log.error("unregister client exception from broker: " + addr, e);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public boolean registerProducer(final String group, final DefaultMQProducerImpl producer) {
+ if (null == group || null == producer) {
+ return false;
+ }
+
+ MQProducerInner prev = this.producerTable.putIfAbsent(group, producer);
+ if (prev != null) {
+ log.warn("the producer group[{}] exist already.", group);
+ return false;
+ }
+
+ return true;
+ }
+
+ public void unregisterProducer(final String group) {
+ this.producerTable.remove(group);
+ this.unregisterClientWithLock(group, null);
+ }
+
+ public boolean registerAdminExt(final String group, final MQAdminExtInner admin) {
+ if (null == group || null == admin) {
+ return false;
+ }
+
+ MQAdminExtInner prev = this.adminExtTable.putIfAbsent(group, admin);
+ if (prev != null) {
+ log.warn("the admin group[{}] exist already.", group);
+ return false;
+ }
+
+ return true;
+ }
+
+ public void unregisterAdminExt(final String group) {
+ this.adminExtTable.remove(group);
+ }
+
+ public void rebalanceImmediately() {
+ this.rebalanceService.wakeup();
+ }
+
+ public void doRebalance() {
+ for (Map.Entry<String, MQConsumerInner> entry : this.consumerTable.entrySet()) {
+ MQConsumerInner impl = entry.getValue();
+ if (impl != null) {
+ try {
+ impl.doRebalance();
+ } catch (Throwable e) {
+ log.error("doRebalance exception", e);
+ }
+ }
+ }
+ }
+
+ public MQProducerInner selectProducer(final String group) {
+ return this.producerTable.get(group);
+ }
+
+ public MQConsumerInner selectConsumer(final String group) {
+ return this.consumerTable.get(group);
+ }
+
+ public FindBrokerResult findBrokerAddressInAdmin(final String brokerName) {
+ String brokerAddr = null;
+ boolean slave = false;
+ boolean found = false;
+
+ HashMap<Long/* brokerId */, String/* address */> map = this.brokerAddrTable.get(brokerName);
+ if (map != null && !map.isEmpty()) {
+ FOR_SEG:
+ for (Map.Entry<Long, String> entry : map.entrySet()) {
+ Long id = entry.getKey();
+ brokerAddr = entry.getValue();
+ if (brokerAddr != null) {
+ found = true;
+ if (MixAll.MASTER_ID == id) {
+ slave = false;
+ break FOR_SEG;
+ } else {
+ slave = true;
+ }
+ break;
+
+ }
+ } // end of for
+ }
+
+ if (found) {
+ return new FindBrokerResult(brokerAddr, slave);
+ }
+
+ return null;
+ }
+
+ public String findBrokerAddressInPublish(final String brokerName) {
+ HashMap<Long/* brokerId */, String/* address */> map = this.brokerAddrTable.get(brokerName);
+ if (map != null && !map.isEmpty()) {
+ return map.get(MixAll.MASTER_ID);
+ }
+
+ return null;
+ }
+
+ public FindBrokerResult findBrokerAddressInSubscribe(//
+ final String brokerName, //
+ final long brokerId, //
+ final boolean onlyThisBroker//
+ ) {
+ String brokerAddr = null;
+ boolean slave = false;
+ boolean found = false;
+
+ HashMap<Long/* brokerId */, String/* address */> map = this.brokerAddrTable.get(brokerName);
+ if (map != null && !map.isEmpty()) {
+ brokerAddr = map.get(brokerId);
+ slave = brokerId != MixAll.MASTER_ID;
+ found = brokerAddr != null;
+
+ if (!found && !onlyThisBroker) {
+ Entry<Long, String> entry = map.entrySet().iterator().next();
+ brokerAddr = entry.getValue();
+ slave = entry.getKey() != MixAll.MASTER_ID;
+ found = true;
+ }
+ }
+
+ if (found) {
+ return new FindBrokerResult(brokerAddr, slave);
+ }
+
+ return null;
+ }
+
+ public List<String> findConsumerIdList(final String topic, final String group) {
+ String brokerAddr = this.findBrokerAddrByTopic(topic);
+ if (null == brokerAddr) {
+ this.updateTopicRouteInfoFromNameServer(topic);
+ brokerAddr = this.findBrokerAddrByTopic(topic);
+ }
+
+ if (null != brokerAddr) {
+ try {
+ return this.mQClientAPIImpl.getConsumerIdListByGroup(brokerAddr, group, 3000);
+ } catch (Exception e) {
+ log.warn("getConsumerIdListByGroup exception, " + brokerAddr + " " + group, e);
+ }
+ }
+
+ return null;
+ }
+
+ public String findBrokerAddrByTopic(final String topic) {
+ TopicRouteData topicRouteData = this.topicRouteTable.get(topic);
+ if (topicRouteData != null) {
+ List<BrokerData> brokers = topicRouteData.getBrokerDatas();
+ if (!brokers.isEmpty()) {
+ int index = random.nextInt(brokers.size());
+ BrokerData bd = brokers.get(index % brokers.size());
+ return bd.selectBrokerAddr();
+ }
+ }
+
+ return null;
+ }
+
+ public void resetOffset(String topic, String group, Map<MessageQueue, Long> offsetTable) {
+ DefaultMQPushConsumerImpl consumer = null;
+ try {
+ MQConsumerInner impl = this.consumerTable.get(group);
+ if (impl != null && impl instanceof DefaultMQPushConsumerImpl) {
+ consumer = (DefaultMQPushConsumerImpl) impl;
+ } else {
+ log.info("[reset-offset] consumer dose not exist. group={}", group);
+ return;
+ }
+ consumer.suspend();
+
+ ConcurrentHashMap<MessageQueue, ProcessQueue> processQueueTable = consumer.getRebalanceImpl().getProcessQueueTable();
+ for (Map.Entry<MessageQueue, ProcessQueue> entry : processQueueTable.entrySet()) {
+ MessageQueue mq = entry.getKey();
+ if (topic.equals(mq.getTopic()) && offsetTable.containsKey(mq)) {
+ ProcessQueue pq = entry.getValue();
+ pq.setDropped(true);
+ pq.clear();
+ }
+ }
+
+ try {
+ TimeUnit.SECONDS.sleep(10);
+ } catch (InterruptedException e) {
+ //
+ }
+
+ Iterator<MessageQueue> iterator = processQueueTable.keySet().iterator();
+ while (iterator.hasNext()) {
+ MessageQueue mq = iterator.next();
+ Long offset = offsetTable.get(mq);
+ if (topic.equals(mq.getTopic()) && offset != null) {
+ try {
+ consumer.updateConsumeOffset(mq, offset);
+ consumer.getRebalanceImpl().removeUnnecessaryMessageQueue(mq, processQueueTable.get(mq));
+ iterator.remove();
+ } catch (Exception e) {
+ log.warn("reset offset failed. group={}, {}", group, mq, e);
+ }
+ }
+ }
+ } finally {
+ consumer.resume();
+ }
+ }
+
+ public Map<MessageQueue, Long> getConsumerStatus(String topic, String group) {
+ MQConsumerInner impl = this.consumerTable.get(group);
+ if (impl != null && impl instanceof DefaultMQPushConsumerImpl) {
+ DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) impl;
+ return consumer.getOffsetStore().cloneOffsetTable(topic);
+ } else if (impl != null && impl instanceof DefaultMQPullConsumerImpl) {
+ DefaultMQPullConsumerImpl consumer = (DefaultMQPullConsumerImpl) impl;
+ return consumer.getOffsetStore().cloneOffsetTable(topic);
+ } else {
+ return Collections.EMPTY_MAP;
+ }
+ }
+
+ public TopicRouteData getAnExistTopicRouteData(final String topic) {
+ return this.topicRouteTable.get(topic);
+ }
+
+ public MQClientAPIImpl getMQClientAPIImpl() {
+ return mQClientAPIImpl;
+ }
+
+ public MQAdminImpl getMQAdminImpl() {
+ return mQAdminImpl;
+ }
+
+ public long getBootTimestamp() {
+ return bootTimestamp;
+ }
+
+ public ScheduledExecutorService getScheduledExecutorService() {
+ return scheduledExecutorService;
+ }
+
+ public PullMessageService getPullMessageService() {
+ return pullMessageService;
+ }
+
+ public DefaultMQProducer getDefaultMQProducer() {
+ return defaultMQProducer;
+ }
+
+ public ConcurrentHashMap<String, TopicRouteData> getTopicRouteTable() {
+ return topicRouteTable;
+ }
+
+ public ConsumeMessageDirectlyResult consumeMessageDirectly(final MessageExt msg, //
+ final String consumerGroup, //
+ final String brokerName) {
+ MQConsumerInner mqConsumerInner = this.consumerTable.get(consumerGroup);
+ if (null != mqConsumerInner) {
+ DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) mqConsumerInner;
+
+ ConsumeMessageDirectlyResult result = consumer.getConsumeMessageService().consumeMessageDirectly(msg, brokerName);
+ return result;
+ }
+
+ return null;
+ }
+
+
+ public ConsumerRunningInfo consumerRunningInfo(final String consumerGroup) {
+ MQConsumerInner mqConsumerInner = this.consumerTable.get(consumerGroup);
+
+ ConsumerRunningInfo consumerRunningInfo = mqConsumerInner.consumerRunningInfo();
+
+ List<String> nsList = this.mQClientAPIImpl.getRemotingClient().getNameServerAddressList();
+
+ StringBuffer strBuffer = new StringBuffer();
+ if (nsList != null) {
+ for (String addr : nsList) {
+ strBuffer.append(addr + ";");
+ }
+ }
+
+ String nsAddr = strBuffer.toString();
+ consumerRunningInfo.getProperties().put(ConsumerRunningInfo.PROP_NAMESERVER_ADDR, nsAddr);
+ consumerRunningInfo.getProperties().put(ConsumerRunningInfo.PROP_CONSUME_TYPE, mqConsumerInner.consumeType().name());
+ consumerRunningInfo.getProperties().put(ConsumerRunningInfo.PROP_CLIENT_VERSION,
+ MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION));
+
+ return consumerRunningInfo;
+ }
+
+
+ public ConsumerStatsManager getConsumerStatsManager() {
+ return consumerStatsManager;
+ }
+
+ public NettyClientConfig getNettyClientConfig() {
+ return nettyClientConfig;
+ }
+}
[37/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
deleted file mode 100644
index 9df2be3..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/**
- * 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.client.consumer.store;
-
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.impl.FindBrokerResult;
-import com.alibaba.rocketmq.client.impl.factory.MQClientInstance;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.header.QueryConsumerOffsetRequestHeader;
-import com.alibaba.rocketmq.common.protocol.header.UpdateConsumerOffsetRequestHeader;
-import com.alibaba.rocketmq.remoting.exception.RemotingException;
-import org.slf4j.Logger;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
-
-
-/**
- * Remote storage implementation
- *
- * @author shijia.wxr
- */
-public class RemoteBrokerOffsetStore implements OffsetStore {
- private final static Logger log = ClientLogger.getLog();
- private final MQClientInstance mQClientFactory;
- private final String groupName;
- private ConcurrentHashMap<MessageQueue, AtomicLong> offsetTable =
- new ConcurrentHashMap<MessageQueue, AtomicLong>();
-
-
- public RemoteBrokerOffsetStore(MQClientInstance mQClientFactory, String groupName) {
- this.mQClientFactory = mQClientFactory;
- this.groupName = groupName;
- }
-
-
- @Override
- public void load() {
- }
-
-
- @Override
- public void updateOffset(MessageQueue mq, long offset, boolean increaseOnly) {
- if (mq != null) {
- AtomicLong offsetOld = this.offsetTable.get(mq);
- if (null == offsetOld) {
- offsetOld = this.offsetTable.putIfAbsent(mq, new AtomicLong(offset));
- }
-
- if (null != offsetOld) {
- if (increaseOnly) {
- MixAll.compareAndIncreaseOnly(offsetOld, offset);
- } else {
- offsetOld.set(offset);
- }
- }
- }
- }
-
-
- @Override
- public long readOffset(final MessageQueue mq, final ReadOffsetType type) {
- if (mq != null) {
- switch (type) {
- case MEMORY_FIRST_THEN_STORE:
- case READ_FROM_MEMORY: {
- AtomicLong offset = this.offsetTable.get(mq);
- if (offset != null) {
- return offset.get();
- } else if (ReadOffsetType.READ_FROM_MEMORY == type) {
- return -1;
- }
- }
- case READ_FROM_STORE: {
- try {
- long brokerOffset = this.fetchConsumeOffsetFromBroker(mq);
- AtomicLong offset = new AtomicLong(brokerOffset);
- this.updateOffset(mq, offset.get(), false);
- return brokerOffset;
- }
- // No offset in broker
- catch (MQBrokerException e) {
- return -1;
- }
- //Other exceptions
- catch (Exception e) {
- log.warn("fetchConsumeOffsetFromBroker exception, " + mq, e);
- return -2;
- }
- }
- default:
- break;
- }
- }
-
- return -1;
- }
-
-
- @Override
- public void persistAll(Set<MessageQueue> mqs) {
- if (null == mqs || mqs.isEmpty())
- return;
-
- final HashSet<MessageQueue> unusedMQ = new HashSet<MessageQueue>();
- if (mqs != null && !mqs.isEmpty()) {
- for (Map.Entry<MessageQueue, AtomicLong> entry : this.offsetTable.entrySet()) {
- MessageQueue mq = entry.getKey();
- AtomicLong offset = entry.getValue();
- if (offset != null) {
- if (mqs.contains(mq)) {
- try {
- this.updateConsumeOffsetToBroker(mq, offset.get());
- log.info("[persistAll] Group: {} ClientId: {} updateConsumeOffsetToBroker {} {}",
- this.groupName,
- this.mQClientFactory.getClientId(),
- mq,
- offset.get());
- } catch (Exception e) {
- log.error("updateConsumeOffsetToBroker exception, " + mq.toString(), e);
- }
- } else {
- unusedMQ.add(mq);
- }
- }
- }
- }
-
- if (!unusedMQ.isEmpty()) {
- for (MessageQueue mq : unusedMQ) {
- this.offsetTable.remove(mq);
- log.info("remove unused mq, {}, {}", mq, this.groupName);
- }
- }
- }
-
-
- @Override
- public void persist(MessageQueue mq) {
- AtomicLong offset = this.offsetTable.get(mq);
- if (offset != null) {
- try {
- this.updateConsumeOffsetToBroker(mq, offset.get());
- log.info("[persist] Group: {} ClientId: {} updateConsumeOffsetToBroker {} {}",
- this.groupName,
- this.mQClientFactory.getClientId(),
- mq,
- offset.get());
- } catch (Exception e) {
- log.error("updateConsumeOffsetToBroker exception, " + mq.toString(), e);
- }
- }
- }
-
- public void removeOffset(MessageQueue mq) {
- if (mq != null) {
- this.offsetTable.remove(mq);
- log.info("remove unnecessary messageQueue offset. group={}, mq={}, offsetTableSize={}", this.groupName, mq,
- offsetTable.size());
- }
- }
-
- @Override
- public Map<MessageQueue, Long> cloneOffsetTable(String topic) {
- Map<MessageQueue, Long> cloneOffsetTable = new HashMap<MessageQueue, Long>();
- for (Map.Entry<MessageQueue, AtomicLong> entry : this.offsetTable.entrySet()) {
- MessageQueue mq = entry.getKey();
- if (!UtilAll.isBlank(topic) && !topic.equals(mq.getTopic())) {
- continue;
- }
- cloneOffsetTable.put(mq, entry.getValue().get());
- }
- return cloneOffsetTable;
- }
-
- /**
- * Update the Consumer Offset in one way, once the Master is off, updated to Slave,
- * here need to be optimized.
- */
- private void updateConsumeOffsetToBroker(MessageQueue mq, long offset) throws RemotingException,
- MQBrokerException, InterruptedException, MQClientException {
- updateConsumeOffsetToBroker(mq, offset, true);
- }
-
- /**
- * Update the Consumer Offset synchronously, once the Master is off, updated to Slave,
- * here need to be optimized.
- */
- @Override
- public void updateConsumeOffsetToBroker(MessageQueue mq, long offset, boolean isOneway) throws RemotingException,
- MQBrokerException, InterruptedException, MQClientException {
- FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInAdmin(mq.getBrokerName());
- if (null == findBrokerResult) {
- // TODO Here may be heavily overhead for Name Server,need tuning
- this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
- findBrokerResult = this.mQClientFactory.findBrokerAddressInAdmin(mq.getBrokerName());
- }
-
- if (findBrokerResult != null) {
- UpdateConsumerOffsetRequestHeader requestHeader = new UpdateConsumerOffsetRequestHeader();
- requestHeader.setTopic(mq.getTopic());
- requestHeader.setConsumerGroup(this.groupName);
- requestHeader.setQueueId(mq.getQueueId());
- requestHeader.setCommitOffset(offset);
-
- if (isOneway) {
- this.mQClientFactory.getMQClientAPIImpl().updateConsumerOffsetOneway(
- findBrokerResult.getBrokerAddr(), requestHeader, 1000 * 5);
- } else {
- this.mQClientFactory.getMQClientAPIImpl().updateConsumerOffset(
- findBrokerResult.getBrokerAddr(), requestHeader, 1000 * 5);
- }
- } else {
- throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
- }
- }
-
- private long fetchConsumeOffsetFromBroker(MessageQueue mq) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException {
- FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInAdmin(mq.getBrokerName());
- if (null == findBrokerResult) {
- // TODO Here may be heavily overhead for Name Server,need tuning
- this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
- findBrokerResult = this.mQClientFactory.findBrokerAddressInAdmin(mq.getBrokerName());
- }
-
- if (findBrokerResult != null) {
- QueryConsumerOffsetRequestHeader requestHeader = new QueryConsumerOffsetRequestHeader();
- requestHeader.setTopic(mq.getTopic());
- requestHeader.setConsumerGroup(this.groupName);
- requestHeader.setQueueId(mq.getQueueId());
-
- return this.mQClientFactory.getMQClientAPIImpl().queryConsumerOffset(
- findBrokerResult.getBrokerAddr(), requestHeader, 1000 * 5);
- } else {
- throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/exception/MQBrokerException.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/exception/MQBrokerException.java b/client/src/main/java/com/alibaba/rocketmq/client/exception/MQBrokerException.java
deleted file mode 100644
index 7fc09f8..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/exception/MQBrokerException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * 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.client.exception;
-
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.help.FAQUrl;
-
-
-/**
- * @author shijia.wxr
- */
-public class MQBrokerException extends Exception {
- private static final long serialVersionUID = 5975020272601250368L;
- private final int responseCode;
- private final String errorMessage;
-
-
- public MQBrokerException(int responseCode, String errorMessage) {
- super(FAQUrl.attachDefaultURL("CODE: " + UtilAll.responseCode2String(responseCode) + " DESC: "
- + errorMessage));
- this.responseCode = responseCode;
- this.errorMessage = errorMessage;
- }
-
-
- public int getResponseCode() {
- return responseCode;
- }
-
-
- public String getErrorMessage() {
- return errorMessage;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/exception/MQClientException.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/exception/MQClientException.java b/client/src/main/java/com/alibaba/rocketmq/client/exception/MQClientException.java
deleted file mode 100644
index f343a67..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/exception/MQClientException.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * 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.client.exception;
-
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.help.FAQUrl;
-
-
-/**
- * @author shijia.wxr
- */
-public class MQClientException extends Exception {
- private static final long serialVersionUID = -5758410930844185841L;
- private int responseCode;
- private String errorMessage;
-
-
- public MQClientException(String errorMessage, Throwable cause) {
- super(FAQUrl.attachDefaultURL(errorMessage), cause);
- this.responseCode = -1;
- this.errorMessage = errorMessage;
- }
-
-
- public MQClientException(int responseCode, String errorMessage) {
- super(FAQUrl.attachDefaultURL("CODE: " + UtilAll.responseCode2String(responseCode) + " DESC: "
- + errorMessage));
- this.responseCode = responseCode;
- this.errorMessage = errorMessage;
- }
-
- public int getResponseCode() {
- return responseCode;
- }
-
- public MQClientException setResponseCode(final int responseCode) {
- this.responseCode = responseCode;
- return this;
- }
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
- public void setErrorMessage(final String errorMessage) {
- this.errorMessage = errorMessage;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/hook/CheckForbiddenContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/hook/CheckForbiddenContext.java b/client/src/main/java/com/alibaba/rocketmq/client/hook/CheckForbiddenContext.java
deleted file mode 100644
index 6291803..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/hook/CheckForbiddenContext.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- * 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.client.hook;
-
-import com.alibaba.rocketmq.client.impl.CommunicationMode;
-import com.alibaba.rocketmq.client.producer.SendResult;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-
-/**
- * @author manhong.yqd
- */
-public class CheckForbiddenContext {
- private String nameSrvAddr;
- private String group;
- private Message message;
- private MessageQueue mq;
- private String brokerAddr;
- private CommunicationMode communicationMode;
- private SendResult sendResult;
- private Exception exception;
- private Object arg;
- private boolean unitMode = false;
-
-
- public String getGroup() {
- return group;
- }
-
-
- public void setGroup(String group) {
- this.group = group;
- }
-
-
- public Message getMessage() {
- return message;
- }
-
-
- public void setMessage(Message message) {
- this.message = message;
- }
-
-
- public MessageQueue getMq() {
- return mq;
- }
-
-
- public void setMq(MessageQueue mq) {
- this.mq = mq;
- }
-
-
- public String getBrokerAddr() {
- return brokerAddr;
- }
-
-
- public void setBrokerAddr(String brokerAddr) {
- this.brokerAddr = brokerAddr;
- }
-
-
- public CommunicationMode getCommunicationMode() {
- return communicationMode;
- }
-
-
- public void setCommunicationMode(CommunicationMode communicationMode) {
- this.communicationMode = communicationMode;
- }
-
-
- public SendResult getSendResult() {
- return sendResult;
- }
-
-
- public void setSendResult(SendResult sendResult) {
- this.sendResult = sendResult;
- }
-
-
- public Exception getException() {
- return exception;
- }
-
-
- public void setException(Exception exception) {
- this.exception = exception;
- }
-
-
- public Object getArg() {
- return arg;
- }
-
-
- public void setArg(Object arg) {
- this.arg = arg;
- }
-
-
- public boolean isUnitMode() {
- return unitMode;
- }
-
-
- public void setUnitMode(boolean isUnitMode) {
- this.unitMode = isUnitMode;
- }
-
-
- public String getNameSrvAddr() {
- return nameSrvAddr;
- }
-
-
- public void setNameSrvAddr(String nameSrvAddr) {
- this.nameSrvAddr = nameSrvAddr;
- }
-
-
- @Override
- public String toString() {
- return "SendMessageContext [nameSrvAddr=" + nameSrvAddr + ", group=" + group + ", message=" + message
- + ", mq=" + mq + ", brokerAddr=" + brokerAddr + ", communicationMode=" + communicationMode
- + ", sendResult=" + sendResult + ", exception=" + exception + ", unitMode=" + unitMode
- + ", arg=" + arg + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/hook/CheckForbiddenHook.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/hook/CheckForbiddenHook.java b/client/src/main/java/com/alibaba/rocketmq/client/hook/CheckForbiddenHook.java
deleted file mode 100644
index 35a2740..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/hook/CheckForbiddenHook.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * 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.client.hook;
-
-import com.alibaba.rocketmq.client.exception.MQClientException;
-
-
-/**
- * @author manhong.yqd
- */
-public interface CheckForbiddenHook {
- public String hookName();
-
-
- public void checkForbidden(final CheckForbiddenContext context) throws MQClientException;
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/hook/ConsumeMessageContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/hook/ConsumeMessageContext.java b/client/src/main/java/com/alibaba/rocketmq/client/hook/ConsumeMessageContext.java
deleted file mode 100644
index 0c0e7cd..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/hook/ConsumeMessageContext.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * 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.client.hook;
-
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-import java.util.List;
-import java.util.Map;
-
-
-public class ConsumeMessageContext {
- private String consumerGroup;
- private List<MessageExt> msgList;
- private MessageQueue mq;
- private boolean success;
- private String status;
- private Object mqTraceContext;
- private Map<String, String> props;
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
-
- public List<MessageExt> getMsgList() {
- return msgList;
- }
-
-
- public void setMsgList(List<MessageExt> msgList) {
- this.msgList = msgList;
- }
-
-
- public MessageQueue getMq() {
- return mq;
- }
-
-
- public void setMq(MessageQueue mq) {
- this.mq = mq;
- }
-
-
- public boolean isSuccess() {
- return success;
- }
-
-
- public void setSuccess(boolean success) {
- this.success = success;
- }
-
-
- public Object getMqTraceContext() {
- return mqTraceContext;
- }
-
-
- public void setMqTraceContext(Object mqTraceContext) {
- this.mqTraceContext = mqTraceContext;
- }
-
-
- public Map<String, String> getProps() {
- return props;
- }
-
-
- public void setProps(Map<String, String> props) {
- this.props = props;
- }
-
-
- public String getStatus() {
- return status;
- }
-
-
- public void setStatus(String status) {
- this.status = status;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/hook/ConsumeMessageHook.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/hook/ConsumeMessageHook.java b/client/src/main/java/com/alibaba/rocketmq/client/hook/ConsumeMessageHook.java
deleted file mode 100644
index 96b0e53..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/hook/ConsumeMessageHook.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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.client.hook;
-
-public interface ConsumeMessageHook {
- String hookName();
-
- void consumeMessageBefore(final ConsumeMessageContext context);
-
- void consumeMessageAfter(final ConsumeMessageContext context);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/hook/FilterMessageContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/hook/FilterMessageContext.java b/client/src/main/java/com/alibaba/rocketmq/client/hook/FilterMessageContext.java
deleted file mode 100644
index c47f09e..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/hook/FilterMessageContext.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * 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.client.hook;
-
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-import java.util.List;
-
-
-/**
- * @author manhong.yqd
- */
-public class FilterMessageContext {
- private String consumerGroup;
- private List<MessageExt> msgList;
- private MessageQueue mq;
- private Object arg;
- private boolean unitMode;
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
-
- public List<MessageExt> getMsgList() {
- return msgList;
- }
-
-
- public void setMsgList(List<MessageExt> msgList) {
- this.msgList = msgList;
- }
-
-
- public MessageQueue getMq() {
- return mq;
- }
-
-
- public void setMq(MessageQueue mq) {
- this.mq = mq;
- }
-
-
- public Object getArg() {
- return arg;
- }
-
-
- public void setArg(Object arg) {
- this.arg = arg;
- }
-
-
- public boolean isUnitMode() {
- return unitMode;
- }
-
-
- public void setUnitMode(boolean isUnitMode) {
- this.unitMode = isUnitMode;
- }
-
-
- @Override
- public String toString() {
- return "ConsumeMessageContext [consumerGroup=" + consumerGroup + ", msgList=" + msgList + ", mq="
- + mq + ", arg=" + arg + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/hook/FilterMessageHook.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/hook/FilterMessageHook.java b/client/src/main/java/com/alibaba/rocketmq/client/hook/FilterMessageHook.java
deleted file mode 100644
index 1528ef9..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/hook/FilterMessageHook.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * 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.client.hook;
-
-/**
- * @author manhong.yqd
- */
-public interface FilterMessageHook {
- public String hookName();
-
-
- public void filterMessage(final FilterMessageContext context);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/hook/SendMessageContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/hook/SendMessageContext.java b/client/src/main/java/com/alibaba/rocketmq/client/hook/SendMessageContext.java
deleted file mode 100644
index 9552456..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/hook/SendMessageContext.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
- * 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.client.hook;
-
-import com.alibaba.rocketmq.client.impl.CommunicationMode;
-import com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl;
-import com.alibaba.rocketmq.client.producer.SendResult;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.message.MessageType;
-
-import java.util.Map;
-
-
-public class SendMessageContext {
- private String producerGroup;
- private Message message;
- private MessageQueue mq;
- private String brokerAddr;
- private String bornHost;
- private CommunicationMode communicationMode;
- private SendResult sendResult;
- private Exception exception;
- private Object mqTraceContext;
- private Map<String, String> props;
- private DefaultMQProducerImpl producer;
- private MessageType msgType = MessageType.Normal_Msg;
-
- public MessageType getMsgType() {
- return msgType;
- }
-
- public void setMsgType(final MessageType msgType) {
- this.msgType = msgType;
- }
-
- public DefaultMQProducerImpl getProducer() {
- return producer;
- }
-
- public void setProducer(final DefaultMQProducerImpl producer) {
- this.producer = producer;
- }
-
- public String getProducerGroup() {
- return producerGroup;
- }
-
-
- public void setProducerGroup(String producerGroup) {
- this.producerGroup = producerGroup;
- }
-
-
- public Message getMessage() {
- return message;
- }
-
-
- public void setMessage(Message message) {
- this.message = message;
- }
-
-
- public MessageQueue getMq() {
- return mq;
- }
-
-
- public void setMq(MessageQueue mq) {
- this.mq = mq;
- }
-
-
- public String getBrokerAddr() {
- return brokerAddr;
- }
-
-
- public void setBrokerAddr(String brokerAddr) {
- this.brokerAddr = brokerAddr;
- }
-
-
- public CommunicationMode getCommunicationMode() {
- return communicationMode;
- }
-
-
- public void setCommunicationMode(CommunicationMode communicationMode) {
- this.communicationMode = communicationMode;
- }
-
-
- public SendResult getSendResult() {
- return sendResult;
- }
-
-
- public void setSendResult(SendResult sendResult) {
- this.sendResult = sendResult;
- }
-
-
- public Exception getException() {
- return exception;
- }
-
-
- public void setException(Exception exception) {
- this.exception = exception;
- }
-
-
- public Object getMqTraceContext() {
- return mqTraceContext;
- }
-
-
- public void setMqTraceContext(Object mqTraceContext) {
- this.mqTraceContext = mqTraceContext;
- }
-
-
- public Map<String, String> getProps() {
- return props;
- }
-
-
- public void setProps(Map<String, String> props) {
- this.props = props;
- }
-
-
- public String getBornHost() {
- return bornHost;
- }
-
-
- public void setBornHost(String bornHost) {
- this.bornHost = bornHost;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/hook/SendMessageHook.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/hook/SendMessageHook.java b/client/src/main/java/com/alibaba/rocketmq/client/hook/SendMessageHook.java
deleted file mode 100644
index 22e1fb3..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/hook/SendMessageHook.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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.client.hook;
-
-public interface SendMessageHook {
- String hookName();
-
- void sendMessageBefore(final SendMessageContext context);
-
- void sendMessageAfter(final SendMessageContext context);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/ClientRemotingProcessor.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/ClientRemotingProcessor.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/ClientRemotingProcessor.java
deleted file mode 100644
index 79a539e..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/ClientRemotingProcessor.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/**
- * 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.client.impl;
-
-import com.alibaba.rocketmq.client.impl.factory.MQClientInstance;
-import com.alibaba.rocketmq.client.impl.producer.MQProducerInner;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.message.MessageConst;
-import com.alibaba.rocketmq.common.message.MessageDecoder;
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.RequestCode;
-import com.alibaba.rocketmq.common.protocol.ResponseCode;
-import com.alibaba.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
-import com.alibaba.rocketmq.common.protocol.body.ConsumerRunningInfo;
-import com.alibaba.rocketmq.common.protocol.body.GetConsumerStatusBody;
-import com.alibaba.rocketmq.common.protocol.body.ResetOffsetBody;
-import com.alibaba.rocketmq.common.protocol.header.*;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-import com.alibaba.rocketmq.remoting.netty.NettyRequestProcessor;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import io.netty.channel.ChannelHandlerContext;
-import org.slf4j.Logger;
-
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * @author shijia.wxr
- */
-public class ClientRemotingProcessor implements NettyRequestProcessor {
- private final Logger log = ClientLogger.getLog();
- private final MQClientInstance mqClientFactory;
-
-
- public ClientRemotingProcessor(final MQClientInstance mqClientFactory) {
- this.mqClientFactory = mqClientFactory;
- }
-
-
- @Override
- public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- switch (request.getCode()) {
- case RequestCode.CHECK_TRANSACTION_STATE:
- return this.checkTransactionState(ctx, request);
- case RequestCode.NOTIFY_CONSUMER_IDS_CHANGED:
- return this.notifyConsumerIdsChanged(ctx, request);
- case RequestCode.RESET_CONSUMER_CLIENT_OFFSET:
- return this.resetOffset(ctx, request);
- case RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT:
- return this.getConsumeStatus(ctx, request);
-
- case RequestCode.GET_CONSUMER_RUNNING_INFO:
- return this.getConsumerRunningInfo(ctx, request);
-
- case RequestCode.CONSUME_MESSAGE_DIRECTLY:
- return this.consumeMessageDirectly(ctx, request);
- default:
- break;
- }
- return null;
- }
-
- @Override
- public boolean rejectRequest() {
- return false;
- }
-
- public RemotingCommand checkTransactionState(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final CheckTransactionStateRequestHeader requestHeader =
- (CheckTransactionStateRequestHeader) request.decodeCommandCustomHeader(CheckTransactionStateRequestHeader.class);
- final ByteBuffer byteBuffer = ByteBuffer.wrap(request.getBody());
- final MessageExt messageExt = MessageDecoder.decode(byteBuffer);
- if (messageExt != null) {
- final String group = messageExt.getProperty(MessageConst.PROPERTY_PRODUCER_GROUP);
- if (group != null) {
- MQProducerInner producer = this.mqClientFactory.selectProducer(group);
- if (producer != null) {
- final String addr = RemotingHelper.parseChannelRemoteAddr(ctx.channel());
- producer.checkTransactionState(addr, messageExt, requestHeader);
- } else {
- log.debug("checkTransactionState, pick producer by group[{}] failed", group);
- }
- } else {
- log.warn("checkTransactionState, pick producer group failed");
- }
- } else {
- log.warn("checkTransactionState, decode message failed");
- }
-
- return null;
- }
-
- public RemotingCommand notifyConsumerIdsChanged(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- try {
- final NotifyConsumerIdsChangedRequestHeader requestHeader =
- (NotifyConsumerIdsChangedRequestHeader) request.decodeCommandCustomHeader(NotifyConsumerIdsChangedRequestHeader.class);
- log.info("receive broker's notification[{}], the consumer group: {} changed, rebalance immediately",
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
- requestHeader.getConsumerGroup());
- this.mqClientFactory.rebalanceImmediately();
- } catch (Exception e) {
- log.error("notifyConsumerIdsChanged exception", RemotingHelper.exceptionSimpleDesc(e));
- }
- return null;
- }
-
- public RemotingCommand resetOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final ResetOffsetRequestHeader requestHeader =
- (ResetOffsetRequestHeader) request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
- log.info("invoke reset offset operation from broker. brokerAddr={}, topic={}, group={}, timestamp={}",
- new Object[]{RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
- requestHeader.getTimestamp()});
- Map<MessageQueue, Long> offsetTable = new HashMap<MessageQueue, Long>();
- if (request.getBody() != null) {
- ResetOffsetBody body = ResetOffsetBody.decode(request.getBody(), ResetOffsetBody.class);
- offsetTable = body.getOffsetTable();
- }
- this.mqClientFactory.resetOffset(requestHeader.getTopic(), requestHeader.getGroup(), offsetTable);
- return null;
- }
-
- @Deprecated
- public RemotingCommand getConsumeStatus(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- final GetConsumerStatusRequestHeader requestHeader =
- (GetConsumerStatusRequestHeader) request.decodeCommandCustomHeader(GetConsumerStatusRequestHeader.class);
-
- Map<MessageQueue, Long> offsetTable = this.mqClientFactory.getConsumerStatus(requestHeader.getTopic(), requestHeader.getGroup());
- GetConsumerStatusBody body = new GetConsumerStatusBody();
- body.setMessageQueueTable(offsetTable);
- response.setBody(body.encode());
- response.setCode(ResponseCode.SUCCESS);
- return response;
- }
-
- private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- final GetConsumerRunningInfoRequestHeader requestHeader =
- (GetConsumerRunningInfoRequestHeader) request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);
-
- ConsumerRunningInfo consumerRunningInfo = this.mqClientFactory.consumerRunningInfo(requestHeader.getConsumerGroup());
- if (null != consumerRunningInfo) {
- if (requestHeader.isJstackEnable()) {
- Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces();
- String jstack = UtilAll.jstack(map);
- consumerRunningInfo.setJstack(jstack);
- }
-
- response.setCode(ResponseCode.SUCCESS);
- response.setBody(consumerRunningInfo.encode());
- } else {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark(String.format("The Consumer Group <%s> not exist in this consumer", requestHeader.getConsumerGroup()));
- }
-
- return response;
- }
-
- private RemotingCommand consumeMessageDirectly(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- final ConsumeMessageDirectlyResultRequestHeader requestHeader =
- (ConsumeMessageDirectlyResultRequestHeader) request
- .decodeCommandCustomHeader(ConsumeMessageDirectlyResultRequestHeader.class);
-
- final MessageExt msg = MessageDecoder.decode(ByteBuffer.wrap(request.getBody()));
-
- ConsumeMessageDirectlyResult result =
- this.mqClientFactory.consumeMessageDirectly(msg, requestHeader.getConsumerGroup(), requestHeader.getBrokerName());
-
- if (null != result) {
- response.setCode(ResponseCode.SUCCESS);
- response.setBody(result.encode());
- } else {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark(String.format("The Consumer Group <%s> not exist in this consumer", requestHeader.getConsumerGroup()));
- }
-
- return response;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/CommunicationMode.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/CommunicationMode.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/CommunicationMode.java
deleted file mode 100644
index bc2f95d..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/CommunicationMode.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * 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.client.impl;
-
-/**
- * @author shijia.wxr
- */
-public enum CommunicationMode {
- SYNC,
- ASYNC,
- ONEWAY,
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/FindBrokerResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/FindBrokerResult.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/FindBrokerResult.java
deleted file mode 100644
index 22805cd..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/FindBrokerResult.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.client.impl;
-
-/**
- * @author shijia.wxr
- */
-public class FindBrokerResult {
- private final String brokerAddr;
- private final boolean slave;
-
-
- public FindBrokerResult(String brokerAddr, boolean slave) {
- this.brokerAddr = brokerAddr;
- this.slave = slave;
- }
-
-
- public String getBrokerAddr() {
- return brokerAddr;
- }
-
-
- public boolean isSlave() {
- return slave;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/MQAdminImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/MQAdminImpl.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/MQAdminImpl.java
deleted file mode 100644
index 9f7e964..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/MQAdminImpl.java
+++ /dev/null
@@ -1,418 +0,0 @@
-/**
- * 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.client.impl;
-
-import com.alibaba.rocketmq.client.QueryResult;
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.impl.factory.MQClientInstance;
-import com.alibaba.rocketmq.client.impl.producer.TopicPublishInfo;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.TopicConfig;
-import com.alibaba.rocketmq.common.help.FAQUrl;
-import com.alibaba.rocketmq.common.message.*;
-import com.alibaba.rocketmq.common.protocol.ResponseCode;
-import com.alibaba.rocketmq.common.protocol.header.QueryMessageRequestHeader;
-import com.alibaba.rocketmq.common.protocol.header.QueryMessageResponseHeader;
-import com.alibaba.rocketmq.common.protocol.route.BrokerData;
-import com.alibaba.rocketmq.common.protocol.route.TopicRouteData;
-import com.alibaba.rocketmq.remoting.InvokeCallback;
-import com.alibaba.rocketmq.remoting.common.RemotingUtil;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-import com.alibaba.rocketmq.remoting.exception.RemotingException;
-import com.alibaba.rocketmq.remoting.netty.ResponseFuture;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import org.slf4j.Logger;
-
-import java.nio.ByteBuffer;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-
-/**
- * @author shijia.wxr
- */
-public class MQAdminImpl {
-
- private final Logger log = ClientLogger.getLog();
- private final MQClientInstance mQClientFactory;
- private long timeoutMillis = 6000;
-
-
- public MQAdminImpl(MQClientInstance mQClientFactory) {
- this.mQClientFactory = mQClientFactory;
- }
-
-
- public long getTimeoutMillis() {
- return timeoutMillis;
- }
-
-
- public void setTimeoutMillis(long timeoutMillis) {
- this.timeoutMillis = timeoutMillis;
- }
-
-
- public void createTopic(String key, String newTopic, int queueNum) throws MQClientException {
- createTopic(key, newTopic, queueNum, 0);
- }
-
-
- public void createTopic(String key, String newTopic, int queueNum, int topicSysFlag) throws MQClientException {
- try {
- TopicRouteData topicRouteData = this.mQClientFactory.getMQClientAPIImpl().getTopicRouteInfoFromNameServer(key, timeoutMillis);
- List<BrokerData> brokerDataList = topicRouteData.getBrokerDatas();
- if (brokerDataList != null && !brokerDataList.isEmpty()) {
- Collections.sort(brokerDataList);
-
- boolean createOKAtLeastOnce = false;
- MQClientException exception = null;
-
- StringBuilder orderTopicString = new StringBuilder();
-
- for (BrokerData brokerData : brokerDataList) {
- String addr = brokerData.getBrokerAddrs().get(MixAll.MASTER_ID);
- if (addr != null) {
- TopicConfig topicConfig = new TopicConfig(newTopic);
- topicConfig.setReadQueueNums(queueNum);
- topicConfig.setWriteQueueNums(queueNum);
- topicConfig.setTopicSysFlag(topicSysFlag);
-
- boolean createOK = false;
- for (int i = 0; i < 5; i++) {
- try {
- this.mQClientFactory.getMQClientAPIImpl().createTopic(addr, key, topicConfig, timeoutMillis);
- createOK = true;
- createOKAtLeastOnce = true;
- break;
- } catch (Exception e) {
- if (4 == i) {
- exception = new MQClientException("create topic to broker exception", e);
- }
- }
- }
-
- if (createOK) {
- orderTopicString.append(brokerData.getBrokerName());
- orderTopicString.append(":");
- orderTopicString.append(queueNum);
- orderTopicString.append(";");
- }
- }
- }
-
- if (exception != null && !createOKAtLeastOnce) {
- throw exception;
- }
- } else {
- throw new MQClientException("Not found broker, maybe key is wrong", null);
- }
- } catch (Exception e) {
- throw new MQClientException("create new topic failed", e);
- }
- }
-
-
- public List<MessageQueue> fetchPublishMessageQueues(String topic) throws MQClientException {
- try {
- TopicRouteData topicRouteData = this.mQClientFactory.getMQClientAPIImpl().getTopicRouteInfoFromNameServer(topic, timeoutMillis);
- if (topicRouteData != null) {
- TopicPublishInfo topicPublishInfo = MQClientInstance.topicRouteData2TopicPublishInfo(topic, topicRouteData);
- if (topicPublishInfo != null && topicPublishInfo.ok()) {
- return topicPublishInfo.getMessageQueueList();
- }
- }
- } catch (Exception e) {
- throw new MQClientException("Can not find Message Queue for this topic, " + topic, e);
- }
-
- throw new MQClientException("Unknow why, Can not find Message Queue for this topic, " + topic, null);
- }
-
-
- public Set<MessageQueue> fetchSubscribeMessageQueues(String topic) throws MQClientException {
- try {
- TopicRouteData topicRouteData = this.mQClientFactory.getMQClientAPIImpl().getTopicRouteInfoFromNameServer(topic, timeoutMillis);
- if (topicRouteData != null) {
- Set<MessageQueue> mqList = MQClientInstance.topicRouteData2TopicSubscribeInfo(topic, topicRouteData);
- if (!mqList.isEmpty()) {
- return mqList;
- } else {
- throw new MQClientException("Can not find Message Queue for this topic, " + topic + " Namesrv return empty", null);
- }
- }
- } catch (Exception e) {
- throw new MQClientException(
- "Can not find Message Queue for this topic, " + topic + FAQUrl.suggestTodo(FAQUrl.MQLIST_NOT_EXIST), //
- e);
- }
-
- throw new MQClientException("Unknow why, Can not find Message Queue for this topic, " + topic, null);
- }
-
-
- public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
- String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
- if (null == brokerAddr) {
- this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
- brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
- }
-
- if (brokerAddr != null) {
- try {
- return this.mQClientFactory.getMQClientAPIImpl().searchOffset(brokerAddr, mq.getTopic(), mq.getQueueId(), timestamp,
- timeoutMillis);
- } catch (Exception e) {
- throw new MQClientException("Invoke Broker[" + brokerAddr + "] exception", e);
- }
- }
-
- throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
- }
-
-
- public long maxOffset(MessageQueue mq) throws MQClientException {
- String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
- if (null == brokerAddr) {
- this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
- brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
- }
-
- if (brokerAddr != null) {
- try {
- return this.mQClientFactory.getMQClientAPIImpl().getMaxOffset(brokerAddr, mq.getTopic(), mq.getQueueId(), timeoutMillis);
- } catch (Exception e) {
- throw new MQClientException("Invoke Broker[" + brokerAddr + "] exception", e);
- }
- }
-
- throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
- }
-
-
- public long minOffset(MessageQueue mq) throws MQClientException {
- String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
- if (null == brokerAddr) {
- this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
- brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
- }
-
- if (brokerAddr != null) {
- try {
- return this.mQClientFactory.getMQClientAPIImpl().getMinOffset(brokerAddr, mq.getTopic(), mq.getQueueId(), timeoutMillis);
- } catch (Exception e) {
- throw new MQClientException("Invoke Broker[" + brokerAddr + "] exception", e);
- }
- }
-
- throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
- }
-
-
- public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
- String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
- if (null == brokerAddr) {
- this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
- brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
- }
-
- if (brokerAddr != null) {
- try {
- return this.mQClientFactory.getMQClientAPIImpl().getEarliestMsgStoretime(brokerAddr, mq.getTopic(), mq.getQueueId(),
- timeoutMillis);
- } catch (Exception e) {
- throw new MQClientException("Invoke Broker[" + brokerAddr + "] exception", e);
- }
- }
-
- throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
- }
-
- public MessageExt viewMessage(String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
-
- MessageId messageId = null;
- try {
- messageId = MessageDecoder.decodeMessageId(msgId);
- } catch (Exception e) {
- throw new MQClientException(ResponseCode.NO_MESSAGE, "query message by id finished, but no message.");
- }
- return this.mQClientFactory.getMQClientAPIImpl().viewMessage(RemotingUtil.socketAddress2String(messageId.getAddress()),
- messageId.getOffset(), timeoutMillis);
- }
-
- public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end) throws MQClientException,
- InterruptedException {
- return queryMessage(topic, key, maxNum, begin, end, false);
- }
-
- public MessageExt queryMessageByUniqKey(String topic, String uniqKey) throws InterruptedException, MQClientException {
-
- QueryResult qr = this.queryMessage(topic, uniqKey, 32,
- MessageClientIDSetter.getNearlyTimeFromID(uniqKey).getTime() - 1000, Long.MAX_VALUE, true);
- if (qr != null && qr.getMessageList() != null && qr.getMessageList().size() > 0) {
- return qr.getMessageList().get(0);
- } else {
- return null;
- }
- }
-
- protected QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end, boolean isUniqKey) throws MQClientException,
- InterruptedException {
- TopicRouteData topicRouteData = this.mQClientFactory.getAnExistTopicRouteData(topic);
- if (null == topicRouteData) {
- this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic);
- topicRouteData = this.mQClientFactory.getAnExistTopicRouteData(topic);
- }
-
- if (topicRouteData != null) {
- List<String> brokerAddrs = new LinkedList<String>();
- for (BrokerData brokerData : topicRouteData.getBrokerDatas()) {
- String addr = brokerData.selectBrokerAddr();
- if (addr != null) {
- brokerAddrs.add(addr);
- }
- }
-
- if (!brokerAddrs.isEmpty()) {
- final CountDownLatch countDownLatch = new CountDownLatch(brokerAddrs.size());
- final List<QueryResult> queryResultList = new LinkedList<QueryResult>();
-
- for (String addr : brokerAddrs) {
- try {
- QueryMessageRequestHeader requestHeader = new QueryMessageRequestHeader();
- requestHeader.setTopic(topic);
- requestHeader.setKey(key);
- requestHeader.setMaxNum(maxNum);
- requestHeader.setBeginTimestamp(begin);
- requestHeader.setEndTimestamp(end);
-
- this.mQClientFactory.getMQClientAPIImpl().queryMessage(addr, requestHeader, timeoutMillis * 3,
- new InvokeCallback() {
- @Override
- public void operationComplete(ResponseFuture responseFuture) {
- try {
- RemotingCommand response = responseFuture.getResponseCommand();
- if (response != null) {
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- QueryMessageResponseHeader responseHeader = null;
- try {
- responseHeader =
- (QueryMessageResponseHeader) response
- .decodeCommandCustomHeader(QueryMessageResponseHeader.class);
- } catch (RemotingCommandException e) {
- log.error("decodeCommandCustomHeader exception", e);
- return;
- }
-
- List<MessageExt> wrappers =
- MessageDecoder.decodes(ByteBuffer.wrap(response.getBody()), true);
-
- QueryResult qr = new QueryResult(responseHeader.getIndexLastUpdateTimestamp(), wrappers);
- queryResultList.add(qr);
- break;
- }
- default:
- log.warn("getResponseCommand failed, {} {}", response.getCode(), response.getRemark());
- break;
- }
- } else {
- log.warn("getResponseCommand return null");
- }
- } finally {
- countDownLatch.countDown();
- }
- }
- }, isUniqKey);
- } catch (Exception e) {
- log.warn("queryMessage exception", e);
- }
-
- }
-
- boolean ok = countDownLatch.await(timeoutMillis * 4, TimeUnit.MILLISECONDS);
- if (!ok) {
- log.warn("queryMessage, maybe some broker failed");
- }
-
- long indexLastUpdateTimestamp = 0;
- List<MessageExt> messageList = new LinkedList<MessageExt>();
- for (QueryResult qr : queryResultList) {
- if (qr.getIndexLastUpdateTimestamp() > indexLastUpdateTimestamp) {
- indexLastUpdateTimestamp = qr.getIndexLastUpdateTimestamp();
- }
-
- for (MessageExt msgExt : qr.getMessageList()) {
- if (isUniqKey) {
- if (msgExt.getMsgId().equals(key)) {
-
- if (messageList.size() > 0) {
-
- if (messageList.get(0).getStoreTimestamp() > msgExt.getStoreTimestamp()) {
-
- messageList.clear();
- messageList.add(msgExt);
- }
-
- } else {
-
- messageList.add(msgExt);
- }
- } else {
- log.warn("queryMessage by uniqKey, find message key not matched, maybe hash duplicate {}", msgExt.toString());
- }
- } else {
- String keys = msgExt.getKeys();
- if (keys != null) {
- boolean matched = false;
- String[] keyArray = keys.split(MessageConst.KEY_SEPARATOR);
- if (keyArray != null) {
- for (String k : keyArray) {
- if (key.equals(k)) {
- matched = true;
- break;
- }
- }
- }
-
- if (matched) {
- messageList.add(msgExt);
- } else {
- log.warn("queryMessage, find message key not matched, maybe hash duplicate {}", msgExt.toString());
- }
- }
- }
- }
- }
-
- if (!messageList.isEmpty()) {
- return new QueryResult(indexLastUpdateTimestamp, messageList);
- } else {
- throw new MQClientException(ResponseCode.NO_MESSAGE, "query message by key finished, but no message.");
- }
- }
- }
-
- throw new MQClientException(ResponseCode.TOPIC_NOT_EXIST, "The topic[" + topic + "] not matched route info");
- }
-}
[31/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/producer/DefaultMQProducerImpl.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
deleted file mode 100644
index b82cde9..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
+++ /dev/null
@@ -1,1080 +0,0 @@
-/**
- * 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.client.impl.producer;
-
-import com.alibaba.rocketmq.client.QueryResult;
-import com.alibaba.rocketmq.client.Validators;
-import com.alibaba.rocketmq.client.common.ClientErrorCode;
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.hook.CheckForbiddenContext;
-import com.alibaba.rocketmq.client.hook.CheckForbiddenHook;
-import com.alibaba.rocketmq.client.hook.SendMessageContext;
-import com.alibaba.rocketmq.client.hook.SendMessageHook;
-import com.alibaba.rocketmq.client.impl.CommunicationMode;
-import com.alibaba.rocketmq.client.impl.MQClientManager;
-import com.alibaba.rocketmq.client.impl.factory.MQClientInstance;
-import com.alibaba.rocketmq.client.latency.MQFaultStrategy;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.client.producer.*;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.ServiceState;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.help.FAQUrl;
-import com.alibaba.rocketmq.common.message.*;
-import com.alibaba.rocketmq.common.protocol.ResponseCode;
-import com.alibaba.rocketmq.common.protocol.header.CheckTransactionStateRequestHeader;
-import com.alibaba.rocketmq.common.protocol.header.EndTransactionRequestHeader;
-import com.alibaba.rocketmq.common.protocol.header.SendMessageRequestHeader;
-import com.alibaba.rocketmq.common.sysflag.MessageSysFlag;
-import com.alibaba.rocketmq.remoting.RPCHook;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import com.alibaba.rocketmq.remoting.exception.RemotingConnectException;
-import com.alibaba.rocketmq.remoting.exception.RemotingException;
-import com.alibaba.rocketmq.remoting.exception.RemotingTimeoutException;
-import org.slf4j.Logger;
-
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.util.*;
-import java.util.concurrent.*;
-
-
-/**
- * @author shijia.wxr
- */
-public class DefaultMQProducerImpl implements MQProducerInner {
- private final Logger log = ClientLogger.getLog();
- private final Random random = new Random();
- private final DefaultMQProducer defaultMQProducer;
- private final ConcurrentHashMap<String/* topic */, TopicPublishInfo> topicPublishInfoTable =
- new ConcurrentHashMap<String, TopicPublishInfo>();
- private final ArrayList<SendMessageHook> sendMessageHookList = new ArrayList<SendMessageHook>();
- private final RPCHook rpcHook;
- protected BlockingQueue<Runnable> checkRequestQueue;
- protected ExecutorService checkExecutor;
- private ServiceState serviceState = ServiceState.CREATE_JUST;
- private MQClientInstance mQClientFactory;
- private ArrayList<CheckForbiddenHook> checkForbiddenHookList = new ArrayList<CheckForbiddenHook>();
- private int zipCompressLevel = Integer.parseInt(System.getProperty(MixAll.MESSAGE_COMPRESS_LEVEL, "5"));
-
- private MQFaultStrategy mqFaultStrategy = new MQFaultStrategy();
-
-
- public DefaultMQProducerImpl(final DefaultMQProducer defaultMQProducer) {
- this(defaultMQProducer, null);
- }
-
-
- public DefaultMQProducerImpl(final DefaultMQProducer defaultMQProducer, RPCHook rpcHook) {
- this.defaultMQProducer = defaultMQProducer;
- this.rpcHook = rpcHook;
- }
-
- public void registerCheckForbiddenHook(CheckForbiddenHook checkForbiddenHook) {
- this.checkForbiddenHookList.add(checkForbiddenHook);
- log.info("register a new checkForbiddenHook. hookName={}, allHookSize={}", checkForbiddenHook.hookName(),
- checkForbiddenHookList.size());
- }
-
- public void initTransactionEnv() {
- TransactionMQProducer producer = (TransactionMQProducer) this.defaultMQProducer;
- this.checkRequestQueue = new LinkedBlockingQueue<Runnable>(producer.getCheckRequestHoldMax());
- this.checkExecutor = new ThreadPoolExecutor(//
- producer.getCheckThreadPoolMinSize(), //
- producer.getCheckThreadPoolMaxSize(), //
- 1000 * 60, //
- TimeUnit.MILLISECONDS, //
- this.checkRequestQueue);
- }
-
- public void destroyTransactionEnv() {
- this.checkExecutor.shutdown();
- this.checkRequestQueue.clear();
- }
-
- public void registerSendMessageHook(final SendMessageHook hook) {
- this.sendMessageHookList.add(hook);
- log.info("register sendMessage Hook, {}", hook.hookName());
- }
-
- public void start() throws MQClientException {
- this.start(true);
- }
-
- public void start(final boolean startFactory) throws MQClientException {
- switch (this.serviceState) {
- case CREATE_JUST:
- this.serviceState = ServiceState.START_FAILED;
-
- this.checkConfig();
-
- if (!this.defaultMQProducer.getProducerGroup().equals(MixAll.CLIENT_INNER_PRODUCER_GROUP)) {
- this.defaultMQProducer.changeInstanceNameToPID();
- }
-
- this.mQClientFactory = MQClientManager.getInstance().getAndCreateMQClientInstance(this.defaultMQProducer, rpcHook);
-
- boolean registerOK = mQClientFactory.registerProducer(this.defaultMQProducer.getProducerGroup(), this);
- if (!registerOK) {
- this.serviceState = ServiceState.CREATE_JUST;
- throw new MQClientException("The producer group[" + this.defaultMQProducer.getProducerGroup()
- + "] has been created before, specify another name please." + FAQUrl.suggestTodo(FAQUrl.GROUP_NAME_DUPLICATE_URL),
- null);
- }
-
- this.topicPublishInfoTable.put(this.defaultMQProducer.getCreateTopicKey(), new TopicPublishInfo());
-
- if (startFactory) {
- mQClientFactory.start();
- }
-
- log.info("the producer [{}] start OK. sendMessageWithVIPChannel={}", this.defaultMQProducer.getProducerGroup(),
- this.defaultMQProducer.isSendMessageWithVIPChannel());
- this.serviceState = ServiceState.RUNNING;
- break;
- case RUNNING:
- case START_FAILED:
- case SHUTDOWN_ALREADY:
- throw new MQClientException("The producer service state not OK, maybe started once, "//
- + this.serviceState//
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
- null);
- default:
- break;
- }
-
- this.mQClientFactory.sendHeartbeatToAllBrokerWithLock();
- }
-
- private void checkConfig() throws MQClientException {
- Validators.checkGroup(this.defaultMQProducer.getProducerGroup());
-
- if (null == this.defaultMQProducer.getProducerGroup()) {
- throw new MQClientException("producerGroup is null", null);
- }
-
- if (this.defaultMQProducer.getProducerGroup().equals(MixAll.DEFAULT_PRODUCER_GROUP)) {
- throw new MQClientException("producerGroup can not equal " + MixAll.DEFAULT_PRODUCER_GROUP + ", please specify another one.",
- null);
- }
- }
-
- public void shutdown() {
- this.shutdown(true);
- }
-
- public void shutdown(final boolean shutdownFactory) {
- switch (this.serviceState) {
- case CREATE_JUST:
- break;
- case RUNNING:
- this.mQClientFactory.unregisterProducer(this.defaultMQProducer.getProducerGroup());
- if (shutdownFactory) {
- this.mQClientFactory.shutdown();
- }
-
- log.info("the producer [{}] shutdown OK", this.defaultMQProducer.getProducerGroup());
- this.serviceState = ServiceState.SHUTDOWN_ALREADY;
- break;
- case SHUTDOWN_ALREADY:
- break;
- default:
- break;
- }
- }
-
- @Override
- public Set<String> getPublishTopicList() {
- Set<String> topicList = new HashSet<String>();
- for (String key : this.topicPublishInfoTable.keySet()) {
- topicList.add(key);
- }
-
- return topicList;
- }
-
- @Override
- public boolean isPublishTopicNeedUpdate(String topic) {
- TopicPublishInfo prev = this.topicPublishInfoTable.get(topic);
-
- return null == prev || !prev.ok();
- }
-
- @Override
- public TransactionCheckListener checkListener() {
- if (this.defaultMQProducer instanceof TransactionMQProducer) {
- TransactionMQProducer producer = (TransactionMQProducer) defaultMQProducer;
- return producer.getTransactionCheckListener();
- }
-
- return null;
- }
-
- @Override
- public void checkTransactionState(final String addr, final MessageExt msg, final CheckTransactionStateRequestHeader header) {
- Runnable request = new Runnable() {
- private final String brokerAddr = addr;
- private final MessageExt message = msg;
- private final CheckTransactionStateRequestHeader checkRequestHeader = header;
- private final String group = DefaultMQProducerImpl.this.defaultMQProducer.getProducerGroup();
-
-
- @Override
- public void run() {
- TransactionCheckListener transactionCheckListener = DefaultMQProducerImpl.this.checkListener();
- if (transactionCheckListener != null) {
- LocalTransactionState localTransactionState = LocalTransactionState.UNKNOW;
- Throwable exception = null;
- try {
- localTransactionState = transactionCheckListener.checkLocalTransactionState(message);
- } catch (Throwable e) {
- log.error("Broker call checkTransactionState, but checkLocalTransactionState exception", e);
- exception = e;
- }
-
- this.processTransactionState(//
- localTransactionState, //
- group, //
- exception);
- } else {
- log.warn("checkTransactionState, pick transactionCheckListener by group[{}] failed", group);
- }
- }
-
-
- private void processTransactionState(//
- final LocalTransactionState localTransactionState, //
- final String producerGroup, //
- final Throwable exception) {
- final EndTransactionRequestHeader thisHeader = new EndTransactionRequestHeader();
- thisHeader.setCommitLogOffset(checkRequestHeader.getCommitLogOffset());
- thisHeader.setProducerGroup(producerGroup);
- thisHeader.setTranStateTableOffset(checkRequestHeader.getTranStateTableOffset());
- thisHeader.setFromTransactionCheck(true);
-
- String uniqueKey = message.getProperties().get(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX);
- if (uniqueKey == null) {
- uniqueKey = message.getMsgId();
- }
- thisHeader.setMsgId(uniqueKey);
- thisHeader.setTransactionId(checkRequestHeader.getTransactionId());
- switch (localTransactionState) {
- case COMMIT_MESSAGE:
- thisHeader.setCommitOrRollback(MessageSysFlag.TRANSACTION_COMMIT_TYPE);
- break;
- case ROLLBACK_MESSAGE:
- thisHeader.setCommitOrRollback(MessageSysFlag.TRANSACTION_ROLLBACK_TYPE);
- log.warn("when broker check, client rollback this transaction, {}", thisHeader);
- break;
- case UNKNOW:
- thisHeader.setCommitOrRollback(MessageSysFlag.TRANSACTION_NOT_TYPE);
- log.warn("when broker check, client does not know this transaction state, {}", thisHeader);
- break;
- default:
- break;
- }
-
- String remark = null;
- if (exception != null) {
- remark = "checkLocalTransactionState Exception: " + RemotingHelper.exceptionSimpleDesc(exception);
- }
-
- try {
- DefaultMQProducerImpl.this.mQClientFactory.getMQClientAPIImpl().endTransactionOneway(brokerAddr, thisHeader, remark,
- 3000);
- } catch (Exception e) {
- log.error("endTransactionOneway exception", e);
- }
- }
- };
-
- this.checkExecutor.submit(request);
- }
-
- @Override
- public void updateTopicPublishInfo(final String topic, final TopicPublishInfo info) {
- if (info != null && topic != null) {
- TopicPublishInfo prev = this.topicPublishInfoTable.put(topic, info);
- if (prev != null) {
- log.info("updateTopicPublishInfo prev is not null, " + prev.toString());
- }
- }
- }
-
- @Override
- public boolean isUnitMode() {
- return this.defaultMQProducer.isUnitMode();
- }
-
- public void createTopic(String key, String newTopic, int queueNum) throws MQClientException {
- createTopic(key, newTopic, queueNum, 0);
- }
-
- public void createTopic(String key, String newTopic, int queueNum, int topicSysFlag) throws MQClientException {
- this.makeSureStateOK();
- Validators.checkTopic(newTopic);
-
- this.mQClientFactory.getMQAdminImpl().createTopic(key, newTopic, queueNum, topicSysFlag);
- }
-
- private void makeSureStateOK() throws MQClientException {
- if (this.serviceState != ServiceState.RUNNING) {
- throw new MQClientException("The producer service state not OK, "//
- + this.serviceState//
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
- null);
- }
- }
-
- public List<MessageQueue> fetchPublishMessageQueues(String topic) throws MQClientException {
- this.makeSureStateOK();
- return this.mQClientFactory.getMQAdminImpl().fetchPublishMessageQueues(topic);
- }
-
- public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
- this.makeSureStateOK();
- return this.mQClientFactory.getMQAdminImpl().searchOffset(mq, timestamp);
- }
-
- public long maxOffset(MessageQueue mq) throws MQClientException {
- this.makeSureStateOK();
- return this.mQClientFactory.getMQAdminImpl().maxOffset(mq);
- }
-
- public long minOffset(MessageQueue mq) throws MQClientException {
- this.makeSureStateOK();
- return this.mQClientFactory.getMQAdminImpl().minOffset(mq);
- }
-
- public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
- this.makeSureStateOK();
- return this.mQClientFactory.getMQAdminImpl().earliestMsgStoreTime(mq);
- }
-
- public MessageExt viewMessage(String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- this.makeSureStateOK();
-
- return this.mQClientFactory.getMQAdminImpl().viewMessage(msgId);
- }
-
- public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
- throws MQClientException, InterruptedException {
- this.makeSureStateOK();
- return this.mQClientFactory.getMQAdminImpl().queryMessage(topic, key, maxNum, begin, end);
- }
-
- public MessageExt queryMessageByUniqKey(String topic, String uniqKey)
- throws MQClientException, InterruptedException {
- this.makeSureStateOK();
- return this.mQClientFactory.getMQAdminImpl().queryMessageByUniqKey(topic, uniqKey);
- }
-
- /**
- * DEFAULT ASYNC -------------------------------------------------------
- */
- public void send(Message msg, SendCallback sendCallback) throws MQClientException, RemotingException, InterruptedException {
- send(msg, sendCallback, this.defaultMQProducer.getSendMsgTimeout());
- }
-
- public void send(Message msg, SendCallback sendCallback, long timeout)
- throws MQClientException, RemotingException, InterruptedException {
- try {
- this.sendDefaultImpl(msg, CommunicationMode.ASYNC, sendCallback, timeout);
- } catch (MQBrokerException e) {
- throw new MQClientException("unknownn exception", e);
- }
- }
-
- public MessageQueue selectOneMessageQueue(final TopicPublishInfo tpInfo, final String lastBrokerName) {
- return this.mqFaultStrategy.selectOneMessageQueue(tpInfo, lastBrokerName);
- }
-
- public void updateFaultItem(final String brokerName, final long currentLatency, boolean isolation) {
- this.mqFaultStrategy.updateFaultItem(brokerName, currentLatency, isolation);
- }
-
- private SendResult sendDefaultImpl(//
- Message msg, //
- final CommunicationMode communicationMode, //
- final SendCallback sendCallback, //
- final long timeout//
- ) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- this.makeSureStateOK();
- Validators.checkMessage(msg, this.defaultMQProducer);
-
- final long invokeID = random.nextLong();
- long beginTimestampFirst = System.currentTimeMillis();
- long beginTimestampPrev = beginTimestampFirst;
- long endTimestamp = beginTimestampFirst;
- TopicPublishInfo topicPublishInfo = this.tryToFindTopicPublishInfo(msg.getTopic());
- if (topicPublishInfo != null && topicPublishInfo.ok()) {
- MessageQueue mq = null;
- Exception exception = null;
- SendResult sendResult = null;
- int timesTotal = communicationMode == CommunicationMode.SYNC ? 1 + this.defaultMQProducer.getRetryTimesWhenSendFailed() : 1;
- int times = 0;
- String[] brokersSent = new String[timesTotal];
- for (; times < timesTotal; times++) {
- String lastBrokerName = null == mq ? null : mq.getBrokerName();
- MessageQueue tmpmq = this.selectOneMessageQueue(topicPublishInfo, lastBrokerName);
- if (tmpmq != null) {
- mq = tmpmq;
- brokersSent[times] = mq.getBrokerName();
- try {
- beginTimestampPrev = System.currentTimeMillis();
- sendResult = this.sendKernelImpl(msg, mq, communicationMode, sendCallback, topicPublishInfo, timeout);
- endTimestamp = System.currentTimeMillis();
- this.updateFaultItem(mq.getBrokerName(), endTimestamp - beginTimestampPrev, false);
- switch (communicationMode) {
- case ASYNC:
- return null;
- case ONEWAY:
- return null;
- case SYNC:
- if (sendResult.getSendStatus() != SendStatus.SEND_OK) {
- if (this.defaultMQProducer.isRetryAnotherBrokerWhenNotStoreOK()) {
- continue;
- }
- }
-
- return sendResult;
- default:
- break;
- }
- } catch (RemotingException e) {
- endTimestamp = System.currentTimeMillis();
- this.updateFaultItem(mq.getBrokerName(), endTimestamp - beginTimestampPrev, true);
- log.warn(String.format("sendKernelImpl exception, resend at once, InvokeID: %s, RT: %sms, Broker: %s", invokeID, endTimestamp - beginTimestampPrev, mq), e);
- log.warn(msg.toString());
- exception = e;
- continue;
- } catch (MQClientException e) {
- endTimestamp = System.currentTimeMillis();
- this.updateFaultItem(mq.getBrokerName(), endTimestamp - beginTimestampPrev, true);
- log.warn(String.format("sendKernelImpl exception, resend at once, InvokeID: %s, RT: %sms, Broker: %s", invokeID, endTimestamp - beginTimestampPrev, mq), e);
- log.warn(msg.toString());
- exception = e;
- continue;
- } catch (MQBrokerException e) {
- endTimestamp = System.currentTimeMillis();
- this.updateFaultItem(mq.getBrokerName(), endTimestamp - beginTimestampPrev, true);
- log.warn(String.format("sendKernelImpl exception, resend at once, InvokeID: %s, RT: %sms, Broker: %s", invokeID, endTimestamp - beginTimestampPrev, mq), e);
- log.warn(msg.toString());
- exception = e;
- switch (e.getResponseCode()) {
- case ResponseCode.TOPIC_NOT_EXIST:
- case ResponseCode.SERVICE_NOT_AVAILABLE:
- case ResponseCode.SYSTEM_ERROR:
- case ResponseCode.NO_PERMISSION:
- case ResponseCode.NO_BUYER_ID:
- case ResponseCode.NOT_IN_CURRENT_UNIT:
- continue;
- default:
- if (sendResult != null) {
- return sendResult;
- }
-
- throw e;
- }
- } catch (InterruptedException e) {
- endTimestamp = System.currentTimeMillis();
- this.updateFaultItem(mq.getBrokerName(), endTimestamp - beginTimestampPrev, false);
- log.warn(String.format("sendKernelImpl exception, throw exception, InvokeID: %s, RT: %sms, Broker: %s", invokeID, endTimestamp - beginTimestampPrev, mq), e);
- log.warn(msg.toString());
-
- log.warn("sendKernelImpl exception", e);
- log.warn(msg.toString());
- throw e;
- }
- } else {
- break;
- }
- }
-
- if (sendResult != null) {
- return sendResult;
- }
-
- String info = String.format("Send [%d] times, still failed, cost [%d]ms, Topic: %s, BrokersSent: %s",
- times,
- System.currentTimeMillis() - beginTimestampFirst,
- msg.getTopic(),
- Arrays.toString(brokersSent));
-
- info += FAQUrl.suggestTodo(FAQUrl.SEND_MSG_FAILED);
-
- MQClientException mqClientException = new MQClientException(info, exception);
- if (exception instanceof MQBrokerException) {
- mqClientException.setResponseCode(((MQBrokerException) exception).getResponseCode());
- } else if (exception instanceof RemotingConnectException) {
- mqClientException.setResponseCode(ClientErrorCode.CONNECT_BROKER_EXCEPTION);
- } else if (exception instanceof RemotingTimeoutException) {
- mqClientException.setResponseCode(ClientErrorCode.ACCESS_BROKER_TIMEOUT);
- } else if (exception instanceof MQClientException) {
- mqClientException.setResponseCode(ClientErrorCode.BROKER_NOT_EXIST_EXCEPTION);
- }
-
- throw mqClientException;
- }
-
- List<String> nsList = this.getmQClientFactory().getMQClientAPIImpl().getNameServerAddressList();
- if (null == nsList || nsList.isEmpty()) {
- throw new MQClientException(
- "No name server address, please set it." + FAQUrl.suggestTodo(FAQUrl.NAME_SERVER_ADDR_NOT_EXIST_URL), null).setResponseCode(ClientErrorCode.NO_NAME_SERVER_EXCEPTION);
- }
-
- throw new MQClientException("No route info of this topic, " + msg.getTopic() + FAQUrl.suggestTodo(FAQUrl.NO_TOPIC_ROUTE_INFO),
- null).setResponseCode(ClientErrorCode.NOT_FOUND_TOPIC_EXCEPTION);
- }
-
- private TopicPublishInfo tryToFindTopicPublishInfo(final String topic) {
- TopicPublishInfo topicPublishInfo = this.topicPublishInfoTable.get(topic);
- if (null == topicPublishInfo || !topicPublishInfo.ok()) {
- this.topicPublishInfoTable.putIfAbsent(topic, new TopicPublishInfo());
- this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic);
- topicPublishInfo = this.topicPublishInfoTable.get(topic);
- }
-
- if (topicPublishInfo.isHaveTopicRouterInfo() || topicPublishInfo.ok()) {
- return topicPublishInfo;
- } else {
- this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic, true, this.defaultMQProducer);
- topicPublishInfo = this.topicPublishInfoTable.get(topic);
- return topicPublishInfo;
- }
- }
-
- private SendResult sendKernelImpl(final Message msg, //
- final MessageQueue mq, //
- final CommunicationMode communicationMode, //
- final SendCallback sendCallback, //
- final TopicPublishInfo topicPublishInfo, //
- final long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
- if (null == brokerAddr) {
- tryToFindTopicPublishInfo(mq.getTopic());
- brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
- }
-
- SendMessageContext context = null;
- if (brokerAddr != null) {
- brokerAddr = MixAll.brokerVIPChannel(this.defaultMQProducer.isSendMessageWithVIPChannel(), brokerAddr);
-
- byte[] prevBody = msg.getBody();
- try {
-
- MessageClientIDSetter.setUniqID(msg);
-
- int sysFlag = 0;
- if (this.tryToCompressMessage(msg)) {
- sysFlag |= MessageSysFlag.COMPRESSED_FLAG;
- }
-
- final String tranMsg = msg.getProperty(MessageConst.PROPERTY_TRANSACTION_PREPARED);
- if (tranMsg != null && Boolean.parseBoolean(tranMsg)) {
- sysFlag |= MessageSysFlag.TRANSACTION_PREPARED_TYPE;
- }
-
- if (hasCheckForbiddenHook()) {
- CheckForbiddenContext checkForbiddenContext = new CheckForbiddenContext();
- checkForbiddenContext.setNameSrvAddr(this.defaultMQProducer.getNamesrvAddr());
- checkForbiddenContext.setGroup(this.defaultMQProducer.getProducerGroup());
- checkForbiddenContext.setCommunicationMode(communicationMode);
- checkForbiddenContext.setBrokerAddr(brokerAddr);
- checkForbiddenContext.setMessage(msg);
- checkForbiddenContext.setMq(mq);
- checkForbiddenContext.setUnitMode(this.isUnitMode());
- this.executeCheckForbiddenHook(checkForbiddenContext);
- }
-
- if (this.hasSendMessageHook()) {
- context = new SendMessageContext();
- context.setProducer(this);
- context.setProducerGroup(this.defaultMQProducer.getProducerGroup());
- context.setCommunicationMode(communicationMode);
- context.setBornHost(this.defaultMQProducer.getClientIP());
- context.setBrokerAddr(brokerAddr);
- context.setMessage(msg);
- context.setMq(mq);
- String isTrans = msg.getProperty(MessageConst.PROPERTY_TRANSACTION_PREPARED);
- if (isTrans != null && isTrans.equals("true")) {
- context.setMsgType(MessageType.Trans_Msg_Half);
- }
-
- if (msg.getProperty("__STARTDELIVERTIME") != null || msg.getProperty(MessageConst.PROPERTY_DELAY_TIME_LEVEL) != null) {
- context.setMsgType(MessageType.Delay_Msg);
- }
- this.executeSendMessageHookBefore(context);
- }
-
- SendMessageRequestHeader requestHeader = new SendMessageRequestHeader();
- requestHeader.setProducerGroup(this.defaultMQProducer.getProducerGroup());
- requestHeader.setTopic(msg.getTopic());
- requestHeader.setDefaultTopic(this.defaultMQProducer.getCreateTopicKey());
- requestHeader.setDefaultTopicQueueNums(this.defaultMQProducer.getDefaultTopicQueueNums());
- requestHeader.setQueueId(mq.getQueueId());
- requestHeader.setSysFlag(sysFlag);
- requestHeader.setBornTimestamp(System.currentTimeMillis());
- requestHeader.setFlag(msg.getFlag());
- requestHeader.setProperties(MessageDecoder.messageProperties2String(msg.getProperties()));
- requestHeader.setReconsumeTimes(0);
- requestHeader.setUnitMode(this.isUnitMode());
- if (requestHeader.getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
- String reconsumeTimes = MessageAccessor.getReconsumeTime(msg);
- if (reconsumeTimes != null) {
- requestHeader.setReconsumeTimes(Integer.valueOf(reconsumeTimes));
- MessageAccessor.clearProperty(msg, MessageConst.PROPERTY_RECONSUME_TIME);
- }
-
- String maxReconsumeTimes = MessageAccessor.getMaxReconsumeTimes(msg);
- if (maxReconsumeTimes != null) {
- requestHeader.setMaxReconsumeTimes(Integer.valueOf(maxReconsumeTimes));
- MessageAccessor.clearProperty(msg, MessageConst.PROPERTY_MAX_RECONSUME_TIMES);
- }
- }
-
- SendResult sendResult = null;
- switch (communicationMode) {
- case ASYNC:
- sendResult = this.mQClientFactory.getMQClientAPIImpl().sendMessage(//
- brokerAddr, // 1
- mq.getBrokerName(), // 2
- msg, // 3
- requestHeader, // 4
- timeout, // 5
- communicationMode, // 6
- sendCallback, // 7
- topicPublishInfo, // 8
- this.mQClientFactory, // 9
- this.defaultMQProducer.getRetryTimesWhenSendAsyncFailed(), // 10
- context, //
- this);
- break;
- case ONEWAY:
- case SYNC:
- sendResult = this.mQClientFactory.getMQClientAPIImpl().sendMessage(
- brokerAddr,
- mq.getBrokerName(),
- msg,
- requestHeader,
- timeout,
- communicationMode,
- context,
- this);
- break;
- default:
- assert false;
- break;
- }
-
- if (this.hasSendMessageHook()) {
- context.setSendResult(sendResult);
- this.executeSendMessageHookAfter(context);
- }
-
- return sendResult;
- } catch (RemotingException e) {
- if (this.hasSendMessageHook()) {
- context.setException(e);
- this.executeSendMessageHookAfter(context);
- }
- throw e;
- } catch (MQBrokerException e) {
- if (this.hasSendMessageHook()) {
- context.setException(e);
- this.executeSendMessageHookAfter(context);
- }
- throw e;
- } catch (InterruptedException e) {
- if (this.hasSendMessageHook()) {
- context.setException(e);
- this.executeSendMessageHookAfter(context);
- }
- throw e;
- } finally {
- msg.setBody(prevBody);
- }
- }
-
- throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
- }
-
- public MQClientInstance getmQClientFactory() {
- return mQClientFactory;
- }
-
- private boolean tryToCompressMessage(final Message msg) {
- byte[] body = msg.getBody();
- if (body != null) {
- if (body.length >= this.defaultMQProducer.getCompressMsgBodyOverHowmuch()) {
- try {
- byte[] data = UtilAll.compress(body, zipCompressLevel);
- if (data != null) {
- msg.setBody(data);
- return true;
- }
- } catch (IOException e) {
- log.error("tryToCompressMessage exception", e);
- log.warn(msg.toString());
- }
- }
- }
-
- return false;
- }
-
- public boolean hasCheckForbiddenHook() {
- return !checkForbiddenHookList.isEmpty();
- }
-
- public void executeCheckForbiddenHook(final CheckForbiddenContext context) throws MQClientException {
- if (hasCheckForbiddenHook()) {
- for (CheckForbiddenHook hook : checkForbiddenHookList) {
- hook.checkForbidden(context);
- }
- }
- }
-
- public boolean hasSendMessageHook() {
- return !this.sendMessageHookList.isEmpty();
- }
-
- public void executeSendMessageHookBefore(final SendMessageContext context) {
- if (!this.sendMessageHookList.isEmpty()) {
- for (SendMessageHook hook : this.sendMessageHookList) {
- try {
- hook.sendMessageBefore(context);
- } catch (Throwable e) {
- log.warn("failed to executeSendMessageHookBefore", e);
- }
- }
- }
- }
-
- public void executeSendMessageHookAfter(final SendMessageContext context) {
- if (!this.sendMessageHookList.isEmpty()) {
- for (SendMessageHook hook : this.sendMessageHookList) {
- try {
- hook.sendMessageAfter(context);
- } catch (Throwable e) {
- log.warn("failed to executeSendMessageHookAfter", e);
- }
- }
- }
- }
-
- /**
- * DEFAULT ONEWAY -------------------------------------------------------
- */
- public void sendOneway(Message msg) throws MQClientException, RemotingException, InterruptedException {
- try {
- this.sendDefaultImpl(msg, CommunicationMode.ONEWAY, null, this.defaultMQProducer.getSendMsgTimeout());
- } catch (MQBrokerException e) {
- throw new MQClientException("unknown exception", e);
- }
- }
-
- /**
- * KERNEL SYNC -------------------------------------------------------
- */
- public SendResult send(Message msg, MessageQueue mq)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- return send(msg, mq, this.defaultMQProducer.getSendMsgTimeout());
- }
-
- public SendResult send(Message msg, MessageQueue mq, long timeout)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- this.makeSureStateOK();
- Validators.checkMessage(msg, this.defaultMQProducer);
-
- if (!msg.getTopic().equals(mq.getTopic())) {
- throw new MQClientException("message's topic not equal mq's topic", null);
- }
-
- return this.sendKernelImpl(msg, mq, CommunicationMode.SYNC, null, null, timeout);
- }
-
- /**
- * KERNEL ASYNC -------------------------------------------------------
- */
- public void send(Message msg, MessageQueue mq, SendCallback sendCallback)
- throws MQClientException, RemotingException, InterruptedException {
- send(msg, mq, sendCallback, this.defaultMQProducer.getSendMsgTimeout());
- }
-
- public void send(Message msg, MessageQueue mq, SendCallback sendCallback, long timeout)
- throws MQClientException, RemotingException, InterruptedException {
- this.makeSureStateOK();
- Validators.checkMessage(msg, this.defaultMQProducer);
-
- if (!msg.getTopic().equals(mq.getTopic())) {
- throw new MQClientException("message's topic not equal mq's topic", null);
- }
-
- try {
- this.sendKernelImpl(msg, mq, CommunicationMode.ASYNC, sendCallback, null, timeout);
- } catch (MQBrokerException e) {
- throw new MQClientException("unknown exception", e);
- }
- }
-
- /**
- * KERNEL ONEWAY -------------------------------------------------------
- */
- public void sendOneway(Message msg, MessageQueue mq) throws MQClientException, RemotingException, InterruptedException {
- this.makeSureStateOK();
- Validators.checkMessage(msg, this.defaultMQProducer);
-
- try {
- this.sendKernelImpl(msg, mq, CommunicationMode.ONEWAY, null, null, this.defaultMQProducer.getSendMsgTimeout());
- } catch (MQBrokerException e) {
- throw new MQClientException("unknown exception", e);
- }
- }
-
- /**
- * SELECT SYNC -------------------------------------------------------
- */
- public SendResult send(Message msg, MessageQueueSelector selector, Object arg)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- return send(msg, selector, arg, this.defaultMQProducer.getSendMsgTimeout());
- }
-
- public SendResult send(Message msg, MessageQueueSelector selector, Object arg, long timeout)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- return this.sendSelectImpl(msg, selector, arg, CommunicationMode.SYNC, null, timeout);
- }
-
- private SendResult sendSelectImpl(//
- Message msg, //
- MessageQueueSelector selector, //
- Object arg, //
- final CommunicationMode communicationMode, //
- final SendCallback sendCallback, final long timeout//
- ) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- this.makeSureStateOK();
- Validators.checkMessage(msg, this.defaultMQProducer);
-
- TopicPublishInfo topicPublishInfo = this.tryToFindTopicPublishInfo(msg.getTopic());
- if (topicPublishInfo != null && topicPublishInfo.ok()) {
- MessageQueue mq = null;
- try {
- mq = selector.select(topicPublishInfo.getMessageQueueList(), msg, arg);
- } catch (Throwable e) {
- throw new MQClientException("select message queue throwed exception.", e);
- }
-
- if (mq != null) {
- return this.sendKernelImpl(msg, mq, communicationMode, sendCallback, null, timeout);
- } else {
- throw new MQClientException("select message queue return null.", null);
- }
- }
-
- throw new MQClientException("No route info for this topic, " + msg.getTopic(), null);
- }
-
- /**
- * SELECT ASYNC -------------------------------------------------------
- */
- public void send(Message msg, MessageQueueSelector selector, Object arg, SendCallback sendCallback)
- throws MQClientException, RemotingException, InterruptedException {
- send(msg, selector, arg, sendCallback, this.defaultMQProducer.getSendMsgTimeout());
- }
-
- public void send(Message msg, MessageQueueSelector selector, Object arg, SendCallback sendCallback, long timeout)
- throws MQClientException, RemotingException, InterruptedException {
- try {
- this.sendSelectImpl(msg, selector, arg, CommunicationMode.ASYNC, sendCallback, timeout);
- } catch (MQBrokerException e) {
- throw new MQClientException("unknownn exception", e);
- }
- }
-
- /**
- * SELECT ONEWAY -------------------------------------------------------
- */
- public void sendOneway(Message msg, MessageQueueSelector selector, Object arg)
- throws MQClientException, RemotingException, InterruptedException {
- try {
- this.sendSelectImpl(msg, selector, arg, CommunicationMode.ONEWAY, null, this.defaultMQProducer.getSendMsgTimeout());
- } catch (MQBrokerException e) {
- throw new MQClientException("unknown exception", e);
- }
- }
-
- public TransactionSendResult sendMessageInTransaction(final Message msg, final LocalTransactionExecuter tranExecuter, final Object arg)
- throws MQClientException {
- if (null == tranExecuter) {
- throw new MQClientException("tranExecutor is null", null);
- }
- Validators.checkMessage(msg, this.defaultMQProducer);
-
- SendResult sendResult = null;
- MessageAccessor.putProperty(msg, MessageConst.PROPERTY_TRANSACTION_PREPARED, "true");
- MessageAccessor.putProperty(msg, MessageConst.PROPERTY_PRODUCER_GROUP, this.defaultMQProducer.getProducerGroup());
- try {
- sendResult = this.send(msg);
- } catch (Exception e) {
- throw new MQClientException("send message Exception", e);
- }
-
- LocalTransactionState localTransactionState = LocalTransactionState.UNKNOW;
- Throwable localException = null;
- switch (sendResult.getSendStatus()) {
- case SEND_OK: {
- try {
- if (sendResult.getTransactionId() != null) {
- msg.putUserProperty("__transactionId__", sendResult.getTransactionId());
- }
- localTransactionState = tranExecuter.executeLocalTransactionBranch(msg, arg);
- if (null == localTransactionState) {
- localTransactionState = LocalTransactionState.UNKNOW;
- }
-
- if (localTransactionState != LocalTransactionState.COMMIT_MESSAGE) {
- log.info("executeLocalTransactionBranch return {}", localTransactionState);
- log.info(msg.toString());
- }
- } catch (Throwable e) {
- log.info("executeLocalTransactionBranch exception", e);
- log.info(msg.toString());
- localException = e;
- }
- }
- break;
- case FLUSH_DISK_TIMEOUT:
- case FLUSH_SLAVE_TIMEOUT:
- case SLAVE_NOT_AVAILABLE:
- localTransactionState = LocalTransactionState.ROLLBACK_MESSAGE;
- break;
- default:
- break;
- }
-
- try {
- this.endTransaction(sendResult, localTransactionState, localException);
- } catch (Exception e) {
- log.warn("local transaction execute " + localTransactionState + ", but end broker transaction failed", e);
- }
-
- TransactionSendResult transactionSendResult = new TransactionSendResult();
- transactionSendResult.setSendStatus(sendResult.getSendStatus());
- transactionSendResult.setMessageQueue(sendResult.getMessageQueue());
- transactionSendResult.setMsgId(sendResult.getMsgId());
- transactionSendResult.setQueueOffset(sendResult.getQueueOffset());
- transactionSendResult.setTransactionId(sendResult.getTransactionId());
- transactionSendResult.setLocalTransactionState(localTransactionState);
- return transactionSendResult;
- }
-
- /**
- * DEFAULT SYNC -------------------------------------------------------
- */
- public SendResult send(Message msg) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- return send(msg, this.defaultMQProducer.getSendMsgTimeout());
- }
-
- public void endTransaction(//
- final SendResult sendResult, //
- final LocalTransactionState localTransactionState, //
- final Throwable localException) throws RemotingException, MQBrokerException, InterruptedException, UnknownHostException {
- final MessageId id;
- if (sendResult.getOffsetMsgId() != null) {
- id = MessageDecoder.decodeMessageId(sendResult.getOffsetMsgId());
- } else {
- id = MessageDecoder.decodeMessageId(sendResult.getMsgId());
- }
- String transactionId = sendResult.getTransactionId();
- final String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(sendResult.getMessageQueue().getBrokerName());
- EndTransactionRequestHeader requestHeader = new EndTransactionRequestHeader();
- requestHeader.setTransactionId(transactionId);
- requestHeader.setCommitLogOffset(id.getOffset());
- switch (localTransactionState) {
- case COMMIT_MESSAGE:
- requestHeader.setCommitOrRollback(MessageSysFlag.TRANSACTION_COMMIT_TYPE);
- break;
- case ROLLBACK_MESSAGE:
- requestHeader.setCommitOrRollback(MessageSysFlag.TRANSACTION_ROLLBACK_TYPE);
- break;
- case UNKNOW:
- requestHeader.setCommitOrRollback(MessageSysFlag.TRANSACTION_NOT_TYPE);
- break;
- default:
- break;
- }
-
- requestHeader.setProducerGroup(this.defaultMQProducer.getProducerGroup());
- requestHeader.setTranStateTableOffset(sendResult.getQueueOffset());
- requestHeader.setMsgId(sendResult.getMsgId());
- String remark = localException != null ? ("executeLocalTransactionBranch exception: " + localException.toString()) : null;
- this.mQClientFactory.getMQClientAPIImpl().endTransactionOneway(brokerAddr, requestHeader, remark,
- this.defaultMQProducer.getSendMsgTimeout());
- }
-
- public SendResult send(Message msg, long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- return this.sendDefaultImpl(msg, CommunicationMode.SYNC, null, timeout);
- }
-
- public ConcurrentHashMap<String, TopicPublishInfo> getTopicPublishInfoTable() {
- return topicPublishInfoTable;
- }
-
- public int getZipCompressLevel() {
- return zipCompressLevel;
- }
-
-
- public void setZipCompressLevel(int zipCompressLevel) {
- this.zipCompressLevel = zipCompressLevel;
- }
-
-
- public ServiceState getServiceState() {
- return serviceState;
- }
-
-
- public void setServiceState(ServiceState serviceState) {
- this.serviceState = serviceState;
- }
-
- public long[] getNotAvailableDuration() {
- return this.mqFaultStrategy.getNotAvailableDuration();
- }
-
- public void setNotAvailableDuration(final long[] notAvailableDuration) {
- this.mqFaultStrategy.setNotAvailableDuration(notAvailableDuration);
- }
-
- public long[] getLatencyMax() {
- return this.mqFaultStrategy.getLatencyMax();
- }
-
- public void setLatencyMax(final long[] latencyMax) {
- this.mqFaultStrategy.setLatencyMax(latencyMax);
- }
-
- public boolean isSendLatencyFaultEnable() {
- return this.mqFaultStrategy.isSendLatencyFaultEnable();
- }
-
- public void setSendLatencyFaultEnable(final boolean sendLatencyFaultEnable) {
- this.mqFaultStrategy.setSendLatencyFaultEnable(sendLatencyFaultEnable);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/producer/MQProducerInner.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/producer/MQProducerInner.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/producer/MQProducerInner.java
deleted file mode 100644
index e2837e2..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/producer/MQProducerInner.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.client.impl.producer;
-
-import com.alibaba.rocketmq.client.producer.TransactionCheckListener;
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.protocol.header.CheckTransactionStateRequestHeader;
-
-import java.util.Set;
-
-
-/**
- * @author shijia.wxr
- */
-public interface MQProducerInner {
- Set<String> getPublishTopicList();
-
-
- boolean isPublishTopicNeedUpdate(final String topic);
-
-
- TransactionCheckListener checkListener();
-
-
- void checkTransactionState(//
- final String addr, //
- final MessageExt msg, //
- final CheckTransactionStateRequestHeader checkRequestHeader);
-
-
- void updateTopicPublishInfo(final String topic, final TopicPublishInfo info);
-
-
- boolean isUnitMode();
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/producer/TopicPublishInfo.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/producer/TopicPublishInfo.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/producer/TopicPublishInfo.java
deleted file mode 100644
index 2f7de22..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/producer/TopicPublishInfo.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * 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.client.impl.producer;
-
-import com.alibaba.rocketmq.client.common.ThreadLocalIndex;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.route.QueueData;
-import com.alibaba.rocketmq.common.protocol.route.TopicRouteData;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public class TopicPublishInfo {
- private boolean orderTopic = false;
- private boolean haveTopicRouterInfo = false;
- private List<MessageQueue> messageQueueList = new ArrayList<MessageQueue>();
- private volatile ThreadLocalIndex sendWhichQueue = new ThreadLocalIndex(0);
- private TopicRouteData topicRouteData;
-
-
- public boolean isOrderTopic() {
- return orderTopic;
- }
-
- public void setOrderTopic(boolean orderTopic) {
- this.orderTopic = orderTopic;
- }
-
- public boolean ok() {
- return null != this.messageQueueList && !this.messageQueueList.isEmpty();
- }
-
- public List<MessageQueue> getMessageQueueList() {
- return messageQueueList;
- }
-
-
- public void setMessageQueueList(List<MessageQueue> messageQueueList) {
- this.messageQueueList = messageQueueList;
- }
-
-
- public ThreadLocalIndex getSendWhichQueue() {
- return sendWhichQueue;
- }
-
-
- public void setSendWhichQueue(ThreadLocalIndex sendWhichQueue) {
- this.sendWhichQueue = sendWhichQueue;
- }
-
-
- public boolean isHaveTopicRouterInfo() {
- return haveTopicRouterInfo;
- }
-
-
- public void setHaveTopicRouterInfo(boolean haveTopicRouterInfo) {
- this.haveTopicRouterInfo = haveTopicRouterInfo;
- }
-
-
- public MessageQueue selectOneMessageQueue(final String lastBrokerName) {
- if (lastBrokerName == null) {
- return selectOneMessageQueue();
- } else {
- int index = this.sendWhichQueue.getAndIncrement();
- for (int i = 0; i < this.messageQueueList.size(); i++) {
- int pos = Math.abs(index++) % this.messageQueueList.size();
- if (pos < 0)
- pos = 0;
- MessageQueue mq = this.messageQueueList.get(pos);
- if (!mq.getBrokerName().equals(lastBrokerName)) {
- return mq;
- }
- }
- return selectOneMessageQueue();
- }
- }
-
-
- public MessageQueue selectOneMessageQueue() {
- int index = this.sendWhichQueue.getAndIncrement();
- int pos = Math.abs(index) % this.messageQueueList.size();
- if (pos < 0)
- pos = 0;
- return this.messageQueueList.get(pos);
- }
-
- public int getQueueIdByBroker(final String brokerName) {
- for (int i = 0; i < topicRouteData.getQueueDatas().size(); i++) {
- final QueueData queueData = this.topicRouteData.getQueueDatas().get(i);
- if (queueData.getBrokerName().equals(brokerName)) {
- return queueData.getWriteQueueNums();
- }
- }
-
- return -1;
- }
-
-
- @Override
- public String toString() {
- return "TopicPublishInfo [orderTopic=" + orderTopic + ", messageQueueList=" + messageQueueList
- + ", sendWhichQueue=" + sendWhichQueue + ", haveTopicRouterInfo=" + haveTopicRouterInfo + "]";
- }
-
- public TopicRouteData getTopicRouteData() {
- return topicRouteData;
- }
-
- public void setTopicRouteData(final TopicRouteData topicRouteData) {
- this.topicRouteData = topicRouteData;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/latency/LatencyFaultTolerance.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/latency/LatencyFaultTolerance.java b/client/src/main/java/com/alibaba/rocketmq/client/latency/LatencyFaultTolerance.java
deleted file mode 100644
index e6152e4..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/latency/LatencyFaultTolerance.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * 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.client.latency;
-
-/**
- * @author shijia.wxr
- */
-public interface LatencyFaultTolerance<T> {
- void updateFaultItem(final T name, final long currentLatency, final long notAvailableDuration);
-
- boolean isAvailable(final T name);
-
- void remove(final T name);
-
- T pickOneAtLeast();
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/latency/LatencyFaultToleranceImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/latency/LatencyFaultToleranceImpl.java b/client/src/main/java/com/alibaba/rocketmq/client/latency/LatencyFaultToleranceImpl.java
deleted file mode 100644
index 8a86449..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/latency/LatencyFaultToleranceImpl.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/**
- * 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.client.latency;
-
-import com.alibaba.rocketmq.client.common.ThreadLocalIndex;
-
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * @author shijia.wxr
- */
-public class LatencyFaultToleranceImpl implements LatencyFaultTolerance<String> {
- private final ConcurrentHashMap<String, FaultItem> faultItemTable = new ConcurrentHashMap<String, FaultItem>(16);
-
- private final ThreadLocalIndex whichItemWorst = new ThreadLocalIndex(0);
-
- @Override
- public void updateFaultItem(final String name, final long currentLatency, final long notAvailableDuration) {
- FaultItem old = this.faultItemTable.get(name);
- if (null == old) {
- final FaultItem faultItem = new FaultItem(name);
- faultItem.setCurrentLatency(currentLatency);
- faultItem.setStartTimestamp(System.currentTimeMillis() + notAvailableDuration);
-
- old = this.faultItemTable.putIfAbsent(name, faultItem);
- if (old != null) {
- old.setCurrentLatency(currentLatency);
- old.setStartTimestamp(System.currentTimeMillis() + notAvailableDuration);
- }
- } else {
- old.setCurrentLatency(currentLatency);
- old.setStartTimestamp(System.currentTimeMillis() + notAvailableDuration);
- }
- }
-
- @Override
- public boolean isAvailable(final String name) {
- final FaultItem faultItem = this.faultItemTable.get(name);
- if (faultItem != null) {
- return faultItem.isAvailable();
- }
- return true;
- }
-
- @Override
- public void remove(final String name) {
- this.faultItemTable.remove(name);
- }
-
- @Override
- public String pickOneAtLeast() {
- final Enumeration<FaultItem> elements = this.faultItemTable.elements();
- List<FaultItem> tmpList = new LinkedList<FaultItem>();
- while (elements.hasMoreElements()) {
- final FaultItem faultItem = elements.nextElement();
- tmpList.add(faultItem);
- }
-
- if (!tmpList.isEmpty()) {
- Collections.shuffle(tmpList);
-
- Collections.sort(tmpList);
-
- final int half = tmpList.size() / 2;
- if (half <= 0) {
- return tmpList.get(0).getName();
- } else {
- final int i = this.whichItemWorst.getAndIncrement() % half;
- return tmpList.get(i).getName();
- }
- }
-
- return null;
- }
-
- class FaultItem implements Comparable<FaultItem> {
- private final String name;
- private volatile long currentLatency;
- private volatile long startTimestamp;
-
- public FaultItem(final String name) {
- this.name = name;
- }
-
- @Override
- public int compareTo(final FaultItem other) {
- if (this.isAvailable() != other.isAvailable()) {
- if (this.isAvailable()) return -1;
-
- if (other.isAvailable()) return 1;
- }
-
- if (this.currentLatency < other.currentLatency)
- return -1;
- else if (this.currentLatency > other.currentLatency) {
- return 1;
- }
-
- if (this.startTimestamp < other.startTimestamp)
- return -1;
- else if (this.startTimestamp > other.startTimestamp) {
- return 1;
- }
-
- return 0;
- }
-
- public boolean isAvailable() {
- return (System.currentTimeMillis() - startTimestamp) >= 0;
- }
-
- @Override
- public int hashCode() {
- int result = getName() != null ? getName().hashCode() : 0;
- result = 31 * result + (int) (getCurrentLatency() ^ (getCurrentLatency() >>> 32));
- result = 31 * result + (int) (getStartTimestamp() ^ (getStartTimestamp() >>> 32));
- return result;
- }
-
- @Override
- public boolean equals(final Object o) {
- if (this == o) return true;
- if (!(o instanceof FaultItem)) return false;
-
- final FaultItem faultItem = (FaultItem) o;
-
- if (getCurrentLatency() != faultItem.getCurrentLatency()) return false;
- if (getStartTimestamp() != faultItem.getStartTimestamp()) return false;
- return getName() != null ? getName().equals(faultItem.getName()) : faultItem.getName() == null;
-
- }
-
- @Override
- public String toString() {
- return "FaultItem{" +
- "name='" + name + '\'' +
- ", currentLatency=" + currentLatency +
- ", startTimestamp=" + startTimestamp +
- '}';
- }
-
- public String getName() {
- return name;
- }
-
- public long getCurrentLatency() {
- return currentLatency;
- }
-
- public void setCurrentLatency(final long currentLatency) {
- this.currentLatency = currentLatency;
- }
-
- public long getStartTimestamp() {
- return startTimestamp;
- }
-
- public void setStartTimestamp(final long startTimestamp) {
- this.startTimestamp = startTimestamp;
- }
-
-
- }
-
- @Override
- public String toString() {
- return "LatencyFaultToleranceImpl{" +
- "faultItemTable=" + faultItemTable +
- ", whichItemWorst=" + whichItemWorst +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/latency/MQFaultStrategy.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/latency/MQFaultStrategy.java b/client/src/main/java/com/alibaba/rocketmq/client/latency/MQFaultStrategy.java
deleted file mode 100644
index b323f04..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/latency/MQFaultStrategy.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * 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.client.latency;
-
-import com.alibaba.rocketmq.client.impl.producer.TopicPublishInfo;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-/**
- * @author shijia.wxr
- */
-public class MQFaultStrategy {
- private final LatencyFaultTolerance<String> latencyFaultTolerance = new LatencyFaultToleranceImpl();
-
- private boolean sendLatencyFaultEnable = false;
-
- private long[] latencyMax = {50L, 100L, 550L, 1000L, 2000L, 3000L, 15000L};
- private long[] notAvailableDuration = {0L, 0L, 30000L, 60000L, 120000L, 180000L, 600000L};
-
- public long[] getNotAvailableDuration() {
- return notAvailableDuration;
- }
-
- public void setNotAvailableDuration(final long[] notAvailableDuration) {
- this.notAvailableDuration = notAvailableDuration;
- }
-
- public long[] getLatencyMax() {
- return latencyMax;
- }
-
- public void setLatencyMax(final long[] latencyMax) {
- this.latencyMax = latencyMax;
- }
-
- public boolean isSendLatencyFaultEnable() {
- return sendLatencyFaultEnable;
- }
-
- public void setSendLatencyFaultEnable(final boolean sendLatencyFaultEnable) {
- this.sendLatencyFaultEnable = sendLatencyFaultEnable;
- }
-
- public MessageQueue selectOneMessageQueue(final TopicPublishInfo tpInfo, final String lastBrokerName) {
- if (this.sendLatencyFaultEnable) {
- try {
- int index = tpInfo.getSendWhichQueue().getAndIncrement();
- for (int i = 0; i < tpInfo.getMessageQueueList().size(); i++) {
- int pos = Math.abs(index++) % tpInfo.getMessageQueueList().size();
- if (pos < 0)
- pos = 0;
- MessageQueue mq = tpInfo.getMessageQueueList().get(pos);
- if (latencyFaultTolerance.isAvailable(mq.getBrokerName())) {
- if (null == lastBrokerName || mq.getBrokerName().equals(lastBrokerName))
- return mq;
- }
- }
-
- final String notBestBroker = latencyFaultTolerance.pickOneAtLeast();
- int writeQueueNums = tpInfo.getQueueIdByBroker(notBestBroker);
- if (writeQueueNums > 0) {
- final MessageQueue mq = tpInfo.selectOneMessageQueue();
- if (notBestBroker != null) {
- mq.setBrokerName(notBestBroker);
- mq.setQueueId(tpInfo.getSendWhichQueue().getAndIncrement() % writeQueueNums);
- }
- return mq;
- } else {
- latencyFaultTolerance.remove(notBestBroker);
- }
- } catch (Exception e) {
- }
-
- return tpInfo.selectOneMessageQueue();
- }
-
- return tpInfo.selectOneMessageQueue(lastBrokerName);
- }
-
- public void updateFaultItem(final String brokerName, final long currentLatency, boolean isolation) {
- if (this.sendLatencyFaultEnable) {
- long duration = computeNotAvailableDuration(isolation ? 30000 : currentLatency);
- this.latencyFaultTolerance.updateFaultItem(brokerName, currentLatency, duration);
- }
- }
-
- private long computeNotAvailableDuration(final long currentLatency) {
- for (int i = latencyMax.length - 1; i >= 0; i--) {
- if (currentLatency >= latencyMax[i]) return this.notAvailableDuration[i];
- }
-
- return 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/log/ClientLogger.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/log/ClientLogger.java b/client/src/main/java/com/alibaba/rocketmq/client/log/ClientLogger.java
deleted file mode 100644
index 02af207..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/log/ClientLogger.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- * 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.client.log;
-
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import org.slf4j.ILoggerFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Method;
-import java.net.URL;
-
-
-/**
- * @author shijia.wxr
- */
-public class ClientLogger {
- private static Logger log;
- public static final String CLIENT_LOG_ROOT = "rocketmq.client.logRoot";
- public static final String CLIENT_LOG_MAXINDEX = "rocketmq.client.logFileMaxIndex";
- public static final String CLIENT_LOG_LEVEL = "rocketmq.client.logLevel";
-
- static {
- log = createLogger(LoggerName.CLIENT_LOGGER_NAME);
- }
-
-
- private static Logger createLogger(final String loggerName) {
- String logConfigFilePath =
- System.getProperty("rocketmq.client.log.configFile",
- System.getenv("ROCKETMQ_CLIENT_LOG_CONFIGFILE"));
- Boolean isloadconfig =
- Boolean.parseBoolean(System.getProperty("rocketmq.client.log.loadconfig", "true"));
-
- final String log4JResourceFile =
- System.getProperty("rocketmq.client.log4j.resource.fileName", "log4j_rocketmq_client.xml");
-
- final String logbackResourceFile =
- System.getProperty("rocketmq.client.logback.resource.fileName", "logback_rocketmq_client.xml");
-
- String clientLogRoot = System.getProperty(CLIENT_LOG_ROOT, "${user.home}/logs/rocketmqlogs");
- System.setProperty("client.logRoot", clientLogRoot);
- String clientLogLevel = System.getProperty(CLIENT_LOG_LEVEL, "INFO");
- System.setProperty("client.logLevel", clientLogLevel);
- String clientLogMaxIndex = System.getProperty(CLIENT_LOG_MAXINDEX, "10");
- System.setProperty("client.logFileMaxIndex", clientLogMaxIndex);
-
- if (isloadconfig) {
- try {
- ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory();
- Class classType = iLoggerFactory.getClass();
- if (classType.getName().equals("org.slf4j.impl.Log4jLoggerFactory")) {
- Class<?> domconfigurator;
- Object domconfiguratorobj;
- domconfigurator = Class.forName("org.apache.log4j.xml.DOMConfigurator");
- domconfiguratorobj = domconfigurator.newInstance();
- if (null == logConfigFilePath) {
- Method configure = domconfiguratorobj.getClass().getMethod("configure", URL.class);
- URL url = ClientLogger.class.getClassLoader().getResource(log4JResourceFile);
- configure.invoke(domconfiguratorobj, url);
- } else {
- Method configure = domconfiguratorobj.getClass().getMethod("configure", String.class);
- configure.invoke(domconfiguratorobj, logConfigFilePath);
- }
-
- } else if (classType.getName().equals("ch.qos.logback.classic.LoggerContext")) {
- Class<?> joranConfigurator;
- Class<?> context = Class.forName("ch.qos.logback.core.Context");
- Object joranConfiguratoroObj;
- joranConfigurator = Class.forName("ch.qos.logback.classic.joran.JoranConfigurator");
- joranConfiguratoroObj = joranConfigurator.newInstance();
- Method setContext = joranConfiguratoroObj.getClass().getMethod("setContext", context);
- setContext.invoke(joranConfiguratoroObj, iLoggerFactory);
- if (null == logConfigFilePath) {
- URL url = ClientLogger.class.getClassLoader().getResource(logbackResourceFile);
- Method doConfigure =
- joranConfiguratoroObj.getClass().getMethod("doConfigure", URL.class);
- doConfigure.invoke(joranConfiguratoroObj, url);
- } else {
- Method doConfigure =
- joranConfiguratoroObj.getClass().getMethod("doConfigure", String.class);
- doConfigure.invoke(joranConfiguratoroObj, logConfigFilePath);
- }
-
- }
- } catch (Exception e) {
- System.err.println(e);
- }
- }
- return LoggerFactory.getLogger(LoggerName.CLIENT_LOGGER_NAME);
- }
-
-
- public static Logger getLog() {
- return log;
- }
-
-
- public static void setLog(Logger log) {
- ClientLogger.log = log;
- }
-}
[44/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
new file mode 100644
index 0000000..1749e91
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
@@ -0,0 +1,266 @@
+/**
+ * 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.broker;
+
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.joran.JoranConfigurator;
+import org.apache.rocketmq.common.BrokerConfig;
+import org.apache.rocketmq.common.MQVersion;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.remoting.common.RemotingUtil;
+import org.apache.rocketmq.remoting.netty.NettyClientConfig;
+import org.apache.rocketmq.remoting.netty.NettyServerConfig;
+import org.apache.rocketmq.remoting.netty.NettySystemConfig;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.apache.rocketmq.srvutil.ServerUtil;
+import org.apache.rocketmq.store.config.BrokerRole;
+import org.apache.rocketmq.store.config.MessageStoreConfig;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.PosixParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class BrokerStartup {
+ public static Properties properties = null;
+ public static CommandLine commandLine = null;
+ public static String configFile = null;
+ public static Logger log;
+
+ public static void main(String[] args) {
+ start(createBrokerController(args));
+ }
+
+ public static BrokerController start(BrokerController controller) {
+ try {
+ controller.start();
+ String tip = "The broker[" + controller.getBrokerConfig().getBrokerName() + ", "
+ + controller.getBrokerAddr() + "] boot success. serializeType=" + RemotingCommand.getSerializeTypeConfigInThisServer();
+
+ if (null != controller.getBrokerConfig().getNamesrvAddr()) {
+ tip += " and name server is " + controller.getBrokerConfig().getNamesrvAddr();
+ }
+
+ log.info(tip);
+ return controller;
+ } catch (Throwable e) {
+ e.printStackTrace();
+ System.exit(-1);
+ }
+
+ return null;
+ }
+
+ public static BrokerController createBrokerController(String[] args) {
+ System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));
+
+ if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE)) {
+ NettySystemConfig.socketSndbufSize = 131072;
+ }
+
+ if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE)) {
+ NettySystemConfig.socketRcvbufSize = 131072;
+ }
+
+ try {
+ //PackageConflictDetect.detectFastjson();
+ Options options = ServerUtil.buildCommandlineOptions(new Options());
+ commandLine = ServerUtil.parseCmdLine("mqbroker", args, buildCommandlineOptions(options),
+ new PosixParser());
+ if (null == commandLine) {
+ System.exit(-1);
+ }
+
+ final BrokerConfig brokerConfig = new BrokerConfig();
+ final NettyServerConfig nettyServerConfig = new NettyServerConfig();
+ final NettyClientConfig nettyClientConfig = new NettyClientConfig();
+ nettyServerConfig.setListenPort(10911);
+ final MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
+
+ if (BrokerRole.SLAVE == messageStoreConfig.getBrokerRole()) {
+ int ratio = messageStoreConfig.getAccessMessageInMemoryMaxRatio() - 10;
+ messageStoreConfig.setAccessMessageInMemoryMaxRatio(ratio);
+ }
+
+ if (commandLine.hasOption('p')) {
+ MixAll.printObjectProperties(null, brokerConfig);
+ MixAll.printObjectProperties(null, nettyServerConfig);
+ MixAll.printObjectProperties(null, nettyClientConfig);
+ MixAll.printObjectProperties(null, messageStoreConfig);
+ System.exit(0);
+ } else if (commandLine.hasOption('m')) {
+ MixAll.printObjectProperties(null, brokerConfig, true);
+ MixAll.printObjectProperties(null, nettyServerConfig, true);
+ MixAll.printObjectProperties(null, nettyClientConfig, true);
+ MixAll.printObjectProperties(null, messageStoreConfig, true);
+ System.exit(0);
+ }
+
+ if (commandLine.hasOption('c')) {
+ String file = commandLine.getOptionValue('c');
+ if (file != null) {
+ configFile = file;
+ InputStream in = new BufferedInputStream(new FileInputStream(file));
+ properties = new Properties();
+ properties.load(in);
+
+ parsePropertie2SystemEnv(properties);
+ MixAll.properties2Object(properties, brokerConfig);
+ MixAll.properties2Object(properties, nettyServerConfig);
+ MixAll.properties2Object(properties, nettyClientConfig);
+ MixAll.properties2Object(properties, messageStoreConfig);
+
+ BrokerPathConfigHelper.setBrokerConfigPath(file);
+ in.close();
+ }
+ }
+
+ MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), brokerConfig);
+
+ if (null == brokerConfig.getRocketmqHome()) {
+ System.out.printf("Please set the " + MixAll.ROCKETMQ_HOME_ENV
+ + " variable in your environment to match the location of the RocketMQ installation");
+ System.exit(-2);
+ }
+
+ String namesrvAddr = brokerConfig.getNamesrvAddr();
+ if (null != namesrvAddr) {
+ try {
+ String[] addrArray = namesrvAddr.split(";");
+ if (addrArray != null) {
+ for (String addr : addrArray) {
+ RemotingUtil.string2SocketAddress(addr);
+ }
+ }
+ } catch (Exception e) {
+ System.out.printf(
+ "The Name Server Address[%s] illegal, please set it as follows, \"127.0.0.1:9876;192.168.0.1:9876\"%n",
+ namesrvAddr);
+ System.exit(-3);
+ }
+ }
+
+
+ switch (messageStoreConfig.getBrokerRole()) {
+ case ASYNC_MASTER:
+ case SYNC_MASTER:
+ brokerConfig.setBrokerId(MixAll.MASTER_ID);
+ break;
+ case SLAVE:
+ if (brokerConfig.getBrokerId() <= 0) {
+ System.out.printf("Slave's brokerId must be > 0");
+ System.exit(-3);
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ messageStoreConfig.setHaListenPort(nettyServerConfig.getListenPort() + 1);
+ LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+ JoranConfigurator configurator = new JoranConfigurator();
+ configurator.setContext(lc);
+ lc.reset();
+ configurator.doConfigure(brokerConfig.getRocketmqHome() + "/conf/logback_broker.xml");
+ log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+
+ MixAll.printObjectProperties(log, brokerConfig);
+ MixAll.printObjectProperties(log, nettyServerConfig);
+ MixAll.printObjectProperties(log, nettyClientConfig);
+ MixAll.printObjectProperties(log, messageStoreConfig);
+
+ final BrokerController controller = new BrokerController(//
+ brokerConfig, //
+ nettyServerConfig, //
+ nettyClientConfig, //
+ messageStoreConfig);
+ // remember all configs to prevent discard
+ controller.getConfiguration().registerConfig(properties);
+
+ boolean initResult = controller.initialize();
+ if (!initResult) {
+ controller.shutdown();
+ System.exit(-3);
+ }
+
+ Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
+ private volatile boolean hasShutdown = false;
+ private AtomicInteger shutdownTimes = new AtomicInteger(0);
+
+ @Override
+ public void run() {
+ synchronized (this) {
+ log.info("shutdown hook was invoked, " + this.shutdownTimes.incrementAndGet());
+ if (!this.hasShutdown) {
+ this.hasShutdown = true;
+ long begineTime = System.currentTimeMillis();
+ controller.shutdown();
+ long consumingTimeTotal = System.currentTimeMillis() - begineTime;
+ log.info("shutdown hook over, consuming time total(ms): " + consumingTimeTotal);
+ }
+ }
+ }
+ }, "ShutdownHook"));
+
+ return controller;
+ } catch (Throwable e) {
+ e.printStackTrace();
+ System.exit(-1);
+ }
+
+ return null;
+ }
+
+ private static void parsePropertie2SystemEnv(Properties properties) {
+ if (properties == null) {
+ return;
+ }
+ String rmqAddressServerDomain = properties.getProperty("rmqAddressServerDomain", "jmenv.tbsite.net");
+ String rmqAddressServerSubGroup = properties.getProperty("rmqAddressServerSubGroup", "nsaddr");
+ System.setProperty("rocketmq.namesrv.domain", rmqAddressServerDomain);
+ System.setProperty("rocketmq.namesrv.domain.subgroup", rmqAddressServerSubGroup);
+ }
+
+ public static Options buildCommandlineOptions(final Options options) {
+ Option opt = new Option("c", "configFile", true, "Broker config properties file");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+ opt = new Option("p", "printConfigItem", false, "Print all config item");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+ opt = new Option("m", "printImportantConfig", false, "Print important config item");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+ return options;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
new file mode 100644
index 0000000..e15a22a
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
@@ -0,0 +1,115 @@
+/**
+ * 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.broker.client;
+
+import org.apache.rocketmq.remoting.protocol.LanguageCode;
+import io.netty.channel.Channel;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ClientChannelInfo {
+ private final Channel channel;
+ private final String clientId;
+ private final LanguageCode language;
+ private final int version;
+ private volatile long lastUpdateTimestamp = System.currentTimeMillis();
+
+
+ public ClientChannelInfo(Channel channel) {
+ this(channel, null, null, 0);
+ }
+
+
+ public ClientChannelInfo(Channel channel, String clientId, LanguageCode language, int version) {
+ this.channel = channel;
+ this.clientId = clientId;
+ this.language = language;
+ this.version = version;
+ }
+
+
+ public Channel getChannel() {
+ return channel;
+ }
+
+
+ public String getClientId() {
+ return clientId;
+ }
+
+
+ public LanguageCode getLanguage() {
+ return language;
+ }
+
+
+ public int getVersion() {
+ return version;
+ }
+
+
+ public long getLastUpdateTimestamp() {
+ return lastUpdateTimestamp;
+ }
+
+
+ public void setLastUpdateTimestamp(long lastUpdateTimestamp) {
+ this.lastUpdateTimestamp = lastUpdateTimestamp;
+ }
+
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((channel == null) ? 0 : channel.hashCode());
+ result = prime * result + ((clientId == null) ? 0 : clientId.hashCode());
+ result = prime * result + ((language == null) ? 0 : language.hashCode());
+ result = prime * result + (int) (lastUpdateTimestamp ^ (lastUpdateTimestamp >>> 32));
+ result = prime * result + version;
+ return result;
+ }
+
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ClientChannelInfo other = (ClientChannelInfo) obj;
+ if (channel == null) {
+ if (other.channel != null)
+ return false;
+ } else if (this.channel != other.channel) {
+ return false;
+ }
+
+ return true;
+ }
+
+
+ @Override
+ public String toString() {
+ return "ClientChannelInfo [channel=" + channel + ", clientId=" + clientId + ", language=" + language
+ + ", version=" + version + ", lastUpdateTimestamp=" + lastUpdateTimestamp + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java
new file mode 100644
index 0000000..2d1ad9b
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java
@@ -0,0 +1,100 @@
+/**
+ * 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.broker.client;
+
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.common.ThreadFactoryImpl;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.remoting.ChannelEventListener;
+import io.netty.channel.Channel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ClientHousekeepingService implements ChannelEventListener {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+ private final BrokerController brokerController;
+
+ private ScheduledExecutorService scheduledExecutorService = Executors
+ .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ClientHousekeepingScheduledThread"));
+
+
+ public ClientHousekeepingService(final BrokerController brokerController) {
+ this.brokerController = brokerController;
+ }
+
+
+ public void start() {
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ ClientHousekeepingService.this.scanExceptionChannel();
+ } catch (Exception e) {
+ log.error("", e);
+ }
+ }
+ }, 1000 * 10, 1000 * 10, TimeUnit.MILLISECONDS);
+ }
+
+ private void scanExceptionChannel() {
+ this.brokerController.getProducerManager().scanNotActiveChannel();
+ this.brokerController.getConsumerManager().scanNotActiveChannel();
+ this.brokerController.getFilterServerManager().scanNotActiveChannel();
+ }
+
+ public void shutdown() {
+ this.scheduledExecutorService.shutdown();
+ }
+
+ @Override
+ public void onChannelConnect(String remoteAddr, Channel channel) {
+
+ }
+
+
+ @Override
+ public void onChannelClose(String remoteAddr, Channel channel) {
+ this.brokerController.getProducerManager().doChannelCloseEvent(remoteAddr, channel);
+ this.brokerController.getConsumerManager().doChannelCloseEvent(remoteAddr, channel);
+ this.brokerController.getFilterServerManager().doChannelCloseEvent(remoteAddr, channel);
+ }
+
+
+ @Override
+ public void onChannelException(String remoteAddr, Channel channel) {
+ this.brokerController.getProducerManager().doChannelCloseEvent(remoteAddr, channel);
+ this.brokerController.getConsumerManager().doChannelCloseEvent(remoteAddr, channel);
+ this.brokerController.getFilterServerManager().doChannelCloseEvent(remoteAddr, channel);
+ }
+
+
+ @Override
+ public void onChannelIdle(String remoteAddr, Channel channel) {
+ this.brokerController.getProducerManager().doChannelCloseEvent(remoteAddr, channel);
+ this.brokerController.getConsumerManager().doChannelCloseEvent(remoteAddr, channel);
+ this.brokerController.getFilterServerManager().doChannelCloseEvent(remoteAddr, channel);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java
new file mode 100644
index 0000000..10795f5
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java
@@ -0,0 +1,273 @@
+/**
+ * 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.broker.client;
+
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
+import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
+import io.netty.channel.Channel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ConsumerGroupInfo {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+ private final String groupName;
+ private final ConcurrentHashMap<String/* Topic */, SubscriptionData> subscriptionTable =
+ new ConcurrentHashMap<String, SubscriptionData>();
+ private final ConcurrentHashMap<Channel, ClientChannelInfo> channelInfoTable =
+ new ConcurrentHashMap<Channel, ClientChannelInfo>(16);
+ private volatile ConsumeType consumeType;
+ private volatile MessageModel messageModel;
+ private volatile ConsumeFromWhere consumeFromWhere;
+ private volatile long lastUpdateTimestamp = System.currentTimeMillis();
+
+
+ public ConsumerGroupInfo(String groupName, ConsumeType consumeType, MessageModel messageModel,
+ ConsumeFromWhere consumeFromWhere) {
+ this.groupName = groupName;
+ this.consumeType = consumeType;
+ this.messageModel = messageModel;
+ this.consumeFromWhere = consumeFromWhere;
+ }
+
+
+ public ClientChannelInfo findChannel(final String clientId) {
+ Iterator<Entry<Channel, ClientChannelInfo>> it = this.channelInfoTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<Channel, ClientChannelInfo> next = it.next();
+ if (next.getValue().getClientId().equals(clientId)) {
+ return next.getValue();
+ }
+ }
+
+ return null;
+ }
+
+
+ public ConcurrentHashMap<String, SubscriptionData> getSubscriptionTable() {
+ return subscriptionTable;
+ }
+
+
+ public ConcurrentHashMap<Channel, ClientChannelInfo> getChannelInfoTable() {
+ return channelInfoTable;
+ }
+
+
+ public List<Channel> getAllChannel() {
+ List<Channel> result = new ArrayList<Channel>();
+
+ result.addAll(this.channelInfoTable.keySet());
+
+ return result;
+ }
+
+
+ public List<String> getAllClientId() {
+ List<String> result = new ArrayList<String>();
+
+ Iterator<Entry<Channel, ClientChannelInfo>> it = this.channelInfoTable.entrySet().iterator();
+
+ while (it.hasNext()) {
+ Entry<Channel, ClientChannelInfo> entry = it.next();
+ ClientChannelInfo clientChannelInfo = entry.getValue();
+ result.add(clientChannelInfo.getClientId());
+ }
+
+ return result;
+ }
+
+
+ public void unregisterChannel(final ClientChannelInfo clientChannelInfo) {
+ ClientChannelInfo old = this.channelInfoTable.remove(clientChannelInfo.getChannel());
+ if (old != null) {
+ log.info("unregister a consumer[{}] from consumerGroupInfo {}", this.groupName, old.toString());
+ }
+ }
+
+
+ public boolean doChannelCloseEvent(final String remoteAddr, final Channel channel) {
+ final ClientChannelInfo info = this.channelInfoTable.remove(channel);
+ if (info != null) {
+ log.warn(
+ "NETTY EVENT: remove not active channel[{}] from ConsumerGroupInfo groupChannelTable, consumer group: {}",
+ info.toString(), groupName);
+ return true;
+ }
+
+ return false;
+ }
+
+ public boolean updateChannel(final ClientChannelInfo infoNew, ConsumeType consumeType,
+ MessageModel messageModel, ConsumeFromWhere consumeFromWhere) {
+ boolean updated = false;
+ this.consumeType = consumeType;
+ this.messageModel = messageModel;
+ this.consumeFromWhere = consumeFromWhere;
+
+ ClientChannelInfo infoOld = this.channelInfoTable.get(infoNew.getChannel());
+ if (null == infoOld) {
+ ClientChannelInfo prev = this.channelInfoTable.put(infoNew.getChannel(), infoNew);
+ if (null == prev) {
+ log.info("new consumer connected, group: {} {} {} channel: {}", this.groupName, consumeType,
+ messageModel, infoNew.toString());
+ updated = true;
+ }
+
+ infoOld = infoNew;
+ } else {
+ if (!infoOld.getClientId().equals(infoNew.getClientId())) {
+ log.error("[BUG] consumer channel exist in broker, but clientId not equal. GROUP: {} OLD: {} NEW: {} ",
+ this.groupName,
+ infoOld.toString(),
+ infoNew.toString());
+ this.channelInfoTable.put(infoNew.getChannel(), infoNew);
+ }
+ }
+
+ this.lastUpdateTimestamp = System.currentTimeMillis();
+ infoOld.setLastUpdateTimestamp(this.lastUpdateTimestamp);
+
+ return updated;
+ }
+
+
+ public boolean updateSubscription(final Set<SubscriptionData> subList) {
+ boolean updated = false;
+
+ for (SubscriptionData sub : subList) {
+ SubscriptionData old = this.subscriptionTable.get(sub.getTopic());
+ if (old == null) {
+ SubscriptionData prev = this.subscriptionTable.putIfAbsent(sub.getTopic(), sub);
+ if (null == prev) {
+ updated = true;
+ log.info("subscription changed, add new topic, group: {} {}",
+ this.groupName,
+ sub.toString());
+ }
+ } else if (sub.getSubVersion() > old.getSubVersion()) {
+ if (this.consumeType == ConsumeType.CONSUME_PASSIVELY) {
+ log.info("subscription changed, group: {} OLD: {} NEW: {}",
+ this.groupName,
+ old.toString(),
+ sub.toString()
+ );
+ }
+
+ this.subscriptionTable.put(sub.getTopic(), sub);
+ }
+ }
+
+
+ Iterator<Entry<String, SubscriptionData>> it = this.subscriptionTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, SubscriptionData> next = it.next();
+ String oldTopic = next.getKey();
+
+ boolean exist = false;
+ for (SubscriptionData sub : subList) {
+ if (sub.getTopic().equals(oldTopic)) {
+ exist = true;
+ break;
+ }
+ }
+
+ if (!exist) {
+ log.warn("subscription changed, group: {} remove topic {} {}",
+ this.groupName,
+ oldTopic,
+ next.getValue().toString()
+ );
+
+ it.remove();
+ updated = true;
+ }
+ }
+
+ this.lastUpdateTimestamp = System.currentTimeMillis();
+
+ return updated;
+ }
+
+
+ public Set<String> getSubscribeTopics() {
+ return subscriptionTable.keySet();
+ }
+
+
+ public SubscriptionData findSubscriptionData(final String topic) {
+ return this.subscriptionTable.get(topic);
+ }
+
+
+ public ConsumeType getConsumeType() {
+ return consumeType;
+ }
+
+
+ public void setConsumeType(ConsumeType consumeType) {
+ this.consumeType = consumeType;
+ }
+
+
+ public MessageModel getMessageModel() {
+ return messageModel;
+ }
+
+
+ public void setMessageModel(MessageModel messageModel) {
+ this.messageModel = messageModel;
+ }
+
+
+ public String getGroupName() {
+ return groupName;
+ }
+
+
+ public long getLastUpdateTimestamp() {
+ return lastUpdateTimestamp;
+ }
+
+
+ public void setLastUpdateTimestamp(long lastUpdateTimestamp) {
+ this.lastUpdateTimestamp = lastUpdateTimestamp;
+ }
+
+
+ public ConsumeFromWhere getConsumeFromWhere() {
+ return consumeFromWhere;
+ }
+
+
+ public void setConsumeFromWhere(ConsumeFromWhere consumeFromWhere) {
+ this.consumeFromWhere = consumeFromWhere;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java
new file mode 100644
index 0000000..e8d23db
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java
@@ -0,0 +1,29 @@
+/**
+ * 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.broker.client;
+
+import io.netty.channel.Channel;
+
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public interface ConsumerIdsChangeListener {
+ public void consumerIdsChanged(final String group, final List<Channel> channels);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java
new file mode 100644
index 0000000..561fec6
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java
@@ -0,0 +1,187 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.broker.client;
+
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
+import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.common.RemotingUtil;
+import io.netty.channel.Channel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ConsumerManager {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+ private static final long CHANNEL_EXPIRED_TIMEOUT = 1000 * 120;
+ private final ConcurrentHashMap<String/* Group */, ConsumerGroupInfo> consumerTable =
+ new ConcurrentHashMap<String, ConsumerGroupInfo>(1024);
+ private final ConsumerIdsChangeListener consumerIdsChangeListener;
+
+ public ConsumerManager(final ConsumerIdsChangeListener consumerIdsChangeListener) {
+ this.consumerIdsChangeListener = consumerIdsChangeListener;
+ }
+
+ public ClientChannelInfo findChannel(final String group, final String clientId) {
+ ConsumerGroupInfo consumerGroupInfo = this.consumerTable.get(group);
+ if (consumerGroupInfo != null) {
+ return consumerGroupInfo.findChannel(clientId);
+ }
+ return null;
+ }
+
+ public SubscriptionData findSubscriptionData(final String group, final String topic) {
+ ConsumerGroupInfo consumerGroupInfo = this.getConsumerGroupInfo(group);
+ if (consumerGroupInfo != null) {
+ return consumerGroupInfo.findSubscriptionData(topic);
+ }
+
+ return null;
+ }
+
+ public ConsumerGroupInfo getConsumerGroupInfo(final String group) {
+ return this.consumerTable.get(group);
+ }
+
+ public int findSubscriptionDataCount(final String group) {
+ ConsumerGroupInfo consumerGroupInfo = this.getConsumerGroupInfo(group);
+ if (consumerGroupInfo != null) {
+ return consumerGroupInfo.getSubscriptionTable().size();
+ }
+
+ return 0;
+ }
+
+ public void doChannelCloseEvent(final String remoteAddr, final Channel channel) {
+ Iterator<Entry<String, ConsumerGroupInfo>> it = this.consumerTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, ConsumerGroupInfo> next = it.next();
+ ConsumerGroupInfo info = next.getValue();
+ boolean removed = info.doChannelCloseEvent(remoteAddr, channel);
+ if (removed) {
+ if (info.getChannelInfoTable().isEmpty()) {
+ ConsumerGroupInfo remove = this.consumerTable.remove(next.getKey());
+ if (remove != null) {
+ log.info("unregister consumer ok, no any connection, and remove consumer group, {}",
+ next.getKey());
+ }
+ }
+
+ this.consumerIdsChangeListener.consumerIdsChanged(next.getKey(), info.getAllChannel());
+ }
+ }
+ }
+
+ public boolean registerConsumer(final String group, final ClientChannelInfo clientChannelInfo,
+ ConsumeType consumeType, MessageModel messageModel, ConsumeFromWhere consumeFromWhere,
+ final Set<SubscriptionData> subList, boolean isNotifyConsumerIdsChangedEnable) {
+
+ ConsumerGroupInfo consumerGroupInfo = this.consumerTable.get(group);
+ if (null == consumerGroupInfo) {
+ ConsumerGroupInfo tmp = new ConsumerGroupInfo(group, consumeType, messageModel, consumeFromWhere);
+ ConsumerGroupInfo prev = this.consumerTable.putIfAbsent(group, tmp);
+ consumerGroupInfo = prev != null ? prev : tmp;
+ }
+
+ boolean r1 =
+ consumerGroupInfo.updateChannel(clientChannelInfo, consumeType, messageModel,
+ consumeFromWhere);
+ boolean r2 = consumerGroupInfo.updateSubscription(subList);
+
+ if (r1 || r2) {
+ if (isNotifyConsumerIdsChangedEnable) {
+ this.consumerIdsChangeListener.consumerIdsChanged(group, consumerGroupInfo.getAllChannel());
+ }
+ }
+
+ return r1 || r2;
+ }
+
+ public void unregisterConsumer(final String group, final ClientChannelInfo clientChannelInfo, boolean isNotifyConsumerIdsChangedEnable) {
+ ConsumerGroupInfo consumerGroupInfo = this.consumerTable.get(group);
+ if (null != consumerGroupInfo) {
+ consumerGroupInfo.unregisterChannel(clientChannelInfo);
+ if (consumerGroupInfo.getChannelInfoTable().isEmpty()) {
+ ConsumerGroupInfo remove = this.consumerTable.remove(group);
+ if (remove != null) {
+ log.info("unregister consumer ok, no any connection, and remove consumer group, {}", group);
+ }
+ }
+ if (isNotifyConsumerIdsChangedEnable) {
+ this.consumerIdsChangeListener.consumerIdsChanged(group, consumerGroupInfo.getAllChannel());
+ }
+ }
+ }
+
+ public void scanNotActiveChannel() {
+ Iterator<Entry<String, ConsumerGroupInfo>> it = this.consumerTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, ConsumerGroupInfo> next = it.next();
+ String group = next.getKey();
+ ConsumerGroupInfo consumerGroupInfo = next.getValue();
+ ConcurrentHashMap<Channel, ClientChannelInfo> channelInfoTable =
+ consumerGroupInfo.getChannelInfoTable();
+
+ Iterator<Entry<Channel, ClientChannelInfo>> itChannel = channelInfoTable.entrySet().iterator();
+ while (itChannel.hasNext()) {
+ Entry<Channel, ClientChannelInfo> nextChannel = itChannel.next();
+ ClientChannelInfo clientChannelInfo = nextChannel.getValue();
+ long diff = System.currentTimeMillis() - clientChannelInfo.getLastUpdateTimestamp();
+ if (diff > CHANNEL_EXPIRED_TIMEOUT) {
+ log.warn(
+ "SCAN: remove expired channel from ConsumerManager consumerTable. channel={}, consumerGroup={}",
+ RemotingHelper.parseChannelRemoteAddr(clientChannelInfo.getChannel()), group);
+ RemotingUtil.closeChannel(clientChannelInfo.getChannel());
+ itChannel.remove();
+ }
+ }
+
+ if (channelInfoTable.isEmpty()) {
+ log.warn(
+ "SCAN: remove expired channel from ConsumerManager consumerTable, all clear, consumerGroup={}",
+ group);
+ it.remove();
+ }
+ }
+ }
+
+ public HashSet<String> queryTopicConsumeByWho(final String topic) {
+ HashSet<String> groups = new HashSet<String>();
+ Iterator<Entry<String, ConsumerGroupInfo>> it = this.consumerTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, ConsumerGroupInfo> entry = it.next();
+ ConcurrentHashMap<String, SubscriptionData> subscriptionTable =
+ entry.getValue().getSubscriptionTable();
+ if (subscriptionTable.containsKey(topic)) {
+ groups.add(entry.getKey());
+ }
+ }
+ return groups;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java b/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java
new file mode 100644
index 0000000..501d665
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java
@@ -0,0 +1,45 @@
+/**
+ * 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.broker.client;
+
+import org.apache.rocketmq.broker.BrokerController;
+import io.netty.channel.Channel;
+
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class DefaultConsumerIdsChangeListener implements ConsumerIdsChangeListener {
+ private final BrokerController brokerController;
+
+
+ public DefaultConsumerIdsChangeListener(BrokerController brokerController) {
+ this.brokerController = brokerController;
+ }
+
+
+ @Override
+ public void consumerIdsChanged(String group, List<Channel> channels) {
+ if (channels != null && brokerController.getBrokerConfig().isNotifyConsumerIdsChangedEnable()) {
+ for (Channel chl : channels) {
+ this.brokerController.getBroker2Client().notifyConsumerIdsChanged(chl, group);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java
new file mode 100644
index 0000000..6656ab0
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java
@@ -0,0 +1,199 @@
+/**
+ * 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.broker.client;
+
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.common.RemotingUtil;
+import io.netty.channel.Channel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ProducerManager {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+ private static final long LOCK_TIMEOUT_MILLIS = 3000;
+ private static final long CHANNEL_EXPIRED_TIMEOUT = 1000 * 120;
+ private final Lock groupChannelLock = new ReentrantLock();
+ private final HashMap<String /* group name */, HashMap<Channel, ClientChannelInfo>> groupChannelTable =
+ new HashMap<String, HashMap<Channel, ClientChannelInfo>>();
+
+
+ public ProducerManager() {
+ }
+
+
+ public HashMap<String, HashMap<Channel, ClientChannelInfo>> getGroupChannelTable() {
+ HashMap<String /* group name */, HashMap<Channel, ClientChannelInfo>> newGroupChannelTable =
+ new HashMap<String, HashMap<Channel, ClientChannelInfo>>();
+ try {
+ if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
+ try {
+ newGroupChannelTable.putAll(groupChannelTable);
+ } finally {
+ groupChannelLock.unlock();
+ }
+ }
+ } catch (InterruptedException e) {
+ log.error("", e);
+ }
+ return newGroupChannelTable;
+ }
+
+
+ public void scanNotActiveChannel() {
+ try {
+ if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
+ try {
+ for (final Map.Entry<String, HashMap<Channel, ClientChannelInfo>> entry : this.groupChannelTable
+ .entrySet()) {
+ final String group = entry.getKey();
+ final HashMap<Channel, ClientChannelInfo> chlMap = entry.getValue();
+
+ Iterator<Entry<Channel, ClientChannelInfo>> it = chlMap.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<Channel, ClientChannelInfo> item = it.next();
+ // final Integer id = item.getKey();
+ final ClientChannelInfo info = item.getValue();
+
+ long diff = System.currentTimeMillis() - info.getLastUpdateTimestamp();
+ if (diff > CHANNEL_EXPIRED_TIMEOUT) {
+ it.remove();
+ log.warn(
+ "SCAN: remove expired channel[{}] from ProducerManager groupChannelTable, producer group name: {}",
+ RemotingHelper.parseChannelRemoteAddr(info.getChannel()), group);
+ RemotingUtil.closeChannel(info.getChannel());
+ }
+ }
+ }
+ } finally {
+ this.groupChannelLock.unlock();
+ }
+ } else {
+ log.warn("ProducerManager scanNotActiveChannel lock timeout");
+ }
+ } catch (InterruptedException e) {
+ log.error("", e);
+ }
+ }
+
+
+ public void doChannelCloseEvent(final String remoteAddr, final Channel channel) {
+ if (channel != null) {
+ try {
+ if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
+ try {
+ for (final Map.Entry<String, HashMap<Channel, ClientChannelInfo>> entry : this.groupChannelTable
+ .entrySet()) {
+ final String group = entry.getKey();
+ final HashMap<Channel, ClientChannelInfo> clientChannelInfoTable =
+ entry.getValue();
+ final ClientChannelInfo clientChannelInfo =
+ clientChannelInfoTable.remove(channel);
+ if (clientChannelInfo != null) {
+ log.info(
+ "NETTY EVENT: remove channel[{}][{}] from ProducerManager groupChannelTable, producer group: {}",
+ clientChannelInfo.toString(), remoteAddr, group);
+ }
+
+ }
+ } finally {
+ this.groupChannelLock.unlock();
+ }
+ } else {
+ log.warn("ProducerManager doChannelCloseEvent lock timeout");
+ }
+ } catch (InterruptedException e) {
+ log.error("", e);
+ }
+ }
+ }
+
+
+ public void registerProducer(final String group, final ClientChannelInfo clientChannelInfo) {
+ try {
+ ClientChannelInfo clientChannelInfoFound = null;
+
+ if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
+ try {
+ HashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group);
+ if (null == channelTable) {
+ channelTable = new HashMap<Channel, ClientChannelInfo>();
+ this.groupChannelTable.put(group, channelTable);
+ }
+
+ clientChannelInfoFound = channelTable.get(clientChannelInfo.getChannel());
+ if (null == clientChannelInfoFound) {
+ channelTable.put(clientChannelInfo.getChannel(), clientChannelInfo);
+ log.info("new producer connected, group: {} channel: {}", group,
+ clientChannelInfo.toString());
+ }
+ } finally {
+ this.groupChannelLock.unlock();
+ }
+
+ if (clientChannelInfoFound != null) {
+ clientChannelInfoFound.setLastUpdateTimestamp(System.currentTimeMillis());
+ }
+ } else {
+ log.warn("ProducerManager registerProducer lock timeout");
+ }
+ } catch (InterruptedException e) {
+ log.error("", e);
+ }
+ }
+
+
+ public void unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo) {
+ try {
+ if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
+ try {
+ HashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group);
+ if (null != channelTable && !channelTable.isEmpty()) {
+ ClientChannelInfo old = channelTable.remove(clientChannelInfo.getChannel());
+ if (old != null) {
+ log.info("unregister a producer[{}] from groupChannelTable {}", group,
+ clientChannelInfo.toString());
+ }
+
+ if (channelTable.isEmpty()) {
+ this.groupChannelTable.remove(group);
+ log.info("unregister a producer group[{}] from groupChannelTable", group);
+ }
+ }
+ } finally {
+ this.groupChannelLock.unlock();
+ }
+ } else {
+ log.warn("ProducerManager unregisterProducer lock timeout");
+ }
+ } catch (InterruptedException e) {
+ log.error("", e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java b/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
new file mode 100644
index 0000000..7d7064a
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
@@ -0,0 +1,317 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.broker.client.net;
+
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.broker.client.ClientChannelInfo;
+import org.apache.rocketmq.broker.client.ConsumerGroupInfo;
+import org.apache.rocketmq.broker.pagecache.OneMessageTransfer;
+import org.apache.rocketmq.common.MQVersion;
+import org.apache.rocketmq.common.TopicConfig;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.message.MessageQueueForC;
+import org.apache.rocketmq.common.protocol.RequestCode;
+import org.apache.rocketmq.common.protocol.ResponseCode;
+import org.apache.rocketmq.common.protocol.body.GetConsumerStatusBody;
+import org.apache.rocketmq.common.protocol.body.ResetOffsetBody;
+import org.apache.rocketmq.common.protocol.body.ResetOffsetBodyForC;
+import org.apache.rocketmq.common.protocol.header.CheckTransactionStateRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetConsumerStatusRequestHeader;
+import org.apache.rocketmq.common.protocol.header.NotifyConsumerIdsChangedRequestHeader;
+import org.apache.rocketmq.common.protocol.header.ResetOffsetRequestHeader;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
+import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.apache.rocketmq.store.SelectMappedBufferResult;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelFutureListener;
+import io.netty.channel.FileRegion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class Broker2Client {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+ private final BrokerController brokerController;
+
+ public Broker2Client(BrokerController brokerController) {
+ this.brokerController = brokerController;
+ }
+
+ public void checkProducerTransactionState(
+ final Channel channel,
+ final CheckTransactionStateRequestHeader requestHeader,
+ final SelectMappedBufferResult selectMappedBufferResult) {
+ RemotingCommand request =
+ RemotingCommand.createRequestCommand(RequestCode.CHECK_TRANSACTION_STATE, requestHeader);
+ request.markOnewayRPC();
+
+ try {
+ FileRegion fileRegion =
+ new OneMessageTransfer(request.encodeHeader(selectMappedBufferResult.getSize()),
+ selectMappedBufferResult);
+ channel.writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
+ @Override
+ public void operationComplete(ChannelFuture future) throws Exception {
+ selectMappedBufferResult.release();
+ if (!future.isSuccess()) {
+ log.error("invokeProducer failed,", future.cause());
+ }
+ }
+ });
+ } catch (Throwable e) {
+ log.error("invokeProducer exception", e);
+ selectMappedBufferResult.release();
+ }
+ }
+
+ public RemotingCommand callClient(final Channel channel,
+ final RemotingCommand request
+ ) throws RemotingSendRequestException, RemotingTimeoutException, InterruptedException {
+ return this.brokerController.getRemotingServer().invokeSync(channel, request, 10000);
+ }
+
+ public void notifyConsumerIdsChanged(
+ final Channel channel,
+ final String consumerGroup) {
+ if (null == consumerGroup) {
+ log.error("notifyConsumerIdsChanged consumerGroup is null");
+ return;
+ }
+
+ NotifyConsumerIdsChangedRequestHeader requestHeader = new NotifyConsumerIdsChangedRequestHeader();
+ requestHeader.setConsumerGroup(consumerGroup);
+ RemotingCommand request =
+ RemotingCommand.createRequestCommand(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, requestHeader);
+
+ try {
+ this.brokerController.getRemotingServer().invokeOneway(channel, request, 10);
+ } catch (Exception e) {
+ log.error("notifyConsumerIdsChanged exception, " + consumerGroup, e.getMessage());
+ }
+ }
+
+ public RemotingCommand resetOffset(String topic, String group, long timeStamp, boolean isForce) {
+ return resetOffset(topic, group, timeStamp, isForce, false);
+ }
+
+ public RemotingCommand resetOffset(String topic, String group, long timeStamp, boolean isForce,
+ boolean isC) {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+
+ TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
+ if (null == topicConfig) {
+ log.error("[reset-offset] reset offset failed, no topic in this broker. topic={}", topic);
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("[reset-offset] reset offset failed, no topic in this broker. topic=" + topic);
+ return response;
+ }
+
+ Map<MessageQueue, Long> offsetTable = new HashMap<MessageQueue, Long>();
+
+ for (int i = 0; i < topicConfig.getWriteQueueNums(); i++) {
+ MessageQueue mq = new MessageQueue();
+ mq.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());
+ mq.setTopic(topic);
+ mq.setQueueId(i);
+
+ long consumerOffset =
+ this.brokerController.getConsumerOffsetManager().queryOffset(group, topic, i);
+ if (-1 == consumerOffset) {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark(String.format("THe consumer group <%s> not exist", group));
+ return response;
+ }
+
+ long timeStampOffset;
+ if (timeStamp == -1) {
+
+ timeStampOffset = this.brokerController.getMessageStore().getMaxOffsetInQuque(topic, i);
+ } else {
+ timeStampOffset = this.brokerController.getMessageStore().getOffsetInQueueByTime(topic, i, timeStamp);
+ }
+
+ if (timeStampOffset < 0) {
+ log.warn("reset offset is invalid. topic={}, queueId={}, timeStampOffset={}", topic, i, timeStampOffset);
+ timeStampOffset = 0;
+ }
+
+ if (isForce || timeStampOffset < consumerOffset) {
+ offsetTable.put(mq, timeStampOffset);
+ } else {
+ offsetTable.put(mq, consumerOffset);
+ }
+ }
+
+ ResetOffsetRequestHeader requestHeader = new ResetOffsetRequestHeader();
+ requestHeader.setTopic(topic);
+ requestHeader.setGroup(group);
+ requestHeader.setTimestamp(timeStamp);
+ RemotingCommand request =
+ RemotingCommand.createRequestCommand(RequestCode.RESET_CONSUMER_CLIENT_OFFSET, requestHeader);
+ if (isC) {
+ // c++ language
+ ResetOffsetBodyForC body = new ResetOffsetBodyForC();
+ List<MessageQueueForC> offsetList = convertOffsetTable2OffsetList(offsetTable);
+ body.setOffsetTable(offsetList);
+ request.setBody(body.encode());
+ } else {
+ // other language
+ ResetOffsetBody body = new ResetOffsetBody();
+ body.setOffsetTable(offsetTable);
+ request.setBody(body.encode());
+ }
+
+ ConsumerGroupInfo consumerGroupInfo =
+ this.brokerController.getConsumerManager().getConsumerGroupInfo(group);
+
+ if (consumerGroupInfo != null && !consumerGroupInfo.getAllChannel().isEmpty()) {
+ ConcurrentHashMap<Channel, ClientChannelInfo> channelInfoTable =
+ consumerGroupInfo.getChannelInfoTable();
+ for (Map.Entry<Channel, ClientChannelInfo> entry : channelInfoTable.entrySet()) {
+ int version = entry.getValue().getVersion();
+ if (version >= MQVersion.Version.V3_0_7_SNAPSHOT.ordinal()) {
+ try {
+ this.brokerController.getRemotingServer().invokeOneway(entry.getKey(), request, 5000);
+ log.info("[reset-offset] reset offset success. topic={}, group={}, clientId={}",
+ new Object[]{topic, group, entry.getValue().getClientId()});
+ } catch (Exception e) {
+ log.error("[reset-offset] reset offset exception. topic={}, group={}",
+ new Object[]{topic, group}, e);
+ }
+ } else {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("the client does not support this feature. version="
+ + MQVersion.getVersionDesc(version));
+ log.warn("[reset-offset] the client does not support this feature. version={}",
+ RemotingHelper.parseChannelRemoteAddr(entry.getKey()), MQVersion.getVersionDesc(version));
+ return response;
+ }
+ }
+ } else {
+ String errorInfo =
+ String.format("Consumer not online, so can not reset offset, Group: %s Topic: %s Timestamp: %d",
+ requestHeader.getGroup(),
+ requestHeader.getTopic(),
+ requestHeader.getTimestamp());
+ log.error(errorInfo);
+ response.setCode(ResponseCode.CONSUMER_NOT_ONLINE);
+ response.setRemark(errorInfo);
+ return response;
+ }
+ response.setCode(ResponseCode.SUCCESS);
+ ResetOffsetBody resBody = new ResetOffsetBody();
+ resBody.setOffsetTable(offsetTable);
+ response.setBody(resBody.encode());
+ return response;
+ }
+
+ private List<MessageQueueForC> convertOffsetTable2OffsetList(Map<MessageQueue, Long> table) {
+ List<MessageQueueForC> list = new ArrayList<MessageQueueForC>();
+ for (Entry<MessageQueue, Long> entry : table.entrySet()) {
+ MessageQueue mq = entry.getKey();
+ MessageQueueForC tmp =
+ new MessageQueueForC(mq.getTopic(), mq.getBrokerName(), mq.getQueueId(), entry.getValue());
+ list.add(tmp);
+ }
+ return list;
+ }
+
+ public RemotingCommand getConsumeStatus(String topic, String group, String originClientId) {
+ final RemotingCommand result = RemotingCommand.createResponseCommand(null);
+
+ GetConsumerStatusRequestHeader requestHeader = new GetConsumerStatusRequestHeader();
+ requestHeader.setTopic(topic);
+ requestHeader.setGroup(group);
+ RemotingCommand request =
+ RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT,
+ requestHeader);
+
+ Map<String, Map<MessageQueue, Long>> consumerStatusTable =
+ new HashMap<String, Map<MessageQueue, Long>>();
+ ConcurrentHashMap<Channel, ClientChannelInfo> channelInfoTable =
+ this.brokerController.getConsumerManager().getConsumerGroupInfo(group).getChannelInfoTable();
+ if (null == channelInfoTable || channelInfoTable.isEmpty()) {
+ result.setCode(ResponseCode.SYSTEM_ERROR);
+ result.setRemark(String.format("No Any Consumer online in the consumer group: [%s]", group));
+ return result;
+ }
+
+ for (Map.Entry<Channel, ClientChannelInfo> entry : channelInfoTable.entrySet()) {
+ int version = entry.getValue().getVersion();
+ String clientId = entry.getValue().getClientId();
+ if (version < MQVersion.Version.V3_0_7_SNAPSHOT.ordinal()) {
+ result.setCode(ResponseCode.SYSTEM_ERROR);
+ result.setRemark("the client does not support this feature. version="
+ + MQVersion.getVersionDesc(version));
+ log.warn("[get-consumer-status] the client does not support this feature. version={}",
+ RemotingHelper.parseChannelRemoteAddr(entry.getKey()), MQVersion.getVersionDesc(version));
+ return result;
+ } else if (UtilAll.isBlank(originClientId) || originClientId.equals(clientId)) {
+ try {
+ RemotingCommand response =
+ this.brokerController.getRemotingServer().invokeSync(entry.getKey(), request, 5000);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ if (response.getBody() != null) {
+ GetConsumerStatusBody body =
+ GetConsumerStatusBody.decode(response.getBody(),
+ GetConsumerStatusBody.class);
+
+ consumerStatusTable.put(clientId, body.getMessageQueueTable());
+ log.info(
+ "[get-consumer-status] get consumer status success. topic={}, group={}, channelRemoteAddr={}",
+ new Object[]{topic, group, clientId});
+ }
+ }
+ default:
+ break;
+ }
+ } catch (Exception e) {
+ log.error(
+ "[get-consumer-status] get consumer status exception. topic={}, group={}, offset={}",
+ new Object[]{topic, group}, e);
+ }
+
+ if (!UtilAll.isBlank(originClientId) && originClientId.equals(clientId)) {
+ break;
+ }
+ }
+ }
+
+ result.setCode(ResponseCode.SUCCESS);
+ GetConsumerStatusBody resBody = new GetConsumerStatusBody();
+ resBody.setConsumerTable(consumerStatusTable);
+ result.setBody(resBody.encode());
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java b/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java
new file mode 100644
index 0000000..adb1819
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java
@@ -0,0 +1,281 @@
+/**
+ * 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.broker.client.rebalance;
+
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class RebalanceLockManager {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.REBALANCE_LOCK_LOGGER_NAME);
+ private final static long REBALANCE_LOCK_MAX_LIVE_TIME = Long.parseLong(System.getProperty(
+ "rocketmq.broker.rebalance.lockMaxLiveTime", "60000"));
+ private final Lock lock = new ReentrantLock();
+ private final ConcurrentHashMap<String/* group */, ConcurrentHashMap<MessageQueue, LockEntry>> mqLockTable =
+ new ConcurrentHashMap<String, ConcurrentHashMap<MessageQueue, LockEntry>>(1024);
+
+ public boolean tryLock(final String group, final MessageQueue mq, final String clientId) {
+
+ if (!this.isLocked(group, mq, clientId)) {
+ try {
+ this.lock.lockInterruptibly();
+ try {
+ ConcurrentHashMap<MessageQueue, LockEntry> groupValue = this.mqLockTable.get(group);
+ if (null == groupValue) {
+ groupValue = new ConcurrentHashMap<MessageQueue, LockEntry>(32);
+ this.mqLockTable.put(group, groupValue);
+ }
+
+ LockEntry lockEntry = groupValue.get(mq);
+ if (null == lockEntry) {
+ lockEntry = new LockEntry();
+ lockEntry.setClientId(clientId);
+ groupValue.put(mq, lockEntry);
+ log.info("tryLock, message queue not locked, I got it. Group: {} NewClientId: {} {}", //
+ group, //
+ clientId, //
+ mq);
+ }
+
+ if (lockEntry.isLocked(clientId)) {
+ lockEntry.setLastUpdateTimestamp(System.currentTimeMillis());
+ return true;
+ }
+
+ String oldClientId = lockEntry.getClientId();
+
+
+ if (lockEntry.isExpired()) {
+ lockEntry.setClientId(clientId);
+ lockEntry.setLastUpdateTimestamp(System.currentTimeMillis());
+ log.warn(
+ "tryLock, message queue lock expired, I got it. Group: {} OldClientId: {} NewClientId: {} {}", //
+ group, //
+ oldClientId, //
+ clientId, //
+ mq);
+ return true;
+ }
+
+
+ log.warn(
+ "tryLock, message queue locked by other client. Group: {} OtherClientId: {} NewClientId: {} {}", //
+ group, //
+ oldClientId, //
+ clientId, //
+ mq);
+ return false;
+ } finally {
+ this.lock.unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("putMessage exception", e);
+ }
+ } else {
+
+ }
+
+ return true;
+ }
+
+ private boolean isLocked(final String group, final MessageQueue mq, final String clientId) {
+ ConcurrentHashMap<MessageQueue, LockEntry> groupValue = this.mqLockTable.get(group);
+ if (groupValue != null) {
+ LockEntry lockEntry = groupValue.get(mq);
+ if (lockEntry != null) {
+ boolean locked = lockEntry.isLocked(clientId);
+ if (locked) {
+ lockEntry.setLastUpdateTimestamp(System.currentTimeMillis());
+ }
+
+ return locked;
+ }
+ }
+
+ return false;
+ }
+
+ public Set<MessageQueue> tryLockBatch(final String group, final Set<MessageQueue> mqs,
+ final String clientId) {
+ Set<MessageQueue> lockedMqs = new HashSet<MessageQueue>(mqs.size());
+ Set<MessageQueue> notLockedMqs = new HashSet<MessageQueue>(mqs.size());
+
+
+ for (MessageQueue mq : mqs) {
+ if (this.isLocked(group, mq, clientId)) {
+ lockedMqs.add(mq);
+ } else {
+ notLockedMqs.add(mq);
+ }
+ }
+
+ if (!notLockedMqs.isEmpty()) {
+ try {
+ this.lock.lockInterruptibly();
+ try {
+ ConcurrentHashMap<MessageQueue, LockEntry> groupValue = this.mqLockTable.get(group);
+ if (null == groupValue) {
+ groupValue = new ConcurrentHashMap<MessageQueue, LockEntry>(32);
+ this.mqLockTable.put(group, groupValue);
+ }
+
+
+ for (MessageQueue mq : notLockedMqs) {
+ LockEntry lockEntry = groupValue.get(mq);
+ if (null == lockEntry) {
+ lockEntry = new LockEntry();
+ lockEntry.setClientId(clientId);
+ groupValue.put(mq, lockEntry);
+ log.info(
+ "tryLockBatch, message queue not locked, I got it. Group: {} NewClientId: {} {}", //
+ group, //
+ clientId, //
+ mq);
+ }
+
+
+ if (lockEntry.isLocked(clientId)) {
+ lockEntry.setLastUpdateTimestamp(System.currentTimeMillis());
+ lockedMqs.add(mq);
+ continue;
+ }
+
+ String oldClientId = lockEntry.getClientId();
+
+
+ if (lockEntry.isExpired()) {
+ lockEntry.setClientId(clientId);
+ lockEntry.setLastUpdateTimestamp(System.currentTimeMillis());
+ log.warn(
+ "tryLockBatch, message queue lock expired, I got it. Group: {} OldClientId: {} NewClientId: {} {}", //
+ group, //
+ oldClientId, //
+ clientId, //
+ mq);
+ lockedMqs.add(mq);
+ continue;
+ }
+
+
+ log.warn(
+ "tryLockBatch, message queue locked by other client. Group: {} OtherClientId: {} NewClientId: {} {}", //
+ group, //
+ oldClientId, //
+ clientId, //
+ mq);
+ }
+ } finally {
+ this.lock.unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("putMessage exception", e);
+ }
+ }
+
+ return lockedMqs;
+ }
+
+ public void unlockBatch(final String group, final Set<MessageQueue> mqs, final String clientId) {
+ try {
+ this.lock.lockInterruptibly();
+ try {
+ ConcurrentHashMap<MessageQueue, LockEntry> groupValue = this.mqLockTable.get(group);
+ if (null != groupValue) {
+ for (MessageQueue mq : mqs) {
+ LockEntry lockEntry = groupValue.get(mq);
+ if (null != lockEntry) {
+ if (lockEntry.getClientId().equals(clientId)) {
+ groupValue.remove(mq);
+ log.info("unlockBatch, Group: {} {} {}",
+ group,
+ mq,
+ clientId);
+ } else {
+ log.warn("unlockBatch, but mq locked by other client: {}, Group: {} {} {}",
+ lockEntry.getClientId(),
+ group,
+ mq,
+ clientId);
+ }
+ } else {
+ log.warn("unlockBatch, but mq not locked, Group: {} {} {}",
+ group,
+ mq,
+ clientId);
+ }
+ }
+ } else {
+ log.warn("unlockBatch, group not exist, Group: {} {}",
+ group,
+ clientId);
+ }
+ } finally {
+ this.lock.unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("putMessage exception", e);
+ }
+ }
+
+ static class LockEntry {
+ private String clientId;
+ private volatile long lastUpdateTimestamp = System.currentTimeMillis();
+
+
+ public String getClientId() {
+ return clientId;
+ }
+
+
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
+
+ public long getLastUpdateTimestamp() {
+ return lastUpdateTimestamp;
+ }
+
+
+ public void setLastUpdateTimestamp(long lastUpdateTimestamp) {
+ this.lastUpdateTimestamp = lastUpdateTimestamp;
+ }
+
+ public boolean isLocked(final String clientId) {
+ boolean eq = this.clientId.equals(clientId);
+ return eq && !this.isExpired();
+ }
+
+ public boolean isExpired() {
+ boolean expired =
+ (System.currentTimeMillis() - this.lastUpdateTimestamp) > REBALANCE_LOCK_MAX_LIVE_TIME;
+
+ return expired;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerManager.java b/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerManager.java
new file mode 100644
index 0000000..5b86d99
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerManager.java
@@ -0,0 +1,175 @@
+/**
+ * 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.broker.filtersrv;
+
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.broker.BrokerStartup;
+import org.apache.rocketmq.common.ThreadFactoryImpl;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.remoting.common.RemotingUtil;
+import io.netty.channel.Channel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+
+public class FilterServerManager {
+
+ public static final long FILTER_SERVER_MAX_IDLE_TIME_MILLS = 30000;
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+ private final ConcurrentHashMap<Channel, FilterServerInfo> filterServerTable =
+ new ConcurrentHashMap<Channel, FilterServerInfo>(16);
+ private final BrokerController brokerController;
+
+ private ScheduledExecutorService scheduledExecutorService = Executors
+ .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("FilterServerManagerScheduledThread"));
+
+ public FilterServerManager(final BrokerController brokerController) {
+ this.brokerController = brokerController;
+ }
+
+ public void start() {
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ FilterServerManager.this.createFilterServer();
+ } catch (Exception e) {
+ log.error("", e);
+ }
+ }
+ }, 1000 * 5, 1000 * 30, TimeUnit.MILLISECONDS);
+ }
+
+ public void createFilterServer() {
+ int more =
+ this.brokerController.getBrokerConfig().getFilterServerNums() - this.filterServerTable.size();
+ String cmd = this.buildStartCommand();
+ for (int i = 0; i < more; i++) {
+ FilterServerUtil.callShell(cmd, log);
+ }
+ }
+
+ private String buildStartCommand() {
+ String config = "";
+ if (BrokerStartup.configFile != null) {
+ config = String.format("-c %s", BrokerStartup.configFile);
+ }
+
+ if (this.brokerController.getBrokerConfig().getNamesrvAddr() != null) {
+ config += String.format(" -n %s", this.brokerController.getBrokerConfig().getNamesrvAddr());
+ }
+
+ if (RemotingUtil.isWindowsPlatform()) {
+ return String.format("start /b %s\\bin\\mqfiltersrv.exe %s",
+ this.brokerController.getBrokerConfig().getRocketmqHome(),
+ config);
+ } else {
+ return String.format("sh %s/bin/startfsrv.sh %s",
+ this.brokerController.getBrokerConfig().getRocketmqHome(),
+ config);
+ }
+ }
+
+ public void shutdown() {
+ this.scheduledExecutorService.shutdown();
+ }
+
+ public void registerFilterServer(final Channel channel, final String filterServerAddr) {
+ FilterServerInfo filterServerInfo = this.filterServerTable.get(channel);
+ if (filterServerInfo != null) {
+ filterServerInfo.setLastUpdateTimestamp(System.currentTimeMillis());
+ } else {
+ filterServerInfo = new FilterServerInfo();
+ filterServerInfo.setFilterServerAddr(filterServerAddr);
+ filterServerInfo.setLastUpdateTimestamp(System.currentTimeMillis());
+ this.filterServerTable.put(channel, filterServerInfo);
+ log.info("Receive a New Filter Server<{}>", filterServerAddr);
+ }
+ }
+
+ /**
+
+ */
+ public void scanNotActiveChannel() {
+
+ Iterator<Entry<Channel, FilterServerInfo>> it = this.filterServerTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<Channel, FilterServerInfo> next = it.next();
+ long timestamp = next.getValue().getLastUpdateTimestamp();
+ Channel channel = next.getKey();
+ if ((System.currentTimeMillis() - timestamp) > FILTER_SERVER_MAX_IDLE_TIME_MILLS) {
+ log.info("The Filter Server<{}> expired, remove it", next.getKey());
+ it.remove();
+ RemotingUtil.closeChannel(channel);
+ }
+ }
+ }
+
+ public void doChannelCloseEvent(final String remoteAddr, final Channel channel) {
+ FilterServerInfo old = this.filterServerTable.remove(channel);
+ if (old != null) {
+ log.warn("The Filter Server<{}> connection<{}> closed, remove it", old.getFilterServerAddr(),
+ remoteAddr);
+ }
+ }
+
+ public List<String> buildNewFilterServerList() {
+ List<String> addr = new ArrayList<String>();
+ Iterator<Entry<Channel, FilterServerInfo>> it = this.filterServerTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<Channel, FilterServerInfo> next = it.next();
+ addr.add(next.getValue().getFilterServerAddr());
+ }
+ return addr;
+ }
+
+ static class FilterServerInfo {
+ private String filterServerAddr;
+ private long lastUpdateTimestamp;
+
+
+ public String getFilterServerAddr() {
+ return filterServerAddr;
+ }
+
+
+ public void setFilterServerAddr(String filterServerAddr) {
+ this.filterServerAddr = filterServerAddr;
+ }
+
+
+ public long getLastUpdateTimestamp() {
+ return lastUpdateTimestamp;
+ }
+
+
+ public void setLastUpdateTimestamp(long lastUpdateTimestamp) {
+ this.lastUpdateTimestamp = lastUpdateTimestamp;
+ }
+ }
+}
[06/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/stats/StatsItem.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/stats/StatsItem.java b/common/src/main/java/org/apache/rocketmq/common/stats/StatsItem.java
new file mode 100644
index 0000000..42bb561
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/stats/StatsItem.java
@@ -0,0 +1,272 @@
+/**
+ * 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.common.stats;
+
+import org.apache.rocketmq.common.UtilAll;
+import org.slf4j.Logger;
+
+import java.util.LinkedList;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+
+public class StatsItem {
+
+ private final AtomicLong value = new AtomicLong(0);
+
+ private final AtomicLong times = new AtomicLong(0);
+
+ private final LinkedList<CallSnapshot> csListMinute = new LinkedList<CallSnapshot>();
+
+
+ private final LinkedList<CallSnapshot> csListHour = new LinkedList<CallSnapshot>();
+
+
+ private final LinkedList<CallSnapshot> csListDay = new LinkedList<CallSnapshot>();
+
+ private final String statsName;
+ private final String statsKey;
+ private final ScheduledExecutorService scheduledExecutorService;
+ private final Logger log;
+
+
+ public StatsItem(String statsName, String statsKey, ScheduledExecutorService scheduledExecutorService,
+ Logger log) {
+ this.statsName = statsName;
+ this.statsKey = statsKey;
+ this.scheduledExecutorService = scheduledExecutorService;
+ this.log = log;
+ }
+
+ public StatsSnapshot getStatsDataInMinute() {
+ return computeStatsData(this.csListMinute);
+ }
+
+ private static StatsSnapshot computeStatsData(final LinkedList<CallSnapshot> csList) {
+ StatsSnapshot statsSnapshot = new StatsSnapshot();
+ synchronized (csList) {
+ double tps = 0;
+ double avgpt = 0;
+ long sum = 0;
+ if (!csList.isEmpty()) {
+ CallSnapshot first = csList.getFirst();
+ CallSnapshot last = csList.getLast();
+ sum = last.getValue() - first.getValue();
+ tps = (sum * 1000.0d) / (last.getTimestamp() - first.getTimestamp());
+
+ long timesDiff = last.getTimes() - first.getTimes();
+ if (timesDiff > 0) {
+ avgpt = (sum * 1.0d) / timesDiff;
+ }
+ }
+
+ statsSnapshot.setSum(sum);
+ statsSnapshot.setTps(tps);
+ statsSnapshot.setAvgpt(avgpt);
+ }
+
+ return statsSnapshot;
+ }
+
+ public StatsSnapshot getStatsDataInHour() {
+ return computeStatsData(this.csListHour);
+ }
+
+ public StatsSnapshot getStatsDataInDay() {
+ return computeStatsData(this.csListDay);
+ }
+
+ public void init() {
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ samplingInSeconds();
+ } catch (Throwable e) {
+ }
+ }
+ }, 0, 10, TimeUnit.SECONDS);
+
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ samplingInMinutes();
+ } catch (Throwable e) {
+ }
+ }
+ }, 0, 10, TimeUnit.MINUTES);
+
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ samplingInHour();
+ } catch (Throwable e) {
+ }
+ }
+ }, 0, 1, TimeUnit.HOURS);
+
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ printAtMinutes();
+ } catch (Throwable ignored) {
+ }
+ }
+ }, Math.abs(UtilAll.computNextMinutesTimeMillis() - System.currentTimeMillis()), 1000 * 60, TimeUnit.MILLISECONDS);
+
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ printAtHour();
+ } catch (Throwable ignored) {
+ }
+ }
+ }, Math.abs(UtilAll.computNextHourTimeMillis() - System.currentTimeMillis()), 1000 * 60 * 60, TimeUnit.MILLISECONDS);
+
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ printAtDay();
+ } catch (Throwable ignored) {
+ }
+ }
+ }, Math.abs(UtilAll.computNextMorningTimeMillis() - System.currentTimeMillis()) - 2000, 1000 * 60 * 60 * 24, TimeUnit.MILLISECONDS);
+ }
+
+ public void samplingInSeconds() {
+ synchronized (this.csListMinute) {
+ this.csListMinute.add(new CallSnapshot(System.currentTimeMillis(), this.times.get(), this.value
+ .get()));
+ if (this.csListMinute.size() > 7) {
+ this.csListMinute.removeFirst();
+ }
+ }
+ }
+
+ public void samplingInMinutes() {
+ synchronized (this.csListHour) {
+ this.csListHour.add(new CallSnapshot(System.currentTimeMillis(), this.times.get(), this.value
+ .get()));
+ if (this.csListHour.size() > 7) {
+ this.csListHour.removeFirst();
+ }
+ }
+ }
+
+ public void samplingInHour() {
+ synchronized (this.csListDay) {
+ this.csListDay.add(new CallSnapshot(System.currentTimeMillis(), this.times.get(), this.value
+ .get()));
+ if (this.csListDay.size() > 25) {
+ this.csListDay.removeFirst();
+ }
+ }
+ }
+
+ public void printAtMinutes() {
+ StatsSnapshot ss = computeStatsData(this.csListMinute);
+ log.info(String.format("[%s] [%s] Stats In One Minute, SUM: %d TPS: %.2f AVGPT: %.2f",
+ this.statsName,
+ this.statsKey,
+ ss.getSum(),
+ ss.getTps(),
+ ss.getAvgpt()));
+ }
+
+ public void printAtHour() {
+ StatsSnapshot ss = computeStatsData(this.csListHour);
+ log.info(String.format("[%s] [%s] Stats In One Hour, SUM: %d TPS: %.2f AVGPT: %.2f",
+ this.statsName,
+ this.statsKey,
+ ss.getSum(),
+ ss.getTps(),
+ ss.getAvgpt()));
+ }
+
+ public void printAtDay() {
+ StatsSnapshot ss = computeStatsData(this.csListDay);
+ log.info(String.format("[%s] [%s] Stats In One Day, SUM: %d TPS: %.2f AVGPT: %.2f",
+ this.statsName,
+ this.statsKey,
+ ss.getSum(),
+ ss.getTps(),
+ ss.getAvgpt()));
+ }
+
+ public AtomicLong getValue() {
+ return value;
+ }
+
+
+ public String getStatsKey() {
+ return statsKey;
+ }
+
+
+ public String getStatsName() {
+ return statsName;
+ }
+
+
+ public AtomicLong getTimes() {
+ return times;
+ }
+}
+
+
+class CallSnapshot {
+ private final long timestamp;
+ private final long times;
+
+ private final long value;
+
+
+ public CallSnapshot(long timestamp, long times, long value) {
+ super();
+ this.timestamp = timestamp;
+ this.times = times;
+ this.value = value;
+ }
+
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+
+ public long getTimes() {
+ return times;
+ }
+
+
+ public long getValue() {
+ return value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/stats/StatsItemSet.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/stats/StatsItemSet.java b/common/src/main/java/org/apache/rocketmq/common/stats/StatsItemSet.java
new file mode 100644
index 0000000..919745d
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/stats/StatsItemSet.java
@@ -0,0 +1,210 @@
+/**
+ * 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.common.stats;
+
+import org.apache.rocketmq.common.UtilAll;
+import org.slf4j.Logger;
+
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+
+public class StatsItemSet {
+ private final ConcurrentHashMap<String/* key */, StatsItem> statsItemTable =
+ new ConcurrentHashMap<String, StatsItem>(128);
+
+ private final String statsName;
+ private final ScheduledExecutorService scheduledExecutorService;
+ private final Logger log;
+
+
+ public StatsItemSet(String statsName, ScheduledExecutorService scheduledExecutorService, Logger log) {
+ this.statsName = statsName;
+ this.scheduledExecutorService = scheduledExecutorService;
+ this.log = log;
+ this.init();
+ }
+
+ public void init() {
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ samplingInSeconds();
+ } catch (Throwable e) {
+ }
+ }
+ }, 0, 10, TimeUnit.SECONDS);
+
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ samplingInMinutes();
+ } catch (Throwable e) {
+ }
+ }
+ }, 0, 10, TimeUnit.MINUTES);
+
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ samplingInHour();
+ } catch (Throwable e) {
+ }
+ }
+ }, 0, 1, TimeUnit.HOURS);
+
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ printAtMinutes();
+ } catch (Throwable e) {
+ }
+ }
+ }, Math.abs(UtilAll.computNextMinutesTimeMillis() - System.currentTimeMillis()), 1000 * 60, TimeUnit.MILLISECONDS);
+
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ printAtHour();
+ } catch (Throwable e) {
+ }
+ }
+ }, Math.abs(UtilAll.computNextHourTimeMillis() - System.currentTimeMillis()), 1000 * 60 * 60, TimeUnit.MILLISECONDS);
+
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ printAtDay();
+ } catch (Throwable e) {
+ }
+ }
+ }, Math.abs(UtilAll.computNextMorningTimeMillis() - System.currentTimeMillis()), 1000 * 60 * 60 * 24, TimeUnit.MILLISECONDS);
+ }
+
+ private void samplingInSeconds() {
+ Iterator<Entry<String, StatsItem>> it = this.statsItemTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, StatsItem> next = it.next();
+ next.getValue().samplingInSeconds();
+ }
+ }
+
+ private void samplingInMinutes() {
+ Iterator<Entry<String, StatsItem>> it = this.statsItemTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, StatsItem> next = it.next();
+ next.getValue().samplingInMinutes();
+ }
+ }
+
+ private void samplingInHour() {
+ Iterator<Entry<String, StatsItem>> it = this.statsItemTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, StatsItem> next = it.next();
+ next.getValue().samplingInHour();
+ }
+ }
+
+ private void printAtMinutes() {
+ Iterator<Entry<String, StatsItem>> it = this.statsItemTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, StatsItem> next = it.next();
+ next.getValue().printAtMinutes();
+ }
+ }
+
+ private void printAtHour() {
+ Iterator<Entry<String, StatsItem>> it = this.statsItemTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, StatsItem> next = it.next();
+ next.getValue().printAtHour();
+ }
+ }
+
+ private void printAtDay() {
+ Iterator<Entry<String, StatsItem>> it = this.statsItemTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, StatsItem> next = it.next();
+ next.getValue().printAtDay();
+ }
+ }
+
+ public void addValue(final String statsKey, final int incValue, final int incTimes) {
+ StatsItem statsItem = this.getAndCreateStatsItem(statsKey);
+ statsItem.getValue().addAndGet(incValue);
+ statsItem.getTimes().addAndGet(incTimes);
+ }
+
+ public StatsItem getAndCreateStatsItem(final String statsKey) {
+ StatsItem statsItem = this.statsItemTable.get(statsKey);
+ if (null == statsItem) {
+ statsItem = new StatsItem(this.statsName, statsKey, this.scheduledExecutorService, this.log);
+ StatsItem prev = this.statsItemTable.put(statsKey, statsItem);
+
+ if (null == prev) {
+
+ // statsItem.init();
+ }
+ }
+
+ return statsItem;
+ }
+
+ public StatsSnapshot getStatsDataInMinute(final String statsKey) {
+ StatsItem statsItem = this.statsItemTable.get(statsKey);
+ if (null != statsItem) {
+ return statsItem.getStatsDataInMinute();
+ }
+ return new StatsSnapshot();
+ }
+
+ public StatsSnapshot getStatsDataInHour(final String statsKey) {
+ StatsItem statsItem = this.statsItemTable.get(statsKey);
+ if (null != statsItem) {
+ return statsItem.getStatsDataInHour();
+ }
+ return new StatsSnapshot();
+ }
+
+ public StatsSnapshot getStatsDataInDay(final String statsKey) {
+ StatsItem statsItem = this.statsItemTable.get(statsKey);
+ if (null != statsItem) {
+ return statsItem.getStatsDataInDay();
+ }
+ return new StatsSnapshot();
+ }
+
+ public StatsItem getStatsItem(final String statsKey) {
+ return this.statsItemTable.get(statsKey);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/stats/StatsSnapshot.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/stats/StatsSnapshot.java b/common/src/main/java/org/apache/rocketmq/common/stats/StatsSnapshot.java
new file mode 100644
index 0000000..652d214
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/stats/StatsSnapshot.java
@@ -0,0 +1,54 @@
+/**
+ * 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.common.stats;
+
+public class StatsSnapshot {
+ private long sum;
+ private double tps;
+ private double avgpt;
+
+
+ public long getSum() {
+ return sum;
+ }
+
+
+ public void setSum(long sum) {
+ this.sum = sum;
+ }
+
+
+ public double getTps() {
+ return tps;
+ }
+
+
+ public void setTps(double tps) {
+ this.tps = tps;
+ }
+
+
+ public double getAvgpt() {
+ return avgpt;
+ }
+
+
+ public void setAvgpt(double avgpt) {
+ this.avgpt = avgpt;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java b/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
new file mode 100644
index 0000000..5c3a3c3
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/subscription/SubscriptionGroupConfig.java
@@ -0,0 +1,194 @@
+/**
+ * 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.common.subscription;
+
+import org.apache.rocketmq.common.MixAll;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class SubscriptionGroupConfig {
+
+ private String groupName;
+
+ private boolean consumeEnable = true;
+ private boolean consumeFromMinEnable = true;
+
+ private boolean consumeBroadcastEnable = true;
+
+ private int retryQueueNums = 1;
+
+ private int retryMaxTimes = 16;
+
+ private long brokerId = MixAll.MASTER_ID;
+
+ private long whichBrokerWhenConsumeSlowly = 1;
+
+ private boolean notifyConsumerIdsChangedEnable = true;
+
+
+ public String getGroupName() {
+ return groupName;
+ }
+
+
+ public void setGroupName(String groupName) {
+ this.groupName = groupName;
+ }
+
+
+ public boolean isConsumeEnable() {
+ return consumeEnable;
+ }
+
+
+ public void setConsumeEnable(boolean consumeEnable) {
+ this.consumeEnable = consumeEnable;
+ }
+
+
+ public boolean isConsumeFromMinEnable() {
+ return consumeFromMinEnable;
+ }
+
+
+ public void setConsumeFromMinEnable(boolean consumeFromMinEnable) {
+ this.consumeFromMinEnable = consumeFromMinEnable;
+ }
+
+
+ public boolean isConsumeBroadcastEnable() {
+ return consumeBroadcastEnable;
+ }
+
+
+ public void setConsumeBroadcastEnable(boolean consumeBroadcastEnable) {
+ this.consumeBroadcastEnable = consumeBroadcastEnable;
+ }
+
+
+ public int getRetryQueueNums() {
+ return retryQueueNums;
+ }
+
+
+ public void setRetryQueueNums(int retryQueueNums) {
+ this.retryQueueNums = retryQueueNums;
+ }
+
+
+ public int getRetryMaxTimes() {
+ return retryMaxTimes;
+ }
+
+
+ public void setRetryMaxTimes(int retryMaxTimes) {
+ this.retryMaxTimes = retryMaxTimes;
+ }
+
+
+ public long getBrokerId() {
+ return brokerId;
+ }
+
+
+ public void setBrokerId(long brokerId) {
+ this.brokerId = brokerId;
+ }
+
+
+ public long getWhichBrokerWhenConsumeSlowly() {
+ return whichBrokerWhenConsumeSlowly;
+ }
+
+
+ public void setWhichBrokerWhenConsumeSlowly(long whichBrokerWhenConsumeSlowly) {
+ this.whichBrokerWhenConsumeSlowly = whichBrokerWhenConsumeSlowly;
+ }
+
+ public boolean isNotifyConsumerIdsChangedEnable() {
+ return notifyConsumerIdsChangedEnable;
+ }
+
+ public void setNotifyConsumerIdsChangedEnable(final boolean notifyConsumerIdsChangedEnable) {
+ this.notifyConsumerIdsChangedEnable = notifyConsumerIdsChangedEnable;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (brokerId ^ (brokerId >>> 32));
+ result = prime * result + (consumeBroadcastEnable ? 1231 : 1237);
+ result = prime * result + (consumeEnable ? 1231 : 1237);
+ result = prime * result + (consumeFromMinEnable ? 1231 : 1237);
+ result = prime * result + (notifyConsumerIdsChangedEnable ? 1231 : 1237);
+ result = prime * result + ((groupName == null) ? 0 : groupName.hashCode());
+ result = prime * result + retryMaxTimes;
+ result = prime * result + retryQueueNums;
+ result =
+ prime * result + (int) (whichBrokerWhenConsumeSlowly ^ (whichBrokerWhenConsumeSlowly >>> 32));
+ return result;
+ }
+
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ SubscriptionGroupConfig other = (SubscriptionGroupConfig) obj;
+ if (brokerId != other.brokerId)
+ return false;
+ if (consumeBroadcastEnable != other.consumeBroadcastEnable)
+ return false;
+ if (consumeEnable != other.consumeEnable)
+ return false;
+ if (consumeFromMinEnable != other.consumeFromMinEnable)
+ return false;
+ if (groupName == null) {
+ if (other.groupName != null)
+ return false;
+ } else if (!groupName.equals(other.groupName))
+ return false;
+ if (retryMaxTimes != other.retryMaxTimes)
+ return false;
+ if (retryQueueNums != other.retryQueueNums)
+ return false;
+ if (whichBrokerWhenConsumeSlowly != other.whichBrokerWhenConsumeSlowly)
+ return false;
+ if (notifyConsumerIdsChangedEnable != other.notifyConsumerIdsChangedEnable)
+ return false;
+ return true;
+ }
+
+
+ @Override
+ public String toString() {
+ return "SubscriptionGroupConfig [groupName=" + groupName + ", consumeEnable=" + consumeEnable
+ + ", consumeFromMinEnable=" + consumeFromMinEnable + ", consumeBroadcastEnable="
+ + consumeBroadcastEnable + ", retryQueueNums=" + retryQueueNums + ", retryMaxTimes="
+ + retryMaxTimes + ", brokerId=" + brokerId + ", whichBrokerWhenConsumeSlowly="
+ + whichBrokerWhenConsumeSlowly + ", notifyConsumerIdsChangedEnable="
+ + notifyConsumerIdsChangedEnable + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java b/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java
new file mode 100644
index 0000000..8a069e5
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/sysflag/MessageSysFlag.java
@@ -0,0 +1,44 @@
+/**
+ * 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.common.sysflag;
+
+/**
+ * @author shijia.wxr
+ */
+public class MessageSysFlag {
+ public final static int COMPRESSED_FLAG = 0x1;
+ public final static int MULTI_TAGS_FLAG = 0x1 << 1;
+ public final static int TRANSACTION_NOT_TYPE = 0;
+ public final static int TRANSACTION_PREPARED_TYPE = 0x1 << 2;
+ public final static int TRANSACTION_COMMIT_TYPE = 0x2 << 2;
+ public final static int TRANSACTION_ROLLBACK_TYPE = 0x3 << 2;
+
+
+ public static int getTransactionValue(final int flag) {
+ return flag & TRANSACTION_ROLLBACK_TYPE;
+ }
+
+
+ public static int resetTransactionValue(final int flag, final int type) {
+ return (flag & (~TRANSACTION_ROLLBACK_TYPE)) | type;
+ }
+
+
+ public static int clearCompressedFlag(final int flag) {
+ return flag & (~COMPRESSED_FLAG);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java b/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java
new file mode 100644
index 0000000..cc2a5c8
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/sysflag/PullSysFlag.java
@@ -0,0 +1,76 @@
+/**
+ * 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.common.sysflag;
+
+/**
+ * @author shijia.wxr
+ */
+public class PullSysFlag {
+ private final static int FLAG_COMMIT_OFFSET = 0x1 << 0;
+ private final static int FLAG_SUSPEND = 0x1 << 1;
+ private final static int FLAG_SUBSCRIPTION = 0x1 << 2;
+ private final static int FLAG_CLASS_FILTER = 0x1 << 3;
+
+
+ public static int buildSysFlag(final boolean commitOffset, final boolean suspend,
+ final boolean subscription, final boolean classFilter) {
+ int flag = 0;
+
+ if (commitOffset) {
+ flag |= FLAG_COMMIT_OFFSET;
+ }
+
+ if (suspend) {
+ flag |= FLAG_SUSPEND;
+ }
+
+ if (subscription) {
+ flag |= FLAG_SUBSCRIPTION;
+ }
+
+ if (classFilter) {
+ flag |= FLAG_CLASS_FILTER;
+ }
+
+ return flag;
+ }
+
+
+ public static int clearCommitOffsetFlag(final int sysFlag) {
+ return sysFlag & (~FLAG_COMMIT_OFFSET);
+ }
+
+
+ public static boolean hasCommitOffsetFlag(final int sysFlag) {
+ return (sysFlag & FLAG_COMMIT_OFFSET) == FLAG_COMMIT_OFFSET;
+ }
+
+
+ public static boolean hasSuspendFlag(final int sysFlag) {
+ return (sysFlag & FLAG_SUSPEND) == FLAG_SUSPEND;
+ }
+
+
+ public static boolean hasSubscriptionFlag(final int sysFlag) {
+ return (sysFlag & FLAG_SUBSCRIPTION) == FLAG_SUBSCRIPTION;
+ }
+
+
+ public static boolean hasClassFilterFlag(final int sysFlag) {
+ return (sysFlag & FLAG_CLASS_FILTER) == FLAG_CLASS_FILTER;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/sysflag/SubscriptionSysFlag.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/sysflag/SubscriptionSysFlag.java b/common/src/main/java/org/apache/rocketmq/common/sysflag/SubscriptionSysFlag.java
new file mode 100644
index 0000000..2761a0b
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/sysflag/SubscriptionSysFlag.java
@@ -0,0 +1,55 @@
+/**
+ * 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.common.sysflag;
+
+/**
+ * @author manhong.yqd
+ */
+public class SubscriptionSysFlag {
+
+ private final static int FLAG_UNIT = 0x1 << 0;
+
+
+ public static int buildSysFlag(final boolean unit) {
+ int sysFlag = 0;
+
+ if (unit) {
+ sysFlag |= FLAG_UNIT;
+ }
+
+ return sysFlag;
+ }
+
+
+ public static int setUnitFlag(final int sysFlag) {
+ return sysFlag | FLAG_UNIT;
+ }
+
+
+ public static int clearUnitFlag(final int sysFlag) {
+ return sysFlag & (~FLAG_UNIT);
+ }
+
+
+ public static boolean hasUnitFlag(final int sysFlag) {
+ return (sysFlag & FLAG_UNIT) == FLAG_UNIT;
+ }
+
+
+ public static void main(String[] args) {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/sysflag/TopicSysFlag.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/sysflag/TopicSysFlag.java b/common/src/main/java/org/apache/rocketmq/common/sysflag/TopicSysFlag.java
new file mode 100644
index 0000000..b12108a
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/sysflag/TopicSysFlag.java
@@ -0,0 +1,79 @@
+/**
+ * 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.common.sysflag;
+
+/**
+
+ *
+ * @author manhong.yqd
+ *
+ */
+public class TopicSysFlag {
+
+ private final static int FLAG_UNIT = 0x1 << 0;
+
+ private final static int FLAG_UNIT_SUB = 0x1 << 1;
+
+
+ public static int buildSysFlag(final boolean unit, final boolean hasUnitSub) {
+ int sysFlag = 0;
+
+ if (unit) {
+ sysFlag |= FLAG_UNIT;
+ }
+
+ if (hasUnitSub) {
+ sysFlag |= FLAG_UNIT_SUB;
+ }
+
+ return sysFlag;
+ }
+
+
+ public static int setUnitFlag(final int sysFlag) {
+ return sysFlag | FLAG_UNIT;
+ }
+
+
+ public static int clearUnitFlag(final int sysFlag) {
+ return sysFlag & (~FLAG_UNIT);
+ }
+
+
+ public static boolean hasUnitFlag(final int sysFlag) {
+ return (sysFlag & FLAG_UNIT) == FLAG_UNIT;
+ }
+
+
+ public static int setUnitSubFlag(final int sysFlag) {
+ return sysFlag | FLAG_UNIT_SUB;
+ }
+
+
+ public static int clearUnitSubFlag(final int sysFlag) {
+ return sysFlag & (~FLAG_UNIT_SUB);
+ }
+
+
+ public static boolean hasUnitSubFlag(final int sysFlag) {
+ return (sysFlag & FLAG_UNIT_SUB) == FLAG_UNIT_SUB;
+ }
+
+
+ public static void main(String[] args) {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/utils/ChannelUtil.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/utils/ChannelUtil.java b/common/src/main/java/org/apache/rocketmq/common/utils/ChannelUtil.java
new file mode 100644
index 0000000..ab017f2
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/utils/ChannelUtil.java
@@ -0,0 +1,35 @@
+/**
+ * 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.common.utils;
+
+import io.netty.channel.Channel;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+
+public class ChannelUtil {
+ public static String getRemoteIp(Channel channel) {
+ InetSocketAddress inetSocketAddress = (InetSocketAddress) channel.remoteAddress();
+ if (inetSocketAddress == null) {
+ return "";
+ }
+ final InetAddress inetAddr = inetSocketAddress.getAddress();
+ return inetAddr != null ? inetAddr.getHostAddress() : inetSocketAddress.getHostName();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/utils/HttpTinyClient.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/utils/HttpTinyClient.java b/common/src/main/java/org/apache/rocketmq/common/utils/HttpTinyClient.java
new file mode 100755
index 0000000..fcd002c
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/utils/HttpTinyClient.java
@@ -0,0 +1,154 @@
+/**
+ * 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.common.utils;
+
+import org.apache.rocketmq.common.MQVersion;
+import org.apache.rocketmq.common.MixAll;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.Iterator;
+import java.util.List;
+
+
+public class HttpTinyClient {
+
+ static public HttpResult httpGet(String url, List<String> headers, List<String> paramValues,
+ String encoding, long readTimeoutMs) throws IOException {
+ String encodedContent = encodingParams(paramValues, encoding);
+ url += (null == encodedContent) ? "" : ("?" + encodedContent);
+
+ HttpURLConnection conn = null;
+ try {
+ conn = (HttpURLConnection) new URL(url).openConnection();
+ conn.setRequestMethod("GET");
+ conn.setConnectTimeout((int) readTimeoutMs);
+ conn.setReadTimeout((int) readTimeoutMs);
+ setHeaders(conn, headers, encoding);
+
+ conn.connect();
+ int respCode = conn.getResponseCode();
+ String resp = null;
+
+ if (HttpURLConnection.HTTP_OK == respCode) {
+ resp = IOTinyUtils.toString(conn.getInputStream(), encoding);
+ } else {
+ resp = IOTinyUtils.toString(conn.getErrorStream(), encoding);
+ }
+ return new HttpResult(respCode, resp);
+ } finally {
+ if (conn != null) {
+ conn.disconnect();
+ }
+ }
+ }
+
+ static private String encodingParams(List<String> paramValues, String encoding)
+ throws UnsupportedEncodingException {
+ StringBuilder sb = new StringBuilder();
+ if (null == paramValues) {
+ return null;
+ }
+
+ for (Iterator<String> iter = paramValues.iterator(); iter.hasNext(); ) {
+ sb.append(iter.next()).append("=");
+ sb.append(URLEncoder.encode(iter.next(), encoding));
+ if (iter.hasNext()) {
+ sb.append("&");
+ }
+ }
+ return sb.toString();
+ }
+
+ static private void setHeaders(HttpURLConnection conn, List<String> headers, String encoding) {
+ if (null != headers) {
+ for (Iterator<String> iter = headers.iterator(); iter.hasNext(); ) {
+ conn.addRequestProperty(iter.next(), iter.next());
+ }
+ }
+ conn.addRequestProperty("Client-Version", MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION));
+ conn.addRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + encoding);
+
+
+ String ts = String.valueOf(System.currentTimeMillis());
+ conn.addRequestProperty("Metaq-Client-RequestTS", ts);
+ }
+
+ /**
+
+ *
+ * @param url
+ * @param headers
+
+ * @param paramValues
+
+ * @param encoding
+
+ * @param readTimeoutMs
+
+ *
+ * @return the http response of given http post request
+ *
+ * @throws java.io.IOException
+ */
+ static public HttpResult httpPost(String url, List<String> headers, List<String> paramValues,
+ String encoding, long readTimeoutMs) throws IOException {
+ String encodedContent = encodingParams(paramValues, encoding);
+
+ HttpURLConnection conn = null;
+ try {
+ conn = (HttpURLConnection) new URL(url).openConnection();
+ conn.setRequestMethod("POST");
+ conn.setConnectTimeout(3000);
+ conn.setReadTimeout((int) readTimeoutMs);
+ conn.setDoOutput(true);
+ conn.setDoInput(true);
+ setHeaders(conn, headers, encoding);
+
+ conn.getOutputStream().write(encodedContent.getBytes(MixAll.DEFAULT_CHARSET));
+
+ int respCode = conn.getResponseCode();
+ String resp = null;
+
+ if (HttpURLConnection.HTTP_OK == respCode) {
+ resp = IOTinyUtils.toString(conn.getInputStream(), encoding);
+ } else {
+ resp = IOTinyUtils.toString(conn.getErrorStream(), encoding);
+ }
+ return new HttpResult(respCode, resp);
+ } finally {
+ if (null != conn) {
+ conn.disconnect();
+ }
+ }
+ }
+
+ static public class HttpResult {
+ final public int code;
+ final public String content;
+
+
+ public HttpResult(int code, String content) {
+ this.code = code;
+ this.content = content;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java b/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java
new file mode 100644
index 0000000..3284759
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java
@@ -0,0 +1,167 @@
+/**
+ * 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.common.utils;
+
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+
+import java.io.*;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @author manhong.yqd
+ */
+public class IOTinyUtils {
+
+ static public String toString(InputStream input, String encoding) throws IOException {
+ return (null == encoding) ? toString(new InputStreamReader(input, RemotingHelper.DEFAULT_CHARSET)) : toString(new InputStreamReader(
+ input, encoding));
+ }
+
+
+ static public String toString(Reader reader) throws IOException {
+ CharArrayWriter sw = new CharArrayWriter();
+ copy(reader, sw);
+ return sw.toString();
+ }
+
+
+ static public long copy(Reader input, Writer output) throws IOException {
+ char[] buffer = new char[1 << 12];
+ long count = 0;
+ for (int n = 0; (n = input.read(buffer)) >= 0; ) {
+ output.write(buffer, 0, n);
+ count += n;
+ }
+ return count;
+ }
+
+
+ /**
+
+ */
+ static public List<String> readLines(Reader input) throws IOException {
+ BufferedReader reader = toBufferedReader(input);
+ List<String> list = new ArrayList<String>();
+ String line = null;
+ for (;;) {
+ line = reader.readLine();
+ if (null != line) {
+ list.add(line);
+ } else {
+ break;
+ }
+ }
+ return list;
+ }
+
+
+ static private BufferedReader toBufferedReader(Reader reader) {
+ return reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader);
+ }
+
+
+ static public void copyFile(String source, String target) throws IOException {
+ File sf = new File(source);
+ if (!sf.exists()) {
+ throw new IllegalArgumentException("source file does not exist.");
+ }
+ File tf = new File(target);
+ tf.getParentFile().mkdirs();
+ if (!tf.exists() && !tf.createNewFile()) {
+ throw new RuntimeException("failed to create target file.");
+ }
+
+ FileChannel sc = null;
+ FileChannel tc = null;
+ try {
+ tc = new FileOutputStream(tf).getChannel();
+ sc = new FileInputStream(sf).getChannel();
+ sc.transferTo(0, sc.size(), tc);
+ } finally {
+ if (null != sc) {
+ sc.close();
+ }
+ if (null != tc) {
+ tc.close();
+ }
+ }
+ }
+
+
+ public static void delete(File fileOrDir) throws IOException {
+ if (fileOrDir == null) {
+ return;
+ }
+
+ if (fileOrDir.isDirectory()) {
+ cleanDirectory(fileOrDir);
+ }
+
+ fileOrDir.delete();
+ }
+
+
+ /**
+
+ */
+ public static void cleanDirectory(File directory) throws IOException {
+ if (!directory.exists()) {
+ String message = directory + " does not exist";
+ throw new IllegalArgumentException(message);
+ }
+
+ if (!directory.isDirectory()) {
+ String message = directory + " is not a directory";
+ throw new IllegalArgumentException(message);
+ }
+
+ File[] files = directory.listFiles();
+ if (files == null) { // null if security restricted
+ throw new IOException("Failed to list contents of " + directory);
+ }
+
+ IOException exception = null;
+ for (File file : files) {
+ try {
+ delete(file);
+ } catch (IOException ioe) {
+ exception = ioe;
+ }
+ }
+
+ if (null != exception) {
+ throw exception;
+ }
+ }
+
+
+ public static void writeStringToFile(File file, String data, String encoding) throws IOException {
+ OutputStream os = null;
+ try {
+ os = new FileOutputStream(file);
+ os.write(data.getBytes(encoding));
+ } finally {
+ if (null != os) {
+ os.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/test/java/com/alibaba/rocketmq/common/MixAllTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/com/alibaba/rocketmq/common/MixAllTest.java b/common/src/test/java/com/alibaba/rocketmq/common/MixAllTest.java
deleted file mode 100644
index 72e02d0..0000000
--- a/common/src/test/java/com/alibaba/rocketmq/common/MixAllTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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.common;
-
-import junit.framework.Assert;
-import org.junit.Test;
-
-import java.net.InetAddress;
-import java.util.List;
-
-
-/**
- * @author lansheng.zj
- */
-public class MixAllTest {
-
- @Test
- public void test() throws Exception {
- List<String> localInetAddress = MixAll.getLocalInetAddress();
- String local = InetAddress.getLocalHost().getHostAddress();
- Assert.assertTrue(localInetAddress.contains("127.0.0.1"));
- Assert.assertTrue(localInetAddress.contains(local));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/test/java/com/alibaba/rocketmq/common/RemotingUtilTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/com/alibaba/rocketmq/common/RemotingUtilTest.java b/common/src/test/java/com/alibaba/rocketmq/common/RemotingUtilTest.java
deleted file mode 100644
index e6468b9..0000000
--- a/common/src/test/java/com/alibaba/rocketmq/common/RemotingUtilTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 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.common;
-
-import com.alibaba.rocketmq.remoting.common.RemotingUtil;
-import org.junit.Test;
-
-
-public class RemotingUtilTest {
- @Test
- public void test() throws Exception {
- String a = RemotingUtil.getLocalAddress();
- System.out.println(a);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/test/java/com/alibaba/rocketmq/common/UtilAllTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/com/alibaba/rocketmq/common/UtilAllTest.java b/common/src/test/java/com/alibaba/rocketmq/common/UtilAllTest.java
deleted file mode 100644
index 7764fcc..0000000
--- a/common/src/test/java/com/alibaba/rocketmq/common/UtilAllTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- * 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.common;
-
-import org.junit.Test;
-
-import java.net.URL;
-import java.util.Properties;
-
-import static org.junit.Assert.assertTrue;
-
-
-public class UtilAllTest {
-
- @Test
- public void test_currentStackTrace() {
- System.out.println(UtilAll.currentStackTrace());
- }
-
-
- @Test
- public void test_a() {
- URL url = this.getClass().getProtectionDomain().getCodeSource().getLocation();
- System.out.println(url);
- System.out.println(url.getPath());
- }
-
-
- @Test
- public void test_resetClassProperties() {
- DemoConfig demoConfig = new DemoConfig();
- MixAll.properties2Object(new Properties(), demoConfig);
- }
-
-
- @Test
- public void test_properties2String() {
- DemoConfig demoConfig = new DemoConfig();
- Properties properties = MixAll.object2Properties(demoConfig);
- System.out.println(MixAll.properties2String(properties));
- }
-
-
- @Test
- public void test_timeMillisToHumanString() {
- System.out.println(UtilAll.timeMillisToHumanString());
- }
-
-
- @Test
- public void test_isPropertiesEqual() {
- final Properties p1 = new Properties();
- final Properties p2 = new Properties();
-
- p1.setProperty("a", "1");
- p1.setProperty("b", "2");
-
- p2.setProperty("a", "1");
- p2.setProperty("b", "2");
- // p2.setProperty("c", "3");
-
- assertTrue(MixAll.isPropertiesEqual(p1, p2));
- }
-
-
- @Test
- public void test_getpid() {
- int pid = UtilAll.getPid();
-
- System.out.println("PID = " + pid);
- assertTrue(pid > 0);
- }
-
-
- @Test
- public void test_isBlank() {
- {
- boolean result = UtilAll.isBlank("Hello ");
- assertTrue(!result);
- }
-
- {
- boolean result = UtilAll.isBlank(" Hello");
- assertTrue(!result);
- }
-
- {
- boolean result = UtilAll.isBlank("He llo");
- assertTrue(!result);
- }
-
- {
- boolean result = UtilAll.isBlank(" ");
- assertTrue(result);
- }
-
- {
- boolean result = UtilAll.isBlank("Hello");
- assertTrue(!result);
- }
- }
-
- static class DemoConfig {
- private int demoWidth = 0;
- private int demoLength = 0;
- private boolean demoOK = false;
- private String demoName = "haha";
-
-
- public int getDemoWidth() {
- return demoWidth;
- }
-
-
- public void setDemoWidth(int demoWidth) {
- this.demoWidth = demoWidth;
- }
-
-
- public int getDemoLength() {
- return demoLength;
- }
-
-
- public void setDemoLength(int demoLength) {
- this.demoLength = demoLength;
- }
-
-
- public boolean isDemoOK() {
- return demoOK;
- }
-
-
- public void setDemoOK(boolean demoOK) {
- this.demoOK = demoOK;
- }
-
-
- public String getDemoName() {
- return demoName;
- }
-
-
- public void setDemoNfieldame(String demoName) {
- this.demoName = demoName;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/test/java/com/alibaba/rocketmq/common/filter/FilterAPITest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/com/alibaba/rocketmq/common/filter/FilterAPITest.java b/common/src/test/java/com/alibaba/rocketmq/common/filter/FilterAPITest.java
deleted file mode 100644
index e45873b..0000000
--- a/common/src/test/java/com/alibaba/rocketmq/common/filter/FilterAPITest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * 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.common.filter;
-
-import com.alibaba.rocketmq.common.protocol.heartbeat.SubscriptionData;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-import org.junit.Test;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class FilterAPITest {
-
- @Test
- public void testBuildSubscriptionData() throws Exception {
- SubscriptionData subscriptionData =
- FilterAPI.buildSubscriptionData("ConsumerGroup1", "TestTopic", "TAG1 || Tag2 || tag3");
- System.out.println(subscriptionData);
- }
-
- @Test
- public void testSubscriptionData() throws Exception {
- SubscriptionData subscriptionData =
- FilterAPI.buildSubscriptionData("ConsumerGroup1", "TestTopic", "TAG1 || Tag2 || tag3");
- subscriptionData.setFilterClassSource("java hello");
- String json = RemotingSerializable.toJson(subscriptionData, true);
- System.out.println(json);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/test/java/com/alibaba/rocketmq/common/filter/PolishExprTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/com/alibaba/rocketmq/common/filter/PolishExprTest.java b/common/src/test/java/com/alibaba/rocketmq/common/filter/PolishExprTest.java
deleted file mode 100644
index 612df69..0000000
--- a/common/src/test/java/com/alibaba/rocketmq/common/filter/PolishExprTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * 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.common.filter;
-
-import com.alibaba.rocketmq.common.filter.impl.Op;
-import com.alibaba.rocketmq.common.filter.impl.PolishExpr;
-import junit.framework.Assert;
-import org.junit.Test;
-
-import java.util.List;
-
-
-/**
- * @author lansheng.zj
- */
-public class PolishExprTest {
-
- private String expression = "tag1||(tag2&&tag3)&&tag4||tag5&&(tag6 && tag7)|| tag8 && tag9";
- private PolishExpr polishExpr;
-
-
- public void init() {
- polishExpr = new PolishExpr();
- }
-
-
- @Test
- public void testReversePolish() {
- List<Op> antiPolishExpression = polishExpr.reversePolish(expression);
- System.out.println(antiPolishExpression);
- }
-
-
- @Test
- public void testReversePolish_Performance() {
- // prepare
- for (int i = 0; i < 100000; i++) {
- polishExpr.reversePolish(expression);
- }
-
- long start = System.currentTimeMillis();
- for (int i = 0; i < 100000; i++) {
- polishExpr.reversePolish(expression);
- }
- long cost = System.currentTimeMillis() - start;
- System.out.println(cost);
- // System.out.println(cost / 100000F);
-
- Assert.assertTrue(cost < 500);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/test/java/com/alibaba/rocketmq/common/protocol/ConsumeStatusTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/com/alibaba/rocketmq/common/protocol/ConsumeStatusTest.java b/common/src/test/java/com/alibaba/rocketmq/common/protocol/ConsumeStatusTest.java
deleted file mode 100644
index 32e3d98..0000000
--- a/common/src/test/java/com/alibaba/rocketmq/common/protocol/ConsumeStatusTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * 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.common.protocol;
-
-import com.alibaba.rocketmq.common.protocol.body.ConsumeStatus;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-import org.junit.Test;
-
-
-public class ConsumeStatusTest {
-
- @Test
- public void decode_test() throws Exception {
- ConsumeStatus cs = new ConsumeStatus();
- cs.setConsumeFailedTPS(0L);
- String json = RemotingSerializable.toJson(cs, true);
- System.out.println(json);
- ConsumeStatus fromJson = RemotingSerializable.fromJson(json, ConsumeStatus.class);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/test/java/com/alibaba/rocketmq/common/protocol/MQProtosHelperTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/com/alibaba/rocketmq/common/protocol/MQProtosHelperTest.java b/common/src/test/java/com/alibaba/rocketmq/common/protocol/MQProtosHelperTest.java
deleted file mode 100644
index 749e7df..0000000
--- a/common/src/test/java/com/alibaba/rocketmq/common/protocol/MQProtosHelperTest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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.common.protocol;
-
-/**
- * @author shijia.wxr
- */
-public class MQProtosHelperTest {
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java b/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java
new file mode 100644
index 0000000..6e7c17b
--- /dev/null
+++ b/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java
@@ -0,0 +1,39 @@
+/**
+ * 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.common;
+
+import junit.framework.Assert;
+import org.junit.Test;
+
+import java.net.InetAddress;
+import java.util.List;
+
+
+/**
+ * @author lansheng.zj
+ */
+public class MixAllTest {
+
+ @Test
+ public void test() throws Exception {
+ List<String> localInetAddress = MixAll.getLocalInetAddress();
+ String local = InetAddress.getLocalHost().getHostAddress();
+ Assert.assertTrue(localInetAddress.contains("127.0.0.1"));
+ Assert.assertTrue(localInetAddress.contains(local));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/test/java/org/apache/rocketmq/common/RemotingUtilTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/rocketmq/common/RemotingUtilTest.java b/common/src/test/java/org/apache/rocketmq/common/RemotingUtilTest.java
new file mode 100644
index 0000000..b7509b1
--- /dev/null
+++ b/common/src/test/java/org/apache/rocketmq/common/RemotingUtilTest.java
@@ -0,0 +1,29 @@
+/**
+ * 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.common;
+
+import org.apache.rocketmq.remoting.common.RemotingUtil;
+import org.junit.Test;
+
+
+public class RemotingUtilTest {
+ @Test
+ public void test() throws Exception {
+ String a = RemotingUtil.getLocalAddress();
+ System.out.println(a);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java b/common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java
new file mode 100644
index 0000000..decd3d0
--- /dev/null
+++ b/common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java
@@ -0,0 +1,164 @@
+/**
+ * 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.common;
+
+import org.junit.Test;
+
+import java.net.URL;
+import java.util.Properties;
+
+import static org.junit.Assert.assertTrue;
+
+
+public class UtilAllTest {
+
+ @Test
+ public void test_currentStackTrace() {
+ System.out.println(UtilAll.currentStackTrace());
+ }
+
+
+ @Test
+ public void test_a() {
+ URL url = this.getClass().getProtectionDomain().getCodeSource().getLocation();
+ System.out.println(url);
+ System.out.println(url.getPath());
+ }
+
+
+ @Test
+ public void test_resetClassProperties() {
+ DemoConfig demoConfig = new DemoConfig();
+ MixAll.properties2Object(new Properties(), demoConfig);
+ }
+
+
+ @Test
+ public void test_properties2String() {
+ DemoConfig demoConfig = new DemoConfig();
+ Properties properties = MixAll.object2Properties(demoConfig);
+ System.out.println(MixAll.properties2String(properties));
+ }
+
+
+ @Test
+ public void test_timeMillisToHumanString() {
+ System.out.println(UtilAll.timeMillisToHumanString());
+ }
+
+
+ @Test
+ public void test_isPropertiesEqual() {
+ final Properties p1 = new Properties();
+ final Properties p2 = new Properties();
+
+ p1.setProperty("a", "1");
+ p1.setProperty("b", "2");
+
+ p2.setProperty("a", "1");
+ p2.setProperty("b", "2");
+ // p2.setProperty("c", "3");
+
+ assertTrue(MixAll.isPropertiesEqual(p1, p2));
+ }
+
+
+ @Test
+ public void test_getpid() {
+ int pid = UtilAll.getPid();
+
+ System.out.println("PID = " + pid);
+ assertTrue(pid > 0);
+ }
+
+
+ @Test
+ public void test_isBlank() {
+ {
+ boolean result = UtilAll.isBlank("Hello ");
+ assertTrue(!result);
+ }
+
+ {
+ boolean result = UtilAll.isBlank(" Hello");
+ assertTrue(!result);
+ }
+
+ {
+ boolean result = UtilAll.isBlank("He llo");
+ assertTrue(!result);
+ }
+
+ {
+ boolean result = UtilAll.isBlank(" ");
+ assertTrue(result);
+ }
+
+ {
+ boolean result = UtilAll.isBlank("Hello");
+ assertTrue(!result);
+ }
+ }
+
+ static class DemoConfig {
+ private int demoWidth = 0;
+ private int demoLength = 0;
+ private boolean demoOK = false;
+ private String demoName = "haha";
+
+
+ public int getDemoWidth() {
+ return demoWidth;
+ }
+
+
+ public void setDemoWidth(int demoWidth) {
+ this.demoWidth = demoWidth;
+ }
+
+
+ public int getDemoLength() {
+ return demoLength;
+ }
+
+
+ public void setDemoLength(int demoLength) {
+ this.demoLength = demoLength;
+ }
+
+
+ public boolean isDemoOK() {
+ return demoOK;
+ }
+
+
+ public void setDemoOK(boolean demoOK) {
+ this.demoOK = demoOK;
+ }
+
+
+ public String getDemoName() {
+ return demoName;
+ }
+
+
+ public void setDemoNfieldame(String demoName) {
+ this.demoName = demoName;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java b/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java
new file mode 100644
index 0000000..b67c59a
--- /dev/null
+++ b/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java
@@ -0,0 +1,46 @@
+/**
+ * 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.common.filter;
+
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+import org.junit.Test;
+
+
+/**
+ * @author shijia.wxr
+ *
+ */
+public class FilterAPITest {
+
+ @Test
+ public void testBuildSubscriptionData() throws Exception {
+ SubscriptionData subscriptionData =
+ FilterAPI.buildSubscriptionData("ConsumerGroup1", "TestTopic", "TAG1 || Tag2 || tag3");
+ System.out.println(subscriptionData);
+ }
+
+ @Test
+ public void testSubscriptionData() throws Exception {
+ SubscriptionData subscriptionData =
+ FilterAPI.buildSubscriptionData("ConsumerGroup1", "TestTopic", "TAG1 || Tag2 || tag3");
+ subscriptionData.setFilterClassSource("java hello");
+ String json = RemotingSerializable.toJson(subscriptionData, true);
+ System.out.println(json);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/test/java/org/apache/rocketmq/common/filter/PolishExprTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/rocketmq/common/filter/PolishExprTest.java b/common/src/test/java/org/apache/rocketmq/common/filter/PolishExprTest.java
new file mode 100644
index 0000000..f2ba2a3
--- /dev/null
+++ b/common/src/test/java/org/apache/rocketmq/common/filter/PolishExprTest.java
@@ -0,0 +1,67 @@
+/**
+ * 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.common.filter;
+
+import org.apache.rocketmq.common.filter.impl.Op;
+import org.apache.rocketmq.common.filter.impl.PolishExpr;
+import junit.framework.Assert;
+import org.junit.Test;
+
+import java.util.List;
+
+
+/**
+ * @author lansheng.zj
+ */
+public class PolishExprTest {
+
+ private String expression = "tag1||(tag2&&tag3)&&tag4||tag5&&(tag6 && tag7)|| tag8 && tag9";
+ private PolishExpr polishExpr;
+
+
+ public void init() {
+ polishExpr = new PolishExpr();
+ }
+
+
+ @Test
+ public void testReversePolish() {
+ List<Op> antiPolishExpression = polishExpr.reversePolish(expression);
+ System.out.println(antiPolishExpression);
+ }
+
+
+ @Test
+ public void testReversePolish_Performance() {
+ // prepare
+ for (int i = 0; i < 100000; i++) {
+ polishExpr.reversePolish(expression);
+ }
+
+ long start = System.currentTimeMillis();
+ for (int i = 0; i < 100000; i++) {
+ polishExpr.reversePolish(expression);
+ }
+ long cost = System.currentTimeMillis() - start;
+ System.out.println(cost);
+ // System.out.println(cost / 100000F);
+
+ Assert.assertTrue(cost < 500);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/test/java/org/apache/rocketmq/common/protocol/ConsumeStatusTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/rocketmq/common/protocol/ConsumeStatusTest.java b/common/src/test/java/org/apache/rocketmq/common/protocol/ConsumeStatusTest.java
new file mode 100644
index 0000000..79c6bbf
--- /dev/null
+++ b/common/src/test/java/org/apache/rocketmq/common/protocol/ConsumeStatusTest.java
@@ -0,0 +1,36 @@
+/**
+ * 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.common.protocol;
+
+import org.apache.rocketmq.common.protocol.body.ConsumeStatus;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+import org.junit.Test;
+
+
+public class ConsumeStatusTest {
+
+ @Test
+ public void decode_test() throws Exception {
+ ConsumeStatus cs = new ConsumeStatus();
+ cs.setConsumeFailedTPS(0L);
+ String json = RemotingSerializable.toJson(cs, true);
+ System.out.println(json);
+ ConsumeStatus fromJson = RemotingSerializable.fromJson(json, ConsumeStatus.class);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/test/java/org/apache/rocketmq/common/protocol/MQProtosHelperTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/rocketmq/common/protocol/MQProtosHelperTest.java b/common/src/test/java/org/apache/rocketmq/common/protocol/MQProtosHelperTest.java
new file mode 100644
index 0000000..cd56627
--- /dev/null
+++ b/common/src/test/java/org/apache/rocketmq/common/protocol/MQProtosHelperTest.java
@@ -0,0 +1,25 @@
+/**
+ * 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.common.protocol;
+
+/**
+ * @author shijia.wxr
+ */
+public class MQProtosHelperTest {
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/pom.xml
----------------------------------------------------------------------
diff --git a/example/pom.xml b/example/pom.xml
index 8e68a58..53aa6a6 100644
--- a/example/pom.xml
+++ b/example/pom.xml
@@ -18,7 +18,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.rocketmq</groupId>
+ <groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-all</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>
[16/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumerOffsetSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumerOffsetSerializeWrapper.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumerOffsetSerializeWrapper.java
deleted file mode 100644
index 7af4e7a..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumerOffsetSerializeWrapper.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.concurrent.ConcurrentHashMap;
-
-
-/**
- * @author manhong.yqd
- */
-public class ConsumerOffsetSerializeWrapper extends RemotingSerializable {
- private ConcurrentHashMap<String/* topic@group */, ConcurrentHashMap<Integer, Long>> offsetTable =
- new ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>>(512);
-
-
- public ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>> getOffsetTable() {
- return offsetTable;
- }
-
-
- public void setOffsetTable(ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>> offsetTable) {
- this.offsetTable = offsetTable;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumerRunningInfo.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumerRunningInfo.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumerRunningInfo.java
deleted file mode 100644
index 56babc2..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ConsumerRunningInfo.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType;
-import com.alibaba.rocketmq.common.protocol.heartbeat.SubscriptionData;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.*;
-import java.util.Map.Entry;
-
-public class ConsumerRunningInfo extends RemotingSerializable {
- public static final String PROP_NAMESERVER_ADDR = "PROP_NAMESERVER_ADDR";
- public static final String PROP_THREADPOOL_CORE_SIZE = "PROP_THREADPOOL_CORE_SIZE";
- public static final String PROP_CONSUME_ORDERLY = "PROP_CONSUMEORDERLY";
- public static final String PROP_CONSUME_TYPE = "PROP_CONSUME_TYPE";
- public static final String PROP_CLIENT_VERSION = "PROP_CLIENT_VERSION";
- public static final String PROP_CONSUMER_START_TIMESTAMP = "PROP_CONSUMER_START_TIMESTAMP";
-
-
- private Properties properties = new Properties();
-
- private TreeSet<SubscriptionData> subscriptionSet = new TreeSet<SubscriptionData>();
-
- private TreeMap<MessageQueue, ProcessQueueInfo> mqTable = new TreeMap<MessageQueue, ProcessQueueInfo>();
-
- private TreeMap<String/* Topic */, ConsumeStatus> statusTable = new TreeMap<String, ConsumeStatus>();
-
- private String jstack;
-
- public static boolean analyzeSubscription(final TreeMap<String/* clientId */, ConsumerRunningInfo> criTable) {
- ConsumerRunningInfo prev = criTable.firstEntry().getValue();
-
- boolean push = false;
- {
- String property = prev.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUME_TYPE);
-
- if (property == null) {
- property = ((ConsumeType) prev.getProperties().get(ConsumerRunningInfo.PROP_CONSUME_TYPE)).name();
- }
- push = ConsumeType.valueOf(property) == ConsumeType.CONSUME_PASSIVELY;
- }
-
- boolean startForAWhile = false;
- {
-
- String property = prev.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP);
- if (property == null) {
- property = String.valueOf(prev.getProperties().get(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP));
- }
- startForAWhile = (System.currentTimeMillis() - Long.parseLong(property)) > (1000 * 60 * 2);
- }
-
- if (push && startForAWhile) {
-
- {
- Iterator<Entry<String, ConsumerRunningInfo>> it = criTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, ConsumerRunningInfo> next = it.next();
- ConsumerRunningInfo current = next.getValue();
- boolean equals = current.getSubscriptionSet().equals(prev.getSubscriptionSet());
-
- if (!equals) {
- // Different subscription in the same group of consumer
- return false;
- }
-
- prev = next.getValue();
- }
-
- if (prev != null) {
-
- if (prev.getSubscriptionSet().isEmpty()) {
- // Subscription empty!
- return false;
- }
- }
- }
- }
-
- return true;
- }
-
- public Properties getProperties() {
- return properties;
- }
-
- public void setProperties(Properties properties) {
- this.properties = properties;
- }
-
- public TreeSet<SubscriptionData> getSubscriptionSet() {
- return subscriptionSet;
- }
-
- public void setSubscriptionSet(TreeSet<SubscriptionData> subscriptionSet) {
- this.subscriptionSet = subscriptionSet;
- }
-
- public static boolean analyzeRebalance(final TreeMap<String/* clientId */, ConsumerRunningInfo> criTable) {
- return true;
- }
-
- public static String analyzeProcessQueue(final String clientId, ConsumerRunningInfo info) {
- StringBuilder sb = new StringBuilder();
- boolean push = false;
- {
- String property = info.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUME_TYPE);
-
- if (property == null) {
- property = ((ConsumeType) info.getProperties().get(ConsumerRunningInfo.PROP_CONSUME_TYPE)).name();
- }
- push = ConsumeType.valueOf(property) == ConsumeType.CONSUME_PASSIVELY;
- }
-
- boolean orderMsg = false;
- {
- String property = info.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUME_ORDERLY);
- orderMsg = Boolean.parseBoolean(property);
- }
-
- if (push) {
- Iterator<Entry<MessageQueue, ProcessQueueInfo>> it = info.getMqTable().entrySet().iterator();
- while (it.hasNext()) {
- Entry<MessageQueue, ProcessQueueInfo> next = it.next();
- MessageQueue mq = next.getKey();
- ProcessQueueInfo pq = next.getValue();
-
-
- if (orderMsg) {
-
- if (!pq.isLocked()) {
- sb.append(String.format("%s %s can't lock for a while, %dms%n", //
- clientId, //
- mq, //
- System.currentTimeMillis() - pq.getLastLockTimestamp()));
- } else {
- if (pq.isDroped() && (pq.getTryUnlockTimes() > 0)) {
- sb.append(String.format("%s %s unlock %d times, still failed%n", //
- clientId, //
- mq, //
- pq.getTryUnlockTimes()));
- }
- }
-
-
- } else {
- long diff = System.currentTimeMillis() - pq.getLastConsumeTimestamp();
-
- if (diff > (1000 * 60) && pq.getCachedMsgCount() > 0) {
- sb.append(String.format("%s %s can't consume for a while, maybe blocked, %dms%n", //
- clientId, //
- mq, //
- diff));
- }
- }
- }
- }
-
- return sb.toString();
- }
-
- public TreeMap<MessageQueue, ProcessQueueInfo> getMqTable() {
- return mqTable;
- }
-
- public void setMqTable(TreeMap<MessageQueue, ProcessQueueInfo> mqTable) {
- this.mqTable = mqTable;
- }
-
- public TreeMap<String, ConsumeStatus> getStatusTable() {
- return statusTable;
- }
-
- public void setStatusTable(TreeMap<String, ConsumeStatus> statusTable) {
- this.statusTable = statusTable;
- }
-
- public String formatString() {
- StringBuilder sb = new StringBuilder();
-
- {
- sb.append("#Consumer Properties#\n");
- Iterator<Entry<Object, Object>> it = this.properties.entrySet().iterator();
- while (it.hasNext()) {
- Entry<Object, Object> next = it.next();
- String item = String.format("%-40s: %s%n", next.getKey().toString(), next.getValue().toString());
- sb.append(item);
- }
- }
-
- {
- sb.append("\n\n#Consumer Subscription#\n");
-
- Iterator<SubscriptionData> it = this.subscriptionSet.iterator();
- int i = 0;
- while (it.hasNext()) {
- SubscriptionData next = it.next();
- String item = String.format("%03d Topic: %-40s ClassFilter: %-8s SubExpression: %s%n", //
- ++i, //
- next.getTopic(), //
- next.isClassFilterMode(), //
- next.getSubString());
-
- sb.append(item);
- }
- }
-
- {
- sb.append("\n\n#Consumer Offset#\n");
- sb.append(String.format("%-32s %-32s %-4s %-20s%n", //
- "#Topic", //
- "#Broker Name", //
- "#QID", //
- "#Consumer Offset"//
- ));
-
- Iterator<Entry<MessageQueue, ProcessQueueInfo>> it = this.mqTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<MessageQueue, ProcessQueueInfo> next = it.next();
- String item = String.format("%-32s %-32s %-4d %-20d%n", //
- next.getKey().getTopic(), //
- next.getKey().getBrokerName(), //
- next.getKey().getQueueId(), //
- next.getValue().getCommitOffset());
-
- sb.append(item);
- }
- }
-
- {
- sb.append("\n\n#Consumer MQ Detail#\n");
- sb.append(String.format("%-32s %-32s %-4s %-20s%n", //
- "#Topic", //
- "#Broker Name", //
- "#QID", //
- "#ProcessQueueInfo"//
- ));
-
- Iterator<Entry<MessageQueue, ProcessQueueInfo>> it = this.mqTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<MessageQueue, ProcessQueueInfo> next = it.next();
- String item = String.format("%-32s %-32s %-4d %s%n", //
- next.getKey().getTopic(), //
- next.getKey().getBrokerName(), //
- next.getKey().getQueueId(), //
- next.getValue().toString());
-
- sb.append(item);
- }
- }
-
- {
- sb.append("\n\n#Consumer RT&TPS#\n");
- sb.append(String.format("%-32s %14s %14s %14s %14s %18s %25s%n", //
- "#Topic", //
- "#Pull RT", //
- "#Pull TPS", //
- "#Consume RT", //
- "#ConsumeOK TPS", //
- "#ConsumeFailed TPS", //
- "#ConsumeFailedMsgsInHour"//
- ));
-
- Iterator<Entry<String, ConsumeStatus>> it = this.statusTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, ConsumeStatus> next = it.next();
- String item = String.format("%-32s %14.2f %14.2f %14.2f %14.2f %18.2f %25d%n", //
- next.getKey(), //
- next.getValue().getPullRT(), //
- next.getValue().getPullTPS(), //
- next.getValue().getConsumeRT(), //
- next.getValue().getConsumeOKTPS(), //
- next.getValue().getConsumeFailedTPS(), //
- next.getValue().getConsumeFailedMsgs()//
- );
-
- sb.append(item);
- }
- }
-
- if (this.jstack != null) {
- sb.append("\n\n#Consumer jstack#\n");
- sb.append(this.jstack);
- }
-
- return sb.toString();
- }
-
- public String getJstack() {
- return jstack;
- }
-
-
- public void setJstack(String jstack) {
- this.jstack = jstack;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/GetConsumerStatusBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/GetConsumerStatusBody.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/GetConsumerStatusBody.java
deleted file mode 100644
index ca84f21..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/GetConsumerStatusBody.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * @author manhong.yqd
- */
-@Deprecated
-public class GetConsumerStatusBody extends RemotingSerializable {
- private Map<MessageQueue, Long> messageQueueTable = new HashMap<MessageQueue, Long>();
- private Map<String, Map<MessageQueue, Long>> consumerTable =
- new HashMap<String, Map<MessageQueue, Long>>();
-
-
- public Map<MessageQueue, Long> getMessageQueueTable() {
- return messageQueueTable;
- }
-
-
- public void setMessageQueueTable(Map<MessageQueue, Long> messageQueueTable) {
- this.messageQueueTable = messageQueueTable;
- }
-
-
- public Map<String, Map<MessageQueue, Long>> getConsumerTable() {
- return consumerTable;
- }
-
-
- public void setConsumerTable(Map<String, Map<MessageQueue, Long>> consumerTable) {
- this.consumerTable = consumerTable;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/GroupList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/GroupList.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/GroupList.java
deleted file mode 100644
index 9f7e500..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/GroupList.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.HashSet;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class GroupList extends RemotingSerializable {
- private HashSet<String> groupList = new HashSet<String>();
-
-
- public HashSet<String> getGroupList() {
- return groupList;
- }
-
-
- public void setGroupList(HashSet<String> groupList) {
- this.groupList = groupList;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/KVTable.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/KVTable.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/KVTable.java
deleted file mode 100644
index 41cfcb8..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/KVTable.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.HashMap;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class KVTable extends RemotingSerializable {
- private HashMap<String, String> table = new HashMap<String, String>();
-
-
- public HashMap<String, String> getTable() {
- return table;
- }
-
-
- public void setTable(HashMap<String, String> table) {
- this.table = table;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/LockBatchRequestBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/LockBatchRequestBody.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/LockBatchRequestBody.java
deleted file mode 100644
index 992f656..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/LockBatchRequestBody.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.HashSet;
-import java.util.Set;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class LockBatchRequestBody extends RemotingSerializable {
- private String consumerGroup;
- private String clientId;
- private Set<MessageQueue> mqSet = new HashSet<MessageQueue>();
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
-
- public String getClientId() {
- return clientId;
- }
-
-
- public void setClientId(String clientId) {
- this.clientId = clientId;
- }
-
-
- public Set<MessageQueue> getMqSet() {
- return mqSet;
- }
-
-
- public void setMqSet(Set<MessageQueue> mqSet) {
- this.mqSet = mqSet;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/LockBatchResponseBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/LockBatchResponseBody.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/LockBatchResponseBody.java
deleted file mode 100644
index 12f6c76..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/LockBatchResponseBody.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.HashSet;
-import java.util.Set;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class LockBatchResponseBody extends RemotingSerializable {
-
- private Set<MessageQueue> lockOKMQSet = new HashSet<MessageQueue>();
-
-
- public Set<MessageQueue> getLockOKMQSet() {
- return lockOKMQSet;
- }
-
-
- public void setLockOKMQSet(Set<MessageQueue> lockOKMQSet) {
- this.lockOKMQSet = lockOKMQSet;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ProcessQueueInfo.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ProcessQueueInfo.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ProcessQueueInfo.java
deleted file mode 100644
index 6c17443..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ProcessQueueInfo.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.common.UtilAll;
-
-
-public class ProcessQueueInfo {
- private long commitOffset;
-
- private long cachedMsgMinOffset;
- private long cachedMsgMaxOffset;
- private int cachedMsgCount;
-
- private long transactionMsgMinOffset;
- private long transactionMsgMaxOffset;
- private int transactionMsgCount;
-
- private boolean locked;
- private long tryUnlockTimes;
- private long lastLockTimestamp;
-
- private boolean droped;
- private long lastPullTimestamp;
- private long lastConsumeTimestamp;
-
-
- public long getCommitOffset() {
- return commitOffset;
- }
-
-
- public void setCommitOffset(long commitOffset) {
- this.commitOffset = commitOffset;
- }
-
-
- public long getCachedMsgMinOffset() {
- return cachedMsgMinOffset;
- }
-
-
- public void setCachedMsgMinOffset(long cachedMsgMinOffset) {
- this.cachedMsgMinOffset = cachedMsgMinOffset;
- }
-
-
- public long getCachedMsgMaxOffset() {
- return cachedMsgMaxOffset;
- }
-
-
- public void setCachedMsgMaxOffset(long cachedMsgMaxOffset) {
- this.cachedMsgMaxOffset = cachedMsgMaxOffset;
- }
-
-
- public int getCachedMsgCount() {
- return cachedMsgCount;
- }
-
-
- public void setCachedMsgCount(int cachedMsgCount) {
- this.cachedMsgCount = cachedMsgCount;
- }
-
-
- public long getTransactionMsgMinOffset() {
- return transactionMsgMinOffset;
- }
-
-
- public void setTransactionMsgMinOffset(long transactionMsgMinOffset) {
- this.transactionMsgMinOffset = transactionMsgMinOffset;
- }
-
-
- public long getTransactionMsgMaxOffset() {
- return transactionMsgMaxOffset;
- }
-
-
- public void setTransactionMsgMaxOffset(long transactionMsgMaxOffset) {
- this.transactionMsgMaxOffset = transactionMsgMaxOffset;
- }
-
-
- public int getTransactionMsgCount() {
- return transactionMsgCount;
- }
-
-
- public void setTransactionMsgCount(int transactionMsgCount) {
- this.transactionMsgCount = transactionMsgCount;
- }
-
-
- public boolean isLocked() {
- return locked;
- }
-
-
- public void setLocked(boolean locked) {
- this.locked = locked;
- }
-
-
- public long getTryUnlockTimes() {
- return tryUnlockTimes;
- }
-
-
- public void setTryUnlockTimes(long tryUnlockTimes) {
- this.tryUnlockTimes = tryUnlockTimes;
- }
-
-
- public long getLastLockTimestamp() {
- return lastLockTimestamp;
- }
-
-
- public void setLastLockTimestamp(long lastLockTimestamp) {
- this.lastLockTimestamp = lastLockTimestamp;
- }
-
-
- public boolean isDroped() {
- return droped;
- }
-
-
- public void setDroped(boolean droped) {
- this.droped = droped;
- }
-
-
- public long getLastPullTimestamp() {
- return lastPullTimestamp;
- }
-
-
- public void setLastPullTimestamp(long lastPullTimestamp) {
- this.lastPullTimestamp = lastPullTimestamp;
- }
-
-
- public long getLastConsumeTimestamp() {
- return lastConsumeTimestamp;
- }
-
-
- public void setLastConsumeTimestamp(long lastConsumeTimestamp) {
- this.lastConsumeTimestamp = lastConsumeTimestamp;
- }
-
-
- @Override
- public String toString() {
- return "ProcessQueueInfo [commitOffset=" + commitOffset + ", cachedMsgMinOffset="
- + cachedMsgMinOffset + ", cachedMsgMaxOffset=" + cachedMsgMaxOffset + ", cachedMsgCount="
- + cachedMsgCount + ", transactionMsgMinOffset=" + transactionMsgMinOffset
- + ", transactionMsgMaxOffset=" + transactionMsgMaxOffset + ", transactionMsgCount="
- + transactionMsgCount + ", locked=" + locked + ", tryUnlockTimes=" + tryUnlockTimes
- + ", lastLockTimestamp=" + UtilAll.timeMillisToHumanString(lastLockTimestamp) + ", droped="
- + droped + ", lastPullTimestamp=" + UtilAll.timeMillisToHumanString(lastPullTimestamp)
- + ", lastConsumeTimestamp=" + UtilAll.timeMillisToHumanString(lastConsumeTimestamp) + "]";
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ProducerConnection.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ProducerConnection.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ProducerConnection.java
deleted file mode 100644
index 32fe1d0..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ProducerConnection.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.HashSet;
-
-
-/**
- * @author shijia.wxr
- */
-public class ProducerConnection extends RemotingSerializable {
- private HashSet<Connection> connectionSet = new HashSet<Connection>();
-
-
- public HashSet<Connection> getConnectionSet() {
- return connectionSet;
- }
-
-
- public void setConnectionSet(HashSet<Connection> connectionSet) {
- this.connectionSet = connectionSet;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java
deleted file mode 100644
index 2f52666..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * @author manhong.yqd
- */
-public class QueryConsumeTimeSpanBody extends RemotingSerializable {
- List<QueueTimeSpan> consumeTimeSpanSet = new ArrayList<QueueTimeSpan>();
-
-
- public List<QueueTimeSpan> getConsumeTimeSpanSet() {
- return consumeTimeSpanSet;
- }
-
-
- public void setConsumeTimeSpanSet(List<QueueTimeSpan> consumeTimeSpanSet) {
- this.consumeTimeSpanSet = consumeTimeSpanSet;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java
deleted file mode 100644
index 225b90c..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * @author manhong.yqd
- */
-public class QueryCorrectionOffsetBody extends RemotingSerializable {
- private Map<Integer, Long> correctionOffsets = new HashMap<Integer, Long>();
-
-
- public Map<Integer, Long> getCorrectionOffsets() {
- return correctionOffsets;
- }
-
-
- public void setCorrectionOffsets(Map<Integer, Long> correctionOffsets) {
- this.correctionOffsets = correctionOffsets;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/QueueTimeSpan.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/QueueTimeSpan.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/QueueTimeSpan.java
deleted file mode 100644
index 14001ec..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/QueueTimeSpan.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-import java.util.Date;
-
-
-/**
- * @author manhong.yqd
- */
-public class QueueTimeSpan {
- private MessageQueue messageQueue;
- private long minTimeStamp;
- private long maxTimeStamp;
- private long consumeTimeStamp;
- private long delayTime;
-
-
- public MessageQueue getMessageQueue() {
- return messageQueue;
- }
-
-
- public void setMessageQueue(MessageQueue messageQueue) {
- this.messageQueue = messageQueue;
- }
-
-
- public long getMinTimeStamp() {
- return minTimeStamp;
- }
-
-
- public void setMinTimeStamp(long minTimeStamp) {
- this.minTimeStamp = minTimeStamp;
- }
-
-
- public long getMaxTimeStamp() {
- return maxTimeStamp;
- }
-
-
- public void setMaxTimeStamp(long maxTimeStamp) {
- this.maxTimeStamp = maxTimeStamp;
- }
-
-
- public long getConsumeTimeStamp() {
- return consumeTimeStamp;
- }
-
-
- public void setConsumeTimeStamp(long consumeTimeStamp) {
- this.consumeTimeStamp = consumeTimeStamp;
- }
-
-
- public String getMinTimeStampStr() {
- return UtilAll.formatDate(new Date(minTimeStamp), UtilAll.YYYY_MM_DD_HH_MM_SS_SSS);
- }
-
-
- public String getMaxTimeStampStr() {
- return UtilAll.formatDate(new Date(maxTimeStamp), UtilAll.YYYY_MM_DD_HH_MM_SS_SSS);
- }
-
-
- public String getConsumeTimeStampStr() {
- return UtilAll.formatDate(new Date(consumeTimeStamp), UtilAll.YYYY_MM_DD_HH_MM_SS_SSS);
- }
-
-
- public long getDelayTime() {
- return delayTime;
- }
-
-
- public void setDelayTime(long delayTime) {
- this.delayTime = delayTime;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/RegisterBrokerBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/RegisterBrokerBody.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/RegisterBrokerBody.java
deleted file mode 100644
index 364bbcb..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/RegisterBrokerBody.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-public class RegisterBrokerBody extends RemotingSerializable {
- private TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper();
- private List<String> filterServerList = new ArrayList<String>();
-
-
- public TopicConfigSerializeWrapper getTopicConfigSerializeWrapper() {
- return topicConfigSerializeWrapper;
- }
-
-
- public void setTopicConfigSerializeWrapper(TopicConfigSerializeWrapper topicConfigSerializeWrapper) {
- this.topicConfigSerializeWrapper = topicConfigSerializeWrapper;
- }
-
-
- public List<String> getFilterServerList() {
- return filterServerList;
- }
-
-
- public void setFilterServerList(List<String> filterServerList) {
- this.filterServerList = filterServerList;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ResetOffsetBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ResetOffsetBody.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ResetOffsetBody.java
deleted file mode 100644
index 2122e61..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ResetOffsetBody.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.Map;
-
-
-/**
- * @author manhong.yqd
- *
- */
-public class ResetOffsetBody extends RemotingSerializable {
- private Map<MessageQueue, Long> offsetTable;
-
-
- public Map<MessageQueue, Long> getOffsetTable() {
- return offsetTable;
- }
-
-
- public void setOffsetTable(Map<MessageQueue, Long> offsetTable) {
- this.offsetTable = offsetTable;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ResetOffsetBodyForC.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ResetOffsetBodyForC.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ResetOffsetBodyForC.java
deleted file mode 100644
index fb7360e..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/ResetOffsetBodyForC.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.common.message.MessageQueueForC;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.List;
-
-public class ResetOffsetBodyForC extends RemotingSerializable {
-
- private List<MessageQueueForC> offsetTable;
-
-
- public List<MessageQueueForC> getOffsetTable() {
- return offsetTable;
- }
-
-
- public void setOffsetTable(List<MessageQueueForC> offsetTable) {
- this.offsetTable = offsetTable;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/SubscriptionGroupWrapper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/SubscriptionGroupWrapper.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/SubscriptionGroupWrapper.java
deleted file mode 100644
index 096672c..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/SubscriptionGroupWrapper.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.common.DataVersion;
-import com.alibaba.rocketmq.common.subscription.SubscriptionGroupConfig;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.concurrent.ConcurrentHashMap;
-
-
-/**
- * @author manhong.yqd
- */
-public class SubscriptionGroupWrapper extends RemotingSerializable {
- private ConcurrentHashMap<String, SubscriptionGroupConfig> subscriptionGroupTable =
- new ConcurrentHashMap<String, SubscriptionGroupConfig>(1024);
- private DataVersion dataVersion = new DataVersion();
-
-
- public ConcurrentHashMap<String, SubscriptionGroupConfig> getSubscriptionGroupTable() {
- return subscriptionGroupTable;
- }
-
-
- public void setSubscriptionGroupTable(
- ConcurrentHashMap<String, SubscriptionGroupConfig> subscriptionGroupTable) {
- this.subscriptionGroupTable = subscriptionGroupTable;
- }
-
-
- public DataVersion getDataVersion() {
- return dataVersion;
- }
-
-
- public void setDataVersion(DataVersion dataVersion) {
- this.dataVersion = dataVersion;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/TopicConfigSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/TopicConfigSerializeWrapper.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/TopicConfigSerializeWrapper.java
deleted file mode 100644
index 0050762..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/TopicConfigSerializeWrapper.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.common.DataVersion;
-import com.alibaba.rocketmq.common.TopicConfig;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.concurrent.ConcurrentHashMap;
-
-
-public class TopicConfigSerializeWrapper extends RemotingSerializable {
- private ConcurrentHashMap<String, TopicConfig> topicConfigTable =
- new ConcurrentHashMap<String, TopicConfig>();
- private DataVersion dataVersion = new DataVersion();
-
-
- public ConcurrentHashMap<String, TopicConfig> getTopicConfigTable() {
- return topicConfigTable;
- }
-
-
- public void setTopicConfigTable(ConcurrentHashMap<String, TopicConfig> topicConfigTable) {
- this.topicConfigTable = topicConfigTable;
- }
-
-
- public DataVersion getDataVersion() {
- return dataVersion;
- }
-
-
- public void setDataVersion(DataVersion dataVersion) {
- this.dataVersion = dataVersion;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/TopicList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/TopicList.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/TopicList.java
deleted file mode 100644
index 84912ce..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/TopicList.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.HashSet;
-import java.util.Set;
-
-
-/**
- * @author shijia.wxr
- */
-public class TopicList extends RemotingSerializable {
- private Set<String> topicList = new HashSet<String>();
- private String brokerAddr;
-
-
- public Set<String> getTopicList() {
- return topicList;
- }
-
-
- public void setTopicList(Set<String> topicList) {
- this.topicList = topicList;
- }
-
-
- public String getBrokerAddr() {
- return brokerAddr;
- }
-
-
- public void setBrokerAddr(String brokerAddr) {
- this.brokerAddr = brokerAddr;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/UnlockBatchRequestBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/UnlockBatchRequestBody.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/UnlockBatchRequestBody.java
deleted file mode 100644
index 542b797..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/body/UnlockBatchRequestBody.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * 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.common.protocol.body;
-
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.HashSet;
-import java.util.Set;
-
-
-/**
- * @author shijia.wxr
- */
-public class UnlockBatchRequestBody extends RemotingSerializable {
- private String consumerGroup;
- private String clientId;
- private Set<MessageQueue> mqSet = new HashSet<MessageQueue>();
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
-
- public String getClientId() {
- return clientId;
- }
-
-
- public void setClientId(String clientId) {
- this.clientId = clientId;
- }
-
-
- public Set<MessageQueue> getMqSet() {
- return mqSet;
- }
-
-
- public void setMqSet(Set<MessageQueue> mqSet) {
- this.mqSet = mqSet;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
deleted file mode 100644
index 37d6a7f..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: EndTransactionRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class CheckTransactionStateRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private Long tranStateTableOffset;
- @CFNotNull
- private Long commitLogOffset;
- private String msgId;
- private String transactionId;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public Long getTranStateTableOffset() {
- return tranStateTableOffset;
- }
-
-
- public void setTranStateTableOffset(Long tranStateTableOffset) {
- this.tranStateTableOffset = tranStateTableOffset;
- }
-
-
- public Long getCommitLogOffset() {
- return commitLogOffset;
- }
-
-
- public void setCommitLogOffset(Long commitLogOffset) {
- this.commitLogOffset = commitLogOffset;
- }
-
- public String getMsgId() {
- return msgId;
- }
-
- public void setMsgId(String msgId) {
- this.msgId = msgId;
- }
-
- public String getTransactionId() {
- return transactionId;
- }
-
- public void setTransactionId(String transactionId) {
- this.transactionId = transactionId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
deleted file mode 100644
index 76c9732..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: EndTransactionResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.common.sysflag.MessageSysFlag;
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class CheckTransactionStateResponseHeader implements CommandCustomHeader {
- @CFNotNull
- private String producerGroup;
- @CFNotNull
- private Long tranStateTableOffset;
- @CFNotNull
- private Long commitLogOffset;
- @CFNotNull
- private Integer commitOrRollback; // TRANSACTION_COMMIT_TYPE
-
-
- // TRANSACTION_ROLLBACK_TYPE
-
- @Override
- public void checkFields() throws RemotingCommandException {
- if (MessageSysFlag.TRANSACTION_COMMIT_TYPE == this.commitOrRollback) {
- return;
- }
-
- if (MessageSysFlag.TRANSACTION_ROLLBACK_TYPE == this.commitOrRollback) {
- return;
- }
-
- throw new RemotingCommandException("commitOrRollback field wrong");
- }
-
-
- public String getProducerGroup() {
- return producerGroup;
- }
-
-
- public void setProducerGroup(String producerGroup) {
- this.producerGroup = producerGroup;
- }
-
-
- public Long getTranStateTableOffset() {
- return tranStateTableOffset;
- }
-
-
- public void setTranStateTableOffset(Long tranStateTableOffset) {
- this.tranStateTableOffset = tranStateTableOffset;
- }
-
-
- public Long getCommitLogOffset() {
- return commitLogOffset;
- }
-
-
- public void setCommitLogOffset(Long commitLogOffset) {
- this.commitLogOffset = commitLogOffset;
- }
-
-
- public Integer getCommitOrRollback() {
- return commitOrRollback;
- }
-
-
- public void setCommitOrRollback(Integer commitOrRollback) {
- this.commitOrRollback = commitOrRollback;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
deleted file mode 100644
index 6043229..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: DeleteTopicRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author manhong.yqd
- */
-public class CloneGroupOffsetRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String srcGroup;
- @CFNotNull
- private String destGroup;
- private String topic;
- private boolean offline;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getDestGroup() {
- return destGroup;
- }
-
-
- public void setDestGroup(String destGroup) {
- this.destGroup = destGroup;
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public String getSrcGroup() {
-
- return srcGroup;
- }
-
-
- public void setSrcGroup(String srcGroup) {
- this.srcGroup = srcGroup;
- }
-
-
- public boolean isOffline() {
- return offline;
- }
-
-
- public void setOffline(boolean offline) {
- this.offline = offline;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ConsumeMessageDirectlyResultRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ConsumeMessageDirectlyResultRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ConsumeMessageDirectlyResultRequestHeader.java
deleted file mode 100644
index 3c68636..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ConsumeMessageDirectlyResultRequestHeader.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.annotation.CFNullable;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-public class ConsumeMessageDirectlyResultRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String consumerGroup;
- @CFNullable
- private String clientId;
- @CFNullable
- private String msgId;
- @CFNullable
- private String brokerName;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
-
- public String getBrokerName() {
- return brokerName;
- }
-
-
- public void setBrokerName(String brokerName) {
- this.brokerName = brokerName;
- }
-
-
- public String getClientId() {
- return clientId;
- }
-
-
- public void setClientId(String clientId) {
- this.clientId = clientId;
- }
-
-
- public String getMsgId() {
- return msgId;
- }
-
-
- public void setMsgId(String msgId) {
- this.msgId = msgId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java
deleted file mode 100644
index c0acf88..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.annotation.CFNullable;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class ConsumerSendMsgBackRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private Long offset;
- @CFNotNull
- private String group;
- @CFNotNull
- private Integer delayLevel;
- private String originMsgId;
- private String originTopic;
- @CFNullable
- private boolean unitMode = false;
- private Integer maxReconsumeTimes;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
-
- }
-
-
- public Long getOffset() {
- return offset;
- }
-
-
- public void setOffset(Long offset) {
- this.offset = offset;
- }
-
-
- public String getGroup() {
- return group;
- }
-
-
- public void setGroup(String group) {
- this.group = group;
- }
-
-
- public Integer getDelayLevel() {
- return delayLevel;
- }
-
-
- public void setDelayLevel(Integer delayLevel) {
- this.delayLevel = delayLevel;
- }
-
-
- public String getOriginMsgId() {
- return originMsgId;
- }
-
-
- public void setOriginMsgId(String originMsgId) {
- this.originMsgId = originMsgId;
- }
-
-
- public String getOriginTopic() {
- return originTopic;
- }
-
-
- public void setOriginTopic(String originTopic) {
- this.originTopic = originTopic;
- }
-
-
- public boolean isUnitMode() {
- return unitMode;
- }
-
-
- public void setUnitMode(boolean unitMode) {
- this.unitMode = unitMode;
- }
-
-
- public Integer getMaxReconsumeTimes() {
- return maxReconsumeTimes;
- }
-
-
- public void setMaxReconsumeTimes(final Integer maxReconsumeTimes) {
- this.maxReconsumeTimes = maxReconsumeTimes;
- }
-
-
- @Override
- public String toString() {
- return "ConsumerSendMsgBackRequestHeader [group=" + group + ", originTopic=" + originTopic + ", originMsgId=" + originMsgId
- + ", delayLevel=" + delayLevel + ", unitMode=" + unitMode + ", maxReconsumeTimes=" + maxReconsumeTimes + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/CreateTopicRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
deleted file mode 100644
index a9d219c..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: CreateTopicRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.common.TopicFilterType;
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class CreateTopicRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String topic;
- @CFNotNull
- private String defaultTopic;
- @CFNotNull
- private Integer readQueueNums;
- @CFNotNull
- private Integer writeQueueNums;
- @CFNotNull
- private Integer perm;
- @CFNotNull
- private String topicFilterType;
- private Integer topicSysFlag;
- @CFNotNull
- private Boolean order = false;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- try {
- TopicFilterType.valueOf(this.topicFilterType);
- } catch (Exception e) {
- throw new RemotingCommandException("topicFilterType = [" + topicFilterType + "] value invalid", e);
- }
- }
-
-
- public TopicFilterType getTopicFilterTypeEnum() {
- return TopicFilterType.valueOf(this.topicFilterType);
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public String getDefaultTopic() {
- return defaultTopic;
- }
-
-
- public void setDefaultTopic(String defaultTopic) {
- this.defaultTopic = defaultTopic;
- }
-
-
- public Integer getReadQueueNums() {
- return readQueueNums;
- }
-
-
- public void setReadQueueNums(Integer readQueueNums) {
- this.readQueueNums = readQueueNums;
- }
-
-
- public Integer getWriteQueueNums() {
- return writeQueueNums;
- }
-
-
- public void setWriteQueueNums(Integer writeQueueNums) {
- this.writeQueueNums = writeQueueNums;
- }
-
-
- public Integer getPerm() {
- return perm;
- }
-
-
- public void setPerm(Integer perm) {
- this.perm = perm;
- }
-
-
- public String getTopicFilterType() {
- return topicFilterType;
- }
-
-
- public void setTopicFilterType(String topicFilterType) {
- this.topicFilterType = topicFilterType;
- }
-
-
- public Integer getTopicSysFlag() {
- return topicSysFlag;
- }
-
-
- public void setTopicSysFlag(Integer topicSysFlag) {
- this.topicSysFlag = topicSysFlag;
- }
-
-
- public Boolean getOrder() {
- return order;
- }
-
-
- public void setOrder(Boolean order) {
- this.order = order;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java
deleted file mode 100644
index 9307c01..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author manhong.yqd
- */
-public class DeleteSubscriptionGroupRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String groupName;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getGroupName() {
- return groupName;
- }
-
-
- public void setGroupName(String groupName) {
- this.groupName = groupName;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
deleted file mode 100644
index 4b1a844..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: DeleteTopicRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class DeleteTopicRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String topic;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/EndTransactionRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
deleted file mode 100644
index 12f052d..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: EndTransactionRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.common.sysflag.MessageSysFlag;
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.annotation.CFNullable;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class EndTransactionRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String producerGroup;
- @CFNotNull
- private Long tranStateTableOffset;
- @CFNotNull
- private Long commitLogOffset;
- @CFNotNull
- private Integer commitOrRollback; // TRANSACTION_COMMIT_TYPE
- // TRANSACTION_ROLLBACK_TYPE
- // TRANSACTION_NOT_TYPE
-
- @CFNullable
- private Boolean fromTransactionCheck = false;
-
- @CFNotNull
- private String msgId;
-
- private String transactionId;
-
- @Override
- public void checkFields() throws RemotingCommandException {
- if (MessageSysFlag.TRANSACTION_NOT_TYPE == this.commitOrRollback) {
- return;
- }
-
- if (MessageSysFlag.TRANSACTION_COMMIT_TYPE == this.commitOrRollback) {
- return;
- }
-
- if (MessageSysFlag.TRANSACTION_ROLLBACK_TYPE == this.commitOrRollback) {
- return;
- }
-
- throw new RemotingCommandException("commitOrRollback field wrong");
- }
-
-
- public String getProducerGroup() {
- return producerGroup;
- }
-
-
- public void setProducerGroup(String producerGroup) {
- this.producerGroup = producerGroup;
- }
-
-
- public Long getTranStateTableOffset() {
- return tranStateTableOffset;
- }
-
-
- public void setTranStateTableOffset(Long tranStateTableOffset) {
- this.tranStateTableOffset = tranStateTableOffset;
- }
-
-
- public Long getCommitLogOffset() {
- return commitLogOffset;
- }
-
-
- public void setCommitLogOffset(Long commitLogOffset) {
- this.commitLogOffset = commitLogOffset;
- }
-
-
- public Integer getCommitOrRollback() {
- return commitOrRollback;
- }
-
-
- public void setCommitOrRollback(Integer commitOrRollback) {
- this.commitOrRollback = commitOrRollback;
- }
-
-
- public Boolean getFromTransactionCheck() {
- return fromTransactionCheck;
- }
-
-
- public void setFromTransactionCheck(Boolean fromTransactionCheck) {
- this.fromTransactionCheck = fromTransactionCheck;
- }
-
-
- public String getMsgId() {
- return msgId;
- }
-
-
- public void setMsgId(String msgId) {
- this.msgId = msgId;
- }
-
- public String getTransactionId() {
- return transactionId;
- }
-
- public void setTransactionId(String transactionId) {
- this.transactionId = transactionId;
- }
-
- @Override
- public String toString() {
- return "EndTransactionRequestHeader [producerGroup=" + producerGroup + ", tranStateTableOffset="
- + tranStateTableOffset + ", commitLogOffset=" + commitLogOffset + ", commitOrRollback="
- + commitOrRollback + ", fromTransactionCheck=" + fromTransactionCheck + ", msgId=" + msgId
- + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/EndTransactionResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
deleted file mode 100644
index 49b71f5..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: EndTransactionResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class EndTransactionResponseHeader implements CommandCustomHeader {
-
- @Override
- public void checkFields() throws RemotingCommandException {
-
- }
-
-}
[46/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/processor/EndTransactionProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/processor/EndTransactionProcessor.java b/broker/src/main/java/com/alibaba/rocketmq/broker/processor/EndTransactionProcessor.java
deleted file mode 100644
index ed10f1b..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/processor/EndTransactionProcessor.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/**
- * 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.processor;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import com.alibaba.rocketmq.common.TopicFilterType;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.message.MessageAccessor;
-import com.alibaba.rocketmq.common.message.MessageConst;
-import com.alibaba.rocketmq.common.message.MessageDecoder;
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.protocol.ResponseCode;
-import com.alibaba.rocketmq.common.protocol.header.EndTransactionRequestHeader;
-import com.alibaba.rocketmq.common.sysflag.MessageSysFlag;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-import com.alibaba.rocketmq.remoting.netty.NettyRequestProcessor;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import com.alibaba.rocketmq.store.MessageExtBrokerInner;
-import com.alibaba.rocketmq.store.MessageStore;
-import com.alibaba.rocketmq.store.PutMessageResult;
-import io.netty.channel.ChannelHandlerContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * @author shijia.wxr
- */
-public class EndTransactionProcessor implements NettyRequestProcessor {
- private static final Logger LOGGER = LoggerFactory.getLogger(LoggerName.TRANSACTION_LOGGER_NAME);
- private final BrokerController brokerController;
-
- public EndTransactionProcessor(final BrokerController brokerController) {
- this.brokerController = brokerController;
- }
-
- @Override
- public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- final EndTransactionRequestHeader requestHeader =
- (EndTransactionRequestHeader) request.decodeCommandCustomHeader(EndTransactionRequestHeader.class);
-
-
- if (requestHeader.getFromTransactionCheck()) {
- switch (requestHeader.getCommitOrRollback()) {
- case MessageSysFlag.TRANSACTION_NOT_TYPE: {
- LOGGER.warn("check producer[{}] transaction state, but it's pending status."
- + "RequestHeader: {} Remark: {}",
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
- requestHeader.toString(),
- request.getRemark());
- return null;
- }
-
- case MessageSysFlag.TRANSACTION_COMMIT_TYPE: {
- LOGGER.warn("check producer[{}] transaction state, the producer commit the message."
- + "RequestHeader: {} Remark: {}",
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
- requestHeader.toString(),
- request.getRemark());
-
- break;
- }
-
- case MessageSysFlag.TRANSACTION_ROLLBACK_TYPE: {
- LOGGER.warn("check producer[{}] transaction state, the producer rollback the message."
- + "RequestHeader: {} Remark: {}",
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
- requestHeader.toString(),
- request.getRemark());
- break;
- }
- default:
- return null;
- }
- } else {
- switch (requestHeader.getCommitOrRollback()) {
- case MessageSysFlag.TRANSACTION_NOT_TYPE: {
- LOGGER.warn("the producer[{}] end transaction in sending message, and it's pending status."
- + "RequestHeader: {} Remark: {}",
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
- requestHeader.toString(),
- request.getRemark());
- return null;
- }
-
- case MessageSysFlag.TRANSACTION_COMMIT_TYPE: {
- break;
- }
-
- case MessageSysFlag.TRANSACTION_ROLLBACK_TYPE: {
- LOGGER.warn("the producer[{}] end transaction in sending message, rollback the message."
- + "RequestHeader: {} Remark: {}",
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
- requestHeader.toString(),
- request.getRemark());
- break;
- }
- default:
- return null;
- }
- }
-
- final MessageExt msgExt = this.brokerController.getMessageStore().lookMessageByOffset(requestHeader.getCommitLogOffset());
- if (msgExt != null) {
- final String pgroupRead = msgExt.getProperty(MessageConst.PROPERTY_PRODUCER_GROUP);
- if (!pgroupRead.equals(requestHeader.getProducerGroup())) {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("the producer group wrong");
- return response;
- }
-
- if (msgExt.getQueueOffset() != requestHeader.getTranStateTableOffset()) {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("the transaction state table offset wrong");
- return response;
- }
-
- if (msgExt.getCommitLogOffset() != requestHeader.getCommitLogOffset()) {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("the commit log offset wrong");
- return response;
- }
-
- MessageExtBrokerInner msgInner = this.endMessageTransaction(msgExt);
- msgInner.setSysFlag(MessageSysFlag.resetTransactionValue(msgInner.getSysFlag(), requestHeader.getCommitOrRollback()));
-
- msgInner.setQueueOffset(requestHeader.getTranStateTableOffset());
- msgInner.setPreparedTransactionOffset(requestHeader.getCommitLogOffset());
- msgInner.setStoreTimestamp(msgExt.getStoreTimestamp());
- if (MessageSysFlag.TRANSACTION_ROLLBACK_TYPE == requestHeader.getCommitOrRollback()) {
- msgInner.setBody(null);
- }
-
- final MessageStore messageStore = this.brokerController.getMessageStore();
- final PutMessageResult putMessageResult = messageStore.putMessage(msgInner);
- if (putMessageResult != null) {
- switch (putMessageResult.getPutMessageStatus()) {
- // Success
- case PUT_OK:
- case FLUSH_DISK_TIMEOUT:
- case FLUSH_SLAVE_TIMEOUT:
- case SLAVE_NOT_AVAILABLE:
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- break;
- // Failed
- case CREATE_MAPEDFILE_FAILED:
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("create maped file failed.");
- break;
- case MESSAGE_ILLEGAL:
- case PROPERTIES_SIZE_EXCEEDED:
- response.setCode(ResponseCode.MESSAGE_ILLEGAL);
- response.setRemark("the message is illegal, maybe msg body or properties length not matched. msg body length limit 128k, msg properties length limit 32k.");
- break;
- case SERVICE_NOT_AVAILABLE:
- response.setCode(ResponseCode.SERVICE_NOT_AVAILABLE);
- response.setRemark("service not available now.");
- break;
- case OS_PAGECACHE_BUSY:
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("OS page cache busy, please try another machine");
- break;
- case UNKNOWN_ERROR:
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("UNKNOWN_ERROR");
- break;
- default:
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("UNKNOWN_ERROR DEFAULT");
- break;
- }
-
- return response;
- } else {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("store putMessage return null");
- }
- } else {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("find prepared transaction message failed");
- return response;
- }
-
- return response;
- }
-
- @Override
- public boolean rejectRequest() {
- return false;
- }
-
- private MessageExtBrokerInner endMessageTransaction(MessageExt msgExt) {
- MessageExtBrokerInner msgInner = new MessageExtBrokerInner();
- msgInner.setBody(msgExt.getBody());
- msgInner.setFlag(msgExt.getFlag());
- MessageAccessor.setProperties(msgInner, msgExt.getProperties());
-
- TopicFilterType topicFilterType =
- (msgInner.getSysFlag() & MessageSysFlag.MULTI_TAGS_FLAG) == MessageSysFlag.MULTI_TAGS_FLAG ? TopicFilterType.MULTI_TAG
- : TopicFilterType.SINGLE_TAG;
- long tagsCodeValue = MessageExtBrokerInner.tagsString2tagsCode(topicFilterType, msgInner.getTags());
- msgInner.setTagsCode(tagsCodeValue);
- msgInner.setPropertiesString(MessageDecoder.messageProperties2String(msgExt.getProperties()));
-
- msgInner.setSysFlag(msgExt.getSysFlag());
- msgInner.setBornTimestamp(msgExt.getBornTimestamp());
- msgInner.setBornHost(msgExt.getBornHost());
- msgInner.setStoreHost(msgExt.getStoreHost());
- msgInner.setReconsumeTimes(msgExt.getReconsumeTimes());
-
- msgInner.setWaitStoreMsgOK(false);
- MessageAccessor.clearProperty(msgInner, MessageConst.PROPERTY_DELAY_TIME_LEVEL);
-
- msgInner.setTopic(msgExt.getTopic());
- msgInner.setQueueId(msgExt.getQueueId());
-
- return msgInner;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/processor/ForwardRequestProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/processor/ForwardRequestProcessor.java b/broker/src/main/java/com/alibaba/rocketmq/broker/processor/ForwardRequestProcessor.java
deleted file mode 100644
index a92ead0..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/processor/ForwardRequestProcessor.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * 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.processor;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.remoting.netty.NettyRequestProcessor;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import io.netty.channel.ChannelHandlerContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * @author shijia.wxr
- */
-public class ForwardRequestProcessor implements NettyRequestProcessor {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
-
- private final BrokerController brokerController;
-
-
- public ForwardRequestProcessor(final BrokerController brokerController) {
- this.brokerController = brokerController;
- }
-
-
- @Override
- public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) {
- return null;
- }
-
- @Override
- public boolean rejectRequest() {
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/processor/PullMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/processor/PullMessageProcessor.java b/broker/src/main/java/com/alibaba/rocketmq/broker/processor/PullMessageProcessor.java
deleted file mode 100644
index 1257f18..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/processor/PullMessageProcessor.java
+++ /dev/null
@@ -1,542 +0,0 @@
-/**
- * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.processor;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import com.alibaba.rocketmq.broker.client.ConsumerGroupInfo;
-import com.alibaba.rocketmq.broker.longpolling.PullRequest;
-import com.alibaba.rocketmq.broker.mqtrace.ConsumeMessageContext;
-import com.alibaba.rocketmq.broker.mqtrace.ConsumeMessageHook;
-import com.alibaba.rocketmq.broker.pagecache.ManyMessageTransfer;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.TopicConfig;
-import com.alibaba.rocketmq.common.TopicFilterType;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.constant.PermName;
-import com.alibaba.rocketmq.common.filter.FilterAPI;
-import com.alibaba.rocketmq.common.help.FAQUrl;
-import com.alibaba.rocketmq.common.message.MessageDecoder;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.ResponseCode;
-import com.alibaba.rocketmq.common.protocol.header.PullMessageRequestHeader;
-import com.alibaba.rocketmq.common.protocol.header.PullMessageResponseHeader;
-import com.alibaba.rocketmq.common.protocol.heartbeat.MessageModel;
-import com.alibaba.rocketmq.common.protocol.heartbeat.SubscriptionData;
-import com.alibaba.rocketmq.common.protocol.topic.OffsetMovedEvent;
-import com.alibaba.rocketmq.common.subscription.SubscriptionGroupConfig;
-import com.alibaba.rocketmq.common.sysflag.PullSysFlag;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import com.alibaba.rocketmq.remoting.common.RemotingUtil;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-import com.alibaba.rocketmq.remoting.netty.NettyRequestProcessor;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import com.alibaba.rocketmq.store.GetMessageResult;
-import com.alibaba.rocketmq.store.MessageExtBrokerInner;
-import com.alibaba.rocketmq.store.PutMessageResult;
-import com.alibaba.rocketmq.store.config.BrokerRole;
-import com.alibaba.rocketmq.store.stats.BrokerStatsManager;
-import io.netty.channel.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.nio.ByteBuffer;
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public class PullMessageProcessor implements NettyRequestProcessor {
- private static final Logger LOG = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
- private final BrokerController brokerController;
- private List<ConsumeMessageHook> consumeMessageHookList;
-
- public PullMessageProcessor(final BrokerController brokerController) {
- this.brokerController = brokerController;
- }
-
- @Override
- public RemotingCommand processRequest(final ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- return this.processRequest(ctx.channel(), request, true);
- }
-
- @Override
- public boolean rejectRequest() {
- return false;
- }
-
- private RemotingCommand processRequest(final Channel channel, RemotingCommand request, boolean brokerAllowSuspend)
- throws RemotingCommandException {
- RemotingCommand response = RemotingCommand.createResponseCommand(PullMessageResponseHeader.class);
- final PullMessageResponseHeader responseHeader = (PullMessageResponseHeader) response.readCustomHeader();
- final PullMessageRequestHeader requestHeader =
- (PullMessageRequestHeader) request.decodeCommandCustomHeader(PullMessageRequestHeader.class);
-
-
- response.setOpaque(request.getOpaque());
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("receive PullMessage request command, " + request);
- }
-
-
- if (!PermName.isReadable(this.brokerController.getBrokerConfig().getBrokerPermission())) {
- response.setCode(ResponseCode.NO_PERMISSION);
- response.setRemark("the broker[" + this.brokerController.getBrokerConfig().getBrokerIP1() + "] pulling message is forbidden");
- return response;
- }
-
-
- SubscriptionGroupConfig subscriptionGroupConfig =
- this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(requestHeader.getConsumerGroup());
- if (null == subscriptionGroupConfig) {
- response.setCode(ResponseCode.SUBSCRIPTION_GROUP_NOT_EXIST);
- response.setRemark("subscription group not exist, " + requestHeader.getConsumerGroup() + " "
- + FAQUrl.suggestTodo(FAQUrl.SUBSCRIPTION_GROUP_NOT_EXIST));
- return response;
- }
-
-
- if (!subscriptionGroupConfig.isConsumeEnable()) {
- response.setCode(ResponseCode.NO_PERMISSION);
- response.setRemark("subscription group no permission, " + requestHeader.getConsumerGroup());
- return response;
- }
-
- final boolean hasSuspendFlag = PullSysFlag.hasSuspendFlag(requestHeader.getSysFlag());
- final boolean hasCommitOffsetFlag = PullSysFlag.hasCommitOffsetFlag(requestHeader.getSysFlag());
- final boolean hasSubscriptionFlag = PullSysFlag.hasSubscriptionFlag(requestHeader.getSysFlag());
-
- final long suspendTimeoutMillisLong = hasSuspendFlag ? requestHeader.getSuspendTimeoutMillis() : 0;
-
-
- TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(requestHeader.getTopic());
- if (null == topicConfig) {
- LOG.error("the topic " + requestHeader.getTopic() + " not exist, consumer: " + RemotingHelper.parseChannelRemoteAddr(channel));
- response.setCode(ResponseCode.TOPIC_NOT_EXIST);
- response.setRemark(
- "topic[" + requestHeader.getTopic() + "] not exist, apply first please!" + FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
- return response;
- }
-
-
- if (!PermName.isReadable(topicConfig.getPerm())) {
- response.setCode(ResponseCode.NO_PERMISSION);
- response.setRemark("the topic[" + requestHeader.getTopic() + "] pulling message is forbidden");
- return response;
- }
-
-
- if (requestHeader.getQueueId() < 0 || requestHeader.getQueueId() >= topicConfig.getReadQueueNums()) {
- String errorInfo = "queueId[" + requestHeader.getQueueId() + "] is illagal,Topic :" + requestHeader.getTopic()
- + " topicConfig.readQueueNums: " + topicConfig.getReadQueueNums() + " consumer: " + channel.remoteAddress();
- LOG.warn(errorInfo);
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark(errorInfo);
- return response;
- }
-
-
- SubscriptionData subscriptionData = null;
- if (hasSubscriptionFlag) {
- try {
- subscriptionData = FilterAPI.buildSubscriptionData(requestHeader.getConsumerGroup(), requestHeader.getTopic(),
- requestHeader.getSubscription());
- } catch (Exception e) {
- LOG.warn("parse the consumer's subscription[{}] failed, group: {}", requestHeader.getSubscription(), //
- requestHeader.getConsumerGroup());
- response.setCode(ResponseCode.SUBSCRIPTION_PARSE_FAILED);
- response.setRemark("parse the consumer's subscription failed");
- return response;
- }
- } else {
- ConsumerGroupInfo consumerGroupInfo =
- this.brokerController.getConsumerManager().getConsumerGroupInfo(requestHeader.getConsumerGroup());
- if (null == consumerGroupInfo) {
- LOG.warn("the consumer's group info not exist, group: {}", requestHeader.getConsumerGroup());
- response.setCode(ResponseCode.SUBSCRIPTION_NOT_EXIST);
- response.setRemark("the consumer's group info not exist" + FAQUrl.suggestTodo(FAQUrl.SAME_GROUP_DIFFERENT_TOPIC));
- return response;
- }
-
- if (!subscriptionGroupConfig.isConsumeBroadcastEnable() //
- && consumerGroupInfo.getMessageModel() == MessageModel.BROADCASTING) {
- response.setCode(ResponseCode.NO_PERMISSION);
- response.setRemark("the consumer group[" + requestHeader.getConsumerGroup() + "] can not consume by broadcast way");
- return response;
- }
-
- subscriptionData = consumerGroupInfo.findSubscriptionData(requestHeader.getTopic());
- if (null == subscriptionData) {
- LOG.warn("the consumer's subscription not exist, group: {}, topic:{}", requestHeader.getConsumerGroup(), requestHeader.getTopic());
- response.setCode(ResponseCode.SUBSCRIPTION_NOT_EXIST);
- response.setRemark("the consumer's subscription not exist" + FAQUrl.suggestTodo(FAQUrl.SAME_GROUP_DIFFERENT_TOPIC));
- return response;
- }
-
-
- if (subscriptionData.getSubVersion() < requestHeader.getSubVersion()) {
- LOG.warn("the broker's subscription is not latest, group: {} {}", requestHeader.getConsumerGroup(),
- subscriptionData.getSubString());
- response.setCode(ResponseCode.SUBSCRIPTION_NOT_LATEST);
- response.setRemark("the consumer's subscription not latest");
- return response;
- }
- }
-
- final GetMessageResult getMessageResult =
- this.brokerController.getMessageStore().getMessage(requestHeader.getConsumerGroup(), requestHeader.getTopic(),
- requestHeader.getQueueId(), requestHeader.getQueueOffset(), requestHeader.getMaxMsgNums(), subscriptionData);
- if (getMessageResult != null) {
- response.setRemark(getMessageResult.getStatus().name());
- responseHeader.setNextBeginOffset(getMessageResult.getNextBeginOffset());
- responseHeader.setMinOffset(getMessageResult.getMinOffset());
- responseHeader.setMaxOffset(getMessageResult.getMaxOffset());
-
-
- if (getMessageResult.isSuggestPullingFromSlave()) {
- responseHeader.setSuggestWhichBrokerId(subscriptionGroupConfig.getWhichBrokerWhenConsumeSlowly());
- } else {
- responseHeader.setSuggestWhichBrokerId(MixAll.MASTER_ID);
- }
-
- switch (this.brokerController.getMessageStoreConfig().getBrokerRole()) {
- case ASYNC_MASTER:
- case SYNC_MASTER:
- break;
- case SLAVE:
- if (!this.brokerController.getBrokerConfig().isSlaveReadEnable()) {
- response.setCode(ResponseCode.PULL_RETRY_IMMEDIATELY);
- responseHeader.setSuggestWhichBrokerId(MixAll.MASTER_ID);
- }
- break;
- }
-
- if (this.brokerController.getBrokerConfig().isSlaveReadEnable()) {
- // consume too slow ,redirect to another machine
- if (getMessageResult.isSuggestPullingFromSlave()) {
- responseHeader.setSuggestWhichBrokerId(subscriptionGroupConfig.getWhichBrokerWhenConsumeSlowly());
- }
- // consume ok
- else {
- responseHeader.setSuggestWhichBrokerId(subscriptionGroupConfig.getBrokerId());
- }
- } else {
- responseHeader.setSuggestWhichBrokerId(MixAll.MASTER_ID);
- }
-
- switch (getMessageResult.getStatus()) {
- case FOUND:
- response.setCode(ResponseCode.SUCCESS);
- break;
- case MESSAGE_WAS_REMOVING:
- response.setCode(ResponseCode.PULL_RETRY_IMMEDIATELY);
- break;
- case NO_MATCHED_LOGIC_QUEUE:
- case NO_MESSAGE_IN_QUEUE:
- if (0 != requestHeader.getQueueOffset()) {
- response.setCode(ResponseCode.PULL_OFFSET_MOVED);
-
- // XXX: warn and notify me
- LOG.info("the broker store no queue data, fix the request offset {} to {}, Topic: {} QueueId: {} Consumer Group: {}", //
- requestHeader.getQueueOffset(), //
- getMessageResult.getNextBeginOffset(), //
- requestHeader.getTopic(), //
- requestHeader.getQueueId(), //
- requestHeader.getConsumerGroup()//
- );
- } else {
- response.setCode(ResponseCode.PULL_NOT_FOUND);
- }
- break;
- case NO_MATCHED_MESSAGE:
- response.setCode(ResponseCode.PULL_RETRY_IMMEDIATELY);
- break;
- case OFFSET_FOUND_NULL:
- response.setCode(ResponseCode.PULL_NOT_FOUND);
- break;
- case OFFSET_OVERFLOW_BADLY:
- response.setCode(ResponseCode.PULL_OFFSET_MOVED);
- // XXX: warn and notify me
- LOG.info("the request offset: " + requestHeader.getQueueOffset() + " over flow badly, broker max offset: "
- + getMessageResult.getMaxOffset() + ", consumer: " + channel.remoteAddress());
- break;
- case OFFSET_OVERFLOW_ONE:
- response.setCode(ResponseCode.PULL_NOT_FOUND);
- break;
- case OFFSET_TOO_SMALL:
- response.setCode(ResponseCode.PULL_OFFSET_MOVED);
- LOG.info("the request offset too small. group={}, topic={}, requestOffset={}, brokerMinOffset={}, clientIp={}",
- requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueOffset(),
- getMessageResult.getMinOffset(), channel.remoteAddress());
- break;
- default:
- assert false;
- break;
- }
-
- if (this.hasConsumeMessageHook()) {
- ConsumeMessageContext context = new ConsumeMessageContext();
- context.setConsumerGroup(requestHeader.getConsumerGroup());
- context.setTopic(requestHeader.getTopic());
- context.setQueueId(requestHeader.getQueueId());
-
- String owner = request.getExtFields().get(BrokerStatsManager.COMMERCIAL_OWNER);
-
- switch (response.getCode()) {
- case ResponseCode.SUCCESS:
- int commercialBaseCount = brokerController.getBrokerConfig().getCommercialBaseCount();
- int incValue = getMessageResult.getMsgCount4Commercial() * commercialBaseCount;
-
- context.setCommercialRcvStats(BrokerStatsManager.StatsType.RCV_SUCCESS);
- context.setCommercialRcvTimes(incValue);
- context.setCommercialRcvSize(getMessageResult.getBufferTotalSize());
- context.setCommercialOwner(owner);
-
- break;
- case ResponseCode.PULL_NOT_FOUND:
- if (!brokerAllowSuspend) {
-
-
- context.setCommercialRcvStats(BrokerStatsManager.StatsType.RCV_EPOLLS);
- context.setCommercialRcvTimes(1);
- context.setCommercialOwner(owner);
-
- }
- break;
- case ResponseCode.PULL_RETRY_IMMEDIATELY:
- case ResponseCode.PULL_OFFSET_MOVED:
- context.setCommercialRcvStats(BrokerStatsManager.StatsType.RCV_EPOLLS);
- context.setCommercialRcvTimes(1);
- context.setCommercialOwner(owner);
- break;
- default:
- assert false;
- break;
- }
-
- this.executeConsumeMessageHookBefore(context);
- }
-
- switch (response.getCode()) {
- case ResponseCode.SUCCESS:
-
- this.brokerController.getBrokerStatsManager().incGroupGetNums(requestHeader.getConsumerGroup(), requestHeader.getTopic(),
- getMessageResult.getMessageCount());
-
- this.brokerController.getBrokerStatsManager().incGroupGetSize(requestHeader.getConsumerGroup(), requestHeader.getTopic(),
- getMessageResult.getBufferTotalSize());
-
- this.brokerController.getBrokerStatsManager().incBrokerGetNums(getMessageResult.getMessageCount());
- if (this.brokerController.getBrokerConfig().isTransferMsgByHeap()) {
- final long beginTimeMills = this.brokerController.getMessageStore().now();
- final byte[] r = this.readGetMessageResult(getMessageResult, requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueId());
- this.brokerController.getBrokerStatsManager().incGroupGetLatency(requestHeader.getConsumerGroup(),
- requestHeader.getTopic(), requestHeader.getQueueId(),
- (int) (this.brokerController.getMessageStore().now() - beginTimeMills));
- response.setBody(r);
- } else {
- try {
- FileRegion fileRegion =
- new ManyMessageTransfer(response.encodeHeader(getMessageResult.getBufferTotalSize()), getMessageResult);
- channel.writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
- @Override
- public void operationComplete(ChannelFuture future) throws Exception {
- getMessageResult.release();
- if (!future.isSuccess()) {
- LOG.error("transfer many message by pagecache failed, " + channel.remoteAddress(), future.cause());
- }
- }
- });
- } catch (Throwable e) {
- LOG.error("transfer many message by pagecache exception", e);
- getMessageResult.release();
- }
-
- response = null;
- }
- break;
- case ResponseCode.PULL_NOT_FOUND:
-
- if (brokerAllowSuspend && hasSuspendFlag) {
- long pollingTimeMills = suspendTimeoutMillisLong;
- if (!this.brokerController.getBrokerConfig().isLongPollingEnable()) {
- pollingTimeMills = this.brokerController.getBrokerConfig().getShortPollingTimeMills();
- }
-
- String topic = requestHeader.getTopic();
- long offset = requestHeader.getQueueOffset();
- int queueId = requestHeader.getQueueId();
- PullRequest pullRequest = new PullRequest(request, channel, pollingTimeMills,
- this.brokerController.getMessageStore().now(), offset, subscriptionData);
- this.brokerController.getPullRequestHoldService().suspendPullRequest(topic, queueId, pullRequest);
- response = null;
- break;
- }
-
-
- case ResponseCode.PULL_RETRY_IMMEDIATELY:
- break;
- case ResponseCode.PULL_OFFSET_MOVED:
- if (this.brokerController.getMessageStoreConfig().getBrokerRole() != BrokerRole.SLAVE
- || this.brokerController.getMessageStoreConfig().isOffsetCheckInSlave()) {
- MessageQueue mq = new MessageQueue();
- mq.setTopic(requestHeader.getTopic());
- mq.setQueueId(requestHeader.getQueueId());
- mq.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());
-
- OffsetMovedEvent event = new OffsetMovedEvent();
- event.setConsumerGroup(requestHeader.getConsumerGroup());
- event.setMessageQueue(mq);
- event.setOffsetRequest(requestHeader.getQueueOffset());
- event.setOffsetNew(getMessageResult.getNextBeginOffset());
- this.generateOffsetMovedEvent(event);
- LOG.warn(
- "PULL_OFFSET_MOVED:correction offset. topic={}, groupId={}, requestOffset={}, newOffset={}, suggestBrokerId={}",
- requestHeader.getTopic(), requestHeader.getConsumerGroup(), event.getOffsetRequest(), event.getOffsetNew(),
- responseHeader.getSuggestWhichBrokerId());
- } else {
- responseHeader.setSuggestWhichBrokerId(subscriptionGroupConfig.getBrokerId());
- response.setCode(ResponseCode.PULL_RETRY_IMMEDIATELY);
- LOG.warn("PULL_OFFSET_MOVED:none correction. topic={}, groupId={}, requestOffset={}, suggestBrokerId={}",
- requestHeader.getTopic(), requestHeader.getConsumerGroup(), requestHeader.getQueueOffset(),
- responseHeader.getSuggestWhichBrokerId());
- }
-
- break;
- default:
- assert false;
- }
- } else {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("store getMessage return null");
- }
-
-
- boolean storeOffsetEnable = brokerAllowSuspend;
- storeOffsetEnable = storeOffsetEnable && hasCommitOffsetFlag;
- storeOffsetEnable = storeOffsetEnable
- && this.brokerController.getMessageStoreConfig().getBrokerRole() != BrokerRole.SLAVE;
- if (storeOffsetEnable) {
- this.brokerController.getConsumerOffsetManager().commitOffset(RemotingHelper.parseChannelRemoteAddr(channel),
- requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueId(), requestHeader.getCommitOffset());
- }
- return response;
- }
-
-
- public boolean hasConsumeMessageHook() {
- return consumeMessageHookList != null && !this.consumeMessageHookList.isEmpty();
- }
-
- public void executeConsumeMessageHookBefore(final ConsumeMessageContext context) {
- if (hasConsumeMessageHook()) {
- for (ConsumeMessageHook hook : this.consumeMessageHookList) {
- try {
- hook.consumeMessageBefore(context);
- } catch (Throwable e) {
- }
- }
- }
- }
-
- private byte[] readGetMessageResult(final GetMessageResult getMessageResult, final String group, final String topic, final int queueId) {
- final ByteBuffer byteBuffer = ByteBuffer.allocate(getMessageResult.getBufferTotalSize());
-
- long storeTimestamp = 0;
- try {
- List<ByteBuffer> messageBufferList = getMessageResult.getMessageBufferList();
- for (ByteBuffer bb : messageBufferList) {
-
- byteBuffer.put(bb);
- storeTimestamp = bb.getLong(MessageDecoder.MESSAGE_STORE_TIMESTAMP_POSTION);
- }
- } finally {
- getMessageResult.release();
- }
-
- this.brokerController.getBrokerStatsManager().recordDiskFallBehindTime(group, topic, queueId, this.brokerController.getMessageStore().now() - storeTimestamp);
- return byteBuffer.array();
- }
-
- private void generateOffsetMovedEvent(final OffsetMovedEvent event) {
- try {
- MessageExtBrokerInner msgInner = new MessageExtBrokerInner();
- msgInner.setTopic(MixAll.OFFSET_MOVED_EVENT);
- msgInner.setTags(event.getConsumerGroup());
- msgInner.setDelayTimeLevel(0);
- msgInner.setKeys(event.getConsumerGroup());
- msgInner.setBody(event.encode());
- msgInner.setFlag(0);
- msgInner.setPropertiesString(MessageDecoder.messageProperties2String(msgInner.getProperties()));
- msgInner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(TopicFilterType.SINGLE_TAG, msgInner.getTags()));
-
- msgInner.setQueueId(0);
- msgInner.setSysFlag(0);
- msgInner.setBornTimestamp(System.currentTimeMillis());
- msgInner.setBornHost(RemotingUtil.string2SocketAddress(this.brokerController.getBrokerAddr()));
- msgInner.setStoreHost(msgInner.getBornHost());
-
- msgInner.setReconsumeTimes(0);
-
- PutMessageResult putMessageResult = this.brokerController.getMessageStore().putMessage(msgInner);
- } catch (Exception e) {
- LOG.warn(String.format("generateOffsetMovedEvent Exception, %s", event.toString()), e);
- }
- }
-
- public void excuteRequestWhenWakeup(final Channel channel, final RemotingCommand request) throws RemotingCommandException {
- Runnable run = new Runnable() {
- @Override
- public void run() {
- try {
- final RemotingCommand response = PullMessageProcessor.this.processRequest(channel, request, false);
-
- if (response != null) {
- response.setOpaque(request.getOpaque());
- response.markResponseType();
- try {
- channel.writeAndFlush(response).addListener(new ChannelFutureListener() {
- @Override
- public void operationComplete(ChannelFuture future) throws Exception {
- if (!future.isSuccess()) {
- LOG.error("processRequestWrapper response to " + future.channel().remoteAddress() + " failed",
- future.cause());
- LOG.error(request.toString());
- LOG.error(response.toString());
- }
- }
- });
- } catch (Throwable e) {
- LOG.error("processRequestWrapper process request over, but response failed", e);
- LOG.error(request.toString());
- LOG.error(response.toString());
- }
- }
- } catch (RemotingCommandException e1) {
- LOG.error("excuteRequestWhenWakeup run", e1);
- }
- }
- };
-
- this.brokerController.getPullMessageExecutor().submit(run);
- }
-
- public void registerConsumeMessageHook(List<ConsumeMessageHook> sendMessageHookList) {
- this.consumeMessageHookList = sendMessageHookList;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/processor/QueryMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/processor/QueryMessageProcessor.java b/broker/src/main/java/com/alibaba/rocketmq/broker/processor/QueryMessageProcessor.java
deleted file mode 100644
index 738d11f..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/processor/QueryMessageProcessor.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/**
- * 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.processor;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import com.alibaba.rocketmq.broker.pagecache.OneMessageTransfer;
-import com.alibaba.rocketmq.broker.pagecache.QueryMessageTransfer;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.protocol.RequestCode;
-import com.alibaba.rocketmq.common.protocol.ResponseCode;
-import com.alibaba.rocketmq.common.protocol.header.QueryMessageRequestHeader;
-import com.alibaba.rocketmq.common.protocol.header.QueryMessageResponseHeader;
-import com.alibaba.rocketmq.common.protocol.header.ViewMessageRequestHeader;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-import com.alibaba.rocketmq.remoting.netty.NettyRequestProcessor;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import com.alibaba.rocketmq.store.QueryMessageResult;
-import com.alibaba.rocketmq.store.SelectMappedBufferResult;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelFutureListener;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.FileRegion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * @author shijia.wxr
- */
-public class QueryMessageProcessor implements NettyRequestProcessor {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
-
- private final BrokerController brokerController;
-
-
- public QueryMessageProcessor(final BrokerController brokerController) {
- this.brokerController = brokerController;
- }
-
-
- @Override
- public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
- switch (request.getCode()) {
- case RequestCode.QUERY_MESSAGE:
- return this.queryMessage(ctx, request);
- case RequestCode.VIEW_MESSAGE_BY_ID:
- return this.viewMessageById(ctx, request);
- default:
- break;
- }
-
- return null;
- }
-
- @Override
- public boolean rejectRequest() {
- return false;
- }
-
-
- public RemotingCommand queryMessage(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
- final RemotingCommand response =
- RemotingCommand.createResponseCommand(QueryMessageResponseHeader.class);
- final QueryMessageResponseHeader responseHeader =
- (QueryMessageResponseHeader) response.readCustomHeader();
- final QueryMessageRequestHeader requestHeader =
- (QueryMessageRequestHeader) request
- .decodeCommandCustomHeader(QueryMessageRequestHeader.class);
-
-
- response.setOpaque(request.getOpaque());
-
-
- String isUniqueKey = request.getExtFields().get(MixAll.UNIQUE_MSG_QUERY_FLAG);
- if (isUniqueKey != null && isUniqueKey.equals("true")) {
- requestHeader.setMaxNum(this.brokerController.getMessageStoreConfig().getDefaultQueryMaxNum());
- }
-
- final QueryMessageResult queryMessageResult =
- this.brokerController.getMessageStore().queryMessage(requestHeader.getTopic(),
- requestHeader.getKey(), requestHeader.getMaxNum(), requestHeader.getBeginTimestamp(),
- requestHeader.getEndTimestamp());
- assert queryMessageResult != null;
-
- responseHeader.setIndexLastUpdatePhyoffset(queryMessageResult.getIndexLastUpdatePhyoffset());
- responseHeader.setIndexLastUpdateTimestamp(queryMessageResult.getIndexLastUpdateTimestamp());
-
-
- if (queryMessageResult.getBufferTotalSize() > 0) {
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
-
- try {
- FileRegion fileRegion =
- new QueryMessageTransfer(response.encodeHeader(queryMessageResult
- .getBufferTotalSize()), queryMessageResult);
- ctx.channel().writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
- @Override
- public void operationComplete(ChannelFuture future) throws Exception {
- queryMessageResult.release();
- if (!future.isSuccess()) {
- log.error("transfer query message by pagecache failed, ", future.cause());
- }
- }
- });
- } catch (Throwable e) {
- log.error("", e);
- queryMessageResult.release();
- }
-
- return null;
- }
-
- response.setCode(ResponseCode.QUERY_NOT_FOUND);
- response.setRemark("can not find message, maybe time range not correct");
- return response;
- }
-
-
- public RemotingCommand viewMessageById(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- final ViewMessageRequestHeader requestHeader =
- (ViewMessageRequestHeader) request.decodeCommandCustomHeader(ViewMessageRequestHeader.class);
-
-
- response.setOpaque(request.getOpaque());
-
- final SelectMappedBufferResult selectMappedBufferResult =
- this.brokerController.getMessageStore().selectOneMessageByOffset(requestHeader.getOffset());
- if (selectMappedBufferResult != null) {
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
-
- try {
- FileRegion fileRegion =
- new OneMessageTransfer(response.encodeHeader(selectMappedBufferResult.getSize()),
- selectMappedBufferResult);
- ctx.channel().writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
- @Override
- public void operationComplete(ChannelFuture future) throws Exception {
- selectMappedBufferResult.release();
- if (!future.isSuccess()) {
- log.error("transfer one message by pagecache failed, ", future.cause());
- }
- }
- });
- } catch (Throwable e) {
- log.error("", e);
- selectMappedBufferResult.release();
- }
-
- return null;
- } else {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("can not find message by the offset, " + requestHeader.getOffset());
- }
-
- return response;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/processor/SendMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/processor/SendMessageProcessor.java b/broker/src/main/java/com/alibaba/rocketmq/broker/processor/SendMessageProcessor.java
deleted file mode 100644
index a375285..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/processor/SendMessageProcessor.java
+++ /dev/null
@@ -1,497 +0,0 @@
-/**
- * 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.processor;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import com.alibaba.rocketmq.broker.mqtrace.ConsumeMessageContext;
-import com.alibaba.rocketmq.broker.mqtrace.ConsumeMessageHook;
-import com.alibaba.rocketmq.broker.mqtrace.SendMessageContext;
-import com.alibaba.rocketmq.common.*;
-import com.alibaba.rocketmq.common.constant.PermName;
-import com.alibaba.rocketmq.common.help.FAQUrl;
-import com.alibaba.rocketmq.common.message.MessageAccessor;
-import com.alibaba.rocketmq.common.message.MessageConst;
-import com.alibaba.rocketmq.common.message.MessageDecoder;
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.protocol.RequestCode;
-import com.alibaba.rocketmq.common.protocol.ResponseCode;
-import com.alibaba.rocketmq.common.protocol.header.ConsumerSendMsgBackRequestHeader;
-import com.alibaba.rocketmq.common.protocol.header.SendMessageRequestHeader;
-import com.alibaba.rocketmq.common.protocol.header.SendMessageResponseHeader;
-import com.alibaba.rocketmq.common.subscription.SubscriptionGroupConfig;
-import com.alibaba.rocketmq.common.sysflag.MessageSysFlag;
-import com.alibaba.rocketmq.common.sysflag.TopicSysFlag;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-import com.alibaba.rocketmq.remoting.netty.NettyRequestProcessor;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import com.alibaba.rocketmq.store.MessageExtBrokerInner;
-import com.alibaba.rocketmq.store.PutMessageResult;
-import com.alibaba.rocketmq.store.config.StorePathConfigHelper;
-import com.alibaba.rocketmq.store.stats.BrokerStatsManager;
-import io.netty.channel.ChannelHandlerContext;
-
-import java.net.SocketAddress;
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public class SendMessageProcessor extends AbstractSendMessageProcessor implements NettyRequestProcessor {
-
- private List<ConsumeMessageHook> consumeMessageHookList;
-
- public SendMessageProcessor(final BrokerController brokerController) {
- super(brokerController);
- }
-
- @Override
- public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- SendMessageContext mqtraceContext;
- switch (request.getCode()) {
- case RequestCode.CONSUMER_SEND_MSG_BACK:
- return this.consumerSendMsgBack(ctx, request);
- default:
- SendMessageRequestHeader requestHeader = parseRequestHeader(request);
- if (requestHeader == null) {
- return null;
- }
-
- mqtraceContext = buildMsgContext(ctx, requestHeader);
- this.executeSendMessageHookBefore(ctx, request, mqtraceContext);
- final RemotingCommand response = this.sendMessage(ctx, request, mqtraceContext, requestHeader);
-
- this.executeSendMessageHookAfter(response, mqtraceContext);
- return response;
- }
- }
-
- @Override
- public boolean rejectRequest() {
- return this.brokerController.getMessageStore().isOSPageCacheBusy() ||
- this.brokerController.getMessageStore().isTransientStorePoolDeficient();
- }
-
- private RemotingCommand consumerSendMsgBack(final ChannelHandlerContext ctx, final RemotingCommand request)
- throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- final ConsumerSendMsgBackRequestHeader requestHeader =
- (ConsumerSendMsgBackRequestHeader) request.decodeCommandCustomHeader(ConsumerSendMsgBackRequestHeader.class);
-
- if (this.hasConsumeMessageHook() && !UtilAll.isBlank(requestHeader.getOriginMsgId())) {
-
- ConsumeMessageContext context = new ConsumeMessageContext();
- context.setConsumerGroup(requestHeader.getGroup());
- context.setTopic(requestHeader.getOriginTopic());
- context.setCommercialRcvStats(BrokerStatsManager.StatsType.SEND_BACK);
- context.setCommercialRcvTimes(1);
- context.setCommercialOwner(request.getExtFields().get(BrokerStatsManager.COMMERCIAL_OWNER));
-
- this.executeConsumeMessageHookAfter(context);
- }
-
-
- SubscriptionGroupConfig subscriptionGroupConfig =
- this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(requestHeader.getGroup());
- if (null == subscriptionGroupConfig) {
- response.setCode(ResponseCode.SUBSCRIPTION_GROUP_NOT_EXIST);
- response.setRemark("subscription group not exist, " + requestHeader.getGroup() + " "
- + FAQUrl.suggestTodo(FAQUrl.SUBSCRIPTION_GROUP_NOT_EXIST));
- return response;
- }
-
-
- if (!PermName.isWriteable(this.brokerController.getBrokerConfig().getBrokerPermission())) {
- response.setCode(ResponseCode.NO_PERMISSION);
- response.setRemark("the broker[" + this.brokerController.getBrokerConfig().getBrokerIP1() + "] sending message is forbidden");
- return response;
- }
-
-
- if (subscriptionGroupConfig.getRetryQueueNums() <= 0) {
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- String newTopic = MixAll.getRetryTopic(requestHeader.getGroup());
- int queueIdInt = Math.abs(this.random.nextInt() % 99999999) % subscriptionGroupConfig.getRetryQueueNums();
-
-
- int topicSysFlag = 0;
- if (requestHeader.isUnitMode()) {
- topicSysFlag = TopicSysFlag.buildSysFlag(false, true);
- }
-
-
- TopicConfig topicConfig = this.brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(//
- newTopic, //
- subscriptionGroupConfig.getRetryQueueNums(), //
- PermName.PERM_WRITE | PermName.PERM_READ, topicSysFlag);
- if (null == topicConfig) {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("topic[" + newTopic + "] not exist");
- return response;
- }
-
-
- if (!PermName.isWriteable(topicConfig.getPerm())) {
- response.setCode(ResponseCode.NO_PERMISSION);
- response.setRemark(String.format("the topic[%s] sending message is forbidden", newTopic));
- return response;
- }
-
- MessageExt msgExt = this.brokerController.getMessageStore().lookMessageByOffset(requestHeader.getOffset());
- if (null == msgExt) {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("look message by offset failed, " + requestHeader.getOffset());
- return response;
- }
-
-
- final String retryTopic = msgExt.getProperty(MessageConst.PROPERTY_RETRY_TOPIC);
- if (null == retryTopic) {
- MessageAccessor.putProperty(msgExt, MessageConst.PROPERTY_RETRY_TOPIC, msgExt.getTopic());
- }
- msgExt.setWaitStoreMsgOK(false);
-
-
- int delayLevel = requestHeader.getDelayLevel();
-
-
- int maxReconsumeTimes = subscriptionGroupConfig.getRetryMaxTimes();
- if (request.getVersion() >= MQVersion.Version.V3_4_9.ordinal()) {
- maxReconsumeTimes = requestHeader.getMaxReconsumeTimes();
- }
-
-
- if (msgExt.getReconsumeTimes() >= maxReconsumeTimes//
- || delayLevel < 0) {
- newTopic = MixAll.getDLQTopic(requestHeader.getGroup());
- queueIdInt = Math.abs(this.random.nextInt() % 99999999) % DLQ_NUMS_PER_GROUP;
-
- topicConfig = this.brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(newTopic, //
- DLQ_NUMS_PER_GROUP, //
- PermName.PERM_WRITE, 0
- );
- if (null == topicConfig) {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("topic[" + newTopic + "] not exist");
- return response;
- }
- } else {
- if (0 == delayLevel) {
- delayLevel = 3 + msgExt.getReconsumeTimes();
- }
-
- msgExt.setDelayTimeLevel(delayLevel);
- }
-
- MessageExtBrokerInner msgInner = new MessageExtBrokerInner();
- msgInner.setTopic(newTopic);
- msgInner.setBody(msgExt.getBody());
- msgInner.setFlag(msgExt.getFlag());
- MessageAccessor.setProperties(msgInner, msgExt.getProperties());
- msgInner.setPropertiesString(MessageDecoder.messageProperties2String(msgExt.getProperties()));
- msgInner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(null, msgExt.getTags()));
-
- msgInner.setQueueId(queueIdInt);
- msgInner.setSysFlag(msgExt.getSysFlag());
- msgInner.setBornTimestamp(msgExt.getBornTimestamp());
- msgInner.setBornHost(msgExt.getBornHost());
- msgInner.setStoreHost(this.getStoreHost());
- msgInner.setReconsumeTimes(msgExt.getReconsumeTimes() + 1);
-
- String originMsgId = MessageAccessor.getOriginMessageId(msgExt);
- MessageAccessor.setOriginMessageId(msgInner, UtilAll.isBlank(originMsgId) ? msgExt.getMsgId() : originMsgId);
-
- PutMessageResult putMessageResult = this.brokerController.getMessageStore().putMessage(msgInner);
- if (putMessageResult != null) {
- switch (putMessageResult.getPutMessageStatus()) {
- case PUT_OK:
- String backTopic = msgExt.getTopic();
- String correctTopic = msgExt.getProperty(MessageConst.PROPERTY_RETRY_TOPIC);
- if (correctTopic != null) {
- backTopic = correctTopic;
- }
-
- this.brokerController.getBrokerStatsManager().incSendBackNums(requestHeader.getGroup(), backTopic);
-
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
-
- return response;
- default:
- break;
- }
-
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark(putMessageResult.getPutMessageStatus().name());
- return response;
- }
-
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("putMessageResult is null");
- return response;
- }
-
- private RemotingCommand sendMessage(final ChannelHandlerContext ctx, //
- final RemotingCommand request, //
- final SendMessageContext sendMessageContext, //
- final SendMessageRequestHeader requestHeader) throws RemotingCommandException {
-
- final RemotingCommand response = RemotingCommand.createResponseCommand(SendMessageResponseHeader.class);
- final SendMessageResponseHeader responseHeader = (SendMessageResponseHeader) response.readCustomHeader();
-
-
- response.setOpaque(request.getOpaque());
-
- response.addExtField(MessageConst.PROPERTY_MSG_REGION, this.brokerController.getBrokerConfig().getRegionId());
- response.addExtField(MessageConst.PROPERTY_TRACE_SWITCH, String.valueOf(this.brokerController.getBrokerConfig().isTraceOn()));
-
- if (log.isDebugEnabled()) {
- log.debug("receive SendMessage request command, " + request);
- }
-
- final long startTimstamp = this.brokerController.getBrokerConfig().getStartAcceptSendRequestTimeStamp();
- if (this.brokerController.getMessageStore().now() < startTimstamp) {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark(String.format("broker unable to service, until %s", UtilAll.timeMillisToHumanString2(startTimstamp)));
- return response;
- }
-
- response.setCode(-1);
- super.msgCheck(ctx, requestHeader, response);
- if (response.getCode() != -1) {
- return response;
- }
-
- final byte[] body = request.getBody();
-
- int queueIdInt = requestHeader.getQueueId();
- TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(requestHeader.getTopic());
-
- if (queueIdInt < 0) {
- queueIdInt = Math.abs(this.random.nextInt() % 99999999) % topicConfig.getWriteQueueNums();
- }
-
- int sysFlag = requestHeader.getSysFlag();
-
- if (TopicFilterType.MULTI_TAG == topicConfig.getTopicFilterType()) {
- sysFlag |= MessageSysFlag.MULTI_TAGS_FLAG;
- }
-
- String newTopic = requestHeader.getTopic();
- if (null != newTopic && newTopic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
- String groupName = newTopic.substring(MixAll.RETRY_GROUP_TOPIC_PREFIX.length());
- SubscriptionGroupConfig subscriptionGroupConfig =
- this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(groupName);
- if (null == subscriptionGroupConfig) {
- response.setCode(ResponseCode.SUBSCRIPTION_GROUP_NOT_EXIST);
- response.setRemark(
- "subscription group not exist, " + groupName + " " + FAQUrl.suggestTodo(FAQUrl.SUBSCRIPTION_GROUP_NOT_EXIST));
- return response;
- }
-
-
- int maxReconsumeTimes = subscriptionGroupConfig.getRetryMaxTimes();
- if (request.getVersion() >= MQVersion.Version.V3_4_9.ordinal()) {
- maxReconsumeTimes = requestHeader.getMaxReconsumeTimes();
- }
- int reconsumeTimes = requestHeader.getReconsumeTimes() == null ? 0 : requestHeader.getReconsumeTimes();
- if (reconsumeTimes >= maxReconsumeTimes) {
- newTopic = MixAll.getDLQTopic(groupName);
- queueIdInt = Math.abs(this.random.nextInt() % 99999999) % DLQ_NUMS_PER_GROUP;
- topicConfig = this.brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(newTopic, //
- DLQ_NUMS_PER_GROUP, //
- PermName.PERM_WRITE, 0
- );
- if (null == topicConfig) {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("topic[" + newTopic + "] not exist");
- return response;
- }
- }
- }
- MessageExtBrokerInner msgInner = new MessageExtBrokerInner();
- msgInner.setTopic(newTopic);
- msgInner.setBody(body);
- msgInner.setFlag(requestHeader.getFlag());
- MessageAccessor.setProperties(msgInner, MessageDecoder.string2messageProperties(requestHeader.getProperties()));
- msgInner.setPropertiesString(requestHeader.getProperties());
- msgInner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(topicConfig.getTopicFilterType(), msgInner.getTags()));
-
- msgInner.setQueueId(queueIdInt);
- msgInner.setSysFlag(sysFlag);
- msgInner.setBornTimestamp(requestHeader.getBornTimestamp());
- msgInner.setBornHost(ctx.channel().remoteAddress());
- msgInner.setStoreHost(this.getStoreHost());
- msgInner.setReconsumeTimes(requestHeader.getReconsumeTimes() == null ? 0 : requestHeader.getReconsumeTimes());
-
- if (this.brokerController.getBrokerConfig().isRejectTransactionMessage()) {
- String traFlag = msgInner.getProperty(MessageConst.PROPERTY_TRANSACTION_PREPARED);
- if (traFlag != null) {
- response.setCode(ResponseCode.NO_PERMISSION);
- response.setRemark(
- "the broker[" + this.brokerController.getBrokerConfig().getBrokerIP1() + "] sending transaction message is forbidden");
- return response;
- }
- }
-
- PutMessageResult putMessageResult = this.brokerController.getMessageStore().putMessage(msgInner);
- if (putMessageResult != null) {
- boolean sendOK = false;
-
- switch (putMessageResult.getPutMessageStatus()) {
- // Success
- case PUT_OK:
- sendOK = true;
- response.setCode(ResponseCode.SUCCESS);
- break;
- case FLUSH_DISK_TIMEOUT:
- response.setCode(ResponseCode.FLUSH_DISK_TIMEOUT);
- sendOK = true;
- break;
- case FLUSH_SLAVE_TIMEOUT:
- response.setCode(ResponseCode.FLUSH_SLAVE_TIMEOUT);
- sendOK = true;
- break;
- case SLAVE_NOT_AVAILABLE:
- response.setCode(ResponseCode.SLAVE_NOT_AVAILABLE);
- sendOK = true;
- break;
-
- // Failed
- case CREATE_MAPEDFILE_FAILED:
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("create mapped file failed, server is busy or broken.");
- break;
- case MESSAGE_ILLEGAL:
- case PROPERTIES_SIZE_EXCEEDED:
- response.setCode(ResponseCode.MESSAGE_ILLEGAL);
- response.setRemark(
- "the message is illegal, maybe msg body or properties length not matched. msg body length limit 128k, msg properties length limit 32k.");
- break;
- case SERVICE_NOT_AVAILABLE:
- response.setCode(ResponseCode.SERVICE_NOT_AVAILABLE);
- response.setRemark(
- "service not available now, maybe disk full, " + diskUtil() + ", maybe your broker machine memory too small.");
- break;
- case OS_PAGECACHE_BUSY:
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("[PC_SYNCHRONIZED]broker busy, start flow control for a while");
- break;
- case UNKNOWN_ERROR:
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("UNKNOWN_ERROR");
- break;
- default:
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("UNKNOWN_ERROR DEFAULT");
- break;
- }
-
- String owner = request.getExtFields().get(BrokerStatsManager.COMMERCIAL_OWNER);
- if (sendOK) {
-
- this.brokerController.getBrokerStatsManager().incTopicPutNums(msgInner.getTopic());
- this.brokerController.getBrokerStatsManager().incTopicPutSize(msgInner.getTopic(),
- putMessageResult.getAppendMessageResult().getWroteBytes());
- this.brokerController.getBrokerStatsManager().incBrokerPutNums();
-
- response.setRemark(null);
-
- responseHeader.setMsgId(putMessageResult.getAppendMessageResult().getMsgId());
- responseHeader.setQueueId(queueIdInt);
- responseHeader.setQueueOffset(putMessageResult.getAppendMessageResult().getLogicsOffset());
-
-
- doResponse(ctx, request, response);
-
-
- if (hasSendMessageHook()) {
- sendMessageContext.setMsgId(responseHeader.getMsgId());
- sendMessageContext.setQueueId(responseHeader.getQueueId());
- sendMessageContext.setQueueOffset(responseHeader.getQueueOffset());
-
- int commercialBaseCount = brokerController.getBrokerConfig().getCommercialBaseCount();
- int wroteSize = putMessageResult.getAppendMessageResult().getWroteBytes();
- int incValue = (int) Math.ceil(wroteSize / BrokerStatsManager.SIZE_PER_COUNT) * commercialBaseCount;
-
- sendMessageContext.setCommercialSendStats(BrokerStatsManager.StatsType.SEND_SUCCESS);
- sendMessageContext.setCommercialSendTimes(incValue);
- sendMessageContext.setCommercialSendSize(wroteSize);
- sendMessageContext.setCommercialOwner(owner);
- }
- return null;
- } else {
- if (hasSendMessageHook()) {
- int wroteSize = request.getBody().length;
- int incValue = (int) Math.ceil(wroteSize / BrokerStatsManager.SIZE_PER_COUNT);
-
- sendMessageContext.setCommercialSendStats(BrokerStatsManager.StatsType.SEND_FAILURE);
- sendMessageContext.setCommercialSendTimes(incValue);
- sendMessageContext.setCommercialSendSize(wroteSize);
- sendMessageContext.setCommercialOwner(owner);
- }
- }
- } else {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("store putMessage return null");
- }
-
- return response;
- }
-
- public boolean hasConsumeMessageHook() {
- return consumeMessageHookList != null && !this.consumeMessageHookList.isEmpty();
- }
-
- public void executeConsumeMessageHookAfter(final ConsumeMessageContext context) {
- if (hasConsumeMessageHook()) {
- for (ConsumeMessageHook hook : this.consumeMessageHookList) {
- try {
- hook.consumeMessageAfter(context);
- } catch (Throwable e) {
- }
- }
- }
- }
-
- public SocketAddress getStoreHost() {
- return storeHost;
- }
-
- private String diskUtil() {
- String storePathPhysic = this.brokerController.getMessageStoreConfig().getStorePathCommitLog();
- double physicRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathPhysic);
-
- String storePathLogis =
- StorePathConfigHelper.getStorePathConsumeQueue(this.brokerController.getMessageStoreConfig().getStorePathRootDir());
- double logisRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathLogis);
-
- String storePathIndex =
- StorePathConfigHelper.getStorePathIndex(this.brokerController.getMessageStoreConfig().getStorePathRootDir());
- double indexRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathIndex);
-
- return String.format("CL: %5.2f CQ: %5.2f INDEX: %5.2f", physicRatio, logisRatio, indexRatio);
- }
-
- public void registerConsumeMessageHook(List<ConsumeMessageHook> consumeMessageHookList) {
- this.consumeMessageHookList = consumeMessageHookList;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/slave/SlaveSynchronize.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/slave/SlaveSynchronize.java b/broker/src/main/java/com/alibaba/rocketmq/broker/slave/SlaveSynchronize.java
deleted file mode 100644
index 8b3aefe..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/slave/SlaveSynchronize.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * 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.slave;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import com.alibaba.rocketmq.broker.subscription.SubscriptionGroupManager;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.protocol.body.ConsumerOffsetSerializeWrapper;
-import com.alibaba.rocketmq.common.protocol.body.SubscriptionGroupWrapper;
-import com.alibaba.rocketmq.common.protocol.body.TopicConfigSerializeWrapper;
-import com.alibaba.rocketmq.store.config.StorePathConfigHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-
-
-/**
- * @author shijia.wxr
- * @author manhong.yqd
- */
-public class SlaveSynchronize {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
- private final BrokerController brokerController;
- private volatile String masterAddr = null;
-
-
- public SlaveSynchronize(BrokerController brokerController) {
- this.brokerController = brokerController;
- }
-
-
- public String getMasterAddr() {
- return masterAddr;
- }
-
-
- public void setMasterAddr(String masterAddr) {
- this.masterAddr = masterAddr;
- }
-
-
- public void syncAll() {
- this.syncTopicConfig();
- this.syncConsumerOffset();
- this.syncDelayOffset();
- this.syncSubscriptionGroupConfig();
- }
-
-
- private void syncTopicConfig() {
- String masterAddrBak = this.masterAddr;
- if (masterAddrBak != null) {
- try {
- TopicConfigSerializeWrapper topicWrapper =
- this.brokerController.getBrokerOuterAPI().getAllTopicConfig(masterAddrBak);
- if (!this.brokerController.getTopicConfigManager().getDataVersion()
- .equals(topicWrapper.getDataVersion())) {
-
- this.brokerController.getTopicConfigManager().getDataVersion()
- .assignNewOne(topicWrapper.getDataVersion());
- this.brokerController.getTopicConfigManager().getTopicConfigTable().clear();
- this.brokerController.getTopicConfigManager().getTopicConfigTable()
- .putAll(topicWrapper.getTopicConfigTable());
- this.brokerController.getTopicConfigManager().persist();
-
- log.info("update slave topic config from master, {}", masterAddrBak);
- }
- } catch (Exception e) {
- log.error("syncTopicConfig Exception, " + masterAddrBak, e);
- }
- }
- }
-
-
- private void syncConsumerOffset() {
- String masterAddrBak = this.masterAddr;
- if (masterAddrBak != null) {
- try {
- ConsumerOffsetSerializeWrapper offsetWrapper =
- this.brokerController.getBrokerOuterAPI().getAllConsumerOffset(masterAddrBak);
- this.brokerController.getConsumerOffsetManager().getOffsetTable()
- .putAll(offsetWrapper.getOffsetTable());
- this.brokerController.getConsumerOffsetManager().persist();
- log.info("update slave consumer offset from master, {}", masterAddrBak);
- } catch (Exception e) {
- log.error("syncConsumerOffset Exception, " + masterAddrBak, e);
- }
- }
- }
-
-
- private void syncDelayOffset() {
- String masterAddrBak = this.masterAddr;
- if (masterAddrBak != null) {
- try {
- String delayOffset =
- this.brokerController.getBrokerOuterAPI().getAllDelayOffset(masterAddrBak);
- if (delayOffset != null) {
-
- String fileName =
- StorePathConfigHelper.getDelayOffsetStorePath(this.brokerController
- .getMessageStoreConfig().getStorePathRootDir());
- try {
- MixAll.string2File(delayOffset, fileName);
- } catch (IOException e) {
- log.error("persist file Exception, " + fileName, e);
- }
- }
- log.info("update slave delay offset from master, {}", masterAddrBak);
- } catch (Exception e) {
- log.error("syncDelayOffset Exception, " + masterAddrBak, e);
- }
- }
- }
-
-
- private void syncSubscriptionGroupConfig() {
- String masterAddrBak = this.masterAddr;
- if (masterAddrBak != null) {
- try {
- SubscriptionGroupWrapper subscriptionWrapper =
- this.brokerController.getBrokerOuterAPI()
- .getAllSubscriptionGroupConfig(masterAddrBak);
-
- if (!this.brokerController.getSubscriptionGroupManager().getDataVersion()
- .equals(subscriptionWrapper.getDataVersion())) {
- SubscriptionGroupManager subscriptionGroupManager =
- this.brokerController.getSubscriptionGroupManager();
- subscriptionGroupManager.getDataVersion().assignNewOne(
- subscriptionWrapper.getDataVersion());
- subscriptionGroupManager.getSubscriptionGroupTable().clear();
- subscriptionGroupManager.getSubscriptionGroupTable().putAll(
- subscriptionWrapper.getSubscriptionGroupTable());
- subscriptionGroupManager.persist();
- log.info("update slave Subscription Group from master, {}", masterAddrBak);
- }
- } catch (Exception e) {
- log.error("syncSubscriptionGroup Exception, " + masterAddrBak, e);
- }
- }
- }
-}
[51/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
ROCKETMQ-18 Rename package name from com.alibaba to org.apache
Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/commit/de6f9416
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/tree/de6f9416
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/diff/de6f9416
Branch: refs/heads/master
Commit: de6f9416aad7fad1c04966888239225bb7394a54
Parents: 770c7f7
Author: yukon <yu...@apache.org>
Authored: Tue Dec 27 18:45:51 2016 +0800
Committer: yukon <yu...@apache.org>
Committed: Tue Dec 27 18:45:51 2016 +0800
----------------------------------------------------------------------
README.md | 4 +-
benchmark/consumer.sh | 2 +-
benchmark/producer.sh | 2 +-
benchmark/tproducer.sh | 2 +-
bin/mqadmin | 2 +-
bin/mqadmin.xml | 2 +-
bin/mqbroker | 2 +-
bin/mqbroker.xml | 2 +-
bin/mqfiltersrv | 2 +-
bin/mqfiltersrv.xml | 2 +-
bin/mqnamesrv | 2 +-
bin/mqnamesrv.xml | 2 +-
bin/mqshutdown | 4 +-
bin/startfsrv.sh | 2 +-
broker/pom.xml | 2 +-
.../rocketmq/broker/BrokerController.java | 773 -------
.../rocketmq/broker/BrokerPathConfigHelper.java | 52 -
.../alibaba/rocketmq/broker/BrokerStartup.java | 266 ---
.../broker/client/ClientChannelInfo.java | 115 -
.../client/ClientHousekeepingService.java | 100 -
.../broker/client/ConsumerGroupInfo.java | 273 ---
.../client/ConsumerIdsChangeListener.java | 29 -
.../rocketmq/broker/client/ConsumerManager.java | 187 --
.../DefaultConsumerIdsChangeListener.java | 45 -
.../rocketmq/broker/client/ProducerManager.java | 199 --
.../broker/client/net/Broker2Client.java | 317 ---
.../client/rebalance/RebalanceLockManager.java | 281 ---
.../broker/filtersrv/FilterServerManager.java | 175 --
.../broker/filtersrv/FilterServerUtil.java | 43 -
.../broker/latency/BrokerFastFailure.java | 115 -
.../latency/BrokerFixedThreadPoolExecutor.java | 46 -
.../rocketmq/broker/latency/FutureTaskExt.java | 42 -
.../broker/longpolling/ManyPullRequest.java | 49 -
.../NotifyMessageArrivingListener.java | 36 -
.../broker/longpolling/PullRequest.java | 74 -
.../longpolling/PullRequestHoldService.java | 169 --
.../broker/mqtrace/ConsumeMessageContext.java | 172 --
.../broker/mqtrace/ConsumeMessageHook.java | 27 -
.../broker/mqtrace/SendMessageContext.java | 261 ---
.../broker/mqtrace/SendMessageHook.java | 27 -
.../broker/offset/ConsumerOffsetManager.java | 249 ---
.../rocketmq/broker/out/BrokerOuterAPI.java | 302 ---
.../broker/pagecache/ManyMessageTransfer.java | 90 -
.../broker/pagecache/OneMessageTransfer.java | 79 -
.../broker/pagecache/QueryMessageTransfer.java | 90 -
.../plugin/AbstractPluginMessageStore.java | 236 ---
.../broker/plugin/MessageStoreFactory.java | 50 -
.../plugin/MessageStorePluginContext.java | 61 -
.../processor/AbstractSendMessageProcessor.java | 332 ---
.../broker/processor/AdminBrokerProcessor.java | 1212 -----------
.../broker/processor/ClientManageProcessor.java | 164 --
.../processor/ConsumerManageProcessor.java | 157 --
.../processor/EndTransactionProcessor.java | 236 ---
.../processor/ForwardRequestProcessor.java | 51 -
.../broker/processor/PullMessageProcessor.java | 542 -----
.../broker/processor/QueryMessageProcessor.java | 178 --
.../broker/processor/SendMessageProcessor.java | 497 -----
.../rocketmq/broker/slave/SlaveSynchronize.java | 158 --
.../subscription/SubscriptionGroupManager.java | 203 --
.../broker/topic/TopicConfigManager.java | 440 ----
.../broker/transaction/TransactionRecord.java | 44 -
.../broker/transaction/TransactionStore.java | 46 -
.../transaction/jdbc/JDBCTransactionStore.java | 240 ---
.../jdbc/JDBCTransactionStoreConfig.java | 65 -
.../rocketmq/broker/BrokerController.java | 773 +++++++
.../rocketmq/broker/BrokerPathConfigHelper.java | 52 +
.../apache/rocketmq/broker/BrokerStartup.java | 266 +++
.../broker/client/ClientChannelInfo.java | 115 +
.../client/ClientHousekeepingService.java | 100 +
.../broker/client/ConsumerGroupInfo.java | 273 +++
.../client/ConsumerIdsChangeListener.java | 29 +
.../rocketmq/broker/client/ConsumerManager.java | 187 ++
.../DefaultConsumerIdsChangeListener.java | 45 +
.../rocketmq/broker/client/ProducerManager.java | 199 ++
.../broker/client/net/Broker2Client.java | 317 +++
.../client/rebalance/RebalanceLockManager.java | 281 +++
.../broker/filtersrv/FilterServerManager.java | 175 ++
.../broker/filtersrv/FilterServerUtil.java | 43 +
.../broker/latency/BrokerFastFailure.java | 115 +
.../latency/BrokerFixedThreadPoolExecutor.java | 46 +
.../rocketmq/broker/latency/FutureTaskExt.java | 42 +
.../broker/longpolling/ManyPullRequest.java | 49 +
.../NotifyMessageArrivingListener.java | 36 +
.../broker/longpolling/PullRequest.java | 74 +
.../longpolling/PullRequestHoldService.java | 169 ++
.../broker/mqtrace/ConsumeMessageContext.java | 172 ++
.../broker/mqtrace/ConsumeMessageHook.java | 27 +
.../broker/mqtrace/SendMessageContext.java | 261 +++
.../broker/mqtrace/SendMessageHook.java | 27 +
.../broker/offset/ConsumerOffsetManager.java | 249 +++
.../rocketmq/broker/out/BrokerOuterAPI.java | 302 +++
.../broker/pagecache/ManyMessageTransfer.java | 90 +
.../broker/pagecache/OneMessageTransfer.java | 79 +
.../broker/pagecache/QueryMessageTransfer.java | 90 +
.../plugin/AbstractPluginMessageStore.java | 236 +++
.../broker/plugin/MessageStoreFactory.java | 50 +
.../plugin/MessageStorePluginContext.java | 61 +
.../processor/AbstractSendMessageProcessor.java | 332 +++
.../broker/processor/AdminBrokerProcessor.java | 1212 +++++++++++
.../broker/processor/ClientManageProcessor.java | 164 ++
.../processor/ConsumerManageProcessor.java | 157 ++
.../processor/EndTransactionProcessor.java | 236 +++
.../processor/ForwardRequestProcessor.java | 51 +
.../broker/processor/PullMessageProcessor.java | 542 +++++
.../broker/processor/QueryMessageProcessor.java | 178 ++
.../broker/processor/SendMessageProcessor.java | 497 +++++
.../rocketmq/broker/slave/SlaveSynchronize.java | 158 ++
.../subscription/SubscriptionGroupManager.java | 203 ++
.../broker/topic/TopicConfigManager.java | 440 ++++
.../broker/transaction/TransactionRecord.java | 44 +
.../broker/transaction/TransactionStore.java | 46 +
.../transaction/jdbc/JDBCTransactionStore.java | 240 +++
.../jdbc/JDBCTransactionStoreConfig.java | 65 +
.../rocketmq/broker/BrokerControllerTest.java | 61 -
.../rocketmq/broker/BrokerTestHarness.java | 74 -
.../rocketmq/broker/api/SendMessageTest.java | 83 -
.../offset/ConsumerOffsetManagerTest.java | 65 -
.../broker/topic/TopicConfigManagerTest.java | 62 -
.../rocketmq/broker/BrokerControllerTest.java | 61 +
.../rocketmq/broker/BrokerTestHarness.java | 74 +
.../rocketmq/broker/api/SendMessageTest.java | 83 +
.../offset/ConsumerOffsetManagerTest.java | 65 +
.../broker/topic/TopicConfigManagerTest.java | 62 +
client/pom.xml | 12 +-
.../alibaba/rocketmq/client/ClientConfig.java | 202 --
.../com/alibaba/rocketmq/client/MQAdmin.java | 173 --
.../com/alibaba/rocketmq/client/MQHelper.java | 94 -
.../alibaba/rocketmq/client/QueryResult.java | 53 -
.../com/alibaba/rocketmq/client/Validators.java | 150 --
.../rocketmq/client/admin/MQAdminExtInner.java | 24 -
.../rocketmq/client/common/ClientErrorCode.java | 26 -
.../client/common/ThreadLocalIndex.java | 51 -
.../consumer/AllocateMessageQueueStrategy.java | 60 -
.../client/consumer/DefaultMQPullConsumer.java | 381 ----
.../client/consumer/DefaultMQPushConsumer.java | 519 -----
.../rocketmq/client/consumer/MQConsumer.java | 78 -
.../client/consumer/MQPullConsumer.java | 229 --
.../consumer/MQPullConsumerScheduleService.java | 212 --
.../client/consumer/MQPushConsumer.java | 117 -
.../client/consumer/MessageQueueListener.java | 41 -
.../rocketmq/client/consumer/PullCallback.java | 28 -
.../rocketmq/client/consumer/PullResult.java | 82 -
.../rocketmq/client/consumer/PullStatus.java | 39 -
.../client/consumer/PullTaskCallback.java | 24 -
.../client/consumer/PullTaskContext.java | 44 -
.../listener/ConsumeConcurrentlyContext.java | 66 -
.../listener/ConsumeConcurrentlyStatus.java | 31 -
.../listener/ConsumeOrderlyContext.java | 61 -
.../consumer/listener/ConsumeOrderlyStatus.java | 41 -
.../consumer/listener/ConsumeReturnType.java | 44 -
.../consumer/listener/MessageListener.java | 25 -
.../listener/MessageListenerConcurrently.java | 42 -
.../listener/MessageListenerOrderly.java | 42 -
.../AllocateMessageQueueAveragely.java | 75 -
.../AllocateMessageQueueAveragelyByCircle.java | 71 -
.../rebalance/AllocateMessageQueueByConfig.java | 50 -
.../AllocateMessageQueueByMachineRoom.java | 75 -
.../consumer/store/LocalFileOffsetStore.java | 228 --
.../consumer/store/OffsetSerializeWrapper.java | 42 -
.../client/consumer/store/OffsetStore.java | 97 -
.../client/consumer/store/ReadOffsetType.java | 32 -
.../consumer/store/RemoteBrokerOffsetStore.java | 261 ---
.../client/exception/MQBrokerException.java | 48 -
.../client/exception/MQClientException.java | 62 -
.../client/hook/CheckForbiddenContext.java | 148 --
.../client/hook/CheckForbiddenHook.java | 31 -
.../client/hook/ConsumeMessageContext.java | 104 -
.../client/hook/ConsumeMessageHook.java | 25 -
.../client/hook/FilterMessageContext.java | 91 -
.../rocketmq/client/hook/FilterMessageHook.java | 27 -
.../client/hook/SendMessageContext.java | 157 --
.../rocketmq/client/hook/SendMessageHook.java | 25 -
.../client/impl/ClientRemotingProcessor.java | 199 --
.../rocketmq/client/impl/CommunicationMode.java | 26 -
.../rocketmq/client/impl/FindBrokerResult.java | 41 -
.../rocketmq/client/impl/MQAdminImpl.java | 418 ----
.../rocketmq/client/impl/MQClientAPIImpl.java | 1996 ------------------
.../rocketmq/client/impl/MQClientManager.java | 71 -
.../ConsumeMessageConcurrentlyService.java | 471 -----
.../consumer/ConsumeMessageOrderlyService.java | 536 -----
.../impl/consumer/ConsumeMessageService.java | 56 -
.../consumer/DefaultMQPullConsumerImpl.java | 706 -------
.../consumer/DefaultMQPushConsumerImpl.java | 1071 ----------
.../client/impl/consumer/MQConsumerInner.java | 66 -
.../client/impl/consumer/MessageQueueLock.java | 46 -
.../client/impl/consumer/ProcessQueue.java | 451 ----
.../client/impl/consumer/PullAPIWrapper.java | 255 ---
.../impl/consumer/PullMessageService.java | 109 -
.../client/impl/consumer/PullRequest.java | 114 -
.../client/impl/consumer/PullResultExt.java | 55 -
.../client/impl/consumer/RebalanceImpl.java | 481 -----
.../client/impl/consumer/RebalancePullImpl.java | 85 -
.../client/impl/consumer/RebalancePushImpl.java | 196 --
.../client/impl/consumer/RebalanceService.java | 58 -
.../client/impl/factory/MQClientInstance.java | 1147 ----------
.../impl/producer/DefaultMQProducerImpl.java | 1080 ----------
.../client/impl/producer/MQProducerInner.java | 49 -
.../client/impl/producer/TopicPublishInfo.java | 133 --
.../client/latency/LatencyFaultTolerance.java | 31 -
.../latency/LatencyFaultToleranceImpl.java | 191 --
.../client/latency/MQFaultStrategy.java | 108 -
.../rocketmq/client/log/ClientLogger.java | 116 -
.../client/producer/DefaultMQProducer.java | 380 ----
.../producer/LocalTransactionExecuter.java | 27 -
.../client/producer/LocalTransactionState.java | 26 -
.../rocketmq/client/producer/MQProducer.java | 106 -
.../client/producer/MessageQueueSelector.java | 30 -
.../rocketmq/client/producer/SendCallback.java | 27 -
.../rocketmq/client/producer/SendResult.java | 143 --
.../rocketmq/client/producer/SendStatus.java | 27 -
.../producer/TransactionCheckListener.java | 27 -
.../client/producer/TransactionMQProducer.java | 109 -
.../client/producer/TransactionSendResult.java | 38 -
.../selector/SelectMessageQueueByHash.java | 41 -
.../SelectMessageQueueByMachineRoom.java | 48 -
.../selector/SelectMessageQueueByRandoom.java | 44 -
.../client/stat/ConsumerStatsManager.java | 165 --
.../apache/rocketmq/client/ClientConfig.java | 202 ++
.../org/apache/rocketmq/client/MQAdmin.java | 173 ++
.../org/apache/rocketmq/client/MQHelper.java | 94 +
.../org/apache/rocketmq/client/QueryResult.java | 53 +
.../org/apache/rocketmq/client/Validators.java | 150 ++
.../rocketmq/client/admin/MQAdminExtInner.java | 24 +
.../rocketmq/client/common/ClientErrorCode.java | 26 +
.../client/common/ThreadLocalIndex.java | 51 +
.../consumer/AllocateMessageQueueStrategy.java | 60 +
.../client/consumer/DefaultMQPullConsumer.java | 381 ++++
.../client/consumer/DefaultMQPushConsumer.java | 519 +++++
.../rocketmq/client/consumer/MQConsumer.java | 78 +
.../client/consumer/MQPullConsumer.java | 229 ++
.../consumer/MQPullConsumerScheduleService.java | 212 ++
.../client/consumer/MQPushConsumer.java | 117 +
.../client/consumer/MessageQueueListener.java | 41 +
.../rocketmq/client/consumer/PullCallback.java | 28 +
.../rocketmq/client/consumer/PullResult.java | 82 +
.../rocketmq/client/consumer/PullStatus.java | 39 +
.../client/consumer/PullTaskCallback.java | 24 +
.../client/consumer/PullTaskContext.java | 44 +
.../listener/ConsumeConcurrentlyContext.java | 66 +
.../listener/ConsumeConcurrentlyStatus.java | 31 +
.../listener/ConsumeOrderlyContext.java | 61 +
.../consumer/listener/ConsumeOrderlyStatus.java | 41 +
.../consumer/listener/ConsumeReturnType.java | 44 +
.../consumer/listener/MessageListener.java | 25 +
.../listener/MessageListenerConcurrently.java | 42 +
.../listener/MessageListenerOrderly.java | 42 +
.../AllocateMessageQueueAveragely.java | 75 +
.../AllocateMessageQueueAveragelyByCircle.java | 71 +
.../rebalance/AllocateMessageQueueByConfig.java | 50 +
.../AllocateMessageQueueByMachineRoom.java | 75 +
.../consumer/store/LocalFileOffsetStore.java | 228 ++
.../consumer/store/OffsetSerializeWrapper.java | 42 +
.../client/consumer/store/OffsetStore.java | 97 +
.../client/consumer/store/ReadOffsetType.java | 32 +
.../consumer/store/RemoteBrokerOffsetStore.java | 261 +++
.../client/exception/MQBrokerException.java | 48 +
.../client/exception/MQClientException.java | 62 +
.../client/hook/CheckForbiddenContext.java | 148 ++
.../client/hook/CheckForbiddenHook.java | 31 +
.../client/hook/ConsumeMessageContext.java | 104 +
.../client/hook/ConsumeMessageHook.java | 25 +
.../client/hook/FilterMessageContext.java | 91 +
.../rocketmq/client/hook/FilterMessageHook.java | 27 +
.../client/hook/SendMessageContext.java | 157 ++
.../rocketmq/client/hook/SendMessageHook.java | 25 +
.../client/impl/ClientRemotingProcessor.java | 199 ++
.../rocketmq/client/impl/CommunicationMode.java | 26 +
.../rocketmq/client/impl/FindBrokerResult.java | 41 +
.../rocketmq/client/impl/MQAdminImpl.java | 418 ++++
.../rocketmq/client/impl/MQClientAPIImpl.java | 1996 ++++++++++++++++++
.../rocketmq/client/impl/MQClientManager.java | 71 +
.../ConsumeMessageConcurrentlyService.java | 471 +++++
.../consumer/ConsumeMessageOrderlyService.java | 539 +++++
.../impl/consumer/ConsumeMessageService.java | 56 +
.../consumer/DefaultMQPullConsumerImpl.java | 706 +++++++
.../consumer/DefaultMQPushConsumerImpl.java | 1071 ++++++++++
.../client/impl/consumer/MQConsumerInner.java | 66 +
.../client/impl/consumer/MessageQueueLock.java | 46 +
.../client/impl/consumer/ProcessQueue.java | 451 ++++
.../client/impl/consumer/PullAPIWrapper.java | 255 +++
.../impl/consumer/PullMessageService.java | 109 +
.../client/impl/consumer/PullRequest.java | 114 +
.../client/impl/consumer/PullResultExt.java | 55 +
.../client/impl/consumer/RebalanceImpl.java | 481 +++++
.../client/impl/consumer/RebalancePullImpl.java | 85 +
.../client/impl/consumer/RebalancePushImpl.java | 196 ++
.../client/impl/consumer/RebalanceService.java | 58 +
.../client/impl/factory/MQClientInstance.java | 1147 ++++++++++
.../impl/producer/DefaultMQProducerImpl.java | 1080 ++++++++++
.../client/impl/producer/MQProducerInner.java | 49 +
.../client/impl/producer/TopicPublishInfo.java | 133 ++
.../client/latency/LatencyFaultTolerance.java | 31 +
.../latency/LatencyFaultToleranceImpl.java | 191 ++
.../client/latency/MQFaultStrategy.java | 108 +
.../rocketmq/client/log/ClientLogger.java | 116 +
.../client/producer/DefaultMQProducer.java | 380 ++++
.../producer/LocalTransactionExecuter.java | 27 +
.../client/producer/LocalTransactionState.java | 26 +
.../rocketmq/client/producer/MQProducer.java | 106 +
.../client/producer/MessageQueueSelector.java | 30 +
.../rocketmq/client/producer/SendCallback.java | 27 +
.../rocketmq/client/producer/SendResult.java | 143 ++
.../rocketmq/client/producer/SendStatus.java | 27 +
.../producer/TransactionCheckListener.java | 27 +
.../client/producer/TransactionMQProducer.java | 109 +
.../client/producer/TransactionSendResult.java | 38 +
.../selector/SelectMessageQueueByHash.java | 41 +
.../SelectMessageQueueByMachineRoom.java | 48 +
.../selector/SelectMessageQueueByRandoom.java | 44 +
.../client/stat/ConsumerStatsManager.java | 165 ++
.../alibaba/rocketmq/client/ValidatorsTest.java | 35 -
.../AllocateMessageQueueAveragelyTest.java | 272 ---
.../apache/rocketmq/client/ValidatorsTest.java | 34 +
.../AllocateMessageQueueAveragelyTest.java | 272 +++
common/pom.xml | 2 +-
.../alibaba/rocketmq/common/BrokerConfig.java | 549 -----
.../rocketmq/common/BrokerConfigSingleton.java | 39 -
.../alibaba/rocketmq/common/ConfigManager.java | 89 -
.../alibaba/rocketmq/common/Configuration.java | 310 ---
.../alibaba/rocketmq/common/CountDownLatch.java | 207 --
.../alibaba/rocketmq/common/DataVersion.java | 82 -
.../com/alibaba/rocketmq/common/MQVersion.java | 362 ----
.../com/alibaba/rocketmq/common/MixAll.java | 486 -----
.../java/com/alibaba/rocketmq/common/Pair.java | 51 -
.../alibaba/rocketmq/common/ServiceState.java | 39 -
.../alibaba/rocketmq/common/ServiceThread.java | 142 --
.../alibaba/rocketmq/common/SystemClock.java | 26 -
.../rocketmq/common/ThreadFactoryImpl.java | 39 -
.../alibaba/rocketmq/common/TopicConfig.java | 206 --
.../rocketmq/common/TopicFilterType.java | 25 -
.../com/alibaba/rocketmq/common/UtilAll.java | 525 -----
.../rocketmq/common/admin/ConsumeStats.java | 67 -
.../rocketmq/common/admin/OffsetWrapper.java | 59 -
.../rocketmq/common/admin/RollbackStats.java | 91 -
.../rocketmq/common/admin/TopicOffset.java | 58 -
.../rocketmq/common/admin/TopicStatsTable.java | 42 -
.../common/annotation/ImportantField.java | 29 -
.../common/constant/DBMsgConstants.java | 22 -
.../rocketmq/common/constant/LoggerName.java | 40 -
.../rocketmq/common/constant/PermName.java | 56 -
.../common/consumer/ConsumeFromWhere.java | 34 -
.../rocketmq/common/filter/FilterAPI.java | 72 -
.../rocketmq/common/filter/FilterContext.java | 32 -
.../rocketmq/common/filter/MessageFilter.java | 25 -
.../alibaba/rocketmq/common/filter/impl/Op.java | 38 -
.../rocketmq/common/filter/impl/Operand.java | 26 -
.../rocketmq/common/filter/impl/Operator.java | 71 -
.../rocketmq/common/filter/impl/PolishExpr.java | 189 --
.../rocketmq/common/filter/impl/Type.java | 26 -
.../alibaba/rocketmq/common/help/FAQUrl.java | 101 -
.../rocketmq/common/hook/FilterCheckHook.java | 33 -
.../rocketmq/common/message/Message.java | 212 --
.../common/message/MessageAccessor.java | 104 -
.../common/message/MessageClientExt.java | 45 -
.../common/message/MessageClientIDSetter.java | 142 --
.../rocketmq/common/message/MessageConst.java | 75 -
.../rocketmq/common/message/MessageDecoder.java | 395 ----
.../rocketmq/common/message/MessageExt.java | 238 ---
.../rocketmq/common/message/MessageId.java | 54 -
.../rocketmq/common/message/MessageQueue.java | 134 --
.../common/message/MessageQueueForC.java | 152 --
.../rocketmq/common/message/MessageType.java | 25 -
.../rocketmq/common/namesrv/NamesrvConfig.java | 100 -
.../rocketmq/common/namesrv/NamesrvUtil.java | 25 -
.../common/namesrv/RegisterBrokerResult.java | 60 -
.../rocketmq/common/namesrv/TopAddressing.java | 116 -
.../common/protocol/MQProtosHelper.java | 57 -
.../rocketmq/common/protocol/RequestCode.java | 166 --
.../rocketmq/common/protocol/ResponseCode.java | 77 -
.../common/protocol/body/BrokerStatsData.java | 60 -
.../common/protocol/body/BrokerStatsItem.java | 54 -
.../rocketmq/common/protocol/body/CMResult.java | 27 -
.../common/protocol/body/ClusterInfo.java | 76 -
.../common/protocol/body/Connection.java | 71 -
.../common/protocol/body/ConsumeByWho.java | 84 -
.../body/ConsumeMessageDirectlyResult.java | 87 -
.../common/protocol/body/ConsumeStatsList.java | 58 -
.../common/protocol/body/ConsumeStatus.java | 88 -
.../protocol/body/ConsumerConnection.java | 102 -
.../body/ConsumerOffsetSerializeWrapper.java | 41 -
.../protocol/body/ConsumerRunningInfo.java | 315 ---
.../protocol/body/GetConsumerStatusBody.java | 55 -
.../common/protocol/body/GroupList.java | 40 -
.../rocketmq/common/protocol/body/KVTable.java | 40 -
.../protocol/body/LockBatchRequestBody.java | 65 -
.../protocol/body/LockBatchResponseBody.java | 45 -
.../common/protocol/body/ProcessQueueInfo.java | 185 --
.../protocol/body/ProducerConnection.java | 40 -
.../protocol/body/QueryConsumeTimeSpanBody.java | 41 -
.../body/QueryCorrectionOffsetBody.java | 40 -
.../common/protocol/body/QueueTimeSpan.java | 100 -
.../protocol/body/RegisterBrokerBody.java | 49 -
.../common/protocol/body/ResetOffsetBody.java | 42 -
.../protocol/body/ResetOffsetBodyForC.java | 38 -
.../protocol/body/SubscriptionGroupWrapper.java | 55 -
.../body/TopicConfigSerializeWrapper.java | 51 -
.../common/protocol/body/TopicList.java | 51 -
.../protocol/body/UnlockBatchRequestBody.java | 64 -
.../CheckTransactionStateRequestHeader.java | 79 -
.../CheckTransactionStateResponseHeader.java | 97 -
.../header/CloneGroupOffsetRequestHeader.java | 84 -
...nsumeMessageDirectlyResultRequestHeader.java | 80 -
.../ConsumerSendMsgBackRequestHeader.java | 125 --
.../header/CreateTopicRequestHeader.java | 143 --
.../DeleteSubscriptionGroupRequestHeader.java | 46 -
.../header/DeleteTopicRequestHeader.java | 49 -
.../header/EndTransactionRequestHeader.java | 145 --
.../header/EndTransactionResponseHeader.java | 37 -
.../header/GetAllTopicConfigResponseHeader.java | 35 -
.../header/GetBrokerConfigResponseHeader.java | 49 -
.../header/GetConsumeStatsInBrokerHeader.java | 41 -
.../header/GetConsumeStatsRequestHeader.java | 58 -
.../GetConsumerConnectionListRequestHeader.java | 50 -
.../GetConsumerListByGroupRequestHeader.java | 46 -
.../GetConsumerListByGroupResponseBody.java | 40 -
.../GetConsumerListByGroupResponseHeader.java | 32 -
.../GetConsumerRunningInfoRequestHeader.java | 71 -
.../header/GetConsumerStatusRequestHeader.java | 73 -
.../GetEarliestMsgStoretimeRequestHeader.java | 62 -
.../GetEarliestMsgStoretimeResponseHeader.java | 49 -
.../header/GetMaxOffsetRequestHeader.java | 61 -
.../header/GetMaxOffsetResponseHeader.java | 49 -
.../header/GetMinOffsetRequestHeader.java | 61 -
.../header/GetMinOffsetResponseHeader.java | 49 -
.../GetProducerConnectionListRequestHeader.java | 48 -
.../header/GetTopicStatsInfoRequestHeader.java | 47 -
.../header/GetTopicsByClusterRequestHeader.java | 47 -
.../NotifyConsumerIdsChangedRequestHeader.java | 46 -
.../header/PullMessageRequestHeader.java | 158 --
.../header/PullMessageResponseHeader.java | 85 -
.../QueryConsumeTimeSpanRequestHeader.java | 59 -
.../QueryConsumerOffsetRequestHeader.java | 73 -
.../QueryConsumerOffsetResponseHeader.java | 49 -
.../header/QueryCorrectionOffsetHeader.java | 75 -
.../header/QueryMessageRequestHeader.java | 98 -
.../header/QueryMessageResponseHeader.java | 61 -
.../QueryTopicConsumeByWhoRequestHeader.java | 50 -
.../header/ResetOffsetRequestHeader.java | 85 -
.../header/SearchOffsetRequestHeader.java | 76 -
.../header/SearchOffsetResponseHeader.java | 49 -
.../header/SendMessageRequestHeader.java | 181 --
.../header/SendMessageRequestHeaderV2.java | 212 --
.../header/SendMessageResponseHeader.java | 82 -
.../header/UnregisterClientRequestHeader.java | 77 -
.../header/UnregisterClientResponseHeader.java | 38 -
.../UpdateConsumerOffsetRequestHeader.java | 85 -
.../UpdateConsumerOffsetResponseHeader.java | 35 -
.../ViewBrokerStatsDataRequestHeader.java | 56 -
.../header/ViewMessageRequestHeader.java | 49 -
.../header/ViewMessageResponseHeader.java | 35 -
.../RegisterFilterServerRequestHeader.java | 43 -
.../RegisterFilterServerResponseHeader.java | 55 -
...RegisterMessageFilterClassRequestHeader.java | 79 -
.../namesrv/DeleteKVConfigRequestHeader.java | 59 -
.../DeleteTopicInNamesrvRequestHeader.java | 46 -
.../namesrv/GetKVConfigRequestHeader.java | 59 -
.../namesrv/GetKVConfigResponseHeader.java | 47 -
.../GetKVListByNamespaceRequestHeader.java | 47 -
.../namesrv/GetRouteInfoRequestHeader.java | 49 -
.../namesrv/GetRouteInfoResponseHeader.java | 37 -
.../namesrv/PutKVConfigRequestHeader.java | 67 -
.../namesrv/RegisterBrokerRequestHeader.java | 97 -
.../namesrv/RegisterBrokerResponseHeader.java | 59 -
.../RegisterOrderTopicRequestHeader.java | 62 -
.../namesrv/UnRegisterBrokerRequestHeader.java | 85 -
.../WipeWritePermOfBrokerRequestHeader.java | 47 -
.../WipeWritePermOfBrokerResponseHeader.java | 46 -
.../common/protocol/heartbeat/ConsumeType.java | 42 -
.../common/protocol/heartbeat/ConsumerData.java | 107 -
.../protocol/heartbeat/HeartbeatData.java | 73 -
.../common/protocol/heartbeat/MessageModel.java | 48 -
.../common/protocol/heartbeat/ProducerData.java | 44 -
.../protocol/heartbeat/SubscriptionData.java | 188 --
.../common/protocol/route/BrokerData.java | 113 -
.../common/protocol/route/QueueData.java | 118 --
.../common/protocol/route/TopicRouteData.java | 146 --
.../common/protocol/topic/OffsetMovedEvent.java | 76 -
.../common/queue/ConcurrentTreeMap.java | 81 -
.../rocketmq/common/queue/RoundQueue.java | 53 -
.../rocketmq/common/running/RunningStats.java | 25 -
.../rocketmq/common/stats/MomentStatsItem.java | 82 -
.../common/stats/MomentStatsItemSet.java | 94 -
.../rocketmq/common/stats/StatsItem.java | 272 ---
.../rocketmq/common/stats/StatsItemSet.java | 210 --
.../rocketmq/common/stats/StatsSnapshot.java | 54 -
.../subscription/SubscriptionGroupConfig.java | 194 --
.../rocketmq/common/sysflag/MessageSysFlag.java | 44 -
.../rocketmq/common/sysflag/PullSysFlag.java | 76 -
.../common/sysflag/SubscriptionSysFlag.java | 55 -
.../rocketmq/common/sysflag/TopicSysFlag.java | 79 -
.../rocketmq/common/utils/ChannelUtil.java | 35 -
.../rocketmq/common/utils/HttpTinyClient.java | 154 --
.../rocketmq/common/utils/IOTinyUtils.java | 167 --
.../apache/rocketmq/common/BrokerConfig.java | 549 +++++
.../rocketmq/common/BrokerConfigSingleton.java | 39 +
.../apache/rocketmq/common/ConfigManager.java | 89 +
.../apache/rocketmq/common/Configuration.java | 310 +++
.../apache/rocketmq/common/CountDownLatch.java | 207 ++
.../org/apache/rocketmq/common/DataVersion.java | 82 +
.../org/apache/rocketmq/common/MQVersion.java | 362 ++++
.../java/org/apache/rocketmq/common/MixAll.java | 486 +++++
.../java/org/apache/rocketmq/common/Pair.java | 51 +
.../apache/rocketmq/common/ServiceState.java | 39 +
.../apache/rocketmq/common/ServiceThread.java | 142 ++
.../org/apache/rocketmq/common/SystemClock.java | 26 +
.../rocketmq/common/ThreadFactoryImpl.java | 39 +
.../org/apache/rocketmq/common/TopicConfig.java | 206 ++
.../apache/rocketmq/common/TopicFilterType.java | 25 +
.../org/apache/rocketmq/common/UtilAll.java | 525 +++++
.../rocketmq/common/admin/ConsumeStats.java | 67 +
.../rocketmq/common/admin/OffsetWrapper.java | 59 +
.../rocketmq/common/admin/RollbackStats.java | 91 +
.../rocketmq/common/admin/TopicOffset.java | 58 +
.../rocketmq/common/admin/TopicStatsTable.java | 42 +
.../common/annotation/ImportantField.java | 29 +
.../common/constant/DBMsgConstants.java | 22 +
.../rocketmq/common/constant/LoggerName.java | 40 +
.../rocketmq/common/constant/PermName.java | 56 +
.../common/consumer/ConsumeFromWhere.java | 34 +
.../rocketmq/common/filter/FilterAPI.java | 72 +
.../rocketmq/common/filter/FilterContext.java | 32 +
.../rocketmq/common/filter/MessageFilter.java | 25 +
.../apache/rocketmq/common/filter/impl/Op.java | 38 +
.../rocketmq/common/filter/impl/Operand.java | 26 +
.../rocketmq/common/filter/impl/Operator.java | 71 +
.../rocketmq/common/filter/impl/PolishExpr.java | 189 ++
.../rocketmq/common/filter/impl/Type.java | 26 +
.../org/apache/rocketmq/common/help/FAQUrl.java | 101 +
.../rocketmq/common/hook/FilterCheckHook.java | 33 +
.../apache/rocketmq/common/message/Message.java | 212 ++
.../common/message/MessageAccessor.java | 104 +
.../common/message/MessageClientExt.java | 45 +
.../common/message/MessageClientIDSetter.java | 142 ++
.../rocketmq/common/message/MessageConst.java | 75 +
.../rocketmq/common/message/MessageDecoder.java | 395 ++++
.../rocketmq/common/message/MessageExt.java | 238 +++
.../rocketmq/common/message/MessageId.java | 54 +
.../rocketmq/common/message/MessageQueue.java | 134 ++
.../common/message/MessageQueueForC.java | 152 ++
.../rocketmq/common/message/MessageType.java | 25 +
.../rocketmq/common/namesrv/NamesrvConfig.java | 100 +
.../rocketmq/common/namesrv/NamesrvUtil.java | 25 +
.../common/namesrv/RegisterBrokerResult.java | 60 +
.../rocketmq/common/namesrv/TopAddressing.java | 115 +
.../common/protocol/MQProtosHelper.java | 57 +
.../rocketmq/common/protocol/RequestCode.java | 166 ++
.../rocketmq/common/protocol/ResponseCode.java | 77 +
.../common/protocol/body/BrokerStatsData.java | 60 +
.../common/protocol/body/BrokerStatsItem.java | 54 +
.../rocketmq/common/protocol/body/CMResult.java | 27 +
.../common/protocol/body/ClusterInfo.java | 76 +
.../common/protocol/body/Connection.java | 71 +
.../common/protocol/body/ConsumeByWho.java | 84 +
.../body/ConsumeMessageDirectlyResult.java | 87 +
.../common/protocol/body/ConsumeStatsList.java | 58 +
.../common/protocol/body/ConsumeStatus.java | 88 +
.../protocol/body/ConsumerConnection.java | 102 +
.../body/ConsumerOffsetSerializeWrapper.java | 41 +
.../protocol/body/ConsumerRunningInfo.java | 315 +++
.../protocol/body/GetConsumerStatusBody.java | 55 +
.../common/protocol/body/GroupList.java | 40 +
.../rocketmq/common/protocol/body/KVTable.java | 40 +
.../protocol/body/LockBatchRequestBody.java | 65 +
.../protocol/body/LockBatchResponseBody.java | 45 +
.../common/protocol/body/ProcessQueueInfo.java | 185 ++
.../protocol/body/ProducerConnection.java | 40 +
.../protocol/body/QueryConsumeTimeSpanBody.java | 41 +
.../body/QueryCorrectionOffsetBody.java | 40 +
.../common/protocol/body/QueueTimeSpan.java | 100 +
.../protocol/body/RegisterBrokerBody.java | 49 +
.../common/protocol/body/ResetOffsetBody.java | 42 +
.../protocol/body/ResetOffsetBodyForC.java | 38 +
.../protocol/body/SubscriptionGroupWrapper.java | 55 +
.../body/TopicConfigSerializeWrapper.java | 51 +
.../common/protocol/body/TopicList.java | 51 +
.../protocol/body/UnlockBatchRequestBody.java | 64 +
.../CheckTransactionStateRequestHeader.java | 79 +
.../CheckTransactionStateResponseHeader.java | 97 +
.../header/CloneGroupOffsetRequestHeader.java | 84 +
...nsumeMessageDirectlyResultRequestHeader.java | 80 +
.../ConsumerSendMsgBackRequestHeader.java | 125 ++
.../header/CreateTopicRequestHeader.java | 143 ++
.../DeleteSubscriptionGroupRequestHeader.java | 46 +
.../header/DeleteTopicRequestHeader.java | 49 +
.../header/EndTransactionRequestHeader.java | 145 ++
.../header/EndTransactionResponseHeader.java | 37 +
.../header/GetAllTopicConfigResponseHeader.java | 35 +
.../header/GetBrokerConfigResponseHeader.java | 49 +
.../header/GetConsumeStatsInBrokerHeader.java | 41 +
.../header/GetConsumeStatsRequestHeader.java | 58 +
.../GetConsumerConnectionListRequestHeader.java | 50 +
.../GetConsumerListByGroupRequestHeader.java | 46 +
.../GetConsumerListByGroupResponseBody.java | 40 +
.../GetConsumerListByGroupResponseHeader.java | 32 +
.../GetConsumerRunningInfoRequestHeader.java | 71 +
.../header/GetConsumerStatusRequestHeader.java | 73 +
.../GetEarliestMsgStoretimeRequestHeader.java | 62 +
.../GetEarliestMsgStoretimeResponseHeader.java | 49 +
.../header/GetMaxOffsetRequestHeader.java | 61 +
.../header/GetMaxOffsetResponseHeader.java | 49 +
.../header/GetMinOffsetRequestHeader.java | 61 +
.../header/GetMinOffsetResponseHeader.java | 49 +
.../GetProducerConnectionListRequestHeader.java | 48 +
.../header/GetTopicStatsInfoRequestHeader.java | 47 +
.../header/GetTopicsByClusterRequestHeader.java | 47 +
.../NotifyConsumerIdsChangedRequestHeader.java | 46 +
.../header/PullMessageRequestHeader.java | 158 ++
.../header/PullMessageResponseHeader.java | 85 +
.../QueryConsumeTimeSpanRequestHeader.java | 59 +
.../QueryConsumerOffsetRequestHeader.java | 73 +
.../QueryConsumerOffsetResponseHeader.java | 49 +
.../header/QueryCorrectionOffsetHeader.java | 75 +
.../header/QueryMessageRequestHeader.java | 98 +
.../header/QueryMessageResponseHeader.java | 61 +
.../QueryTopicConsumeByWhoRequestHeader.java | 50 +
.../header/ResetOffsetRequestHeader.java | 85 +
.../header/SearchOffsetRequestHeader.java | 76 +
.../header/SearchOffsetResponseHeader.java | 49 +
.../header/SendMessageRequestHeader.java | 181 ++
.../header/SendMessageRequestHeaderV2.java | 212 ++
.../header/SendMessageResponseHeader.java | 82 +
.../header/UnregisterClientRequestHeader.java | 77 +
.../header/UnregisterClientResponseHeader.java | 38 +
.../UpdateConsumerOffsetRequestHeader.java | 85 +
.../UpdateConsumerOffsetResponseHeader.java | 35 +
.../ViewBrokerStatsDataRequestHeader.java | 56 +
.../header/ViewMessageRequestHeader.java | 49 +
.../header/ViewMessageResponseHeader.java | 35 +
.../RegisterFilterServerRequestHeader.java | 43 +
.../RegisterFilterServerResponseHeader.java | 55 +
...RegisterMessageFilterClassRequestHeader.java | 79 +
.../namesrv/DeleteKVConfigRequestHeader.java | 59 +
.../DeleteTopicInNamesrvRequestHeader.java | 46 +
.../namesrv/GetKVConfigRequestHeader.java | 59 +
.../namesrv/GetKVConfigResponseHeader.java | 47 +
.../GetKVListByNamespaceRequestHeader.java | 47 +
.../namesrv/GetRouteInfoRequestHeader.java | 49 +
.../namesrv/GetRouteInfoResponseHeader.java | 37 +
.../namesrv/PutKVConfigRequestHeader.java | 67 +
.../namesrv/RegisterBrokerRequestHeader.java | 97 +
.../namesrv/RegisterBrokerResponseHeader.java | 59 +
.../RegisterOrderTopicRequestHeader.java | 62 +
.../namesrv/UnRegisterBrokerRequestHeader.java | 85 +
.../WipeWritePermOfBrokerRequestHeader.java | 47 +
.../WipeWritePermOfBrokerResponseHeader.java | 46 +
.../common/protocol/heartbeat/ConsumeType.java | 42 +
.../common/protocol/heartbeat/ConsumerData.java | 107 +
.../protocol/heartbeat/HeartbeatData.java | 73 +
.../common/protocol/heartbeat/MessageModel.java | 48 +
.../common/protocol/heartbeat/ProducerData.java | 44 +
.../protocol/heartbeat/SubscriptionData.java | 188 ++
.../common/protocol/route/BrokerData.java | 113 +
.../common/protocol/route/QueueData.java | 118 ++
.../common/protocol/route/TopicRouteData.java | 146 ++
.../common/protocol/topic/OffsetMovedEvent.java | 76 +
.../common/queue/ConcurrentTreeMap.java | 81 +
.../rocketmq/common/queue/RoundQueue.java | 53 +
.../rocketmq/common/running/RunningStats.java | 25 +
.../rocketmq/common/stats/MomentStatsItem.java | 82 +
.../common/stats/MomentStatsItemSet.java | 94 +
.../apache/rocketmq/common/stats/StatsItem.java | 272 +++
.../rocketmq/common/stats/StatsItemSet.java | 210 ++
.../rocketmq/common/stats/StatsSnapshot.java | 54 +
.../subscription/SubscriptionGroupConfig.java | 194 ++
.../rocketmq/common/sysflag/MessageSysFlag.java | 44 +
.../rocketmq/common/sysflag/PullSysFlag.java | 76 +
.../common/sysflag/SubscriptionSysFlag.java | 55 +
.../rocketmq/common/sysflag/TopicSysFlag.java | 79 +
.../rocketmq/common/utils/ChannelUtil.java | 35 +
.../rocketmq/common/utils/HttpTinyClient.java | 154 ++
.../rocketmq/common/utils/IOTinyUtils.java | 167 ++
.../com/alibaba/rocketmq/common/MixAllTest.java | 39 -
.../rocketmq/common/RemotingUtilTest.java | 29 -
.../alibaba/rocketmq/common/UtilAllTest.java | 164 --
.../rocketmq/common/filter/FilterAPITest.java | 46 -
.../rocketmq/common/filter/PolishExprTest.java | 67 -
.../common/protocol/ConsumeStatusTest.java | 36 -
.../common/protocol/MQProtosHelperTest.java | 25 -
.../org/apache/rocketmq/common/MixAllTest.java | 39 +
.../rocketmq/common/RemotingUtilTest.java | 29 +
.../org/apache/rocketmq/common/UtilAllTest.java | 164 ++
.../rocketmq/common/filter/FilterAPITest.java | 46 +
.../rocketmq/common/filter/PolishExprTest.java | 67 +
.../common/protocol/ConsumeStatusTest.java | 36 +
.../common/protocol/MQProtosHelperTest.java | 25 +
example/pom.xml | 2 +-
.../rocketmq/example/benchmark/Consumer.java | 214 --
.../rocketmq/example/benchmark/Producer.java | 262 ---
.../example/benchmark/TransactionProducer.java | 265 ---
.../example/broadcast/PushConsumer.java | 54 -
.../rocketmq/example/filter/Consumer.java | 53 -
.../rocketmq/example/filter/Producer.java | 46 -
.../rocketmq/example/operation/Consumer.java | 114 -
.../rocketmq/example/operation/Producer.java | 104 -
.../rocketmq/example/ordermessage/Consumer.java | 67 -
.../rocketmq/example/ordermessage/Producer.java | 68 -
.../rocketmq/example/quickstart/Consumer.java | 51 -
.../rocketmq/example/quickstart/Producer.java | 53 -
.../rocketmq/example/simple/AsyncProducer.java | 61 -
.../rocketmq/example/simple/CachedQueue.java | 32 -
.../rocketmq/example/simple/Producer.java | 50 -
.../rocketmq/example/simple/PullConsumer.java | 80 -
.../example/simple/PullConsumerTest.java | 47 -
.../example/simple/PullScheduleService.java | 72 -
.../rocketmq/example/simple/PushConsumer.java | 50 -
.../example/simple/RandomAsyncCommit.java | 60 -
.../rocketmq/example/simple/TestProducer.java | 54 -
.../TransactionCheckListenerImpl.java | 45 -
.../transaction/TransactionExecuterImpl.java | 43 -
.../transaction/TransactionProducer.java | 61 -
.../rocketmq/example/benchmark/Consumer.java | 214 ++
.../rocketmq/example/benchmark/Producer.java | 262 +++
.../example/benchmark/TransactionProducer.java | 265 +++
.../example/broadcast/PushConsumer.java | 54 +
.../rocketmq/example/filter/Consumer.java | 53 +
.../rocketmq/example/filter/Producer.java | 46 +
.../rocketmq/example/operation/Consumer.java | 114 +
.../rocketmq/example/operation/Producer.java | 104 +
.../rocketmq/example/ordermessage/Consumer.java | 67 +
.../rocketmq/example/ordermessage/Producer.java | 68 +
.../rocketmq/example/quickstart/Consumer.java | 51 +
.../rocketmq/example/quickstart/Producer.java | 53 +
.../rocketmq/example/simple/AsyncProducer.java | 61 +
.../rocketmq/example/simple/CachedQueue.java | 32 +
.../rocketmq/example/simple/Producer.java | 50 +
.../rocketmq/example/simple/PullConsumer.java | 80 +
.../example/simple/PullConsumerTest.java | 47 +
.../example/simple/PullScheduleService.java | 72 +
.../rocketmq/example/simple/PushConsumer.java | 50 +
.../example/simple/RandomAsyncCommit.java | 60 +
.../rocketmq/example/simple/TestProducer.java | 54 +
.../TransactionCheckListenerImpl.java | 45 +
.../transaction/TransactionExecuterImpl.java | 43 +
.../transaction/TransactionProducer.java | 61 +
.../src/main/resources/MessageFilterImpl.java | 6 +-
filtersrv/pom.xml | 2 +-
.../filtersrv/FilterServerOuterAPI.java | 82 -
.../rocketmq/filtersrv/FiltersrvConfig.java | 158 --
.../rocketmq/filtersrv/FiltersrvController.java | 226 --
.../rocketmq/filtersrv/FiltersrvStartup.java | 183 --
.../rocketmq/filtersrv/filter/DynaCode.java | 393 ----
.../filter/FilterClassFetchMethod.java | 22 -
.../filtersrv/filter/FilterClassInfo.java | 57 -
.../filtersrv/filter/FilterClassLoader.java | 24 -
.../filtersrv/filter/FilterClassManager.java | 175 --
.../filter/HttpFilterClassFetchMethod.java | 53 -
.../processor/DefaultRequestProcessor.java | 355 ----
.../stats/FilterServerStatsManager.java | 65 -
.../filtersrv/FilterServerOuterAPI.java | 82 +
.../rocketmq/filtersrv/FiltersrvConfig.java | 158 ++
.../rocketmq/filtersrv/FiltersrvController.java | 226 ++
.../rocketmq/filtersrv/FiltersrvStartup.java | 183 ++
.../rocketmq/filtersrv/filter/DynaCode.java | 393 ++++
.../filter/FilterClassFetchMethod.java | 22 +
.../filtersrv/filter/FilterClassInfo.java | 57 +
.../filtersrv/filter/FilterClassLoader.java | 24 +
.../filtersrv/filter/FilterClassManager.java | 175 ++
.../filter/HttpFilterClassFetchMethod.java | 53 +
.../processor/DefaultRequestProcessor.java | 355 ++++
.../stats/FilterServerStatsManager.java | 65 +
namesrv/pom.xml | 6 +-
.../rocketmq/namesrv/NamesrvController.java | 167 --
.../rocketmq/namesrv/NamesrvStartup.java | 184 --
.../namesrv/kvconfig/KVConfigManager.java | 203 --
.../kvconfig/KVConfigSerializeWrapper.java | 39 -
.../processor/ClusterTestRequestProcessor.java | 91 -
.../processor/DefaultRequestProcessor.java | 491 -----
.../routeinfo/BrokerHousekeepingService.java | 61 -
.../namesrv/routeinfo/RouteInfoManager.java | 815 -------
.../rocketmq/namesrv/NamesrvController.java | 167 ++
.../apache/rocketmq/namesrv/NamesrvStartup.java | 184 ++
.../namesrv/kvconfig/KVConfigManager.java | 203 ++
.../kvconfig/KVConfigSerializeWrapper.java | 39 +
.../processor/ClusterTestRequestProcessor.java | 91 +
.../processor/DefaultRequestProcessor.java | 491 +++++
.../routeinfo/BrokerHousekeepingService.java | 61 +
.../namesrv/routeinfo/RouteInfoManager.java | 815 +++++++
pom.xml | 18 +-
release-client.xml | 2 +-
release.xml | 12 +-
remoting/pom.xml | 2 +-
.../rocketmq/remoting/ChannelEventListener.java | 37 -
.../rocketmq/remoting/CommandCustomHeader.java | 27 -
.../rocketmq/remoting/InvokeCallback.java | 28 -
.../com/alibaba/rocketmq/remoting/RPCHook.java | 29 -
.../rocketmq/remoting/RemotingClient.java | 62 -
.../rocketmq/remoting/RemotingServer.java | 63 -
.../rocketmq/remoting/RemotingService.java | 28 -
.../rocketmq/remoting/annotation/CFNotNull.java | 32 -
.../remoting/annotation/CFNullable.java | 32 -
.../alibaba/rocketmq/remoting/common/Pair.java | 51 -
.../remoting/common/RemotingHelper.java | 212 --
.../rocketmq/remoting/common/RemotingUtil.java | 215 --
.../common/SemaphoreReleaseOnlyOnce.java | 48 -
.../rocketmq/remoting/common/ServiceThread.java | 141 --
.../exception/RemotingCommandException.java | 34 -
.../exception/RemotingConnectException.java | 34 -
.../remoting/exception/RemotingException.java | 34 -
.../exception/RemotingSendRequestException.java | 34 -
.../exception/RemotingTimeoutException.java | 40 -
.../RemotingTooMuchRequestException.java | 29 -
.../remoting/netty/NettyClientConfig.java | 151 --
.../rocketmq/remoting/netty/NettyDecoder.java | 69 -
.../rocketmq/remoting/netty/NettyEncoder.java | 56 -
.../rocketmq/remoting/netty/NettyEvent.java | 57 -
.../rocketmq/remoting/netty/NettyEventType.java | 28 -
.../remoting/netty/NettyRemotingAbstract.java | 457 ----
.../remoting/netty/NettyRemotingClient.java | 682 ------
.../remoting/netty/NettyRemotingServer.java | 384 ----
.../remoting/netty/NettyRequestProcessor.java | 33 -
.../remoting/netty/NettyServerConfig.java | 161 --
.../remoting/netty/NettySystemConfig.java | 42 -
.../rocketmq/remoting/netty/RequestTask.java | 83 -
.../rocketmq/remoting/netty/ResponseFuture.java | 146 --
.../remoting/protocol/LanguageCode.java | 49 -
.../remoting/protocol/RemotingCommand.java | 569 -----
.../remoting/protocol/RemotingCommandType.java | 26 -
.../remoting/protocol/RemotingSerializable.java | 67 -
.../protocol/RemotingSysResponseCode.java | 31 -
.../remoting/protocol/RocketMQSerializable.java | 214 --
.../remoting/protocol/SerializeType.java | 42 -
.../remoting/protocol/protocol.sevialize.txt | 21 -
.../rocketmq/remoting/protocol/protocol.txt | 21 -
.../rocketmq/remoting/ChannelEventListener.java | 37 +
.../rocketmq/remoting/CommandCustomHeader.java | 27 +
.../rocketmq/remoting/InvokeCallback.java | 28 +
.../org/apache/rocketmq/remoting/RPCHook.java | 29 +
.../rocketmq/remoting/RemotingClient.java | 62 +
.../rocketmq/remoting/RemotingServer.java | 63 +
.../rocketmq/remoting/RemotingService.java | 28 +
.../rocketmq/remoting/annotation/CFNotNull.java | 32 +
.../remoting/annotation/CFNullable.java | 32 +
.../apache/rocketmq/remoting/common/Pair.java | 51 +
.../remoting/common/RemotingHelper.java | 212 ++
.../rocketmq/remoting/common/RemotingUtil.java | 215 ++
.../common/SemaphoreReleaseOnlyOnce.java | 48 +
.../rocketmq/remoting/common/ServiceThread.java | 141 ++
.../exception/RemotingCommandException.java | 34 +
.../exception/RemotingConnectException.java | 34 +
.../remoting/exception/RemotingException.java | 34 +
.../exception/RemotingSendRequestException.java | 34 +
.../exception/RemotingTimeoutException.java | 40 +
.../RemotingTooMuchRequestException.java | 29 +
.../remoting/netty/NettyClientConfig.java | 151 ++
.../rocketmq/remoting/netty/NettyDecoder.java | 69 +
.../rocketmq/remoting/netty/NettyEncoder.java | 56 +
.../rocketmq/remoting/netty/NettyEvent.java | 57 +
.../rocketmq/remoting/netty/NettyEventType.java | 28 +
.../remoting/netty/NettyRemotingAbstract.java | 457 ++++
.../remoting/netty/NettyRemotingClient.java | 682 ++++++
.../remoting/netty/NettyRemotingServer.java | 384 ++++
.../remoting/netty/NettyRequestProcessor.java | 33 +
.../remoting/netty/NettyServerConfig.java | 161 ++
.../remoting/netty/NettySystemConfig.java | 42 +
.../rocketmq/remoting/netty/RequestTask.java | 83 +
.../rocketmq/remoting/netty/ResponseFuture.java | 146 ++
.../remoting/protocol/LanguageCode.java | 49 +
.../remoting/protocol/RemotingCommand.java | 569 +++++
.../remoting/protocol/RemotingCommandType.java | 26 +
.../remoting/protocol/RemotingSerializable.java | 67 +
.../protocol/RemotingSysResponseCode.java | 31 +
.../remoting/protocol/RocketMQSerializable.java | 214 ++
.../remoting/protocol/SerializeType.java | 42 +
.../remoting/protocol/protocol.sevialize.txt | 21 +
.../rocketmq/remoting/protocol/protocol.txt | 21 +
.../rocketmq/remoting/ExceptionTest.java | 94 -
.../com/alibaba/rocketmq/remoting/MixTest.java | 34 -
.../rocketmq/remoting/NettyConnectionTest.java | 113 -
.../rocketmq/remoting/NettyIdleTest.java | 91 -
.../alibaba/rocketmq/remoting/NettyRPCTest.java | 253 ---
.../rocketmq/remoting/SyncInvokeTest.java | 54 -
.../rocketmq/subclass/TestSubClassAuto.java | 34 -
.../apache/rocketmq/remoting/ExceptionTest.java | 94 +
.../org/apache/rocketmq/remoting/MixTest.java | 34 +
.../rocketmq/remoting/NettyConnectionTest.java | 109 +
.../apache/rocketmq/remoting/NettyIdleTest.java | 91 +
.../apache/rocketmq/remoting/NettyRPCTest.java | 253 +++
.../rocketmq/remoting/SyncInvokeTest.java | 54 +
.../rocketmq/subclass/TestSubClassAuto.java | 34 +
srvutil/pom.xml | 2 +-
.../alibaba/rocketmq/srvutil/ServerUtil.java | 83 -
.../org/apache/rocketmq/srvutil/ServerUtil.java | 83 +
store/pom.xml | 2 +-
.../store/AllocateMappedFileService.java | 342 ---
.../rocketmq/store/AppendMessageCallback.java | 41 -
.../rocketmq/store/AppendMessageResult.java | 138 --
.../rocketmq/store/AppendMessageStatus.java | 31 -
.../com/alibaba/rocketmq/store/CommitLog.java | 1296 ------------
.../alibaba/rocketmq/store/ConsumeQueue.java | 495 -----
.../rocketmq/store/DefaultMessageFilter.java | 47 -
.../rocketmq/store/DefaultMessageStore.java | 1748 ---------------
.../alibaba/rocketmq/store/DispatchRequest.java | 174 --
.../rocketmq/store/GetMessageResult.java | 158 --
.../rocketmq/store/GetMessageStatus.java | 41 -
.../com/alibaba/rocketmq/store/MappedFile.java | 591 ------
.../alibaba/rocketmq/store/MappedFileQueue.java | 614 ------
.../rocketmq/store/MessageArrivingListener.java | 22 -
.../rocketmq/store/MessageExtBrokerInner.java | 57 -
.../alibaba/rocketmq/store/MessageFilter.java | 27 -
.../alibaba/rocketmq/store/MessageStore.java | 135 --
.../rocketmq/store/PutMessageResult.java | 64 -
.../rocketmq/store/PutMessageStatus.java | 33 -
.../rocketmq/store/QueryMessageResult.java | 81 -
.../rocketmq/store/ReferenceResource.java | 87 -
.../alibaba/rocketmq/store/RunningFlags.java | 139 --
.../store/SelectMappedBufferResult.java | 84 -
.../alibaba/rocketmq/store/StoreCheckpoint.java | 141 --
.../rocketmq/store/StoreStatsService.java | 615 ------
.../com/alibaba/rocketmq/store/StoreUtil.java | 41 -
.../rocketmq/store/TransientStorePool.java | 93 -
.../rocketmq/store/config/BrokerRole.java | 26 -
.../rocketmq/store/config/FlushDiskType.java | 25 -
.../store/config/MessageStoreConfig.java | 727 -------
.../store/config/StorePathConfigHelper.java | 58 -
.../alibaba/rocketmq/store/ha/HAConnection.java | 429 ----
.../alibaba/rocketmq/store/ha/HAService.java | 669 ------
.../rocketmq/store/ha/WaitNotifyObject.java | 101 -
.../alibaba/rocketmq/store/index/IndexFile.java | 289 ---
.../rocketmq/store/index/IndexHeader.java | 141 --
.../rocketmq/store/index/IndexService.java | 392 ----
.../rocketmq/store/index/QueryOffsetResult.java | 52 -
.../schedule/DelayOffsetSerializeWrapper.java | 41 -
.../store/schedule/ScheduleMessageService.java | 386 ----
.../rocketmq/store/stats/BrokerStats.java | 111 -
.../store/stats/BrokerStatsManager.java | 220 --
.../com/alibaba/rocketmq/store/util/LibC.java | 54 -
.../store/AllocateMappedFileService.java | 342 +++
.../rocketmq/store/AppendMessageCallback.java | 41 +
.../rocketmq/store/AppendMessageResult.java | 138 ++
.../rocketmq/store/AppendMessageStatus.java | 31 +
.../org/apache/rocketmq/store/CommitLog.java | 1296 ++++++++++++
.../org/apache/rocketmq/store/ConsumeQueue.java | 495 +++++
.../rocketmq/store/DefaultMessageFilter.java | 47 +
.../rocketmq/store/DefaultMessageStore.java | 1748 +++++++++++++++
.../apache/rocketmq/store/DispatchRequest.java | 174 ++
.../apache/rocketmq/store/GetMessageResult.java | 158 ++
.../apache/rocketmq/store/GetMessageStatus.java | 41 +
.../org/apache/rocketmq/store/MappedFile.java | 591 ++++++
.../apache/rocketmq/store/MappedFileQueue.java | 614 ++++++
.../rocketmq/store/MessageArrivingListener.java | 22 +
.../rocketmq/store/MessageExtBrokerInner.java | 57 +
.../apache/rocketmq/store/MessageFilter.java | 27 +
.../org/apache/rocketmq/store/MessageStore.java | 135 ++
.../apache/rocketmq/store/PutMessageResult.java | 64 +
.../apache/rocketmq/store/PutMessageStatus.java | 33 +
.../rocketmq/store/QueryMessageResult.java | 81 +
.../rocketmq/store/ReferenceResource.java | 87 +
.../org/apache/rocketmq/store/RunningFlags.java | 139 ++
.../store/SelectMappedBufferResult.java | 84 +
.../apache/rocketmq/store/StoreCheckpoint.java | 141 ++
.../rocketmq/store/StoreStatsService.java | 615 ++++++
.../org/apache/rocketmq/store/StoreUtil.java | 41 +
.../rocketmq/store/TransientStorePool.java | 93 +
.../rocketmq/store/config/BrokerRole.java | 26 +
.../rocketmq/store/config/FlushDiskType.java | 25 +
.../store/config/MessageStoreConfig.java | 727 +++++++
.../store/config/StorePathConfigHelper.java | 58 +
.../apache/rocketmq/store/ha/HAConnection.java | 429 ++++
.../org/apache/rocketmq/store/ha/HAService.java | 669 ++++++
.../rocketmq/store/ha/WaitNotifyObject.java | 101 +
.../apache/rocketmq/store/index/IndexFile.java | 289 +++
.../rocketmq/store/index/IndexHeader.java | 141 ++
.../rocketmq/store/index/IndexService.java | 392 ++++
.../rocketmq/store/index/QueryOffsetResult.java | 52 +
.../schedule/DelayOffsetSerializeWrapper.java | 41 +
.../store/schedule/ScheduleMessageService.java | 386 ++++
.../rocketmq/store/stats/BrokerStats.java | 111 +
.../store/stats/BrokerStatsManager.java | 220 ++
.../org/apache/rocketmq/store/util/LibC.java | 54 +
.../rocketmq/store/DefaultMessageStoreTest.java | 164 --
.../rocketmq/store/MappedFileQueueTest.java | 199 --
.../alibaba/rocketmq/store/MappedFileTest.java | 89 -
.../com/alibaba/rocketmq/store/RecoverTest.java | 213 --
.../rocketmq/store/StoreCheckpointTest.java | 58 -
.../rocketmq/store/index/IndexFileTest.java | 73 -
.../store/schedule/ScheduleMessageTest.java | 135 --
.../rocketmq/store/DefaultMessageStoreTest.java | 164 ++
.../rocketmq/store/MappedFileQueueTest.java | 199 ++
.../apache/rocketmq/store/MappedFileTest.java | 89 +
.../org/apache/rocketmq/store/RecoverTest.java | 213 ++
.../rocketmq/store/StoreCheckpointTest.java | 58 +
.../rocketmq/store/index/IndexFileTest.java | 73 +
.../store/schedule/ScheduleMessageTest.java | 136 ++
store/src/test/resources/logback-test.xml | 2 +-
tools/pom.xml | 2 +-
.../rocketmq/tools/admin/DefaultMQAdminExt.java | 458 ----
.../tools/admin/DefaultMQAdminExtImpl.java | 933 --------
.../rocketmq/tools/admin/MQAdminExt.java | 229 --
.../rocketmq/tools/admin/api/MessageTrack.java | 61 -
.../rocketmq/tools/admin/api/TrackType.java | 27 -
.../rocketmq/tools/command/CommandUtil.java | 157 --
.../rocketmq/tools/command/MQAdminStartup.java | 219 --
.../rocketmq/tools/command/SubCommand.java | 38 -
.../broker/BrokerConsumeStatsSubCommad.java | 143 --
.../command/broker/BrokerStatusSubCommand.java | 117 -
.../broker/CleanExpiredCQSubCommand.java | 84 -
.../command/broker/CleanUnusedTopicCommand.java | 84 -
.../command/broker/GetBrokerConfigCommand.java | 132 --
.../command/broker/SendMsgStatusCommand.java | 104 -
.../broker/UpdateBrokerConfigSubCommand.java | 117 -
.../cluster/CLusterSendMsgRTCommand.java | 211 --
.../command/cluster/ClusterListSubCommand.java | 280 ---
.../ConsumerConnectionSubCommand.java | 106 -
.../ProducerConnectionSubCommand.java | 88 -
.../consumer/ConsumerProgressSubCommand.java | 285 ---
.../consumer/ConsumerStatusSubCommand.java | 143 --
.../command/consumer/ConsumerSubCommand.java | 142 --
.../DeleteSubscriptionGroupCommand.java | 113 -
.../consumer/StartMonitoringSubCommand.java | 67 -
.../consumer/UpdateSubGroupSubCommand.java | 196 --
.../command/message/CheckMsgSendRTCommand.java | 135 --
.../command/message/DecodeMessageIdCommond.java | 63 -
.../message/PrintMessageByQueueCommand.java | 259 ---
.../command/message/PrintMessageSubCommand.java | 177 --
.../command/message/QueryMsgByIdSubCommand.java | 294 ---
.../message/QueryMsgByKeySubCommand.java | 91 -
.../message/QueryMsgByOffsetSubCommand.java | 109 -
.../message/QueryMsgByUniqueKeySubCommand.java | 211 --
.../rocketmq/tools/command/message/Store.java | 271 ---
.../command/namesrv/DeleteKvConfigCommand.java | 78 -
.../namesrv/GetNamesrvConfigCommand.java | 85 -
.../command/namesrv/UpdateKvConfigCommand.java | 84 -
.../namesrv/UpdateNamesrvConfigCommand.java | 94 -
.../namesrv/WipeWritePermSubCommand.java | 86 -
.../command/offset/CloneGroupOffsetCommand.java | 104 -
.../offset/GetConsumerStatusCommand.java | 101 -
.../offset/ResetOffsetByTimeCommand.java | 147 --
.../offset/ResetOffsetByTimeOldCommand.java | 136 --
.../tools/command/stats/StatsAllSubCommand.java | 208 --
.../command/topic/AllocateMQSubCommand.java | 100 -
.../command/topic/DeleteTopicSubCommand.java | 112 -
.../tools/command/topic/RebalanceResult.java | 36 -
.../command/topic/TopicClusterSubCommand.java | 73 -
.../command/topic/TopicListSubCommand.java | 142 --
.../command/topic/TopicRouteSubCommand.java | 76 -
.../command/topic/TopicStatusSubCommand.java | 108 -
.../command/topic/UpdateOrderConfCommand.java | 115 -
.../topic/UpdateTopicPermSubCommand.java | 123 --
.../command/topic/UpdateTopicSubCommand.java | 193 --
.../tools/monitor/DefaultMonitorListener.java | 97 -
.../rocketmq/tools/monitor/DeleteMsgsEvent.java | 53 -
.../rocketmq/tools/monitor/FailedMsgs.java | 61 -
.../rocketmq/tools/monitor/MonitorConfig.java | 48 -
.../rocketmq/tools/monitor/MonitorListener.java | 36 -
.../rocketmq/tools/monitor/MonitorService.java | 325 ---
.../rocketmq/tools/monitor/UndoneMsgs.java | 87 -
.../rocketmq/tools/admin/DefaultMQAdminExt.java | 458 ++++
.../tools/admin/DefaultMQAdminExtImpl.java | 933 ++++++++
.../apache/rocketmq/tools/admin/MQAdminExt.java | 229 ++
.../rocketmq/tools/admin/api/MessageTrack.java | 61 +
.../rocketmq/tools/admin/api/TrackType.java | 27 +
.../rocketmq/tools/command/CommandUtil.java | 157 ++
.../rocketmq/tools/command/MQAdminStartup.java | 219 ++
.../rocketmq/tools/command/SubCommand.java | 38 +
.../broker/BrokerConsumeStatsSubCommad.java | 143 ++
.../command/broker/BrokerStatusSubCommand.java | 117 +
.../broker/CleanExpiredCQSubCommand.java | 84 +
.../command/broker/CleanUnusedTopicCommand.java | 84 +
.../command/broker/GetBrokerConfigCommand.java | 132 ++
.../command/broker/SendMsgStatusCommand.java | 104 +
.../broker/UpdateBrokerConfigSubCommand.java | 117 +
.../cluster/CLusterSendMsgRTCommand.java | 211 ++
.../command/cluster/ClusterListSubCommand.java | 280 +++
.../ConsumerConnectionSubCommand.java | 106 +
.../ProducerConnectionSubCommand.java | 88 +
.../consumer/ConsumerProgressSubCommand.java | 285 +++
.../consumer/ConsumerStatusSubCommand.java | 143 ++
.../command/consumer/ConsumerSubCommand.java | 142 ++
.../DeleteSubscriptionGroupCommand.java | 113 +
.../consumer/StartMonitoringSubCommand.java | 67 +
.../consumer/UpdateSubGroupSubCommand.java | 196 ++
.../command/message/CheckMsgSendRTCommand.java | 135 ++
.../command/message/DecodeMessageIdCommond.java | 63 +
.../message/PrintMessageByQueueCommand.java | 259 +++
.../command/message/PrintMessageSubCommand.java | 177 ++
.../command/message/QueryMsgByIdSubCommand.java | 294 +++
.../message/QueryMsgByKeySubCommand.java | 91 +
.../message/QueryMsgByOffsetSubCommand.java | 109 +
.../message/QueryMsgByUniqueKeySubCommand.java | 211 ++
.../rocketmq/tools/command/message/Store.java | 271 +++
.../command/namesrv/DeleteKvConfigCommand.java | 78 +
.../namesrv/GetNamesrvConfigCommand.java | 85 +
.../command/namesrv/UpdateKvConfigCommand.java | 84 +
.../namesrv/UpdateNamesrvConfigCommand.java | 94 +
.../namesrv/WipeWritePermSubCommand.java | 86 +
.../command/offset/CloneGroupOffsetCommand.java | 104 +
.../offset/GetConsumerStatusCommand.java | 101 +
.../offset/ResetOffsetByTimeCommand.java | 147 ++
.../offset/ResetOffsetByTimeOldCommand.java | 136 ++
.../tools/command/stats/StatsAllSubCommand.java | 208 ++
.../command/topic/AllocateMQSubCommand.java | 100 +
.../command/topic/DeleteTopicSubCommand.java | 112 +
.../tools/command/topic/RebalanceResult.java | 36 +
.../command/topic/TopicClusterSubCommand.java | 73 +
.../command/topic/TopicListSubCommand.java | 142 ++
.../command/topic/TopicRouteSubCommand.java | 76 +
.../command/topic/TopicStatusSubCommand.java | 108 +
.../command/topic/UpdateOrderConfCommand.java | 115 +
.../topic/UpdateTopicPermSubCommand.java | 123 ++
.../command/topic/UpdateTopicSubCommand.java | 193 ++
.../tools/monitor/DefaultMonitorListener.java | 97 +
.../rocketmq/tools/monitor/DeleteMsgsEvent.java | 53 +
.../rocketmq/tools/monitor/FailedMsgs.java | 61 +
.../rocketmq/tools/monitor/MonitorConfig.java | 48 +
.../rocketmq/tools/monitor/MonitorListener.java | 36 +
.../rocketmq/tools/monitor/MonitorService.java | 325 +++
.../rocketmq/tools/monitor/UndoneMsgs.java | 87 +
1107 files changed, 74986 insertions(+), 74988 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 31687a2..7b1157b 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
## RocketMQ [![Build Status](https://travis-ci.org/apache/incubator-rocketmq.svg?branch=master)](https://travis-ci.org/apache/incubator-rocketmq)
-[![Maven Central](https://img.shields.io/badge/maven--center-stable--version-green.svg)](http://search.maven.org/#search%7Cga%7C1%7Ccom.alibaba.rocketmq)
-[![GitHub release](https://img.shields.io/badge/release-download-orange.svg)](https://github.com/alibaba/RocketMQ/releases)
+[![Maven Central](https://img.shields.io/badge/maven--center-stable--version-green.svg)](http://search.maven.org/#search%7Cga%7C1%7Corg.apache.rocketmq)
+[![GitHub release](https://img.shields.io/badge/release-download-orange.svg)](https://github.org/apache/rocketmqreleases)
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
**RocketMQ is a low latency, reliable, scalable, easy to use message oriented middleware born from alibaba massive messaging business.**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/benchmark/consumer.sh
----------------------------------------------------------------------
diff --git a/benchmark/consumer.sh b/benchmark/consumer.sh
index 0ba054e..8cbbbd9 100644
--- a/benchmark/consumer.sh
+++ b/benchmark/consumer.sh
@@ -18,4 +18,4 @@
#
# $Id: consumer.sh 1831 2013-05-16 01:39:51Z shijia.wxr $
#
-sh ./runclass.sh com.alibaba.rocketmq.example.benchmark.Consumer $@ &
+sh ./runclass.sh org.apache.rocketmq.example.benchmark.Consumer $@ &
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/benchmark/producer.sh
----------------------------------------------------------------------
diff --git a/benchmark/producer.sh b/benchmark/producer.sh
index 16552fd..4eb5ca7 100644
--- a/benchmark/producer.sh
+++ b/benchmark/producer.sh
@@ -17,4 +17,4 @@
#
# $Id: producer.sh 1831 2013-05-16 01:39:51Z shijia.wxr $
#
-sh ./runclass.sh -Dcom.alibaba.rocketmq.client.sendSmartMsg=true com.alibaba.rocketmq.example.benchmark.Producer $@ &
+sh ./runclass.sh -Dorg.apache.rocketmq.client.sendSmartMsg=true org.apache.rocketmq.example.benchmark.Producer $@ &
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/benchmark/tproducer.sh
----------------------------------------------------------------------
diff --git a/benchmark/tproducer.sh b/benchmark/tproducer.sh
index 4aca55c..bf64802 100644
--- a/benchmark/tproducer.sh
+++ b/benchmark/tproducer.sh
@@ -17,4 +17,4 @@
#
# $Id: producer.sh 1831 2013-05-16 01:39:51Z shijia.wxr $
#
-sh ./runclass.sh com.alibaba.rocketmq.example.benchmark.TransactionProducer $@
+sh ./runclass.sh org.apache.rocketmq.example.benchmark.TransactionProducer $@
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/bin/mqadmin
----------------------------------------------------------------------
diff --git a/bin/mqadmin b/bin/mqadmin
index 616dc6d..1acd3e0 100644
--- a/bin/mqadmin
+++ b/bin/mqadmin
@@ -42,4 +42,4 @@ fi
export ROCKETMQ_HOME
-sh ${ROCKETMQ_HOME}/bin/tools.sh com.alibaba.rocketmq.tools.command.MQAdminStartup $@
+sh ${ROCKETMQ_HOME}/bin/tools.sh org.apache.rocketmq.tools.command.MQAdminStartup $@
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/bin/mqadmin.xml
----------------------------------------------------------------------
diff --git a/bin/mqadmin.xml b/bin/mqadmin.xml
index 3f01808..9c4f5ac 100644
--- a/bin/mqadmin.xml
+++ b/bin/mqadmin.xml
@@ -22,7 +22,7 @@
<jvmtype>server</jvmtype>
- <mainclass>com.alibaba.rocketmq.tools.command.MQAdminStartup</mainclass>
+ <mainclass>org.apache.rocketmq.tools.command.MQAdminStartup</mainclass>
<properties>
<java.ext.dirs>${cpd}/../lib</java.ext.dirs>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/bin/mqbroker
----------------------------------------------------------------------
diff --git a/bin/mqbroker b/bin/mqbroker
index d474254..99234e2 100644
--- a/bin/mqbroker
+++ b/bin/mqbroker
@@ -44,4 +44,4 @@ export ROCKETMQ_HOME
rm -f $HOME/rmq_bk_gc.log.bac
cp $HOME/rmq_bk_gc.log $HOME/rmq_bk_gc.log.bac
-sh ${ROCKETMQ_HOME}/bin/runbroker.sh com.alibaba.rocketmq.broker.BrokerStartup $@
+sh ${ROCKETMQ_HOME}/bin/runbroker.sh org.apache.rocketmq.broker.BrokerStartup $@
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/bin/mqbroker.xml
----------------------------------------------------------------------
diff --git a/bin/mqbroker.xml b/bin/mqbroker.xml
index f0254d3..289da61 100644
--- a/bin/mqbroker.xml
+++ b/bin/mqbroker.xml
@@ -22,7 +22,7 @@
<jvmtype>server</jvmtype>
- <mainclass>com.alibaba.rocketmq.broker.BrokerStartup</mainclass>
+ <mainclass>org.apache.rocketmq.broker.BrokerStartup</mainclass>
<properties>
<java.ext.dirs>${cpd}/../lib</java.ext.dirs>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/bin/mqfiltersrv
----------------------------------------------------------------------
diff --git a/bin/mqfiltersrv b/bin/mqfiltersrv
index 69fc635..ff83a7a 100644
--- a/bin/mqfiltersrv
+++ b/bin/mqfiltersrv
@@ -42,4 +42,4 @@ fi
export ROCKETMQ_HOME
-sh ${ROCKETMQ_HOME}/bin/runserver.sh com.alibaba.rocketmq.filtersrv.FiltersrvStartup $@
+sh ${ROCKETMQ_HOME}/bin/runserver.sh org.apache.rocketmq.filtersrv.FiltersrvStartup $@
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/bin/mqfiltersrv.xml
----------------------------------------------------------------------
diff --git a/bin/mqfiltersrv.xml b/bin/mqfiltersrv.xml
index 0e391d2..105ea26 100644
--- a/bin/mqfiltersrv.xml
+++ b/bin/mqfiltersrv.xml
@@ -22,7 +22,7 @@
<jvmtype>server</jvmtype>
- <mainclass>com.alibaba.rocketmq.filtersrv.FiltersrvStartup</mainclass>
+ <mainclass>org.apache.rocketmq.filtersrv.FiltersrvStartup</mainclass>
<properties>
<java.ext.dirs>${cpd}/../lib</java.ext.dirs>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/bin/mqnamesrv
----------------------------------------------------------------------
diff --git a/bin/mqnamesrv b/bin/mqnamesrv
index ed7cd1e..94ec8f2 100644
--- a/bin/mqnamesrv
+++ b/bin/mqnamesrv
@@ -42,4 +42,4 @@ fi
export ROCKETMQ_HOME
-sh ${ROCKETMQ_HOME}/bin/runserver.sh com.alibaba.rocketmq.namesrv.NamesrvStartup $@
+sh ${ROCKETMQ_HOME}/bin/runserver.sh org.apache.rocketmq.namesrv.NamesrvStartup $@
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/bin/mqnamesrv.xml
----------------------------------------------------------------------
diff --git a/bin/mqnamesrv.xml b/bin/mqnamesrv.xml
index 9194cbb..8ea3102 100644
--- a/bin/mqnamesrv.xml
+++ b/bin/mqnamesrv.xml
@@ -22,7 +22,7 @@
<jvmtype>server</jvmtype>
- <mainclass>com.alibaba.rocketmq.namesrv.NamesrvStartup</mainclass>
+ <mainclass>org.apache.rocketmq.namesrv.NamesrvStartup</mainclass>
<properties>
<java.ext.dirs>${cpd}/../lib</java.ext.dirs>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/bin/mqshutdown
----------------------------------------------------------------------
diff --git a/bin/mqshutdown b/bin/mqshutdown
index 19561ac..5f1a174 100644
--- a/bin/mqshutdown
+++ b/bin/mqshutdown
@@ -18,7 +18,7 @@
case $1 in
broker)
- pid=`ps ax | grep -i 'com.alibaba.rocketmq.broker.BrokerStartup' |grep java | grep -v grep | awk '{print $1}'`
+ pid=`ps ax | grep -i 'org.apache.rocketmq.broker.BrokerStartup' |grep java | grep -v grep | awk '{print $1}'`
if [ -z "$pid" ] ; then
echo "No mqbroker running."
exit -1;
@@ -32,7 +32,7 @@ case $1 in
;;
namesrv)
- pid=`ps ax | grep -i 'com.alibaba.rocketmq.namesrv.NamesrvStartup' |grep java | grep -v grep | awk '{print $1}'`
+ pid=`ps ax | grep -i 'org.apache.rocketmq.namesrv.NamesrvStartup' |grep java | grep -v grep | awk '{print $1}'`
if [ -z "$pid" ] ; then
echo "No mqnamesrv running."
exit -1;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/bin/startfsrv.sh
----------------------------------------------------------------------
diff --git a/bin/startfsrv.sh b/bin/startfsrv.sh
index 21c828c..7ce7d71 100755
--- a/bin/startfsrv.sh
+++ b/bin/startfsrv.sh
@@ -42,4 +42,4 @@ fi
export ROCKETMQ_HOME
-nohup sh ${ROCKETMQ_HOME}/bin/runserver.sh com.alibaba.rocketmq.filtersrv.FiltersrvStartup $@ &
+nohup sh ${ROCKETMQ_HOME}/bin/runserver.sh org.apache.rocketmq.filtersrv.FiltersrvStartup $@ &
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/pom.xml
----------------------------------------------------------------------
diff --git a/broker/pom.xml b/broker/pom.xml
index fbbf0ee..0917503 100644
--- a/broker/pom.xml
+++ b/broker/pom.xml
@@ -18,7 +18,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.rocketmq</groupId>
+ <groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-all</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>
[11/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java b/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
new file mode 100644
index 0000000..1405299
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
@@ -0,0 +1,67 @@
+/**
+ * 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.common.admin;
+
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+
+/**
+ *
+ * @author shijia.wxr
+ *
+ */
+public class ConsumeStats extends RemotingSerializable {
+ private HashMap<MessageQueue, OffsetWrapper> offsetTable = new HashMap<MessageQueue, OffsetWrapper>();
+ private double consumeTps = 0;
+
+
+ public long computeTotalDiff() {
+ long diffTotal = 0L;
+
+ Iterator<Entry<MessageQueue, OffsetWrapper>> it = this.offsetTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<MessageQueue, OffsetWrapper> next = it.next();
+ long diff = next.getValue().getBrokerOffset() - next.getValue().getConsumerOffset();
+ diffTotal += diff;
+ }
+
+ return diffTotal;
+ }
+
+
+ public HashMap<MessageQueue, OffsetWrapper> getOffsetTable() {
+ return offsetTable;
+ }
+
+
+ public void setOffsetTable(HashMap<MessageQueue, OffsetWrapper> offsetTable) {
+ this.offsetTable = offsetTable;
+ }
+
+ public double getConsumeTps() {
+ return consumeTps;
+ }
+
+ public void setConsumeTps(double consumeTps) {
+ this.consumeTps = consumeTps;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java b/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
new file mode 100644
index 0000000..00bab0e
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
@@ -0,0 +1,59 @@
+/**
+ * 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.common.admin;
+
+/**
+ *
+ * @author shijia.wxr
+ *
+ */
+public class OffsetWrapper {
+ private long brokerOffset;
+ private long consumerOffset;
+
+ private long lastTimestamp;
+
+
+ public long getBrokerOffset() {
+ return brokerOffset;
+ }
+
+
+ public void setBrokerOffset(long brokerOffset) {
+ this.brokerOffset = brokerOffset;
+ }
+
+
+ public long getConsumerOffset() {
+ return consumerOffset;
+ }
+
+
+ public void setConsumerOffset(long consumerOffset) {
+ this.consumerOffset = consumerOffset;
+ }
+
+
+ public long getLastTimestamp() {
+ return lastTimestamp;
+ }
+
+
+ public void setLastTimestamp(long lastTimestamp) {
+ this.lastTimestamp = lastTimestamp;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/admin/RollbackStats.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/RollbackStats.java b/common/src/main/java/org/apache/rocketmq/common/admin/RollbackStats.java
new file mode 100644
index 0000000..5709327
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/RollbackStats.java
@@ -0,0 +1,91 @@
+/**
+ * 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.common.admin;
+
+/**
+ *
+ * @author manhong.yqd
+ */
+public class RollbackStats {
+ private String brokerName;
+ private long queueId;
+ private long brokerOffset;
+ private long consumerOffset;
+ private long timestampOffset;
+ private long rollbackOffset;
+
+
+ public String getBrokerName() {
+ return brokerName;
+ }
+
+
+ public void setBrokerName(String brokerName) {
+ this.brokerName = brokerName;
+ }
+
+
+ public long getQueueId() {
+ return queueId;
+ }
+
+
+ public void setQueueId(long queueId) {
+ this.queueId = queueId;
+ }
+
+
+ public long getBrokerOffset() {
+ return brokerOffset;
+ }
+
+
+ public void setBrokerOffset(long brokerOffset) {
+ this.brokerOffset = brokerOffset;
+ }
+
+
+ public long getConsumerOffset() {
+ return consumerOffset;
+ }
+
+
+ public void setConsumerOffset(long consumerOffset) {
+ this.consumerOffset = consumerOffset;
+ }
+
+
+ public long getTimestampOffset() {
+ return timestampOffset;
+ }
+
+
+ public void setTimestampOffset(long timestampOffset) {
+ this.timestampOffset = timestampOffset;
+ }
+
+
+ public long getRollbackOffset() {
+ return rollbackOffset;
+ }
+
+
+ public void setRollbackOffset(long rollbackOffset) {
+ this.rollbackOffset = rollbackOffset;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java b/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
new file mode 100644
index 0000000..d1b36a5
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
@@ -0,0 +1,58 @@
+/**
+ * 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.common.admin;
+
+/**
+ *
+ * @author shijia.wxr
+ *
+ */
+public class TopicOffset {
+ private long minOffset;
+ private long maxOffset;
+ private long lastUpdateTimestamp;
+
+
+ public long getMinOffset() {
+ return minOffset;
+ }
+
+
+ public void setMinOffset(long minOffset) {
+ this.minOffset = minOffset;
+ }
+
+
+ public long getMaxOffset() {
+ return maxOffset;
+ }
+
+
+ public void setMaxOffset(long maxOffset) {
+ this.maxOffset = maxOffset;
+ }
+
+
+ public long getLastUpdateTimestamp() {
+ return lastUpdateTimestamp;
+ }
+
+
+ public void setLastUpdateTimestamp(long lastUpdateTimestamp) {
+ this.lastUpdateTimestamp = lastUpdateTimestamp;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java b/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
new file mode 100644
index 0000000..d8f7e0a
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
@@ -0,0 +1,42 @@
+/**
+ * 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.common.admin;
+
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.HashMap;
+
+
+/**
+ *
+ * @author shijia.wxr
+ *
+ */
+public class TopicStatsTable extends RemotingSerializable {
+ private HashMap<MessageQueue, TopicOffset> offsetTable = new HashMap<MessageQueue, TopicOffset>();
+
+
+ public HashMap<MessageQueue, TopicOffset> getOffsetTable() {
+ return offsetTable;
+ }
+
+
+ public void setOffsetTable(HashMap<MessageQueue, TopicOffset> offsetTable) {
+ this.offsetTable = offsetTable;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/annotation/ImportantField.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/annotation/ImportantField.java b/common/src/main/java/org/apache/rocketmq/common/annotation/ImportantField.java
new file mode 100644
index 0000000..952e08e
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/annotation/ImportantField.java
@@ -0,0 +1,29 @@
+/**
+ * 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.common.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE})
+public @interface ImportantField {
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/constant/DBMsgConstants.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/constant/DBMsgConstants.java b/common/src/main/java/org/apache/rocketmq/common/constant/DBMsgConstants.java
new file mode 100644
index 0000000..298a427
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/constant/DBMsgConstants.java
@@ -0,0 +1,22 @@
+/**
+ * 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.common.constant;
+
+public class DBMsgConstants {
+ public static final int MAX_BODY_SIZE = 64 * 1024 * 1204; //64KB
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java b/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java
new file mode 100644
index 0000000..1942dc8
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java
@@ -0,0 +1,40 @@
+/**
+ * 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.common.constant;
+
+/**
+ * @author shijia.wxr
+ */
+public class LoggerName {
+ public static final String FILTERSRV_LOGGER_NAME = "RocketmqFiltersrv";
+ public static final String NAMESRV_LOGGER_NAME = "RocketmqNamesrv";
+ public static final String BROKER_LOGGER_NAME = "RocketmqBroker";
+ public static final String CLIENT_LOGGER_NAME = "RocketmqClient";
+ public static final String TOOLS_LOGGER_NAME = "RocketmqTools";
+ public static final String COMMON_LOGGER_NAME = "RocketmqCommon";
+ public static final String STORE_LOGGER_NAME = "RocketmqStore";
+ public static final String STORE_ERROR_LOGGER_NAME = "RocketmqStoreError";
+ public static final String TRANSACTION_LOGGER_NAME = "RocketmqTransaction";
+ public static final String REBALANCE_LOCK_LOGGER_NAME = "RocketmqRebalanceLock";
+ public static final String ROCKETMQ_STATS_LOGGER_NAME = "RocketmqStats";
+ public static final String COMMERCIAL_LOGGER_NAME = "RocketmqCommercial";
+ public static final String FLOW_CONTROL_LOGGER_NAME = "RocketmqFlowControl";
+ public static final String ROCKETMQ_AUTHORIZE_LOGGER_NAME = "RocketmqAuthorize";
+ public static final String DUPLICATION_LOGGER_NAME = "RocketmqDuplication";
+ public static final String PROTECTION_LOGGER_NAME = "RocketmqProtection";
+ public static final String WATER_MARK_LOGGER_NAME = "RocketmqWaterMark";
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java b/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java
new file mode 100644
index 0000000..ed379ec
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java
@@ -0,0 +1,56 @@
+/**
+ * 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.common.constant;
+
+/**
+ * @author shijia.wxr
+ */
+public class PermName {
+ public static final int PERM_PRIORITY = 0x1 << 3;
+ public static final int PERM_READ = 0x1 << 2;
+ public static final int PERM_WRITE = 0x1 << 1;
+ public static final int PERM_INHERIT = 0x1 << 0;
+
+ public static String perm2String(final int perm) {
+ final StringBuffer sb = new StringBuffer("---");
+ if (isReadable(perm)) {
+ sb.replace(0, 1, "R");
+ }
+
+ if (isWriteable(perm)) {
+ sb.replace(1, 2, "W");
+ }
+
+ if (isInherited(perm)) {
+ sb.replace(2, 3, "X");
+ }
+
+ return sb.toString();
+ }
+
+ public static boolean isReadable(final int perm) {
+ return (perm & PERM_READ) == PERM_READ;
+ }
+
+ public static boolean isWriteable(final int perm) {
+ return (perm & PERM_WRITE) == PERM_WRITE;
+ }
+
+ public static boolean isInherited(final int perm) {
+ return (perm & PERM_INHERIT) == PERM_INHERIT;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java b/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java
new file mode 100644
index 0000000..db093a0
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java
@@ -0,0 +1,34 @@
+/**
+ * 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.common.consumer;
+
+/**
+ *
+ * @author shijia.wxr
+ */
+public enum ConsumeFromWhere {
+ CONSUME_FROM_LAST_OFFSET,
+
+ @Deprecated
+ CONSUME_FROM_LAST_OFFSET_AND_FROM_MIN_WHEN_BOOT_FIRST,
+ @Deprecated
+ CONSUME_FROM_MIN_OFFSET,
+ @Deprecated
+ CONSUME_FROM_MAX_OFFSET,
+ CONSUME_FROM_FIRST_OFFSET,
+ CONSUME_FROM_TIMESTAMP,
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.java b/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.java
new file mode 100644
index 0000000..fac48ea
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.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.rocketmq.common.filter;
+
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
+
+import java.net.URL;
+
+
+/**
+ * @author shijia.wxr
+ *
+ */
+public class FilterAPI {
+ public static URL classFile(final String className) {
+ final String javaSource = simpleClassName(className) + ".java";
+ URL url = FilterAPI.class.getClassLoader().getResource(javaSource);
+ return url;
+ }
+
+ public static String simpleClassName(final String className) {
+ String simple = className;
+ int index = className.lastIndexOf(".");
+ if (index >= 0) {
+ simple = className.substring(index + 1);
+ }
+
+ return simple;
+ }
+
+ public static SubscriptionData buildSubscriptionData(final String consumerGroup, String topic,
+ String subString) throws Exception {
+ SubscriptionData subscriptionData = new SubscriptionData();
+ subscriptionData.setTopic(topic);
+ subscriptionData.setSubString(subString);
+
+ if (null == subString || subString.equals(SubscriptionData.SUB_ALL) || subString.length() == 0) {
+ subscriptionData.setSubString(SubscriptionData.SUB_ALL);
+ } else {
+ String[] tags = subString.split("\\|\\|");
+ if (tags != null && tags.length > 0) {
+ for (String tag : tags) {
+ if (tag.length() > 0) {
+ String trimString = tag.trim();
+ if (trimString.length() > 0) {
+ subscriptionData.getTagsSet().add(trimString);
+ subscriptionData.getCodeSet().add(trimString.hashCode());
+ }
+ }
+ }
+ } else {
+ throw new Exception("subString split error");
+ }
+ }
+
+ return subscriptionData;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/filter/FilterContext.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/FilterContext.java b/common/src/main/java/org/apache/rocketmq/common/filter/FilterContext.java
new file mode 100644
index 0000000..e18fe48
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/FilterContext.java
@@ -0,0 +1,32 @@
+/**
+ * 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.common.filter;
+
+public class FilterContext {
+ private String consumerGroup;
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/filter/MessageFilter.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/MessageFilter.java b/common/src/main/java/org/apache/rocketmq/common/filter/MessageFilter.java
new file mode 100644
index 0000000..c20e737
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/MessageFilter.java
@@ -0,0 +1,25 @@
+/**
+ * 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.common.filter;
+
+import org.apache.rocketmq.common.message.MessageExt;
+
+
+public interface MessageFilter {
+ boolean match(final MessageExt msg, final FilterContext context);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/filter/impl/Op.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/impl/Op.java b/common/src/main/java/org/apache/rocketmq/common/filter/impl/Op.java
new file mode 100644
index 0000000..af54566
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/impl/Op.java
@@ -0,0 +1,38 @@
+/**
+ * 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.common.filter.impl;
+
+public abstract class Op {
+
+ private String symbol;
+
+
+ protected Op(String symbol) {
+ this.symbol = symbol;
+ }
+
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+
+ public String toString() {
+ return symbol;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/filter/impl/Operand.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/impl/Operand.java b/common/src/main/java/org/apache/rocketmq/common/filter/impl/Operand.java
new file mode 100644
index 0000000..ce21d90
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/impl/Operand.java
@@ -0,0 +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 org.apache.rocketmq.common.filter.impl;
+
+public class Operand extends Op {
+
+ public Operand(String symbol) {
+ super(symbol);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/filter/impl/Operator.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/impl/Operator.java b/common/src/main/java/org/apache/rocketmq/common/filter/impl/Operator.java
new file mode 100644
index 0000000..45bebf0
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/impl/Operator.java
@@ -0,0 +1,71 @@
+/**
+ * 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.common.filter.impl;
+
+public class Operator extends Op {
+
+ public static final Operator LEFTPARENTHESIS = new Operator("(", 30, false);
+ public static final Operator RIGHTPARENTHESIS = new Operator(")", 30, false);
+ public static final Operator AND = new Operator("&&", 20, true);
+ public static final Operator OR = new Operator("||", 15, true);
+
+ private int priority;
+ private boolean compareable;
+
+
+ private Operator(String symbol, int priority, boolean compareable) {
+ super(symbol);
+ this.priority = priority;
+ this.compareable = compareable;
+ }
+
+ public static Operator createOperator(String operator) {
+ if (LEFTPARENTHESIS.getSymbol().equals(operator))
+ return LEFTPARENTHESIS;
+ else if (RIGHTPARENTHESIS.getSymbol().equals(operator))
+ return RIGHTPARENTHESIS;
+ else if (AND.getSymbol().equals(operator))
+ return AND;
+ else if (OR.getSymbol().equals(operator))
+ return OR;
+ else
+ throw new IllegalArgumentException("unsupport operator " + operator);
+ }
+
+ public int getPriority() {
+ return priority;
+ }
+
+ public boolean isCompareable() {
+ return compareable;
+ }
+
+
+ public int compare(Operator operator) {
+ if (this.priority > operator.priority)
+ return 1;
+ else if (this.priority == operator.priority)
+ return 0;
+ else
+ return -1;
+ }
+
+ public boolean isSpecifiedOp(String operator) {
+ return this.getSymbol().equals(operator);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/filter/impl/PolishExpr.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/impl/PolishExpr.java b/common/src/main/java/org/apache/rocketmq/common/filter/impl/PolishExpr.java
new file mode 100644
index 0000000..73b51b6
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/impl/PolishExpr.java
@@ -0,0 +1,189 @@
+/**
+ * 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.common.filter.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+
+import static org.apache.rocketmq.common.filter.impl.Operator.LEFTPARENTHESIS;
+import static org.apache.rocketmq.common.filter.impl.Operator.RIGHTPARENTHESIS;
+import static org.apache.rocketmq.common.filter.impl.Operator.createOperator;
+
+public class PolishExpr {
+
+ public static List<Op> reversePolish(String expression) {
+ return reversePolish(participle(expression));
+ }
+
+ /**
+ * Shunting-yard algorithm <br/>
+ * http://en.wikipedia.org/wiki/Shunting_yard_algorithm
+ *
+ * @param tokens
+ * @return the compute result of Shunting-yard algorithm
+ */
+ public static List<Op> reversePolish(List<Op> tokens) {
+ List<Op> segments = new ArrayList<Op>();
+ Stack<Operator> operatorStack = new Stack<Operator>();
+
+ for (int i = 0; i < tokens.size(); i++) {
+ Op token = tokens.get(i);
+ if (isOperand(token)) {
+
+ segments.add(token);
+ } else if (isLeftParenthesis(token)) {
+
+ operatorStack.push((Operator) token);
+ } else if (isRightParenthesis(token)) {
+
+ Operator opNew = null;
+ while (!operatorStack.empty() && LEFTPARENTHESIS != (opNew = operatorStack.pop())) {
+ segments.add(opNew);
+ }
+ if (null == opNew || LEFTPARENTHESIS != opNew)
+ throw new IllegalArgumentException("mismatched parentheses");
+ } else if (isOperator(token)) {
+
+ Operator opNew = (Operator) token;
+ if (!operatorStack.empty()) {
+ Operator opOld = operatorStack.peek();
+ if (opOld.isCompareable() && opNew.compare(opOld) != 1) {
+ segments.add(operatorStack.pop());
+ }
+ }
+ operatorStack.push(opNew);
+ } else
+ throw new IllegalArgumentException("illegal token " + token);
+ }
+
+ while (!operatorStack.empty()) {
+ Operator operator = operatorStack.pop();
+ if (LEFTPARENTHESIS == operator || RIGHTPARENTHESIS == operator)
+ throw new IllegalArgumentException("mismatched parentheses " + operator);
+ segments.add(operator);
+ }
+
+ return segments;
+ }
+
+ /**
+ *
+ * @param expression
+ *
+ * @return
+ *
+ * @throws Exception
+ */
+ private static List<Op> participle(String expression) {
+ List<Op> segments = new ArrayList<Op>();
+
+ int size = expression.length();
+ int wordStartIndex = -1;
+ int wordLen = 0;
+ Type preType = Type.NULL;
+
+ for (int i = 0; i < size; i++) {
+ int chValue = (int) expression.charAt(i);
+
+ if ((97 <= chValue && chValue <= 122) || (65 <= chValue && chValue <= 90)
+ || (49 <= chValue && chValue <= 57) || 95 == chValue) {
+
+
+ if (Type.OPERATOR == preType || Type.SEPAERATOR == preType || Type.NULL == preType
+ || Type.PARENTHESIS == preType) {
+ if (Type.OPERATOR == preType) {
+ segments.add(createOperator(expression.substring(wordStartIndex, wordStartIndex
+ + wordLen)));
+ }
+ wordStartIndex = i;
+ wordLen = 0;
+ }
+ preType = Type.OPERAND;
+ wordLen++;
+ } else if (40 == chValue || 41 == chValue) {
+
+
+ if (Type.OPERATOR == preType) {
+ segments.add(createOperator(expression
+ .substring(wordStartIndex, wordStartIndex + wordLen)));
+ wordStartIndex = -1;
+ wordLen = 0;
+ } else if (Type.OPERAND == preType) {
+ segments.add(new Operand(expression.substring(wordStartIndex, wordStartIndex + wordLen)));
+ wordStartIndex = -1;
+ wordLen = 0;
+ }
+
+ preType = Type.PARENTHESIS;
+ segments.add(createOperator((char) chValue + ""));
+ } else if (38 == chValue || 124 == chValue) {
+
+ if (Type.OPERAND == preType || Type.SEPAERATOR == preType || Type.PARENTHESIS == preType) {
+ if (Type.OPERAND == preType) {
+ segments.add(new Operand(expression.substring(wordStartIndex, wordStartIndex
+ + wordLen)));
+ }
+ wordStartIndex = i;
+ wordLen = 0;
+ }
+ preType = Type.OPERATOR;
+ wordLen++;
+ } else if (32 == chValue || 9 == chValue) {
+
+
+ if (Type.OPERATOR == preType) {
+ segments.add(createOperator(expression
+ .substring(wordStartIndex, wordStartIndex + wordLen)));
+ wordStartIndex = -1;
+ wordLen = 0;
+ } else if (Type.OPERAND == preType) {
+ segments.add(new Operand(expression.substring(wordStartIndex, wordStartIndex + wordLen)));
+ wordStartIndex = -1;
+ wordLen = 0;
+ }
+ preType = Type.SEPAERATOR;
+ } else {
+
+ throw new IllegalArgumentException("illegal expression, at index " + i + " " + (char) chValue);
+ }
+
+ }
+
+ if (wordLen > 0) {
+ segments.add(new Operand(expression.substring(wordStartIndex, wordStartIndex + wordLen)));
+ }
+ return segments;
+ }
+
+ public static boolean isOperand(Op token) {
+ return token instanceof Operand;
+ }
+
+ public static boolean isLeftParenthesis(Op token) {
+ return token instanceof Operator && LEFTPARENTHESIS == (Operator) token;
+ }
+
+ public static boolean isRightParenthesis(Op token) {
+ return token instanceof Operator && RIGHTPARENTHESIS == (Operator) token;
+ }
+
+ public static boolean isOperator(Op token) {
+ return token instanceof Operator;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/filter/impl/Type.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/impl/Type.java b/common/src/main/java/org/apache/rocketmq/common/filter/impl/Type.java
new file mode 100644
index 0000000..834bde8
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/impl/Type.java
@@ -0,0 +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 org.apache.rocketmq.common.filter.impl;
+
+public enum Type {
+ NULL,
+ OPERAND,
+ OPERATOR,
+ PARENTHESIS,
+ SEPAERATOR;
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java b/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java
new file mode 100644
index 0000000..85bef76
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java
@@ -0,0 +1,101 @@
+/**
+ * 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.common.help;
+
+/**
+ * @author shijia.wxr
+ */
+public class FAQUrl {
+
+ public static final String APPLY_TOPIC_URL = //
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&topic_not_exist";
+
+
+ public static final String NAME_SERVER_ADDR_NOT_EXIST_URL = //
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&namesrv_not_exist";
+
+
+ public static final String GROUP_NAME_DUPLICATE_URL = //
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&group_duplicate";
+
+
+ public static final String CLIENT_PARAMETER_CHECK_URL = //
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions¶meter_check_failed";
+
+
+ public static final String SUBSCRIPTION_GROUP_NOT_EXIST = //
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&subGroup_not_exist";
+
+
+ public static final String CLIENT_SERVICE_NOT_OK = //
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&service_not_ok";
+
+ // FAQ: No route info of this topic, TopicABC
+ public static final String NO_TOPIC_ROUTE_INFO = //
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&topic_not_exist";
+
+
+ public static final String LOAD_JSON_EXCEPTION = //
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&load_json_exception";
+
+
+ public static final String SAME_GROUP_DIFFERENT_TOPIC = //
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&subscription_exception";
+
+
+ public static final String MQLIST_NOT_EXIST = //
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&queue_not_exist";
+
+ public static final String UNEXPECTED_EXCEPTION_URL = //
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&unexpected_exception";
+
+
+ public static final String SEND_MSG_FAILED = //
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&send_msg_failed";
+
+
+ public static final String UNKNOWN_HOST_EXCEPTION = //
+ "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&unknown_host";
+
+ private static final String TIP_STRING_BEGIN = "\nSee ";
+ private static final String TIP_STRING_END = " for further details.";
+
+
+ public static String suggestTodo(final String url) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(TIP_STRING_BEGIN);
+ sb.append(url);
+ sb.append(TIP_STRING_END);
+ return sb.toString();
+ }
+
+ public static String attachDefaultURL(final String errorMessage) {
+ if (errorMessage != null) {
+ int index = errorMessage.indexOf(TIP_STRING_BEGIN);
+ if (-1 == index) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(errorMessage);
+ sb.append("\n");
+ sb.append("For more information, please visit the url, ");
+ sb.append(UNEXPECTED_EXCEPTION_URL);
+ return sb.toString();
+ }
+ }
+
+ return errorMessage;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java b/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java
new file mode 100644
index 0000000..a99df6e
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java
@@ -0,0 +1,33 @@
+/**
+ * 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.common.hook;
+
+import java.nio.ByteBuffer;
+
+
+/**
+ *
+ * @author manhong.yqd
+ *
+ */
+public interface FilterCheckHook {
+ public String hookName();
+
+
+ public boolean isFilterMatched(final boolean isUnitMode, final ByteBuffer byteBuffer);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/message/Message.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/Message.java b/common/src/main/java/org/apache/rocketmq/common/message/Message.java
new file mode 100644
index 0000000..c2d2d85
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/message/Message.java
@@ -0,0 +1,212 @@
+/**
+ * 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.common.message;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ *
+ * @author shijia.wxr
+ *
+ */
+public class Message implements Serializable {
+ private static final long serialVersionUID = 8445773977080406428L;
+
+ private String topic;
+ private int flag;
+ private Map<String, String> properties;
+ private byte[] body;
+
+
+ public Message() {
+ }
+
+
+ public Message(String topic, byte[] body) {
+ this(topic, "", "", 0, body, true);
+ }
+
+
+ public Message(String topic, String tags, String keys, int flag, byte[] body, boolean waitStoreMsgOK) {
+ this.topic = topic;
+ this.flag = flag;
+ this.body = body;
+
+ if (tags != null && tags.length() > 0)
+ this.setTags(tags);
+
+ if (keys != null && keys.length() > 0)
+ this.setKeys(keys);
+
+ this.setWaitStoreMsgOK(waitStoreMsgOK);
+ }
+
+ public void setKeys(String keys) {
+ this.putProperty(MessageConst.PROPERTY_KEYS, keys);
+ }
+
+ void putProperty(final String name, final String value) {
+ if (null == this.properties) {
+ this.properties = new HashMap<String, String>();
+ }
+
+ this.properties.put(name, value);
+ }
+
+
+ public Message(String topic, String tags, byte[] body) {
+ this(topic, tags, "", 0, body, true);
+ }
+
+
+ public Message(String topic, String tags, String keys, byte[] body) {
+ this(topic, tags, keys, 0, body, true);
+ }
+
+ void clearProperty(final String name) {
+ if (null != this.properties) {
+ this.properties.remove(name);
+ }
+ }
+
+ public void putUserProperty(final String name, final String value) {
+ if (MessageConst.STRING_HASH_SET.contains(name)) {
+ throw new RuntimeException(String.format(
+ "The Property<%s> is used by system, input another please", name));
+ }
+ this.putProperty(name, value);
+ }
+
+ public String getUserProperty(final String name) {
+ return this.getProperty(name);
+ }
+
+ public String getProperty(final String name) {
+ if (null == this.properties) {
+ this.properties = new HashMap<String, String>();
+ }
+
+ return this.properties.get(name);
+ }
+
+ public String getTopic() {
+ return topic;
+ }
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+ public String getTags() {
+ return this.getProperty(MessageConst.PROPERTY_TAGS);
+ }
+
+ public void setTags(String tags) {
+ this.putProperty(MessageConst.PROPERTY_TAGS, tags);
+ }
+
+ public String getKeys() {
+ return this.getProperty(MessageConst.PROPERTY_KEYS);
+ }
+
+ public void setKeys(Collection<String> keys) {
+ StringBuffer sb = new StringBuffer();
+ for (String k : keys) {
+ sb.append(k);
+ sb.append(MessageConst.KEY_SEPARATOR);
+ }
+
+ this.setKeys(sb.toString().trim());
+ }
+
+
+ public int getDelayTimeLevel() {
+ String t = this.getProperty(MessageConst.PROPERTY_DELAY_TIME_LEVEL);
+ if (t != null) {
+ return Integer.parseInt(t);
+ }
+
+ return 0;
+ }
+
+
+ public void setDelayTimeLevel(int level) {
+ this.putProperty(MessageConst.PROPERTY_DELAY_TIME_LEVEL, String.valueOf(level));
+ }
+
+
+ public boolean isWaitStoreMsgOK() {
+ String result = this.getProperty(MessageConst.PROPERTY_WAIT_STORE_MSG_OK);
+ if (null == result)
+ return true;
+
+ return Boolean.parseBoolean(result);
+ }
+
+
+ public void setWaitStoreMsgOK(boolean waitStoreMsgOK) {
+ this.putProperty(MessageConst.PROPERTY_WAIT_STORE_MSG_OK, Boolean.toString(waitStoreMsgOK));
+ }
+
+
+ public int getFlag() {
+ return flag;
+ }
+
+
+ public void setFlag(int flag) {
+ this.flag = flag;
+ }
+
+
+ public byte[] getBody() {
+ return body;
+ }
+
+
+ public void setBody(byte[] body) {
+ this.body = body;
+ }
+
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+
+ void setProperties(Map<String, String> properties) {
+ this.properties = properties;
+ }
+
+ public String getBuyerId() {
+ return getProperty(MessageConst.PROPERTY_BUYER_ID);
+ }
+
+ public void setBuyerId(String buyerId) {
+ putProperty(MessageConst.PROPERTY_BUYER_ID, buyerId);
+ }
+
+ @Override
+ public String toString() {
+ return "Message [topic=" + topic + ", flag=" + flag + ", properties=" + properties + ", body="
+ + (body != null ? body.length : 0) + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/message/MessageAccessor.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageAccessor.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageAccessor.java
new file mode 100644
index 0000000..5cd0ba8
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageAccessor.java
@@ -0,0 +1,104 @@
+/**
+ * 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.common.message;
+
+import java.util.Map;
+
+
+public class MessageAccessor {
+
+ public static void clearProperty(final Message msg, final String name) {
+ msg.clearProperty(name);
+ }
+
+ public static void setProperties(final Message msg, Map<String, String> properties) {
+ msg.setProperties(properties);
+ }
+
+ public static void setTransferFlag(final Message msg, String unit) {
+ putProperty(msg, MessageConst.PROPERTY_TRANSFER_FLAG, unit);
+ }
+
+ public static void putProperty(final Message msg, final String name, final String value) {
+ msg.putProperty(name, value);
+ }
+
+ public static String getTransferFlag(final Message msg) {
+ return msg.getProperty(MessageConst.PROPERTY_TRANSFER_FLAG);
+ }
+
+
+ public static void setCorrectionFlag(final Message msg, String unit) {
+ putProperty(msg, MessageConst.PROPERTY_CORRECTION_FLAG, unit);
+ }
+
+
+ public static String getCorrectionFlag(final Message msg) {
+ return msg.getProperty(MessageConst.PROPERTY_CORRECTION_FLAG);
+ }
+
+
+ public static void setOriginMessageId(final Message msg, String originMessageId) {
+ putProperty(msg, MessageConst.PROPERTY_ORIGIN_MESSAGE_ID, originMessageId);
+ }
+
+
+ public static String getOriginMessageId(final Message msg) {
+ return msg.getProperty(MessageConst.PROPERTY_ORIGIN_MESSAGE_ID);
+ }
+
+
+ public static void setMQ2Flag(final Message msg, String flag) {
+ putProperty(msg, MessageConst.PROPERTY_MQ2_FLAG, flag);
+ }
+
+
+ public static String getMQ2Flag(final Message msg) {
+ return msg.getProperty(MessageConst.PROPERTY_MQ2_FLAG);
+ }
+
+
+ public static void setReconsumeTime(final Message msg, String reconsumeTimes) {
+ putProperty(msg, MessageConst.PROPERTY_RECONSUME_TIME, reconsumeTimes);
+ }
+
+
+ public static String getReconsumeTime(final Message msg) {
+ return msg.getProperty(MessageConst.PROPERTY_RECONSUME_TIME);
+ }
+
+
+ public static void setMaxReconsumeTimes(final Message msg, String maxReconsumeTimes) {
+ putProperty(msg, MessageConst.PROPERTY_MAX_RECONSUME_TIMES, maxReconsumeTimes);
+ }
+
+
+ public static String getMaxReconsumeTimes(final Message msg) {
+ return msg.getProperty(MessageConst.PROPERTY_MAX_RECONSUME_TIMES);
+ }
+
+ public static void setConsumeStartTimeStamp(final Message msg, String propertyConsumeStartTimeStamp) {
+ putProperty(msg, MessageConst.PROPERTY_CONSUME_START_TIMESTAMP, propertyConsumeStartTimeStamp);
+ }
+
+
+ public static String getConsumeStartTimeStamp(final Message msg) {
+ return msg.getProperty(MessageConst.PROPERTY_CONSUME_START_TIMESTAMP);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/message/MessageClientExt.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageClientExt.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageClientExt.java
new file mode 100644
index 0000000..90703ca
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageClientExt.java
@@ -0,0 +1,45 @@
+/**
+ * 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.common.message;
+
+public class MessageClientExt extends MessageExt {
+
+ public void setOffsetMsgId(String offsetMsgId) {
+ super.setMsgId(offsetMsgId);
+ }
+
+
+ public String getOffsetMsgId() {
+ return super.getMsgId();
+ }
+
+ public void setMsgId(String msgId) {
+ //DO NOTHING
+ //MessageClientIDSetter.setUniqID(this);
+ }
+
+ @Override
+ public String getMsgId() {
+ String uniqID = MessageClientIDSetter.getUniqID(this);
+ if (uniqID == null) {
+ return this.getOffsetMsgId();
+ }
+ else {
+ return uniqID;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/message/MessageClientIDSetter.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageClientIDSetter.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageClientIDSetter.java
new file mode 100644
index 0000000..1c3a1b7
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageClientIDSetter.java
@@ -0,0 +1,142 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.common.message;
+
+import org.apache.rocketmq.common.UtilAll;
+
+import java.nio.ByteBuffer;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class MessageClientIDSetter {
+ private static final String TOPIC_KEY_SPLITTER = "#";
+ private static final int LEN;
+ private static final String FIX_STRING;
+ private static final AtomicInteger COUNTER;
+ private static long startTime;
+ private static long nextStartTime;
+
+ static {
+ LEN = 4 + 2 + 4 + 4 + 2;
+ ByteBuffer tempBuffer = ByteBuffer.allocate(10);
+ tempBuffer.position(2);
+ tempBuffer.putInt(UtilAll.getPid());
+ tempBuffer.position(0);
+ try {
+ tempBuffer.put(UtilAll.getIP());
+ } catch (Exception e) {
+ tempBuffer.put(createFakeIP());
+ }
+ tempBuffer.position(6);
+ tempBuffer.putInt(MessageClientIDSetter.class.getClassLoader().hashCode()); //4
+ FIX_STRING = UtilAll.bytes2string(tempBuffer.array());
+ setStartTime(System.currentTimeMillis());
+ COUNTER = new AtomicInteger(0);
+ }
+
+ private synchronized static void setStartTime(long millis) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTimeInMillis(millis);
+ cal.set(Calendar.DAY_OF_MONTH, 1);
+ cal.set(Calendar.HOUR, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ startTime = cal.getTimeInMillis();
+ cal.add(Calendar.MONTH, 1);
+ nextStartTime = cal.getTimeInMillis();
+ }
+
+ public static Date getNearlyTimeFromID(String msgID) {
+ ByteBuffer buf = ByteBuffer.allocate(8);
+ byte[] bytes = UtilAll.string2bytes(msgID);
+ buf.put((byte) 0);
+ buf.put((byte) 0);
+ buf.put((byte) 0);
+ buf.put((byte) 0);
+ buf.put(bytes, 10, 4);
+ buf.position(0);
+ long spanMS = buf.getLong();
+ Calendar cal = Calendar.getInstance();
+ long now = cal.getTimeInMillis();
+ cal.set(Calendar.DAY_OF_MONTH, 1);
+ cal.set(Calendar.HOUR, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ long monStartTime = cal.getTimeInMillis();
+ if (monStartTime + spanMS >= now) {
+ cal.add(Calendar.MONTH, -1);
+ monStartTime = cal.getTimeInMillis();
+ }
+ cal.setTimeInMillis(monStartTime + spanMS);
+ return cal.getTime();
+ }
+
+ public static String getIPStrFromID(String msgID) {
+ byte[] ipBytes = getIPFromID(msgID);
+ return UtilAll.ipToIPv4Str(ipBytes);
+ }
+
+ public static byte[] getIPFromID(String msgID) {
+ byte[] result = new byte[4];
+ byte[] bytes = UtilAll.string2bytes(msgID);
+ System.arraycopy(bytes, 0, result, 0, 4);
+ return result;
+ }
+
+ public static String createUniqID() {
+ StringBuilder sb = new StringBuilder(LEN * 2);
+ sb.append(FIX_STRING);
+ sb.append(UtilAll.bytes2string(createUniqIDBuffer()));
+ return sb.toString();
+ }
+
+
+ private static byte[] createUniqIDBuffer() {
+ ByteBuffer buffer = ByteBuffer.allocate(4 + 2);
+ long current = System.currentTimeMillis();
+ if (current >= nextStartTime) {
+ setStartTime(current);
+ }
+ buffer.position(0);
+ buffer.putInt((int) (System.currentTimeMillis() - startTime));
+ buffer.putShort((short) COUNTER.getAndIncrement());
+ return buffer.array();
+ }
+
+ public static void setUniqID(final Message msg) {
+ if (msg.getProperty(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX) == null) {
+ msg.putProperty(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX, createUniqID());
+ }
+ }
+
+ public static String getUniqID(final Message msg) {
+ return msg.getProperty(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX);
+ }
+
+ public static byte[] createFakeIP() {
+ ByteBuffer bb = ByteBuffer.allocate(8);
+ bb.putLong(System.currentTimeMillis());
+ bb.position(4);
+ byte[] fakeIP = new byte[4];
+ bb.get(fakeIP);
+ return fakeIP;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/message/MessageConst.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageConst.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageConst.java
new file mode 100644
index 0000000..d65160b
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageConst.java
@@ -0,0 +1,75 @@
+/**
+ * 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.common.message;
+
+import java.util.HashSet;
+
+
+public class MessageConst {
+ public static final String PROPERTY_KEYS = "KEYS";
+ public static final String PROPERTY_TAGS = "TAGS";
+ public static final String PROPERTY_WAIT_STORE_MSG_OK = "WAIT";
+ public static final String PROPERTY_DELAY_TIME_LEVEL = "DELAY";
+ public static final String PROPERTY_RETRY_TOPIC = "RETRY_TOPIC";
+ public static final String PROPERTY_REAL_TOPIC = "REAL_TOPIC";
+ public static final String PROPERTY_REAL_QUEUE_ID = "REAL_QID";
+ public static final String PROPERTY_TRANSACTION_PREPARED = "TRAN_MSG";
+ public static final String PROPERTY_PRODUCER_GROUP = "PGROUP";
+ public static final String PROPERTY_MIN_OFFSET = "MIN_OFFSET";
+ public static final String PROPERTY_MAX_OFFSET = "MAX_OFFSET";
+ public static final String PROPERTY_BUYER_ID = "BUYER_ID";
+ public static final String PROPERTY_ORIGIN_MESSAGE_ID = "ORIGIN_MESSAGE_ID";
+ public static final String PROPERTY_TRANSFER_FLAG = "TRANSFER_FLAG";
+ public static final String PROPERTY_CORRECTION_FLAG = "CORRECTION_FLAG";
+ public static final String PROPERTY_MQ2_FLAG = "MQ2_FLAG";
+ public static final String PROPERTY_RECONSUME_TIME = "RECONSUME_TIME";
+ public static final String PROPERTY_MSG_REGION = "MSG_REGION";
+ public static final String PROPERTY_TRACE_SWITCH = "TRACE_ON";
+ public static final String PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX = "UNIQ_KEY";
+ public static final String PROPERTY_MAX_RECONSUME_TIMES = "MAX_RECONSUME_TIMES";
+ public static final String PROPERTY_CONSUME_START_TIMESTAMP = "CONSUME_START_TIME";
+
+ public static final String KEY_SEPARATOR = " ";
+
+ public static final HashSet<String> STRING_HASH_SET = new HashSet<String>();
+
+
+ static {
+ STRING_HASH_SET.add(PROPERTY_TRACE_SWITCH);
+ STRING_HASH_SET.add(PROPERTY_MSG_REGION);
+ STRING_HASH_SET.add(PROPERTY_KEYS);
+ STRING_HASH_SET.add(PROPERTY_TAGS);
+ STRING_HASH_SET.add(PROPERTY_WAIT_STORE_MSG_OK);
+ STRING_HASH_SET.add(PROPERTY_DELAY_TIME_LEVEL);
+ STRING_HASH_SET.add(PROPERTY_RETRY_TOPIC);
+ STRING_HASH_SET.add(PROPERTY_REAL_TOPIC);
+ STRING_HASH_SET.add(PROPERTY_REAL_QUEUE_ID);
+ STRING_HASH_SET.add(PROPERTY_TRANSACTION_PREPARED);
+ STRING_HASH_SET.add(PROPERTY_PRODUCER_GROUP);
+ STRING_HASH_SET.add(PROPERTY_MIN_OFFSET);
+ STRING_HASH_SET.add(PROPERTY_MAX_OFFSET);
+ STRING_HASH_SET.add(PROPERTY_BUYER_ID);
+ STRING_HASH_SET.add(PROPERTY_ORIGIN_MESSAGE_ID);
+ STRING_HASH_SET.add(PROPERTY_TRANSFER_FLAG);
+ STRING_HASH_SET.add(PROPERTY_CORRECTION_FLAG);
+ STRING_HASH_SET.add(PROPERTY_MQ2_FLAG);
+ STRING_HASH_SET.add(PROPERTY_RECONSUME_TIME);
+ STRING_HASH_SET.add(PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX);
+ STRING_HASH_SET.add(PROPERTY_MAX_RECONSUME_TIMES);
+ STRING_HASH_SET.add(PROPERTY_CONSUME_START_TIMESTAMP);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
new file mode 100644
index 0000000..4410171
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
@@ -0,0 +1,395 @@
+/**
+ * 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.common.message;
+
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.sysflag.MessageSysFlag;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.net.UnknownHostException;
+import java.nio.BufferUnderflowException;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class MessageDecoder {
+ public final static int MSG_ID_LENGTH = 8 + 8;
+
+ public final static Charset CHARSET_UTF8 = Charset.forName("UTF-8");
+ public final static int MESSAGE_MAGIC_CODE_POSTION = 4;
+ public final static int MESSAGE_FLAG_POSTION = 16;
+ public final static int MESSAGE_PHYSIC_OFFSET_POSTION = 28;
+ public final static int MESSAGE_STORE_TIMESTAMP_POSTION = 56;
+ public final static int MESSAGE_MAGIC_CODE = 0xAABBCCDD ^ 1880681586 + 8;
+
+
+ public static String createMessageId(final ByteBuffer input, final ByteBuffer addr, final long offset) {
+ input.flip();
+ input.limit(MessageDecoder.MSG_ID_LENGTH);
+
+ input.put(addr);
+ input.putLong(offset);
+
+ return UtilAll.bytes2string(input.array());
+ }
+
+
+ public static String createMessageId(SocketAddress socketAddress, long transactionIdhashCode) {
+ ByteBuffer byteBuffer = ByteBuffer.allocate(MessageDecoder.MSG_ID_LENGTH);
+ InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
+ byteBuffer.put(inetSocketAddress.getAddress().getAddress());
+ byteBuffer.putInt(inetSocketAddress.getPort());
+ byteBuffer.putLong(transactionIdhashCode);
+ byteBuffer.flip();
+ return UtilAll.bytes2string(byteBuffer.array());
+ }
+
+
+ public static MessageId decodeMessageId(final String msgId) throws UnknownHostException {
+ SocketAddress address;
+ long offset;
+
+
+ byte[] ip = UtilAll.string2bytes(msgId.substring(0, 8));
+ byte[] port = UtilAll.string2bytes(msgId.substring(8, 16));
+ ByteBuffer bb = ByteBuffer.wrap(port);
+ int portInt = bb.getInt(0);
+ address = new InetSocketAddress(InetAddress.getByAddress(ip), portInt);
+
+ // offset
+ byte[] data = UtilAll.string2bytes(msgId.substring(16, 32));
+ bb = ByteBuffer.wrap(data);
+ offset = bb.getLong(0);
+
+ return new MessageId(address, offset);
+ }
+
+
+ public static MessageExt decode(java.nio.ByteBuffer byteBuffer) {
+ return decode(byteBuffer, true, true, false);
+ }
+
+ public static MessageExt clientDecode(java.nio.ByteBuffer byteBuffer, final boolean readBody) {
+ return decode(byteBuffer, readBody, true, true);
+ }
+
+ public static MessageExt decode(java.nio.ByteBuffer byteBuffer, final boolean readBody) {
+ return decode(byteBuffer, readBody, true, false);
+ }
+
+
+ public static byte[] encode(MessageExt messageExt, boolean needCompress) throws Exception {
+ byte[] body = messageExt.getBody();
+ byte[] topics = messageExt.getTopic().getBytes(CHARSET_UTF8);
+ byte topicLen = (byte) topics.length;
+ String properties = messageProperties2String(messageExt.getProperties());
+ byte[] propertiesBytes = properties.getBytes(CHARSET_UTF8);
+ short propertiesLength = (short) propertiesBytes.length;
+ int sysFlag = messageExt.getSysFlag();
+ byte[] newBody = messageExt.getBody();
+ if (needCompress && (sysFlag & MessageSysFlag.COMPRESSED_FLAG) == MessageSysFlag.COMPRESSED_FLAG) {
+ newBody = UtilAll.compress(body, 5);
+ }
+ int bodyLength = newBody.length;
+ int storeSize = messageExt.getStoreSize();
+ ByteBuffer byteBuffer;
+ if (storeSize > 0) {
+ byteBuffer = ByteBuffer.allocate(storeSize);
+ } else {
+ storeSize = 4 // 1 TOTALSIZE
+ + 4 // 2 MAGICCODE
+ + 4 // 3 BODYCRC
+ + 4 // 4 QUEUEID
+ + 4 // 5 FLAG
+ + 8 // 6 QUEUEOFFSET
+ + 8 // 7 PHYSICALOFFSET
+ + 4 // 8 SYSFLAG
+ + 8 // 9 BORNTIMESTAMP
+ + 8 // 10 BORNHOST
+ + 8 // 11 STORETIMESTAMP
+ + 8 // 12 STOREHOSTADDRESS
+ + 4 // 13 RECONSUMETIMES
+ + 8 // 14 Prepared Transaction Offset
+ + 4 + bodyLength // 14 BODY
+ + 1 + topicLen // 15 TOPIC
+ + 2 + propertiesLength // 16 propertiesLength
+ + 0;
+ byteBuffer = ByteBuffer.allocate(storeSize);
+ }
+ // 1 TOTALSIZE
+ byteBuffer.putInt(storeSize);
+
+ // 2 MAGICCODE
+ byteBuffer.putInt(MESSAGE_MAGIC_CODE);
+
+ // 3 BODYCRC
+ int bodyCRC = messageExt.getBodyCRC();
+ byteBuffer.putInt(bodyCRC);
+
+ // 4 QUEUEID
+ int queueId = messageExt.getQueueId();
+ byteBuffer.putInt(queueId);
+
+ // 5 FLAG
+ int flag = messageExt.getFlag();
+ byteBuffer.putInt(flag);
+
+ // 6 QUEUEOFFSET
+ long queueOffset = messageExt.getQueueOffset();
+ byteBuffer.putLong(queueOffset);
+
+ // 7 PHYSICALOFFSET
+ long physicOffset = messageExt.getCommitLogOffset();
+ byteBuffer.putLong(physicOffset);
+
+ // 8 SYSFLAG
+ byteBuffer.putInt(sysFlag);
+
+ // 9 BORNTIMESTAMP
+ long bornTimeStamp = messageExt.getBornTimestamp();
+ byteBuffer.putLong(bornTimeStamp);
+
+ // 10 BORNHOST
+ InetSocketAddress bornHost = (InetSocketAddress) messageExt.getBornHost();
+ byteBuffer.put(bornHost.getAddress().getAddress());
+ byteBuffer.putInt(bornHost.getPort());
+
+ // 11 STORETIMESTAMP
+ long storeTimestamp = messageExt.getStoreTimestamp();
+ byteBuffer.putLong(storeTimestamp);
+
+ // 12 STOREHOST
+ InetSocketAddress serverHost = (InetSocketAddress) messageExt.getStoreHost();
+ byteBuffer.put(serverHost.getAddress().getAddress());
+ byteBuffer.putInt(serverHost.getPort());
+
+ // 13 RECONSUMETIMES
+ int reconsumeTimes = messageExt.getReconsumeTimes();
+ byteBuffer.putInt(reconsumeTimes);
+
+ // 14 Prepared Transaction Offset
+ long preparedTransactionOffset = messageExt.getPreparedTransactionOffset();
+ byteBuffer.putLong(preparedTransactionOffset);
+
+ // 15 BODY
+ byteBuffer.putInt(bodyLength);
+ byteBuffer.put(newBody);
+
+ // 16 TOPIC
+ byteBuffer.put(topicLen);
+ byteBuffer.put(topics);
+
+ // 17 properties
+ byteBuffer.putShort(propertiesLength);
+ byteBuffer.put(propertiesBytes);
+
+ return byteBuffer.array();
+ }
+
+ public static MessageExt decode(
+ java.nio.ByteBuffer byteBuffer, final boolean readBody, final boolean deCompressBody) {
+ return decode(byteBuffer, readBody, deCompressBody, false);
+ }
+
+ public static MessageExt decode(
+ java.nio.ByteBuffer byteBuffer, final boolean readBody, final boolean deCompressBody, final boolean isClient) {
+ try {
+
+ MessageExt msgExt;
+ if (isClient) {
+ msgExt = new MessageClientExt();
+ } else {
+ msgExt = new MessageExt();
+ }
+
+ // 1 TOTALSIZE
+ int storeSize = byteBuffer.getInt();
+ msgExt.setStoreSize(storeSize);
+
+ // 2 MAGICCODE
+ byteBuffer.getInt();
+
+ // 3 BODYCRC
+ int bodyCRC = byteBuffer.getInt();
+ msgExt.setBodyCRC(bodyCRC);
+
+ // 4 QUEUEID
+ int queueId = byteBuffer.getInt();
+ msgExt.setQueueId(queueId);
+
+ // 5 FLAG
+ int flag = byteBuffer.getInt();
+ msgExt.setFlag(flag);
+
+ // 6 QUEUEOFFSET
+ long queueOffset = byteBuffer.getLong();
+ msgExt.setQueueOffset(queueOffset);
+
+ // 7 PHYSICALOFFSET
+ long physicOffset = byteBuffer.getLong();
+ msgExt.setCommitLogOffset(physicOffset);
+
+ // 8 SYSFLAG
+ int sysFlag = byteBuffer.getInt();
+ msgExt.setSysFlag(sysFlag);
+
+ // 9 BORNTIMESTAMP
+ long bornTimeStamp = byteBuffer.getLong();
+ msgExt.setBornTimestamp(bornTimeStamp);
+
+ // 10 BORNHOST
+ byte[] bornHost = new byte[4];
+ byteBuffer.get(bornHost, 0, 4);
+ int port = byteBuffer.getInt();
+ msgExt.setBornHost(new InetSocketAddress(InetAddress.getByAddress(bornHost), port));
+
+ // 11 STORETIMESTAMP
+ long storeTimestamp = byteBuffer.getLong();
+ msgExt.setStoreTimestamp(storeTimestamp);
+
+ // 12 STOREHOST
+ byte[] storeHost = new byte[4];
+ byteBuffer.get(storeHost, 0, 4);
+ port = byteBuffer.getInt();
+ msgExt.setStoreHost(new InetSocketAddress(InetAddress.getByAddress(storeHost), port));
+
+ // 13 RECONSUMETIMES
+ int reconsumeTimes = byteBuffer.getInt();
+ msgExt.setReconsumeTimes(reconsumeTimes);
+
+ // 14 Prepared Transaction Offset
+ long preparedTransactionOffset = byteBuffer.getLong();
+ msgExt.setPreparedTransactionOffset(preparedTransactionOffset);
+
+ // 15 BODY
+ int bodyLen = byteBuffer.getInt();
+ if (bodyLen > 0) {
+ if (readBody) {
+ byte[] body = new byte[bodyLen];
+ byteBuffer.get(body);
+
+ // uncompress body
+ if (deCompressBody && (sysFlag & MessageSysFlag.COMPRESSED_FLAG) == MessageSysFlag.COMPRESSED_FLAG) {
+ body = UtilAll.uncompress(body);
+ }
+
+ msgExt.setBody(body);
+ } else {
+ byteBuffer.position(byteBuffer.position() + bodyLen);
+ }
+ }
+
+ // 16 TOPIC
+ byte topicLen = byteBuffer.get();
+ byte[] topic = new byte[(int) topicLen];
+ byteBuffer.get(topic);
+ msgExt.setTopic(new String(topic, CHARSET_UTF8));
+
+ // 17 properties
+ short propertiesLength = byteBuffer.getShort();
+ if (propertiesLength > 0) {
+ byte[] properties = new byte[propertiesLength];
+ byteBuffer.get(properties);
+ String propertiesString = new String(properties, CHARSET_UTF8);
+ Map<String, String> map = string2messageProperties(propertiesString);
+ msgExt.setProperties(map);
+ }
+
+ ByteBuffer byteBufferMsgId = ByteBuffer.allocate(MSG_ID_LENGTH);
+ String msgId = createMessageId(byteBufferMsgId, msgExt.getStoreHostBytes(), msgExt.getCommitLogOffset());
+ msgExt.setMsgId(msgId);
+
+ if (isClient) {
+ ((MessageClientExt) msgExt).setOffsetMsgId(msgId);
+ }
+
+ return msgExt;
+ } catch (UnknownHostException e) {
+ byteBuffer.position(byteBuffer.limit());
+ } catch (BufferUnderflowException e) {
+ byteBuffer.position(byteBuffer.limit());
+ } catch (Exception e) {
+ byteBuffer.position(byteBuffer.limit());
+ }
+
+ return null;
+ }
+
+
+ public static List<MessageExt> decodes(java.nio.ByteBuffer byteBuffer) {
+ return decodes(byteBuffer, true);
+ }
+
+ public static List<MessageExt> decodes(java.nio.ByteBuffer byteBuffer, final boolean readBody) {
+ List<MessageExt> msgExts = new ArrayList<MessageExt>();
+ while (byteBuffer.hasRemaining()) {
+ MessageExt msgExt = clientDecode(byteBuffer, readBody);
+ if (null != msgExt) {
+ msgExts.add(msgExt);
+ } else {
+ break;
+ }
+ }
+ return msgExts;
+ }
+
+ public static final char NAME_VALUE_SEPARATOR = 1;
+ public static final char PROPERTY_SEPARATOR = 2;
+
+
+ public static String messageProperties2String(Map<String, String> properties) {
+ StringBuilder sb = new StringBuilder();
+ if (properties != null) {
+ for (final Map.Entry<String, String> entry : properties.entrySet()) {
+ final String name = entry.getKey();
+ final String value = entry.getValue();
+
+ sb.append(name);
+ sb.append(NAME_VALUE_SEPARATOR);
+ sb.append(value);
+ sb.append(PROPERTY_SEPARATOR);
+ }
+ }
+ return sb.toString();
+ }
+
+ public static Map<String, String> string2messageProperties(final String properties) {
+ Map<String, String> map = new HashMap<String, String>();
+ if (properties != null) {
+ String[] items = properties.split(String.valueOf(PROPERTY_SEPARATOR));
+ if (items != null) {
+ for (String i : items) {
+ String[] nv = i.split(String.valueOf(NAME_VALUE_SEPARATOR));
+ if (nv != null && 2 == nv.length) {
+ map.put(nv[0], nv[1]);
+ }
+ }
+ }
+ }
+
+ return map;
+ }
+}
[60/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Remove
author annotation.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicClusterSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicClusterSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicClusterSubCommand.java
index ab6d7d6..2bdedd6 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicClusterSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicClusterSubCommand.java
@@ -28,7 +28,6 @@ import java.util.Set;
/**
*
- * @author zhouli
*
*/
public class TopicClusterSubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java
index a3c1b5f..42184fb 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java
@@ -39,7 +39,6 @@ import java.util.Set;
/**
*
- * @author vintagewang@apache.org
*
*/
public class TopicListSubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java
index 0d1d528..6f89b22 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java
@@ -27,7 +27,6 @@ import org.apache.commons.cli.Options;
/**
*
- * @author vintagewang@apache.org
*
*/
public class TopicRouteSubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java
index 99f4865..73b98c9 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java
@@ -34,7 +34,6 @@ import java.util.List;
/**
*
- * @author vintagewang@apache.org
*
*/
public class TopicStatusSubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateOrderConfCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateOrderConfCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateOrderConfCommand.java
index 0933eb0..4cc88eb 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateOrderConfCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateOrderConfCommand.java
@@ -29,7 +29,6 @@ import org.apache.commons.cli.Options;
/**
*
- * @author manhong.yqd
*
*/
public class UpdateOrderConfCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicSubCommand.java
index 72ee5af..25dd1f3 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicSubCommand.java
@@ -30,9 +30,6 @@ import org.apache.commons.cli.Options;
import java.util.Set;
-/**
- * @author vintagewang@apache.org
- */
public class UpdateTopicSubCommand implements SubCommand {
@Override
[27/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
new file mode 100644
index 0000000..b6255c4
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
@@ -0,0 +1,418 @@
+/**
+ * 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.impl;
+
+import org.apache.rocketmq.client.QueryResult;
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.impl.factory.MQClientInstance;
+import org.apache.rocketmq.client.impl.producer.TopicPublishInfo;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.TopicConfig;
+import org.apache.rocketmq.common.help.FAQUrl;
+import org.apache.rocketmq.common.message.*;
+import org.apache.rocketmq.common.protocol.ResponseCode;
+import org.apache.rocketmq.common.protocol.header.QueryMessageRequestHeader;
+import org.apache.rocketmq.common.protocol.header.QueryMessageResponseHeader;
+import org.apache.rocketmq.common.protocol.route.BrokerData;
+import org.apache.rocketmq.common.protocol.route.TopicRouteData;
+import org.apache.rocketmq.remoting.InvokeCallback;
+import org.apache.rocketmq.remoting.common.RemotingUtil;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+import org.apache.rocketmq.remoting.netty.ResponseFuture;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.slf4j.Logger;
+
+import java.nio.ByteBuffer;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class MQAdminImpl {
+
+ private final Logger log = ClientLogger.getLog();
+ private final MQClientInstance mQClientFactory;
+ private long timeoutMillis = 6000;
+
+
+ public MQAdminImpl(MQClientInstance mQClientFactory) {
+ this.mQClientFactory = mQClientFactory;
+ }
+
+
+ public long getTimeoutMillis() {
+ return timeoutMillis;
+ }
+
+
+ public void setTimeoutMillis(long timeoutMillis) {
+ this.timeoutMillis = timeoutMillis;
+ }
+
+
+ public void createTopic(String key, String newTopic, int queueNum) throws MQClientException {
+ createTopic(key, newTopic, queueNum, 0);
+ }
+
+
+ public void createTopic(String key, String newTopic, int queueNum, int topicSysFlag) throws MQClientException {
+ try {
+ TopicRouteData topicRouteData = this.mQClientFactory.getMQClientAPIImpl().getTopicRouteInfoFromNameServer(key, timeoutMillis);
+ List<BrokerData> brokerDataList = topicRouteData.getBrokerDatas();
+ if (brokerDataList != null && !brokerDataList.isEmpty()) {
+ Collections.sort(brokerDataList);
+
+ boolean createOKAtLeastOnce = false;
+ MQClientException exception = null;
+
+ StringBuilder orderTopicString = new StringBuilder();
+
+ for (BrokerData brokerData : brokerDataList) {
+ String addr = brokerData.getBrokerAddrs().get(MixAll.MASTER_ID);
+ if (addr != null) {
+ TopicConfig topicConfig = new TopicConfig(newTopic);
+ topicConfig.setReadQueueNums(queueNum);
+ topicConfig.setWriteQueueNums(queueNum);
+ topicConfig.setTopicSysFlag(topicSysFlag);
+
+ boolean createOK = false;
+ for (int i = 0; i < 5; i++) {
+ try {
+ this.mQClientFactory.getMQClientAPIImpl().createTopic(addr, key, topicConfig, timeoutMillis);
+ createOK = true;
+ createOKAtLeastOnce = true;
+ break;
+ } catch (Exception e) {
+ if (4 == i) {
+ exception = new MQClientException("create topic to broker exception", e);
+ }
+ }
+ }
+
+ if (createOK) {
+ orderTopicString.append(brokerData.getBrokerName());
+ orderTopicString.append(":");
+ orderTopicString.append(queueNum);
+ orderTopicString.append(";");
+ }
+ }
+ }
+
+ if (exception != null && !createOKAtLeastOnce) {
+ throw exception;
+ }
+ } else {
+ throw new MQClientException("Not found broker, maybe key is wrong", null);
+ }
+ } catch (Exception e) {
+ throw new MQClientException("create new topic failed", e);
+ }
+ }
+
+
+ public List<MessageQueue> fetchPublishMessageQueues(String topic) throws MQClientException {
+ try {
+ TopicRouteData topicRouteData = this.mQClientFactory.getMQClientAPIImpl().getTopicRouteInfoFromNameServer(topic, timeoutMillis);
+ if (topicRouteData != null) {
+ TopicPublishInfo topicPublishInfo = MQClientInstance.topicRouteData2TopicPublishInfo(topic, topicRouteData);
+ if (topicPublishInfo != null && topicPublishInfo.ok()) {
+ return topicPublishInfo.getMessageQueueList();
+ }
+ }
+ } catch (Exception e) {
+ throw new MQClientException("Can not find Message Queue for this topic, " + topic, e);
+ }
+
+ throw new MQClientException("Unknow why, Can not find Message Queue for this topic, " + topic, null);
+ }
+
+
+ public Set<MessageQueue> fetchSubscribeMessageQueues(String topic) throws MQClientException {
+ try {
+ TopicRouteData topicRouteData = this.mQClientFactory.getMQClientAPIImpl().getTopicRouteInfoFromNameServer(topic, timeoutMillis);
+ if (topicRouteData != null) {
+ Set<MessageQueue> mqList = MQClientInstance.topicRouteData2TopicSubscribeInfo(topic, topicRouteData);
+ if (!mqList.isEmpty()) {
+ return mqList;
+ } else {
+ throw new MQClientException("Can not find Message Queue for this topic, " + topic + " Namesrv return empty", null);
+ }
+ }
+ } catch (Exception e) {
+ throw new MQClientException(
+ "Can not find Message Queue for this topic, " + topic + FAQUrl.suggestTodo(FAQUrl.MQLIST_NOT_EXIST), //
+ e);
+ }
+
+ throw new MQClientException("Unknow why, Can not find Message Queue for this topic, " + topic, null);
+ }
+
+
+ public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
+ String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
+ if (null == brokerAddr) {
+ this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
+ brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
+ }
+
+ if (brokerAddr != null) {
+ try {
+ return this.mQClientFactory.getMQClientAPIImpl().searchOffset(brokerAddr, mq.getTopic(), mq.getQueueId(), timestamp,
+ timeoutMillis);
+ } catch (Exception e) {
+ throw new MQClientException("Invoke Broker[" + brokerAddr + "] exception", e);
+ }
+ }
+
+ throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
+ }
+
+
+ public long maxOffset(MessageQueue mq) throws MQClientException {
+ String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
+ if (null == brokerAddr) {
+ this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
+ brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
+ }
+
+ if (brokerAddr != null) {
+ try {
+ return this.mQClientFactory.getMQClientAPIImpl().getMaxOffset(brokerAddr, mq.getTopic(), mq.getQueueId(), timeoutMillis);
+ } catch (Exception e) {
+ throw new MQClientException("Invoke Broker[" + brokerAddr + "] exception", e);
+ }
+ }
+
+ throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
+ }
+
+
+ public long minOffset(MessageQueue mq) throws MQClientException {
+ String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
+ if (null == brokerAddr) {
+ this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
+ brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
+ }
+
+ if (brokerAddr != null) {
+ try {
+ return this.mQClientFactory.getMQClientAPIImpl().getMinOffset(brokerAddr, mq.getTopic(), mq.getQueueId(), timeoutMillis);
+ } catch (Exception e) {
+ throw new MQClientException("Invoke Broker[" + brokerAddr + "] exception", e);
+ }
+ }
+
+ throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
+ }
+
+
+ public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
+ String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
+ if (null == brokerAddr) {
+ this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
+ brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
+ }
+
+ if (brokerAddr != null) {
+ try {
+ return this.mQClientFactory.getMQClientAPIImpl().getEarliestMsgStoretime(brokerAddr, mq.getTopic(), mq.getQueueId(),
+ timeoutMillis);
+ } catch (Exception e) {
+ throw new MQClientException("Invoke Broker[" + brokerAddr + "] exception", e);
+ }
+ }
+
+ throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
+ }
+
+ public MessageExt viewMessage(String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+
+ MessageId messageId = null;
+ try {
+ messageId = MessageDecoder.decodeMessageId(msgId);
+ } catch (Exception e) {
+ throw new MQClientException(ResponseCode.NO_MESSAGE, "query message by id finished, but no message.");
+ }
+ return this.mQClientFactory.getMQClientAPIImpl().viewMessage(RemotingUtil.socketAddress2String(messageId.getAddress()),
+ messageId.getOffset(), timeoutMillis);
+ }
+
+ public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end) throws MQClientException,
+ InterruptedException {
+ return queryMessage(topic, key, maxNum, begin, end, false);
+ }
+
+ public MessageExt queryMessageByUniqKey(String topic, String uniqKey) throws InterruptedException, MQClientException {
+
+ QueryResult qr = this.queryMessage(topic, uniqKey, 32,
+ MessageClientIDSetter.getNearlyTimeFromID(uniqKey).getTime() - 1000, Long.MAX_VALUE, true);
+ if (qr != null && qr.getMessageList() != null && qr.getMessageList().size() > 0) {
+ return qr.getMessageList().get(0);
+ } else {
+ return null;
+ }
+ }
+
+ protected QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end, boolean isUniqKey) throws MQClientException,
+ InterruptedException {
+ TopicRouteData topicRouteData = this.mQClientFactory.getAnExistTopicRouteData(topic);
+ if (null == topicRouteData) {
+ this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic);
+ topicRouteData = this.mQClientFactory.getAnExistTopicRouteData(topic);
+ }
+
+ if (topicRouteData != null) {
+ List<String> brokerAddrs = new LinkedList<String>();
+ for (BrokerData brokerData : topicRouteData.getBrokerDatas()) {
+ String addr = brokerData.selectBrokerAddr();
+ if (addr != null) {
+ brokerAddrs.add(addr);
+ }
+ }
+
+ if (!brokerAddrs.isEmpty()) {
+ final CountDownLatch countDownLatch = new CountDownLatch(brokerAddrs.size());
+ final List<QueryResult> queryResultList = new LinkedList<QueryResult>();
+
+ for (String addr : brokerAddrs) {
+ try {
+ QueryMessageRequestHeader requestHeader = new QueryMessageRequestHeader();
+ requestHeader.setTopic(topic);
+ requestHeader.setKey(key);
+ requestHeader.setMaxNum(maxNum);
+ requestHeader.setBeginTimestamp(begin);
+ requestHeader.setEndTimestamp(end);
+
+ this.mQClientFactory.getMQClientAPIImpl().queryMessage(addr, requestHeader, timeoutMillis * 3,
+ new InvokeCallback() {
+ @Override
+ public void operationComplete(ResponseFuture responseFuture) {
+ try {
+ RemotingCommand response = responseFuture.getResponseCommand();
+ if (response != null) {
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ QueryMessageResponseHeader responseHeader = null;
+ try {
+ responseHeader =
+ (QueryMessageResponseHeader) response
+ .decodeCommandCustomHeader(QueryMessageResponseHeader.class);
+ } catch (RemotingCommandException e) {
+ log.error("decodeCommandCustomHeader exception", e);
+ return;
+ }
+
+ List<MessageExt> wrappers =
+ MessageDecoder.decodes(ByteBuffer.wrap(response.getBody()), true);
+
+ QueryResult qr = new QueryResult(responseHeader.getIndexLastUpdateTimestamp(), wrappers);
+ queryResultList.add(qr);
+ break;
+ }
+ default:
+ log.warn("getResponseCommand failed, {} {}", response.getCode(), response.getRemark());
+ break;
+ }
+ } else {
+ log.warn("getResponseCommand return null");
+ }
+ } finally {
+ countDownLatch.countDown();
+ }
+ }
+ }, isUniqKey);
+ } catch (Exception e) {
+ log.warn("queryMessage exception", e);
+ }
+
+ }
+
+ boolean ok = countDownLatch.await(timeoutMillis * 4, TimeUnit.MILLISECONDS);
+ if (!ok) {
+ log.warn("queryMessage, maybe some broker failed");
+ }
+
+ long indexLastUpdateTimestamp = 0;
+ List<MessageExt> messageList = new LinkedList<MessageExt>();
+ for (QueryResult qr : queryResultList) {
+ if (qr.getIndexLastUpdateTimestamp() > indexLastUpdateTimestamp) {
+ indexLastUpdateTimestamp = qr.getIndexLastUpdateTimestamp();
+ }
+
+ for (MessageExt msgExt : qr.getMessageList()) {
+ if (isUniqKey) {
+ if (msgExt.getMsgId().equals(key)) {
+
+ if (messageList.size() > 0) {
+
+ if (messageList.get(0).getStoreTimestamp() > msgExt.getStoreTimestamp()) {
+
+ messageList.clear();
+ messageList.add(msgExt);
+ }
+
+ } else {
+
+ messageList.add(msgExt);
+ }
+ } else {
+ log.warn("queryMessage by uniqKey, find message key not matched, maybe hash duplicate {}", msgExt.toString());
+ }
+ } else {
+ String keys = msgExt.getKeys();
+ if (keys != null) {
+ boolean matched = false;
+ String[] keyArray = keys.split(MessageConst.KEY_SEPARATOR);
+ if (keyArray != null) {
+ for (String k : keyArray) {
+ if (key.equals(k)) {
+ matched = true;
+ break;
+ }
+ }
+ }
+
+ if (matched) {
+ messageList.add(msgExt);
+ } else {
+ log.warn("queryMessage, find message key not matched, maybe hash duplicate {}", msgExt.toString());
+ }
+ }
+ }
+ }
+ }
+
+ if (!messageList.isEmpty()) {
+ return new QueryResult(indexLastUpdateTimestamp, messageList);
+ } else {
+ throw new MQClientException(ResponseCode.NO_MESSAGE, "query message by key finished, but no message.");
+ }
+ }
+ }
+
+ throw new MQClientException(ResponseCode.TOPIC_NOT_EXIST, "The topic[" + topic + "] not matched route info");
+ }
+}
[53/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Use apache
email as author.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingSendRequestException.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingSendRequestException.java b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingSendRequestException.java
index d32ff4f..d542c2b 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingSendRequestException.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingSendRequestException.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.remoting.exception;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class RemotingSendRequestException extends RemotingException {
private static final long serialVersionUID = 5391285827332471674L;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTimeoutException.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTimeoutException.java b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTimeoutException.java
index 358c1a8..4e07e9a 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTimeoutException.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTimeoutException.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.remoting.exception;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class RemotingTimeoutException extends RemotingException {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTooMuchRequestException.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTooMuchRequestException.java b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTooMuchRequestException.java
index d89662b..59ce786 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTooMuchRequestException.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTooMuchRequestException.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.remoting.exception;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class RemotingTooMuchRequestException extends RemotingException {
private static final long serialVersionUID = 4326919581254519654L;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyClientConfig.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyClientConfig.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyClientConfig.java
index 2dcb9f9..e558b76 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyClientConfig.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyClientConfig.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.remoting.netty;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class NettyClientConfig {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
index b61d3ed..b4883ee 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
@@ -29,7 +29,7 @@ import java.nio.ByteBuffer;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class NettyDecoder extends LengthFieldBasedFrameDecoder {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEncoder.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEncoder.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEncoder.java
index 43b8caa..832e3cd 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEncoder.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEncoder.java
@@ -29,7 +29,7 @@ import java.nio.ByteBuffer;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class NettyEncoder extends MessageToByteEncoder<RemotingCommand> {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEvent.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEvent.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEvent.java
index 1159ffb..38fbb86 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEvent.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEvent.java
@@ -20,7 +20,7 @@ import io.netty.channel.Channel;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class NettyEvent {
private final NettyEventType type;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEventType.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEventType.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEventType.java
index d4306a9..e6ec3cd 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEventType.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEventType.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.remoting.netty;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public enum NettyEventType {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java
index c136ff5..bc8ee73 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java
@@ -50,7 +50,7 @@ import java.util.concurrent.TimeUnit;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public abstract class NettyRemotingAbstract {
private static final Logger PLOG = LoggerFactory.getLogger(RemotingHelper.ROCKETMQ_REMOTING);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
index 2a6546c..fd5aeac 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
@@ -67,7 +67,7 @@ import java.util.concurrent.locks.ReentrantLock;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class NettyRemotingClient extends NettyRemotingAbstract implements RemotingClient {
private static final Logger log = LoggerFactory.getLogger(RemotingHelper.ROCKETMQ_REMOTING);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java
index ade8401..3ce364e 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java
@@ -23,7 +23,7 @@ import io.netty.channel.ChannelHandlerContext;
/**
* Common remoting command processor
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public interface NettyRequestProcessor {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
index 76e7914..b441962 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
@@ -19,7 +19,7 @@ package org.apache.rocketmq.remoting.netty;
/**
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class NettyServerConfig implements Cloneable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/netty/ResponseFuture.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/ResponseFuture.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/ResponseFuture.java
index b14ebb4..58cc1e4 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/ResponseFuture.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/ResponseFuture.java
@@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ResponseFuture {
private final int opaque;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
index 473326b..bf8eb0e 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
@@ -34,7 +34,7 @@ import java.util.concurrent.atomic.AtomicInteger;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class RemotingCommand {
public static final String SERIALIZE_TYPE_PROPERTY = "rocketmq.serialize.type";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommandType.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommandType.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommandType.java
index ee3eb78..fa4035b 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommandType.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommandType.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.remoting.protocol;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public enum RemotingCommandType {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java
index 8ae63f0..93b968c 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java
@@ -22,7 +22,7 @@ import java.nio.charset.Charset;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public abstract class RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
index 9c4283f..b11ed44 100644
--- a/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
+++ b/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: MixTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
+ * $Id: MixTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
package org.apache.rocketmq.remoting;
@@ -24,7 +24,7 @@ import org.junit.Test;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MixTest {
@Test
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
index e2f640d..42ae4fb 100644
--- a/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
+++ b/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: NettyRPCTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
+ * $Id: NettyRPCTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
package org.apache.rocketmq.remoting;
@@ -33,7 +33,7 @@ import static org.junit.Assert.assertTrue;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class NettyRPCTest {
@Test
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java b/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java
index aeb7c40..8f9132c 100644
--- a/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java
+++ b/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java
@@ -24,7 +24,7 @@ import org.junit.Test;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class TestSubClassAuto {
@Test
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java b/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
index 0b2ef15..471418f 100644
--- a/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
@@ -35,7 +35,7 @@ import java.util.concurrent.TimeUnit;
/**
* Create MappedFile in advance
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class AllocateMappedFileService extends ServiceThread {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java b/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java
index ec4acaf..786f16d 100644
--- a/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java
+++ b/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java
@@ -22,7 +22,7 @@ import java.nio.ByteBuffer;
/**
* Write messages callback interface
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public interface AppendMessageCallback {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java b/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java
index 7de82d4..53a7c98 100644
--- a/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java
@@ -19,7 +19,7 @@ package org.apache.rocketmq.store;
/**
* When write a message to the commit log, returns results
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class AppendMessageResult {
// Return code
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java b/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java
index d82a024..2a6b329 100644
--- a/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java
+++ b/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java
@@ -19,7 +19,7 @@ package org.apache.rocketmq.store;
/**
* When write a message to the commit log, returns code
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public enum AppendMessageStatus {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/CommitLog.java b/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
index 29b8900..5bb82ef 100644
--- a/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
+++ b/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
@@ -45,7 +45,7 @@ import java.util.concurrent.locks.ReentrantLock;
/**
* Store all metadata downtime for recovery, data protection reliability
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class CommitLog {
// Message's MAGIC CODE daa320a7
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java b/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
index f45febe..b89db8a 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
@@ -26,7 +26,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ConsumeQueue {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/DefaultMessageFilter.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageFilter.java b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageFilter.java
index 86bdf3e..4ba7e60 100644
--- a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageFilter.java
+++ b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageFilter.java
@@ -20,7 +20,7 @@ import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class DefaultMessageFilter implements MessageFilter {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
index f4c9427..60a0188 100644
--- a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
+++ b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
@@ -50,7 +50,7 @@ import static org.apache.rocketmq.store.config.BrokerRole.SLAVE;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class DefaultMessageStore implements MessageStore {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/DispatchRequest.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/DispatchRequest.java b/store/src/main/java/org/apache/rocketmq/store/DispatchRequest.java
index 9462a09..2b099a6 100644
--- a/store/src/main/java/org/apache/rocketmq/store/DispatchRequest.java
+++ b/store/src/main/java/org/apache/rocketmq/store/DispatchRequest.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.store;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class DispatchRequest {
private final String topic;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java b/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java
index 35ead73..edd0020 100644
--- a/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java
@@ -24,7 +24,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class GetMessageResult {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/GetMessageStatus.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/GetMessageStatus.java b/store/src/main/java/org/apache/rocketmq/store/GetMessageStatus.java
index bc80537..c3ae337 100644
--- a/store/src/main/java/org/apache/rocketmq/store/GetMessageStatus.java
+++ b/store/src/main/java/org/apache/rocketmq/store/GetMessageStatus.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.store;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public enum GetMessageStatus {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/MappedFile.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/MappedFile.java b/store/src/main/java/org/apache/rocketmq/store/MappedFile.java
index 8013250..d06960b 100644
--- a/store/src/main/java/org/apache/rocketmq/store/MappedFile.java
+++ b/store/src/main/java/org/apache/rocketmq/store/MappedFile.java
@@ -42,7 +42,7 @@ import java.util.concurrent.atomic.AtomicLong;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MappedFile extends ReferenceResource {
public static final int OS_PAGE_SIZE = 1024 * 4;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java b/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
index 53062cb..21b682e 100644
--- a/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
+++ b/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
@@ -28,7 +28,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MappedFileQueue {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/MessageExtBrokerInner.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/MessageExtBrokerInner.java b/store/src/main/java/org/apache/rocketmq/store/MessageExtBrokerInner.java
index de38448..ecdd28b 100644
--- a/store/src/main/java/org/apache/rocketmq/store/MessageExtBrokerInner.java
+++ b/store/src/main/java/org/apache/rocketmq/store/MessageExtBrokerInner.java
@@ -21,7 +21,7 @@ import org.apache.rocketmq.common.message.MessageExt;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MessageExtBrokerInner extends MessageExt {
private static final long serialVersionUID = 7256001576878700634L;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/MessageFilter.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/MessageFilter.java b/store/src/main/java/org/apache/rocketmq/store/MessageFilter.java
index 9c21cc8..cc4657f 100644
--- a/store/src/main/java/org/apache/rocketmq/store/MessageFilter.java
+++ b/store/src/main/java/org/apache/rocketmq/store/MessageFilter.java
@@ -20,7 +20,7 @@ import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface MessageFilter {
boolean isMessageMatched(final SubscriptionData subscriptionData, final Long tagsCode);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/MessageStore.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/MessageStore.java b/store/src/main/java/org/apache/rocketmq/store/MessageStore.java
index cba4e6a..c9a8ddc 100644
--- a/store/src/main/java/org/apache/rocketmq/store/MessageStore.java
+++ b/store/src/main/java/org/apache/rocketmq/store/MessageStore.java
@@ -24,7 +24,7 @@ import java.util.Set;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface MessageStore {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/PutMessageResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/PutMessageResult.java b/store/src/main/java/org/apache/rocketmq/store/PutMessageResult.java
index c6145cf..8aaee98 100644
--- a/store/src/main/java/org/apache/rocketmq/store/PutMessageResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/PutMessageResult.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.store;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class PutMessageResult {
private PutMessageStatus putMessageStatus;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/PutMessageStatus.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/PutMessageStatus.java b/store/src/main/java/org/apache/rocketmq/store/PutMessageStatus.java
index 3a42088..a37b94e 100644
--- a/store/src/main/java/org/apache/rocketmq/store/PutMessageStatus.java
+++ b/store/src/main/java/org/apache/rocketmq/store/PutMessageStatus.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.store;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public enum PutMessageStatus {
PUT_OK,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/QueryMessageResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/QueryMessageResult.java b/store/src/main/java/org/apache/rocketmq/store/QueryMessageResult.java
index a833185..fa57ed2 100644
--- a/store/src/main/java/org/apache/rocketmq/store/QueryMessageResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/QueryMessageResult.java
@@ -22,7 +22,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class QueryMessageResult {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/ReferenceResource.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/ReferenceResource.java b/store/src/main/java/org/apache/rocketmq/store/ReferenceResource.java
index b0124ca..b322e04 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ReferenceResource.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ReferenceResource.java
@@ -20,7 +20,7 @@ import java.util.concurrent.atomic.AtomicLong;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public abstract class ReferenceResource {
protected final AtomicLong refCount = new AtomicLong(1);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/RunningFlags.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/RunningFlags.java b/store/src/main/java/org/apache/rocketmq/store/RunningFlags.java
index 8231a88..c103984 100644
--- a/store/src/main/java/org/apache/rocketmq/store/RunningFlags.java
+++ b/store/src/main/java/org/apache/rocketmq/store/RunningFlags.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.store;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class RunningFlags {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/SelectMappedBufferResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/SelectMappedBufferResult.java b/store/src/main/java/org/apache/rocketmq/store/SelectMappedBufferResult.java
index f57ec64..14fcce3 100644
--- a/store/src/main/java/org/apache/rocketmq/store/SelectMappedBufferResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/SelectMappedBufferResult.java
@@ -20,7 +20,7 @@ import java.nio.ByteBuffer;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class SelectMappedBufferResult {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/StoreCheckpoint.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/StoreCheckpoint.java b/store/src/main/java/org/apache/rocketmq/store/StoreCheckpoint.java
index f411165..d795077 100644
--- a/store/src/main/java/org/apache/rocketmq/store/StoreCheckpoint.java
+++ b/store/src/main/java/org/apache/rocketmq/store/StoreCheckpoint.java
@@ -30,7 +30,7 @@ import java.nio.channels.FileChannel.MapMode;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class StoreCheckpoint {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java b/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java
index 94f2339..4ecc1cc 100644
--- a/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java
@@ -31,7 +31,7 @@ import java.util.concurrent.locks.ReentrantLock;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class StoreStatsService extends ServiceThread {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java b/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java
index bfcb1c6..6fe0790 100644
--- a/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java
+++ b/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java
@@ -21,7 +21,7 @@ import java.lang.management.OperatingSystemMXBean;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class StoreUtil {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java b/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java
index 680fec7..9e7bcc4 100644
--- a/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java
+++ b/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java
@@ -30,7 +30,7 @@ import java.util.Deque;
import java.util.concurrent.ConcurrentLinkedDeque;
/**
- * @author xinyuzhou.zxy
+ * @author yukon@apache.org
*/
public class TransientStorePool {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/config/BrokerRole.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/config/BrokerRole.java b/store/src/main/java/org/apache/rocketmq/store/config/BrokerRole.java
index f916695..0d3c639 100644
--- a/store/src/main/java/org/apache/rocketmq/store/config/BrokerRole.java
+++ b/store/src/main/java/org/apache/rocketmq/store/config/BrokerRole.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.store.config;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public enum BrokerRole {
ASYNC_MASTER,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/config/FlushDiskType.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/config/FlushDiskType.java b/store/src/main/java/org/apache/rocketmq/store/config/FlushDiskType.java
index 9ed40a1..5696429 100644
--- a/store/src/main/java/org/apache/rocketmq/store/config/FlushDiskType.java
+++ b/store/src/main/java/org/apache/rocketmq/store/config/FlushDiskType.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.store.config;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public enum FlushDiskType {
SYNC_FLUSH,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java b/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java
index eb2b566..9230fa4 100644
--- a/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java
+++ b/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java
@@ -23,8 +23,8 @@ import java.io.File;
/**
- * @author vongosling
- * @author shijia.wxr
+ * @author vongosling@apache.org
+ * @author vintagewang@apache.org
*/
public class MessageStoreConfig {
//The root directory in which the log data is kept
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/ha/HAConnection.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/ha/HAConnection.java b/store/src/main/java/org/apache/rocketmq/store/ha/HAConnection.java
index fe1c3b9..d1f8219 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ha/HAConnection.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ha/HAConnection.java
@@ -31,7 +31,7 @@ import java.nio.channels.SocketChannel;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class HAConnection {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
@@ -91,7 +91,7 @@ public class HAConnection {
/**
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
class ReadSocketService extends ServiceThread {
private static final int READ_MAX_BUFFER_SIZE = 1024 * 1024;
@@ -215,7 +215,7 @@ public class HAConnection {
/**
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
class WriteSocketService extends ServiceThread {
private final Selector selector;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java b/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
index bb68112..7a17108 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
@@ -39,7 +39,7 @@ import java.util.concurrent.atomic.AtomicReference;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class HAService {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/ha/WaitNotifyObject.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/ha/WaitNotifyObject.java b/store/src/main/java/org/apache/rocketmq/store/ha/WaitNotifyObject.java
index 11f2434..9da9fbf 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ha/WaitNotifyObject.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ha/WaitNotifyObject.java
@@ -20,7 +20,7 @@ import java.util.HashMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class WaitNotifyObject {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java b/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
index 9d44463..f2861fb 100644
--- a/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
+++ b/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
@@ -30,7 +30,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class IndexFile {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/index/IndexHeader.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/index/IndexHeader.java b/store/src/main/java/org/apache/rocketmq/store/index/IndexHeader.java
index 2b3a3ed..ec6199d 100644
--- a/store/src/main/java/org/apache/rocketmq/store/index/IndexHeader.java
+++ b/store/src/main/java/org/apache/rocketmq/store/index/IndexHeader.java
@@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicLong;
/**
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class IndexHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java b/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java
index 2d00b22..eab83cd 100644
--- a/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java
@@ -36,7 +36,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class IndexService {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/index/QueryOffsetResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/index/QueryOffsetResult.java b/store/src/main/java/org/apache/rocketmq/store/index/QueryOffsetResult.java
index 7a4f01d..0af9aa0 100644
--- a/store/src/main/java/org/apache/rocketmq/store/index/QueryOffsetResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/index/QueryOffsetResult.java
@@ -20,7 +20,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class QueryOffsetResult {
private final List<Long> phyOffsets;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/schedule/DelayOffsetSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/schedule/DelayOffsetSerializeWrapper.java b/store/src/main/java/org/apache/rocketmq/store/schedule/DelayOffsetSerializeWrapper.java
index 96b1176..5c60a2c 100644
--- a/store/src/main/java/org/apache/rocketmq/store/schedule/DelayOffsetSerializeWrapper.java
+++ b/store/src/main/java/org/apache/rocketmq/store/schedule/DelayOffsetSerializeWrapper.java
@@ -22,7 +22,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class DelayOffsetSerializeWrapper extends RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java b/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java
index a1acbab..0b5df95 100644
--- a/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java
@@ -35,7 +35,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class ScheduleMessageService extends ConfigManager {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStats.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStats.java b/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStats.java
index f3982b7..4f21ae5 100644
--- a/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStats.java
+++ b/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStats.java
@@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class BrokerStats {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java b/store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java
index 83dc739..abad9c7 100644
--- a/store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java
@@ -35,7 +35,7 @@ import static org.junit.Assert.assertTrue;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class DefaultMessageStoreTest {
private static final Logger logger = LoggerFactory.getLogger(DefaultMessageStoreTest.class);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/test/java/org/apache/rocketmq/store/MappedFileQueueTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/MappedFileQueueTest.java b/store/src/test/java/org/apache/rocketmq/store/MappedFileQueueTest.java
index c10af61..ac1e016 100644
--- a/store/src/test/java/org/apache/rocketmq/store/MappedFileQueueTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/MappedFileQueueTest.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: MappedFileQueueTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
+ * $Id: MappedFileQueueTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
package org.apache.rocketmq.store;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/test/java/org/apache/rocketmq/store/MappedFileTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/MappedFileTest.java b/store/src/test/java/org/apache/rocketmq/store/MappedFileTest.java
index a03b3c9..bfa09e9 100644
--- a/store/src/test/java/org/apache/rocketmq/store/MappedFileTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/MappedFileTest.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: MappedFileTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
+ * $Id: MappedFileTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
package org.apache.rocketmq.store;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/test/java/org/apache/rocketmq/store/StoreCheckpointTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/StoreCheckpointTest.java b/store/src/test/java/org/apache/rocketmq/store/StoreCheckpointTest.java
index 557275b..f0245a9 100644
--- a/store/src/test/java/org/apache/rocketmq/store/StoreCheckpointTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/StoreCheckpointTest.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: StoreCheckpointTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
+ * $Id: StoreCheckpointTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
package org.apache.rocketmq.store;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/test/java/org/apache/rocketmq/store/index/IndexFileTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/index/IndexFileTest.java b/store/src/test/java/org/apache/rocketmq/store/index/IndexFileTest.java
index 9d5d8bb..95cf0c8 100644
--- a/store/src/test/java/org/apache/rocketmq/store/index/IndexFileTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/index/IndexFileTest.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: IndexFileTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
+ * $Id: IndexFileTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
package org.apache.rocketmq.store.index;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/store/src/test/java/org/apache/rocketmq/store/schedule/ScheduleMessageTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/schedule/ScheduleMessageTest.java b/store/src/test/java/org/apache/rocketmq/store/schedule/ScheduleMessageTest.java
index 54d3eb7..7ac8233 100644
--- a/store/src/test/java/org/apache/rocketmq/store/schedule/ScheduleMessageTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/schedule/ScheduleMessageTest.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: ScheduleMessageTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
+ * $Id: ScheduleMessageTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
package org.apache.rocketmq.store.schedule;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java
index b9347c4..688fd5e 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java
@@ -42,7 +42,7 @@ import java.util.Set;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
private final DefaultMQAdminExtImpl defaultMQAdminExtImpl;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
index 8b20a3a..5237219 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
@@ -54,7 +54,7 @@ import java.util.Map.Entry;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
private final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java b/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
index 9c254dc..bb20c94 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
@@ -29,7 +29,7 @@ import java.util.*;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class CommandUtil {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java b/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java
index e4be914..5c4e173 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java
@@ -46,7 +46,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MQAdminStartup {
protected static List<SubCommand> subCommandList = new ArrayList<SubCommand>();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/SubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/SubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/SubCommand.java
index a399d2e..4a96021 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/SubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/SubCommand.java
@@ -22,7 +22,7 @@ import org.apache.commons.cli.Options;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface SubCommand {
public String commandName();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerConsumeStatsSubCommad.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerConsumeStatsSubCommad.java b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerConsumeStatsSubCommad.java
index beb7c29..6caa3e9 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerConsumeStatsSubCommad.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerConsumeStatsSubCommad.java
@@ -32,7 +32,7 @@ import java.util.*;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class BrokerConsumeStatsSubCommad implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerStatusSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerStatusSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerStatusSubCommand.java
index 5c9ece8..9d096a9 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerStatusSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerStatusSubCommand.java
@@ -36,7 +36,7 @@ import java.util.TreeMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class BrokerStatusSubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/broker/UpdateBrokerConfigSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/UpdateBrokerConfigSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/UpdateBrokerConfigSubCommand.java
index 5789270..d71ee3f 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/UpdateBrokerConfigSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/UpdateBrokerConfigSubCommand.java
@@ -30,7 +30,7 @@ import java.util.Set;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class UpdateBrokerConfigSubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/ClusterListSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/ClusterListSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/ClusterListSubCommand.java
index 635800c..781dc90 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/ClusterListSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/ClusterListSubCommand.java
@@ -37,7 +37,7 @@ import java.util.TreeSet;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ClusterListSubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ConsumerConnectionSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ConsumerConnectionSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ConsumerConnectionSubCommand.java
index faa7838..c12f459 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ConsumerConnectionSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ConsumerConnectionSubCommand.java
@@ -32,7 +32,7 @@ import java.util.Map.Entry;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ConsumerConnectionSubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ProducerConnectionSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ProducerConnectionSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ProducerConnectionSubCommand.java
index 9e46f3e..17244de 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ProducerConnectionSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ProducerConnectionSubCommand.java
@@ -28,7 +28,7 @@ import org.apache.commons.cli.Options;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ProducerConnectionSubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
index 6b82a0b..d88d4be 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
@@ -42,7 +42,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ConsumerProgressSubCommand implements SubCommand {
private final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerStatusSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerStatusSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerStatusSubCommand.java
index 382f74c..87ead28 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerStatusSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerStatusSubCommand.java
@@ -35,7 +35,7 @@ import java.util.TreeMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ConsumerStatusSubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerSubCommand.java
index 60d3217..3dad886 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerSubCommand.java
@@ -35,7 +35,7 @@ import java.util.TreeMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ConsumerSubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/StartMonitoringSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/StartMonitoringSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/StartMonitoringSubCommand.java
index 94cdf0a..d902210 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/StartMonitoringSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/StartMonitoringSubCommand.java
@@ -28,7 +28,7 @@ import org.slf4j.Logger;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class StartMonitoringSubCommand implements SubCommand {
private final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/UpdateSubGroupSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/UpdateSubGroupSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/UpdateSubGroupSubCommand.java
index ad77eec..c784a06 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/UpdateSubGroupSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/UpdateSubGroupSubCommand.java
@@ -30,7 +30,7 @@ import java.util.Set;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class UpdateSubGroupSubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageSubCommand.java
index dcaa80f..4148387 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageSubCommand.java
@@ -34,7 +34,7 @@ import java.util.Set;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class PrintMessageSubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java
index f39cb19..8006657 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java
@@ -43,7 +43,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class QueryMsgByIdSubCommand implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java
index 1ce3656..e184ac1 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java
@@ -29,7 +29,7 @@ import org.apache.commons.cli.Options;
/**
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class QueryMsgByKeySubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByOffsetSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByOffsetSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByOffsetSubCommand.java
index 93b9d2d..e82508f 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByOffsetSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByOffsetSubCommand.java
@@ -29,7 +29,7 @@ import org.apache.commons.cli.Options;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class QueryMsgByOffsetSubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java
index c632102..a3c1b5f 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java
@@ -39,7 +39,7 @@ import java.util.Set;
/**
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class TopicListSubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java
index a06dd2b..0d1d528 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java
@@ -27,7 +27,7 @@ import org.apache.commons.cli.Options;
/**
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class TopicRouteSubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java
index 220906a..99f4865 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java
@@ -34,7 +34,7 @@ import java.util.List;
/**
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*
*/
public class TopicStatusSubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicSubCommand.java
index 2e5431a..72ee5af 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicSubCommand.java
@@ -31,7 +31,7 @@ import java.util.Set;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class UpdateTopicSubCommand implements SubCommand {
[26/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
new file mode 100644
index 0000000..99204b0
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
@@ -0,0 +1,1996 @@
+/**
+ * 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.impl;
+
+import org.apache.rocketmq.client.ClientConfig;
+import org.apache.rocketmq.client.consumer.PullCallback;
+import org.apache.rocketmq.client.consumer.PullResult;
+import org.apache.rocketmq.client.consumer.PullStatus;
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.hook.SendMessageContext;
+import org.apache.rocketmq.client.impl.consumer.PullResultExt;
+import org.apache.rocketmq.client.impl.factory.MQClientInstance;
+import org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl;
+import org.apache.rocketmq.client.impl.producer.TopicPublishInfo;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.client.producer.SendCallback;
+import org.apache.rocketmq.client.producer.SendResult;
+import org.apache.rocketmq.client.producer.SendStatus;
+import org.apache.rocketmq.common.MQVersion;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.TopicConfig;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.admin.ConsumeStats;
+import org.apache.rocketmq.common.admin.TopicStatsTable;
+import org.apache.rocketmq.common.message.*;
+import org.apache.rocketmq.common.namesrv.TopAddressing;
+import org.apache.rocketmq.common.protocol.RequestCode;
+import org.apache.rocketmq.common.protocol.ResponseCode;
+import org.apache.rocketmq.common.protocol.body.*;
+import org.apache.rocketmq.common.protocol.header.*;
+import org.apache.rocketmq.common.protocol.header.filtersrv.RegisterMessageFilterClassRequestHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.*;
+import org.apache.rocketmq.common.protocol.heartbeat.HeartbeatData;
+import org.apache.rocketmq.common.protocol.route.TopicRouteData;
+import org.apache.rocketmq.common.subscription.SubscriptionGroupConfig;
+import org.apache.rocketmq.remoting.InvokeCallback;
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.remoting.RemotingClient;
+import org.apache.rocketmq.remoting.exception.*;
+import org.apache.rocketmq.remoting.netty.NettyClientConfig;
+import org.apache.rocketmq.remoting.netty.NettyRemotingClient;
+import org.apache.rocketmq.remoting.netty.ResponseFuture;
+import org.apache.rocketmq.remoting.protocol.LanguageCode;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+import org.slf4j.Logger;
+
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class MQClientAPIImpl {
+
+ private final static Logger log = ClientLogger.getLog();
+ public static boolean sendSmartMsg =
+ Boolean.parseBoolean(System.getProperty("org.apache.rocketmq.client.sendSmartMsg", "true"));
+
+ static {
+ System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));
+ }
+
+ private final RemotingClient remotingClient;
+ private final TopAddressing topAddressing;
+ private final ClientRemotingProcessor clientRemotingProcessor;
+ private String nameSrvAddr = null;
+ private ClientConfig clientConfig;
+
+ public MQClientAPIImpl(final NettyClientConfig nettyClientConfig, final ClientRemotingProcessor clientRemotingProcessor,
+ RPCHook rpcHook, final ClientConfig clientConfig) {
+ this.clientConfig = clientConfig;
+ topAddressing = new TopAddressing(MixAll.WS_ADDR, clientConfig.getUnitName());
+ this.remotingClient = new NettyRemotingClient(nettyClientConfig, null);
+ this.clientRemotingProcessor = clientRemotingProcessor;
+
+ this.remotingClient.registerRPCHook(rpcHook);
+ this.remotingClient.registerProcessor(RequestCode.CHECK_TRANSACTION_STATE, this.clientRemotingProcessor, null);
+
+ this.remotingClient.registerProcessor(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, this.clientRemotingProcessor, null);
+
+ this.remotingClient.registerProcessor(RequestCode.RESET_CONSUMER_CLIENT_OFFSET, this.clientRemotingProcessor, null);
+
+ this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT, this.clientRemotingProcessor, null);
+
+ this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_RUNNING_INFO, this.clientRemotingProcessor, null);
+
+ this.remotingClient.registerProcessor(RequestCode.CONSUME_MESSAGE_DIRECTLY, this.clientRemotingProcessor, null);
+ }
+
+ public List<String> getNameServerAddressList() {
+ return this.remotingClient.getNameServerAddressList();
+ }
+
+ public RemotingClient getRemotingClient() {
+ return remotingClient;
+ }
+
+ public String fetchNameServerAddr() {
+ try {
+ String addrs = this.topAddressing.fetchNSAddr();
+ if (addrs != null) {
+ if (!addrs.equals(this.nameSrvAddr)) {
+ log.info("name server address changed, old=" + this.nameSrvAddr + ", new=" + addrs);
+ this.updateNameServerAddressList(addrs);
+ this.nameSrvAddr = addrs;
+ return nameSrvAddr;
+ }
+ }
+ } catch (Exception e) {
+ log.error("fetchNameServerAddr Exception", e);
+ }
+ return nameSrvAddr;
+ }
+
+ public void updateNameServerAddressList(final String addrs) {
+ List<String> lst = new ArrayList<String>();
+ String[] addrArray = addrs.split(";");
+ if (addrArray != null) {
+ for (String addr : addrArray) {
+ lst.add(addr);
+ }
+
+ this.remotingClient.updateNameServerAddressList(lst);
+ }
+ }
+
+ public void start() {
+ this.remotingClient.start();
+ }
+
+ public void shutdown() {
+ this.remotingClient.shutdown();
+ }
+
+ public void createSubscriptionGroup(final String addr, final SubscriptionGroupConfig config, final long timeoutMillis)
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_SUBSCRIPTIONGROUP, null);
+
+ byte[] body = RemotingSerializable.encode(config);
+ request.setBody(body);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return;
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+
+ }
+
+ public void createTopic(final String addr, final String defaultTopic, final TopicConfig topicConfig, final long timeoutMillis)
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ CreateTopicRequestHeader requestHeader = new CreateTopicRequestHeader();
+ requestHeader.setTopic(topicConfig.getTopicName());
+ requestHeader.setDefaultTopic(defaultTopic);
+ requestHeader.setReadQueueNums(topicConfig.getReadQueueNums());
+ requestHeader.setWriteQueueNums(topicConfig.getWriteQueueNums());
+ requestHeader.setPerm(topicConfig.getPerm());
+ requestHeader.setTopicFilterType(topicConfig.getTopicFilterType().name());
+ requestHeader.setTopicSysFlag(topicConfig.getTopicSysFlag());
+ requestHeader.setOrder(topicConfig.isOrder());
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_TOPIC, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return;
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+ public SendResult sendMessage(//
+ final String addr, // 1
+ final String brokerName, // 2
+ final Message msg, // 3
+ final SendMessageRequestHeader requestHeader, // 4
+ final long timeoutMillis, // 5
+ final CommunicationMode communicationMode, // 6
+ final SendMessageContext context, // 7
+ final DefaultMQProducerImpl producer // 8
+ ) throws RemotingException, MQBrokerException, InterruptedException {
+ return sendMessage(addr, brokerName, msg, requestHeader, timeoutMillis, communicationMode, null, null, null, 0, context, producer);
+ }
+
+ public SendResult sendMessage(//
+ final String addr, // 1
+ final String brokerName, // 2
+ final Message msg, // 3
+ final SendMessageRequestHeader requestHeader, // 4
+ final long timeoutMillis, // 5
+ final CommunicationMode communicationMode, // 6
+ final SendCallback sendCallback, // 7
+ final TopicPublishInfo topicPublishInfo, // 8
+ final MQClientInstance instance, // 9
+ final int retryTimesWhenSendFailed, // 10
+ final SendMessageContext context, // 11
+ final DefaultMQProducerImpl producer // 12
+ ) throws RemotingException, MQBrokerException, InterruptedException {
+ RemotingCommand request = null;
+ if (sendSmartMsg) {
+ SendMessageRequestHeaderV2 requestHeaderV2 = SendMessageRequestHeaderV2.createSendMessageRequestHeaderV2(requestHeader);
+ request = RemotingCommand.createRequestCommand(RequestCode.SEND_MESSAGE_V2, requestHeaderV2);
+ } else {
+ request = RemotingCommand.createRequestCommand(RequestCode.SEND_MESSAGE, requestHeader);
+ }
+
+ request.setBody(msg.getBody());
+
+ switch (communicationMode) {
+ case ONEWAY:
+ this.remotingClient.invokeOneway(addr, request, timeoutMillis);
+ return null;
+ case ASYNC:
+ final AtomicInteger times = new AtomicInteger();
+ this.sendMessageAsync(addr, brokerName, msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance,
+ retryTimesWhenSendFailed, times, context, producer);
+ return null;
+ case SYNC:
+ return this.sendMessageSync(addr, brokerName, msg, timeoutMillis, request);
+ default:
+ assert false;
+ break;
+ }
+
+ return null;
+ }
+
+ private SendResult sendMessageSync(//
+ final String addr, //
+ final String brokerName, //
+ final Message msg, //
+ final long timeoutMillis, //
+ final RemotingCommand request//
+ ) throws RemotingException, MQBrokerException, InterruptedException {
+ RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
+ assert response != null;
+ return this.processSendResponse(brokerName, msg, response);
+ }
+
+ private void sendMessageAsync(//
+ final String addr, //
+ final String brokerName, //
+ final Message msg, //
+ final long timeoutMillis, //
+ final RemotingCommand request, //
+ final SendCallback sendCallback, //
+ final TopicPublishInfo topicPublishInfo, //
+ final MQClientInstance instance, //
+ final int retryTimesWhenSendFailed, //
+ final AtomicInteger times, //
+ final SendMessageContext context, //
+ final DefaultMQProducerImpl producer //
+ ) throws InterruptedException, RemotingException {
+ this.remotingClient.invokeAsync(addr, request, timeoutMillis, new InvokeCallback() {
+ @Override
+ public void operationComplete(ResponseFuture responseFuture) {
+ RemotingCommand response = responseFuture.getResponseCommand();
+ if (null == sendCallback && response != null) {
+
+ try {
+ SendResult sendResult = MQClientAPIImpl.this.processSendResponse(brokerName, msg, response);
+ if (context != null && sendResult != null) {
+ context.setSendResult(sendResult);
+ context.getProducer().executeSendMessageHookAfter(context);
+ }
+ } catch (Throwable e) {
+ //
+ }
+
+ producer.updateFaultItem(brokerName, System.currentTimeMillis() - responseFuture.getBeginTimestamp(), false);
+ return;
+ }
+
+ if (response != null) {
+ try {
+ SendResult sendResult = MQClientAPIImpl.this.processSendResponse(brokerName, msg, response);
+ assert sendResult != null;
+ if (context != null) {
+ context.setSendResult(sendResult);
+ context.getProducer().executeSendMessageHookAfter(context);
+ }
+
+ try {
+ sendCallback.onSuccess(sendResult);
+ } catch (Throwable e) {
+ }
+
+ producer.updateFaultItem(brokerName, System.currentTimeMillis() - responseFuture.getBeginTimestamp(), false);
+ } catch (Exception e) {
+ producer.updateFaultItem(brokerName, System.currentTimeMillis() - responseFuture.getBeginTimestamp(), true);
+ onExceptionImpl(brokerName, msg, 0L, request, sendCallback, topicPublishInfo, instance,
+ retryTimesWhenSendFailed, times, e, context, false, producer);
+ }
+ } else {
+ producer.updateFaultItem(brokerName, System.currentTimeMillis() - responseFuture.getBeginTimestamp(), true);
+ if (!responseFuture.isSendRequestOK()) {
+ MQClientException ex = new MQClientException("send request failed", responseFuture.getCause());
+ onExceptionImpl(brokerName, msg, 0L, request, sendCallback, topicPublishInfo, instance,
+ retryTimesWhenSendFailed, times, ex, context, true, producer);
+ } else if (responseFuture.isTimeout()) {
+ MQClientException ex = new MQClientException("wait response timeout " + responseFuture.getTimeoutMillis() + "ms",
+ responseFuture.getCause());
+ onExceptionImpl(brokerName, msg, 0L, request, sendCallback, topicPublishInfo, instance,
+ retryTimesWhenSendFailed, times, ex, context, true, producer);
+ } else {
+ MQClientException ex = new MQClientException("unknow reseaon", responseFuture.getCause());
+ onExceptionImpl(brokerName, msg, 0L, request, sendCallback, topicPublishInfo, instance,
+ retryTimesWhenSendFailed, times, ex, context, true, producer);
+ }
+ }
+ }
+ });
+ }
+
+
+ private void onExceptionImpl(final String brokerName, //
+ final Message msg, //
+ final long timeoutMillis, //
+ final RemotingCommand request, //
+ final SendCallback sendCallback, //
+ final TopicPublishInfo topicPublishInfo, //
+ final MQClientInstance instance, //
+ final int timesTotal, //
+ final AtomicInteger curTimes, //
+ final Exception e, //
+ final SendMessageContext context, //
+ final boolean needRetry, //
+ final DefaultMQProducerImpl producer // 12
+ ) {
+ int tmp = curTimes.incrementAndGet();
+ if (needRetry && tmp <= timesTotal) {
+ MessageQueue tmpmq = producer.selectOneMessageQueue(topicPublishInfo, brokerName);
+ String addr = instance.findBrokerAddressInPublish(tmpmq.getBrokerName());
+ log.info("async send msg by retry {} times. topic={}, brokerAddr={}, brokerName={}", tmp, msg.getTopic(), addr,
+ tmpmq.getBrokerName());
+ try {
+ request.setOpaque(RemotingCommand.createNewRequestId());
+ sendMessageAsync(addr, tmpmq.getBrokerName(), msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance,
+ timesTotal, curTimes, context, producer);
+ } catch (InterruptedException e1) {
+ onExceptionImpl(tmpmq.getBrokerName(), msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance, timesTotal, curTimes, e1,
+ context, false, producer);
+ } catch (RemotingConnectException e1) {
+ producer.updateFaultItem(brokerName, 3000, true);
+ onExceptionImpl(tmpmq.getBrokerName(), msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance, timesTotal, curTimes, e1,
+ context, true, producer);
+ } catch (RemotingTooMuchRequestException e1) {
+ onExceptionImpl(tmpmq.getBrokerName(), msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance, timesTotal, curTimes, e1,
+ context, false, producer);
+ } catch (RemotingException e1) {
+ producer.updateFaultItem(brokerName, 3000, true);
+ onExceptionImpl(tmpmq.getBrokerName(), msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance, timesTotal, curTimes, e1,
+ context, true, producer);
+ }
+ } else {
+ if (context != null) {
+ context.setException(e);
+ context.getProducer().executeSendMessageHookAfter(context);
+ }
+ try {
+ sendCallback.onException(e);
+ } catch (Exception e2) {
+ }
+ }
+ }
+
+
+ private SendResult processSendResponse(//
+ final String brokerName, //
+ final Message msg, //
+ final RemotingCommand response//
+ ) throws MQBrokerException, RemotingCommandException {
+ switch (response.getCode()) {
+ case ResponseCode.FLUSH_DISK_TIMEOUT:
+ case ResponseCode.FLUSH_SLAVE_TIMEOUT:
+ case ResponseCode.SLAVE_NOT_AVAILABLE: {
+ // TODO LOG
+ }
+ case ResponseCode.SUCCESS: {
+ SendStatus sendStatus = SendStatus.SEND_OK;
+ switch (response.getCode()) {
+ case ResponseCode.FLUSH_DISK_TIMEOUT:
+ sendStatus = SendStatus.FLUSH_DISK_TIMEOUT;
+ break;
+ case ResponseCode.FLUSH_SLAVE_TIMEOUT:
+ sendStatus = SendStatus.FLUSH_SLAVE_TIMEOUT;
+ break;
+ case ResponseCode.SLAVE_NOT_AVAILABLE:
+ sendStatus = SendStatus.SLAVE_NOT_AVAILABLE;
+ break;
+ case ResponseCode.SUCCESS:
+ sendStatus = SendStatus.SEND_OK;
+ break;
+ default:
+ assert false;
+ break;
+ }
+
+ SendMessageResponseHeader responseHeader =
+ (SendMessageResponseHeader) response.decodeCommandCustomHeader(SendMessageResponseHeader.class);
+
+ MessageQueue messageQueue = new MessageQueue(msg.getTopic(), brokerName, responseHeader.getQueueId());
+
+ SendResult sendResult = new SendResult(sendStatus,
+ MessageClientIDSetter.getUniqID(msg),
+ responseHeader.getMsgId(), messageQueue, responseHeader.getQueueOffset());
+ sendResult.setTransactionId(responseHeader.getTransactionId());
+ String regionId = response.getExtFields().get(MessageConst.PROPERTY_MSG_REGION);
+ String traceOn = response.getExtFields().get(MessageConst.PROPERTY_TRACE_SWITCH);
+ if (regionId == null || regionId.isEmpty()) {
+ regionId = MixAll.DEFAULT_TRACE_REGION_ID;
+ }
+ if (traceOn != null && traceOn.equals("false")) {
+ sendResult.setTraceOn(false);
+ } else {
+ sendResult.setTraceOn(true);
+ }
+ sendResult.setRegionId(regionId);
+ return sendResult;
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public PullResult pullMessage(//
+ final String addr, //
+ final PullMessageRequestHeader requestHeader, //
+ final long timeoutMillis, //
+ final CommunicationMode communicationMode, //
+ final PullCallback pullCallback//
+ ) throws RemotingException, MQBrokerException, InterruptedException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.PULL_MESSAGE, requestHeader);
+
+ switch (communicationMode) {
+ case ONEWAY:
+ assert false;
+ return null;
+ case ASYNC:
+ this.pullMessageAsync(addr, request, timeoutMillis, pullCallback);
+ return null;
+ case SYNC:
+ return this.pullMessageSync(addr, request, timeoutMillis);
+ default:
+ assert false;
+ break;
+ }
+
+ return null;
+ }
+
+
+ private void pullMessageAsync(//
+ final String addr, // 1
+ final RemotingCommand request, //
+ final long timeoutMillis, //
+ final PullCallback pullCallback//
+ ) throws RemotingException, InterruptedException {
+ this.remotingClient.invokeAsync(addr, request, timeoutMillis, new InvokeCallback() {
+ @Override
+ public void operationComplete(ResponseFuture responseFuture) {
+ RemotingCommand response = responseFuture.getResponseCommand();
+ if (response != null) {
+ try {
+ PullResult pullResult = MQClientAPIImpl.this.processPullResponse(response);
+ assert pullResult != null;
+ pullCallback.onSuccess(pullResult);
+ } catch (Exception e) {
+ pullCallback.onException(e);
+ }
+ } else {
+ if (!responseFuture.isSendRequestOK()) {
+ pullCallback.onException(new MQClientException("send request failed", responseFuture.getCause()));
+ } else if (responseFuture.isTimeout()) {
+ pullCallback.onException(new MQClientException("wait response timeout " + responseFuture.getTimeoutMillis() + "ms",
+ responseFuture.getCause()));
+ } else {
+ pullCallback.onException(new MQClientException("unknow reseaon", responseFuture.getCause()));
+ }
+ }
+ }
+ });
+ }
+
+ private PullResult pullMessageSync(//
+ final String addr, // 1
+ final RemotingCommand request, // 2
+ final long timeoutMillis// 3
+ ) throws RemotingException, InterruptedException, MQBrokerException {
+ RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
+ assert response != null;
+ return this.processPullResponse(response);
+ }
+
+ private PullResult processPullResponse(final RemotingCommand response) throws MQBrokerException, RemotingCommandException {
+ PullStatus pullStatus = PullStatus.NO_NEW_MSG;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS:
+ pullStatus = PullStatus.FOUND;
+ break;
+ case ResponseCode.PULL_NOT_FOUND:
+ pullStatus = PullStatus.NO_NEW_MSG;
+ break;
+ case ResponseCode.PULL_RETRY_IMMEDIATELY:
+ pullStatus = PullStatus.NO_MATCHED_MSG;
+ break;
+ case ResponseCode.PULL_OFFSET_MOVED:
+ pullStatus = PullStatus.OFFSET_ILLEGAL;
+ break;
+
+ default:
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+ PullMessageResponseHeader responseHeader =
+ (PullMessageResponseHeader) response.decodeCommandCustomHeader(PullMessageResponseHeader.class);
+
+ return new PullResultExt(pullStatus, responseHeader.getNextBeginOffset(), responseHeader.getMinOffset(),
+ responseHeader.getMaxOffset(), null, responseHeader.getSuggestWhichBrokerId(), response.getBody());
+ }
+
+ public MessageExt viewMessage(final String addr, final long phyoffset, final long timeoutMillis)
+ throws RemotingException, MQBrokerException, InterruptedException {
+ ViewMessageRequestHeader requestHeader = new ViewMessageRequestHeader();
+ requestHeader.setOffset(phyoffset);
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.VIEW_MESSAGE_BY_ID, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ ByteBuffer byteBuffer = ByteBuffer.wrap(response.getBody());
+ MessageExt messageExt = MessageDecoder.clientDecode(byteBuffer, true);
+ return messageExt;
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public long searchOffset(final String addr, final String topic, final int queueId, final long timestamp, final long timeoutMillis)
+ throws RemotingException, MQBrokerException, InterruptedException {
+ SearchOffsetRequestHeader requestHeader = new SearchOffsetRequestHeader();
+ requestHeader.setTopic(topic);
+ requestHeader.setQueueId(queueId);
+ requestHeader.setTimestamp(timestamp);
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.SEARCH_OFFSET_BY_TIMESTAMP, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ SearchOffsetResponseHeader responseHeader =
+ (SearchOffsetResponseHeader) response.decodeCommandCustomHeader(SearchOffsetResponseHeader.class);
+ return responseHeader.getOffset();
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public long getMaxOffset(final String addr, final String topic, final int queueId, final long timeoutMillis)
+ throws RemotingException, MQBrokerException, InterruptedException {
+ GetMaxOffsetRequestHeader requestHeader = new GetMaxOffsetRequestHeader();
+ requestHeader.setTopic(topic);
+ requestHeader.setQueueId(queueId);
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_MAX_OFFSET, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ GetMaxOffsetResponseHeader responseHeader =
+ (GetMaxOffsetResponseHeader) response.decodeCommandCustomHeader(GetMaxOffsetResponseHeader.class);
+
+ return responseHeader.getOffset();
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public List<String> getConsumerIdListByGroup(//
+ final String addr, //
+ final String consumerGroup, //
+ final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
+ MQBrokerException, InterruptedException {
+ GetConsumerListByGroupRequestHeader requestHeader = new GetConsumerListByGroupRequestHeader();
+ requestHeader.setConsumerGroup(consumerGroup);
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_LIST_BY_GROUP, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ if (response.getBody() != null) {
+ GetConsumerListByGroupResponseBody body =
+ GetConsumerListByGroupResponseBody.decode(response.getBody(), GetConsumerListByGroupResponseBody.class);
+ return body.getConsumerIdList();
+ }
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public long getMinOffset(final String addr, final String topic, final int queueId, final long timeoutMillis)
+ throws RemotingException, MQBrokerException, InterruptedException {
+ GetMinOffsetRequestHeader requestHeader = new GetMinOffsetRequestHeader();
+ requestHeader.setTopic(topic);
+ requestHeader.setQueueId(queueId);
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_MIN_OFFSET, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ GetMinOffsetResponseHeader responseHeader =
+ (GetMinOffsetResponseHeader) response.decodeCommandCustomHeader(GetMinOffsetResponseHeader.class);
+
+ return responseHeader.getOffset();
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public long getEarliestMsgStoretime(final String addr, final String topic, final int queueId, final long timeoutMillis)
+ throws RemotingException, MQBrokerException, InterruptedException {
+ GetEarliestMsgStoretimeRequestHeader requestHeader = new GetEarliestMsgStoretimeRequestHeader();
+ requestHeader.setTopic(topic);
+ requestHeader.setQueueId(queueId);
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_EARLIEST_MSG_STORETIME, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ GetEarliestMsgStoretimeResponseHeader responseHeader =
+ (GetEarliestMsgStoretimeResponseHeader) response.decodeCommandCustomHeader(GetEarliestMsgStoretimeResponseHeader.class);
+
+ return responseHeader.getTimestamp();
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public long queryConsumerOffset(//
+ final String addr, //
+ final QueryConsumerOffsetRequestHeader requestHeader, //
+ final long timeoutMillis//
+ ) throws RemotingException, MQBrokerException, InterruptedException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CONSUMER_OFFSET, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ QueryConsumerOffsetResponseHeader responseHeader =
+ (QueryConsumerOffsetResponseHeader) response.decodeCommandCustomHeader(QueryConsumerOffsetResponseHeader.class);
+
+ return responseHeader.getOffset();
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public void updateConsumerOffset(//
+ final String addr, //
+ final UpdateConsumerOffsetRequestHeader requestHeader, //
+ final long timeoutMillis//
+ ) throws RemotingException, MQBrokerException, InterruptedException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_CONSUMER_OFFSET, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return;
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public void updateConsumerOffsetOneway(//
+ final String addr, //
+ final UpdateConsumerOffsetRequestHeader requestHeader, //
+ final long timeoutMillis//
+ ) throws RemotingConnectException, RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException,
+ InterruptedException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_CONSUMER_OFFSET, requestHeader);
+
+ this.remotingClient.invokeOneway(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
+ }
+
+
+ public void sendHearbeat(//
+ final String addr, //
+ final HeartbeatData heartbeatData, //
+ final long timeoutMillis//
+ ) throws RemotingException, MQBrokerException, InterruptedException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.HEART_BEAT, null);
+
+ request.setBody(heartbeatData.encode());
+ RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return;
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public void unregisterClient(//
+ final String addr, //
+ final String clientID, //
+ final String producerGroup, //
+ final String consumerGroup, //
+ final long timeoutMillis//
+ ) throws RemotingException, MQBrokerException, InterruptedException {
+ final UnregisterClientRequestHeader requestHeader = new UnregisterClientRequestHeader();
+ requestHeader.setClientID(clientID);
+ requestHeader.setProducerGroup(producerGroup);
+ requestHeader.setConsumerGroup(consumerGroup);
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UNREGISTER_CLIENT, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return;
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public void endTransactionOneway(//
+ final String addr, //
+ final EndTransactionRequestHeader requestHeader, //
+ final String remark, //
+ final long timeoutMillis//
+ ) throws RemotingException, MQBrokerException, InterruptedException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.END_TRANSACTION, requestHeader);
+
+ request.setRemark(remark);
+ this.remotingClient.invokeOneway(addr, request, timeoutMillis);
+ }
+
+
+ public void queryMessage(
+ final String addr,
+ final QueryMessageRequestHeader requestHeader,
+ final long timeoutMillis,
+ final InvokeCallback invokeCallback,
+ final Boolean isUnqiueKey
+ ) throws RemotingException, MQBrokerException, InterruptedException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_MESSAGE, requestHeader);
+ request.addExtField(MixAll.UNIQUE_MSG_QUERY_FLAG, isUnqiueKey.toString());
+ this.remotingClient.invokeAsync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis,
+ invokeCallback);
+ }
+
+
+ public boolean registerClient(final String addr, final HeartbeatData heartbeat, final long timeoutMillis)
+ throws RemotingException, InterruptedException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.HEART_BEAT, null);
+
+ request.setBody(heartbeat.encode());
+ RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
+ return response.getCode() == ResponseCode.SUCCESS;
+ }
+
+
+ public void consumerSendMessageBack(
+ final String addr,
+ final MessageExt msg,
+ final String consumerGroup,
+ final int delayLevel,
+ final long timeoutMillis,
+ final int maxConsumeRetryTimes
+ ) throws RemotingException, MQBrokerException, InterruptedException {
+ ConsumerSendMsgBackRequestHeader requestHeader = new ConsumerSendMsgBackRequestHeader();
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.CONSUMER_SEND_MSG_BACK, requestHeader);
+
+ requestHeader.setGroup(consumerGroup);
+ requestHeader.setOriginTopic(msg.getTopic());
+ requestHeader.setOffset(msg.getCommitLogOffset());
+ requestHeader.setDelayLevel(delayLevel);
+ requestHeader.setOriginMsgId(msg.getMsgId());
+ requestHeader.setMaxReconsumeTimes(maxConsumeRetryTimes);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return;
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public Set<MessageQueue> lockBatchMQ(//
+ final String addr, //
+ final LockBatchRequestBody requestBody, //
+ final long timeoutMillis) throws RemotingException, MQBrokerException, InterruptedException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.LOCK_BATCH_MQ, null);
+
+ request.setBody(requestBody.encode());
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ LockBatchResponseBody responseBody = LockBatchResponseBody.decode(response.getBody(), LockBatchResponseBody.class);
+ Set<MessageQueue> messageQueues = responseBody.getLockOKMQSet();
+ return messageQueues;
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public void unlockBatchMQ(//
+ final String addr, //
+ final UnlockBatchRequestBody requestBody, //
+ final long timeoutMillis, //
+ final boolean oneway//
+ ) throws RemotingException, MQBrokerException, InterruptedException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UNLOCK_BATCH_MQ, null);
+
+ request.setBody(requestBody.encode());
+
+ if (oneway) {
+ this.remotingClient.invokeOneway(addr, request, timeoutMillis);
+ } else {
+ RemotingCommand response = this.remotingClient
+ .invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return;
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+ }
+
+
+ public TopicStatsTable getTopicStatsInfo(final String addr, final String topic, final long timeoutMillis) throws InterruptedException,
+ RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
+ GetTopicStatsInfoRequestHeader requestHeader = new GetTopicStatsInfoRequestHeader();
+ requestHeader.setTopic(topic);
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPIC_STATS_INFO, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ TopicStatsTable topicStatsTable = TopicStatsTable.decode(response.getBody(), TopicStatsTable.class);
+ return topicStatsTable;
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public ConsumeStats getConsumeStats(final String addr, final String consumerGroup, final long timeoutMillis)
+ throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException,
+ MQBrokerException {
+ return getConsumeStats(addr, consumerGroup, null, timeoutMillis);
+ }
+
+
+ public ConsumeStats getConsumeStats(final String addr, final String consumerGroup, final String topic, final long timeoutMillis)
+ throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException,
+ MQBrokerException {
+ GetConsumeStatsRequestHeader requestHeader = new GetConsumeStatsRequestHeader();
+ requestHeader.setConsumerGroup(consumerGroup);
+ requestHeader.setTopic(topic);
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUME_STATS, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ ConsumeStats consumeStats = ConsumeStats.decode(response.getBody(), ConsumeStats.class);
+ return consumeStats;
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public ProducerConnection getProducerConnectionList(final String addr, final String producerGroup, final long timeoutMillis)
+ throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
+ MQBrokerException {
+ GetProducerConnectionListRequestHeader requestHeader = new GetProducerConnectionListRequestHeader();
+ requestHeader.setProducerGroup(producerGroup);
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_PRODUCER_CONNECTION_LIST, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return ProducerConnection.decode(response.getBody(), ProducerConnection.class);
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public ConsumerConnection getConsumerConnectionList(final String addr, final String consumerGroup, final long timeoutMillis)
+ throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
+ MQBrokerException {
+ GetConsumerConnectionListRequestHeader requestHeader = new GetConsumerConnectionListRequestHeader();
+ requestHeader.setConsumerGroup(consumerGroup);
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_CONNECTION_LIST, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ ConsumerConnection consumerConnection = ConsumerConnection.decode(response.getBody(), ConsumerConnection.class);
+ return consumerConnection;
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public KVTable getBrokerRuntimeInfo(final String addr, final long timeoutMillis) throws RemotingConnectException,
+ RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException {
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_RUNTIME_INFO, null);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return KVTable.decode(response.getBody(), KVTable.class);
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public void updateBrokerConfig(final String addr, final Properties properties, final long timeoutMillis)
+ throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
+ MQBrokerException, UnsupportedEncodingException {
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_BROKER_CONFIG, null);
+
+ String str = MixAll.properties2String(properties);
+ if (str != null && str.length() > 0) {
+ request.setBody(str.getBytes(MixAll.DEFAULT_CHARSET));
+ RemotingCommand response = this.remotingClient
+ .invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return;
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+ }
+
+
+ public Properties getBrokerConfig(final String addr, final long timeoutMillis)
+ throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
+ MQBrokerException, UnsupportedEncodingException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_CONFIG, null);
+
+ RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return MixAll.string2Properties(new String(response.getBody(), MixAll.DEFAULT_CHARSET));
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+ public ClusterInfo getBrokerClusterInfo(final long timeoutMillis) throws InterruptedException, RemotingTimeoutException,
+ RemotingSendRequestException, RemotingConnectException, MQBrokerException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_CLUSTER_INFO, null);
+
+ RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ ClusterInfo responseBody = ClusterInfo.decode(response.getBody(), ClusterInfo.class);
+ return responseBody;
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public TopicRouteData getDefaultTopicRouteInfoFromNameServer(final String topic, final long timeoutMillis)
+ throws RemotingException, MQClientException, InterruptedException {
+ GetRouteInfoRequestHeader requestHeader = new GetRouteInfoRequestHeader();
+ requestHeader.setTopic(topic);
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ROUTEINTO_BY_TOPIC, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.TOPIC_NOT_EXIST: {
+ // TODO LOG
+ break;
+ }
+ case ResponseCode.SUCCESS: {
+ byte[] body = response.getBody();
+ if (body != null) {
+ return TopicRouteData.decode(body, TopicRouteData.class);
+ }
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public TopicRouteData getTopicRouteInfoFromNameServer(final String topic, final long timeoutMillis)
+ throws RemotingException, MQClientException, InterruptedException {
+ GetRouteInfoRequestHeader requestHeader = new GetRouteInfoRequestHeader();
+ requestHeader.setTopic(topic);
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ROUTEINTO_BY_TOPIC, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.TOPIC_NOT_EXIST: {
+ if (!topic.equals(MixAll.DEFAULT_TOPIC))
+ log.warn("get Topic [{}] RouteInfoFromNameServer is not exist value", topic);
+ break;
+ }
+ case ResponseCode.SUCCESS: {
+ byte[] body = response.getBody();
+ if (body != null) {
+ return TopicRouteData.decode(body, TopicRouteData.class);
+ }
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public TopicList getTopicListFromNameServer(final long timeoutMillis)
+ throws RemotingException, MQClientException, InterruptedException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_LIST_FROM_NAMESERVER, null);
+
+ RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ byte[] body = response.getBody();
+ if (body != null) {
+ TopicList topicList = TopicList.decode(body, TopicList.class);
+ return topicList;
+ }
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public int wipeWritePermOfBroker(final String namesrvAddr, String brokerName, final long timeoutMillis) throws RemotingCommandException,
+ RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQClientException {
+ WipeWritePermOfBrokerRequestHeader requestHeader = new WipeWritePermOfBrokerRequestHeader();
+ requestHeader.setBrokerName(brokerName);
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.WIPE_WRITE_PERM_OF_BROKER, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(namesrvAddr, request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ WipeWritePermOfBrokerResponseHeader responseHeader =
+ (WipeWritePermOfBrokerResponseHeader) response.decodeCommandCustomHeader(WipeWritePermOfBrokerResponseHeader.class);
+ return responseHeader.getWipeTopicCount();
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public void deleteTopicInBroker(final String addr, final String topic, final long timeoutMillis)
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ DeleteTopicRequestHeader requestHeader = new DeleteTopicRequestHeader();
+ requestHeader.setTopic(topic);
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.DELETE_TOPIC_IN_BROKER, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return;
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public void deleteTopicInNameServer(final String addr, final String topic, final long timeoutMillis)
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ DeleteTopicRequestHeader requestHeader = new DeleteTopicRequestHeader();
+ requestHeader.setTopic(topic);
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.DELETE_TOPIC_IN_NAMESRV, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return;
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public void deleteSubscriptionGroup(final String addr, final String groupName, final long timeoutMillis)
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ DeleteSubscriptionGroupRequestHeader requestHeader = new DeleteSubscriptionGroupRequestHeader();
+ requestHeader.setGroupName(groupName);
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.DELETE_SUBSCRIPTIONGROUP, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return;
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public String getKVConfigValue(final String namespace, final String key, final long timeoutMillis)
+ throws RemotingException, MQClientException, InterruptedException {
+ GetKVConfigRequestHeader requestHeader = new GetKVConfigRequestHeader();
+ requestHeader.setNamespace(namespace);
+ requestHeader.setKey(key);
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_KV_CONFIG, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ GetKVConfigResponseHeader responseHeader =
+ (GetKVConfigResponseHeader) response.decodeCommandCustomHeader(GetKVConfigResponseHeader.class);
+ return responseHeader.getValue();
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public void putKVConfigValue(final String namespace, final String key, final String value, final long timeoutMillis)
+ throws RemotingException, MQClientException, InterruptedException {
+ PutKVConfigRequestHeader requestHeader = new PutKVConfigRequestHeader();
+ requestHeader.setNamespace(namespace);
+ requestHeader.setKey(key);
+ requestHeader.setValue(value);
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.PUT_KV_CONFIG, requestHeader);
+
+ List<String> nameServerAddressList = this.remotingClient.getNameServerAddressList();
+ if (nameServerAddressList != null) {
+ RemotingCommand errResponse = null;
+ for (String namesrvAddr : nameServerAddressList) {
+ RemotingCommand response = this.remotingClient.invokeSync(namesrvAddr, request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ break;
+ }
+ default:
+ errResponse = response;
+ }
+ }
+
+ if (errResponse != null) {
+ throw new MQClientException(errResponse.getCode(), errResponse.getRemark());
+ }
+ }
+ }
+
+
+ public void deleteKVConfigValue(final String namespace, final String key, final long timeoutMillis)
+ throws RemotingException, MQClientException, InterruptedException {
+ DeleteKVConfigRequestHeader requestHeader = new DeleteKVConfigRequestHeader();
+ requestHeader.setNamespace(namespace);
+ requestHeader.setKey(key);
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.DELETE_KV_CONFIG, requestHeader);
+
+ List<String> nameServerAddressList = this.remotingClient.getNameServerAddressList();
+ if (nameServerAddressList != null) {
+ RemotingCommand errResponse = null;
+ for (String namesrvAddr : nameServerAddressList) {
+ RemotingCommand response = this.remotingClient.invokeSync(namesrvAddr, request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ break;
+ }
+ default:
+ errResponse = response;
+ }
+ }
+ if (errResponse != null) {
+ throw new MQClientException(errResponse.getCode(), errResponse.getRemark());
+ }
+ }
+ }
+
+
+ public KVTable getKVListByNamespace(final String namespace, final long timeoutMillis)
+ throws RemotingException, MQClientException, InterruptedException {
+ GetKVListByNamespaceRequestHeader requestHeader = new GetKVListByNamespaceRequestHeader();
+ requestHeader.setNamespace(namespace);
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_KVLIST_BY_NAMESPACE, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return KVTable.decode(response.getBody(), KVTable.class);
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public Map<MessageQueue, Long> invokeBrokerToResetOffset(final String addr, final String topic, final String group,
+ final long timestamp, final boolean isForce, final long timeoutMillis)
+ throws RemotingException, MQClientException, InterruptedException {
+ return invokeBrokerToResetOffset(addr, topic, group, timestamp, isForce, timeoutMillis, false);
+ }
+
+
+ public Map<MessageQueue, Long> invokeBrokerToResetOffset(final String addr, final String topic, final String group,
+ final long timestamp, final boolean isForce, final long timeoutMillis, boolean isC)
+ throws RemotingException, MQClientException, InterruptedException {
+ ResetOffsetRequestHeader requestHeader = new ResetOffsetRequestHeader();
+ requestHeader.setTopic(topic);
+ requestHeader.setGroup(group);
+ requestHeader.setTimestamp(timestamp);
+ requestHeader.setForce(isForce);
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.INVOKE_BROKER_TO_RESET_OFFSET, requestHeader);
+ if (isC) {
+ request.setLanguage(LanguageCode.CPP);
+ }
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ if (response.getBody() != null) {
+ ResetOffsetBody body = ResetOffsetBody.decode(response.getBody(), ResetOffsetBody.class);
+ return body.getOffsetTable();
+ }
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public Map<String, Map<MessageQueue, Long>> invokeBrokerToGetConsumerStatus(final String addr, final String topic, final String group,
+ final String clientAddr, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
+ GetConsumerStatusRequestHeader requestHeader = new GetConsumerStatusRequestHeader();
+ requestHeader.setTopic(topic);
+ requestHeader.setGroup(group);
+ requestHeader.setClientAddr(clientAddr);
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.INVOKE_BROKER_TO_GET_CONSUMER_STATUS, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ if (response.getBody() != null) {
+ GetConsumerStatusBody body = GetConsumerStatusBody.decode(response.getBody(), GetConsumerStatusBody.class);
+ return body.getConsumerTable();
+ }
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public GroupList queryTopicConsumeByWho(final String addr, final String topic, final long timeoutMillis)
+ throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
+ MQBrokerException {
+ QueryTopicConsumeByWhoRequestHeader requestHeader = new QueryTopicConsumeByWhoRequestHeader();
+ requestHeader.setTopic(topic);
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_TOPIC_CONSUME_BY_WHO, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ GroupList groupList = GroupList.decode(response.getBody(), GroupList.class);
+ return groupList;
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public List<QueueTimeSpan> queryConsumeTimeSpan(final String addr, final String topic, final String group, final long timeoutMillis)
+ throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
+ MQBrokerException {
+ QueryConsumeTimeSpanRequestHeader requestHeader = new QueryConsumeTimeSpanRequestHeader();
+ requestHeader.setTopic(topic);
+ requestHeader.setGroup(group);
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CONSUME_TIME_SPAN, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ QueryConsumeTimeSpanBody consumeTimeSpanBody = GroupList.decode(response.getBody(), QueryConsumeTimeSpanBody.class);
+ return consumeTimeSpanBody.getConsumeTimeSpanSet();
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public TopicList getTopicsByCluster(final String cluster, final long timeoutMillis)
+ throws RemotingException, MQClientException, InterruptedException {
+ GetTopicsByClusterRequestHeader requestHeader = new GetTopicsByClusterRequestHeader();
+ requestHeader.setCluster(cluster);
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPICS_BY_CLUSTER, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ byte[] body = response.getBody();
+ if (body != null) {
+ TopicList topicList = TopicList.decode(body, TopicList.class);
+ return topicList;
+ }
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public void registerMessageFilterClass(final String addr, //
+ final String consumerGroup, //
+ final String topic, //
+ final String className, //
+ final int classCRC, //
+ final byte[] classBody, //
+ final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
+ InterruptedException, MQBrokerException {
+ RegisterMessageFilterClassRequestHeader requestHeader = new RegisterMessageFilterClassRequestHeader();
+ requestHeader.setConsumerGroup(consumerGroup);
+ requestHeader.setClassName(className);
+ requestHeader.setTopic(topic);
+ requestHeader.setClassCRC(classCRC);
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.REGISTER_MESSAGE_FILTER_CLASS, requestHeader);
+ request.setBody(classBody);
+ RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return;
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+
+ public TopicList getSystemTopicList(final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_SYSTEM_TOPIC_LIST_FROM_NS, null);
+
+ RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ byte[] body = response.getBody();
+ if (body != null) {
+ TopicList topicList = TopicList.decode(response.getBody(), TopicList.class);
+ if (topicList.getTopicList() != null && !topicList.getTopicList().isEmpty()
+ && !UtilAll.isBlank(topicList.getBrokerAddr())) {
+ TopicList tmp = getSystemTopicListFromBroker(topicList.getBrokerAddr(), timeoutMillis);
+ if (tmp.getTopicList() != null && !tmp.getTopicList().isEmpty()) {
+ topicList.getTopicList().addAll(tmp.getTopicList());
+ }
+ }
+ return topicList;
+ }
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public TopicList getSystemTopicListFromBroker(final String addr, final long timeoutMillis)
+ throws RemotingException, MQClientException, InterruptedException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_SYSTEM_TOPIC_LIST_FROM_BROKER, null);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ byte[] body = response.getBody();
+ if (body != null) {
+ TopicList topicList = TopicList.decode(body, TopicList.class);
+ return topicList;
+ }
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public boolean cleanExpiredConsumeQueue(final String addr, long timeoutMillis) throws MQClientException, RemotingConnectException,
+ RemotingSendRequestException, RemotingTimeoutException, InterruptedException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.CLEAN_EXPIRED_CONSUMEQUEUE, null);
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return true;
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public boolean cleanUnusedTopicByAddr(final String addr, long timeoutMillis) throws MQClientException, RemotingConnectException,
+ RemotingSendRequestException, RemotingTimeoutException, InterruptedException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.CLEAN_UNUSED_TOPIC, null);
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return true;
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+ public ConsumerRunningInfo getConsumerRunningInfo(final String addr, String consumerGroup, String clientId, boolean jstack,
+ final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
+ GetConsumerRunningInfoRequestHeader requestHeader = new GetConsumerRunningInfoRequestHeader();
+ requestHeader.setConsumerGroup(consumerGroup);
+ requestHeader.setClientId(clientId);
+ requestHeader.setJstackEnable(jstack);
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_RUNNING_INFO, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ byte[] body = response.getBody();
+ if (body != null) {
+ ConsumerRunningInfo info = ConsumerRunningInfo.decode(body, ConsumerRunningInfo.class);
+ return info;
+ }
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+ public ConsumeMessageDirectlyResult consumeMessageDirectly(final String addr, //
+ String consumerGroup, //
+ String clientId, //
+ String msgId, //
+ final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
+ ConsumeMessageDirectlyResultRequestHeader requestHeader = new ConsumeMessageDirectlyResultRequestHeader();
+ requestHeader.setConsumerGroup(consumerGroup);
+ requestHeader.setClientId(clientId);
+ requestHeader.setMsgId(msgId);
+
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.CONSUME_MESSAGE_DIRECTLY, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ byte[] body = response.getBody();
+ if (body != null) {
+ ConsumeMessageDirectlyResult info = ConsumeMessageDirectlyResult.decode(body, ConsumeMessageDirectlyResult.class);
+ return info;
+ }
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+ public Map<Integer, Long> queryCorrectionOffset(final String addr, final String topic, final String group, Set<String> filterGroup,
+ long timeoutMillis) throws MQClientException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
+ InterruptedException {
+ QueryCorrectionOffsetHeader requestHeader = new QueryCorrectionOffsetHeader();
+ requestHeader.setCompareGroup(group);
+ requestHeader.setTopic(topic);
+ if (filterGroup != null) {
+ StringBuilder sb = new StringBuilder();
+ String splitor = "";
+ for (String s : filterGroup) {
+ sb.append(splitor).append(s);
+ splitor = ",";
+ }
+ requestHeader.setFilterGroups(sb.toString());
+ }
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CORRECTION_OFFSET, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ if (response.getBody() != null) {
+ QueryCorrectionOffsetBody body = QueryCorrectionOffsetBody.decode(response.getBody(), QueryCorrectionOffsetBody.class);
+ return body.getCorrectionOffsets();
+ }
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+ public TopicList getUnitTopicList(final boolean containRetry, final long timeoutMillis)
+ throws RemotingException, MQClientException, InterruptedException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_UNIT_TOPIC_LIST, null);
+
+ RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ byte[] body = response.getBody();
+ if (body != null) {
+ TopicList topicList = TopicList.decode(response.getBody(), TopicList.class);
+ if (!containRetry) {
+ Iterator<String> it = topicList.getTopicList().iterator();
+ while (it.hasNext()) {
+ String topic = it.next();
+ if (topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX))
+ it.remove();
+ }
+ }
+
+ return topicList;
+ }
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public TopicList getHasUnitSubTopicList(final boolean containRetry, final long timeoutMillis)
+ throws RemotingException, MQClientException, InterruptedException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_HAS_UNIT_SUB_TOPIC_LIST, null);
+
+ RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ byte[] body = response.getBody();
+ if (body != null) {
+ TopicList topicList = TopicList.decode(response.getBody(), TopicList.class);
+ if (!containRetry) {
+ Iterator<String> it = topicList.getTopicList().iterator();
+ while (it.hasNext()) {
+ String topic = it.next();
+ if (topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX))
+ it.remove();
+ }
+ }
+ return topicList;
+ }
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public TopicList getHasUnitSubUnUnitTopicList(final boolean containRetry, final long timeoutMillis)
+ throws RemotingException, MQClientException, InterruptedException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_HAS_UNIT_SUB_UNUNIT_TOPIC_LIST, null);
+
+ RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ byte[] body = response.getBody();
+ if (body != null) {
+ TopicList topicList = TopicList.decode(response.getBody(), TopicList.class);
+ if (!containRetry) {
+ Iterator<String> it = topicList.getTopicList().iterator();
+ while (it.hasNext()) {
+ String topic = it.next();
+ if (topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX))
+ it.remove();
+ }
+ }
+ return topicList;
+ }
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public void cloneGroupOffset(final String addr, final String srcGroup, final String destGroup, final String topic,
+ final boolean isOffline, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
+ CloneGroupOffsetRequestHeader requestHeader = new CloneGroupOffsetRequestHeader();
+ requestHeader.setSrcGroup(srcGroup);
+ requestHeader.setDestGroup(destGroup);
+ requestHeader.setTopic(topic);
+ requestHeader.setOffline(isOffline);
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.CLONE_GROUP_OFFSET, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
+ request, timeoutMillis);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return;
+ }
+ default:
+ break;
+ }
+
+ throw new MQClientException(response.getCode(), response.getRemark());
+ }
+
+
+ public BrokerStatsData viewBrokerStatsData(String brokerAddr, String statsName, String statsKey, long timeoutMillis)
+ throws MQClientException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
+ InterruptedException {
+ ViewBrokerStatsDataRequestHeader request
<TRUNCATED>
[20/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..070635a
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java
@@ -0,0 +1,380 @@
+/**
+ * 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.producer;
+
+import org.apache.rocketmq.client.ClientConfig;
+import org.apache.rocketmq.client.QueryResult;
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+import org.apache.rocketmq.common.message.*;
+
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class DefaultMQProducer extends ClientConfig implements MQProducer {
+ protected final transient DefaultMQProducerImpl defaultMQProducerImpl;
+ private String producerGroup;
+ /**
+ * Just for testing or demo program
+ */
+ private String createTopicKey = MixAll.DEFAULT_TOPIC;
+ private volatile int defaultTopicQueueNums = 4;
+ private int sendMsgTimeout = 3000;
+ private int compressMsgBodyOverHowmuch = 1024 * 4;
+ private int retryTimesWhenSendFailed = 2;
+ private int retryTimesWhenSendAsyncFailed = 2;
+
+ private boolean retryAnotherBrokerWhenNotStoreOK = false;
+ private int maxMessageSize = 1024 * 1024 * 4; // 4M
+ public DefaultMQProducer() {
+ this(MixAll.DEFAULT_PRODUCER_GROUP, null);
+ }
+
+
+ public DefaultMQProducer(final String producerGroup, RPCHook rpcHook) {
+ this.producerGroup = producerGroup;
+ defaultMQProducerImpl = new DefaultMQProducerImpl(this, rpcHook);
+ }
+
+
+ public DefaultMQProducer(final String producerGroup) {
+ this(producerGroup, null);
+ }
+
+
+ public DefaultMQProducer(RPCHook rpcHook) {
+ this(MixAll.DEFAULT_PRODUCER_GROUP, rpcHook);
+ }
+
+
+ @Override
+ public void start() throws MQClientException {
+ this.defaultMQProducerImpl.start();
+ }
+
+ @Override
+ public void shutdown() {
+ this.defaultMQProducerImpl.shutdown();
+ }
+
+
+ @Override
+ public List<MessageQueue> fetchPublishMessageQueues(String topic) throws MQClientException {
+ return this.defaultMQProducerImpl.fetchPublishMessageQueues(topic);
+ }
+
+
+ @Override
+ public SendResult send(Message msg) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ return this.defaultMQProducerImpl.send(msg);
+ }
+
+
+ @Override
+ public SendResult send(Message msg, long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ return this.defaultMQProducerImpl.send(msg, timeout);
+ }
+
+
+ @Override
+ public void send(Message msg, SendCallback sendCallback) throws MQClientException, RemotingException, InterruptedException {
+ this.defaultMQProducerImpl.send(msg, sendCallback);
+ }
+
+
+ @Override
+ public void send(Message msg, SendCallback sendCallback, long timeout)
+ throws MQClientException, RemotingException, InterruptedException {
+ this.defaultMQProducerImpl.send(msg, sendCallback, timeout);
+ }
+
+
+ @Override
+ public void sendOneway(Message msg) throws MQClientException, RemotingException, InterruptedException {
+ this.defaultMQProducerImpl.sendOneway(msg);
+ }
+
+
+ @Override
+ public SendResult send(Message msg, MessageQueue mq)
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ return this.defaultMQProducerImpl.send(msg, mq);
+ }
+
+
+ @Override
+ public SendResult send(Message msg, MessageQueue mq, long timeout)
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ return this.defaultMQProducerImpl.send(msg, mq, timeout);
+ }
+
+
+ @Override
+ public void send(Message msg, MessageQueue mq, SendCallback sendCallback)
+ throws MQClientException, RemotingException, InterruptedException {
+ this.defaultMQProducerImpl.send(msg, mq, sendCallback);
+ }
+
+
+ @Override
+ public void send(Message msg, MessageQueue mq, SendCallback sendCallback, long timeout)
+ throws MQClientException, RemotingException, InterruptedException {
+ this.defaultMQProducerImpl.send(msg, mq, sendCallback, timeout);
+ }
+
+
+ @Override
+ public void sendOneway(Message msg, MessageQueue mq) throws MQClientException, RemotingException, InterruptedException {
+ this.defaultMQProducerImpl.sendOneway(msg, mq);
+ }
+
+
+ @Override
+ public SendResult send(Message msg, MessageQueueSelector selector, Object arg)
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ return this.defaultMQProducerImpl.send(msg, selector, arg);
+ }
+
+
+ @Override
+ public SendResult send(Message msg, MessageQueueSelector selector, Object arg, long timeout)
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ return this.defaultMQProducerImpl.send(msg, selector, arg, timeout);
+ }
+
+
+ @Override
+ public void send(Message msg, MessageQueueSelector selector, Object arg, SendCallback sendCallback)
+ throws MQClientException, RemotingException, InterruptedException {
+ this.defaultMQProducerImpl.send(msg, selector, arg, sendCallback);
+ }
+
+
+ @Override
+ public void send(Message msg, MessageQueueSelector selector, Object arg, SendCallback sendCallback, long timeout)
+ throws MQClientException, RemotingException, InterruptedException {
+ this.defaultMQProducerImpl.send(msg, selector, arg, sendCallback, timeout);
+ }
+
+
+ @Override
+ public void sendOneway(Message msg, MessageQueueSelector selector, Object arg)
+ throws MQClientException, RemotingException, InterruptedException {
+ this.defaultMQProducerImpl.sendOneway(msg, selector, arg);
+ }
+
+
+ @Override
+ public TransactionSendResult sendMessageInTransaction(Message msg, LocalTransactionExecuter tranExecuter, final Object arg)
+ throws MQClientException {
+ throw new RuntimeException("sendMessageInTransaction not implement, please use TransactionMQProducer class");
+ }
+
+
+ @Override
+ public void createTopic(String key, String newTopic, int queueNum) throws MQClientException {
+ createTopic(key, newTopic, queueNum, 0);
+ }
+
+
+ @Override
+ public void createTopic(String key, String newTopic, int queueNum, int topicSysFlag) throws MQClientException {
+ this.defaultMQProducerImpl.createTopic(key, newTopic, queueNum, topicSysFlag);
+ }
+
+
+ @Override
+ public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
+ return this.defaultMQProducerImpl.searchOffset(mq, timestamp);
+ }
+
+
+ @Override
+ public long maxOffset(MessageQueue mq) throws MQClientException {
+ return this.defaultMQProducerImpl.maxOffset(mq);
+ }
+
+
+ @Override
+ public long minOffset(MessageQueue mq) throws MQClientException {
+ return this.defaultMQProducerImpl.minOffset(mq);
+ }
+
+
+ @Override
+ public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
+ return this.defaultMQProducerImpl.earliestMsgStoreTime(mq);
+ }
+
+
+ @Override
+ public MessageExt viewMessage(String offsetMsgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ return this.defaultMQProducerImpl.viewMessage(offsetMsgId);
+ }
+
+
+ @Override
+ public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
+ throws MQClientException, InterruptedException {
+ return this.defaultMQProducerImpl.queryMessage(topic, key, maxNum, begin, end);
+ }
+
+
+ @Override
+ public MessageExt viewMessage(String topic, String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ try {
+ MessageId oldMsgId = MessageDecoder.decodeMessageId(msgId);
+ return this.viewMessage(msgId);
+ } catch (Exception e) {
+ }
+ return this.defaultMQProducerImpl.queryMessageByUniqKey(topic, msgId);
+ }
+
+ public String getProducerGroup() {
+ return producerGroup;
+ }
+
+
+ public void setProducerGroup(String producerGroup) {
+ this.producerGroup = producerGroup;
+ }
+
+
+ public String getCreateTopicKey() {
+ return createTopicKey;
+ }
+
+
+ public void setCreateTopicKey(String createTopicKey) {
+ this.createTopicKey = createTopicKey;
+ }
+
+
+ public int getSendMsgTimeout() {
+ return sendMsgTimeout;
+ }
+
+
+ public void setSendMsgTimeout(int sendMsgTimeout) {
+ this.sendMsgTimeout = sendMsgTimeout;
+ }
+
+
+ public int getCompressMsgBodyOverHowmuch() {
+ return compressMsgBodyOverHowmuch;
+ }
+
+
+ public void setCompressMsgBodyOverHowmuch(int compressMsgBodyOverHowmuch) {
+ this.compressMsgBodyOverHowmuch = compressMsgBodyOverHowmuch;
+ }
+
+
+ public DefaultMQProducerImpl getDefaultMQProducerImpl() {
+ return defaultMQProducerImpl;
+ }
+
+
+ public boolean isRetryAnotherBrokerWhenNotStoreOK() {
+ return retryAnotherBrokerWhenNotStoreOK;
+ }
+
+
+ public void setRetryAnotherBrokerWhenNotStoreOK(boolean retryAnotherBrokerWhenNotStoreOK) {
+ this.retryAnotherBrokerWhenNotStoreOK = retryAnotherBrokerWhenNotStoreOK;
+ }
+
+
+ public int getMaxMessageSize() {
+ return maxMessageSize;
+ }
+
+
+ public void setMaxMessageSize(int maxMessageSize) {
+ this.maxMessageSize = maxMessageSize;
+ }
+
+
+ public int getDefaultTopicQueueNums() {
+ return defaultTopicQueueNums;
+ }
+
+
+ public void setDefaultTopicQueueNums(int defaultTopicQueueNums) {
+ this.defaultTopicQueueNums = defaultTopicQueueNums;
+ }
+
+
+ public int getRetryTimesWhenSendFailed() {
+ return retryTimesWhenSendFailed;
+ }
+
+
+ public void setRetryTimesWhenSendFailed(int retryTimesWhenSendFailed) {
+ this.retryTimesWhenSendFailed = retryTimesWhenSendFailed;
+ }
+
+
+ public boolean isSendMessageWithVIPChannel() {
+ return isVipChannelEnabled();
+ }
+
+
+ public void setSendMessageWithVIPChannel(final boolean sendMessageWithVIPChannel) {
+ this.setVipChannelEnabled(sendMessageWithVIPChannel);
+ }
+
+
+ public long[] getNotAvailableDuration() {
+ return this.defaultMQProducerImpl.getNotAvailableDuration();
+ }
+
+ public void setNotAvailableDuration(final long[] notAvailableDuration) {
+ this.defaultMQProducerImpl.setNotAvailableDuration(notAvailableDuration);
+ }
+
+ public long[] getLatencyMax() {
+ return this.defaultMQProducerImpl.getLatencyMax();
+ }
+
+ public void setLatencyMax(final long[] latencyMax) {
+ this.defaultMQProducerImpl.setLatencyMax(latencyMax);
+ }
+
+ public boolean isSendLatencyFaultEnable() {
+ return this.defaultMQProducerImpl.isSendLatencyFaultEnable();
+ }
+
+ public void setSendLatencyFaultEnable(final boolean sendLatencyFaultEnable) {
+ this.defaultMQProducerImpl.setSendLatencyFaultEnable(sendLatencyFaultEnable);
+ }
+
+ public int getRetryTimesWhenSendAsyncFailed() {
+ return retryTimesWhenSendAsyncFailed;
+ }
+
+ public void setRetryTimesWhenSendAsyncFailed(final int retryTimesWhenSendAsyncFailed) {
+ this.retryTimesWhenSendAsyncFailed = retryTimesWhenSendAsyncFailed;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java b/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java
new file mode 100644
index 0000000..5e8178a
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java
@@ -0,0 +1,27 @@
+/**
+ * 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.producer;
+
+import org.apache.rocketmq.common.message.Message;
+
+
+/**
+ * @author shijia.wxr
+ */
+public interface LocalTransactionExecuter {
+ public LocalTransactionState executeLocalTransactionBranch(final Message msg, final Object arg);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java b/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java
new file mode 100644
index 0000000..ce5b0d9
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java
@@ -0,0 +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 org.apache.rocketmq.client.producer;
+
+/**
+ * @author shijia.wxr
+ */
+public enum LocalTransactionState {
+ COMMIT_MESSAGE,
+ ROLLBACK_MESSAGE,
+ UNKNOW,
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java b/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java
new file mode 100644
index 0000000..0ea4a33
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java
@@ -0,0 +1,106 @@
+/**
+ * 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.producer;
+
+import org.apache.rocketmq.client.MQAdmin;
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public interface MQProducer extends MQAdmin {
+ void start() throws MQClientException;
+
+ void shutdown();
+
+
+ List<MessageQueue> fetchPublishMessageQueues(final String topic) throws MQClientException;
+
+
+ SendResult send(final Message msg) throws MQClientException, RemotingException, MQBrokerException,
+ InterruptedException;
+
+
+ SendResult send(final Message msg, final long timeout) throws MQClientException,
+ RemotingException, MQBrokerException, InterruptedException;
+
+
+ void send(final Message msg, final SendCallback sendCallback) throws MQClientException,
+ RemotingException, InterruptedException;
+
+
+ void send(final Message msg, final SendCallback sendCallback, final long timeout)
+ throws MQClientException, RemotingException, InterruptedException;
+
+
+ void sendOneway(final Message msg) throws MQClientException, RemotingException,
+ InterruptedException;
+
+
+ SendResult send(final Message msg, final MessageQueue mq) throws MQClientException,
+ RemotingException, MQBrokerException, InterruptedException;
+
+
+ SendResult send(final Message msg, final MessageQueue mq, final long timeout)
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException;
+
+
+ void send(final Message msg, final MessageQueue mq, final SendCallback sendCallback)
+ throws MQClientException, RemotingException, InterruptedException;
+
+
+ void send(final Message msg, final MessageQueue mq, final SendCallback sendCallback, long timeout)
+ throws MQClientException, RemotingException, InterruptedException;
+
+
+ void sendOneway(final Message msg, final MessageQueue mq) throws MQClientException,
+ RemotingException, InterruptedException;
+
+
+ SendResult send(final Message msg, final MessageQueueSelector selector, final Object arg)
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException;
+
+
+ SendResult send(final Message msg, final MessageQueueSelector selector, final Object arg,
+ final long timeout) throws MQClientException, RemotingException, MQBrokerException,
+ InterruptedException;
+
+
+ void send(final Message msg, final MessageQueueSelector selector, final Object arg,
+ final SendCallback sendCallback) throws MQClientException, RemotingException,
+ InterruptedException;
+
+
+ void send(final Message msg, final MessageQueueSelector selector, final Object arg,
+ final SendCallback sendCallback, final long timeout) throws MQClientException, RemotingException,
+ InterruptedException;
+
+
+ void sendOneway(final Message msg, final MessageQueueSelector selector, final Object arg)
+ throws MQClientException, RemotingException, InterruptedException;
+
+
+ TransactionSendResult sendMessageInTransaction(final Message msg,
+ final LocalTransactionExecuter tranExecuter, final Object arg) throws MQClientException;
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java b/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java
new file mode 100644
index 0000000..c7a9124
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java
@@ -0,0 +1,30 @@
+/**
+ * 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.producer;
+
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageQueue;
+
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public interface MessageQueueSelector {
+ MessageQueue select(final List<MessageQueue> mqs, final Message msg, final Object arg);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java b/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java
new file mode 100644
index 0000000..7b0e00e
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java
@@ -0,0 +1,27 @@
+/**
+ * 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.producer;
+
+/**
+ * @author shijia.wxr
+ */
+public interface SendCallback {
+ public void onSuccess(final SendResult sendResult);
+
+
+ public void onException(final Throwable e);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java b/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java
new file mode 100644
index 0000000..02ed6b5
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java
@@ -0,0 +1,143 @@
+/**
+ * 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.producer;
+
+import com.alibaba.fastjson.JSON;
+import org.apache.rocketmq.common.message.MessageQueue;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class SendResult {
+ private SendStatus sendStatus;
+ private String msgId;
+ private MessageQueue messageQueue;
+ private long queueOffset;
+ private String transactionId;
+ private String offsetMsgId;
+ private String regionId;
+ private boolean traceOn = true;
+
+ public SendResult() {
+ }
+
+ public SendResult(SendStatus sendStatus, String msgId, String offsetMsgId, MessageQueue messageQueue, long queueOffset) {
+ this.sendStatus = sendStatus;
+ this.msgId = msgId;
+ this.offsetMsgId = offsetMsgId;
+ this.messageQueue = messageQueue;
+ this.queueOffset = queueOffset;
+ }
+
+ public SendResult(final SendStatus sendStatus, final String msgId, final MessageQueue messageQueue, final long queueOffset, final String transactionId, final String offsetMsgId, final String regionId) {
+ this.sendStatus = sendStatus;
+ this.msgId = msgId;
+ this.messageQueue = messageQueue;
+ this.queueOffset = queueOffset;
+ this.transactionId = transactionId;
+ this.offsetMsgId = offsetMsgId;
+ this.regionId = regionId;
+ }
+
+ public boolean isTraceOn() {
+ return traceOn;
+ }
+
+ public void setTraceOn(final boolean traceOn) {
+ this.traceOn = traceOn;
+ }
+
+ public String getRegionId() {
+ return regionId;
+ }
+
+ public void setRegionId(final String regionId) {
+ this.regionId = regionId;
+ }
+
+ public static String encoderSendResultToJson(final Object obj) {
+ return JSON.toJSONString(obj);
+ }
+
+ public static SendResult decoderSendResultFromJson(String json) {
+ return JSON.parseObject(json, SendResult.class);
+ }
+
+ public String getMsgId() {
+ return msgId;
+ }
+
+
+ public void setMsgId(String msgId) {
+ this.msgId = msgId;
+ }
+
+
+ public SendStatus getSendStatus() {
+ return sendStatus;
+ }
+
+
+ public void setSendStatus(SendStatus sendStatus) {
+ this.sendStatus = sendStatus;
+ }
+
+
+ public MessageQueue getMessageQueue() {
+ return messageQueue;
+ }
+
+
+ public void setMessageQueue(MessageQueue messageQueue) {
+ this.messageQueue = messageQueue;
+ }
+
+
+ public long getQueueOffset() {
+ return queueOffset;
+ }
+
+
+ public void setQueueOffset(long queueOffset) {
+ this.queueOffset = queueOffset;
+ }
+
+
+ public String getTransactionId() {
+ return transactionId;
+ }
+
+
+ public void setTransactionId(String transactionId) {
+ this.transactionId = transactionId;
+ }
+
+ public String getOffsetMsgId() {
+ return offsetMsgId;
+ }
+
+ public void setOffsetMsgId(String offsetMsgId) {
+ this.offsetMsgId = offsetMsgId;
+ }
+
+ @Override
+ public String toString() {
+ return "SendResult [sendStatus=" + sendStatus + ", msgId=" + msgId + ", offsetMsgId=" + offsetMsgId + ", messageQueue=" + messageQueue
+ + ", queueOffset=" + queueOffset + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java b/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java
new file mode 100644
index 0000000..038bc99
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java
@@ -0,0 +1,27 @@
+/**
+ * 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.producer;
+
+/**
+ * @author shijia.wxr
+ */
+public enum SendStatus {
+ SEND_OK,
+ FLUSH_DISK_TIMEOUT,
+ FLUSH_SLAVE_TIMEOUT,
+ SLAVE_NOT_AVAILABLE,
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java
new file mode 100644
index 0000000..9a11d50
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java
@@ -0,0 +1,27 @@
+/**
+ * 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.producer;
+
+import org.apache.rocketmq.common.message.MessageExt;
+
+
+/**
+ * @author shijia.wxr
+ */
+public interface TransactionCheckListener {
+ LocalTransactionState checkLocalTransactionState(final MessageExt msg);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java
new file mode 100644
index 0000000..eaca6ec
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java
@@ -0,0 +1,109 @@
+/**
+ * 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.producer;
+
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.remoting.RPCHook;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class TransactionMQProducer extends DefaultMQProducer {
+ private TransactionCheckListener transactionCheckListener;
+ private int checkThreadPoolMinSize = 1;
+ private int checkThreadPoolMaxSize = 1;
+ private int checkRequestHoldMax = 2000;
+
+
+ public TransactionMQProducer() {
+ }
+
+
+ public TransactionMQProducer(final String producerGroup) {
+ super(producerGroup);
+ }
+
+ public TransactionMQProducer(final String producerGroup, RPCHook rpcHook) {
+ super(producerGroup, rpcHook);
+ }
+
+ @Override
+ public void start() throws MQClientException {
+ this.defaultMQProducerImpl.initTransactionEnv();
+ super.start();
+ }
+
+
+ @Override
+ public void shutdown() {
+ super.shutdown();
+ this.defaultMQProducerImpl.destroyTransactionEnv();
+ }
+
+
+ @Override
+ public TransactionSendResult sendMessageInTransaction(final Message msg,
+ final LocalTransactionExecuter tranExecuter, final Object arg) throws MQClientException {
+ if (null == this.transactionCheckListener) {
+ throw new MQClientException("localTransactionBranchCheckListener is null", null);
+ }
+
+ return this.defaultMQProducerImpl.sendMessageInTransaction(msg, tranExecuter, arg);
+ }
+
+
+ public TransactionCheckListener getTransactionCheckListener() {
+ return transactionCheckListener;
+ }
+
+
+ public void setTransactionCheckListener(TransactionCheckListener transactionCheckListener) {
+ this.transactionCheckListener = transactionCheckListener;
+ }
+
+
+ public int getCheckThreadPoolMinSize() {
+ return checkThreadPoolMinSize;
+ }
+
+
+ public void setCheckThreadPoolMinSize(int checkThreadPoolMinSize) {
+ this.checkThreadPoolMinSize = checkThreadPoolMinSize;
+ }
+
+
+ public int getCheckThreadPoolMaxSize() {
+ return checkThreadPoolMaxSize;
+ }
+
+
+ public void setCheckThreadPoolMaxSize(int checkThreadPoolMaxSize) {
+ this.checkThreadPoolMaxSize = checkThreadPoolMaxSize;
+ }
+
+
+ public int getCheckRequestHoldMax() {
+ return checkRequestHoldMax;
+ }
+
+
+ public void setCheckRequestHoldMax(int checkRequestHoldMax) {
+ this.checkRequestHoldMax = checkRequestHoldMax;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java
new file mode 100644
index 0000000..478c39d
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java
@@ -0,0 +1,38 @@
+/**
+ * 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.producer;
+
+/**
+ * @author shijia.wxr
+ */
+public class TransactionSendResult extends SendResult {
+ private LocalTransactionState localTransactionState;
+
+
+ public TransactionSendResult() {
+ }
+
+
+ public LocalTransactionState getLocalTransactionState() {
+ return localTransactionState;
+ }
+
+
+ public void setLocalTransactionState(LocalTransactionState localTransactionState) {
+ this.localTransactionState = localTransactionState;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java
new file mode 100644
index 0000000..0f6ce48
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java
@@ -0,0 +1,41 @@
+/**
+ * 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.producer.selector;
+
+import org.apache.rocketmq.client.producer.MessageQueueSelector;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageQueue;
+
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class SelectMessageQueueByHash implements MessageQueueSelector {
+
+ @Override
+ public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
+ int value = arg.hashCode();
+ if (value < 0) {
+ value = Math.abs(value);
+ }
+
+ value = value % mqs.size();
+ return mqs.get(value);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java
new file mode 100644
index 0000000..1902de5
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java
@@ -0,0 +1,48 @@
+/**
+ * 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.producer.selector;
+
+import org.apache.rocketmq.client.producer.MessageQueueSelector;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageQueue;
+
+import java.util.List;
+import java.util.Set;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class SelectMessageQueueByMachineRoom implements MessageQueueSelector {
+ private Set<String> consumeridcs;
+
+
+ @Override
+ public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
+ return null;
+ }
+
+
+ public Set<String> getConsumeridcs() {
+ return consumeridcs;
+ }
+
+
+ public void setConsumeridcs(Set<String> consumeridcs) {
+ this.consumeridcs = consumeridcs;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java
new file mode 100644
index 0000000..b39b777
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java
@@ -0,0 +1,44 @@
+/**
+ * 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.producer.selector;
+
+import org.apache.rocketmq.client.producer.MessageQueueSelector;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageQueue;
+
+import java.util.List;
+import java.util.Random;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class SelectMessageQueueByRandoom implements MessageQueueSelector {
+ private Random random = new Random(System.currentTimeMillis());
+
+
+ @Override
+ public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
+ int value = random.nextInt();
+ if (value < 0) {
+ value = Math.abs(value);
+ }
+
+ value = value % mqs.size();
+ return mqs.get(value);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/stat/ConsumerStatsManager.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/stat/ConsumerStatsManager.java b/client/src/main/java/org/apache/rocketmq/client/stat/ConsumerStatsManager.java
new file mode 100644
index 0000000..3234ada
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/stat/ConsumerStatsManager.java
@@ -0,0 +1,165 @@
+/**
+ * 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.stat;
+
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.protocol.body.ConsumeStatus;
+import org.apache.rocketmq.common.stats.StatsItemSet;
+import org.apache.rocketmq.common.stats.StatsSnapshot;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.ScheduledExecutorService;
+
+
+public class ConsumerStatsManager {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.CLIENT_LOGGER_NAME);
+
+ private static final String TOPIC_AND_GROUP_CONSUME_OK_TPS = "CONSUME_OK_TPS";
+ private static final String TOPIC_AND_GROUP_CONSUME_FAILED_TPS = "CONSUME_FAILED_TPS";
+ private static final String TOPIC_AND_GROUP_CONSUME_RT = "CONSUME_RT";
+ private static final String TOPIC_AND_GROUP_PULL_TPS = "PULL_TPS";
+ private static final String TOPIC_AND_GROUP_PULL_RT = "PULL_RT";
+
+ private final StatsItemSet topicAndGroupConsumeOKTPS;
+ private final StatsItemSet topicAndGroupConsumeRT;
+ private final StatsItemSet topicAndGroupConsumeFailedTPS;
+ private final StatsItemSet topicAndGroupPullTPS;
+ private final StatsItemSet topicAndGroupPullRT;
+
+
+ public ConsumerStatsManager(final ScheduledExecutorService scheduledExecutorService) {
+ this.topicAndGroupConsumeOKTPS =
+ new StatsItemSet(TOPIC_AND_GROUP_CONSUME_OK_TPS, scheduledExecutorService, log);
+
+ this.topicAndGroupConsumeRT =
+ new StatsItemSet(TOPIC_AND_GROUP_CONSUME_RT, scheduledExecutorService, log);
+
+ this.topicAndGroupConsumeFailedTPS =
+ new StatsItemSet(TOPIC_AND_GROUP_CONSUME_FAILED_TPS, scheduledExecutorService, log);
+
+ this.topicAndGroupPullTPS = new StatsItemSet(TOPIC_AND_GROUP_PULL_TPS, scheduledExecutorService, log);
+
+ this.topicAndGroupPullRT = new StatsItemSet(TOPIC_AND_GROUP_PULL_RT, scheduledExecutorService, log);
+ }
+
+
+ public void start() {
+ }
+
+
+ public void shutdown() {
+ }
+
+
+ public void incPullRT(final String group, final String topic, final long rt) {
+ this.topicAndGroupPullRT.addValue(topic + "@" + group, (int) rt, 1);
+ }
+
+
+ public void incPullTPS(final String group, final String topic, final long msgs) {
+ this.topicAndGroupPullTPS.addValue(topic + "@" + group, (int) msgs, 1);
+ }
+
+
+ public void incConsumeRT(final String group, final String topic, final long rt) {
+ this.topicAndGroupConsumeRT.addValue(topic + "@" + group, (int) rt, 1);
+ }
+
+
+ public void incConsumeOKTPS(final String group, final String topic, final long msgs) {
+ this.topicAndGroupConsumeOKTPS.addValue(topic + "@" + group, (int) msgs, 1);
+ }
+
+
+ public void incConsumeFailedTPS(final String group, final String topic, final long msgs) {
+ this.topicAndGroupConsumeFailedTPS.addValue(topic + "@" + group, (int) msgs, 1);
+ }
+
+ public ConsumeStatus consumeStatus(final String group, final String topic) {
+ ConsumeStatus cs = new ConsumeStatus();
+ {
+ StatsSnapshot ss = this.getPullRT(group, topic);
+ if (ss != null) {
+ cs.setPullRT(ss.getAvgpt());
+ }
+ }
+
+ {
+ StatsSnapshot ss = this.getPullTPS(group, topic);
+ if (ss != null) {
+ cs.setPullTPS(ss.getTps());
+ }
+ }
+
+ {
+ StatsSnapshot ss = this.getConsumeRT(group, topic);
+ if (ss != null) {
+ cs.setConsumeRT(ss.getAvgpt());
+ }
+ }
+
+ {
+ StatsSnapshot ss = this.getConsumeOKTPS(group, topic);
+ if (ss != null) {
+ cs.setConsumeOKTPS(ss.getTps());
+ }
+ }
+
+ {
+ StatsSnapshot ss = this.getConsumeFailedTPS(group, topic);
+ if (ss != null) {
+ cs.setConsumeFailedTPS(ss.getTps());
+ }
+ }
+
+ {
+ StatsSnapshot ss = this.topicAndGroupConsumeFailedTPS.getStatsDataInHour(topic + "@" + group);
+ if (ss != null) {
+ cs.setConsumeFailedMsgs(ss.getSum());
+ }
+ }
+
+ return cs;
+ }
+
+ private StatsSnapshot getPullRT(final String group, final String topic) {
+ return this.topicAndGroupPullRT.getStatsDataInMinute(topic + "@" + group);
+ }
+
+ private StatsSnapshot getPullTPS(final String group, final String topic) {
+ return this.topicAndGroupPullTPS.getStatsDataInMinute(topic + "@" + group);
+ }
+
+ private StatsSnapshot getConsumeRT(final String group, final String topic) {
+ StatsSnapshot statsData = this.topicAndGroupConsumeRT.getStatsDataInMinute(topic + "@" + group);
+ if (0 == statsData.getSum()) {
+ statsData = this.topicAndGroupConsumeRT.getStatsDataInHour(topic + "@" + group);
+ }
+
+ return statsData;
+ }
+
+ private StatsSnapshot getConsumeOKTPS(final String group, final String topic) {
+ return this.topicAndGroupConsumeOKTPS.getStatsDataInMinute(topic + "@" + group);
+ }
+
+ private StatsSnapshot getConsumeFailedTPS(final String group, final String topic) {
+ return this.topicAndGroupConsumeFailedTPS.getStatsDataInMinute(topic + "@" + group);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/test/java/com/alibaba/rocketmq/client/ValidatorsTest.java
----------------------------------------------------------------------
diff --git a/client/src/test/java/com/alibaba/rocketmq/client/ValidatorsTest.java b/client/src/test/java/com/alibaba/rocketmq/client/ValidatorsTest.java
deleted file mode 100644
index 2a10ec4..0000000
--- a/client/src/test/java/com/alibaba/rocketmq/client/ValidatorsTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * 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.client;
-
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import org.junit.Assert;
-import org.junit.Test;
-
-
-public class ValidatorsTest {
-
- @Test
- 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");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/test/java/com/alibaba/rocketmq/client/consumer/loadbalance/AllocateMessageQueueAveragelyTest.java
----------------------------------------------------------------------
diff --git a/client/src/test/java/com/alibaba/rocketmq/client/consumer/loadbalance/AllocateMessageQueueAveragelyTest.java b/client/src/test/java/com/alibaba/rocketmq/client/consumer/loadbalance/AllocateMessageQueueAveragelyTest.java
deleted file mode 100644
index 5ef75ed..0000000
--- a/client/src/test/java/com/alibaba/rocketmq/client/consumer/loadbalance/AllocateMessageQueueAveragelyTest.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/**
- * 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.
- */
-
-/*
- * @author yubao.fyb@taoboa.com
- * @version $id$
- */
-package com.alibaba.rocketmq.client.consumer.loadbalance;
-
-import com.alibaba.rocketmq.client.consumer.AllocateMessageQueueStrategy;
-import com.alibaba.rocketmq.client.consumer.rebalance.AllocateMessageQueueAveragely;
-import com.alibaba.rocketmq.client.consumer.rebalance.AllocateMessageQueueAveragelyByCircle;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * @author yubao.fyb@alibaba-inc.com created on 2013-07-03 16:24
- */
-public class AllocateMessageQueueAveragelyTest {
- private AllocateMessageQueueStrategy allocateMessageQueueAveragely;
- private String currentCID;
- private String topic;
- private List<MessageQueue> messageQueueList;
- private List<String> consumerIdList;
-
- @Before
- public void init() {
- allocateMessageQueueAveragely = new AllocateMessageQueueAveragely();
- topic = "topic_test";
- }
-
- @Test
- public void testConsumer1() {
- currentCID = "0";
- createConsumerIdList(1);
- createMessageQueueList(5);
- List<MessageQueue> result =
- allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
- printMessageQueue(result, "testConsumer1");
- Assert.assertEquals(result.size(), 5);
- Assert.assertEquals(result.containsAll(getMessageQueueList()), true);
- }
-
- public void createConsumerIdList(int size) {
- consumerIdList = new ArrayList<String>(size);
- for (int i = 0; i < size; i++) {
- consumerIdList.add(String.valueOf(i));
- }
- }
-
- public void createMessageQueueList(int size) {
- messageQueueList = new ArrayList<MessageQueue>(size);
- for (int i = 0; i < size; i++) {
- MessageQueue mq = new MessageQueue(topic, "brokerName", i);
- messageQueueList.add(mq);
- }
- }
-
- public void printMessageQueue(List<MessageQueue> messageQueueList, String name) {
- if (messageQueueList == null || messageQueueList.size() < 1)
- return;
- System.out.println(name + ".......................................start");
- for (MessageQueue messageQueue : messageQueueList) {
- System.out.println(messageQueue);
- }
- System.out.println(name + ".......................................end");
- }
-
- public List<MessageQueue> getMessageQueueList() {
- return messageQueueList;
- }
-
- public void setMessageQueueList(List<MessageQueue> messageQueueList) {
- this.messageQueueList = messageQueueList;
- }
-
- @Test
- public void testConsumer2() {
- currentCID = "1";
- createConsumerIdList(2);
- createMessageQueueList(5);
- List<MessageQueue> result =
- allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
- printMessageQueue(result, "testConsumer2");
- Assert.assertEquals(result.size(), 3);
- Assert.assertEquals(result.containsAll(getMessageQueueList().subList(2, 5)), true);
-
- }
-
- @Test
- public void testConsumer3CurrentCID0() {
- currentCID = "0";
- createConsumerIdList(3);
- createMessageQueueList(5);
- List<MessageQueue> result =
- allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
- printMessageQueue(result, "testConsumer3CurrentCID0");
- Assert.assertEquals(result.size(), 1);
- Assert.assertEquals(result.containsAll(getMessageQueueList().subList(0, 1)), true);
- }
-
- @Test
- public void testConsumer3CurrentCID1() {
- currentCID = "1";
- createConsumerIdList(3);
- createMessageQueueList(5);
- List<MessageQueue> result =
- allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
- printMessageQueue(result, "testConsumer3CurrentCID1");
- Assert.assertEquals(result.size(), 1);
- Assert.assertEquals(result.containsAll(getMessageQueueList().subList(1, 2)), true);
- }
-
- @Test
- public void testConsumer3CurrentCID2() {
- currentCID = "2";
- createConsumerIdList(3);
- createMessageQueueList(5);
- List<MessageQueue> result =
- allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
- printMessageQueue(result, "testConsumer3CurrentCID2");
- Assert.assertEquals(result.size(), 3);
- Assert.assertEquals(result.containsAll(getMessageQueueList().subList(2, 5)), true);
- }
-
- @Test
- public void testConsumer4() {
- currentCID = "1";
- createConsumerIdList(4);
- createMessageQueueList(5);
- List<MessageQueue> result =
- allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
- printMessageQueue(result, "testConsumer4");
- Assert.assertEquals(result.size(), 1);
- Assert.assertEquals(result.containsAll(getMessageQueueList().subList(1, 2)), true);
- }
-
- @Test
- public void testConsumer5() {
- currentCID = "1";
- createConsumerIdList(5);
- createMessageQueueList(5);
- List<MessageQueue> result =
- allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
- printMessageQueue(result, "testConsumer5");
- Assert.assertEquals(result.size(), 1);
- Assert.assertEquals(result.containsAll(getMessageQueueList().subList(1, 2)), true);
- }
-
- @Test
- public void testConsumer6() {
- currentCID = "1";
- createConsumerIdList(2);
- createMessageQueueList(6);
- List<MessageQueue> result =
- allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
- printMessageQueue(result, "testConsumer");
- Assert.assertEquals(result.size(), 3);
- Assert.assertEquals(result.containsAll(getMessageQueueList().subList(3, 6)), true);
- }
-
- @Test
- public void testCurrentCIDNotExists() {
- currentCID = String.valueOf(Integer.MAX_VALUE);
- createConsumerIdList(2);
- createMessageQueueList(6);
- List<MessageQueue> result =
- allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
- printMessageQueue(result, "testCurrentCIDNotExists");
- Assert.assertEquals(result.size(), 0);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCurrentCIDIllegalArgument() {
- createConsumerIdList(2);
- createMessageQueueList(6);
- allocateMessageQueueAveragely.allocate("", "", getMessageQueueList(), getConsumerIdList());
- }
-
- public List<String> getConsumerIdList() {
- return consumerIdList;
- }
-
- public void setConsumerIdList(List<String> consumerIdList) {
- this.consumerIdList = consumerIdList;
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testMessageQueueIllegalArgument() {
- currentCID = "0";
- createConsumerIdList(2);
- allocateMessageQueueAveragely.allocate("", currentCID, null, getConsumerIdList());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testConsumerIdIllegalArgument() {
- currentCID = "0";
- createMessageQueueList(6);
- allocateMessageQueueAveragely.allocate("", currentCID, getMessageQueueList(), null);
- }
-
- @Test
- public void testAllocate() {
- AllocateMessageQueueAveragely allocateMessageQueueAveragely = new AllocateMessageQueueAveragely();
- String topic = "topic_test";
- String currentCID = "CID";
- int queueSize = 19;
- int consumerSize = 10;
- List<MessageQueue> mqAll = new ArrayList<MessageQueue>();
- for (int i = 0; i < queueSize; i++) {
- MessageQueue mq = new MessageQueue(topic, "brokerName", i);
- mqAll.add(mq);
- }
-
- List<String> cidAll = new ArrayList<String>();
- for (int j = 0; j < consumerSize; j++) {
- cidAll.add("CID" + j);
- }
- System.out.println(mqAll.toString());
- System.out.println(cidAll.toString());
- for (int i = 0; i < consumerSize; i++) {
- List<MessageQueue> rs = allocateMessageQueueAveragely.allocate("", currentCID + i, mqAll, cidAll);
- System.out.println("rs[" + currentCID + i + "]:" + rs.toString());
- }
- }
-
-
- @Test
- public void testAllocateByCircle() {
- AllocateMessageQueueAveragelyByCircle circle = new AllocateMessageQueueAveragelyByCircle();
- String topic = "topic_test";
- String currentCID = "CID";
- int consumerSize = 3;
- int queueSize = 13;
- List<MessageQueue> mqAll = new ArrayList<MessageQueue>();
- for (int i = 0; i < queueSize; i++) {
- MessageQueue mq = new MessageQueue(topic, "brokerName", i);
- mqAll.add(mq);
- }
-
- List<String> cidAll = new ArrayList<String>();
- for (int j = 0; j < consumerSize; j++) {
- cidAll.add("CID" + j);
- }
- System.out.println(mqAll.toString());
- System.out.println(cidAll.toString());
- for (int i = 0; i < consumerSize; i++) {
- List<MessageQueue> rs = circle.allocate("", currentCID + i, mqAll, cidAll);
- System.out.println("rs[" + currentCID + i + "]:" + rs.toString());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/test/java/org/apache/rocketmq/client/ValidatorsTest.java
----------------------------------------------------------------------
diff --git a/client/src/test/java/org/apache/rocketmq/client/ValidatorsTest.java b/client/src/test/java/org/apache/rocketmq/client/ValidatorsTest.java
new file mode 100644
index 0000000..a3daba5
--- /dev/null
+++ b/client/src/test/java/org/apache/rocketmq/client/ValidatorsTest.java
@@ -0,0 +1,34 @@
+/**
+ * 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.exception.MQClientException;
+import org.junit.Test;
+
+
+public class ValidatorsTest {
+
+ @Test
+ 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");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/test/java/org/apache/rocketmq/client/consumer/loadbalance/AllocateMessageQueueAveragelyTest.java
----------------------------------------------------------------------
diff --git a/client/src/test/java/org/apache/rocketmq/client/consumer/loadbalance/AllocateMessageQueueAveragelyTest.java b/client/src/test/java/org/apache/rocketmq/client/consumer/loadbalance/AllocateMessageQueueAveragelyTest.java
new file mode 100644
index 0000000..7b568c5
--- /dev/null
+++ b/client/src/test/java/org/apache/rocketmq/client/consumer/loadbalance/AllocateMessageQueueAveragelyTest.java
@@ -0,0 +1,272 @@
+/**
+ * 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.
+ */
+
+/*
+ * @author yubao.fyb@taoboa.com
+ * @version $id$
+ */
+package org.apache.rocketmq.client.consumer.loadbalance;
+
+import org.apache.rocketmq.client.consumer.AllocateMessageQueueStrategy;
+import org.apache.rocketmq.client.consumer.rebalance.AllocateMessageQueueAveragely;
+import org.apache.rocketmq.client.consumer.rebalance.AllocateMessageQueueAveragelyByCircle;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @author yubao.fyb@alibaba-inc.com created on 2013-07-03 16:24
+ */
+public class AllocateMessageQueueAveragelyTest {
+ private AllocateMessageQueueStrategy allocateMessageQueueAveragely;
+ private String currentCID;
+ private String topic;
+ private List<MessageQueue> messageQueueList;
+ private List<String> consumerIdList;
+
+ @Before
+ public void init() {
+ allocateMessageQueueAveragely = new AllocateMessageQueueAveragely();
+ topic = "topic_test";
+ }
+
+ @Test
+ public void testConsumer1() {
+ currentCID = "0";
+ createConsumerIdList(1);
+ createMessageQueueList(5);
+ List<MessageQueue> result =
+ allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
+ printMessageQueue(result, "testConsumer1");
+ Assert.assertEquals(result.size(), 5);
+ Assert.assertEquals(result.containsAll(getMessageQueueList()), true);
+ }
+
+ public void createConsumerIdList(int size) {
+ consumerIdList = new ArrayList<String>(size);
+ for (int i = 0; i < size; i++) {
+ consumerIdList.add(String.valueOf(i));
+ }
+ }
+
+ public void createMessageQueueList(int size) {
+ messageQueueList = new ArrayList<MessageQueue>(size);
+ for (int i = 0; i < size; i++) {
+ MessageQueue mq = new MessageQueue(topic, "brokerName", i);
+ messageQueueList.add(mq);
+ }
+ }
+
+ public void printMessageQueue(List<MessageQueue> messageQueueList, String name) {
+ if (messageQueueList == null || messageQueueList.size() < 1)
+ return;
+ System.out.println(name + ".......................................start");
+ for (MessageQueue messageQueue : messageQueueList) {
+ System.out.println(messageQueue);
+ }
+ System.out.println(name + ".......................................end");
+ }
+
+ public List<MessageQueue> getMessageQueueList() {
+ return messageQueueList;
+ }
+
+ public void setMessageQueueList(List<MessageQueue> messageQueueList) {
+ this.messageQueueList = messageQueueList;
+ }
+
+ @Test
+ public void testConsumer2() {
+ currentCID = "1";
+ createConsumerIdList(2);
+ createMessageQueueList(5);
+ List<MessageQueue> result =
+ allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
+ printMessageQueue(result, "testConsumer2");
+ Assert.assertEquals(result.size(), 3);
+ Assert.assertEquals(result.containsAll(getMessageQueueList().subList(2, 5)), true);
+
+ }
+
+ @Test
+ public void testConsumer3CurrentCID0() {
+ currentCID = "0";
+ createConsumerIdList(3);
+ createMessageQueueList(5);
+ List<MessageQueue> result =
+ allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
+ printMessageQueue(result, "testConsumer3CurrentCID0");
+ Assert.assertEquals(result.size(), 1);
+ Assert.assertEquals(result.containsAll(getMessageQueueList().subList(0, 1)), true);
+ }
+
+ @Test
+ public void testConsumer3CurrentCID1() {
+ currentCID = "1";
+ createConsumerIdList(3);
+ createMessageQueueList(5);
+ List<MessageQueue> result =
+ allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
+ printMessageQueue(result, "testConsumer3CurrentCID1");
+ Assert.assertEquals(result.size(), 1);
+ Assert.assertEquals(result.containsAll(getMessageQueueList().subList(1, 2)), true);
+ }
+
+ @Test
+ public void testConsumer3CurrentCID2() {
+ currentCID = "2";
+ createConsumerIdList(3);
+ createMessageQueueList(5);
+ List<MessageQueue> result =
+ allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
+ printMessageQueue(result, "testConsumer3CurrentCID2");
+ Assert.assertEquals(result.size(), 3);
+ Assert.assertEquals(result.containsAll(getMessageQueueList().subList(2, 5)), true);
+ }
+
+ @Test
+ public void testConsumer4() {
+ currentCID = "1";
+ createConsumerIdList(4);
+ createMessageQueueList(5);
+ List<MessageQueue> result =
+ allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
+ printMessageQueue(result, "testConsumer4");
+ Assert.assertEquals(result.size(), 1);
+ Assert.assertEquals(result.containsAll(getMessageQueueList().subList(1, 2)), true);
+ }
+
+ @Test
+ public void testConsumer5() {
+ currentCID = "1";
+ createConsumerIdList(5);
+ createMessageQueueList(5);
+ List<MessageQueue> result =
+ allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
+ printMessageQueue(result, "testConsumer5");
+ Assert.assertEquals(result.size(), 1);
+ Assert.assertEquals(result.containsAll(getMessageQueueList().subList(1, 2)), true);
+ }
+
+ @Test
+ public void testConsumer6() {
+ currentCID = "1";
+ createConsumerIdList(2);
+ createMessageQueueList(6);
+ List<MessageQueue> result =
+ allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
+ printMessageQueue(result, "testConsumer");
+ Assert.assertEquals(result.size(), 3);
+ Assert.assertEquals(result.containsAll(getMessageQueueList().subList(3, 6)), true);
+ }
+
+ @Test
+ public void testCurrentCIDNotExists() {
+ currentCID = String.valueOf(Integer.MAX_VALUE);
+ createConsumerIdList(2);
+ createMessageQueueList(6);
+ List<MessageQueue> result =
+ allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
+ printMessageQueue(result, "testCurrentCIDNotExists");
+ Assert.assertEquals(result.size(), 0);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testCurrentCIDIllegalArgument() {
+ createConsumerIdList(2);
+ createMessageQueueList(6);
+ allocateMessageQueueAveragely.allocate("", "", getMessageQueueList(), getConsumerIdList());
+ }
+
+ public List<String> getConsumerIdList() {
+ return consumerIdList;
+ }
+
+ public void setConsumerIdList(List<String> consumerIdList) {
+ this.consumerIdList = consumerIdList;
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMessageQueueIllegalArgument() {
+ currentCID = "0";
+ createConsumerIdList(2);
+ allocateMessageQueueAveragely.allocate("", currentCID, null, getConsumerIdList());
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testConsumerIdIllegalArgument() {
+ currentCID = "0";
+ createMessageQueueList(6);
+ allocateMessageQueueAveragely.allocate("", currentCID, getMessageQueueList(), null);
+ }
+
+ @Test
+ public void testAllocate() {
+ AllocateMessageQueueAveragely allocateMessageQueueAveragely = new AllocateMessageQueueAveragely();
+ String topic = "topic_test";
+ String currentCID = "CID";
+ int queueSize = 19;
+ int consumerSize = 10;
+ List<MessageQueue> mqAll = new ArrayList<MessageQueue>();
+ for (int i = 0; i < queueSize; i++) {
+ MessageQueue mq = new MessageQueue(topic, "brokerName", i);
+ mqAll.add(mq);
+ }
+
+ List<String> cidAll = new ArrayList<String>();
+ for (int j = 0; j < consumerSize; j++) {
+ cidAll.add("CID" + j);
+ }
+ System.out.println(mqAll.toString());
+ System.out.println(cidAll.toString());
+ for (int i = 0; i < consumerSize; i++) {
+ List<MessageQueue> rs = allocateMessageQueueAveragely.allocate("", currentCID + i, mqAll, cidAll);
+ System.out.println("rs[" + currentCID + i + "]:" + rs.toString());
+ }
+ }
+
+
+ @Test
+ public void testAllocateByCircle() {
+ AllocateMessageQueueAveragelyByCircle circle = new AllocateMessageQueueAveragelyByCircle();
+ String topic = "topic_test";
+ String currentCID = "CID";
+ int consumerSize = 3;
+ int queueSize = 13;
+ List<MessageQueue> mqAll = new ArrayList<MessageQueue>();
+ for (int i = 0; i < queueSize; i++) {
+ MessageQueue mq = new MessageQueue(topic, "brokerName", i);
+ mqAll.add(mq);
+ }
+
+ List<String> cidAll = new ArrayList<String>();
+ for (int j = 0; j < consumerSize; j++) {
+ cidAll.add("CID" + j);
+ }
+ System.out.println(mqAll.toString());
+ System.out.println(cidAll.toString());
+ for (int i = 0; i < consumerSize; i++) {
+ List<MessageQueue> rs = circle.allocate("", currentCID + i, mqAll, cidAll);
+ System.out.println("rs[" + currentCID + i + "]:" + rs.toString());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/pom.xml
----------------------------------------------------------------------
diff --git a/common/pom.xml b/common/pom.xml
index 72cc2b0..ec95a76 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -18,7 +18,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.rocketmq</groupId>
+ <groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-all</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>
[14/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SendMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SendMessageResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SendMessageResponseHeader.java
deleted file mode 100644
index 53c233a..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/SendMessageResponseHeader.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: SendMessageResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class SendMessageResponseHeader implements CommandCustomHeader {
- @CFNotNull
- private String msgId;
- @CFNotNull
- private Integer queueId;
- @CFNotNull
- private Long queueOffset;
- private String transactionId;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getMsgId() {
- return msgId;
- }
-
-
- public void setMsgId(String msgId) {
- this.msgId = msgId;
- }
-
-
- public Integer getQueueId() {
- return queueId;
- }
-
-
- public void setQueueId(Integer queueId) {
- this.queueId = queueId;
- }
-
-
- public Long getQueueOffset() {
- return queueOffset;
- }
-
-
- public void setQueueOffset(Long queueOffset) {
- this.queueOffset = queueOffset;
- }
-
- public String getTransactionId() {
- return transactionId;
- }
-
- public void setTransactionId(String transactionId) {
- this.transactionId = transactionId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
deleted file mode 100644
index cf3fcca..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.annotation.CFNullable;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class UnregisterClientRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String clientID;
-
- @CFNullable
- private String producerGroup;
- @CFNullable
- private String consumerGroup;
-
-
- public String getClientID() {
- return clientID;
- }
-
-
- public void setClientID(String clientID) {
- this.clientID = clientID;
- }
-
-
- public String getProducerGroup() {
- return producerGroup;
- }
-
-
- public void setProducerGroup(String producerGroup) {
- this.producerGroup = producerGroup;
- }
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- // TODO Auto-generated method stub
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
deleted file mode 100644
index 86863ba..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class UnregisterClientResponseHeader implements CommandCustomHeader {
-
- @Override
- public void checkFields() throws RemotingCommandException {
- // TODO Auto-generated method stub
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
deleted file mode 100644
index 4fd7326..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: UpdateConsumerOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class UpdateConsumerOffsetRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String consumerGroup;
- @CFNotNull
- private String topic;
- @CFNotNull
- private Integer queueId;
- @CFNotNull
- private Long commitOffset;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public Integer getQueueId() {
- return queueId;
- }
-
-
- public void setQueueId(Integer queueId) {
- this.queueId = queueId;
- }
-
-
- public Long getCommitOffset() {
- return commitOffset;
- }
-
-
- public void setCommitOffset(Long commitOffset) {
- this.commitOffset = commitOffset;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
deleted file mode 100644
index a90f41e..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: UpdateConsumerOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class UpdateConsumerOffsetResponseHeader implements CommandCustomHeader {
- @Override
- public void checkFields() throws RemotingCommandException {
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ViewBrokerStatsDataRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ViewBrokerStatsDataRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ViewBrokerStatsDataRequestHeader.java
deleted file mode 100644
index 45f3ac3..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ViewBrokerStatsDataRequestHeader.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * 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.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-public class ViewBrokerStatsDataRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String statsName;
- @CFNotNull
- private String statsKey;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
-
- }
-
-
- public String getStatsName() {
- return statsName;
- }
-
-
- public void setStatsName(String statsName) {
- this.statsName = statsName;
- }
-
-
- public String getStatsKey() {
- return statsKey;
- }
-
-
- public void setStatsKey(String statsKey) {
- this.statsKey = statsKey;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ViewMessageRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
deleted file mode 100644
index d1db42f..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: ViewMessageRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class ViewMessageRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private Long offset;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public Long getOffset() {
- return offset;
- }
-
-
- public void setOffset(Long offset) {
- this.offset = offset;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ViewMessageResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
deleted file mode 100644
index d9344a5..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: ViewMessageResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class ViewMessageResponseHeader implements CommandCustomHeader {
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerRequestHeader.java
deleted file mode 100644
index ef07b43..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerRequestHeader.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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.common.protocol.header.filtersrv;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-public class RegisterFilterServerRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String filterServerAddr;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getFilterServerAddr() {
- return filterServerAddr;
- }
-
-
- public void setFilterServerAddr(String filterServerAddr) {
- this.filterServerAddr = filterServerAddr;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerResponseHeader.java
deleted file mode 100644
index 7a4a1de..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerResponseHeader.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * 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.common.protocol.header.filtersrv;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-public class RegisterFilterServerResponseHeader implements CommandCustomHeader {
- @CFNotNull
- private String brokerName;
- @CFNotNull
- private long brokerId;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public long getBrokerId() {
- return brokerId;
- }
-
-
- public void setBrokerId(long brokerId) {
- this.brokerId = brokerId;
- }
-
-
- public String getBrokerName() {
- return brokerName;
- }
-
-
- public void setBrokerName(String brokerName) {
- this.brokerName = brokerName;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/filtersrv/RegisterMessageFilterClassRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/filtersrv/RegisterMessageFilterClassRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/filtersrv/RegisterMessageFilterClassRequestHeader.java
deleted file mode 100644
index 2423d95..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/filtersrv/RegisterMessageFilterClassRequestHeader.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * 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.common.protocol.header.filtersrv;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-public class RegisterMessageFilterClassRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String consumerGroup;
- @CFNotNull
- private String topic;
- @CFNotNull
- private String className;
- @CFNotNull
- private Integer classCRC;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public String getClassName() {
- return className;
- }
-
-
- public void setClassName(String className) {
- this.className = className;
- }
-
-
- public Integer getClassCRC() {
- return classCRC;
- }
-
-
- public void setClassCRC(Integer classCRC) {
- this.classCRC = classCRC;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java
deleted file mode 100644
index c3bc110..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * 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.common.protocol.header.namesrv;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class DeleteKVConfigRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String namespace;
- @CFNotNull
- private String key;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getNamespace() {
- return namespace;
- }
-
-
- public void setNamespace(String namespace) {
- this.namespace = namespace;
- }
-
-
- public String getKey() {
- return key;
- }
-
-
- public void setKey(String key) {
- this.key = key;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java
deleted file mode 100644
index 0bfec69..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * 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.common.protocol.header.namesrv;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class DeleteTopicInNamesrvRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String topic;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java
deleted file mode 100644
index 595ab38..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * 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.common.protocol.header.namesrv;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class GetKVConfigRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String namespace;
- @CFNotNull
- private String key;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getNamespace() {
- return namespace;
- }
-
-
- public void setNamespace(String namespace) {
- this.namespace = namespace;
- }
-
-
- public String getKey() {
- return key;
- }
-
-
- public void setKey(String key) {
- this.key = key;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java
deleted file mode 100644
index f4c63a8..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetKVConfigResponseHeader.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * 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.common.protocol.header.namesrv;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNullable;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class GetKVConfigResponseHeader implements CommandCustomHeader {
- @CFNullable
- private String value;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getValue() {
- return value;
- }
-
-
- public void setValue(String value) {
- this.value = value;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java
deleted file mode 100644
index 82cfc6d..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetKVListByNamespaceRequestHeader.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * 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.common.protocol.header.namesrv;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class GetKVListByNamespaceRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String namespace;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getNamespace() {
- return namespace;
- }
-
-
- public void setNamespace(String namespace) {
- this.namespace = namespace;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
deleted file mode 100644
index fce8802..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: GetRouteInfoRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header.namesrv;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class GetRouteInfoRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String topic;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
deleted file mode 100644
index 95777d6..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: GetRouteInfoResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header.namesrv;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class GetRouteInfoResponseHeader implements CommandCustomHeader {
-
- @Override
- public void checkFields() throws RemotingCommandException {
- // TODO Auto-generated method stub
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/PutKVConfigRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/PutKVConfigRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/PutKVConfigRequestHeader.java
deleted file mode 100644
index 22abc6c..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/PutKVConfigRequestHeader.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * 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.common.protocol.header.namesrv;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-public class PutKVConfigRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String namespace;
- @CFNotNull
- private String key;
- @CFNotNull
- private String value;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getNamespace() {
- return namespace;
- }
-
-
- public void setNamespace(String namespace) {
- this.namespace = namespace;
- }
-
-
- public String getKey() {
- return key;
- }
-
-
- public void setKey(String key) {
- this.key = key;
- }
-
-
- public String getValue() {
- return value;
- }
-
-
- public void setValue(String value) {
- this.value = value;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
deleted file mode 100644
index 4ae448f..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/RegisterBrokerRequestHeader.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: RegisterBrokerRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header.namesrv;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author lansheng.zj
- */
-public class RegisterBrokerRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String brokerName;
- @CFNotNull
- private String brokerAddr;
- @CFNotNull
- private String clusterName;
- @CFNotNull
- private String haServerAddr;
- @CFNotNull
- private Long brokerId;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getBrokerName() {
- return brokerName;
- }
-
-
- public void setBrokerName(String brokerName) {
- this.brokerName = brokerName;
- }
-
-
- public String getBrokerAddr() {
- return brokerAddr;
- }
-
-
- public void setBrokerAddr(String brokerAddr) {
- this.brokerAddr = brokerAddr;
- }
-
-
- public String getClusterName() {
- return clusterName;
- }
-
-
- public void setClusterName(String clusterName) {
- this.clusterName = clusterName;
- }
-
-
- public String getHaServerAddr() {
- return haServerAddr;
- }
-
-
- public void setHaServerAddr(String haServerAddr) {
- this.haServerAddr = haServerAddr;
- }
-
-
- public Long getBrokerId() {
- return brokerId;
- }
-
-
- public void setBrokerId(Long brokerId) {
- this.brokerId = brokerId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java
deleted file mode 100644
index 5aed198..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/RegisterBrokerResponseHeader.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * 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.common.protocol.header.namesrv;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNullable;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class RegisterBrokerResponseHeader implements CommandCustomHeader {
- @CFNullable
- private String haServerAddr;
- @CFNullable
- private String masterAddr;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getHaServerAddr() {
- return haServerAddr;
- }
-
-
- public void setHaServerAddr(String haServerAddr) {
- this.haServerAddr = haServerAddr;
- }
-
-
- public String getMasterAddr() {
- return masterAddr;
- }
-
-
- public void setMasterAddr(String masterAddr) {
- this.masterAddr = masterAddr;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
deleted file mode 100644
index e5a895d..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: RegisterOrderTopicRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header.namesrv;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- */
-public class RegisterOrderTopicRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String topic;
- @CFNotNull
- private String orderTopicString;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- // TODO Auto-generated method stub
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public String getOrderTopicString() {
- return orderTopicString;
- }
-
-
- public void setOrderTopicString(String orderTopicString) {
- this.orderTopicString = orderTopicString;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
deleted file mode 100644
index 0cde0ff..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/UnRegisterBrokerRequestHeader.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: UnRegisterBrokerRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.header.namesrv;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author lansheng.zj
- */
-public class UnRegisterBrokerRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String brokerName;
- @CFNotNull
- private String brokerAddr;
- @CFNotNull
- private String clusterName;
- @CFNotNull
- private Long brokerId;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public String getBrokerName() {
- return brokerName;
- }
-
-
- public void setBrokerName(String brokerName) {
- this.brokerName = brokerName;
- }
-
-
- public String getBrokerAddr() {
- return brokerAddr;
- }
-
-
- public void setBrokerAddr(String brokerAddr) {
- this.brokerAddr = brokerAddr;
- }
-
-
- public String getClusterName() {
- return clusterName;
- }
-
-
- public void setClusterName(String clusterName) {
- this.clusterName = clusterName;
- }
-
-
- public Long getBrokerId() {
- return brokerId;
- }
-
-
- public void setBrokerId(Long brokerId) {
- this.brokerId = brokerId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java
deleted file mode 100644
index ed664d5..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerRequestHeader.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * 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.common.protocol.header.namesrv;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class WipeWritePermOfBrokerRequestHeader implements CommandCustomHeader {
- @CFNotNull
- private String brokerName;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
-
- }
-
-
- public String getBrokerName() {
- return brokerName;
- }
-
-
- public void setBrokerName(String brokerName) {
- this.brokerName = brokerName;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java
deleted file mode 100644
index 9df9d3f..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/header/namesrv/WipeWritePermOfBrokerResponseHeader.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * 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.common.protocol.header.namesrv;
-
-import com.alibaba.rocketmq.remoting.CommandCustomHeader;
-import com.alibaba.rocketmq.remoting.annotation.CFNotNull;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class WipeWritePermOfBrokerResponseHeader implements CommandCustomHeader {
- @CFNotNull
- private Integer wipeTopicCount;
-
-
- @Override
- public void checkFields() throws RemotingCommandException {
- }
-
-
- public Integer getWipeTopicCount() {
- return wipeTopicCount;
- }
-
-
- public void setWipeTopicCount(Integer wipeTopicCount) {
- this.wipeTopicCount = wipeTopicCount;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/ConsumeType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/ConsumeType.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/ConsumeType.java
deleted file mode 100644
index 9144c8c..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/ConsumeType.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: ConsumeType.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.heartbeat;
-
-/**
- * @author shijia.wxr
- */
-public enum ConsumeType {
-
- CONSUME_ACTIVELY("PULL"),
-
- CONSUME_PASSIVELY("PUSH");
-
- private String typeCN;
-
- ConsumeType(String typeCN) {
- this.typeCN = typeCN;
- }
-
-
- public String getTypeCN() {
- return typeCN;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/ConsumerData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/ConsumerData.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/ConsumerData.java
deleted file mode 100644
index f1fd6f9..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/ConsumerData.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: ConsumerData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.heartbeat;
-
-import com.alibaba.rocketmq.common.consumer.ConsumeFromWhere;
-
-import java.util.HashSet;
-import java.util.Set;
-
-
-/**
- * @author shijia.wxr
- */
-public class ConsumerData {
- private String groupName;
- private ConsumeType consumeType;
- private MessageModel messageModel;
- private ConsumeFromWhere consumeFromWhere;
- private Set<SubscriptionData> subscriptionDataSet = new HashSet<SubscriptionData>();
- private boolean unitMode;
-
-
- public String getGroupName() {
- return groupName;
- }
-
-
- public void setGroupName(String groupName) {
- this.groupName = groupName;
- }
-
-
- public ConsumeType getConsumeType() {
- return consumeType;
- }
-
-
- public void setConsumeType(ConsumeType consumeType) {
- this.consumeType = consumeType;
- }
-
-
- public MessageModel getMessageModel() {
- return messageModel;
- }
-
-
- public void setMessageModel(MessageModel messageModel) {
- this.messageModel = messageModel;
- }
-
-
- public ConsumeFromWhere getConsumeFromWhere() {
- return consumeFromWhere;
- }
-
-
- public void setConsumeFromWhere(ConsumeFromWhere consumeFromWhere) {
- this.consumeFromWhere = consumeFromWhere;
- }
-
-
- public Set<SubscriptionData> getSubscriptionDataSet() {
- return subscriptionDataSet;
- }
-
-
- public void setSubscriptionDataSet(Set<SubscriptionData> subscriptionDataSet) {
- this.subscriptionDataSet = subscriptionDataSet;
- }
-
-
- public boolean isUnitMode() {
- return unitMode;
- }
-
-
- public void setUnitMode(boolean isUnitMode) {
- this.unitMode = isUnitMode;
- }
-
-
- @Override
- public String toString() {
- return "ConsumerData [groupName=" + groupName + ", consumeType=" + consumeType + ", messageModel="
- + messageModel + ", consumeFromWhere=" + consumeFromWhere + ", unitMode=" + unitMode
- + ", subscriptionDataSet=" + subscriptionDataSet + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/HeartbeatData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/HeartbeatData.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/HeartbeatData.java
deleted file mode 100644
index 8f11e39..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/HeartbeatData.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: HeartbeatData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.heartbeat;
-
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.HashSet;
-import java.util.Set;
-
-
-/**
- * @author shijia.wxr
- */
-public class HeartbeatData extends RemotingSerializable {
- private String clientID;
- private Set<ProducerData> producerDataSet = new HashSet<ProducerData>();
- private Set<ConsumerData> consumerDataSet = new HashSet<ConsumerData>();
-
-
- public String getClientID() {
- return clientID;
- }
-
-
- public void setClientID(String clientID) {
- this.clientID = clientID;
- }
-
-
- public Set<ProducerData> getProducerDataSet() {
- return producerDataSet;
- }
-
-
- public void setProducerDataSet(Set<ProducerData> producerDataSet) {
- this.producerDataSet = producerDataSet;
- }
-
-
- public Set<ConsumerData> getConsumerDataSet() {
- return consumerDataSet;
- }
-
-
- public void setConsumerDataSet(Set<ConsumerData> consumerDataSet) {
- this.consumerDataSet = consumerDataSet;
- }
-
-
- @Override
- public String toString() {
- return "HeartbeatData [clientID=" + clientID + ", producerDataSet=" + producerDataSet
- + ", consumerDataSet=" + consumerDataSet + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/MessageModel.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/MessageModel.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/MessageModel.java
deleted file mode 100644
index 1ff74fa..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/MessageModel.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: MessageModel.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.heartbeat;
-
-/**
- * Message model
- *
- * @author shijia.wxr
- */
-public enum MessageModel {
- /**
- * broadcast
- */
- BROADCASTING("BROADCASTING"),
- /**
- * clustering
- */
- CLUSTERING("CLUSTERING");
-
- private String modeCN;
-
- MessageModel(String modeCN) {
- this.modeCN = modeCN;
- }
-
-
- public String getModeCN() {
- return modeCN;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/ProducerData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/ProducerData.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/ProducerData.java
deleted file mode 100644
index ee95ddd..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/ProducerData.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: ProducerData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.heartbeat;
-
-/**
- * @author shijia.wxr
- */
-public class ProducerData {
- private String groupName;
-
-
- public String getGroupName() {
- return groupName;
- }
-
-
- public void setGroupName(String groupName) {
- this.groupName = groupName;
- }
-
-
- @Override
- public String toString() {
- return "ProducerData [groupName=" + groupName + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/SubscriptionData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/SubscriptionData.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/SubscriptionData.java
deleted file mode 100644
index b4b72fc..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/heartbeat/SubscriptionData.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: SubscriptionData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.heartbeat;
-
-import com.alibaba.fastjson.annotation.JSONField;
-
-import java.util.HashSet;
-import java.util.Set;
-
-
-/**
- * @author shijia.wxr
- */
-public class SubscriptionData implements Comparable<SubscriptionData> {
- public final static String SUB_ALL = "*";
- private boolean classFilterMode = false;
- private String topic;
- private String subString;
- private Set<String> tagsSet = new HashSet<String>();
- private Set<Integer> codeSet = new HashSet<Integer>();
- private long subVersion = System.currentTimeMillis();
-
- @JSONField(serialize = false)
- private String filterClassSource;
-
-
- public SubscriptionData() {
-
- }
-
-
- public SubscriptionData(String topic, String subString) {
- super();
- this.topic = topic;
- this.subString = subString;
- }
-
- public String getFilterClassSource() {
- return filterClassSource;
- }
-
- public void setFilterClassSource(String filterClassSource) {
- this.filterClassSource = filterClassSource;
- }
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public String getSubString() {
- return subString;
- }
-
-
- public void setSubString(String subString) {
- this.subString = subString;
- }
-
-
- public Set<String> getTagsSet() {
- return tagsSet;
- }
-
-
- public void setTagsSet(Set<String> tagsSet) {
- this.tagsSet = tagsSet;
- }
-
-
- public long getSubVersion() {
- return subVersion;
- }
-
-
- public void setSubVersion(long subVersion) {
- this.subVersion = subVersion;
- }
-
-
- public Set<Integer> getCodeSet() {
- return codeSet;
- }
-
-
- public void setCodeSet(Set<Integer> codeSet) {
- this.codeSet = codeSet;
- }
-
-
- public boolean isClassFilterMode() {
- return classFilterMode;
- }
-
-
- public void setClassFilterMode(boolean classFilterMode) {
- this.classFilterMode = classFilterMode;
- }
-
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (classFilterMode ? 1231 : 1237);
- result = prime * result + ((codeSet == null) ? 0 : codeSet.hashCode());
- result = prime * result + ((subString == null) ? 0 : subString.hashCode());
- result = prime * result + ((tagsSet == null) ? 0 : tagsSet.hashCode());
- result = prime * result + ((topic == null) ? 0 : topic.hashCode());
- return result;
- }
-
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- SubscriptionData other = (SubscriptionData) obj;
- if (classFilterMode != other.classFilterMode)
- return false;
- if (codeSet == null) {
- if (other.codeSet != null)
- return false;
- } else if (!codeSet.equals(other.codeSet))
- return false;
- if (subString == null) {
- if (other.subString != null)
- return false;
- } else if (!subString.equals(other.subString))
- return false;
- if (subVersion != other.subVersion)
- return false;
- if (tagsSet == null) {
- if (other.tagsSet != null)
- return false;
- } else if (!tagsSet.equals(other.tagsSet))
- return false;
- if (topic == null) {
- if (other.topic != null)
- return false;
- } else if (!topic.equals(other.topic))
- return false;
- return true;
- }
-
-
- @Override
- public String toString() {
- return "SubscriptionData [classFilterMode=" + classFilterMode + ", topic=" + topic + ", subString="
- + subString + ", tagsSet=" + tagsSet + ", codeSet=" + codeSet + ", subVersion=" + subVersion
- + "]";
- }
-
-
- @Override
- public int compareTo(SubscriptionData other) {
- String thisValue = this.topic + "@" + this.subString;
- String otherValue = other.topic + "@" + other.subString;
- return thisValue.compareTo(otherValue);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/route/BrokerData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/route/BrokerData.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/route/BrokerData.java
deleted file mode 100644
index 322953a..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/route/BrokerData.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: BrokerData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.route;
-
-import com.alibaba.rocketmq.common.MixAll;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class BrokerData implements Comparable<BrokerData> {
- private String cluster;
- private String brokerName;
- private HashMap<Long/* brokerId */, String/* broker address */> brokerAddrs;
-
- public String selectBrokerAddr() {
- String value = this.brokerAddrs.get(MixAll.MASTER_ID);
- if (null == value) {
- for (Map.Entry<Long, String> entry : this.brokerAddrs.entrySet()) {
- return entry.getValue();
- }
- }
-
- return value;
- }
-
- public HashMap<Long, String> getBrokerAddrs() {
- return brokerAddrs;
- }
-
- public void setBrokerAddrs(HashMap<Long, String> brokerAddrs) {
- this.brokerAddrs = brokerAddrs;
- }
-
- public String getCluster() {
- return cluster;
- }
-
- public void setCluster(String cluster) {
- this.cluster = cluster;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((brokerAddrs == null) ? 0 : brokerAddrs.hashCode());
- result = prime * result + ((brokerName == null) ? 0 : brokerName.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- BrokerData other = (BrokerData) obj;
- if (brokerAddrs == null) {
- if (other.brokerAddrs != null)
- return false;
- } else if (!brokerAddrs.equals(other.brokerAddrs))
- return false;
- if (brokerName == null) {
- if (other.brokerName != null)
- return false;
- } else if (!brokerName.equals(other.brokerName))
- return false;
- return true;
- }
-
- @Override
- public String toString() {
- return "BrokerData [brokerName=" + brokerName + ", brokerAddrs=" + brokerAddrs + "]";
- }
-
- @Override
- public int compareTo(BrokerData o) {
- return this.brokerName.compareTo(o.getBrokerName());
- }
-
- public String getBrokerName() {
- return brokerName;
- }
-
- public void setBrokerName(String brokerName) {
- this.brokerName = brokerName;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/route/QueueData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/route/QueueData.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/route/QueueData.java
deleted file mode 100644
index 6f62340..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/route/QueueData.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: QueueData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.route;
-
-public class QueueData implements Comparable<QueueData> {
- private String brokerName;
- private int readQueueNums;
- private int writeQueueNums;
- private int perm;
- private int topicSynFlag;
-
- public int getReadQueueNums() {
- return readQueueNums;
- }
-
- public void setReadQueueNums(int readQueueNums) {
- this.readQueueNums = readQueueNums;
- }
-
- public int getWriteQueueNums() {
- return writeQueueNums;
- }
-
- public void setWriteQueueNums(int writeQueueNums) {
- this.writeQueueNums = writeQueueNums;
- }
-
- public int getPerm() {
- return perm;
- }
-
- public void setPerm(int perm) {
- this.perm = perm;
- }
-
- public int getTopicSynFlag() {
- return topicSynFlag;
- }
-
- public void setTopicSynFlag(int topicSynFlag) {
- this.topicSynFlag = topicSynFlag;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((brokerName == null) ? 0 : brokerName.hashCode());
- result = prime * result + perm;
- result = prime * result + readQueueNums;
- result = prime * result + writeQueueNums;
- result = prime * result + topicSynFlag;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- QueueData other = (QueueData) obj;
- if (brokerName == null) {
- if (other.brokerName != null)
- return false;
- } else if (!brokerName.equals(other.brokerName))
- return false;
- if (perm != other.perm)
- return false;
- if (readQueueNums != other.readQueueNums)
- return false;
- if (writeQueueNums != other.writeQueueNums)
- return false;
- if (topicSynFlag != other.topicSynFlag)
- return false;
- return true;
- }
-
- @Override
- public String toString() {
- return "QueueData [brokerName=" + brokerName + ", readQueueNums=" + readQueueNums
- + ", writeQueueNums=" + writeQueueNums + ", perm=" + perm + ", topicSynFlag=" + topicSynFlag
- + "]";
- }
-
- @Override
- public int compareTo(QueueData o) {
- return this.brokerName.compareTo(o.getBrokerName());
- }
-
- public String getBrokerName() {
- return brokerName;
- }
-
- public void setBrokerName(String brokerName) {
- this.brokerName = brokerName;
- }
-}
[08/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java
new file mode 100644
index 0000000..4fc057d
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java
@@ -0,0 +1,73 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.annotation.CFNullable;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author manhong.yqd
+ *
+ */
+public class GetConsumerStatusRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String topic;
+ @CFNotNull
+ private String group;
+ @CFNullable
+ private String clientAddr;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ // TODO Auto-generated method stub
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public String getGroup() {
+ return group;
+ }
+
+
+ public void setGroup(String group) {
+ this.group = group;
+ }
+
+
+ public String getClientAddr() {
+ return clientAddr;
+ }
+
+
+ public void setClientAddr(String clientAddr) {
+ this.clientAddr = clientAddr;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
new file mode 100644
index 0000000..00e2d84
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
@@ -0,0 +1,62 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: GetEarliestMsgStoretimeRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class GetEarliestMsgStoretimeRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String topic;
+ @CFNotNull
+ private Integer queueId;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ // TODO Auto-generated method stub
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public Integer getQueueId() {
+ return queueId;
+ }
+
+
+ public void setQueueId(Integer queueId) {
+ this.queueId = queueId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
new file mode 100644
index 0000000..84e6925
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
@@ -0,0 +1,49 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: GetEarliestMsgStoretimeResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class GetEarliestMsgStoretimeResponseHeader implements CommandCustomHeader {
+ @CFNotNull
+ private Long timestamp;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public Long getTimestamp() {
+ return timestamp;
+ }
+
+
+ public void setTimestamp(Long timestamp) {
+ this.timestamp = timestamp;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
new file mode 100644
index 0000000..1fff0b8
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
@@ -0,0 +1,61 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: GetMaxOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class GetMaxOffsetRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String topic;
+ @CFNotNull
+ private Integer queueId;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public Integer getQueueId() {
+ return queueId;
+ }
+
+
+ public void setQueueId(Integer queueId) {
+ this.queueId = queueId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
new file mode 100644
index 0000000..577e405
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
@@ -0,0 +1,49 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: GetMaxOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class GetMaxOffsetResponseHeader implements CommandCustomHeader {
+ @CFNotNull
+ private Long offset;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public Long getOffset() {
+ return offset;
+ }
+
+
+ public void setOffset(Long offset) {
+ this.offset = offset;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
new file mode 100644
index 0000000..687f003
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
@@ -0,0 +1,61 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: GetMinOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class GetMinOffsetRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String topic;
+ @CFNotNull
+ private Integer queueId;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public Integer getQueueId() {
+ return queueId;
+ }
+
+
+ public void setQueueId(Integer queueId) {
+ this.queueId = queueId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
new file mode 100644
index 0000000..4c788db
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
@@ -0,0 +1,49 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: GetMinOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class GetMinOffsetResponseHeader implements CommandCustomHeader {
+ @CFNotNull
+ private Long offset;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public Long getOffset() {
+ return offset;
+ }
+
+
+ public void setOffset(Long offset) {
+ this.offset = offset;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java
new file mode 100644
index 0000000..078d632
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java
@@ -0,0 +1,48 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class GetProducerConnectionListRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String producerGroup;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ // To change body of implemented methods use File | Settings | File
+ // Templates.
+ }
+
+
+ public String getProducerGroup() {
+ return producerGroup;
+ }
+
+
+ public void setProducerGroup(String producerGroup) {
+ this.producerGroup = producerGroup;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java
new file mode 100644
index 0000000..5c65c33
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java
@@ -0,0 +1,47 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ *
+ */
+public class GetTopicStatsInfoRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String topic;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicsByClusterRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicsByClusterRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicsByClusterRequestHeader.java
new file mode 100644
index 0000000..439c2ad
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicsByClusterRequestHeader.java
@@ -0,0 +1,47 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author manhong.yqd
+ *
+ */
+public class GetTopicsByClusterRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String cluster;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getCluster() {
+ return cluster;
+ }
+
+
+ public void setCluster(String cluster) {
+ this.cluster = cluster;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java
new file mode 100644
index 0000000..bbd812f
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java
@@ -0,0 +1,46 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class NotifyConsumerIdsChangedRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String consumerGroup;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
new file mode 100644
index 0000000..f8cd7d6
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
@@ -0,0 +1,158 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: PullMessageRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.annotation.CFNullable;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class PullMessageRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String consumerGroup;
+ @CFNotNull
+ private String topic;
+ @CFNotNull
+ private Integer queueId;
+ @CFNotNull
+ private Long queueOffset;
+ @CFNotNull
+ private Integer maxMsgNums;
+ @CFNotNull
+ private Integer sysFlag;
+ @CFNotNull
+ private Long commitOffset;
+ @CFNotNull
+ private Long suspendTimeoutMillis;
+ @CFNullable
+ private String subscription;
+ @CFNotNull
+ private Long subVersion;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public Integer getQueueId() {
+ return queueId;
+ }
+
+
+ public void setQueueId(Integer queueId) {
+ this.queueId = queueId;
+ }
+
+
+ public Long getQueueOffset() {
+ return queueOffset;
+ }
+
+
+ public void setQueueOffset(Long queueOffset) {
+ this.queueOffset = queueOffset;
+ }
+
+
+ public Integer getMaxMsgNums() {
+ return maxMsgNums;
+ }
+
+
+ public void setMaxMsgNums(Integer maxMsgNums) {
+ this.maxMsgNums = maxMsgNums;
+ }
+
+
+ public Integer getSysFlag() {
+ return sysFlag;
+ }
+
+
+ public void setSysFlag(Integer sysFlag) {
+ this.sysFlag = sysFlag;
+ }
+
+
+ public Long getCommitOffset() {
+ return commitOffset;
+ }
+
+
+ public void setCommitOffset(Long commitOffset) {
+ this.commitOffset = commitOffset;
+ }
+
+
+ public Long getSuspendTimeoutMillis() {
+ return suspendTimeoutMillis;
+ }
+
+
+ public void setSuspendTimeoutMillis(Long suspendTimeoutMillis) {
+ this.suspendTimeoutMillis = suspendTimeoutMillis;
+ }
+
+
+ public String getSubscription() {
+ return subscription;
+ }
+
+
+ public void setSubscription(String subscription) {
+ this.subscription = subscription;
+ }
+
+
+ public Long getSubVersion() {
+ return subVersion;
+ }
+
+
+ public void setSubVersion(Long subVersion) {
+ this.subVersion = subVersion;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
new file mode 100644
index 0000000..f532735
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
@@ -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.
+ */
+
+/**
+ * $Id: PullMessageResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class PullMessageResponseHeader implements CommandCustomHeader {
+ @CFNotNull
+ private Long suggestWhichBrokerId;
+ @CFNotNull
+ private Long nextBeginOffset;
+ @CFNotNull
+ private Long minOffset;
+ @CFNotNull
+ private Long maxOffset;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public Long getNextBeginOffset() {
+ return nextBeginOffset;
+ }
+
+
+ public void setNextBeginOffset(Long nextBeginOffset) {
+ this.nextBeginOffset = nextBeginOffset;
+ }
+
+
+ public Long getMinOffset() {
+ return minOffset;
+ }
+
+
+ public void setMinOffset(Long minOffset) {
+ this.minOffset = minOffset;
+ }
+
+
+ public Long getMaxOffset() {
+ return maxOffset;
+ }
+
+
+ public void setMaxOffset(Long maxOffset) {
+ this.maxOffset = maxOffset;
+ }
+
+
+ public Long getSuggestWhichBrokerId() {
+ return suggestWhichBrokerId;
+ }
+
+
+ public void setSuggestWhichBrokerId(Long suggestWhichBrokerId) {
+ this.suggestWhichBrokerId = suggestWhichBrokerId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumeTimeSpanRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumeTimeSpanRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumeTimeSpanRequestHeader.java
new file mode 100644
index 0000000..fa3030c
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumeTimeSpanRequestHeader.java
@@ -0,0 +1,59 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author manhong.yqd
+ *
+ */
+public class QueryConsumeTimeSpanRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String topic;
+ @CFNotNull
+ private String group;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public String getGroup() {
+ return group;
+ }
+
+
+ public void setGroup(String group) {
+ this.group = group;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
new file mode 100644
index 0000000..9449c57
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
@@ -0,0 +1,73 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: QueryConsumerOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class QueryConsumerOffsetRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String consumerGroup;
+ @CFNotNull
+ private String topic;
+ @CFNotNull
+ private Integer queueId;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public Integer getQueueId() {
+ return queueId;
+ }
+
+
+ public void setQueueId(Integer queueId) {
+ this.queueId = queueId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
new file mode 100644
index 0000000..55f41e5
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
@@ -0,0 +1,49 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: QueryConsumerOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class QueryConsumerOffsetResponseHeader implements CommandCustomHeader {
+ @CFNotNull
+ private Long offset;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public Long getOffset() {
+ return offset;
+ }
+
+
+ public void setOffset(Long offset) {
+ this.offset = offset;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
new file mode 100644
index 0000000..5ddb27a
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
@@ -0,0 +1,75 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: GetMinOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ *
+ * @author manhong.yqd
+ *
+ */
+public class QueryCorrectionOffsetHeader implements CommandCustomHeader {
+ private String filterGroups;
+ @CFNotNull
+ private String compareGroup;
+ @CFNotNull
+ private String topic;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ // TODO Auto-generated method stub
+ }
+
+
+ public String getFilterGroups() {
+ return filterGroups;
+ }
+
+
+ public void setFilterGroups(String filterGroups) {
+ this.filterGroups = filterGroups;
+ }
+
+
+ public String getCompareGroup() {
+ return compareGroup;
+ }
+
+
+ public void setCompareGroup(String compareGroup) {
+ this.compareGroup = compareGroup;
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
new file mode 100644
index 0000000..a72d33d
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
@@ -0,0 +1,98 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: QueryMessageRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class QueryMessageRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String topic;
+ @CFNotNull
+ private String key;
+ @CFNotNull
+ private Integer maxNum;
+ @CFNotNull
+ private Long beginTimestamp;
+ @CFNotNull
+ private Long endTimestamp;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public String getKey() {
+ return key;
+ }
+
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+
+ public Integer getMaxNum() {
+ return maxNum;
+ }
+
+
+ public void setMaxNum(Integer maxNum) {
+ this.maxNum = maxNum;
+ }
+
+
+ public Long getBeginTimestamp() {
+ return beginTimestamp;
+ }
+
+
+ public void setBeginTimestamp(Long beginTimestamp) {
+ this.beginTimestamp = beginTimestamp;
+ }
+
+
+ public Long getEndTimestamp() {
+ return endTimestamp;
+ }
+
+
+ public void setEndTimestamp(Long endTimestamp) {
+ this.endTimestamp = endTimestamp;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
new file mode 100644
index 0000000..978101f
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
@@ -0,0 +1,61 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: QueryMessageResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class QueryMessageResponseHeader implements CommandCustomHeader {
+ @CFNotNull
+ private Long indexLastUpdateTimestamp;
+ @CFNotNull
+ private Long indexLastUpdatePhyoffset;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public Long getIndexLastUpdateTimestamp() {
+ return indexLastUpdateTimestamp;
+ }
+
+
+ public void setIndexLastUpdateTimestamp(Long indexLastUpdateTimestamp) {
+ this.indexLastUpdateTimestamp = indexLastUpdateTimestamp;
+ }
+
+
+ public Long getIndexLastUpdatePhyoffset() {
+ return indexLastUpdatePhyoffset;
+ }
+
+
+ public void setIndexLastUpdatePhyoffset(Long indexLastUpdatePhyoffset) {
+ this.indexLastUpdatePhyoffset = indexLastUpdatePhyoffset;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
new file mode 100644
index 0000000..8b97a4f
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
@@ -0,0 +1,50 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: QueryMessageRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class QueryTopicConsumeByWhoRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String topic;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java
new file mode 100644
index 0000000..c8294e7
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java
@@ -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.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ *
+ * @author manhong.yqd
+ *
+ */
+public class ResetOffsetRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String topic;
+ @CFNotNull
+ private String group;
+ @CFNotNull
+ private long timestamp;
+ @CFNotNull
+ private boolean isForce;
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public String getGroup() {
+ return group;
+ }
+
+
+ public void setGroup(String group) {
+ this.group = group;
+ }
+
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+
+ public void setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+
+ public boolean isForce() {
+ return isForce;
+ }
+
+
+ public void setForce(boolean isForce) {
+ this.isForce = isForce;
+ }
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
new file mode 100644
index 0000000..963d10d
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
@@ -0,0 +1,76 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: SearchOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class SearchOffsetRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String topic;
+ @CFNotNull
+ private Integer queueId;
+ @CFNotNull
+ private Long timestamp;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public Integer getQueueId() {
+ return queueId;
+ }
+
+
+ public void setQueueId(Integer queueId) {
+ this.queueId = queueId;
+ }
+
+
+ public Long getTimestamp() {
+ return timestamp;
+ }
+
+
+ public void setTimestamp(Long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
new file mode 100644
index 0000000..422c6d4
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
@@ -0,0 +1,49 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: SearchOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class SearchOffsetResponseHeader implements CommandCustomHeader {
+ @CFNotNull
+ private Long offset;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public Long getOffset() {
+ return offset;
+ }
+
+
+ public void setOffset(Long offset) {
+ this.offset = offset;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
new file mode 100644
index 0000000..589f4fc
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
@@ -0,0 +1,181 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: SendMessageRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.annotation.CFNullable;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class SendMessageRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String producerGroup;
+ @CFNotNull
+ private String topic;
+ @CFNotNull
+ private String defaultTopic;
+ @CFNotNull
+ private Integer defaultTopicQueueNums;
+ @CFNotNull
+ private Integer queueId;
+ @CFNotNull
+ private Integer sysFlag;
+ @CFNotNull
+ private Long bornTimestamp;
+ @CFNotNull
+ private Integer flag;
+ @CFNullable
+ private String properties;
+ @CFNullable
+ private Integer reconsumeTimes;
+ @CFNullable
+ private boolean unitMode = false;
+ private Integer maxReconsumeTimes;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getProducerGroup() {
+ return producerGroup;
+ }
+
+
+ public void setProducerGroup(String producerGroup) {
+ this.producerGroup = producerGroup;
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public String getDefaultTopic() {
+ return defaultTopic;
+ }
+
+
+ public void setDefaultTopic(String defaultTopic) {
+ this.defaultTopic = defaultTopic;
+ }
+
+
+ public Integer getDefaultTopicQueueNums() {
+ return defaultTopicQueueNums;
+ }
+
+
+ public void setDefaultTopicQueueNums(Integer defaultTopicQueueNums) {
+ this.defaultTopicQueueNums = defaultTopicQueueNums;
+ }
+
+
+ public Integer getQueueId() {
+ return queueId;
+ }
+
+
+ public void setQueueId(Integer queueId) {
+ this.queueId = queueId;
+ }
+
+
+ public Integer getSysFlag() {
+ return sysFlag;
+ }
+
+
+ public void setSysFlag(Integer sysFlag) {
+ this.sysFlag = sysFlag;
+ }
+
+
+ public Long getBornTimestamp() {
+ return bornTimestamp;
+ }
+
+
+ public void setBornTimestamp(Long bornTimestamp) {
+ this.bornTimestamp = bornTimestamp;
+ }
+
+
+ public Integer getFlag() {
+ return flag;
+ }
+
+
+ public void setFlag(Integer flag) {
+ this.flag = flag;
+ }
+
+
+ public String getProperties() {
+ return properties;
+ }
+
+
+ public void setProperties(String properties) {
+ this.properties = properties;
+ }
+
+
+ public Integer getReconsumeTimes() {
+ return reconsumeTimes;
+ }
+
+
+ public void setReconsumeTimes(Integer reconsumeTimes) {
+ this.reconsumeTimes = reconsumeTimes;
+ }
+
+
+ public boolean isUnitMode() {
+ return unitMode;
+ }
+
+
+ public void setUnitMode(boolean isUnitMode) {
+ this.unitMode = isUnitMode;
+ }
+
+
+ public Integer getMaxReconsumeTimes() {
+ return maxReconsumeTimes;
+ }
+
+
+ public void setMaxReconsumeTimes(final Integer maxReconsumeTimes) {
+ this.maxReconsumeTimes = maxReconsumeTimes;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
new file mode 100644
index 0000000..e467d9f
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
@@ -0,0 +1,212 @@
+/**
+ * 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 producerGroup 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.annotation.CFNullable;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * Use short variable name to speed up FastJson deserialization process.
+ * @author shijia.wxr
+ */
+public class SendMessageRequestHeaderV2 implements CommandCustomHeader {
+ @CFNotNull
+ private String a; // producerGroup;
+ @CFNotNull
+ private String b; // topic;
+ @CFNotNull
+ private String c; // defaultTopic;
+ @CFNotNull
+ private Integer d; // defaultTopicQueueNums;
+ @CFNotNull
+ private Integer e; // queueId;
+ @CFNotNull
+ private Integer f; // sysFlag;
+ @CFNotNull
+ private Long g; // bornTimestamp;
+ @CFNotNull
+ private Integer h; // flag;
+ @CFNullable
+ private String i; // properties;
+ @CFNullable
+ private Integer j; // reconsumeTimes;
+ @CFNullable
+ private boolean k; // unitMode = false;
+
+ private Integer l; // consumeRetryTimes
+
+ public static SendMessageRequestHeader createSendMessageRequestHeaderV1(final SendMessageRequestHeaderV2 v2) {
+ SendMessageRequestHeader v1 = new SendMessageRequestHeader();
+ v1.setProducerGroup(v2.a);
+ v1.setTopic(v2.b);
+ v1.setDefaultTopic(v2.c);
+ v1.setDefaultTopicQueueNums(v2.d);
+ v1.setQueueId(v2.e);
+ v1.setSysFlag(v2.f);
+ v1.setBornTimestamp(v2.g);
+ v1.setFlag(v2.h);
+ v1.setProperties(v2.i);
+ v1.setReconsumeTimes(v2.j);
+ v1.setUnitMode(v2.k);
+ v1.setMaxReconsumeTimes(v2.l);
+ return v1;
+ }
+
+ public static SendMessageRequestHeaderV2 createSendMessageRequestHeaderV2(final SendMessageRequestHeader v1) {
+ SendMessageRequestHeaderV2 v2 = new SendMessageRequestHeaderV2();
+ v2.a = v1.getProducerGroup();
+ v2.b = v1.getTopic();
+ v2.c = v1.getDefaultTopic();
+ v2.d = v1.getDefaultTopicQueueNums();
+ v2.e = v1.getQueueId();
+ v2.f = v1.getSysFlag();
+ v2.g = v1.getBornTimestamp();
+ v2.h = v1.getFlag();
+ v2.i = v1.getProperties();
+ v2.j = v1.getReconsumeTimes();
+ v2.k = v1.isUnitMode();
+ v2.l = v1.getMaxReconsumeTimes();
+ return v2;
+ }
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+ public String getA() {
+ return a;
+ }
+
+
+ public void setA(String a) {
+ this.a = a;
+ }
+
+
+ public String getB() {
+ return b;
+ }
+
+
+ public void setB(String b) {
+ this.b = b;
+ }
+
+
+ public String getC() {
+ return c;
+ }
+
+
+ public void setC(String c) {
+ this.c = c;
+ }
+
+
+ public Integer getD() {
+ return d;
+ }
+
+
+ public void setD(Integer d) {
+ this.d = d;
+ }
+
+
+ public Integer getE() {
+ return e;
+ }
+
+
+ public void setE(Integer e) {
+ this.e = e;
+ }
+
+
+ public Integer getF() {
+ return f;
+ }
+
+
+ public void setF(Integer f) {
+ this.f = f;
+ }
+
+
+ public Long getG() {
+ return g;
+ }
+
+
+ public void setG(Long g) {
+ this.g = g;
+ }
+
+
+ public Integer getH() {
+ return h;
+ }
+
+
+ public void setH(Integer h) {
+ this.h = h;
+ }
+
+
+ public String getI() {
+ return i;
+ }
+
+
+ public void setI(String i) {
+ this.i = i;
+ }
+
+
+ public Integer getJ() {
+ return j;
+ }
+
+
+ public void setJ(Integer j) {
+ this.j = j;
+ }
+
+
+ public boolean isK() {
+ return k;
+ }
+
+
+ public void setK(boolean k) {
+ this.k = k;
+ }
+
+
+ public Integer getL() {
+ return l;
+ }
+
+
+ public void setL(final Integer l) {
+ this.l = l;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
new file mode 100644
index 0000000..32c55c0
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
@@ -0,0 +1,82 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: SendMessageResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class SendMessageResponseHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String msgId;
+ @CFNotNull
+ private Integer queueId;
+ @CFNotNull
+ private Long queueOffset;
+ private String transactionId;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getMsgId() {
+ return msgId;
+ }
+
+
+ public void setMsgId(String msgId) {
+ this.msgId = msgId;
+ }
+
+
+ public Integer getQueueId() {
+ return queueId;
+ }
+
+
+ public void setQueueId(Integer queueId) {
+ this.queueId = queueId;
+ }
+
+
+ public Long getQueueOffset() {
+ return queueOffset;
+ }
+
+
+ public void setQueueOffset(Long queueOffset) {
+ this.queueOffset = queueOffset;
+ }
+
+ public String getTransactionId() {
+ return transactionId;
+ }
+
+ public void setTransactionId(String transactionId) {
+ this.transactionId = transactionId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
new file mode 100644
index 0000000..1fac7b6
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
@@ -0,0 +1,77 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.annotation.CFNullable;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class UnregisterClientRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String clientID;
+
+ @CFNullable
+ private String producerGroup;
+ @CFNullable
+ private String consumerGroup;
+
+
+ public String getClientID() {
+ return clientID;
+ }
+
+
+ public void setClientID(String clientID) {
+ this.clientID = clientID;
+ }
+
+
+ public String getProducerGroup() {
+ return producerGroup;
+ }
+
+
+ public void setProducerGroup(String producerGroup) {
+ this.producerGroup = producerGroup;
+ }
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ // TODO Auto-generated method stub
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
new file mode 100644
index 0000000..a6d016c
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
@@ -0,0 +1,38 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class UnregisterClientResponseHeader implements CommandCustomHeader {
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
new file mode 100644
index 0000000..7fc015e
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
@@ -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.
+ */
+
+/**
+ * $Id: UpdateConsumerOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class UpdateConsumerOffsetRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String consumerGroup;
+ @CFNotNull
+ private String topic;
+ @CFNotNull
+ private Integer queueId;
+ @CFNotNull
+ private Long commitOffset;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public Integer getQueueId() {
+ return queueId;
+ }
+
+
+ public void setQueueId(Integer queueId) {
+ this.queueId = queueId;
+ }
+
+
+ public Long getCommitOffset() {
+ return commitOffset;
+ }
+
+
+ public void setCommitOffset(Long commitOffset) {
+ this.commitOffset = commitOffset;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
new file mode 100644
index 0000000..3d5454a
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
@@ -0,0 +1,35 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: UpdateConsumerOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class UpdateConsumerOffsetResponseHeader implements CommandCustomHeader {
+ @Override
+ public void checkFields() throws RemotingCommandException {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewBrokerStatsDataRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewBrokerStatsDataRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewBrokerStatsDataRequestHeader.java
new file mode 100644
index 0000000..6d11cd8
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewBrokerStatsDataRequestHeader.java
@@ -0,0 +1,56 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+public class ViewBrokerStatsDataRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String statsName;
+ @CFNotNull
+ private String statsKey;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+
+ }
+
+
+ public String getStatsName() {
+ return statsName;
+ }
+
+
+ public void setStatsName(String statsName) {
+ this.statsName = statsName;
+ }
+
+
+ public String getStatsKey() {
+ return statsKey;
+ }
+
+
+ public void setStatsKey(String statsKey) {
+ this.statsKey = statsKey;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
new file mode 100644
index 0000000..716d418
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
@@ -0,0 +1,49 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: ViewMessageRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ViewMessageRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private Long offset;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public Long getOffset() {
+ return offset;
+ }
+
+
+ public void setOffset(Long offset) {
+ this.offset = offset;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
new file mode 100644
index 0000000..c9284f9
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
@@ -0,0 +1,35 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: ViewMessageResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ViewMessageResponseHeader implements CommandCustomHeader {
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerRequestHeader.java
new file mode 100644
index 0000000..480e528
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerRequestHeader.java
@@ -0,0 +1,43 @@
+/**
+ * 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.common.protocol.header.filtersrv;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+public class RegisterFilterServerRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String filterServerAddr;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getFilterServerAddr() {
+ return filterServerAddr;
+ }
+
+
+ public void setFilterServerAddr(String filterServerAddr) {
+ this.filterServerAddr = filterServerAddr;
+ }
+}
[49/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/client/ProducerManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/client/ProducerManager.java b/broker/src/main/java/com/alibaba/rocketmq/broker/client/ProducerManager.java
deleted file mode 100644
index 74e7ea7..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/client/ProducerManager.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/**
- * 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.client;
-
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import com.alibaba.rocketmq.remoting.common.RemotingUtil;
-import io.netty.channel.Channel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-
-/**
- * @author shijia.wxr
- */
-public class ProducerManager {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
- private static final long LOCK_TIMEOUT_MILLIS = 3000;
- private static final long CHANNEL_EXPIRED_TIMEOUT = 1000 * 120;
- private final Lock groupChannelLock = new ReentrantLock();
- private final HashMap<String /* group name */, HashMap<Channel, ClientChannelInfo>> groupChannelTable =
- new HashMap<String, HashMap<Channel, ClientChannelInfo>>();
-
-
- public ProducerManager() {
- }
-
-
- public HashMap<String, HashMap<Channel, ClientChannelInfo>> getGroupChannelTable() {
- HashMap<String /* group name */, HashMap<Channel, ClientChannelInfo>> newGroupChannelTable =
- new HashMap<String, HashMap<Channel, ClientChannelInfo>>();
- try {
- if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
- try {
- newGroupChannelTable.putAll(groupChannelTable);
- } finally {
- groupChannelLock.unlock();
- }
- }
- } catch (InterruptedException e) {
- log.error("", e);
- }
- return newGroupChannelTable;
- }
-
-
- public void scanNotActiveChannel() {
- try {
- if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
- try {
- for (final Map.Entry<String, HashMap<Channel, ClientChannelInfo>> entry : this.groupChannelTable
- .entrySet()) {
- final String group = entry.getKey();
- final HashMap<Channel, ClientChannelInfo> chlMap = entry.getValue();
-
- Iterator<Entry<Channel, ClientChannelInfo>> it = chlMap.entrySet().iterator();
- while (it.hasNext()) {
- Entry<Channel, ClientChannelInfo> item = it.next();
- // final Integer id = item.getKey();
- final ClientChannelInfo info = item.getValue();
-
- long diff = System.currentTimeMillis() - info.getLastUpdateTimestamp();
- if (diff > CHANNEL_EXPIRED_TIMEOUT) {
- it.remove();
- log.warn(
- "SCAN: remove expired channel[{}] from ProducerManager groupChannelTable, producer group name: {}",
- RemotingHelper.parseChannelRemoteAddr(info.getChannel()), group);
- RemotingUtil.closeChannel(info.getChannel());
- }
- }
- }
- } finally {
- this.groupChannelLock.unlock();
- }
- } else {
- log.warn("ProducerManager scanNotActiveChannel lock timeout");
- }
- } catch (InterruptedException e) {
- log.error("", e);
- }
- }
-
-
- public void doChannelCloseEvent(final String remoteAddr, final Channel channel) {
- if (channel != null) {
- try {
- if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
- try {
- for (final Map.Entry<String, HashMap<Channel, ClientChannelInfo>> entry : this.groupChannelTable
- .entrySet()) {
- final String group = entry.getKey();
- final HashMap<Channel, ClientChannelInfo> clientChannelInfoTable =
- entry.getValue();
- final ClientChannelInfo clientChannelInfo =
- clientChannelInfoTable.remove(channel);
- if (clientChannelInfo != null) {
- log.info(
- "NETTY EVENT: remove channel[{}][{}] from ProducerManager groupChannelTable, producer group: {}",
- clientChannelInfo.toString(), remoteAddr, group);
- }
-
- }
- } finally {
- this.groupChannelLock.unlock();
- }
- } else {
- log.warn("ProducerManager doChannelCloseEvent lock timeout");
- }
- } catch (InterruptedException e) {
- log.error("", e);
- }
- }
- }
-
-
- public void registerProducer(final String group, final ClientChannelInfo clientChannelInfo) {
- try {
- ClientChannelInfo clientChannelInfoFound = null;
-
- if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
- try {
- HashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group);
- if (null == channelTable) {
- channelTable = new HashMap<Channel, ClientChannelInfo>();
- this.groupChannelTable.put(group, channelTable);
- }
-
- clientChannelInfoFound = channelTable.get(clientChannelInfo.getChannel());
- if (null == clientChannelInfoFound) {
- channelTable.put(clientChannelInfo.getChannel(), clientChannelInfo);
- log.info("new producer connected, group: {} channel: {}", group,
- clientChannelInfo.toString());
- }
- } finally {
- this.groupChannelLock.unlock();
- }
-
- if (clientChannelInfoFound != null) {
- clientChannelInfoFound.setLastUpdateTimestamp(System.currentTimeMillis());
- }
- } else {
- log.warn("ProducerManager registerProducer lock timeout");
- }
- } catch (InterruptedException e) {
- log.error("", e);
- }
- }
-
-
- public void unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo) {
- try {
- if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
- try {
- HashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group);
- if (null != channelTable && !channelTable.isEmpty()) {
- ClientChannelInfo old = channelTable.remove(clientChannelInfo.getChannel());
- if (old != null) {
- log.info("unregister a producer[{}] from groupChannelTable {}", group,
- clientChannelInfo.toString());
- }
-
- if (channelTable.isEmpty()) {
- this.groupChannelTable.remove(group);
- log.info("unregister a producer group[{}] from groupChannelTable", group);
- }
- }
- } finally {
- this.groupChannelLock.unlock();
- }
- } else {
- log.warn("ProducerManager unregisterProducer lock timeout");
- }
- } catch (InterruptedException e) {
- log.error("", e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/client/net/Broker2Client.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/client/net/Broker2Client.java b/broker/src/main/java/com/alibaba/rocketmq/broker/client/net/Broker2Client.java
deleted file mode 100644
index a38c9cb..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/client/net/Broker2Client.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/**
- * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.client.net;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import com.alibaba.rocketmq.broker.client.ClientChannelInfo;
-import com.alibaba.rocketmq.broker.client.ConsumerGroupInfo;
-import com.alibaba.rocketmq.broker.pagecache.OneMessageTransfer;
-import com.alibaba.rocketmq.common.MQVersion;
-import com.alibaba.rocketmq.common.TopicConfig;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.message.MessageQueueForC;
-import com.alibaba.rocketmq.common.protocol.RequestCode;
-import com.alibaba.rocketmq.common.protocol.ResponseCode;
-import com.alibaba.rocketmq.common.protocol.body.GetConsumerStatusBody;
-import com.alibaba.rocketmq.common.protocol.body.ResetOffsetBody;
-import com.alibaba.rocketmq.common.protocol.body.ResetOffsetBodyForC;
-import com.alibaba.rocketmq.common.protocol.header.CheckTransactionStateRequestHeader;
-import com.alibaba.rocketmq.common.protocol.header.GetConsumerStatusRequestHeader;
-import com.alibaba.rocketmq.common.protocol.header.NotifyConsumerIdsChangedRequestHeader;
-import com.alibaba.rocketmq.common.protocol.header.ResetOffsetRequestHeader;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import com.alibaba.rocketmq.remoting.exception.RemotingSendRequestException;
-import com.alibaba.rocketmq.remoting.exception.RemotingTimeoutException;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import com.alibaba.rocketmq.store.SelectMappedBufferResult;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelFutureListener;
-import io.netty.channel.FileRegion;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-
-
-/**
- * @author shijia.wxr
- */
-public class Broker2Client {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
- private final BrokerController brokerController;
-
- public Broker2Client(BrokerController brokerController) {
- this.brokerController = brokerController;
- }
-
- public void checkProducerTransactionState(
- final Channel channel,
- final CheckTransactionStateRequestHeader requestHeader,
- final SelectMappedBufferResult selectMappedBufferResult) {
- RemotingCommand request =
- RemotingCommand.createRequestCommand(RequestCode.CHECK_TRANSACTION_STATE, requestHeader);
- request.markOnewayRPC();
-
- try {
- FileRegion fileRegion =
- new OneMessageTransfer(request.encodeHeader(selectMappedBufferResult.getSize()),
- selectMappedBufferResult);
- channel.writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
- @Override
- public void operationComplete(ChannelFuture future) throws Exception {
- selectMappedBufferResult.release();
- if (!future.isSuccess()) {
- log.error("invokeProducer failed,", future.cause());
- }
- }
- });
- } catch (Throwable e) {
- log.error("invokeProducer exception", e);
- selectMappedBufferResult.release();
- }
- }
-
- public RemotingCommand callClient(final Channel channel,
- final RemotingCommand request
- ) throws RemotingSendRequestException, RemotingTimeoutException, InterruptedException {
- return this.brokerController.getRemotingServer().invokeSync(channel, request, 10000);
- }
-
- public void notifyConsumerIdsChanged(
- final Channel channel,
- final String consumerGroup) {
- if (null == consumerGroup) {
- log.error("notifyConsumerIdsChanged consumerGroup is null");
- return;
- }
-
- NotifyConsumerIdsChangedRequestHeader requestHeader = new NotifyConsumerIdsChangedRequestHeader();
- requestHeader.setConsumerGroup(consumerGroup);
- RemotingCommand request =
- RemotingCommand.createRequestCommand(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, requestHeader);
-
- try {
- this.brokerController.getRemotingServer().invokeOneway(channel, request, 10);
- } catch (Exception e) {
- log.error("notifyConsumerIdsChanged exception, " + consumerGroup, e.getMessage());
- }
- }
-
- public RemotingCommand resetOffset(String topic, String group, long timeStamp, boolean isForce) {
- return resetOffset(topic, group, timeStamp, isForce, false);
- }
-
- public RemotingCommand resetOffset(String topic, String group, long timeStamp, boolean isForce,
- boolean isC) {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
-
- TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
- if (null == topicConfig) {
- log.error("[reset-offset] reset offset failed, no topic in this broker. topic={}", topic);
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("[reset-offset] reset offset failed, no topic in this broker. topic=" + topic);
- return response;
- }
-
- Map<MessageQueue, Long> offsetTable = new HashMap<MessageQueue, Long>();
-
- for (int i = 0; i < topicConfig.getWriteQueueNums(); i++) {
- MessageQueue mq = new MessageQueue();
- mq.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());
- mq.setTopic(topic);
- mq.setQueueId(i);
-
- long consumerOffset =
- this.brokerController.getConsumerOffsetManager().queryOffset(group, topic, i);
- if (-1 == consumerOffset) {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark(String.format("THe consumer group <%s> not exist", group));
- return response;
- }
-
- long timeStampOffset;
- if (timeStamp == -1) {
-
- timeStampOffset = this.brokerController.getMessageStore().getMaxOffsetInQuque(topic, i);
- } else {
- timeStampOffset = this.brokerController.getMessageStore().getOffsetInQueueByTime(topic, i, timeStamp);
- }
-
- if (timeStampOffset < 0) {
- log.warn("reset offset is invalid. topic={}, queueId={}, timeStampOffset={}", topic, i, timeStampOffset);
- timeStampOffset = 0;
- }
-
- if (isForce || timeStampOffset < consumerOffset) {
- offsetTable.put(mq, timeStampOffset);
- } else {
- offsetTable.put(mq, consumerOffset);
- }
- }
-
- ResetOffsetRequestHeader requestHeader = new ResetOffsetRequestHeader();
- requestHeader.setTopic(topic);
- requestHeader.setGroup(group);
- requestHeader.setTimestamp(timeStamp);
- RemotingCommand request =
- RemotingCommand.createRequestCommand(RequestCode.RESET_CONSUMER_CLIENT_OFFSET, requestHeader);
- if (isC) {
- // c++ language
- ResetOffsetBodyForC body = new ResetOffsetBodyForC();
- List<MessageQueueForC> offsetList = convertOffsetTable2OffsetList(offsetTable);
- body.setOffsetTable(offsetList);
- request.setBody(body.encode());
- } else {
- // other language
- ResetOffsetBody body = new ResetOffsetBody();
- body.setOffsetTable(offsetTable);
- request.setBody(body.encode());
- }
-
- ConsumerGroupInfo consumerGroupInfo =
- this.brokerController.getConsumerManager().getConsumerGroupInfo(group);
-
- if (consumerGroupInfo != null && !consumerGroupInfo.getAllChannel().isEmpty()) {
- ConcurrentHashMap<Channel, ClientChannelInfo> channelInfoTable =
- consumerGroupInfo.getChannelInfoTable();
- for (Map.Entry<Channel, ClientChannelInfo> entry : channelInfoTable.entrySet()) {
- int version = entry.getValue().getVersion();
- if (version >= MQVersion.Version.V3_0_7_SNAPSHOT.ordinal()) {
- try {
- this.brokerController.getRemotingServer().invokeOneway(entry.getKey(), request, 5000);
- log.info("[reset-offset] reset offset success. topic={}, group={}, clientId={}",
- new Object[]{topic, group, entry.getValue().getClientId()});
- } catch (Exception e) {
- log.error("[reset-offset] reset offset exception. topic={}, group={}",
- new Object[]{topic, group}, e);
- }
- } else {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("the client does not support this feature. version="
- + MQVersion.getVersionDesc(version));
- log.warn("[reset-offset] the client does not support this feature. version={}",
- RemotingHelper.parseChannelRemoteAddr(entry.getKey()), MQVersion.getVersionDesc(version));
- return response;
- }
- }
- } else {
- String errorInfo =
- String.format("Consumer not online, so can not reset offset, Group: %s Topic: %s Timestamp: %d",
- requestHeader.getGroup(),
- requestHeader.getTopic(),
- requestHeader.getTimestamp());
- log.error(errorInfo);
- response.setCode(ResponseCode.CONSUMER_NOT_ONLINE);
- response.setRemark(errorInfo);
- return response;
- }
- response.setCode(ResponseCode.SUCCESS);
- ResetOffsetBody resBody = new ResetOffsetBody();
- resBody.setOffsetTable(offsetTable);
- response.setBody(resBody.encode());
- return response;
- }
-
- private List<MessageQueueForC> convertOffsetTable2OffsetList(Map<MessageQueue, Long> table) {
- List<MessageQueueForC> list = new ArrayList<MessageQueueForC>();
- for (Entry<MessageQueue, Long> entry : table.entrySet()) {
- MessageQueue mq = entry.getKey();
- MessageQueueForC tmp =
- new MessageQueueForC(mq.getTopic(), mq.getBrokerName(), mq.getQueueId(), entry.getValue());
- list.add(tmp);
- }
- return list;
- }
-
- public RemotingCommand getConsumeStatus(String topic, String group, String originClientId) {
- final RemotingCommand result = RemotingCommand.createResponseCommand(null);
-
- GetConsumerStatusRequestHeader requestHeader = new GetConsumerStatusRequestHeader();
- requestHeader.setTopic(topic);
- requestHeader.setGroup(group);
- RemotingCommand request =
- RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT,
- requestHeader);
-
- Map<String, Map<MessageQueue, Long>> consumerStatusTable =
- new HashMap<String, Map<MessageQueue, Long>>();
- ConcurrentHashMap<Channel, ClientChannelInfo> channelInfoTable =
- this.brokerController.getConsumerManager().getConsumerGroupInfo(group).getChannelInfoTable();
- if (null == channelInfoTable || channelInfoTable.isEmpty()) {
- result.setCode(ResponseCode.SYSTEM_ERROR);
- result.setRemark(String.format("No Any Consumer online in the consumer group: [%s]", group));
- return result;
- }
-
- for (Map.Entry<Channel, ClientChannelInfo> entry : channelInfoTable.entrySet()) {
- int version = entry.getValue().getVersion();
- String clientId = entry.getValue().getClientId();
- if (version < MQVersion.Version.V3_0_7_SNAPSHOT.ordinal()) {
- result.setCode(ResponseCode.SYSTEM_ERROR);
- result.setRemark("the client does not support this feature. version="
- + MQVersion.getVersionDesc(version));
- log.warn("[get-consumer-status] the client does not support this feature. version={}",
- RemotingHelper.parseChannelRemoteAddr(entry.getKey()), MQVersion.getVersionDesc(version));
- return result;
- } else if (UtilAll.isBlank(originClientId) || originClientId.equals(clientId)) {
- try {
- RemotingCommand response =
- this.brokerController.getRemotingServer().invokeSync(entry.getKey(), request, 5000);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- if (response.getBody() != null) {
- GetConsumerStatusBody body =
- GetConsumerStatusBody.decode(response.getBody(),
- GetConsumerStatusBody.class);
-
- consumerStatusTable.put(clientId, body.getMessageQueueTable());
- log.info(
- "[get-consumer-status] get consumer status success. topic={}, group={}, channelRemoteAddr={}",
- new Object[]{topic, group, clientId});
- }
- }
- default:
- break;
- }
- } catch (Exception e) {
- log.error(
- "[get-consumer-status] get consumer status exception. topic={}, group={}, offset={}",
- new Object[]{topic, group}, e);
- }
-
- if (!UtilAll.isBlank(originClientId) && originClientId.equals(clientId)) {
- break;
- }
- }
- }
-
- result.setCode(ResponseCode.SUCCESS);
- GetConsumerStatusBody resBody = new GetConsumerStatusBody();
- resBody.setConsumerTable(consumerStatusTable);
- result.setBody(resBody.encode());
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/client/rebalance/RebalanceLockManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/client/rebalance/RebalanceLockManager.java b/broker/src/main/java/com/alibaba/rocketmq/broker/client/rebalance/RebalanceLockManager.java
deleted file mode 100644
index 84be628..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/client/rebalance/RebalanceLockManager.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/**
- * 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.client.rebalance;
-
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-
-/**
- * @author shijia.wxr
- */
-public class RebalanceLockManager {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.REBALANCE_LOCK_LOGGER_NAME);
- private final static long REBALANCE_LOCK_MAX_LIVE_TIME = Long.parseLong(System.getProperty(
- "rocketmq.broker.rebalance.lockMaxLiveTime", "60000"));
- private final Lock lock = new ReentrantLock();
- private final ConcurrentHashMap<String/* group */, ConcurrentHashMap<MessageQueue, LockEntry>> mqLockTable =
- new ConcurrentHashMap<String, ConcurrentHashMap<MessageQueue, LockEntry>>(1024);
-
- public boolean tryLock(final String group, final MessageQueue mq, final String clientId) {
-
- if (!this.isLocked(group, mq, clientId)) {
- try {
- this.lock.lockInterruptibly();
- try {
- ConcurrentHashMap<MessageQueue, LockEntry> groupValue = this.mqLockTable.get(group);
- if (null == groupValue) {
- groupValue = new ConcurrentHashMap<MessageQueue, LockEntry>(32);
- this.mqLockTable.put(group, groupValue);
- }
-
- LockEntry lockEntry = groupValue.get(mq);
- if (null == lockEntry) {
- lockEntry = new LockEntry();
- lockEntry.setClientId(clientId);
- groupValue.put(mq, lockEntry);
- log.info("tryLock, message queue not locked, I got it. Group: {} NewClientId: {} {}", //
- group, //
- clientId, //
- mq);
- }
-
- if (lockEntry.isLocked(clientId)) {
- lockEntry.setLastUpdateTimestamp(System.currentTimeMillis());
- return true;
- }
-
- String oldClientId = lockEntry.getClientId();
-
-
- if (lockEntry.isExpired()) {
- lockEntry.setClientId(clientId);
- lockEntry.setLastUpdateTimestamp(System.currentTimeMillis());
- log.warn(
- "tryLock, message queue lock expired, I got it. Group: {} OldClientId: {} NewClientId: {} {}", //
- group, //
- oldClientId, //
- clientId, //
- mq);
- return true;
- }
-
-
- log.warn(
- "tryLock, message queue locked by other client. Group: {} OtherClientId: {} NewClientId: {} {}", //
- group, //
- oldClientId, //
- clientId, //
- mq);
- return false;
- } finally {
- this.lock.unlock();
- }
- } catch (InterruptedException e) {
- log.error("putMessage exception", e);
- }
- } else {
-
- }
-
- return true;
- }
-
- private boolean isLocked(final String group, final MessageQueue mq, final String clientId) {
- ConcurrentHashMap<MessageQueue, LockEntry> groupValue = this.mqLockTable.get(group);
- if (groupValue != null) {
- LockEntry lockEntry = groupValue.get(mq);
- if (lockEntry != null) {
- boolean locked = lockEntry.isLocked(clientId);
- if (locked) {
- lockEntry.setLastUpdateTimestamp(System.currentTimeMillis());
- }
-
- return locked;
- }
- }
-
- return false;
- }
-
- public Set<MessageQueue> tryLockBatch(final String group, final Set<MessageQueue> mqs,
- final String clientId) {
- Set<MessageQueue> lockedMqs = new HashSet<MessageQueue>(mqs.size());
- Set<MessageQueue> notLockedMqs = new HashSet<MessageQueue>(mqs.size());
-
-
- for (MessageQueue mq : mqs) {
- if (this.isLocked(group, mq, clientId)) {
- lockedMqs.add(mq);
- } else {
- notLockedMqs.add(mq);
- }
- }
-
- if (!notLockedMqs.isEmpty()) {
- try {
- this.lock.lockInterruptibly();
- try {
- ConcurrentHashMap<MessageQueue, LockEntry> groupValue = this.mqLockTable.get(group);
- if (null == groupValue) {
- groupValue = new ConcurrentHashMap<MessageQueue, LockEntry>(32);
- this.mqLockTable.put(group, groupValue);
- }
-
-
- for (MessageQueue mq : notLockedMqs) {
- LockEntry lockEntry = groupValue.get(mq);
- if (null == lockEntry) {
- lockEntry = new LockEntry();
- lockEntry.setClientId(clientId);
- groupValue.put(mq, lockEntry);
- log.info(
- "tryLockBatch, message queue not locked, I got it. Group: {} NewClientId: {} {}", //
- group, //
- clientId, //
- mq);
- }
-
-
- if (lockEntry.isLocked(clientId)) {
- lockEntry.setLastUpdateTimestamp(System.currentTimeMillis());
- lockedMqs.add(mq);
- continue;
- }
-
- String oldClientId = lockEntry.getClientId();
-
-
- if (lockEntry.isExpired()) {
- lockEntry.setClientId(clientId);
- lockEntry.setLastUpdateTimestamp(System.currentTimeMillis());
- log.warn(
- "tryLockBatch, message queue lock expired, I got it. Group: {} OldClientId: {} NewClientId: {} {}", //
- group, //
- oldClientId, //
- clientId, //
- mq);
- lockedMqs.add(mq);
- continue;
- }
-
-
- log.warn(
- "tryLockBatch, message queue locked by other client. Group: {} OtherClientId: {} NewClientId: {} {}", //
- group, //
- oldClientId, //
- clientId, //
- mq);
- }
- } finally {
- this.lock.unlock();
- }
- } catch (InterruptedException e) {
- log.error("putMessage exception", e);
- }
- }
-
- return lockedMqs;
- }
-
- public void unlockBatch(final String group, final Set<MessageQueue> mqs, final String clientId) {
- try {
- this.lock.lockInterruptibly();
- try {
- ConcurrentHashMap<MessageQueue, LockEntry> groupValue = this.mqLockTable.get(group);
- if (null != groupValue) {
- for (MessageQueue mq : mqs) {
- LockEntry lockEntry = groupValue.get(mq);
- if (null != lockEntry) {
- if (lockEntry.getClientId().equals(clientId)) {
- groupValue.remove(mq);
- log.info("unlockBatch, Group: {} {} {}",
- group,
- mq,
- clientId);
- } else {
- log.warn("unlockBatch, but mq locked by other client: {}, Group: {} {} {}",
- lockEntry.getClientId(),
- group,
- mq,
- clientId);
- }
- } else {
- log.warn("unlockBatch, but mq not locked, Group: {} {} {}",
- group,
- mq,
- clientId);
- }
- }
- } else {
- log.warn("unlockBatch, group not exist, Group: {} {}",
- group,
- clientId);
- }
- } finally {
- this.lock.unlock();
- }
- } catch (InterruptedException e) {
- log.error("putMessage exception", e);
- }
- }
-
- static class LockEntry {
- private String clientId;
- private volatile long lastUpdateTimestamp = System.currentTimeMillis();
-
-
- public String getClientId() {
- return clientId;
- }
-
-
- public void setClientId(String clientId) {
- this.clientId = clientId;
- }
-
-
- public long getLastUpdateTimestamp() {
- return lastUpdateTimestamp;
- }
-
-
- public void setLastUpdateTimestamp(long lastUpdateTimestamp) {
- this.lastUpdateTimestamp = lastUpdateTimestamp;
- }
-
- public boolean isLocked(final String clientId) {
- boolean eq = this.clientId.equals(clientId);
- return eq && !this.isExpired();
- }
-
- public boolean isExpired() {
- boolean expired =
- (System.currentTimeMillis() - this.lastUpdateTimestamp) > REBALANCE_LOCK_MAX_LIVE_TIME;
-
- return expired;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/filtersrv/FilterServerManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/filtersrv/FilterServerManager.java b/broker/src/main/java/com/alibaba/rocketmq/broker/filtersrv/FilterServerManager.java
deleted file mode 100644
index b2e7e82..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/filtersrv/FilterServerManager.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/**
- * 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.filtersrv;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import com.alibaba.rocketmq.broker.BrokerStartup;
-import com.alibaba.rocketmq.common.ThreadFactoryImpl;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.remoting.common.RemotingUtil;
-import io.netty.channel.Channel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-
-public class FilterServerManager {
-
- public static final long FILTER_SERVER_MAX_IDLE_TIME_MILLS = 30000;
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
- private final ConcurrentHashMap<Channel, FilterServerInfo> filterServerTable =
- new ConcurrentHashMap<Channel, FilterServerInfo>(16);
- private final BrokerController brokerController;
-
- private ScheduledExecutorService scheduledExecutorService = Executors
- .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("FilterServerManagerScheduledThread"));
-
- public FilterServerManager(final BrokerController brokerController) {
- this.brokerController = brokerController;
- }
-
- public void start() {
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- FilterServerManager.this.createFilterServer();
- } catch (Exception e) {
- log.error("", e);
- }
- }
- }, 1000 * 5, 1000 * 30, TimeUnit.MILLISECONDS);
- }
-
- public void createFilterServer() {
- int more =
- this.brokerController.getBrokerConfig().getFilterServerNums() - this.filterServerTable.size();
- String cmd = this.buildStartCommand();
- for (int i = 0; i < more; i++) {
- FilterServerUtil.callShell(cmd, log);
- }
- }
-
- private String buildStartCommand() {
- String config = "";
- if (BrokerStartup.configFile != null) {
- config = String.format("-c %s", BrokerStartup.configFile);
- }
-
- if (this.brokerController.getBrokerConfig().getNamesrvAddr() != null) {
- config += String.format(" -n %s", this.brokerController.getBrokerConfig().getNamesrvAddr());
- }
-
- if (RemotingUtil.isWindowsPlatform()) {
- return String.format("start /b %s\\bin\\mqfiltersrv.exe %s",
- this.brokerController.getBrokerConfig().getRocketmqHome(),
- config);
- } else {
- return String.format("sh %s/bin/startfsrv.sh %s",
- this.brokerController.getBrokerConfig().getRocketmqHome(),
- config);
- }
- }
-
- public void shutdown() {
- this.scheduledExecutorService.shutdown();
- }
-
- public void registerFilterServer(final Channel channel, final String filterServerAddr) {
- FilterServerInfo filterServerInfo = this.filterServerTable.get(channel);
- if (filterServerInfo != null) {
- filterServerInfo.setLastUpdateTimestamp(System.currentTimeMillis());
- } else {
- filterServerInfo = new FilterServerInfo();
- filterServerInfo.setFilterServerAddr(filterServerAddr);
- filterServerInfo.setLastUpdateTimestamp(System.currentTimeMillis());
- this.filterServerTable.put(channel, filterServerInfo);
- log.info("Receive a New Filter Server<{}>", filterServerAddr);
- }
- }
-
- /**
-
- */
- public void scanNotActiveChannel() {
-
- Iterator<Entry<Channel, FilterServerInfo>> it = this.filterServerTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<Channel, FilterServerInfo> next = it.next();
- long timestamp = next.getValue().getLastUpdateTimestamp();
- Channel channel = next.getKey();
- if ((System.currentTimeMillis() - timestamp) > FILTER_SERVER_MAX_IDLE_TIME_MILLS) {
- log.info("The Filter Server<{}> expired, remove it", next.getKey());
- it.remove();
- RemotingUtil.closeChannel(channel);
- }
- }
- }
-
- public void doChannelCloseEvent(final String remoteAddr, final Channel channel) {
- FilterServerInfo old = this.filterServerTable.remove(channel);
- if (old != null) {
- log.warn("The Filter Server<{}> connection<{}> closed, remove it", old.getFilterServerAddr(),
- remoteAddr);
- }
- }
-
- public List<String> buildNewFilterServerList() {
- List<String> addr = new ArrayList<String>();
- Iterator<Entry<Channel, FilterServerInfo>> it = this.filterServerTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<Channel, FilterServerInfo> next = it.next();
- addr.add(next.getValue().getFilterServerAddr());
- }
- return addr;
- }
-
- static class FilterServerInfo {
- private String filterServerAddr;
- private long lastUpdateTimestamp;
-
-
- public String getFilterServerAddr() {
- return filterServerAddr;
- }
-
-
- public void setFilterServerAddr(String filterServerAddr) {
- this.filterServerAddr = filterServerAddr;
- }
-
-
- public long getLastUpdateTimestamp() {
- return lastUpdateTimestamp;
- }
-
-
- public void setLastUpdateTimestamp(long lastUpdateTimestamp) {
- this.lastUpdateTimestamp = lastUpdateTimestamp;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/filtersrv/FilterServerUtil.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/filtersrv/FilterServerUtil.java b/broker/src/main/java/com/alibaba/rocketmq/broker/filtersrv/FilterServerUtil.java
deleted file mode 100644
index c5ace19..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/filtersrv/FilterServerUtil.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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.filtersrv;
-
-import org.slf4j.Logger;
-
-
-public class FilterServerUtil {
- public static void callShell(final String shellString, final Logger log) {
- Process process = null;
- try {
- String[] cmdArray = splitShellString(shellString);
- process = Runtime.getRuntime().exec(cmdArray);
- process.waitFor();
- log.info("callShell: <{}> OK", shellString);
- } catch (Throwable e) {
- log.error("callShell: readLine IOException, " + shellString, e);
- } finally {
- if (null != process)
- process.destroy();
- }
- }
-
- private static String[] splitShellString(final String shellString) {
- String[] split = shellString.split(" ");
- return split;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/latency/BrokerFastFailure.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/latency/BrokerFastFailure.java b/broker/src/main/java/com/alibaba/rocketmq/broker/latency/BrokerFastFailure.java
deleted file mode 100644
index 586bed0..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/latency/BrokerFastFailure.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * 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.latency;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import com.alibaba.rocketmq.common.ThreadFactoryImpl;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.remoting.netty.RequestTask;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSysResponseCode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-
-/**
- * @author shijia.wxr
- */
-public class BrokerFastFailure {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
- private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl(
- "BrokerFastFailureScheduledThread"));
- private final BrokerController brokerController;
-
- public BrokerFastFailure(final BrokerController brokerController) {
- this.brokerController = brokerController;
- }
-
- public void start() {
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- cleanExpiredRequest();
- }
- }, 1000, 10, TimeUnit.MILLISECONDS);
- }
-
- private void cleanExpiredRequest() {
- while (this.brokerController.getMessageStore().isOSPageCacheBusy()) {
- try {
- if (!this.brokerController.getSendThreadPoolQueue().isEmpty()) {
- final Runnable runnable = this.brokerController.getSendThreadPoolQueue().poll(0, TimeUnit.SECONDS);
- if (null == runnable) {
- break;
- }
-
- final RequestTask rt = castRunnable(runnable);
- rt.returnResponse(RemotingSysResponseCode.SYSTEM_BUSY, String.format("[PCBUSY_CLEAN_QUEUE]broker busy, start flow control for a while, period in queue: %sms, size of queue: %d", System.currentTimeMillis() - rt.getCreateTimestamp(), this.brokerController.getSendThreadPoolQueue().size()));
- } else {
- break;
- }
- } catch (Throwable e) {
- }
- }
-
- while (true) {
- try {
- if (!this.brokerController.getSendThreadPoolQueue().isEmpty()) {
- final Runnable runnable = this.brokerController.getSendThreadPoolQueue().peek();
- if (null == runnable) {
- break;
- }
- final RequestTask rt = castRunnable(runnable);
- if (rt.isStopRun()) {
- break;
- }
-
- final long behind = System.currentTimeMillis() - rt.getCreateTimestamp();
- if (behind >= this.brokerController.getBrokerConfig().getWaitTimeMillsInSendQueue()) {
- if (this.brokerController.getSendThreadPoolQueue().remove(runnable)) {
- rt.setStopRun(true);
- rt.returnResponse(RemotingSysResponseCode.SYSTEM_BUSY, String.format("[TIMEOUT_CLEAN_QUEUE]broker busy, start flow control for a while, period in queue: %sms, size of queue: %d", behind, this.brokerController.getSendThreadPoolQueue().size()));
- }
- } else {
- break;
- }
- } else {
- break;
- }
- } catch (Throwable e) {
- }
- }
- }
-
- public static RequestTask castRunnable(final Runnable runnable) {
- try {
- FutureTaskExt object = (FutureTaskExt) runnable;
- return (RequestTask) object.getRunnable();
- } catch (Throwable e) {
- log.error(String.format("castRunnable exception, %s", runnable.getClass().getName()), e);
- }
-
- return null;
- }
-
- public void shutdown() {
- this.scheduledExecutorService.shutdown();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java b/broker/src/main/java/com/alibaba/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java
deleted file mode 100644
index f81d48a..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * 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.latency;
-
-import java.util.concurrent.*;
-
-/**
- * @author shijia.wxr
- */
-public class BrokerFixedThreadPoolExecutor extends ThreadPoolExecutor {
- public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit, final BlockingQueue<Runnable> workQueue) {
- super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
- }
-
- public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit, final BlockingQueue<Runnable> workQueue, final ThreadFactory threadFactory) {
- super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory);
- }
-
- public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit, final BlockingQueue<Runnable> workQueue, final RejectedExecutionHandler handler) {
- super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, handler);
- }
-
- public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit, final BlockingQueue<Runnable> workQueue, final ThreadFactory threadFactory, final RejectedExecutionHandler handler) {
- super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler);
- }
-
- @Override
- protected <T> RunnableFuture<T> newTaskFor(final Runnable runnable, final T value) {
- return new FutureTaskExt<T>(runnable, value);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/latency/FutureTaskExt.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/latency/FutureTaskExt.java b/broker/src/main/java/com/alibaba/rocketmq/broker/latency/FutureTaskExt.java
deleted file mode 100644
index 6ec7bb5..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/latency/FutureTaskExt.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * 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.latency;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.FutureTask;
-
-/**
- * @author shijia.wxr
- */
-public class FutureTaskExt<V> extends FutureTask<V> {
- private final Runnable runnable;
-
- public FutureTaskExt(final Callable<V> callable) {
- super(callable);
- this.runnable = null;
- }
-
- public FutureTaskExt(final Runnable runnable, final V result) {
- super(runnable, result);
- this.runnable = runnable;
- }
-
- public Runnable getRunnable() {
- return runnable;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/longpolling/ManyPullRequest.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/longpolling/ManyPullRequest.java b/broker/src/main/java/com/alibaba/rocketmq/broker/longpolling/ManyPullRequest.java
deleted file mode 100644
index bc9c58d..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/longpolling/ManyPullRequest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.longpolling;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public class ManyPullRequest {
- private final ArrayList<PullRequest> pullRequestList = new ArrayList<PullRequest>();
-
-
- public synchronized void addPullRequest(final PullRequest pullRequest) {
- this.pullRequestList.add(pullRequest);
- }
-
-
- public synchronized void addPullRequest(final List<PullRequest> many) {
- this.pullRequestList.addAll(many);
- }
-
-
- public synchronized List<PullRequest> cloneListAndClear() {
- if (!this.pullRequestList.isEmpty()) {
- List<PullRequest> result = (ArrayList<PullRequest>) this.pullRequestList.clone();
- this.pullRequestList.clear();
- return result;
- }
-
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/longpolling/NotifyMessageArrivingListener.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/longpolling/NotifyMessageArrivingListener.java b/broker/src/main/java/com/alibaba/rocketmq/broker/longpolling/NotifyMessageArrivingListener.java
deleted file mode 100644
index 15ee050..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/longpolling/NotifyMessageArrivingListener.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * 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.longpolling;
-
-import com.alibaba.rocketmq.store.MessageArrivingListener;
-
-
-public class NotifyMessageArrivingListener implements MessageArrivingListener {
- private final PullRequestHoldService pullRequestHoldService;
-
-
- public NotifyMessageArrivingListener(final PullRequestHoldService pullRequestHoldService) {
- this.pullRequestHoldService = pullRequestHoldService;
- }
-
-
- @Override
- public void arriving(String topic, int queueId, long logicOffset, long tagsCode) {
- this.pullRequestHoldService.notifyMessageArriving(topic, queueId, logicOffset, tagsCode);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/longpolling/PullRequest.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/longpolling/PullRequest.java b/broker/src/main/java/com/alibaba/rocketmq/broker/longpolling/PullRequest.java
deleted file mode 100644
index b4f1e11..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/longpolling/PullRequest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * 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.longpolling;
-
-import com.alibaba.rocketmq.common.protocol.heartbeat.SubscriptionData;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import io.netty.channel.Channel;
-
-
-/**
- * @author shijia.wxr
- */
-public class PullRequest {
- private final RemotingCommand requestCommand;
- private final Channel clientChannel;
- private final long timeoutMillis;
- private final long suspendTimestamp;
- private final long pullFromThisOffset;
- private final SubscriptionData subscriptionData;
-
-
- public PullRequest(RemotingCommand requestCommand, Channel clientChannel, long timeoutMillis, long suspendTimestamp,
- long pullFromThisOffset, SubscriptionData subscriptionData) {
- this.requestCommand = requestCommand;
- this.clientChannel = clientChannel;
- this.timeoutMillis = timeoutMillis;
- this.suspendTimestamp = suspendTimestamp;
- this.pullFromThisOffset = pullFromThisOffset;
- this.subscriptionData = subscriptionData;
- }
-
-
- public RemotingCommand getRequestCommand() {
- return requestCommand;
- }
-
-
- public Channel getClientChannel() {
- return clientChannel;
- }
-
-
- public long getTimeoutMillis() {
- return timeoutMillis;
- }
-
-
- public long getSuspendTimestamp() {
- return suspendTimestamp;
- }
-
-
- public long getPullFromThisOffset() {
- return pullFromThisOffset;
- }
-
- public SubscriptionData getSubscriptionData() {
- return subscriptionData;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/longpolling/PullRequestHoldService.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/longpolling/PullRequestHoldService.java b/broker/src/main/java/com/alibaba/rocketmq/broker/longpolling/PullRequestHoldService.java
deleted file mode 100644
index 888c5f2..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/longpolling/PullRequestHoldService.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/**
- * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.longpolling;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import com.alibaba.rocketmq.common.ServiceThread;
-import com.alibaba.rocketmq.common.SystemClock;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.store.DefaultMessageFilter;
-import com.alibaba.rocketmq.store.MessageFilter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-
-
-/**
- * @author shijia.wxr
- */
-public class PullRequestHoldService extends ServiceThread {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
- private static final String TOPIC_QUEUEID_SEPARATOR = "@";
- private final BrokerController brokerController;
- private final SystemClock systemClock = new SystemClock();
- private final MessageFilter messageFilter = new DefaultMessageFilter();
- private ConcurrentHashMap<String/* topic@queueId */, ManyPullRequest> pullRequestTable =
- new ConcurrentHashMap<String, ManyPullRequest>(1024);
-
-
- public PullRequestHoldService(final BrokerController brokerController) {
- this.brokerController = brokerController;
- }
-
- public void suspendPullRequest(final String topic, final int queueId, final PullRequest pullRequest) {
- String key = this.buildKey(topic, queueId);
- ManyPullRequest mpr = this.pullRequestTable.get(key);
- if (null == mpr) {
- mpr = new ManyPullRequest();
- ManyPullRequest prev = this.pullRequestTable.putIfAbsent(key, mpr);
- if (prev != null) {
- mpr = prev;
- }
- }
-
- mpr.addPullRequest(pullRequest);
- }
-
- private String buildKey(final String topic, final int queueId) {
- StringBuilder sb = new StringBuilder();
- sb.append(topic);
- sb.append(TOPIC_QUEUEID_SEPARATOR);
- sb.append(queueId);
- return sb.toString();
- }
-
- @Override
- public void run() {
- log.info(this.getServiceName() + " service started");
- while (!this.isStopped()) {
- try {
- if (this.brokerController.getBrokerConfig().isLongPollingEnable()) {
- this.waitForRunning(5 * 1000);
- } else {
- this.waitForRunning(this.brokerController.getBrokerConfig().getShortPollingTimeMills());
- }
-
- long beginLockTimestamp = this.systemClock.now();
- this.checkHoldRequest();
- long costTime = this.systemClock.now() - beginLockTimestamp;
- if (costTime > 5 * 1000) {
- log.info("[NOTIFYME] check hold request cost {} ms.", costTime);
- }
- } catch (Throwable e) {
- log.warn(this.getServiceName() + " service has exception. ", e);
- }
- }
-
- log.info(this.getServiceName() + " service end");
- }
-
- @Override
- public String getServiceName() {
- return PullRequestHoldService.class.getSimpleName();
- }
-
- private void checkHoldRequest() {
- for (String key : this.pullRequestTable.keySet()) {
- String[] kArray = key.split(TOPIC_QUEUEID_SEPARATOR);
- if (kArray != null && 2 == kArray.length) {
- String topic = kArray[0];
- int queueId = Integer.parseInt(kArray[1]);
- final long offset = this.brokerController.getMessageStore().getMaxOffsetInQuque(topic, queueId);
- try {
- this.notifyMessageArriving(topic, queueId, offset);
- } catch (Throwable e) {
- log.error("check hold request failed. topic={}, queueId={}", topic, queueId, e);
- }
- }
- }
- }
-
- public void notifyMessageArriving(final String topic, final int queueId, final long maxOffset) {
- notifyMessageArriving(topic, queueId, maxOffset, null);
- }
-
- public void notifyMessageArriving(final String topic, final int queueId, final long maxOffset, final Long tagsCode) {
- String key = this.buildKey(topic, queueId);
- ManyPullRequest mpr = this.pullRequestTable.get(key);
- if (mpr != null) {
- List<PullRequest> requestList = mpr.cloneListAndClear();
- if (requestList != null) {
- List<PullRequest> replayList = new ArrayList<PullRequest>();
-
- for (PullRequest request : requestList) {
- long newestOffset = maxOffset;
- if (newestOffset <= request.getPullFromThisOffset()) {
- newestOffset = this.brokerController.getMessageStore().getMaxOffsetInQuque(topic, queueId);
- }
-
- Long tmp = tagsCode;
- if (newestOffset > request.getPullFromThisOffset()) {
- if (this.messageFilter.isMessageMatched(request.getSubscriptionData(), tmp)) {
- try {
- this.brokerController.getPullMessageProcessor().excuteRequestWhenWakeup(request.getClientChannel(),
- request.getRequestCommand());
- } catch (Throwable e) {
- log.error("execute request when wakeup failed.", e);
- }
- continue;
- }
- }
-
- if (System.currentTimeMillis() >= (request.getSuspendTimestamp() + request.getTimeoutMillis())) {
- try {
- this.brokerController.getPullMessageProcessor().excuteRequestWhenWakeup(request.getClientChannel(),
- request.getRequestCommand());
- } catch (Throwable e) {
- log.error("execute request when wakeup failed.", e);
- }
- continue;
- }
-
-
- replayList.add(request);
- }
-
- if (!replayList.isEmpty()) {
- mpr.addPullRequest(replayList);
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/mqtrace/ConsumeMessageContext.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/mqtrace/ConsumeMessageContext.java b/broker/src/main/java/com/alibaba/rocketmq/broker/mqtrace/ConsumeMessageContext.java
deleted file mode 100644
index b7f9c6e..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/mqtrace/ConsumeMessageContext.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- * 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.mqtrace;
-
-import com.alibaba.rocketmq.store.stats.BrokerStatsManager;
-
-import java.util.Map;
-
-
-public class ConsumeMessageContext {
- private String consumerGroup;
- private String topic;
- private Integer queueId;
- private String clientHost;
- private String storeHost;
- private Map<String, Long> messageIds;
- private int bodyLength;
- private boolean success;
- private String status;
- private Object mqTraceContext;
-
- private String commercialOwner;
- private BrokerStatsManager.StatsType commercialRcvStats;
- private int commercialRcvTimes;
- private int commercialRcvSize;
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public Integer getQueueId() {
- return queueId;
- }
-
-
- public void setQueueId(Integer queueId) {
- this.queueId = queueId;
- }
-
-
- public String getClientHost() {
- return clientHost;
- }
-
-
- public void setClientHost(String clientHost) {
- this.clientHost = clientHost;
- }
-
-
- public String getStoreHost() {
- return storeHost;
- }
-
-
- public void setStoreHost(String storeHost) {
- this.storeHost = storeHost;
- }
-
-
- public Map<String, Long> getMessageIds() {
- return messageIds;
- }
-
-
- public void setMessageIds(Map<String, Long> messageIds) {
- this.messageIds = messageIds;
- }
-
-
- public boolean isSuccess() {
- return success;
- }
-
-
- public void setSuccess(boolean success) {
- this.success = success;
- }
-
-
- public String getStatus() {
- return status;
- }
-
-
- public void setStatus(String status) {
- this.status = status;
- }
-
-
- public Object getMqTraceContext() {
- return mqTraceContext;
- }
-
-
- public void setMqTraceContext(Object mqTraceContext) {
- this.mqTraceContext = mqTraceContext;
- }
-
-
- public int getBodyLength() {
- return bodyLength;
- }
-
-
- public void setBodyLength(int bodyLength) {
- this.bodyLength = bodyLength;
- }
-
- public String getCommercialOwner() {
- return commercialOwner;
- }
-
- public void setCommercialOwner(final String commercialOwner) {
- this.commercialOwner = commercialOwner;
- }
-
- public BrokerStatsManager.StatsType getCommercialRcvStats() {
- return commercialRcvStats;
- }
-
- public void setCommercialRcvStats(final BrokerStatsManager.StatsType commercialRcvStats) {
- this.commercialRcvStats = commercialRcvStats;
- }
-
- public int getCommercialRcvTimes() {
- return commercialRcvTimes;
- }
-
- public void setCommercialRcvTimes(final int commercialRcvTimes) {
- this.commercialRcvTimes = commercialRcvTimes;
- }
-
- public int getCommercialRcvSize() {
- return commercialRcvSize;
- }
-
- public void setCommercialRcvSize(final int commercialRcvSize) {
- this.commercialRcvSize = commercialRcvSize;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/mqtrace/ConsumeMessageHook.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/mqtrace/ConsumeMessageHook.java b/broker/src/main/java/com/alibaba/rocketmq/broker/mqtrace/ConsumeMessageHook.java
deleted file mode 100644
index 4a74db3..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/mqtrace/ConsumeMessageHook.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * 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.mqtrace;
-
-public interface ConsumeMessageHook {
- String hookName();
-
-
- void consumeMessageBefore(final ConsumeMessageContext context);
-
-
- void consumeMessageAfter(final ConsumeMessageContext context);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/mqtrace/SendMessageContext.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/mqtrace/SendMessageContext.java b/broker/src/main/java/com/alibaba/rocketmq/broker/mqtrace/SendMessageContext.java
deleted file mode 100644
index 5bd29cf..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/mqtrace/SendMessageContext.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/**
- * 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.mqtrace;
-
-import com.alibaba.rocketmq.common.message.MessageType;
-import com.alibaba.rocketmq.store.stats.BrokerStatsManager;
-
-import java.util.Properties;
-
-
-public class SendMessageContext {
- private String producerGroup;
- private String topic;
- private String msgId;
- private String originMsgId;
- private Integer queueId;
- private Long queueOffset;
- private String brokerAddr;
- private String bornHost;
- private int bodyLength;
- private int code;
- private String errorMsg;
- private String msgProps;
- private Object mqTraceContext;
- private Properties extProps;
- private String brokerRegionId;
- private String msgUniqueKey;
- private long bornTimeStamp;
- private MessageType msgType = MessageType.Trans_msg_Commit;
- private boolean isSuccess = false;
- //For Commercial
- private String commercialOwner;
- private BrokerStatsManager.StatsType commercialSendStats;
- private int commercialSendSize;
- private int commercialSendTimes;
-
- public boolean isSuccess() {
- return isSuccess;
- }
-
- public void setSuccess(final boolean success) {
- isSuccess = success;
- }
-
- public MessageType getMsgType() {
- return msgType;
- }
-
- public void setMsgType(final MessageType msgType) {
- this.msgType = msgType;
- }
-
- public String getMsgUniqueKey() {
- return msgUniqueKey;
- }
-
- public void setMsgUniqueKey(final String msgUniqueKey) {
- this.msgUniqueKey = msgUniqueKey;
- }
-
- public long getBornTimeStamp() {
- return bornTimeStamp;
- }
-
- public void setBornTimeStamp(final long bornTimeStamp) {
- this.bornTimeStamp = bornTimeStamp;
- }
-
- public String getBrokerRegionId() {
- return brokerRegionId;
- }
-
- public void setBrokerRegionId(final String brokerRegionId) {
- this.brokerRegionId = brokerRegionId;
- }
-
- public String getProducerGroup() {
- return producerGroup;
- }
-
-
- public void setProducerGroup(String producerGroup) {
- this.producerGroup = producerGroup;
- }
-
-
- public String getTopic() {
- return topic;
- }
-
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
-
- public String getMsgId() {
- return msgId;
- }
-
-
- public void setMsgId(String msgId) {
- this.msgId = msgId;
- }
-
-
- public String getOriginMsgId() {
- return originMsgId;
- }
-
-
- public void setOriginMsgId(String originMsgId) {
- this.originMsgId = originMsgId;
- }
-
-
- public Integer getQueueId() {
- return queueId;
- }
-
-
- public void setQueueId(Integer queueId) {
- this.queueId = queueId;
- }
-
-
- public Long getQueueOffset() {
- return queueOffset;
- }
-
-
- public void setQueueOffset(Long queueOffset) {
- this.queueOffset = queueOffset;
- }
-
-
- public String getBrokerAddr() {
- return brokerAddr;
- }
-
-
- public void setBrokerAddr(String brokerAddr) {
- this.brokerAddr = brokerAddr;
- }
-
-
- public String getBornHost() {
- return bornHost;
- }
-
-
- public void setBornHost(String bornHost) {
- this.bornHost = bornHost;
- }
-
-
- public int getBodyLength() {
- return bodyLength;
- }
-
-
- public void setBodyLength(int bodyLength) {
- this.bodyLength = bodyLength;
- }
-
-
- public int getCode() {
- return code;
- }
-
-
- public void setCode(int code) {
- this.code = code;
- }
-
-
- public String getErrorMsg() {
- return errorMsg;
- }
-
-
- public void setErrorMsg(String errorMsg) {
- this.errorMsg = errorMsg;
- }
-
-
- public String getMsgProps() {
- return msgProps;
- }
-
-
- public void setMsgProps(String msgProps) {
- this.msgProps = msgProps;
- }
-
-
- public Object getMqTraceContext() {
- return mqTraceContext;
- }
-
-
- public void setMqTraceContext(Object mqTraceContext) {
- this.mqTraceContext = mqTraceContext;
- }
-
-
- public Properties getExtProps() {
- return extProps;
- }
-
-
- public void setExtProps(Properties extProps) {
- this.extProps = extProps;
- }
-
- public String getCommercialOwner() {
- return commercialOwner;
- }
-
- public void setCommercialOwner(final String commercialOwner) {
- this.commercialOwner = commercialOwner;
- }
-
- public BrokerStatsManager.StatsType getCommercialSendStats() {
- return commercialSendStats;
- }
-
- public void setCommercialSendStats(final BrokerStatsManager.StatsType commercialSendStats) {
- this.commercialSendStats = commercialSendStats;
- }
-
- public int getCommercialSendSize() {
- return commercialSendSize;
- }
-
- public void setCommercialSendSize(final int commercialSendSize) {
- this.commercialSendSize = commercialSendSize;
- }
-
- public int getCommercialSendTimes() {
- return commercialSendTimes;
- }
-
- public void setCommercialSendTimes(final int commercialSendTimes) {
- this.commercialSendTimes = commercialSendTimes;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/mqtrace/SendMessageHook.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/mqtrace/SendMessageHook.java b/broker/src/main/java/com/alibaba/rocketmq/broker/mqtrace/SendMessageHook.java
deleted file mode 100644
index e079b9f..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/mqtrace/SendMessageHook.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * 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.mqtrace;
-
-public interface SendMessageHook {
- public String hookName();
-
-
- public void sendMessageBefore(final SendMessageContext context);
-
-
- public void sendMessageAfter(final SendMessageContext context);
-}
[02/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/stats/FilterServerStatsManager.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/stats/FilterServerStatsManager.java b/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/stats/FilterServerStatsManager.java
deleted file mode 100644
index 3921c92..0000000
--- a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/stats/FilterServerStatsManager.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * 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.filtersrv.stats;
-
-import com.alibaba.rocketmq.common.ThreadFactoryImpl;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.stats.StatsItemSet;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-
-
-public class FilterServerStatsManager {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
- private final ScheduledExecutorService scheduledExecutorService = Executors
- .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("FSStatsThread"));
-
- // ConsumerGroup Get Nums
- private final StatsItemSet groupGetNums = new StatsItemSet("GROUP_GET_NUMS",
- this.scheduledExecutorService, log);
-
- // ConsumerGroup Get Size
- private final StatsItemSet groupGetSize = new StatsItemSet("GROUP_GET_SIZE",
- this.scheduledExecutorService, log);
-
-
- public FilterServerStatsManager() {
- }
-
-
- public void start() {
- }
-
-
- public void shutdown() {
- this.scheduledExecutorService.shutdown();
- }
-
-
- public void incGroupGetNums(final String group, final String topic, final int incValue) {
- this.groupGetNums.addValue(topic + "@" + group, incValue, 1);
- }
-
-
- public void incGroupGetSize(final String group, final String topic, final int incValue) {
- this.groupGetSize.addValue(topic + "@" + group, incValue, 1);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
new file mode 100644
index 0000000..1663dfc
--- /dev/null
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
@@ -0,0 +1,82 @@
+/**
+ * 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.filtersrv;
+
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.common.protocol.RequestCode;
+import org.apache.rocketmq.common.protocol.ResponseCode;
+import org.apache.rocketmq.common.protocol.header.filtersrv.RegisterFilterServerRequestHeader;
+import org.apache.rocketmq.common.protocol.header.filtersrv.RegisterFilterServerResponseHeader;
+import org.apache.rocketmq.remoting.RemotingClient;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.exception.RemotingConnectException;
+import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
+import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
+import org.apache.rocketmq.remoting.netty.NettyClientConfig;
+import org.apache.rocketmq.remoting.netty.NettyRemotingClient;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class FilterServerOuterAPI {
+ private final RemotingClient remotingClient;
+
+
+ public FilterServerOuterAPI() {
+ this.remotingClient = new NettyRemotingClient(new NettyClientConfig());
+ }
+
+
+ public void start() {
+ this.remotingClient.start();
+ }
+
+
+ public void shutdown() {
+ this.remotingClient.shutdown();
+ }
+
+
+ public RegisterFilterServerResponseHeader registerFilterServerToBroker(
+ final String brokerAddr,
+ final String filterServerAddr
+ ) throws RemotingCommandException, RemotingConnectException, RemotingSendRequestException,
+ RemotingTimeoutException, InterruptedException, MQBrokerException {
+ RegisterFilterServerRequestHeader requestHeader = new RegisterFilterServerRequestHeader();
+ requestHeader.setFilterServerAddr(filterServerAddr);
+ RemotingCommand request =
+ RemotingCommand.createRequestCommand(RequestCode.REGISTER_FILTER_SERVER, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(brokerAddr, request, 3000);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ RegisterFilterServerResponseHeader responseHeader =
+ (RegisterFilterServerResponseHeader) response
+ .decodeCommandCustomHeader(RegisterFilterServerResponseHeader.class);
+
+ return responseHeader;
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvConfig.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvConfig.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvConfig.java
new file mode 100644
index 0000000..ec0381d
--- /dev/null
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvConfig.java
@@ -0,0 +1,158 @@
+/**
+ * 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.filtersrv;
+
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.annotation.ImportantField;
+import org.apache.rocketmq.remoting.common.RemotingUtil;
+
+
+public class FiltersrvConfig {
+ private String rocketmqHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY,
+ System.getenv(MixAll.ROCKETMQ_HOME_ENV));
+
+ @ImportantField
+ private String namesrvAddr = System.getProperty(MixAll.NAMESRV_ADDR_PROPERTY,
+ System.getenv(MixAll.NAMESRV_ADDR_ENV));
+
+ private String connectWhichBroker = "127.0.0.1:10911";
+ private String filterServerIP = RemotingUtil.getLocalAddress();
+
+ private int compressMsgBodyOverHowmuch = 1024 * 8;
+ private int zipCompressLevel = 5;
+
+
+ private boolean clientUploadFilterClassEnable = true;
+
+
+ private String filterClassRepertoryUrl = "http://fsrep.tbsite.net/filterclass";
+
+ private int fsServerAsyncSemaphoreValue = 2048;
+ private int fsServerCallbackExecutorThreads = 64;
+ private int fsServerWorkerThreads = 64;
+
+
+ public String getRocketmqHome() {
+ return rocketmqHome;
+ }
+
+
+ public void setRocketmqHome(String rocketmqHome) {
+ this.rocketmqHome = rocketmqHome;
+ }
+
+
+ public String getNamesrvAddr() {
+ return namesrvAddr;
+ }
+
+
+ public void setNamesrvAddr(String namesrvAddr) {
+ this.namesrvAddr = namesrvAddr;
+ }
+
+
+ public String getConnectWhichBroker() {
+ return connectWhichBroker;
+ }
+
+
+ public void setConnectWhichBroker(String connectWhichBroker) {
+ this.connectWhichBroker = connectWhichBroker;
+ }
+
+
+ public String getFilterServerIP() {
+ return filterServerIP;
+ }
+
+
+ public void setFilterServerIP(String filterServerIP) {
+ this.filterServerIP = filterServerIP;
+ }
+
+
+ public int getCompressMsgBodyOverHowmuch() {
+ return compressMsgBodyOverHowmuch;
+ }
+
+
+ public void setCompressMsgBodyOverHowmuch(int compressMsgBodyOverHowmuch) {
+ this.compressMsgBodyOverHowmuch = compressMsgBodyOverHowmuch;
+ }
+
+
+ public int getZipCompressLevel() {
+ return zipCompressLevel;
+ }
+
+
+ public void setZipCompressLevel(int zipCompressLevel) {
+ this.zipCompressLevel = zipCompressLevel;
+ }
+
+
+ public boolean isClientUploadFilterClassEnable() {
+ return clientUploadFilterClassEnable;
+ }
+
+
+ public void setClientUploadFilterClassEnable(boolean clientUploadFilterClassEnable) {
+ this.clientUploadFilterClassEnable = clientUploadFilterClassEnable;
+ }
+
+
+ public String getFilterClassRepertoryUrl() {
+ return filterClassRepertoryUrl;
+ }
+
+
+ public void setFilterClassRepertoryUrl(String filterClassRepertoryUrl) {
+ this.filterClassRepertoryUrl = filterClassRepertoryUrl;
+ }
+
+
+ public int getFsServerAsyncSemaphoreValue() {
+ return fsServerAsyncSemaphoreValue;
+ }
+
+
+ public void setFsServerAsyncSemaphoreValue(int fsServerAsyncSemaphoreValue) {
+ this.fsServerAsyncSemaphoreValue = fsServerAsyncSemaphoreValue;
+ }
+
+
+ public int getFsServerCallbackExecutorThreads() {
+ return fsServerCallbackExecutorThreads;
+ }
+
+
+ public void setFsServerCallbackExecutorThreads(int fsServerCallbackExecutorThreads) {
+ this.fsServerCallbackExecutorThreads = fsServerCallbackExecutorThreads;
+ }
+
+
+ public int getFsServerWorkerThreads() {
+ return fsServerWorkerThreads;
+ }
+
+
+ public void setFsServerWorkerThreads(int fsServerWorkerThreads) {
+ this.fsServerWorkerThreads = fsServerWorkerThreads;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java
new file mode 100644
index 0000000..cb862a6
--- /dev/null
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java
@@ -0,0 +1,226 @@
+/**
+ * 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.filtersrv;
+
+import org.apache.rocketmq.client.consumer.DefaultMQPullConsumer;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.ThreadFactoryImpl;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.protocol.header.filtersrv.RegisterFilterServerResponseHeader;
+import org.apache.rocketmq.filtersrv.filter.FilterClassManager;
+import org.apache.rocketmq.filtersrv.processor.DefaultRequestProcessor;
+import org.apache.rocketmq.filtersrv.stats.FilterServerStatsManager;
+import org.apache.rocketmq.remoting.RemotingServer;
+import org.apache.rocketmq.remoting.netty.NettyRemotingServer;
+import org.apache.rocketmq.remoting.netty.NettyServerConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class FiltersrvController {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
+
+ private final FiltersrvConfig filtersrvConfig;
+
+ private final NettyServerConfig nettyServerConfig;
+ private final FilterClassManager filterClassManager;
+
+ private final FilterServerOuterAPI filterServerOuterAPI = new FilterServerOuterAPI();
+ private final DefaultMQPullConsumer defaultMQPullConsumer = new DefaultMQPullConsumer(
+ MixAll.FILTERSRV_CONSUMER_GROUP);
+
+ private final ScheduledExecutorService scheduledExecutorService = Executors
+ .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("FSScheduledThread"));
+ private final FilterServerStatsManager filterServerStatsManager = new FilterServerStatsManager();
+
+ private RemotingServer remotingServer;
+
+ private ExecutorService remotingExecutor;
+ private volatile String brokerName = null;
+
+
+ public FiltersrvController(FiltersrvConfig filtersrvConfig, NettyServerConfig nettyServerConfig) {
+ this.filtersrvConfig = filtersrvConfig;
+ this.nettyServerConfig = nettyServerConfig;
+ this.filterClassManager = new FilterClassManager(this);
+ }
+
+
+ public boolean initialize() {
+
+ MixAll.printObjectProperties(log, this.filtersrvConfig);
+
+
+ this.remotingServer = new NettyRemotingServer(this.nettyServerConfig);
+
+
+ this.remotingExecutor =
+ Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(),
+ new ThreadFactoryImpl("RemotingExecutorThread_"));
+
+ this.registerProcessor();
+
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+
+ @Override
+ public void run() {
+ FiltersrvController.this.registerFilterServerToBroker();
+ }
+ }, 3, 10, TimeUnit.SECONDS);
+
+ this.defaultMQPullConsumer.setBrokerSuspendMaxTimeMillis(this.defaultMQPullConsumer
+ .getBrokerSuspendMaxTimeMillis() - 1000);
+ this.defaultMQPullConsumer.setConsumerTimeoutMillisWhenSuspend(this.defaultMQPullConsumer
+ .getConsumerTimeoutMillisWhenSuspend() - 1000);
+
+ this.defaultMQPullConsumer.setNamesrvAddr(this.filtersrvConfig.getNamesrvAddr());
+ this.defaultMQPullConsumer.setInstanceName(String.valueOf(UtilAll.getPid()));
+
+ return true;
+ }
+
+ private void registerProcessor() {
+ this.remotingServer
+ .registerDefaultProcessor(new DefaultRequestProcessor(this), this.remotingExecutor);
+ }
+
+ public void registerFilterServerToBroker() {
+ try {
+ RegisterFilterServerResponseHeader responseHeader =
+ this.filterServerOuterAPI.registerFilterServerToBroker(
+ this.filtersrvConfig.getConnectWhichBroker(), this.localAddr());
+ this.defaultMQPullConsumer.getDefaultMQPullConsumerImpl().getPullAPIWrapper()
+ .setDefaultBrokerId(responseHeader.getBrokerId());
+
+ if (null == this.brokerName) {
+ this.brokerName = responseHeader.getBrokerName();
+ }
+
+ log.info("register filter server<{}> to broker<{}> OK, Return: {} {}",
+ this.localAddr(),
+ this.filtersrvConfig.getConnectWhichBroker(),
+ responseHeader.getBrokerName(),
+ responseHeader.getBrokerId());
+ } catch (Exception e) {
+ log.warn("register filter server Exception", e);
+
+ log.warn("access broker failed, kill oneself");
+ System.exit(-1);
+ }
+ }
+
+ public String localAddr() {
+ return String.format("%s:%d", this.filtersrvConfig.getFilterServerIP(),
+ this.remotingServer.localListenPort());
+ }
+
+ public void start() throws Exception {
+ this.defaultMQPullConsumer.start();
+ this.remotingServer.start();
+ this.filterServerOuterAPI.start();
+ this.defaultMQPullConsumer.getDefaultMQPullConsumerImpl().getPullAPIWrapper()
+ .setConnectBrokerByUser(true);
+ this.filterClassManager.start();
+ this.filterServerStatsManager.start();
+ }
+
+
+ public void shutdown() {
+ this.remotingServer.shutdown();
+ this.remotingExecutor.shutdown();
+ this.scheduledExecutorService.shutdown();
+ this.defaultMQPullConsumer.shutdown();
+ this.filterServerOuterAPI.shutdown();
+ this.filterClassManager.shutdown();
+ this.filterServerStatsManager.shutdown();
+ }
+
+
+ public RemotingServer getRemotingServer() {
+ return remotingServer;
+ }
+
+
+ public void setRemotingServer(RemotingServer remotingServer) {
+ this.remotingServer = remotingServer;
+ }
+
+
+ public ExecutorService getRemotingExecutor() {
+ return remotingExecutor;
+ }
+
+
+ public void setRemotingExecutor(ExecutorService remotingExecutor) {
+ this.remotingExecutor = remotingExecutor;
+ }
+
+
+ public FiltersrvConfig getFiltersrvConfig() {
+ return filtersrvConfig;
+ }
+
+
+ public NettyServerConfig getNettyServerConfig() {
+ return nettyServerConfig;
+ }
+
+
+ public ScheduledExecutorService getScheduledExecutorService() {
+ return scheduledExecutorService;
+ }
+
+
+ public FilterServerOuterAPI getFilterServerOuterAPI() {
+ return filterServerOuterAPI;
+ }
+
+
+ public FilterClassManager getFilterClassManager() {
+ return filterClassManager;
+ }
+
+
+ public DefaultMQPullConsumer getDefaultMQPullConsumer() {
+ return defaultMQPullConsumer;
+ }
+
+
+ public String getBrokerName() {
+ return brokerName;
+ }
+
+
+ public void setBrokerName(String brokerName) {
+ this.brokerName = brokerName;
+ }
+
+
+ public FilterServerStatsManager getFilterServerStatsManager() {
+ return filterServerStatsManager;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
new file mode 100644
index 0000000..4e1fbc4
--- /dev/null
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
@@ -0,0 +1,183 @@
+/**
+ * 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.filtersrv;
+
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.joran.JoranConfigurator;
+import org.apache.rocketmq.common.MQVersion;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.remoting.netty.NettyServerConfig;
+import org.apache.rocketmq.remoting.netty.NettySystemConfig;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.apache.rocketmq.srvutil.ServerUtil;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.PosixParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class FiltersrvStartup {
+ public static Logger log;
+
+ public static void main(String[] args) {
+ start(createController(args));
+ }
+
+ public static FiltersrvController start(FiltersrvController controller) {
+
+ try {
+ controller.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(-1);
+ }
+
+ String tip = "The Filter Server boot success, " + controller.localAddr();
+ log.info(tip);
+ System.out.printf("%s%n", tip);
+
+ return controller;
+ }
+
+ public static FiltersrvController createController(String[] args) {
+ System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));
+
+
+ if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE)) {
+ NettySystemConfig.socketSndbufSize = 65535;
+ }
+
+
+ if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE)) {
+ NettySystemConfig.socketRcvbufSize = 1024;
+ }
+
+ try {
+ Options options = ServerUtil.buildCommandlineOptions(new Options());
+ final CommandLine commandLine =
+ ServerUtil.parseCmdLine("mqfiltersrv", args, buildCommandlineOptions(options),
+ new PosixParser());
+ if (null == commandLine) {
+ System.exit(-1);
+ return null;
+ }
+
+ final FiltersrvConfig filtersrvConfig = new FiltersrvConfig();
+ final NettyServerConfig nettyServerConfig = new NettyServerConfig();
+
+ if (commandLine.hasOption('c')) {
+ String file = commandLine.getOptionValue('c');
+ if (file != null) {
+ InputStream in = new BufferedInputStream(new FileInputStream(file));
+ Properties properties = new Properties();
+ properties.load(in);
+ MixAll.properties2Object(properties, filtersrvConfig);
+ System.out.printf("load config properties file OK, " + file + "%n");
+ in.close();
+
+ String port = properties.getProperty("listenPort");
+ if (port != null) {
+ filtersrvConfig.setConnectWhichBroker(String.format("127.0.0.1:%s", port));
+ }
+ }
+ }
+
+ nettyServerConfig.setListenPort(0);
+ nettyServerConfig.setServerAsyncSemaphoreValue(filtersrvConfig.getFsServerAsyncSemaphoreValue());
+ nettyServerConfig.setServerCallbackExecutorThreads(filtersrvConfig
+ .getFsServerCallbackExecutorThreads());
+ nettyServerConfig.setServerWorkerThreads(filtersrvConfig.getFsServerWorkerThreads());
+
+ if (commandLine.hasOption('p')) {
+ MixAll.printObjectProperties(null, filtersrvConfig);
+ MixAll.printObjectProperties(null, nettyServerConfig);
+ System.exit(0);
+ }
+
+ MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), filtersrvConfig);
+ if (null == filtersrvConfig.getRocketmqHome()) {
+ System.out.printf("Please set the " + MixAll.ROCKETMQ_HOME_ENV
+ + " variable in your environment to match the location of the RocketMQ installation%n");
+ System.exit(-2);
+ }
+
+ LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+ JoranConfigurator configurator = new JoranConfigurator();
+ configurator.setContext(lc);
+ lc.reset();
+ configurator.doConfigure(filtersrvConfig.getRocketmqHome() + "/conf/logback_filtersrv.xml");
+ log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
+
+ final FiltersrvController controller =
+ new FiltersrvController(filtersrvConfig, nettyServerConfig);
+ boolean initResult = controller.initialize();
+ if (!initResult) {
+ controller.shutdown();
+ System.exit(-3);
+ }
+
+ Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
+ private volatile boolean hasShutdown = false;
+ private AtomicInteger shutdownTimes = new AtomicInteger(0);
+
+ @Override
+ public void run() {
+ synchronized (this) {
+ log.info("shutdown hook was invoked, " + this.shutdownTimes.incrementAndGet());
+ if (!this.hasShutdown) {
+ this.hasShutdown = true;
+ long begineTime = System.currentTimeMillis();
+ controller.shutdown();
+ long consumingTimeTotal = System.currentTimeMillis() - begineTime;
+ log.info("shutdown hook over, consuming time total(ms): " + consumingTimeTotal);
+ }
+ }
+ }
+ }, "ShutdownHook"));
+
+ return controller;
+ } catch (Throwable e) {
+ e.printStackTrace();
+ System.exit(-1);
+ }
+ return null;
+ }
+
+ public static Options buildCommandlineOptions(final Options options) {
+ Option opt = new Option("c", "configFile", true, "Filter server config properties file");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+ opt = new Option("p", "printConfigItem", false, "Print all config item");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+ return options;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/DynaCode.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/DynaCode.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/DynaCode.java
new file mode 100644
index 0000000..fd95685
--- /dev/null
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/DynaCode.java
@@ -0,0 +1,393 @@
+/**
+ * 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.filtersrv.filter;
+
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.filter.FilterAPI;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.tools.JavaCompiler;
+import javax.tools.ToolProvider;
+import java.io.*;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLDecoder;
+import java.util.*;
+
+
+public class DynaCode {
+ private static final Logger LOGGER = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
+
+ private static final String FILE_SP = System.getProperty("file.separator");
+
+ private static final String LINE_SP = System.getProperty("line.separator");
+
+ private String sourcePath = System.getProperty("user.home") + FILE_SP + "rocketmq_filter_class" + FILE_SP
+ + UtilAll.getPid();
+
+ private String outPutClassPath = sourcePath;
+
+
+ private ClassLoader parentClassLoader;
+
+
+ private List<String> codeStrs;
+
+
+ private Map<String/* fullClassName */, Class<?>/* class */> loadClass;
+
+
+ private String classpath;
+
+
+ private String bootclasspath;
+
+
+ private String extdirs;
+
+
+ private String encoding = "UTF-8";
+
+
+ private String target;
+
+
+ @SuppressWarnings("unchecked")
+ public DynaCode(String code) {
+ this(Thread.currentThread().getContextClassLoader(), Arrays.asList(code));
+ }
+
+
+ public DynaCode(ClassLoader parentClassLoader, List<String> codeStrs) {
+ this(extractClasspath(parentClassLoader), parentClassLoader, codeStrs);
+ }
+
+
+ public DynaCode(String classpath, ClassLoader parentClassLoader, List<String> codeStrs) {
+ this.classpath = classpath;
+ this.parentClassLoader = parentClassLoader;
+ this.codeStrs = codeStrs;
+ this.loadClass = new HashMap<String, Class<?>>(codeStrs.size());
+ }
+
+
+ private static String extractClasspath(ClassLoader cl) {
+ StringBuffer buf = new StringBuffer();
+ while (cl != null) {
+ if (cl instanceof URLClassLoader) {
+ URL urls[] = ((URLClassLoader) cl).getURLs();
+ for (int i = 0; i < urls.length; i++) {
+ if (buf.length() > 0) {
+ buf.append(File.pathSeparatorChar);
+ }
+ String s = urls[i].getFile();
+ try {
+ s = URLDecoder.decode(s, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ continue;
+ }
+ File f = new File(s);
+ buf.append(f.getAbsolutePath());
+ }
+ }
+ cl = cl.getParent();
+ }
+ return buf.toString();
+ }
+
+
+ public DynaCode(List<String> codeStrs) {
+ this(Thread.currentThread().getContextClassLoader(), codeStrs);
+ }
+
+ public static Class<?> compileAndLoadClass(final String className, final String javaSource)
+ throws Exception {
+ String classSimpleName = FilterAPI.simpleClassName(className);
+ String javaCode = javaSource;
+
+ final String newClassSimpleName = classSimpleName + System.currentTimeMillis();
+ String newJavaCode = javaCode.replaceAll(classSimpleName, newClassSimpleName);
+
+ List<String> codes = new ArrayList<String>();
+ codes.add(newJavaCode);
+ DynaCode dc = new DynaCode(codes);
+ dc.compileAndLoadClass();
+ Map<String, Class<?>> map = dc.getLoadClass();
+
+ Class<?> clazz = map.get(getQualifiedName(newJavaCode));
+ return clazz;
+ }
+
+ public void compileAndLoadClass() throws Exception {
+ String[] sourceFiles = this.uploadSrcFile();
+ this.compile(sourceFiles);
+ this.loadClass(this.loadClass.keySet());
+ }
+
+ public Map<String, Class<?>> getLoadClass() {
+ return loadClass;
+ }
+
+ public static String getQualifiedName(String code) {
+ StringBuilder sb = new StringBuilder();
+ String className = getClassName(code);
+ if (StringUtils.isNotBlank(className)) {
+
+ String packageName = getPackageName(code);
+ if (StringUtils.isNotBlank(packageName)) {
+ sb.append(packageName).append(".");
+ }
+ sb.append(className);
+ }
+ return sb.toString();
+ }
+
+ private String[] uploadSrcFile() throws Exception {
+ List<String> srcFileAbsolutePaths = new ArrayList<String>(codeStrs.size());
+ for (String code : codeStrs) {
+ if (StringUtils.isNotBlank(code)) {
+ String packageName = getPackageName(code);
+ String className = getClassName(code);
+ if (StringUtils.isNotBlank(className)) {
+ File srcFile = null;
+ BufferedWriter bufferWriter = null;
+ try {
+ if (StringUtils.isBlank(packageName)) {
+ File pathFile = new File(sourcePath);
+
+ if (!pathFile.exists()) {
+ if (!pathFile.mkdirs()) {
+ throw new RuntimeException("create PathFile Error!");
+ }
+ }
+ srcFile = new File(sourcePath + FILE_SP + className + ".java");
+ } else {
+ String srcPath = StringUtils.replace(packageName, ".", FILE_SP);
+ File pathFile = new File(sourcePath + FILE_SP + srcPath);
+
+ if (!pathFile.exists()) {
+ if (!pathFile.mkdirs()) {
+ throw new RuntimeException("create PathFile Error!");
+ }
+ }
+ srcFile = new File(pathFile.getAbsolutePath() + FILE_SP + className + ".java");
+ }
+ synchronized (loadClass) {
+ loadClass.put(getFullClassName(code), null);
+ }
+ if (null != srcFile) {
+ LOGGER.warn("Dyna Create Java Source File:---->" + srcFile.getAbsolutePath());
+ srcFileAbsolutePaths.add(srcFile.getAbsolutePath());
+ srcFile.deleteOnExit();
+ }
+ OutputStreamWriter outputStreamWriter =
+ new OutputStreamWriter(new FileOutputStream(srcFile), encoding);
+ bufferWriter = new BufferedWriter(outputStreamWriter);
+ for (String lineCode : code.split(LINE_SP)) {
+ bufferWriter.write(lineCode);
+ bufferWriter.newLine();
+ }
+ bufferWriter.flush();
+ } finally {
+ if (null != bufferWriter) {
+ bufferWriter.close();
+ }
+ }
+ }
+ }
+ }
+ return srcFileAbsolutePaths.toArray(new String[srcFileAbsolutePaths.size()]);
+ }
+
+ private void compile(String[] srcFiles) throws Exception {
+ String args[] = this.buildCompileJavacArgs(srcFiles);
+ ByteArrayOutputStream err = new ByteArrayOutputStream();
+ JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+ if (compiler == null) {
+ throw new NullPointerException(
+ "ToolProvider.getSystemJavaCompiler() return null,please use JDK replace JRE!");
+ }
+ int resultCode = compiler.run(null, null, err, args);
+ if (resultCode != 0) {
+ throw new Exception(err.toString(RemotingHelper.DEFAULT_CHARSET));
+ }
+ }
+
+ private void loadClass(Set<String> classFullNames) throws ClassNotFoundException, MalformedURLException {
+ synchronized (loadClass) {
+ ClassLoader classLoader =
+ new URLClassLoader(new URL[]{new File(outPutClassPath).toURI().toURL()},
+ parentClassLoader);
+ for (String key : classFullNames) {
+ Class<?> classz = classLoader.loadClass(key);
+ if (null != classz) {
+ loadClass.put(key, classz);
+ LOGGER.info("Dyna Load Java Class File OK:----> className: " + key);
+ } else {
+ LOGGER.error("Dyna Load Java Class File Fail:----> className: " + key);
+ }
+ }
+ }
+ }
+
+ public static String getClassName(String code) {
+ String className = StringUtils.substringBefore(code, "{");
+ if (StringUtils.isBlank(className)) {
+ return className;
+ }
+ if (StringUtils.contains(code, " class ")) {
+ className = StringUtils.substringAfter(className, " class ");
+ if (StringUtils.contains(className, " extends ")) {
+ className = StringUtils.substringBefore(className, " extends ").trim();
+ } else if (StringUtils.contains(className, " implements ")) {
+ className = StringUtils.trim(StringUtils.substringBefore(className, " implements "));
+ } else {
+ className = StringUtils.trim(className);
+ }
+ } else if (StringUtils.contains(code, " interface ")) {
+ className = StringUtils.substringAfter(className, " interface ");
+ if (StringUtils.contains(className, " extends ")) {
+ className = StringUtils.substringBefore(className, " extends ").trim();
+ } else {
+ className = StringUtils.trim(className);
+ }
+ } else if (StringUtils.contains(code, " enum ")) {
+ className = StringUtils.trim(StringUtils.substringAfter(className, " enum "));
+ } else {
+ return StringUtils.EMPTY;
+ }
+ return className;
+ }
+
+ public static String getPackageName(String code) {
+ String packageName =
+ StringUtils.substringBefore(StringUtils.substringAfter(code, "package "), ";").trim();
+ return packageName;
+ }
+
+ public static String getFullClassName(String code) {
+ String packageName = getPackageName(code);
+ String className = getClassName(code);
+ return StringUtils.isBlank(packageName) ? className : packageName + "." + className;
+ }
+
+ private String[] buildCompileJavacArgs(String srcFiles[]) {
+ ArrayList<String> args = new ArrayList<String>();
+ if (StringUtils.isNotBlank(classpath)) {
+ args.add("-classpath");
+ args.add(classpath);
+ }
+ if (StringUtils.isNotBlank(outPutClassPath)) {
+ args.add("-d");
+ args.add(outPutClassPath);
+ }
+ if (StringUtils.isNotBlank(sourcePath)) {
+ args.add("-sourcepath");
+ args.add(sourcePath);
+ }
+ if (StringUtils.isNotBlank(bootclasspath)) {
+ args.add("-bootclasspath");
+ args.add(bootclasspath);
+ }
+ if (StringUtils.isNotBlank(extdirs)) {
+ args.add("-extdirs");
+ args.add(extdirs);
+ }
+ if (StringUtils.isNotBlank(encoding)) {
+ args.add("-encoding");
+ args.add(encoding);
+ }
+ if (StringUtils.isNotBlank(target)) {
+ args.add("-target");
+ args.add(target);
+ }
+ for (int i = 0; i < srcFiles.length; i++) {
+ args.add(srcFiles[i]);
+ }
+ return args.toArray(new String[args.size()]);
+ }
+
+ public String getOutPutClassPath() {
+ return outPutClassPath;
+ }
+
+ public void setOutPutClassPath(String outPutClassPath) {
+ this.outPutClassPath = outPutClassPath;
+ }
+
+ public String getSourcePath() {
+ return sourcePath;
+ }
+
+ public void setSourcePath(String sourcePath) {
+ this.sourcePath = sourcePath;
+ }
+
+ public ClassLoader getParentClassLoader() {
+ return parentClassLoader;
+ }
+
+ public void setParentClassLoader(ClassLoader parentClassLoader) {
+ this.parentClassLoader = parentClassLoader;
+ }
+
+ public String getClasspath() {
+ return classpath;
+ }
+
+ public void setClasspath(String classpath) {
+ this.classpath = classpath;
+ }
+
+ public String getBootclasspath() {
+ return bootclasspath;
+ }
+
+ public void setBootclasspath(String bootclasspath) {
+ this.bootclasspath = bootclasspath;
+ }
+
+ public String getExtdirs() {
+ return extdirs;
+ }
+
+ public void setExtdirs(String extdirs) {
+ this.extdirs = extdirs;
+ }
+
+ public String getEncoding() {
+ return encoding;
+ }
+
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassFetchMethod.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassFetchMethod.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassFetchMethod.java
new file mode 100644
index 0000000..36d6b7e
--- /dev/null
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassFetchMethod.java
@@ -0,0 +1,22 @@
+/**
+ * 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.filtersrv.filter;
+
+public interface FilterClassFetchMethod {
+ public String fetch(final String topic, final String consumerGroup, final String className);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassInfo.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassInfo.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassInfo.java
new file mode 100644
index 0000000..d278fe3
--- /dev/null
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassInfo.java
@@ -0,0 +1,57 @@
+/**
+ * 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.filtersrv.filter;
+
+import org.apache.rocketmq.common.filter.MessageFilter;
+
+
+public class FilterClassInfo {
+ private String className;
+ private int classCRC;
+ private MessageFilter messageFilter;
+
+
+ public int getClassCRC() {
+ return classCRC;
+ }
+
+
+ public void setClassCRC(int classCRC) {
+ this.classCRC = classCRC;
+ }
+
+
+ public MessageFilter getMessageFilter() {
+ return messageFilter;
+ }
+
+
+ public void setMessageFilter(MessageFilter messageFilter) {
+ this.messageFilter = messageFilter;
+ }
+
+
+ public String getClassName() {
+ return className;
+ }
+
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassLoader.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassLoader.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassLoader.java
new file mode 100644
index 0000000..3269852
--- /dev/null
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassLoader.java
@@ -0,0 +1,24 @@
+/**
+ * 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.filtersrv.filter;
+
+public class FilterClassLoader extends ClassLoader {
+ public final Class<?> createNewClass(String name, byte[] b, int off, int len) throws ClassFormatError {
+ return this.defineClass(name, b, off, len);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassManager.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassManager.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassManager.java
new file mode 100644
index 0000000..fab4d7d
--- /dev/null
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassManager.java
@@ -0,0 +1,175 @@
+/**
+ * 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.filtersrv.filter;
+
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.ThreadFactoryImpl;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.filter.MessageFilter;
+import org.apache.rocketmq.filtersrv.FiltersrvController;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+
+public class FilterClassManager {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
+
+ private final Object compileLock = new Object();
+ private final FiltersrvController filtersrvController;
+
+ private final ScheduledExecutorService scheduledExecutorService = Executors
+ .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("FSGetClassScheduledThread"));
+ private ConcurrentHashMap<String/* topic@consumerGroup */, FilterClassInfo> filterClassTable =
+ new ConcurrentHashMap<String, FilterClassInfo>(128);
+ private FilterClassFetchMethod filterClassFetchMethod;
+
+
+ public FilterClassManager(FiltersrvController filtersrvController) {
+ this.filtersrvController = filtersrvController;
+ this.filterClassFetchMethod =
+ new HttpFilterClassFetchMethod(this.filtersrvController.getFiltersrvConfig()
+ .getFilterClassRepertoryUrl());
+ }
+
+
+ public void start() {
+ if (!this.filtersrvController.getFiltersrvConfig().isClientUploadFilterClassEnable()) {
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+
+ @Override
+ public void run() {
+ fetchClassFromRemoteHost();
+ }
+ }, 1, 1, TimeUnit.MINUTES);
+ }
+ }
+
+ private void fetchClassFromRemoteHost() {
+ Iterator<Entry<String, FilterClassInfo>> it = this.filterClassTable.entrySet().iterator();
+ while (it.hasNext()) {
+ try {
+ Entry<String, FilterClassInfo> next = it.next();
+ FilterClassInfo filterClassInfo = next.getValue();
+ String[] topicAndGroup = next.getKey().split("@");
+ String responseStr =
+ this.filterClassFetchMethod.fetch(topicAndGroup[0], topicAndGroup[1],
+ filterClassInfo.getClassName());
+ byte[] filterSourceBinary = responseStr.getBytes("UTF-8");
+ int classCRC = UtilAll.crc32(responseStr.getBytes("UTF-8"));
+ if (classCRC != filterClassInfo.getClassCRC()) {
+ String javaSource = new String(filterSourceBinary, MixAll.DEFAULT_CHARSET);
+ Class<?> newClass =
+ DynaCode.compileAndLoadClass(filterClassInfo.getClassName(), javaSource);
+ Object newInstance = newClass.newInstance();
+ filterClassInfo.setMessageFilter((MessageFilter) newInstance);
+ filterClassInfo.setClassCRC(classCRC);
+
+ log.info("fetch Remote class File OK, {} {}", next.getKey(),
+ filterClassInfo.getClassName());
+ }
+ } catch (Exception e) {
+ log.error("fetchClassFromRemoteHost Exception", e);
+ }
+ }
+ }
+
+ public void shutdown() {
+ this.scheduledExecutorService.shutdown();
+ }
+
+ public boolean registerFilterClass(final String consumerGroup, final String topic,
+ final String className, final int classCRC, final byte[] filterSourceBinary) {
+ final String key = buildKey(consumerGroup, topic);
+
+
+ boolean registerNew = false;
+ FilterClassInfo filterClassInfoPrev = this.filterClassTable.get(key);
+ if (null == filterClassInfoPrev) {
+ registerNew = true;
+ } else {
+ if (this.filtersrvController.getFiltersrvConfig().isClientUploadFilterClassEnable()) {
+ if (filterClassInfoPrev.getClassCRC() != classCRC && classCRC != 0) {
+ registerNew = true;
+ }
+ }
+ }
+
+ if (registerNew) {
+ synchronized (this.compileLock) {
+ filterClassInfoPrev = this.filterClassTable.get(key);
+ if (null != filterClassInfoPrev && filterClassInfoPrev.getClassCRC() == classCRC) {
+ return true;
+ }
+
+ try {
+
+ FilterClassInfo filterClassInfoNew = new FilterClassInfo();
+ filterClassInfoNew.setClassName(className);
+ filterClassInfoNew.setClassCRC(0);
+ filterClassInfoNew.setMessageFilter(null);
+
+ if (this.filtersrvController.getFiltersrvConfig().isClientUploadFilterClassEnable()) {
+ String javaSource = new String(filterSourceBinary, MixAll.DEFAULT_CHARSET);
+ Class<?> newClass = DynaCode.compileAndLoadClass(className, javaSource);
+ Object newInstance = newClass.newInstance();
+ filterClassInfoNew.setMessageFilter((MessageFilter) newInstance);
+ filterClassInfoNew.setClassCRC(classCRC);
+ }
+
+ this.filterClassTable.put(key, filterClassInfoNew);
+ } catch (Throwable e) {
+ String info =
+ String
+ .format(
+ "FilterServer, registerFilterClass Exception, consumerGroup: %s topic: %s className: %s",
+ consumerGroup, topic, className);
+ log.error(info, e);
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private static String buildKey(final String consumerGroup, final String topic) {
+ return topic + "@" + consumerGroup;
+ }
+
+ public FilterClassInfo findFilterClass(final String consumerGroup, final String topic) {
+ return this.filterClassTable.get(buildKey(consumerGroup, topic));
+ }
+
+
+ public FilterClassFetchMethod getFilterClassFetchMethod() {
+ return filterClassFetchMethod;
+ }
+
+
+ public void setFilterClassFetchMethod(FilterClassFetchMethod filterClassFetchMethod) {
+ this.filterClassFetchMethod = filterClassFetchMethod;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/HttpFilterClassFetchMethod.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/HttpFilterClassFetchMethod.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/HttpFilterClassFetchMethod.java
new file mode 100644
index 0000000..c8b1515
--- /dev/null
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/HttpFilterClassFetchMethod.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 org.apache.rocketmq.filtersrv.filter;
+
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.utils.HttpTinyClient;
+import org.apache.rocketmq.common.utils.HttpTinyClient.HttpResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class HttpFilterClassFetchMethod implements FilterClassFetchMethod {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
+ private final String url;
+
+
+ public HttpFilterClassFetchMethod(String url) {
+ this.url = url;
+ }
+
+
+ @Override
+ public String fetch(String topic, String consumerGroup, String className) {
+ String thisUrl = String.format("%s/%s.java", this.url, className);
+
+ try {
+ HttpResult result = HttpTinyClient.httpGet(thisUrl, null, null, "UTF-8", 5000);
+ if (200 == result.code) {
+ return result.content;
+ }
+ } catch (Exception e) {
+ log.error(
+ String.format("call <%s> exception, Topic: %s Group: %s", thisUrl, topic, consumerGroup), e);
+ }
+
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
new file mode 100644
index 0000000..5553952
--- /dev/null
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
@@ -0,0 +1,355 @@
+/**
+ * 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.filtersrv.processor;
+
+import org.apache.rocketmq.client.consumer.DefaultMQPullConsumer;
+import org.apache.rocketmq.client.consumer.PullCallback;
+import org.apache.rocketmq.client.consumer.PullResult;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.filter.FilterContext;
+import org.apache.rocketmq.common.message.MessageDecoder;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.RequestCode;
+import org.apache.rocketmq.common.protocol.ResponseCode;
+import org.apache.rocketmq.common.protocol.header.PullMessageRequestHeader;
+import org.apache.rocketmq.common.protocol.header.PullMessageResponseHeader;
+import org.apache.rocketmq.common.protocol.header.filtersrv.RegisterMessageFilterClassRequestHeader;
+import org.apache.rocketmq.common.sysflag.MessageSysFlag;
+import org.apache.rocketmq.filtersrv.FiltersrvController;
+import org.apache.rocketmq.filtersrv.filter.FilterClassInfo;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.apache.rocketmq.store.CommitLog;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelFutureListener;
+import io.netty.channel.ChannelHandlerContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class DefaultRequestProcessor implements NettyRequestProcessor {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
+
+ private final FiltersrvController filtersrvController;
+
+
+ public DefaultRequestProcessor(FiltersrvController filtersrvController) {
+ this.filtersrvController = filtersrvController;
+ }
+
+
+ @Override
+ public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws Exception {
+ if (log.isDebugEnabled()) {
+ log.debug("receive request, {} {} {}",
+ request.getCode(),
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
+ request);
+ }
+
+ switch (request.getCode()) {
+ case RequestCode.REGISTER_MESSAGE_FILTER_CLASS:
+ return registerMessageFilterClass(ctx, request);
+ case RequestCode.PULL_MESSAGE:
+ return pullMessageForward(ctx, request);
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean rejectRequest() {
+ return false;
+ }
+
+ private RemotingCommand registerMessageFilterClass(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ final RegisterMessageFilterClassRequestHeader requestHeader =
+ (RegisterMessageFilterClassRequestHeader) request.decodeCommandCustomHeader(RegisterMessageFilterClassRequestHeader.class);
+
+ try {
+ boolean ok = this.filtersrvController.getFilterClassManager().registerFilterClass(requestHeader.getConsumerGroup(),
+ requestHeader.getTopic(),
+ requestHeader.getClassName(),
+ requestHeader.getClassCRC(),
+ request.getBody());
+ if (!ok) {
+ throw new Exception("registerFilterClass error");
+ }
+ } catch (Exception e) {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark(RemotingHelper.exceptionSimpleDesc(e));
+ return response;
+ }
+
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand pullMessageForward(final ChannelHandlerContext ctx, final RemotingCommand request) throws Exception {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(PullMessageResponseHeader.class);
+ final PullMessageResponseHeader responseHeader = (PullMessageResponseHeader) response.readCustomHeader();
+ final PullMessageRequestHeader requestHeader =
+ (PullMessageRequestHeader) request.decodeCommandCustomHeader(PullMessageRequestHeader.class);
+
+ final FilterContext filterContext = new FilterContext();
+ filterContext.setConsumerGroup(requestHeader.getConsumerGroup());
+
+
+ response.setOpaque(request.getOpaque());
+
+ DefaultMQPullConsumer pullConsumer = this.filtersrvController.getDefaultMQPullConsumer();
+ final FilterClassInfo findFilterClass =
+ this.filtersrvController.getFilterClassManager()
+ .findFilterClass(requestHeader.getConsumerGroup(), requestHeader.getTopic());
+ if (null == findFilterClass) {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("Find Filter class failed, not registered");
+ return response;
+ }
+
+ if (null == findFilterClass.getMessageFilter()) {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("Find Filter class failed, registered but no class");
+ return response;
+ }
+
+ responseHeader.setSuggestWhichBrokerId(MixAll.MASTER_ID);
+
+
+ MessageQueue mq = new MessageQueue();
+ mq.setTopic(requestHeader.getTopic());
+ mq.setQueueId(requestHeader.getQueueId());
+ mq.setBrokerName(this.filtersrvController.getBrokerName());
+ long offset = requestHeader.getQueueOffset();
+ int maxNums = requestHeader.getMaxMsgNums();
+
+ final PullCallback pullCallback = new PullCallback() {
+
+ @Override
+ public void onSuccess(PullResult pullResult) {
+ responseHeader.setMaxOffset(pullResult.getMaxOffset());
+ responseHeader.setMinOffset(pullResult.getMinOffset());
+ responseHeader.setNextBeginOffset(pullResult.getNextBeginOffset());
+ response.setRemark(null);
+
+ switch (pullResult.getPullStatus()) {
+ case FOUND:
+ response.setCode(ResponseCode.SUCCESS);
+
+ List<MessageExt> msgListOK = new ArrayList<MessageExt>();
+ try {
+ for (MessageExt msg : pullResult.getMsgFoundList()) {
+ boolean match = findFilterClass.getMessageFilter().match(msg, filterContext);
+ if (match) {
+ msgListOK.add(msg);
+ }
+ }
+
+
+ if (!msgListOK.isEmpty()) {
+ returnResponse(requestHeader.getConsumerGroup(), requestHeader.getTopic(), ctx, response, msgListOK);
+ return;
+ } else {
+ response.setCode(ResponseCode.PULL_RETRY_IMMEDIATELY);
+ }
+ } catch (Throwable e) {
+ final String error =
+ String.format("do Message Filter Exception, ConsumerGroup: %s Topic: %s ",
+ requestHeader.getConsumerGroup(), requestHeader.getTopic());
+ log.error(error, e);
+
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark(error + RemotingHelper.exceptionSimpleDesc(e));
+ returnResponse(requestHeader.getConsumerGroup(), requestHeader.getTopic(), ctx, response, null);
+ return;
+ }
+
+ break;
+ case NO_MATCHED_MSG:
+ response.setCode(ResponseCode.PULL_RETRY_IMMEDIATELY);
+ break;
+ case NO_NEW_MSG:
+ response.setCode(ResponseCode.PULL_NOT_FOUND);
+ break;
+ case OFFSET_ILLEGAL:
+ response.setCode(ResponseCode.PULL_OFFSET_MOVED);
+ break;
+ default:
+ break;
+ }
+
+ returnResponse(requestHeader.getConsumerGroup(), requestHeader.getTopic(), ctx, response, null);
+ }
+
+
+ @Override
+ public void onException(Throwable e) {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("Pull Callback Exception, " + RemotingHelper.exceptionSimpleDesc(e));
+ returnResponse(requestHeader.getConsumerGroup(), requestHeader.getTopic(), ctx, response, null);
+ return;
+ }
+ };
+
+ pullConsumer.pullBlockIfNotFound(mq, null, offset, maxNums, pullCallback);
+
+ return null;
+ }
+
+ private void returnResponse(final String group, final String topic, ChannelHandlerContext ctx, final RemotingCommand response,
+ final List<MessageExt> msgList) {
+ if (null != msgList) {
+ ByteBuffer[] msgBufferList = new ByteBuffer[msgList.size()];
+ int bodyTotalSize = 0;
+ for (int i = 0; i < msgList.size(); i++) {
+ try {
+ msgBufferList[i] = messageToByteBuffer(msgList.get(i));
+ bodyTotalSize += msgBufferList[i].capacity();
+ } catch (Exception e) {
+ log.error("messageToByteBuffer UnsupportedEncodingException", e);
+ }
+ }
+
+ ByteBuffer body = ByteBuffer.allocate(bodyTotalSize);
+ for (ByteBuffer bb : msgBufferList) {
+ bb.flip();
+ body.put(bb);
+ }
+
+ response.setBody(body.array());
+
+
+ this.filtersrvController.getFilterServerStatsManager().incGroupGetNums(group, topic, msgList.size());
+
+ this.filtersrvController.getFilterServerStatsManager().incGroupGetSize(group, topic, bodyTotalSize);
+ }
+
+ try {
+ ctx.writeAndFlush(response).addListener(new ChannelFutureListener() {
+ @Override
+ public void operationComplete(ChannelFuture future) throws Exception {
+ if (!future.isSuccess()) {
+ log.error("FilterServer response to " + future.channel().remoteAddress() + " failed", future.cause());
+ log.error(response.toString());
+ }
+ }
+ });
+ } catch (Throwable e) {
+ log.error("FilterServer process request over, but response failed", e);
+ log.error(response.toString());
+ }
+ }
+
+ private ByteBuffer messageToByteBuffer(final MessageExt msg) throws IOException {
+ int sysFlag = MessageSysFlag.clearCompressedFlag(msg.getSysFlag());
+ if (msg.getBody() != null) {
+ if (msg.getBody().length >= this.filtersrvController.getFiltersrvConfig().getCompressMsgBodyOverHowmuch()) {
+ byte[] data = UtilAll.compress(msg.getBody(), this.filtersrvController.getFiltersrvConfig().getZipCompressLevel());
+ if (data != null) {
+ msg.setBody(data);
+ sysFlag |= MessageSysFlag.COMPRESSED_FLAG;
+ }
+ }
+ }
+
+ final int bodyLength = msg.getBody() != null ? msg.getBody().length : 0;
+ byte[] topicData = msg.getTopic().getBytes(MixAll.DEFAULT_CHARSET);
+ final int topicLength = topicData.length;
+ String properties = MessageDecoder.messageProperties2String(msg.getProperties());
+ byte[] propertiesData = properties.getBytes(MixAll.DEFAULT_CHARSET);
+ final int propertiesLength = propertiesData.length;
+ final int msgLen = 4 // 1 TOTALSIZE
+ + 4 // 2 MAGICCODE
+ + 4 // 3 BODYCRC
+ + 4 // 4 QUEUEID
+ + 4 // 5 FLAG
+ + 8 // 6 QUEUEOFFSET
+ + 8 // 7 PHYSICALOFFSET
+ + 4 // 8 SYSFLAG
+ + 8 // 9 BORNTIMESTAMP
+ + 8 // 10 BORNHOST
+ + 8 // 11 STORETIMESTAMP
+ + 8 // 12 STOREHOSTADDRESS
+ + 4 // 13 RECONSUMETIMES
+ + 8 // 14 Prepared Transaction Offset
+ + 4 + bodyLength // 14 BODY
+ + 1 + topicLength // 15 TOPIC
+ + 2 + propertiesLength // 16 propertiesLength
+ + 0;
+
+ ByteBuffer msgStoreItemMemory = ByteBuffer.allocate(msgLen);
+
+ final MessageExt msgInner = msg;
+
+ // 1 TOTALSIZE
+ msgStoreItemMemory.putInt(msgLen);
+ // 2 MAGICCODE
+ msgStoreItemMemory.putInt(CommitLog.MESSAGE_MAGIC_CODE);
+ // 3 BODYCRC
+ msgStoreItemMemory.putInt(UtilAll.crc32(msgInner.getBody()));
+ // 4 QUEUEID
+ msgStoreItemMemory.putInt(msgInner.getQueueId());
+ // 5 FLAG
+ msgStoreItemMemory.putInt(msgInner.getFlag());
+ // 6 QUEUEOFFSET
+ msgStoreItemMemory.putLong(msgInner.getQueueOffset());
+ // 7 PHYSICALOFFSET
+ msgStoreItemMemory.putLong(msgInner.getCommitLogOffset());
+ // 8 SYSFLAG
+ msgStoreItemMemory.putInt(sysFlag);
+ // 9 BORNTIMESTAMP
+ msgStoreItemMemory.putLong(msgInner.getBornTimestamp());
+ // 10 BORNHOST
+ msgStoreItemMemory.put(msgInner.getBornHostBytes());
+ // 11 STORETIMESTAMP
+ msgStoreItemMemory.putLong(msgInner.getStoreTimestamp());
+ // 12 STOREHOSTADDRESS
+ msgStoreItemMemory.put(msgInner.getStoreHostBytes());
+ // 13 RECONSUMETIMES
+ msgStoreItemMemory.putInt(msgInner.getReconsumeTimes());
+ // 14 Prepared Transaction Offset
+ msgStoreItemMemory.putLong(msgInner.getPreparedTransactionOffset());
+ // 15 BODY
+ msgStoreItemMemory.putInt(bodyLength);
+ if (bodyLength > 0)
+ msgStoreItemMemory.put(msgInner.getBody());
+ // 16 TOPIC
+ msgStoreItemMemory.put((byte) topicLength);
+ msgStoreItemMemory.put(topicData);
+ // 17 PROPERTIES
+ msgStoreItemMemory.putShort((short) propertiesLength);
+ if (propertiesLength > 0)
+ msgStoreItemMemory.put(propertiesData);
+
+ return msgStoreItemMemory;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/stats/FilterServerStatsManager.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/stats/FilterServerStatsManager.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/stats/FilterServerStatsManager.java
new file mode 100644
index 0000000..8665fbd
--- /dev/null
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/stats/FilterServerStatsManager.java
@@ -0,0 +1,65 @@
+/**
+ * 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.filtersrv.stats;
+
+import org.apache.rocketmq.common.ThreadFactoryImpl;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.stats.StatsItemSet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+
+
+public class FilterServerStatsManager {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
+ private final ScheduledExecutorService scheduledExecutorService = Executors
+ .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("FSStatsThread"));
+
+ // ConsumerGroup Get Nums
+ private final StatsItemSet groupGetNums = new StatsItemSet("GROUP_GET_NUMS",
+ this.scheduledExecutorService, log);
+
+ // ConsumerGroup Get Size
+ private final StatsItemSet groupGetSize = new StatsItemSet("GROUP_GET_SIZE",
+ this.scheduledExecutorService, log);
+
+
+ public FilterServerStatsManager() {
+ }
+
+
+ public void start() {
+ }
+
+
+ public void shutdown() {
+ this.scheduledExecutorService.shutdown();
+ }
+
+
+ public void incGroupGetNums(final String group, final String topic, final int incValue) {
+ this.groupGetNums.addValue(topic + "@" + group, incValue, 1);
+ }
+
+
+ public void incGroupGetSize(final String group, final String topic, final int incValue) {
+ this.groupGetSize.addValue(topic + "@" + group, incValue, 1);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/namesrv/pom.xml
----------------------------------------------------------------------
diff --git a/namesrv/pom.xml b/namesrv/pom.xml
index 3494f8f..2ec2f5f 100644
--- a/namesrv/pom.xml
+++ b/namesrv/pom.xml
@@ -18,7 +18,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.rocketmq</groupId>
+ <groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-all</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>
@@ -35,11 +35,11 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>com.alibaba.rocketmq</groupId>
+ <groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
</dependency>
<dependency>
- <groupId>com.alibaba.rocketmq</groupId>
+ <groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-tools</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/namesrv/src/main/java/com/alibaba/rocketmq/namesrv/NamesrvController.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/com/alibaba/rocketmq/namesrv/NamesrvController.java b/namesrv/src/main/java/com/alibaba/rocketmq/namesrv/NamesrvController.java
deleted file mode 100644
index 82f2622..0000000
--- a/namesrv/src/main/java/com/alibaba/rocketmq/namesrv/NamesrvController.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/**
- * 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.namesrv;
-
-import com.alibaba.rocketmq.common.Configuration;
-import com.alibaba.rocketmq.common.ThreadFactoryImpl;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.namesrv.NamesrvConfig;
-import com.alibaba.rocketmq.namesrv.kvconfig.KVConfigManager;
-import com.alibaba.rocketmq.namesrv.processor.ClusterTestRequestProcessor;
-import com.alibaba.rocketmq.namesrv.processor.DefaultRequestProcessor;
-import com.alibaba.rocketmq.namesrv.routeinfo.BrokerHousekeepingService;
-import com.alibaba.rocketmq.namesrv.routeinfo.RouteInfoManager;
-import com.alibaba.rocketmq.remoting.RemotingServer;
-import com.alibaba.rocketmq.remoting.netty.NettyRemotingServer;
-import com.alibaba.rocketmq.remoting.netty.NettyServerConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-
-/**
- * @author shijia.wxr
- */
-public class NamesrvController {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
-
- private final NamesrvConfig namesrvConfig;
-
- private final NettyServerConfig nettyServerConfig;
-
- private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl(
- "NSScheduledThread"));
- private final KVConfigManager kvConfigManager;
- private final RouteInfoManager routeInfoManager;
-
- private RemotingServer remotingServer;
-
- private BrokerHousekeepingService brokerHousekeepingService;
-
- private ExecutorService remotingExecutor;
-
- private Configuration configuration;
-
-
- public NamesrvController(NamesrvConfig namesrvConfig, NettyServerConfig nettyServerConfig) {
- this.namesrvConfig = namesrvConfig;
- this.nettyServerConfig = nettyServerConfig;
- this.kvConfigManager = new KVConfigManager(this);
- this.routeInfoManager = new RouteInfoManager();
- this.brokerHousekeepingService = new BrokerHousekeepingService(this);
- this.configuration = new Configuration(
- log,
- this.namesrvConfig, this.nettyServerConfig
- );
- this.configuration.setStorePathFromConfig(this.namesrvConfig, "configStorePath");
- }
-
-
- public boolean initialize() {
-
- this.kvConfigManager.load();
-
- this.remotingServer = new NettyRemotingServer(this.nettyServerConfig, this.brokerHousekeepingService);
-
-
- this.remotingExecutor =
- Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(), new ThreadFactoryImpl("RemotingExecutorThread_"));
-
- this.registerProcessor();
-
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
-
- @Override
- public void run() {
- NamesrvController.this.routeInfoManager.scanNotActiveBroker();
- }
- }, 5, 10, TimeUnit.SECONDS);
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
-
- @Override
- public void run() {
- NamesrvController.this.kvConfigManager.printAllPeriodically();
- }
- }, 1, 10, TimeUnit.MINUTES);
-
- return true;
- }
-
-
- private void registerProcessor() {
- if (namesrvConfig.isClusterTest()) {
-
- this.remotingServer.registerDefaultProcessor(new ClusterTestRequestProcessor(this, namesrvConfig.getProductEnvName()),
- this.remotingExecutor);
- } else {
-
- this.remotingServer.registerDefaultProcessor(new DefaultRequestProcessor(this), this.remotingExecutor);
- }
- }
-
-
- public void start() throws Exception {
- this.remotingServer.start();
- }
-
-
- public void shutdown() {
- this.remotingServer.shutdown();
- this.remotingExecutor.shutdown();
- this.scheduledExecutorService.shutdown();
- }
-
-
- public NamesrvConfig getNamesrvConfig() {
- return namesrvConfig;
- }
-
-
- public NettyServerConfig getNettyServerConfig() {
- return nettyServerConfig;
- }
-
-
- public KVConfigManager getKvConfigManager() {
- return kvConfigManager;
- }
-
-
- public RouteInfoManager getRouteInfoManager() {
- return routeInfoManager;
- }
-
-
- public RemotingServer getRemotingServer() {
- return remotingServer;
- }
-
-
- public void setRemotingServer(RemotingServer remotingServer) {
- this.remotingServer = remotingServer;
- }
-
- public Configuration getConfiguration() {
- return configuration;
- }
-}
[18/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/UtilAll.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/UtilAll.java b/common/src/main/java/com/alibaba/rocketmq/common/UtilAll.java
deleted file mode 100644
index 4429e3d..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/UtilAll.java
+++ /dev/null
@@ -1,525 +0,0 @@
-/**
- * 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.common;
-
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.lang.management.RuntimeMXBean;
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.text.NumberFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.util.zip.CRC32;
-import java.util.zip.DeflaterOutputStream;
-import java.util.zip.InflaterInputStream;
-
-
-/**
- * @author shijia.wxr
- */
-public class UtilAll {
- public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
- public static final String YYYY_MM_DD_HH_MM_SS_SSS = "yyyy-MM-dd#HH:mm:ss:SSS";
- public static final String YYYY_MMDD_HHMMSS = "yyyyMMddHHmmss";
-
-
- public static int getPid() {
- RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
- String name = runtime.getName(); // format: "pid@hostname"
- try {
- return Integer.parseInt(name.substring(0, name.indexOf('@')));
- } catch (Exception e) {
- return -1;
- }
- }
-
- public static String currentStackTrace() {
- StringBuilder sb = new StringBuilder();
- StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
- for (StackTraceElement ste : stackTrace) {
- sb.append("\n\t");
- sb.append(ste.toString());
- }
-
- return sb.toString();
- }
-
- public static String offset2FileName(final long offset) {
- final NumberFormat nf = NumberFormat.getInstance();
- nf.setMinimumIntegerDigits(20);
- nf.setMaximumFractionDigits(0);
- nf.setGroupingUsed(false);
- return nf.format(offset);
- }
-
- public static long computeEclipseTimeMilliseconds(final long beginTime) {
- return System.currentTimeMillis() - beginTime;
- }
-
-
- public static boolean isItTimeToDo(final String when) {
- String[] whiles = when.split(";");
- if (whiles != null && whiles.length > 0) {
- Calendar now = Calendar.getInstance();
- for (String w : whiles) {
- int nowHour = Integer.parseInt(w);
- if (nowHour == now.get(Calendar.HOUR_OF_DAY)) {
- return true;
- }
- }
- }
-
- return false;
- }
-
-
- public static String timeMillisToHumanString() {
- return timeMillisToHumanString(System.currentTimeMillis());
- }
-
-
- public static String timeMillisToHumanString(final long t) {
- Calendar cal = Calendar.getInstance();
- cal.setTimeInMillis(t);
- return String.format("%04d%02d%02d%02d%02d%02d%03d", cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1,
- cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND),
- cal.get(Calendar.MILLISECOND));
- }
-
-
- public static long computNextMorningTimeMillis() {
- Calendar cal = Calendar.getInstance();
- cal.setTimeInMillis(System.currentTimeMillis());
- cal.add(Calendar.DAY_OF_MONTH, 1);
- cal.set(Calendar.HOUR_OF_DAY, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
-
- return cal.getTimeInMillis();
- }
-
-
- public static long computNextMinutesTimeMillis() {
- Calendar cal = Calendar.getInstance();
- cal.setTimeInMillis(System.currentTimeMillis());
- cal.add(Calendar.DAY_OF_MONTH, 0);
- cal.add(Calendar.HOUR_OF_DAY, 0);
- cal.add(Calendar.MINUTE, 1);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
-
- return cal.getTimeInMillis();
- }
-
-
- public static long computNextHourTimeMillis() {
- Calendar cal = Calendar.getInstance();
- cal.setTimeInMillis(System.currentTimeMillis());
- cal.add(Calendar.DAY_OF_MONTH, 0);
- cal.add(Calendar.HOUR_OF_DAY, 1);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
-
- return cal.getTimeInMillis();
- }
-
-
- public static long computNextHalfHourTimeMillis() {
- Calendar cal = Calendar.getInstance();
- cal.setTimeInMillis(System.currentTimeMillis());
- cal.add(Calendar.DAY_OF_MONTH, 0);
- cal.add(Calendar.HOUR_OF_DAY, 1);
- cal.set(Calendar.MINUTE, 30);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
-
- return cal.getTimeInMillis();
- }
-
-
- public static String timeMillisToHumanString2(final long t) {
- Calendar cal = Calendar.getInstance();
- cal.setTimeInMillis(t);
- return String.format("%04d-%02d-%02d %02d:%02d:%02d,%03d",
- cal.get(Calendar.YEAR),
- cal.get(Calendar.MONTH) + 1,
- cal.get(Calendar.DAY_OF_MONTH),
- cal.get(Calendar.HOUR_OF_DAY),
- cal.get(Calendar.MINUTE),
- cal.get(Calendar.SECOND),
- cal.get(Calendar.MILLISECOND));
- }
-
-
- public static String timeMillisToHumanString3(final long t) {
- Calendar cal = Calendar.getInstance();
- cal.setTimeInMillis(t);
- return String.format("%04d%02d%02d%02d%02d%02d",
- cal.get(Calendar.YEAR),
- cal.get(Calendar.MONTH) + 1,
- cal.get(Calendar.DAY_OF_MONTH),
- cal.get(Calendar.HOUR_OF_DAY),
- cal.get(Calendar.MINUTE),
- cal.get(Calendar.SECOND));
- }
-
-
- public static double getDiskPartitionSpaceUsedPercent(final String path) {
- if (null == path || path.isEmpty())
- return -1;
-
- try {
- File file = new File(path);
- if (!file.exists()) {
- boolean result = file.mkdirs();
- if (!result) {
- }
- }
-
- long totalSpace = file.getTotalSpace();
- long freeSpace = file.getFreeSpace();
- long usedSpace = totalSpace - freeSpace;
- if (totalSpace > 0) {
- return usedSpace / (double) totalSpace;
- }
- } catch (Exception e) {
- return -1;
- }
-
- return -1;
- }
-
-
- public static final int crc32(byte[] array) {
- if (array != null) {
- return crc32(array, 0, array.length);
- }
-
- return 0;
- }
-
-
- public static final int crc32(byte[] array, int offset, int length) {
- CRC32 crc32 = new CRC32();
- crc32.update(array, offset, length);
- return (int) (crc32.getValue() & 0x7FFFFFFF);
- }
-
- final static char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
-
- public static String bytes2string(byte[] src) {
- char[] hexChars = new char[src.length * 2];
- for (int j = 0; j < src.length; j++) {
- int v = src[j] & 0xFF;
- hexChars[j * 2] = HEX_ARRAY[v >>> 4];
- hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
- }
- return new String(hexChars);
- }
-
- public static byte[] string2bytes(String hexString) {
- if (hexString == null || hexString.equals("")) {
- return null;
- }
- hexString = hexString.toUpperCase();
- int length = hexString.length() / 2;
- char[] hexChars = hexString.toCharArray();
- byte[] d = new byte[length];
- for (int i = 0; i < length; i++) {
- int pos = i * 2;
- d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
- }
- return d;
- }
-
-
- private static byte charToByte(char c) {
- return (byte) "0123456789ABCDEF".indexOf(c);
- }
-
-
- public static byte[] uncompress(final byte[] src) throws IOException {
- byte[] result = src;
- byte[] uncompressData = new byte[src.length];
- ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(src);
- InflaterInputStream inflaterInputStream = new InflaterInputStream(byteArrayInputStream);
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(src.length);
-
- try {
- while (true) {
- int len = inflaterInputStream.read(uncompressData, 0, uncompressData.length);
- if (len <= 0) {
- break;
- }
- byteArrayOutputStream.write(uncompressData, 0, len);
- }
- byteArrayOutputStream.flush();
- result = byteArrayOutputStream.toByteArray();
- } catch (IOException e) {
- throw e;
- } finally {
- try {
- byteArrayInputStream.close();
- } catch (IOException e) {
- }
- try {
- inflaterInputStream.close();
- } catch (IOException e) {
- }
- try {
- byteArrayOutputStream.close();
- } catch (IOException e) {
- }
- }
-
- return result;
- }
-
-
- public static byte[] compress(final byte[] src, final int level) throws IOException {
- byte[] result = src;
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(src.length);
- java.util.zip.Deflater defeater = new java.util.zip.Deflater(level);
- DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(byteArrayOutputStream, defeater);
- try {
- deflaterOutputStream.write(src);
- deflaterOutputStream.finish();
- deflaterOutputStream.close();
- result = byteArrayOutputStream.toByteArray();
- } catch (IOException e) {
- defeater.end();
- throw e;
- } finally {
- try {
- byteArrayOutputStream.close();
- } catch (IOException ignored) {
- }
-
- defeater.end();
- }
-
- return result;
- }
-
-
- public static int asInt(String str, int defaultValue) {
- try {
- return Integer.parseInt(str);
- } catch (Exception e) {
- return defaultValue;
- }
- }
-
-
- public static long asLong(String str, long defaultValue) {
- try {
- return Long.parseLong(str);
- } catch (Exception e) {
- return defaultValue;
- }
- }
-
-
- public static String formatDate(Date date, String pattern) {
- SimpleDateFormat df = new SimpleDateFormat(pattern);
- return df.format(date);
- }
-
-
- public static Date parseDate(String date, String pattern) {
- SimpleDateFormat df = new SimpleDateFormat(pattern);
- try {
- return df.parse(date);
- } catch (ParseException e) {
- return null;
- }
- }
-
-
- public static String responseCode2String(final int code) {
- return Integer.toString(code);
- }
-
-
- public static String frontStringAtLeast(final String str, final int size) {
- if (str != null) {
- if (str.length() > size) {
- return str.substring(0, size);
- }
- }
-
- return str;
- }
-
-
- public static boolean isBlank(String str) {
- int strLen;
- if (str == null || (strLen = str.length()) == 0) {
- return true;
- }
- for (int i = 0; i < strLen; i++) {
- if (!Character.isWhitespace(str.charAt(i))) {
- return false;
- }
- }
- return true;
- }
-
-
- public static String jstack() {
- return jstack(Thread.getAllStackTraces());
- }
-
-
- public static String jstack(Map<Thread, StackTraceElement[]> map) {
- StringBuilder result = new StringBuilder();
- try {
- Iterator<Map.Entry<Thread, StackTraceElement[]>> ite = map.entrySet().iterator();
- while (ite.hasNext()) {
- Map.Entry<Thread, StackTraceElement[]> entry = ite.next();
- StackTraceElement[] elements = entry.getValue();
- Thread thread = entry.getKey();
- if (elements != null && elements.length > 0) {
- String threadName = entry.getKey().getName();
- result.append(String.format("%-40sTID: %d STATE: %s%n", threadName, thread.getId(), thread.getState()));
- for (StackTraceElement el : elements) {
- result.append(String.format("%-40s%s%n", threadName, el.toString()));
- }
- result.append("\n");
- }
- }
- } catch (Throwable e) {
- result.append(RemotingHelper.exceptionSimpleDesc(e));
- }
-
- return result.toString();
- }
-
- public static boolean isInternalIP(byte[] ip) {
- if (ip.length != 4) {
- throw new RuntimeException("illegal ipv4 bytes");
- }
-
-
- //10.0.0.0~10.255.255.255
- //172.16.0.0~172.31.255.255
- //192.168.0.0~192.168.255.255
- if (ip[0] == (byte) 10) {
-
- return true;
- } else if (ip[0] == (byte) 172) {
- if (ip[1] >= (byte) 16 && ip[1] <= (byte) 31) {
- return true;
- }
- } else if (ip[0] == (byte) 192) {
- if (ip[1] == (byte) 168) {
- return true;
- }
- }
- return false;
- }
-
- private static boolean ipCheck(byte[] ip) {
- if (ip.length != 4) {
- throw new RuntimeException("illegal ipv4 bytes");
- }
-
-// if (ip[0] == (byte)30 && ip[1] == (byte)10 && ip[2] == (byte)163 && ip[3] == (byte)120) {
-// }
-
-
- if (ip[0] >= (byte) 1 && ip[0] <= (byte) 126) {
- if (ip[1] == (byte) 1 && ip[2] == (byte) 1 && ip[3] == (byte) 1) {
- return false;
- }
- if (ip[1] == (byte) 0 && ip[2] == (byte) 0 && ip[3] == (byte) 0) {
- return false;
- }
- return true;
- } else if (ip[0] >= (byte) 128 && ip[0] <= (byte) 191) {
- if (ip[2] == (byte) 1 && ip[3] == (byte) 1) {
- return false;
- }
- if (ip[2] == (byte) 0 && ip[3] == (byte) 0) {
- return false;
- }
- return true;
- } else if (ip[0] >= (byte) 192 && ip[0] <= (byte) 223) {
- if (ip[3] == (byte) 1) {
- return false;
- }
- if (ip[3] == (byte) 0) {
- return false;
- }
- return true;
- }
- return false;
- }
-
- public static String ipToIPv4Str(byte[] ip) {
- if (ip.length != 4) {
- return null;
- }
- return new StringBuilder().append(ip[0] & 0xFF).append(".").append(
- ip[1] & 0xFF).append(".").append(ip[2] & 0xFF)
- .append(".").append(ip[3] & 0xFF).toString();
- }
-
- public static byte[] getIP() {
- try {
- Enumeration allNetInterfaces = NetworkInterface.getNetworkInterfaces();
- InetAddress ip = null;
- byte[] internalIP = null;
- while (allNetInterfaces.hasMoreElements()) {
- NetworkInterface netInterface = (NetworkInterface) allNetInterfaces.nextElement();
- Enumeration addresses = netInterface.getInetAddresses();
- while (addresses.hasMoreElements()) {
- ip = (InetAddress) addresses.nextElement();
- if (ip != null && ip instanceof Inet4Address) {
- byte[] ipByte = ip.getAddress();
- if (ipByte.length == 4) {
- if (ipCheck(ipByte)) {
- if (!isInternalIP(ipByte)) {
- return ipByte;
- } else if (internalIP == null) {
- internalIP = ipByte;
- }
- }
- }
- }
- }
- }
- if (internalIP != null) {
- return internalIP;
- } else {
- throw new RuntimeException("Can not get local ip");
- }
- } catch (Exception e) {
- throw new RuntimeException("Can not get local ip", e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/admin/ConsumeStats.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/admin/ConsumeStats.java b/common/src/main/java/com/alibaba/rocketmq/common/admin/ConsumeStats.java
deleted file mode 100644
index d8c9311..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/admin/ConsumeStats.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * 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.common.admin;
-
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-
-
-/**
- *
- * @author shijia.wxr
- *
- */
-public class ConsumeStats extends RemotingSerializable {
- private HashMap<MessageQueue, OffsetWrapper> offsetTable = new HashMap<MessageQueue, OffsetWrapper>();
- private double consumeTps = 0;
-
-
- public long computeTotalDiff() {
- long diffTotal = 0L;
-
- Iterator<Entry<MessageQueue, OffsetWrapper>> it = this.offsetTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<MessageQueue, OffsetWrapper> next = it.next();
- long diff = next.getValue().getBrokerOffset() - next.getValue().getConsumerOffset();
- diffTotal += diff;
- }
-
- return diffTotal;
- }
-
-
- public HashMap<MessageQueue, OffsetWrapper> getOffsetTable() {
- return offsetTable;
- }
-
-
- public void setOffsetTable(HashMap<MessageQueue, OffsetWrapper> offsetTable) {
- this.offsetTable = offsetTable;
- }
-
- public double getConsumeTps() {
- return consumeTps;
- }
-
- public void setConsumeTps(double consumeTps) {
- this.consumeTps = consumeTps;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/admin/OffsetWrapper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/admin/OffsetWrapper.java b/common/src/main/java/com/alibaba/rocketmq/common/admin/OffsetWrapper.java
deleted file mode 100644
index 07785c2..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/admin/OffsetWrapper.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * 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.common.admin;
-
-/**
- *
- * @author shijia.wxr
- *
- */
-public class OffsetWrapper {
- private long brokerOffset;
- private long consumerOffset;
-
- private long lastTimestamp;
-
-
- public long getBrokerOffset() {
- return brokerOffset;
- }
-
-
- public void setBrokerOffset(long brokerOffset) {
- this.brokerOffset = brokerOffset;
- }
-
-
- public long getConsumerOffset() {
- return consumerOffset;
- }
-
-
- public void setConsumerOffset(long consumerOffset) {
- this.consumerOffset = consumerOffset;
- }
-
-
- public long getLastTimestamp() {
- return lastTimestamp;
- }
-
-
- public void setLastTimestamp(long lastTimestamp) {
- this.lastTimestamp = lastTimestamp;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/admin/RollbackStats.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/admin/RollbackStats.java b/common/src/main/java/com/alibaba/rocketmq/common/admin/RollbackStats.java
deleted file mode 100644
index 03d94a2..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/admin/RollbackStats.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * 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.common.admin;
-
-/**
- *
- * @author manhong.yqd
- */
-public class RollbackStats {
- private String brokerName;
- private long queueId;
- private long brokerOffset;
- private long consumerOffset;
- private long timestampOffset;
- private long rollbackOffset;
-
-
- public String getBrokerName() {
- return brokerName;
- }
-
-
- public void setBrokerName(String brokerName) {
- this.brokerName = brokerName;
- }
-
-
- public long getQueueId() {
- return queueId;
- }
-
-
- public void setQueueId(long queueId) {
- this.queueId = queueId;
- }
-
-
- public long getBrokerOffset() {
- return brokerOffset;
- }
-
-
- public void setBrokerOffset(long brokerOffset) {
- this.brokerOffset = brokerOffset;
- }
-
-
- public long getConsumerOffset() {
- return consumerOffset;
- }
-
-
- public void setConsumerOffset(long consumerOffset) {
- this.consumerOffset = consumerOffset;
- }
-
-
- public long getTimestampOffset() {
- return timestampOffset;
- }
-
-
- public void setTimestampOffset(long timestampOffset) {
- this.timestampOffset = timestampOffset;
- }
-
-
- public long getRollbackOffset() {
- return rollbackOffset;
- }
-
-
- public void setRollbackOffset(long rollbackOffset) {
- this.rollbackOffset = rollbackOffset;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/admin/TopicOffset.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/admin/TopicOffset.java b/common/src/main/java/com/alibaba/rocketmq/common/admin/TopicOffset.java
deleted file mode 100644
index 076d6eb..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/admin/TopicOffset.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * 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.common.admin;
-
-/**
- *
- * @author shijia.wxr
- *
- */
-public class TopicOffset {
- private long minOffset;
- private long maxOffset;
- private long lastUpdateTimestamp;
-
-
- public long getMinOffset() {
- return minOffset;
- }
-
-
- public void setMinOffset(long minOffset) {
- this.minOffset = minOffset;
- }
-
-
- public long getMaxOffset() {
- return maxOffset;
- }
-
-
- public void setMaxOffset(long maxOffset) {
- this.maxOffset = maxOffset;
- }
-
-
- public long getLastUpdateTimestamp() {
- return lastUpdateTimestamp;
- }
-
-
- public void setLastUpdateTimestamp(long lastUpdateTimestamp) {
- this.lastUpdateTimestamp = lastUpdateTimestamp;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/admin/TopicStatsTable.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/admin/TopicStatsTable.java b/common/src/main/java/com/alibaba/rocketmq/common/admin/TopicStatsTable.java
deleted file mode 100644
index 12d1d4b..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/admin/TopicStatsTable.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * 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.common.admin;
-
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.HashMap;
-
-
-/**
- *
- * @author shijia.wxr
- *
- */
-public class TopicStatsTable extends RemotingSerializable {
- private HashMap<MessageQueue, TopicOffset> offsetTable = new HashMap<MessageQueue, TopicOffset>();
-
-
- public HashMap<MessageQueue, TopicOffset> getOffsetTable() {
- return offsetTable;
- }
-
-
- public void setOffsetTable(HashMap<MessageQueue, TopicOffset> offsetTable) {
- this.offsetTable = offsetTable;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/annotation/ImportantField.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/annotation/ImportantField.java b/common/src/main/java/com/alibaba/rocketmq/common/annotation/ImportantField.java
deleted file mode 100644
index fe0cb12..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/annotation/ImportantField.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 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.common.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE})
-public @interface ImportantField {
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/constant/DBMsgConstants.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/constant/DBMsgConstants.java b/common/src/main/java/com/alibaba/rocketmq/common/constant/DBMsgConstants.java
deleted file mode 100644
index 54bc04d..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/constant/DBMsgConstants.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * 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.common.constant;
-
-public class DBMsgConstants {
- public static final int MAX_BODY_SIZE = 64 * 1024 * 1204; //64KB
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/constant/LoggerName.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/constant/LoggerName.java b/common/src/main/java/com/alibaba/rocketmq/common/constant/LoggerName.java
deleted file mode 100644
index 9175669..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/constant/LoggerName.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.common.constant;
-
-/**
- * @author shijia.wxr
- */
-public class LoggerName {
- public static final String FILTERSRV_LOGGER_NAME = "RocketmqFiltersrv";
- public static final String NAMESRV_LOGGER_NAME = "RocketmqNamesrv";
- public static final String BROKER_LOGGER_NAME = "RocketmqBroker";
- public static final String CLIENT_LOGGER_NAME = "RocketmqClient";
- public static final String TOOLS_LOGGER_NAME = "RocketmqTools";
- public static final String COMMON_LOGGER_NAME = "RocketmqCommon";
- public static final String STORE_LOGGER_NAME = "RocketmqStore";
- public static final String STORE_ERROR_LOGGER_NAME = "RocketmqStoreError";
- public static final String TRANSACTION_LOGGER_NAME = "RocketmqTransaction";
- public static final String REBALANCE_LOCK_LOGGER_NAME = "RocketmqRebalanceLock";
- public static final String ROCKETMQ_STATS_LOGGER_NAME = "RocketmqStats";
- public static final String COMMERCIAL_LOGGER_NAME = "RocketmqCommercial";
- public static final String FLOW_CONTROL_LOGGER_NAME = "RocketmqFlowControl";
- public static final String ROCKETMQ_AUTHORIZE_LOGGER_NAME = "RocketmqAuthorize";
- public static final String DUPLICATION_LOGGER_NAME = "RocketmqDuplication";
- public static final String PROTECTION_LOGGER_NAME = "RocketmqProtection";
- public static final String WATER_MARK_LOGGER_NAME = "RocketmqWaterMark";
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/constant/PermName.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/constant/PermName.java b/common/src/main/java/com/alibaba/rocketmq/common/constant/PermName.java
deleted file mode 100644
index 95c2510..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/constant/PermName.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * 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.common.constant;
-
-/**
- * @author shijia.wxr
- */
-public class PermName {
- public static final int PERM_PRIORITY = 0x1 << 3;
- public static final int PERM_READ = 0x1 << 2;
- public static final int PERM_WRITE = 0x1 << 1;
- public static final int PERM_INHERIT = 0x1 << 0;
-
- public static String perm2String(final int perm) {
- final StringBuffer sb = new StringBuffer("---");
- if (isReadable(perm)) {
- sb.replace(0, 1, "R");
- }
-
- if (isWriteable(perm)) {
- sb.replace(1, 2, "W");
- }
-
- if (isInherited(perm)) {
- sb.replace(2, 3, "X");
- }
-
- return sb.toString();
- }
-
- public static boolean isReadable(final int perm) {
- return (perm & PERM_READ) == PERM_READ;
- }
-
- public static boolean isWriteable(final int perm) {
- return (perm & PERM_WRITE) == PERM_WRITE;
- }
-
- public static boolean isInherited(final int perm) {
- return (perm & PERM_INHERIT) == PERM_INHERIT;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/consumer/ConsumeFromWhere.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/consumer/ConsumeFromWhere.java b/common/src/main/java/com/alibaba/rocketmq/common/consumer/ConsumeFromWhere.java
deleted file mode 100644
index ededc90..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/consumer/ConsumeFromWhere.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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.common.consumer;
-
-/**
- *
- * @author shijia.wxr
- */
-public enum ConsumeFromWhere {
- CONSUME_FROM_LAST_OFFSET,
-
- @Deprecated
- CONSUME_FROM_LAST_OFFSET_AND_FROM_MIN_WHEN_BOOT_FIRST,
- @Deprecated
- CONSUME_FROM_MIN_OFFSET,
- @Deprecated
- CONSUME_FROM_MAX_OFFSET,
- CONSUME_FROM_FIRST_OFFSET,
- CONSUME_FROM_TIMESTAMP,
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/filter/FilterAPI.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/filter/FilterAPI.java b/common/src/main/java/com/alibaba/rocketmq/common/filter/FilterAPI.java
deleted file mode 100644
index 2b26b83..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/filter/FilterAPI.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * 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.common.filter;
-
-import com.alibaba.rocketmq.common.protocol.heartbeat.SubscriptionData;
-
-import java.net.URL;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class FilterAPI {
- public static URL classFile(final String className) {
- final String javaSource = simpleClassName(className) + ".java";
- URL url = FilterAPI.class.getClassLoader().getResource(javaSource);
- return url;
- }
-
- public static String simpleClassName(final String className) {
- String simple = className;
- int index = className.lastIndexOf(".");
- if (index >= 0) {
- simple = className.substring(index + 1);
- }
-
- return simple;
- }
-
- public static SubscriptionData buildSubscriptionData(final String consumerGroup, String topic,
- String subString) throws Exception {
- SubscriptionData subscriptionData = new SubscriptionData();
- subscriptionData.setTopic(topic);
- subscriptionData.setSubString(subString);
-
- if (null == subString || subString.equals(SubscriptionData.SUB_ALL) || subString.length() == 0) {
- subscriptionData.setSubString(SubscriptionData.SUB_ALL);
- } else {
- String[] tags = subString.split("\\|\\|");
- if (tags != null && tags.length > 0) {
- for (String tag : tags) {
- if (tag.length() > 0) {
- String trimString = tag.trim();
- if (trimString.length() > 0) {
- subscriptionData.getTagsSet().add(trimString);
- subscriptionData.getCodeSet().add(trimString.hashCode());
- }
- }
- }
- } else {
- throw new Exception("subString split error");
- }
- }
-
- return subscriptionData;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/filter/FilterContext.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/filter/FilterContext.java b/common/src/main/java/com/alibaba/rocketmq/common/filter/FilterContext.java
deleted file mode 100644
index 50cc5fc..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/filter/FilterContext.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * 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.common.filter;
-
-public class FilterContext {
- private String consumerGroup;
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/filter/MessageFilter.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/filter/MessageFilter.java b/common/src/main/java/com/alibaba/rocketmq/common/filter/MessageFilter.java
deleted file mode 100644
index 8a1252e..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/filter/MessageFilter.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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.common.filter;
-
-import com.alibaba.rocketmq.common.message.MessageExt;
-
-
-public interface MessageFilter {
- boolean match(final MessageExt msg, final FilterContext context);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/Op.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/Op.java b/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/Op.java
deleted file mode 100644
index f83a5f5..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/Op.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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.common.filter.impl;
-
-public abstract class Op {
-
- private String symbol;
-
-
- protected Op(String symbol) {
- this.symbol = symbol;
- }
-
-
- public String getSymbol() {
- return symbol;
- }
-
-
- public String toString() {
- return symbol;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/Operand.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/Operand.java b/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/Operand.java
deleted file mode 100644
index 95ca663..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/Operand.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * 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.common.filter.impl;
-
-public class Operand extends Op {
-
- public Operand(String symbol) {
- super(symbol);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/Operator.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/Operator.java b/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/Operator.java
deleted file mode 100644
index c906d72..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/Operator.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * 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.common.filter.impl;
-
-public class Operator extends Op {
-
- public static final Operator LEFTPARENTHESIS = new Operator("(", 30, false);
- public static final Operator RIGHTPARENTHESIS = new Operator(")", 30, false);
- public static final Operator AND = new Operator("&&", 20, true);
- public static final Operator OR = new Operator("||", 15, true);
-
- private int priority;
- private boolean compareable;
-
-
- private Operator(String symbol, int priority, boolean compareable) {
- super(symbol);
- this.priority = priority;
- this.compareable = compareable;
- }
-
- public static Operator createOperator(String operator) {
- if (LEFTPARENTHESIS.getSymbol().equals(operator))
- return LEFTPARENTHESIS;
- else if (RIGHTPARENTHESIS.getSymbol().equals(operator))
- return RIGHTPARENTHESIS;
- else if (AND.getSymbol().equals(operator))
- return AND;
- else if (OR.getSymbol().equals(operator))
- return OR;
- else
- throw new IllegalArgumentException("unsupport operator " + operator);
- }
-
- public int getPriority() {
- return priority;
- }
-
- public boolean isCompareable() {
- return compareable;
- }
-
-
- public int compare(Operator operator) {
- if (this.priority > operator.priority)
- return 1;
- else if (this.priority == operator.priority)
- return 0;
- else
- return -1;
- }
-
- public boolean isSpecifiedOp(String operator) {
- return this.getSymbol().equals(operator);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/PolishExpr.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/PolishExpr.java b/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/PolishExpr.java
deleted file mode 100644
index 518c45e..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/PolishExpr.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/**
- * 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.common.filter.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Stack;
-
-import static com.alibaba.rocketmq.common.filter.impl.Operator.LEFTPARENTHESIS;
-import static com.alibaba.rocketmq.common.filter.impl.Operator.RIGHTPARENTHESIS;
-import static com.alibaba.rocketmq.common.filter.impl.Operator.createOperator;
-
-public class PolishExpr {
-
- public static List<Op> reversePolish(String expression) {
- return reversePolish(participle(expression));
- }
-
- /**
- * Shunting-yard algorithm <br/>
- * http://en.wikipedia.org/wiki/Shunting_yard_algorithm
- *
- * @param tokens
- * @return the compute result of Shunting-yard algorithm
- */
- public static List<Op> reversePolish(List<Op> tokens) {
- List<Op> segments = new ArrayList<Op>();
- Stack<Operator> operatorStack = new Stack<Operator>();
-
- for (int i = 0; i < tokens.size(); i++) {
- Op token = tokens.get(i);
- if (isOperand(token)) {
-
- segments.add(token);
- } else if (isLeftParenthesis(token)) {
-
- operatorStack.push((Operator) token);
- } else if (isRightParenthesis(token)) {
-
- Operator opNew = null;
- while (!operatorStack.empty() && LEFTPARENTHESIS != (opNew = operatorStack.pop())) {
- segments.add(opNew);
- }
- if (null == opNew || LEFTPARENTHESIS != opNew)
- throw new IllegalArgumentException("mismatched parentheses");
- } else if (isOperator(token)) {
-
- Operator opNew = (Operator) token;
- if (!operatorStack.empty()) {
- Operator opOld = operatorStack.peek();
- if (opOld.isCompareable() && opNew.compare(opOld) != 1) {
- segments.add(operatorStack.pop());
- }
- }
- operatorStack.push(opNew);
- } else
- throw new IllegalArgumentException("illegal token " + token);
- }
-
- while (!operatorStack.empty()) {
- Operator operator = operatorStack.pop();
- if (LEFTPARENTHESIS == operator || RIGHTPARENTHESIS == operator)
- throw new IllegalArgumentException("mismatched parentheses " + operator);
- segments.add(operator);
- }
-
- return segments;
- }
-
- /**
- *
- * @param expression
- *
- * @return
- *
- * @throws Exception
- */
- private static List<Op> participle(String expression) {
- List<Op> segments = new ArrayList<Op>();
-
- int size = expression.length();
- int wordStartIndex = -1;
- int wordLen = 0;
- Type preType = Type.NULL;
-
- for (int i = 0; i < size; i++) {
- int chValue = (int) expression.charAt(i);
-
- if ((97 <= chValue && chValue <= 122) || (65 <= chValue && chValue <= 90)
- || (49 <= chValue && chValue <= 57) || 95 == chValue) {
-
-
- if (Type.OPERATOR == preType || Type.SEPAERATOR == preType || Type.NULL == preType
- || Type.PARENTHESIS == preType) {
- if (Type.OPERATOR == preType) {
- segments.add(createOperator(expression.substring(wordStartIndex, wordStartIndex
- + wordLen)));
- }
- wordStartIndex = i;
- wordLen = 0;
- }
- preType = Type.OPERAND;
- wordLen++;
- } else if (40 == chValue || 41 == chValue) {
-
-
- if (Type.OPERATOR == preType) {
- segments.add(createOperator(expression
- .substring(wordStartIndex, wordStartIndex + wordLen)));
- wordStartIndex = -1;
- wordLen = 0;
- } else if (Type.OPERAND == preType) {
- segments.add(new Operand(expression.substring(wordStartIndex, wordStartIndex + wordLen)));
- wordStartIndex = -1;
- wordLen = 0;
- }
-
- preType = Type.PARENTHESIS;
- segments.add(createOperator((char) chValue + ""));
- } else if (38 == chValue || 124 == chValue) {
-
- if (Type.OPERAND == preType || Type.SEPAERATOR == preType || Type.PARENTHESIS == preType) {
- if (Type.OPERAND == preType) {
- segments.add(new Operand(expression.substring(wordStartIndex, wordStartIndex
- + wordLen)));
- }
- wordStartIndex = i;
- wordLen = 0;
- }
- preType = Type.OPERATOR;
- wordLen++;
- } else if (32 == chValue || 9 == chValue) {
-
-
- if (Type.OPERATOR == preType) {
- segments.add(createOperator(expression
- .substring(wordStartIndex, wordStartIndex + wordLen)));
- wordStartIndex = -1;
- wordLen = 0;
- } else if (Type.OPERAND == preType) {
- segments.add(new Operand(expression.substring(wordStartIndex, wordStartIndex + wordLen)));
- wordStartIndex = -1;
- wordLen = 0;
- }
- preType = Type.SEPAERATOR;
- } else {
-
- throw new IllegalArgumentException("illegal expression, at index " + i + " " + (char) chValue);
- }
-
- }
-
- if (wordLen > 0) {
- segments.add(new Operand(expression.substring(wordStartIndex, wordStartIndex + wordLen)));
- }
- return segments;
- }
-
- public static boolean isOperand(Op token) {
- return token instanceof Operand;
- }
-
- public static boolean isLeftParenthesis(Op token) {
- return token instanceof Operator && LEFTPARENTHESIS == (Operator) token;
- }
-
- public static boolean isRightParenthesis(Op token) {
- return token instanceof Operator && RIGHTPARENTHESIS == (Operator) token;
- }
-
- public static boolean isOperator(Op token) {
- return token instanceof Operator;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/Type.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/Type.java b/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/Type.java
deleted file mode 100644
index 1c0b343..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/filter/impl/Type.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * 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.common.filter.impl;
-
-public enum Type {
- NULL,
- OPERAND,
- OPERATOR,
- PARENTHESIS,
- SEPAERATOR;
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/help/FAQUrl.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/help/FAQUrl.java b/common/src/main/java/com/alibaba/rocketmq/common/help/FAQUrl.java
deleted file mode 100644
index 06a74a6..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/help/FAQUrl.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * 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.common.help;
-
-/**
- * @author shijia.wxr
- */
-public class FAQUrl {
-
- public static final String APPLY_TOPIC_URL = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&topic_not_exist";
-
-
- public static final String NAME_SERVER_ADDR_NOT_EXIST_URL = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&namesrv_not_exist";
-
-
- public static final String GROUP_NAME_DUPLICATE_URL = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&group_duplicate";
-
-
- public static final String CLIENT_PARAMETER_CHECK_URL = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions¶meter_check_failed";
-
-
- public static final String SUBSCRIPTION_GROUP_NOT_EXIST = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&subGroup_not_exist";
-
-
- public static final String CLIENT_SERVICE_NOT_OK = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&service_not_ok";
-
- // FAQ: No route info of this topic, TopicABC
- public static final String NO_TOPIC_ROUTE_INFO = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&topic_not_exist";
-
-
- public static final String LOAD_JSON_EXCEPTION = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&load_json_exception";
-
-
- public static final String SAME_GROUP_DIFFERENT_TOPIC = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&subscription_exception";
-
-
- public static final String MQLIST_NOT_EXIST = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&queue_not_exist";
-
- public static final String UNEXPECTED_EXCEPTION_URL = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&unexpected_exception";
-
-
- public static final String SEND_MSG_FAILED = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&send_msg_failed";
-
-
- public static final String UNKNOWN_HOST_EXCEPTION = //
- "http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&unknown_host";
-
- private static final String TIP_STRING_BEGIN = "\nSee ";
- private static final String TIP_STRING_END = " for further details.";
-
-
- public static String suggestTodo(final String url) {
- StringBuilder sb = new StringBuilder();
- sb.append(TIP_STRING_BEGIN);
- sb.append(url);
- sb.append(TIP_STRING_END);
- return sb.toString();
- }
-
- public static String attachDefaultURL(final String errorMessage) {
- if (errorMessage != null) {
- int index = errorMessage.indexOf(TIP_STRING_BEGIN);
- if (-1 == index) {
- StringBuilder sb = new StringBuilder();
- sb.append(errorMessage);
- sb.append("\n");
- sb.append("For more information, please visit the url, ");
- sb.append(UNEXPECTED_EXCEPTION_URL);
- return sb.toString();
- }
- }
-
- return errorMessage;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/hook/FilterCheckHook.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/hook/FilterCheckHook.java b/common/src/main/java/com/alibaba/rocketmq/common/hook/FilterCheckHook.java
deleted file mode 100644
index f5d9d7e..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/hook/FilterCheckHook.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * 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.common.hook;
-
-import java.nio.ByteBuffer;
-
-
-/**
- *
- * @author manhong.yqd
- *
- */
-public interface FilterCheckHook {
- public String hookName();
-
-
- public boolean isFilterMatched(final boolean isUnitMode, final ByteBuffer byteBuffer);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/message/Message.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/message/Message.java b/common/src/main/java/com/alibaba/rocketmq/common/message/Message.java
deleted file mode 100644
index eeb6f52..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/message/Message.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/**
- * 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.common.message;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- *
- * @author shijia.wxr
- *
- */
-public class Message implements Serializable {
- private static final long serialVersionUID = 8445773977080406428L;
-
- private String topic;
- private int flag;
- private Map<String, String> properties;
- private byte[] body;
-
-
- public Message() {
- }
-
-
- public Message(String topic, byte[] body) {
- this(topic, "", "", 0, body, true);
- }
-
-
- public Message(String topic, String tags, String keys, int flag, byte[] body, boolean waitStoreMsgOK) {
- this.topic = topic;
- this.flag = flag;
- this.body = body;
-
- if (tags != null && tags.length() > 0)
- this.setTags(tags);
-
- if (keys != null && keys.length() > 0)
- this.setKeys(keys);
-
- this.setWaitStoreMsgOK(waitStoreMsgOK);
- }
-
- public void setKeys(String keys) {
- this.putProperty(MessageConst.PROPERTY_KEYS, keys);
- }
-
- void putProperty(final String name, final String value) {
- if (null == this.properties) {
- this.properties = new HashMap<String, String>();
- }
-
- this.properties.put(name, value);
- }
-
-
- public Message(String topic, String tags, byte[] body) {
- this(topic, tags, "", 0, body, true);
- }
-
-
- public Message(String topic, String tags, String keys, byte[] body) {
- this(topic, tags, keys, 0, body, true);
- }
-
- void clearProperty(final String name) {
- if (null != this.properties) {
- this.properties.remove(name);
- }
- }
-
- public void putUserProperty(final String name, final String value) {
- if (MessageConst.STRING_HASH_SET.contains(name)) {
- throw new RuntimeException(String.format(
- "The Property<%s> is used by system, input another please", name));
- }
- this.putProperty(name, value);
- }
-
- public String getUserProperty(final String name) {
- return this.getProperty(name);
- }
-
- public String getProperty(final String name) {
- if (null == this.properties) {
- this.properties = new HashMap<String, String>();
- }
-
- return this.properties.get(name);
- }
-
- public String getTopic() {
- return topic;
- }
-
- public void setTopic(String topic) {
- this.topic = topic;
- }
-
- public String getTags() {
- return this.getProperty(MessageConst.PROPERTY_TAGS);
- }
-
- public void setTags(String tags) {
- this.putProperty(MessageConst.PROPERTY_TAGS, tags);
- }
-
- public String getKeys() {
- return this.getProperty(MessageConst.PROPERTY_KEYS);
- }
-
- public void setKeys(Collection<String> keys) {
- StringBuffer sb = new StringBuffer();
- for (String k : keys) {
- sb.append(k);
- sb.append(MessageConst.KEY_SEPARATOR);
- }
-
- this.setKeys(sb.toString().trim());
- }
-
-
- public int getDelayTimeLevel() {
- String t = this.getProperty(MessageConst.PROPERTY_DELAY_TIME_LEVEL);
- if (t != null) {
- return Integer.parseInt(t);
- }
-
- return 0;
- }
-
-
- public void setDelayTimeLevel(int level) {
- this.putProperty(MessageConst.PROPERTY_DELAY_TIME_LEVEL, String.valueOf(level));
- }
-
-
- public boolean isWaitStoreMsgOK() {
- String result = this.getProperty(MessageConst.PROPERTY_WAIT_STORE_MSG_OK);
- if (null == result)
- return true;
-
- return Boolean.parseBoolean(result);
- }
-
-
- public void setWaitStoreMsgOK(boolean waitStoreMsgOK) {
- this.putProperty(MessageConst.PROPERTY_WAIT_STORE_MSG_OK, Boolean.toString(waitStoreMsgOK));
- }
-
-
- public int getFlag() {
- return flag;
- }
-
-
- public void setFlag(int flag) {
- this.flag = flag;
- }
-
-
- public byte[] getBody() {
- return body;
- }
-
-
- public void setBody(byte[] body) {
- this.body = body;
- }
-
-
- public Map<String, String> getProperties() {
- return properties;
- }
-
-
- void setProperties(Map<String, String> properties) {
- this.properties = properties;
- }
-
- public String getBuyerId() {
- return getProperty(MessageConst.PROPERTY_BUYER_ID);
- }
-
- public void setBuyerId(String buyerId) {
- putProperty(MessageConst.PROPERTY_BUYER_ID, buyerId);
- }
-
- @Override
- public String toString() {
- return "Message [topic=" + topic + ", flag=" + flag + ", properties=" + properties + ", body="
- + (body != null ? body.length : 0) + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/message/MessageAccessor.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageAccessor.java b/common/src/main/java/com/alibaba/rocketmq/common/message/MessageAccessor.java
deleted file mode 100644
index bbbca1a..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageAccessor.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * 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.common.message;
-
-import java.util.Map;
-
-
-public class MessageAccessor {
-
- public static void clearProperty(final Message msg, final String name) {
- msg.clearProperty(name);
- }
-
- public static void setProperties(final Message msg, Map<String, String> properties) {
- msg.setProperties(properties);
- }
-
- public static void setTransferFlag(final Message msg, String unit) {
- putProperty(msg, MessageConst.PROPERTY_TRANSFER_FLAG, unit);
- }
-
- public static void putProperty(final Message msg, final String name, final String value) {
- msg.putProperty(name, value);
- }
-
- public static String getTransferFlag(final Message msg) {
- return msg.getProperty(MessageConst.PROPERTY_TRANSFER_FLAG);
- }
-
-
- public static void setCorrectionFlag(final Message msg, String unit) {
- putProperty(msg, MessageConst.PROPERTY_CORRECTION_FLAG, unit);
- }
-
-
- public static String getCorrectionFlag(final Message msg) {
- return msg.getProperty(MessageConst.PROPERTY_CORRECTION_FLAG);
- }
-
-
- public static void setOriginMessageId(final Message msg, String originMessageId) {
- putProperty(msg, MessageConst.PROPERTY_ORIGIN_MESSAGE_ID, originMessageId);
- }
-
-
- public static String getOriginMessageId(final Message msg) {
- return msg.getProperty(MessageConst.PROPERTY_ORIGIN_MESSAGE_ID);
- }
-
-
- public static void setMQ2Flag(final Message msg, String flag) {
- putProperty(msg, MessageConst.PROPERTY_MQ2_FLAG, flag);
- }
-
-
- public static String getMQ2Flag(final Message msg) {
- return msg.getProperty(MessageConst.PROPERTY_MQ2_FLAG);
- }
-
-
- public static void setReconsumeTime(final Message msg, String reconsumeTimes) {
- putProperty(msg, MessageConst.PROPERTY_RECONSUME_TIME, reconsumeTimes);
- }
-
-
- public static String getReconsumeTime(final Message msg) {
- return msg.getProperty(MessageConst.PROPERTY_RECONSUME_TIME);
- }
-
-
- public static void setMaxReconsumeTimes(final Message msg, String maxReconsumeTimes) {
- putProperty(msg, MessageConst.PROPERTY_MAX_RECONSUME_TIMES, maxReconsumeTimes);
- }
-
-
- public static String getMaxReconsumeTimes(final Message msg) {
- return msg.getProperty(MessageConst.PROPERTY_MAX_RECONSUME_TIMES);
- }
-
- public static void setConsumeStartTimeStamp(final Message msg, String propertyConsumeStartTimeStamp) {
- putProperty(msg, MessageConst.PROPERTY_CONSUME_START_TIMESTAMP, propertyConsumeStartTimeStamp);
- }
-
-
- public static String getConsumeStartTimeStamp(final Message msg) {
- return msg.getProperty(MessageConst.PROPERTY_CONSUME_START_TIMESTAMP);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/message/MessageClientExt.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageClientExt.java b/common/src/main/java/com/alibaba/rocketmq/common/message/MessageClientExt.java
deleted file mode 100644
index 0ab372e..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageClientExt.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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.common.message;
-
-public class MessageClientExt extends MessageExt {
-
- public void setOffsetMsgId(String offsetMsgId) {
- super.setMsgId(offsetMsgId);
- }
-
-
- public String getOffsetMsgId() {
- return super.getMsgId();
- }
-
- public void setMsgId(String msgId) {
- //DO NOTHING
- //MessageClientIDSetter.setUniqID(this);
- }
-
- @Override
- public String getMsgId() {
- String uniqID = MessageClientIDSetter.getUniqID(this);
- if (uniqID == null) {
- return this.getOffsetMsgId();
- }
- else {
- return uniqID;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/message/MessageClientIDSetter.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageClientIDSetter.java b/common/src/main/java/com/alibaba/rocketmq/common/message/MessageClientIDSetter.java
deleted file mode 100644
index 82cd3d1..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/message/MessageClientIDSetter.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.common.message;
-
-import com.alibaba.rocketmq.common.UtilAll;
-
-import java.nio.ByteBuffer;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class MessageClientIDSetter {
- private static final String TOPIC_KEY_SPLITTER = "#";
- private static final int LEN;
- private static final String FIX_STRING;
- private static final AtomicInteger COUNTER;
- private static long startTime;
- private static long nextStartTime;
-
- static {
- LEN = 4 + 2 + 4 + 4 + 2;
- ByteBuffer tempBuffer = ByteBuffer.allocate(10);
- tempBuffer.position(2);
- tempBuffer.putInt(UtilAll.getPid());
- tempBuffer.position(0);
- try {
- tempBuffer.put(UtilAll.getIP());
- } catch (Exception e) {
- tempBuffer.put(createFakeIP());
- }
- tempBuffer.position(6);
- tempBuffer.putInt(MessageClientIDSetter.class.getClassLoader().hashCode()); //4
- FIX_STRING = UtilAll.bytes2string(tempBuffer.array());
- setStartTime(System.currentTimeMillis());
- COUNTER = new AtomicInteger(0);
- }
-
- private synchronized static void setStartTime(long millis) {
- Calendar cal = Calendar.getInstance();
- cal.setTimeInMillis(millis);
- cal.set(Calendar.DAY_OF_MONTH, 1);
- cal.set(Calendar.HOUR, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
- startTime = cal.getTimeInMillis();
- cal.add(Calendar.MONTH, 1);
- nextStartTime = cal.getTimeInMillis();
- }
-
- public static Date getNearlyTimeFromID(String msgID) {
- ByteBuffer buf = ByteBuffer.allocate(8);
- byte[] bytes = UtilAll.string2bytes(msgID);
- buf.put((byte) 0);
- buf.put((byte) 0);
- buf.put((byte) 0);
- buf.put((byte) 0);
- buf.put(bytes, 10, 4);
- buf.position(0);
- long spanMS = buf.getLong();
- Calendar cal = Calendar.getInstance();
- long now = cal.getTimeInMillis();
- cal.set(Calendar.DAY_OF_MONTH, 1);
- cal.set(Calendar.HOUR, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
- long monStartTime = cal.getTimeInMillis();
- if (monStartTime + spanMS >= now) {
- cal.add(Calendar.MONTH, -1);
- monStartTime = cal.getTimeInMillis();
- }
- cal.setTimeInMillis(monStartTime + spanMS);
- return cal.getTime();
- }
-
- public static String getIPStrFromID(String msgID) {
- byte[] ipBytes = getIPFromID(msgID);
- return UtilAll.ipToIPv4Str(ipBytes);
- }
-
- public static byte[] getIPFromID(String msgID) {
- byte[] result = new byte[4];
- byte[] bytes = UtilAll.string2bytes(msgID);
- System.arraycopy(bytes, 0, result, 0, 4);
- return result;
- }
-
- public static String createUniqID() {
- StringBuilder sb = new StringBuilder(LEN * 2);
- sb.append(FIX_STRING);
- sb.append(UtilAll.bytes2string(createUniqIDBuffer()));
- return sb.toString();
- }
-
-
- private static byte[] createUniqIDBuffer() {
- ByteBuffer buffer = ByteBuffer.allocate(4 + 2);
- long current = System.currentTimeMillis();
- if (current >= nextStartTime) {
- setStartTime(current);
- }
- buffer.position(0);
- buffer.putInt((int) (System.currentTimeMillis() - startTime));
- buffer.putShort((short) COUNTER.getAndIncrement());
- return buffer.array();
- }
-
- public static void setUniqID(final Message msg) {
- if (msg.getProperty(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX) == null) {
- msg.putProperty(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX, createUniqID());
- }
- }
-
- public static String getUniqID(final Message msg) {
- return msg.getProperty(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX);
- }
-
- public static byte[] createFakeIP() {
- ByteBuffer bb = ByteBuffer.allocate(8);
- bb.putLong(System.currentTimeMillis());
- bb.position(4);
- byte[] fakeIP = new byte[4];
- bb.get(fakeIP);
- return fakeIP;
- }
-}
-
[94/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
ROCKETMQ-18 Reformat all codes.
Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/commit/388ba7a5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/tree/388ba7a5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/diff/388ba7a5
Branch: refs/heads/master
Commit: 388ba7a58465245389a3592904b6fc7ef777dc7a
Parents: 95cfb8d
Author: yukon <yu...@apache.org>
Authored: Wed Dec 28 15:42:48 2016 +0800
Committer: yukon <yu...@apache.org>
Committed: Wed Dec 28 15:42:48 2016 +0800
----------------------------------------------------------------------
broker/pom.xml | 2 +-
.../rocketmq/broker/BrokerController.java | 155 +++--
.../rocketmq/broker/BrokerPathConfigHelper.java | 20 +-
.../apache/rocketmq/broker/BrokerStartup.java | 41 +-
.../broker/client/ClientChannelInfo.java | 32 +-
.../client/ClientHousekeepingService.java | 29 +-
.../broker/client/ConsumerGroupInfo.java | 73 +-
.../client/ConsumerIdsChangeListener.java | 14 +-
.../rocketmq/broker/client/ConsumerManager.java | 38 +-
.../DefaultConsumerIdsChangeListener.java | 18 +-
.../rocketmq/broker/client/ProducerManager.java | 54 +-
.../broker/client/net/Broker2Client.java | 96 ++-
.../client/rebalance/RebalanceLockManager.java | 107 ++-
.../broker/filtersrv/FilterServerManager.java | 36 +-
.../broker/filtersrv/FilterServerUtil.java | 13 +-
.../broker/latency/BrokerFastFailure.java | 44 +-
.../latency/BrokerFixedThreadPoolExecutor.java | 19 +-
.../broker/longpolling/ManyPullRequest.java | 18 +-
.../NotifyMessageArrivingListener.java | 15 +-
.../broker/longpolling/PullRequest.java | 23 +-
.../longpolling/PullRequestHoldService.java | 16 +-
.../broker/mqtrace/ConsumeMessageContext.java | 36 +-
.../broker/mqtrace/ConsumeMessageHook.java | 14 +-
.../broker/mqtrace/SendMessageContext.java | 43 +-
.../broker/mqtrace/SendMessageHook.java | 14 +-
.../broker/offset/ConsumerOffsetManager.java | 39 +-
.../rocketmq/broker/out/BrokerOuterAPI.java | 90 +--
.../broker/pagecache/ManyMessageTransfer.java | 18 +-
.../broker/pagecache/OneMessageTransfer.java | 18 +-
.../broker/pagecache/QueryMessageTransfer.java | 18 +-
.../plugin/AbstractPluginMessageStore.java | 28 +-
.../broker/plugin/MessageStoreFactory.java | 21 +-
.../plugin/MessageStorePluginContext.java | 17 +-
.../processor/AbstractSendMessageProcessor.java | 98 ++-
.../broker/processor/AdminBrokerProcessor.java | 237 ++++---
.../broker/processor/ClientManageProcessor.java | 61 +-
.../processor/ConsumerManageProcessor.java | 68 +-
.../processor/EndTransactionProcessor.java | 50 +-
.../processor/ForwardRequestProcessor.java | 17 +-
.../broker/processor/PullMessageProcessor.java | 100 ++-
.../broker/processor/QueryMessageProcessor.java | 61 +-
.../broker/processor/SendMessageProcessor.java | 80 +--
.../rocketmq/broker/slave/SlaveSynchronize.java | 54 +-
.../subscription/SubscriptionGroupManager.java | 29 +-
.../broker/topic/TopicConfigManager.java | 64 +-
.../broker/transaction/TransactionRecord.java | 16 +-
.../broker/transaction/TransactionStore.java | 20 +-
.../transaction/jdbc/JDBCTransactionStore.java | 34 +-
.../jdbc/JDBCTransactionStoreConfig.java | 20 +-
.../rocketmq/broker/BrokerControllerTest.java | 15 +-
.../rocketmq/broker/BrokerTestHarness.java | 22 +-
.../rocketmq/broker/api/SendMessageTest.java | 23 +-
.../offset/ConsumerOffsetManagerTest.java | 15 +-
.../broker/topic/TopicConfigManagerTest.java | 19 +-
checkstyle/checkstyle.xml | 8 +-
client/pom.xml | 2 +-
.../apache/rocketmq/client/ClientConfig.java | 35 +-
.../org/apache/rocketmq/client/MQAdmin.java | 33 +-
.../org/apache/rocketmq/client/MQHelper.java | 42 +-
.../org/apache/rocketmq/client/QueryResult.java | 22 +-
.../org/apache/rocketmq/client/Validators.java | 32 +-
.../rocketmq/client/admin/MQAdminExtInner.java | 12 +-
.../client/common/ThreadLocalIndex.java | 20 +-
.../consumer/AllocateMessageQueueStrategy.java | 27 +-
.../client/consumer/DefaultMQPullConsumer.java | 75 +--
.../client/consumer/DefaultMQPushConsumer.java | 81 +--
.../rocketmq/client/consumer/MQConsumer.java | 22 +-
.../client/consumer/MQPullConsumer.java | 52 +-
.../consumer/MQPullConsumerScheduleService.java | 36 +-
.../client/consumer/MQPushConsumer.java | 23 +-
.../client/consumer/MessageQueueListener.java | 18 +-
.../rocketmq/client/consumer/PullCallback.java | 12 +-
.../rocketmq/client/consumer/PullResult.java | 30 +-
.../rocketmq/client/consumer/PullStatus.java | 12 +-
.../client/consumer/PullTaskCallback.java | 13 +-
.../client/consumer/PullTaskContext.java | 16 +-
.../listener/ConsumeConcurrentlyContext.java | 7 -
.../listener/ConsumeConcurrentlyStatus.java | 12 +-
.../listener/ConsumeOrderlyContext.java | 19 +-
.../consumer/listener/ConsumeOrderlyStatus.java | 12 +-
.../consumer/listener/ConsumeReturnType.java | 12 +-
.../consumer/listener/MessageListener.java | 12 +-
.../listener/MessageListenerConcurrently.java | 18 +-
.../listener/MessageListenerOrderly.java | 18 +-
.../AllocateMessageQueueAveragely.java | 19 +-
.../AllocateMessageQueueAveragelyByCircle.java | 15 +-
.../rebalance/AllocateMessageQueueByConfig.java | 19 +-
.../AllocateMessageQueueByMachineRoom.java | 21 +-
.../consumer/store/LocalFileOffsetStore.java | 51 +-
.../consumer/store/OffsetSerializeWrapper.java | 20 +-
.../client/consumer/store/OffsetStore.java | 23 +-
.../client/consumer/store/ReadOffsetType.java | 12 +-
.../consumer/store/RemoteBrokerOffsetStore.java | 53 +-
.../client/exception/MQBrokerException.java | 18 +-
.../client/exception/MQClientException.java | 17 +-
.../client/hook/CheckForbiddenContext.java | 40 +-
.../client/hook/CheckForbiddenHook.java | 14 +-
.../client/hook/ConsumeMessageContext.java | 32 +-
.../client/hook/ConsumeMessageHook.java | 12 +-
.../client/hook/FilterMessageContext.java | 29 +-
.../rocketmq/client/hook/FilterMessageHook.java | 13 +-
.../client/hook/SendMessageContext.java | 35 +-
.../rocketmq/client/hook/SendMessageHook.java | 12 +-
.../client/impl/ClientRemotingProcessor.java | 56 +-
.../rocketmq/client/impl/CommunicationMode.java | 12 +-
.../rocketmq/client/impl/FindBrokerResult.java | 15 +-
.../rocketmq/client/impl/MQAdminImpl.java | 114 ++--
.../rocketmq/client/impl/MQClientAPIImpl.java | 667 ++++++++++---------
.../rocketmq/client/impl/MQClientManager.java | 26 +-
.../ConsumeMessageConcurrentlyService.java | 88 +--
.../consumer/ConsumeMessageOrderlyService.java | 135 ++--
.../impl/consumer/ConsumeMessageService.java | 31 +-
.../consumer/DefaultMQPullConsumerImpl.java | 193 +++---
.../consumer/DefaultMQPushConsumerImpl.java | 261 ++++----
.../client/impl/consumer/MQConsumerInner.java | 26 +-
.../client/impl/consumer/MessageQueueLock.java | 19 +-
.../client/impl/consumer/ProcessQueue.java | 57 +-
.../client/impl/consumer/PullAPIWrapper.java | 84 +--
.../impl/consumer/PullMessageService.java | 37 +-
.../client/impl/consumer/PullRequest.java | 23 +-
.../client/impl/consumer/PullResultExt.java | 22 +-
.../client/impl/consumer/RebalanceImpl.java | 75 +--
.../client/impl/consumer/RebalancePullImpl.java | 22 +-
.../client/impl/consumer/RebalancePushImpl.java | 32 +-
.../client/impl/consumer/RebalanceService.java | 18 +-
.../client/impl/factory/MQClientInstance.java | 234 ++++---
.../impl/producer/DefaultMQProducerImpl.java | 216 +++---
.../client/impl/producer/MQProducerInner.java | 27 +-
.../client/impl/producer/TopicPublishInfo.java | 17 +-
.../latency/LatencyFaultToleranceImpl.java | 52 +-
.../client/latency/MQFaultStrategy.java | 7 +-
.../rocketmq/client/log/ClientLogger.java | 25 +-
.../client/producer/DefaultMQProducer.java | 96 +--
.../producer/LocalTransactionExecuter.java | 13 +-
.../client/producer/LocalTransactionState.java | 12 +-
.../rocketmq/client/producer/MQProducer.java | 71 +-
.../client/producer/MessageQueueSelector.java | 16 +-
.../rocketmq/client/producer/SendCallback.java | 13 +-
.../rocketmq/client/producer/SendResult.java | 31 +-
.../rocketmq/client/producer/SendStatus.java | 12 +-
.../producer/TransactionCheckListener.java | 13 +-
.../client/producer/TransactionMQProducer.java | 27 +-
.../client/producer/TransactionSendResult.java | 15 +-
.../selector/SelectMessageQueueByHash.java | 16 +-
.../SelectMessageQueueByMachineRoom.java | 21 +-
.../selector/SelectMessageQueueByRandoom.java | 19 +-
.../client/stat/ConsumerStatsManager.java | 40 +-
.../main/resources/logback_rocketmq_client.xml | 2 +-
.../apache/rocketmq/client/ValidatorsTest.java | 13 +-
common/pom.xml | 2 +-
.../apache/rocketmq/common/BrokerConfig.java | 83 +--
.../rocketmq/common/BrokerConfigSingleton.java | 12 +-
.../apache/rocketmq/common/ConfigManager.java | 17 +-
.../apache/rocketmq/common/Configuration.java | 27 +-
.../apache/rocketmq/common/CountDownLatch2.java | 111 ++-
.../org/apache/rocketmq/common/DataVersion.java | 36 +-
.../org/apache/rocketmq/common/MQVersion.java | 2 -
.../java/org/apache/rocketmq/common/MixAll.java | 54 +-
.../java/org/apache/rocketmq/common/Pair.java | 17 +-
.../apache/rocketmq/common/ServiceState.java | 12 +-
.../apache/rocketmq/common/ServiceThread.java | 28 +-
.../org/apache/rocketmq/common/SystemClock.java | 12 +-
.../rocketmq/common/ThreadFactoryImpl.java | 15 +-
.../org/apache/rocketmq/common/TopicConfig.java | 68 +-
.../apache/rocketmq/common/TopicFilterType.java | 12 +-
.../org/apache/rocketmq/common/UtilAll.java | 114 ++--
.../rocketmq/common/admin/ConsumeStats.java | 21 +-
.../rocketmq/common/admin/OffsetWrapper.java | 18 +-
.../rocketmq/common/admin/RollbackStats.java | 24 +-
.../rocketmq/common/admin/TopicOffset.java | 18 +-
.../rocketmq/common/admin/TopicStatsTable.java | 18 +-
.../common/constant/DBMsgConstants.java | 12 +-
.../rocketmq/common/constant/LoggerName.java | 12 +-
.../rocketmq/common/constant/PermName.java | 12 +-
.../common/consumer/ConsumeFromWhere.java | 12 +-
.../rocketmq/common/filter/FilterAPI.java | 18 +-
.../rocketmq/common/filter/FilterContext.java | 14 +-
.../rocketmq/common/filter/MessageFilter.java | 1 -
.../apache/rocketmq/common/filter/impl/Op.java | 15 +-
.../rocketmq/common/filter/impl/Operand.java | 12 +-
.../rocketmq/common/filter/impl/Operator.java | 14 +-
.../rocketmq/common/filter/impl/PolishExpr.java | 41 +-
.../rocketmq/common/filter/impl/Type.java | 12 +-
.../org/apache/rocketmq/common/help/FAQUrl.java | 49 +-
.../rocketmq/common/hook/FilterCheckHook.java | 14 +-
.../apache/rocketmq/common/message/Message.java | 48 +-
.../common/message/MessageAccessor.java | 24 +-
.../common/message/MessageClientExt.java | 34 +-
.../common/message/MessageClientIDSetter.java | 16 +-
.../rocketmq/common/message/MessageConst.java | 2 -
.../rocketmq/common/message/MessageDecoder.java | 71 +-
.../rocketmq/common/message/MessageExt.java | 58 +-
.../rocketmq/common/message/MessageId.java | 18 +-
.../rocketmq/common/message/MessageQueue.java | 27 +-
.../common/message/MessageQueueForC.java | 30 +-
.../rocketmq/common/message/MessageType.java | 12 +-
.../rocketmq/common/namesrv/NamesrvConfig.java | 25 +-
.../rocketmq/common/namesrv/NamesrvUtil.java | 12 +-
.../common/namesrv/RegisterBrokerResult.java | 19 +-
.../rocketmq/common/namesrv/TopAddressing.java | 53 +-
.../common/protocol/MQProtosHelper.java | 17 +-
.../rocketmq/common/protocol/RequestCode.java | 16 +-
.../rocketmq/common/protocol/ResponseCode.java | 17 +-
.../common/protocol/body/BrokerStatsData.java | 19 +-
.../common/protocol/body/BrokerStatsItem.java | 18 +-
.../rocketmq/common/protocol/body/CMResult.java | 12 +-
.../common/protocol/body/ClusterInfo.java | 28 +-
.../common/protocol/body/Connection.java | 21 +-
.../common/protocol/body/ConsumeByWho.java | 26 +-
.../body/ConsumeMessageDirectlyResult.java | 28 +-
.../common/protocol/body/ConsumeStatsList.java | 18 +-
.../common/protocol/body/ConsumeStatus.java | 24 +-
.../protocol/body/ConsumerConnection.java | 31 +-
.../body/ConsumerOffsetSerializeWrapper.java | 20 +-
.../protocol/body/ConsumerRunningInfo.java | 134 ++--
.../protocol/body/GetConsumerStatusBody.java | 24 +-
.../common/protocol/body/GroupList.java | 18 +-
.../rocketmq/common/protocol/body/KVTable.java | 18 +-
.../protocol/body/LockBatchRequestBody.java | 24 +-
.../protocol/body/LockBatchResponseBody.java | 20 +-
.../common/protocol/body/ProcessQueueInfo.java | 54 +-
.../protocol/body/ProducerConnection.java | 18 +-
.../protocol/body/QueryConsumeTimeSpanBody.java | 18 +-
.../body/QueryCorrectionOffsetBody.java | 18 +-
.../common/protocol/body/QueueTimeSpan.java | 29 +-
.../protocol/body/RegisterBrokerBody.java | 20 +-
.../common/protocol/body/ResetOffsetBody.java | 18 +-
.../protocol/body/ResetOffsetBodyForC.java | 17 +-
.../protocol/body/SubscriptionGroupWrapper.java | 24 +-
.../body/TopicConfigSerializeWrapper.java | 22 +-
.../common/protocol/body/TopicList.java | 20 +-
.../protocol/body/UnlockBatchRequestBody.java | 24 +-
.../CheckTransactionStateRequestHeader.java | 20 +-
.../CheckTransactionStateResponseHeader.java | 24 +-
.../header/CloneGroupOffsetRequestHeader.java | 24 +-
...nsumeMessageDirectlyResultRequestHeader.java | 22 +-
.../ConsumerSendMsgBackRequestHeader.java | 31 +-
.../header/CreateTopicRequestHeader.java | 33 +-
.../DeleteSubscriptionGroupRequestHeader.java | 16 +-
.../header/DeleteTopicRequestHeader.java | 18 +-
.../header/EndTransactionRequestHeader.java | 33 +-
.../header/EndTransactionResponseHeader.java | 15 +-
.../header/GetAllTopicConfigResponseHeader.java | 15 +-
.../header/GetBrokerConfigResponseHeader.java | 18 +-
.../header/GetConsumeStatsInBrokerHeader.java | 13 +-
.../header/GetConsumeStatsRequestHeader.java | 18 +-
.../GetConsumerConnectionListRequestHeader.java | 16 +-
.../GetConsumerListByGroupRequestHeader.java | 16 +-
.../GetConsumerListByGroupResponseBody.java | 18 +-
.../GetConsumerListByGroupResponseHeader.java | 13 +-
.../GetConsumerRunningInfoRequestHeader.java | 20 +-
.../header/GetConsumerStatusRequestHeader.java | 20 +-
.../GetEarliestMsgStoretimeRequestHeader.java | 20 +-
.../GetEarliestMsgStoretimeResponseHeader.java | 18 +-
.../header/GetMaxOffsetRequestHeader.java | 20 +-
.../header/GetMaxOffsetResponseHeader.java | 18 +-
.../header/GetMinOffsetRequestHeader.java | 20 +-
.../header/GetMinOffsetResponseHeader.java | 18 +-
.../GetProducerConnectionListRequestHeader.java | 16 +-
.../header/GetTopicStatsInfoRequestHeader.java | 16 +-
.../header/GetTopicsByClusterRequestHeader.java | 16 +-
.../NotifyConsumerIdsChangedRequestHeader.java | 16 +-
.../header/PullMessageRequestHeader.java | 36 +-
.../header/PullMessageResponseHeader.java | 24 +-
.../QueryConsumeTimeSpanRequestHeader.java | 18 +-
.../QueryConsumerOffsetRequestHeader.java | 22 +-
.../QueryConsumerOffsetResponseHeader.java | 18 +-
.../header/QueryCorrectionOffsetHeader.java | 22 +-
.../header/QueryMessageRequestHeader.java | 26 +-
.../header/QueryMessageResponseHeader.java | 20 +-
.../QueryTopicConsumeByWhoRequestHeader.java | 18 +-
.../header/ResetOffsetRequestHeader.java | 22 +-
.../header/SearchOffsetRequestHeader.java | 22 +-
.../header/SearchOffsetResponseHeader.java | 18 +-
.../header/SendMessageRequestHeader.java | 40 +-
.../header/SendMessageRequestHeaderV2.java | 24 -
.../header/SendMessageResponseHeader.java | 22 +-
.../header/UnregisterClientRequestHeader.java | 20 +-
.../header/UnregisterClientResponseHeader.java | 13 +-
.../UpdateConsumerOffsetRequestHeader.java | 24 +-
.../UpdateConsumerOffsetResponseHeader.java | 15 +-
.../ViewBrokerStatsDataRequestHeader.java | 18 +-
.../header/ViewMessageRequestHeader.java | 18 +-
.../header/ViewMessageResponseHeader.java | 15 +-
.../RegisterFilterServerRequestHeader.java | 16 +-
.../RegisterFilterServerResponseHeader.java | 18 +-
...RegisterMessageFilterClassRequestHeader.java | 22 +-
.../namesrv/DeleteKVConfigRequestHeader.java | 18 +-
.../DeleteTopicInNamesrvRequestHeader.java | 16 +-
.../namesrv/GetKVConfigRequestHeader.java | 18 +-
.../namesrv/GetKVConfigResponseHeader.java | 16 +-
.../GetKVListByNamespaceRequestHeader.java | 16 +-
.../namesrv/GetRouteInfoRequestHeader.java | 18 +-
.../namesrv/GetRouteInfoResponseHeader.java | 15 +-
.../namesrv/PutKVConfigRequestHeader.java | 20 +-
.../namesrv/RegisterBrokerRequestHeader.java | 26 +-
.../namesrv/RegisterBrokerResponseHeader.java | 18 +-
.../RegisterOrderTopicRequestHeader.java | 20 +-
.../namesrv/UnRegisterBrokerRequestHeader.java | 24 +-
.../WipeWritePermOfBrokerRequestHeader.java | 16 +-
.../WipeWritePermOfBrokerResponseHeader.java | 16 +-
.../common/protocol/heartbeat/ConsumeType.java | 15 +-
.../common/protocol/heartbeat/ConsumerData.java | 35 +-
.../protocol/heartbeat/HeartbeatData.java | 27 +-
.../common/protocol/heartbeat/MessageModel.java | 15 +-
.../common/protocol/heartbeat/ProducerData.java | 17 +-
.../protocol/heartbeat/SubscriptionData.java | 39 +-
.../common/protocol/route/BrokerData.java | 20 +-
.../common/protocol/route/QueueData.java | 20 +-
.../common/protocol/route/TopicRouteData.java | 27 +-
.../common/protocol/topic/OffsetMovedEvent.java | 24 +-
.../common/queue/ConcurrentTreeMap.java | 27 +-
.../rocketmq/common/queue/RoundQueue.java | 15 +-
.../rocketmq/common/running/RunningStats.java | 12 +-
.../rocketmq/common/stats/MomentStatsItem.java | 19 +-
.../common/stats/MomentStatsItemSet.java | 11 +-
.../apache/rocketmq/common/stats/StatsItem.java | 68 +-
.../rocketmq/common/stats/StatsItemSet.java | 14 +-
.../rocketmq/common/stats/StatsSnapshot.java | 18 +-
.../subscription/SubscriptionGroupConfig.java | 35 +-
.../rocketmq/common/sysflag/MessageSysFlag.java | 3 -
.../rocketmq/common/sysflag/PullSysFlag.java | 20 +-
.../common/sysflag/SubscriptionSysFlag.java | 5 -
.../rocketmq/common/sysflag/TopicSysFlag.java | 8 -
.../rocketmq/common/utils/ChannelUtil.java | 15 +-
.../rocketmq/common/utils/HttpTinyClient.java | 36 +-
.../rocketmq/common/utils/IOTinyUtils.java | 42 +-
.../org/apache/rocketmq/common/MixAllTest.java | 18 +-
.../rocketmq/common/RemotingUtilTest.java | 13 +-
.../org/apache/rocketmq/common/UtilAllTest.java | 31 +-
.../rocketmq/common/filter/FilterAPITest.java | 17 +-
.../common/protocol/ConsumeStatusTest.java | 13 +-
conf/2m-2s-async/broker-a-s.properties | 1 -
conf/2m-2s-async/broker-a.properties | 1 -
conf/2m-2s-async/broker-b-s.properties | 1 -
conf/2m-2s-async/broker-b.properties | 1 -
conf/2m-2s-sync/broker-a-s.properties | 1 -
conf/2m-2s-sync/broker-a.properties | 1 -
conf/2m-2s-sync/broker-b-s.properties | 1 -
conf/2m-2s-sync/broker-b.properties | 1 -
conf/2m-noslave/broker-a.properties | 1 -
conf/2m-noslave/broker-b.properties | 1 -
conf/broker.conf | 14 +-
conf/logback_broker.xml | 22 +-
conf/logback_filtersrv.xml | 4 +-
conf/logback_namesrv.xml | 4 +-
conf/logback_tools.xml | 4 +-
example/pom.xml | 2 +-
.../rocketmq/example/benchmark/Consumer.java | 53 +-
.../rocketmq/example/benchmark/Producer.java | 52 +-
.../example/benchmark/TransactionProducer.java | 67 +-
.../example/broadcast/PushConsumer.java | 5 +-
.../rocketmq/example/filter/Consumer.java | 8 +-
.../rocketmq/example/filter/Producer.java | 6 +-
.../rocketmq/example/operation/Consumer.java | 21 +-
.../rocketmq/example/operation/Producer.java | 27 +-
.../rocketmq/example/ordermessage/Consumer.java | 6 +-
.../rocketmq/example/ordermessage/Producer.java | 13 +-
.../rocketmq/example/quickstart/Consumer.java | 5 +-
.../rocketmq/example/quickstart/Producer.java | 4 +-
.../rocketmq/example/simple/AsyncProducer.java | 10 +-
.../rocketmq/example/simple/CachedQueue.java | 17 +-
.../rocketmq/example/simple/Producer.java | 7 +-
.../rocketmq/example/simple/PullConsumer.java | 10 +-
.../example/simple/PullScheduleService.java | 2 -
.../rocketmq/example/simple/PushConsumer.java | 4 +-
.../example/simple/RandomAsyncCommit.java | 23 +-
.../rocketmq/example/simple/TestProducer.java | 8 +-
.../TransactionCheckListenerImpl.java | 5 +-
.../transaction/TransactionExecuterImpl.java | 16 +-
.../transaction/TransactionProducer.java | 9 +-
.../src/main/resources/MessageFilterImpl.java | 15 +-
filtersrv/pom.xml | 2 +-
.../filtersrv/FilterServerOuterAPI.java | 17 +-
.../rocketmq/filtersrv/FiltersrvConfig.java | 41 +-
.../rocketmq/filtersrv/FiltersrvController.java | 61 +-
.../rocketmq/filtersrv/FiltersrvStartup.java | 34 +-
.../rocketmq/filtersrv/filter/DynaCode.java | 177 +++--
.../filter/FilterClassFetchMethod.java | 12 +-
.../filtersrv/filter/FilterClassInfo.java | 19 +-
.../filtersrv/filter/FilterClassLoader.java | 12 +-
.../filtersrv/filter/FilterClassManager.java | 67 +-
.../filter/HttpFilterClassFetchMethod.java | 17 +-
.../processor/DefaultRequestProcessor.java | 91 ++-
.../stats/FilterServerStatsManager.java | 29 +-
namesrv/pom.xml | 2 +-
.../rocketmq/namesrv/NamesrvController.java | 45 +-
.../apache/rocketmq/namesrv/NamesrvStartup.java | 36 +-
.../namesrv/kvconfig/KVConfigManager.java | 45 +-
.../kvconfig/KVConfigSerializeWrapper.java | 18 +-
.../processor/ClusterTestRequestProcessor.java | 25 +-
.../processor/DefaultRequestProcessor.java | 154 ++---
.../routeinfo/BrokerHousekeepingService.java | 20 +-
.../namesrv/routeinfo/RouteInfoManager.java | 142 ++--
remoting/pom.xml | 2 +-
.../rocketmq/remoting/ChannelEventListener.java | 16 +-
.../rocketmq/remoting/CommandCustomHeader.java | 13 +-
.../rocketmq/remoting/InvokeCallback.java | 13 +-
.../org/apache/rocketmq/remoting/RPCHook.java | 4 +-
.../rocketmq/remoting/RemotingClient.java | 38 +-
.../rocketmq/remoting/RemotingServer.java | 26 +-
.../rocketmq/remoting/RemotingService.java | 2 -
.../remoting/annotation/CFNullable.java | 12 +-
.../apache/rocketmq/remoting/common/Pair.java | 17 +-
.../remoting/common/RemotingHelper.java | 41 +-
.../rocketmq/remoting/common/RemotingUtil.java | 29 +-
.../common/SemaphoreReleaseOnlyOnce.java | 16 +-
.../rocketmq/remoting/common/ServiceThread.java | 19 +-
.../exception/RemotingCommandException.java | 14 +-
.../exception/RemotingConnectException.java | 14 +-
.../remoting/exception/RemotingException.java | 14 +-
.../exception/RemotingSendRequestException.java | 14 +-
.../exception/RemotingTimeoutException.java | 15 +-
.../RemotingTooMuchRequestException.java | 13 +-
.../remoting/netty/NettyClientConfig.java | 31 +-
.../rocketmq/remoting/netty/NettyDecoder.java | 28 +-
.../rocketmq/remoting/netty/NettyEncoder.java | 24 +-
.../rocketmq/remoting/netty/NettyEvent.java | 18 +-
.../rocketmq/remoting/netty/NettyEventType.java | 12 +-
.../remoting/netty/NettyRemotingAbstract.java | 85 ++-
.../remoting/netty/NettyRemotingClient.java | 111 ++-
.../remoting/netty/NettyRemotingServer.java | 120 ++--
.../remoting/netty/NettyRequestProcessor.java | 18 +-
.../remoting/netty/NettyServerConfig.java | 36 +-
.../remoting/netty/NettySystemConfig.java | 26 +-
.../rocketmq/remoting/netty/RequestTask.java | 25 +-
.../rocketmq/remoting/netty/ResponseFuture.java | 45 +-
.../remoting/protocol/LanguageCode.java | 30 +-
.../remoting/protocol/RemotingCommand.java | 73 +-
.../remoting/protocol/RemotingCommandType.java | 12 +-
.../remoting/protocol/RemotingSerializable.java | 14 +-
.../protocol/RemotingSysResponseCode.java | 12 +-
.../remoting/protocol/RocketMQSerializable.java | 54 +-
.../remoting/protocol/SerializeType.java | 16 +-
.../org/apache/rocketmq/remoting/MixTest.java | 15 +-
.../apache/rocketmq/remoting/NettyRPCTest.java | 92 ++-
.../rocketmq/subclass/TestSubClassAuto.java | 13 +-
srvutil/pom.xml | 2 +-
.../org/apache/rocketmq/srvutil/ServerUtil.java | 29 +-
store/pom.xml | 2 +-
.../store/AllocateMappedFileService.java | 59 +-
.../rocketmq/store/AppendMessageCallback.java | 15 +-
.../rocketmq/store/AppendMessageResult.java | 42 +-
.../rocketmq/store/AppendMessageStatus.java | 12 +-
.../org/apache/rocketmq/store/CommitLog.java | 300 ++++-----
.../org/apache/rocketmq/store/ConsumeQueue.java | 78 +--
.../rocketmq/store/DefaultMessageFilter.java | 13 +-
.../rocketmq/store/DefaultMessageStore.java | 195 +++---
.../apache/rocketmq/store/DispatchRequest.java | 35 +-
.../apache/rocketmq/store/GetMessageResult.java | 45 +-
.../apache/rocketmq/store/GetMessageStatus.java | 12 +-
.../org/apache/rocketmq/store/MappedFile.java | 176 ++---
.../apache/rocketmq/store/MappedFileQueue.java | 82 +--
.../rocketmq/store/MessageArrivingListener.java | 12 +-
.../rocketmq/store/MessageExtBrokerInner.java | 17 +-
.../apache/rocketmq/store/MessageFilter.java | 13 +-
.../org/apache/rocketmq/store/MessageStore.java | 49 +-
.../apache/rocketmq/store/PutMessageResult.java | 21 +-
.../apache/rocketmq/store/PutMessageStatus.java | 12 +-
.../rocketmq/store/QueryMessageResult.java | 23 +-
.../rocketmq/store/ReferenceResource.java | 22 +-
.../org/apache/rocketmq/store/RunningFlags.java | 26 +-
.../store/SelectMappedBufferResult.java | 21 +-
.../apache/rocketmq/store/StoreCheckpoint.java | 40 +-
.../rocketmq/store/StoreStatsService.java | 88 +--
.../org/apache/rocketmq/store/StoreUtil.java | 16 +-
.../rocketmq/store/TransientStorePool.java | 15 +-
.../rocketmq/store/config/BrokerRole.java | 12 +-
.../rocketmq/store/config/FlushDiskType.java | 12 +-
.../store/config/MessageStoreConfig.java | 132 +---
.../store/config/StorePathConfigHelper.java | 19 +-
.../apache/rocketmq/store/ha/HAConnection.java | 63 +-
.../org/apache/rocketmq/store/ha/HAService.java | 95 +--
.../rocketmq/store/ha/WaitNotifyObject.java | 18 +-
.../apache/rocketmq/store/index/IndexFile.java | 72 +-
.../rocketmq/store/index/IndexHeader.java | 15 -
.../rocketmq/store/index/IndexService.java | 51 +-
.../rocketmq/store/index/QueryOffsetResult.java | 19 +-
.../schedule/DelayOffsetSerializeWrapper.java | 20 +-
.../store/schedule/ScheduleMessageService.java | 112 ++--
.../rocketmq/store/stats/BrokerStats.java | 29 +-
.../store/stats/BrokerStatsManager.java | 34 +-
.../org/apache/rocketmq/store/util/LibC.java | 15 +-
.../rocketmq/store/DefaultMessageStoreTest.java | 34 +-
.../rocketmq/store/MappedFileQueueTest.java | 56 +-
.../apache/rocketmq/store/MappedFileTest.java | 33 +-
.../rocketmq/store/StoreCheckpointTest.java | 20 +-
.../rocketmq/store/index/IndexFileTest.java | 25 +-
.../store/schedule/ScheduleMessageTest.java | 35 +-
store/src/test/resources/logback-test.xml | 24 +-
style/copyright/Apache.xml | 9 +-
style/copyright/profiles_settings.xml | 84 +--
style/rmq_codeStyle.xml | 204 +++---
tools/pom.xml | 2 +-
.../rocketmq/tools/admin/DefaultMQAdminExt.java | 141 ++--
.../tools/admin/DefaultMQAdminExtImpl.java | 212 +++---
.../apache/rocketmq/tools/admin/MQAdminExt.java | 141 ++--
.../rocketmq/tools/admin/api/MessageTrack.java | 21 +-
.../rocketmq/tools/admin/api/TrackType.java | 12 +-
.../rocketmq/tools/command/CommandUtil.java | 46 +-
.../rocketmq/tools/command/MQAdminStartup.java | 72 +-
.../rocketmq/tools/command/SubCommand.java | 18 +-
.../broker/BrokerConsumeStatsSubCommad.java | 46 +-
.../command/broker/BrokerStatusSubCommand.java | 24 +-
.../broker/CleanExpiredCQSubCommand.java | 22 +-
.../command/broker/CleanUnusedTopicCommand.java | 22 +-
.../command/broker/GetBrokerConfigCommand.java | 39 +-
.../command/broker/SendMsgStatusCommand.java | 36 +-
.../broker/UpdateBrokerConfigSubCommand.java | 29 +-
.../cluster/CLusterSendMsgRTCommand.java | 55 +-
.../command/cluster/ClusterListSubCommand.java | 89 ++-
.../ConsumerConnectionSubCommand.java | 29 +-
.../ProducerConnectionSubCommand.java | 17 +-
.../consumer/ConsumerProgressSubCommand.java | 84 +--
.../consumer/ConsumerStatusSubCommand.java | 30 +-
.../command/consumer/ConsumerSubCommand.java | 32 +-
.../DeleteSubscriptionGroupCommand.java | 35 +-
.../consumer/StartMonitoringSubCommand.java | 23 +-
.../consumer/UpdateSubGroupSubCommand.java | 29 +-
.../command/message/CheckMsgSendRTCommand.java | 34 +-
.../command/message/DecodeMessageIdCommond.java | 18 +-
.../message/PrintMessageByQueueCommand.java | 157 +++--
.../command/message/PrintMessageSubCommand.java | 76 +--
.../command/message/QueryMsgByIdSubCommand.java | 287 ++++----
.../message/QueryMsgByKeySubCommand.java | 27 +-
.../message/QueryMsgByOffsetSubCommand.java | 7 +-
.../message/QueryMsgByUniqueKeySubCommand.java | 177 +++--
.../rocketmq/tools/command/message/Store.java | 56 +-
.../command/namesrv/DeleteKvConfigCommand.java | 22 +-
.../namesrv/GetNamesrvConfigCommand.java | 25 +-
.../command/namesrv/UpdateKvConfigCommand.java | 22 +-
.../namesrv/UpdateNamesrvConfigCommand.java | 27 +-
.../namesrv/WipeWritePermSubCommand.java | 34 +-
.../command/offset/CloneGroupOffsetCommand.java | 23 +-
.../offset/GetConsumerStatusCommand.java | 29 +-
.../offset/ResetOffsetByTimeCommand.java | 32 +-
.../offset/ResetOffsetByTimeOldCommand.java | 80 ++-
.../tools/command/stats/StatsAllSubCommand.java | 176 +++--
.../command/topic/AllocateMQSubCommand.java | 20 +-
.../command/topic/DeleteTopicSubCommand.java | 70 +-
.../tools/command/topic/RebalanceResult.java | 15 +-
.../command/topic/TopicClusterSubCommand.java | 12 +-
.../command/topic/TopicListSubCommand.java | 34 +-
.../command/topic/TopicRouteSubCommand.java | 10 +-
.../command/topic/TopicStatusSubCommand.java | 49 +-
.../command/topic/UpdateOrderConfCommand.java | 26 +-
.../topic/UpdateTopicPermSubCommand.java | 17 +-
.../command/topic/UpdateTopicSubCommand.java | 25 +-
.../tools/monitor/DefaultMonitorListener.java | 40 +-
.../rocketmq/tools/monitor/DeleteMsgsEvent.java | 20 +-
.../rocketmq/tools/monitor/FailedMsgs.java | 21 +-
.../rocketmq/tools/monitor/MonitorConfig.java | 19 +-
.../rocketmq/tools/monitor/MonitorListener.java | 3 +-
.../rocketmq/tools/monitor/MonitorService.java | 65 +-
.../rocketmq/tools/monitor/UndoneMsgs.java | 27 +-
555 files changed, 8226 insertions(+), 11139 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/pom.xml
----------------------------------------------------------------------
diff --git a/broker/pom.xml b/broker/pom.xml
index 0917503..30525e4 100644
--- a/broker/pom.xml
+++ b/broker/pom.xml
@@ -15,7 +15,7 @@
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.rocketmq</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
index 8e973ac..501c1c5 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
@@ -16,7 +16,25 @@
*/
package org.apache.rocketmq.broker;
-import org.apache.rocketmq.broker.client.*;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import org.apache.rocketmq.broker.client.ClientHousekeepingService;
+import org.apache.rocketmq.broker.client.ConsumerIdsChangeListener;
+import org.apache.rocketmq.broker.client.ConsumerManager;
+import org.apache.rocketmq.broker.client.DefaultConsumerIdsChangeListener;
+import org.apache.rocketmq.broker.client.ProducerManager;
import org.apache.rocketmq.broker.client.net.Broker2Client;
import org.apache.rocketmq.broker.client.rebalance.RebalanceLockManager;
import org.apache.rocketmq.broker.filtersrv.FilterServerManager;
@@ -30,11 +48,21 @@ import org.apache.rocketmq.broker.offset.ConsumerOffsetManager;
import org.apache.rocketmq.broker.out.BrokerOuterAPI;
import org.apache.rocketmq.broker.plugin.MessageStoreFactory;
import org.apache.rocketmq.broker.plugin.MessageStorePluginContext;
-import org.apache.rocketmq.broker.processor.*;
+import org.apache.rocketmq.broker.processor.AdminBrokerProcessor;
+import org.apache.rocketmq.broker.processor.ClientManageProcessor;
+import org.apache.rocketmq.broker.processor.ConsumerManageProcessor;
+import org.apache.rocketmq.broker.processor.EndTransactionProcessor;
+import org.apache.rocketmq.broker.processor.PullMessageProcessor;
+import org.apache.rocketmq.broker.processor.QueryMessageProcessor;
+import org.apache.rocketmq.broker.processor.SendMessageProcessor;
import org.apache.rocketmq.broker.slave.SlaveSynchronize;
import org.apache.rocketmq.broker.subscription.SubscriptionGroupManager;
import org.apache.rocketmq.broker.topic.TopicConfigManager;
-import org.apache.rocketmq.common.*;
+import org.apache.rocketmq.common.BrokerConfig;
+import org.apache.rocketmq.common.Configuration;
+import org.apache.rocketmq.common.ThreadFactoryImpl;
+import org.apache.rocketmq.common.TopicConfig;
+import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.common.constant.PermName;
import org.apache.rocketmq.common.namesrv.RegisterBrokerResult;
@@ -43,7 +71,11 @@ import org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper;
import org.apache.rocketmq.common.stats.MomentStatsItem;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.remoting.RemotingServer;
-import org.apache.rocketmq.remoting.netty.*;
+import org.apache.rocketmq.remoting.netty.NettyClientConfig;
+import org.apache.rocketmq.remoting.netty.NettyRemotingServer;
+import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
+import org.apache.rocketmq.remoting.netty.NettyServerConfig;
+import org.apache.rocketmq.remoting.netty.RequestTask;
import org.apache.rocketmq.store.DefaultMessageStore;
import org.apache.rocketmq.store.MessageArrivingListener;
import org.apache.rocketmq.store.MessageStore;
@@ -54,15 +86,6 @@ import org.apache.rocketmq.store.stats.BrokerStatsManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.*;
-
-
public class BrokerController {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private static final Logger LOG_PROTECTION = LoggerFactory.getLogger(LoggerName.PROTECTION_LOGGER_NAME);
@@ -84,7 +107,7 @@ public class BrokerController {
private final RebalanceLockManager rebalanceLockManager = new RebalanceLockManager();
private final BrokerOuterAPI brokerOuterAPI;
private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl(
- "BrokerControllerScheduledThread"));
+ "BrokerControllerScheduledThread"));
private final SlaveSynchronize slaveSynchronize;
private final BlockingQueue<Runnable> sendThreadPoolQueue;
private final BlockingQueue<Runnable> pullThreadPoolQueue;
@@ -110,10 +133,10 @@ public class BrokerController {
private Configuration configuration;
public BrokerController(//
- final BrokerConfig brokerConfig, //
- final NettyServerConfig nettyServerConfig, //
- final NettyClientConfig nettyClientConfig, //
- final MessageStoreConfig messageStoreConfig //
+ final BrokerConfig brokerConfig, //
+ final NettyServerConfig nettyServerConfig, //
+ final NettyClientConfig nettyClientConfig, //
+ final MessageStoreConfig messageStoreConfig //
) {
this.brokerConfig = brokerConfig;
this.nettyServerConfig = nettyServerConfig;
@@ -151,9 +174,9 @@ public class BrokerController {
this.brokerFastFailure = new BrokerFastFailure(this);
this.configuration = new Configuration(
- log,
- BrokerPathConfigHelper.getBrokerConfigPath(),
- this.brokerConfig, this.nettyServerConfig, this.nettyClientConfig, this.messageStoreConfig
+ log,
+ BrokerPathConfigHelper.getBrokerConfigPath(),
+ this.brokerConfig, this.nettyServerConfig, this.nettyClientConfig, this.messageStoreConfig
);
}
@@ -180,9 +203,9 @@ public class BrokerController {
if (result) {
try {
this.messageStore =
- new DefaultMessageStore(this.messageStoreConfig, this.brokerStatsManager, this.messageArrivingListener,
- this.brokerConfig);
- this.brokerStats = new BrokerStats((DefaultMessageStore) this.messageStore);
+ new DefaultMessageStore(this.messageStoreConfig, this.brokerStatsManager, this.messageArrivingListener,
+ this.brokerConfig);
+ this.brokerStats = new BrokerStats((DefaultMessageStore)this.messageStore);
//load plugin
MessageStorePluginContext context = new MessageStorePluginContext(messageStoreConfig, brokerStatsManager, messageArrivingListener, brokerConfig);
this.messageStore = MessageStoreFactory.build(context, this.messageStore);
@@ -196,44 +219,43 @@ public class BrokerController {
if (result) {
this.remotingServer = new NettyRemotingServer(this.nettyServerConfig, this.clientHousekeepingService);
- NettyServerConfig fastConfig = (NettyServerConfig) this.nettyServerConfig.clone();
+ NettyServerConfig fastConfig = (NettyServerConfig)this.nettyServerConfig.clone();
fastConfig.setListenPort(nettyServerConfig.getListenPort() - 2);
this.fastRemotingServer = new NettyRemotingServer(fastConfig, this.clientHousekeepingService);
this.sendMessageExecutor = new BrokerFixedThreadPoolExecutor(
- this.brokerConfig.getSendMessageThreadPoolNums(),
- this.brokerConfig.getSendMessageThreadPoolNums(),
- 1000 * 60,
- TimeUnit.MILLISECONDS,
- this.sendThreadPoolQueue,
- new ThreadFactoryImpl("SendMessageThread_"));
+ this.brokerConfig.getSendMessageThreadPoolNums(),
+ this.brokerConfig.getSendMessageThreadPoolNums(),
+ 1000 * 60,
+ TimeUnit.MILLISECONDS,
+ this.sendThreadPoolQueue,
+ new ThreadFactoryImpl("SendMessageThread_"));
this.pullMessageExecutor = new BrokerFixedThreadPoolExecutor(
- this.brokerConfig.getPullMessageThreadPoolNums(),
- this.brokerConfig.getPullMessageThreadPoolNums(),
- 1000 * 60,
- TimeUnit.MILLISECONDS,
- this.pullThreadPoolQueue,
- new ThreadFactoryImpl("PullMessageThread_"));
+ this.brokerConfig.getPullMessageThreadPoolNums(),
+ this.brokerConfig.getPullMessageThreadPoolNums(),
+ 1000 * 60,
+ TimeUnit.MILLISECONDS,
+ this.pullThreadPoolQueue,
+ new ThreadFactoryImpl("PullMessageThread_"));
this.adminBrokerExecutor =
- Executors.newFixedThreadPool(this.brokerConfig.getAdminBrokerThreadPoolNums(), new ThreadFactoryImpl(
- "AdminBrokerThread_"));
+ Executors.newFixedThreadPool(this.brokerConfig.getAdminBrokerThreadPoolNums(), new ThreadFactoryImpl(
+ "AdminBrokerThread_"));
this.clientManageExecutor = new ThreadPoolExecutor(
- this.brokerConfig.getClientManageThreadPoolNums(),
- this.brokerConfig.getClientManageThreadPoolNums(),
- 1000 * 60,
- TimeUnit.MILLISECONDS,
- this.clientManagerThreadPoolQueue,
- new ThreadFactoryImpl("ClientManageThread_"));
+ this.brokerConfig.getClientManageThreadPoolNums(),
+ this.brokerConfig.getClientManageThreadPoolNums(),
+ 1000 * 60,
+ TimeUnit.MILLISECONDS,
+ this.clientManagerThreadPoolQueue,
+ new ThreadFactoryImpl("ClientManageThread_"));
this.consumerManageExecutor =
- Executors.newFixedThreadPool(this.brokerConfig.getConsumerManageThreadPoolNums(), new ThreadFactoryImpl(
- "ConsumerManageThread_"));
+ Executors.newFixedThreadPool(this.brokerConfig.getConsumerManageThreadPoolNums(), new ThreadFactoryImpl(
+ "ConsumerManageThread_"));
this.registerProcessor();
-
// TODO remove in future
final long initialDelay = UtilAll.computNextMorningTimeMillis() - System.currentTimeMillis();
final long period = 1000 * 60 * 60 * 24;
@@ -259,7 +281,6 @@ public class BrokerController {
}
}, 1000 * 10, this.brokerConfig.getFlushConsumerOffsetInterval(), TimeUnit.MILLISECONDS);
-
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
@@ -399,7 +420,6 @@ public class BrokerController {
this.fastRemotingServer.registerProcessor(RequestCode.UPDATE_CONSUMER_OFFSET, consumerManageProcessor, this.consumerManageExecutor);
this.fastRemotingServer.registerProcessor(RequestCode.QUERY_CONSUMER_OFFSET, consumerManageProcessor, this.consumerManageExecutor);
-
/**
* EndTransactionProcessor
*/
@@ -446,7 +466,8 @@ public class BrokerController {
slowTimeMills = this.messageStore.now() - rt.getCreateTimestamp();
}
- if (slowTimeMills < 0) slowTimeMills = 0;
+ if (slowTimeMills < 0)
+ slowTimeMills = 0;
return slowTimeMills;
}
@@ -577,10 +598,10 @@ public class BrokerController {
private void unregisterBrokerAll() {
this.brokerOuterAPI.unregisterBrokerAll(
- this.brokerConfig.getBrokerClusterName(),
- this.getBrokerAddr(),
- this.brokerConfig.getBrokerName(),
- this.brokerConfig.getBrokerId());
+ this.brokerConfig.getBrokerClusterName(),
+ this.getBrokerAddr(),
+ this.brokerConfig.getBrokerName(),
+ this.brokerConfig.getBrokerId());
}
public String getBrokerAddr() {
@@ -643,27 +664,27 @@ public class BrokerController {
TopicConfigSerializeWrapper topicConfigWrapper = this.getTopicConfigManager().buildTopicConfigSerializeWrapper();
if (!PermName.isWriteable(this.getBrokerConfig().getBrokerPermission())
- || !PermName.isReadable(this.getBrokerConfig().getBrokerPermission())) {
+ || !PermName.isReadable(this.getBrokerConfig().getBrokerPermission())) {
ConcurrentHashMap<String, TopicConfig> topicConfigTable = new ConcurrentHashMap<String, TopicConfig>();
for (TopicConfig topicConfig : topicConfigWrapper.getTopicConfigTable().values()) {
TopicConfig tmp =
- new TopicConfig(topicConfig.getTopicName(), topicConfig.getReadQueueNums(), topicConfig.getWriteQueueNums(),
- this.brokerConfig.getBrokerPermission());
+ new TopicConfig(topicConfig.getTopicName(), topicConfig.getReadQueueNums(), topicConfig.getWriteQueueNums(),
+ this.brokerConfig.getBrokerPermission());
topicConfigTable.put(topicConfig.getTopicName(), tmp);
}
topicConfigWrapper.setTopicConfigTable(topicConfigTable);
}
RegisterBrokerResult registerBrokerResult = this.brokerOuterAPI.registerBrokerAll(
- this.brokerConfig.getBrokerClusterName(),
- this.getBrokerAddr(),
- this.brokerConfig.getBrokerName(),
- this.brokerConfig.getBrokerId(),
- this.getHAServerAddr(),
- topicConfigWrapper,
- this.filterServerManager.buildNewFilterServerList(),
- oneway,
- this.brokerConfig.getRegisterBrokerTimeoutMills());
+ this.brokerConfig.getBrokerClusterName(),
+ this.getBrokerAddr(),
+ this.brokerConfig.getBrokerName(),
+ this.brokerConfig.getBrokerId(),
+ this.getHAServerAddr(),
+ topicConfigWrapper,
+ this.filterServerManager.buildNewFilterServerList(),
+ oneway,
+ this.brokerConfig.getRegisterBrokerTimeoutMills());
if (registerBrokerResult != null) {
if (this.updateMasterHAServerAddrPeriodically && registerBrokerResult.getHaServerAddr() != null) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/BrokerPathConfigHelper.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerPathConfigHelper.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerPathConfigHelper.java
index dbcd304..7a46df3 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/BrokerPathConfigHelper.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerPathConfigHelper.java
@@ -6,45 +6,39 @@
* (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
+ * 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.
+ * 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.broker;
import java.io.File;
-
public class BrokerPathConfigHelper {
private static String brokerConfigPath = System.getProperty("user.home") + File.separator + "store"
- + File.separator + "config" + File.separator + "broker.properties";
-
+ + File.separator + "config" + File.separator + "broker.properties";
public static String getBrokerConfigPath() {
return brokerConfigPath;
}
-
public static void setBrokerConfigPath(String path) {
brokerConfigPath = path;
}
-
public static String getTopicConfigPath(final String rootDir) {
return rootDir + File.separator + "config" + File.separator + "topics.json";
}
-
public static String getConsumerOffsetPath(final String rootDir) {
return rootDir + File.separator + "config" + File.separator + "consumerOffset.json";
}
-
public static String getSubscriptionGroupPath(final String rootDir) {
return rootDir + File.separator + "config" + File.separator + "subscriptionGroup.json";
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
index 86091c4..dfa97c1 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
@@ -18,6 +18,15 @@ package org.apache.rocketmq.broker;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.PosixParser;
import org.apache.rocketmq.common.BrokerConfig;
import org.apache.rocketmq.common.MQVersion;
import org.apache.rocketmq.common.MixAll;
@@ -30,20 +39,9 @@ import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.apache.rocketmq.srvutil.ServerUtil;
import org.apache.rocketmq.store.config.BrokerRole;
import org.apache.rocketmq.store.config.MessageStoreConfig;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.PosixParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicInteger;
-
-
public class BrokerStartup {
public static Properties properties = null;
public static CommandLine commandLine = null;
@@ -58,7 +56,7 @@ public class BrokerStartup {
try {
controller.start();
String tip = "The broker[" + controller.getBrokerConfig().getBrokerName() + ", "
- + controller.getBrokerAddr() + "] boot success. serializeType=" + RemotingCommand.getSerializeTypeConfigInThisServer();
+ + controller.getBrokerAddr() + "] boot success. serializeType=" + RemotingCommand.getSerializeTypeConfigInThisServer();
if (null != controller.getBrokerConfig().getNamesrvAddr()) {
tip += " and name server is " + controller.getBrokerConfig().getNamesrvAddr();
@@ -89,7 +87,7 @@ public class BrokerStartup {
//PackageConflictDetect.detectFastjson();
Options options = ServerUtil.buildCommandlineOptions(new Options());
commandLine = ServerUtil.parseCmdLine("mqbroker", args, buildCommandlineOptions(options),
- new PosixParser());
+ new PosixParser());
if (null == commandLine) {
System.exit(-1);
}
@@ -142,7 +140,7 @@ public class BrokerStartup {
if (null == brokerConfig.getRocketmqHome()) {
System.out.printf("Please set the " + MixAll.ROCKETMQ_HOME_ENV
- + " variable in your environment to match the location of the RocketMQ installation");
+ + " variable in your environment to match the location of the RocketMQ installation");
System.exit(-2);
}
@@ -157,13 +155,12 @@ public class BrokerStartup {
}
} catch (Exception e) {
System.out.printf(
- "The Name Server Address[%s] illegal, please set it as follows, \"127.0.0.1:9876;192.168.0.1:9876\"%n",
- namesrvAddr);
+ "The Name Server Address[%s] illegal, please set it as follows, \"127.0.0.1:9876;192.168.0.1:9876\"%n",
+ namesrvAddr);
System.exit(-3);
}
}
-
switch (messageStoreConfig.getBrokerRole()) {
case ASYNC_MASTER:
case SYNC_MASTER:
@@ -181,7 +178,7 @@ public class BrokerStartup {
}
messageStoreConfig.setHaListenPort(nettyServerConfig.getListenPort() + 1);
- LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+ LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
@@ -194,10 +191,10 @@ public class BrokerStartup {
MixAll.printObjectProperties(log, messageStoreConfig);
final BrokerController controller = new BrokerController(//
- brokerConfig, //
- nettyServerConfig, //
- nettyClientConfig, //
- messageStoreConfig);
+ brokerConfig, //
+ nettyServerConfig, //
+ nettyClientConfig, //
+ messageStoreConfig);
// remember all configs to prevent discard
controller.getConfiguration().registerConfig(properties);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
index a994503..24cddb9 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
@@ -6,19 +6,18 @@
* (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
+ * 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.
+ * 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.broker.client;
-import org.apache.rocketmq.remoting.protocol.LanguageCode;
import io.netty.channel.Channel;
-
+import org.apache.rocketmq.remoting.protocol.LanguageCode;
public class ClientChannelInfo {
private final Channel channel;
@@ -27,12 +26,10 @@ public class ClientChannelInfo {
private final int version;
private volatile long lastUpdateTimestamp = System.currentTimeMillis();
-
public ClientChannelInfo(Channel channel) {
this(channel, null, null, 0);
}
-
public ClientChannelInfo(Channel channel, String clientId, LanguageCode language, int version) {
this.channel = channel;
this.clientId = clientId;
@@ -40,37 +37,30 @@ public class ClientChannelInfo {
this.version = version;
}
-
public Channel getChannel() {
return channel;
}
-
public String getClientId() {
return clientId;
}
-
public LanguageCode getLanguage() {
return language;
}
-
public int getVersion() {
return version;
}
-
public long getLastUpdateTimestamp() {
return lastUpdateTimestamp;
}
-
public void setLastUpdateTimestamp(long lastUpdateTimestamp) {
this.lastUpdateTimestamp = lastUpdateTimestamp;
}
-
@Override
public int hashCode() {
final int prime = 31;
@@ -78,12 +68,11 @@ public class ClientChannelInfo {
result = prime * result + ((channel == null) ? 0 : channel.hashCode());
result = prime * result + ((clientId == null) ? 0 : clientId.hashCode());
result = prime * result + ((language == null) ? 0 : language.hashCode());
- result = prime * result + (int) (lastUpdateTimestamp ^ (lastUpdateTimestamp >>> 32));
+ result = prime * result + (int)(lastUpdateTimestamp ^ (lastUpdateTimestamp >>> 32));
result = prime * result + version;
return result;
}
-
@Override
public boolean equals(Object obj) {
if (this == obj)
@@ -92,7 +81,7 @@ public class ClientChannelInfo {
return false;
if (getClass() != obj.getClass())
return false;
- ClientChannelInfo other = (ClientChannelInfo) obj;
+ ClientChannelInfo other = (ClientChannelInfo)obj;
if (channel == null) {
if (other.channel != null)
return false;
@@ -103,10 +92,9 @@ public class ClientChannelInfo {
return true;
}
-
@Override
public String toString() {
return "ClientChannelInfo [channel=" + channel + ", clientId=" + clientId + ", language=" + language
- + ", version=" + version + ", lastUpdateTimestamp=" + lastUpdateTimestamp + "]";
+ + ", version=" + version + ", lastUpdateTimestamp=" + lastUpdateTimestamp + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java
index 856ce72..5d7c0ea 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java
@@ -6,42 +6,38 @@
* (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
+ * 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.
+ * 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.broker.client;
+import io.netty.channel.Channel;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
import org.apache.rocketmq.broker.BrokerController;
import org.apache.rocketmq.common.ThreadFactoryImpl;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.remoting.ChannelEventListener;
-import io.netty.channel.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-
public class ClientHousekeepingService implements ChannelEventListener {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final BrokerController brokerController;
private ScheduledExecutorService scheduledExecutorService = Executors
- .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ClientHousekeepingScheduledThread"));
-
+ .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ClientHousekeepingScheduledThread"));
public ClientHousekeepingService(final BrokerController brokerController) {
this.brokerController = brokerController;
}
-
public void start() {
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@@ -71,7 +67,6 @@ public class ClientHousekeepingService implements ChannelEventListener {
}
-
@Override
public void onChannelClose(String remoteAddr, Channel channel) {
this.brokerController.getProducerManager().doChannelCloseEvent(remoteAddr, channel);
@@ -79,7 +74,6 @@ public class ClientHousekeepingService implements ChannelEventListener {
this.brokerController.getFilterServerManager().doChannelCloseEvent(remoteAddr, channel);
}
-
@Override
public void onChannelException(String remoteAddr, Channel channel) {
this.brokerController.getProducerManager().doChannelCloseEvent(remoteAddr, channel);
@@ -87,7 +81,6 @@ public class ClientHousekeepingService implements ChannelEventListener {
this.brokerController.getFilterServerManager().doChannelCloseEvent(remoteAddr, channel);
}
-
@Override
public void onChannelIdle(String remoteAddr, Channel channel) {
this.brokerController.getProducerManager().doChannelCloseEvent(remoteAddr, channel);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java
index d5b056e..2656467 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java
@@ -16,45 +16,41 @@
*/
package org.apache.rocketmq.broker.client;
-import org.apache.rocketmq.common.constant.LoggerName;
-import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
-import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
-import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
-import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
import io.netty.channel.Channel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
+import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ConsumerGroupInfo {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final String groupName;
private final ConcurrentHashMap<String/* Topic */, SubscriptionData> subscriptionTable =
- new ConcurrentHashMap<String, SubscriptionData>();
+ new ConcurrentHashMap<String, SubscriptionData>();
private final ConcurrentHashMap<Channel, ClientChannelInfo> channelInfoTable =
- new ConcurrentHashMap<Channel, ClientChannelInfo>(16);
+ new ConcurrentHashMap<Channel, ClientChannelInfo>(16);
private volatile ConsumeType consumeType;
private volatile MessageModel messageModel;
private volatile ConsumeFromWhere consumeFromWhere;
private volatile long lastUpdateTimestamp = System.currentTimeMillis();
-
public ConsumerGroupInfo(String groupName, ConsumeType consumeType, MessageModel messageModel,
- ConsumeFromWhere consumeFromWhere) {
+ ConsumeFromWhere consumeFromWhere) {
this.groupName = groupName;
this.consumeType = consumeType;
this.messageModel = messageModel;
this.consumeFromWhere = consumeFromWhere;
}
-
public ClientChannelInfo findChannel(final String clientId) {
Iterator<Entry<Channel, ClientChannelInfo>> it = this.channelInfoTable.entrySet().iterator();
while (it.hasNext()) {
@@ -67,17 +63,14 @@ public class ConsumerGroupInfo {
return null;
}
-
public ConcurrentHashMap<String, SubscriptionData> getSubscriptionTable() {
return subscriptionTable;
}
-
public ConcurrentHashMap<Channel, ClientChannelInfo> getChannelInfoTable() {
return channelInfoTable;
}
-
public List<Channel> getAllChannel() {
List<Channel> result = new ArrayList<Channel>();
@@ -86,7 +79,6 @@ public class ConsumerGroupInfo {
return result;
}
-
public List<String> getAllClientId() {
List<String> result = new ArrayList<String>();
@@ -101,7 +93,6 @@ public class ConsumerGroupInfo {
return result;
}
-
public void unregisterChannel(final ClientChannelInfo clientChannelInfo) {
ClientChannelInfo old = this.channelInfoTable.remove(clientChannelInfo.getChannel());
if (old != null) {
@@ -109,13 +100,12 @@ public class ConsumerGroupInfo {
}
}
-
public boolean doChannelCloseEvent(final String remoteAddr, final Channel channel) {
final ClientChannelInfo info = this.channelInfoTable.remove(channel);
if (info != null) {
log.warn(
- "NETTY EVENT: remove not active channel[{}] from ConsumerGroupInfo groupChannelTable, consumer group: {}",
- info.toString(), groupName);
+ "NETTY EVENT: remove not active channel[{}] from ConsumerGroupInfo groupChannelTable, consumer group: {}",
+ info.toString(), groupName);
return true;
}
@@ -123,7 +113,7 @@ public class ConsumerGroupInfo {
}
public boolean updateChannel(final ClientChannelInfo infoNew, ConsumeType consumeType,
- MessageModel messageModel, ConsumeFromWhere consumeFromWhere) {
+ MessageModel messageModel, ConsumeFromWhere consumeFromWhere) {
boolean updated = false;
this.consumeType = consumeType;
this.messageModel = messageModel;
@@ -134,7 +124,7 @@ public class ConsumerGroupInfo {
ClientChannelInfo prev = this.channelInfoTable.put(infoNew.getChannel(), infoNew);
if (null == prev) {
log.info("new consumer connected, group: {} {} {} channel: {}", this.groupName, consumeType,
- messageModel, infoNew.toString());
+ messageModel, infoNew.toString());
updated = true;
}
@@ -142,9 +132,9 @@ public class ConsumerGroupInfo {
} else {
if (!infoOld.getClientId().equals(infoNew.getClientId())) {
log.error("[BUG] consumer channel exist in broker, but clientId not equal. GROUP: {} OLD: {} NEW: {} ",
- this.groupName,
- infoOld.toString(),
- infoNew.toString());
+ this.groupName,
+ infoOld.toString(),
+ infoNew.toString());
this.channelInfoTable.put(infoNew.getChannel(), infoNew);
}
}
@@ -155,7 +145,6 @@ public class ConsumerGroupInfo {
return updated;
}
-
public boolean updateSubscription(final Set<SubscriptionData> subList) {
boolean updated = false;
@@ -166,15 +155,15 @@ public class ConsumerGroupInfo {
if (null == prev) {
updated = true;
log.info("subscription changed, add new topic, group: {} {}",
- this.groupName,
- sub.toString());
+ this.groupName,
+ sub.toString());
}
} else if (sub.getSubVersion() > old.getSubVersion()) {
if (this.consumeType == ConsumeType.CONSUME_PASSIVELY) {
log.info("subscription changed, group: {} OLD: {} NEW: {}",
- this.groupName,
- old.toString(),
- sub.toString()
+ this.groupName,
+ old.toString(),
+ sub.toString()
);
}
@@ -182,7 +171,6 @@ public class ConsumerGroupInfo {
}
}
-
Iterator<Entry<String, SubscriptionData>> it = this.subscriptionTable.entrySet().iterator();
while (it.hasNext()) {
Entry<String, SubscriptionData> next = it.next();
@@ -198,9 +186,9 @@ public class ConsumerGroupInfo {
if (!exist) {
log.warn("subscription changed, group: {} remove topic {} {}",
- this.groupName,
- oldTopic,
- next.getValue().toString()
+ this.groupName,
+ oldTopic,
+ next.getValue().toString()
);
it.remove();
@@ -213,57 +201,46 @@ public class ConsumerGroupInfo {
return updated;
}
-
public Set<String> getSubscribeTopics() {
return subscriptionTable.keySet();
}
-
public SubscriptionData findSubscriptionData(final String topic) {
return this.subscriptionTable.get(topic);
}
-
public ConsumeType getConsumeType() {
return consumeType;
}
-
public void setConsumeType(ConsumeType consumeType) {
this.consumeType = consumeType;
}
-
public MessageModel getMessageModel() {
return messageModel;
}
-
public void setMessageModel(MessageModel messageModel) {
this.messageModel = messageModel;
}
-
public String getGroupName() {
return groupName;
}
-
public long getLastUpdateTimestamp() {
return lastUpdateTimestamp;
}
-
public void setLastUpdateTimestamp(long lastUpdateTimestamp) {
this.lastUpdateTimestamp = lastUpdateTimestamp;
}
-
public ConsumeFromWhere getConsumeFromWhere() {
return consumeFromWhere;
}
-
public void setConsumeFromWhere(ConsumeFromWhere consumeFromWhere) {
this.consumeFromWhere = consumeFromWhere;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java
index 368582a..fbec010 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java
@@ -6,21 +6,19 @@
* (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
+ * 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.
+ * 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.broker.client;
import io.netty.channel.Channel;
-
import java.util.List;
-
public interface ConsumerIdsChangeListener {
void consumerIdsChanged(final String group, final List<Channel> channels);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java
index 95ed478..fd4fb88 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java
@@ -16,6 +16,12 @@
*/
package org.apache.rocketmq.broker.client;
+import io.netty.channel.Channel;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
@@ -23,22 +29,14 @@ import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.apache.rocketmq.remoting.common.RemotingUtil;
-import io.netty.channel.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-
public class ConsumerManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private static final long CHANNEL_EXPIRED_TIMEOUT = 1000 * 120;
private final ConcurrentHashMap<String/* Group */, ConsumerGroupInfo> consumerTable =
- new ConcurrentHashMap<String, ConsumerGroupInfo>(1024);
+ new ConcurrentHashMap<String, ConsumerGroupInfo>(1024);
private final ConsumerIdsChangeListener consumerIdsChangeListener;
public ConsumerManager(final ConsumerIdsChangeListener consumerIdsChangeListener) {
@@ -86,7 +84,7 @@ public class ConsumerManager {
ConsumerGroupInfo remove = this.consumerTable.remove(next.getKey());
if (remove != null) {
log.info("unregister consumer ok, no any connection, and remove consumer group, {}",
- next.getKey());
+ next.getKey());
}
}
@@ -96,8 +94,8 @@ public class ConsumerManager {
}
public boolean registerConsumer(final String group, final ClientChannelInfo clientChannelInfo,
- ConsumeType consumeType, MessageModel messageModel, ConsumeFromWhere consumeFromWhere,
- final Set<SubscriptionData> subList, boolean isNotifyConsumerIdsChangedEnable) {
+ ConsumeType consumeType, MessageModel messageModel, ConsumeFromWhere consumeFromWhere,
+ final Set<SubscriptionData> subList, boolean isNotifyConsumerIdsChangedEnable) {
ConsumerGroupInfo consumerGroupInfo = this.consumerTable.get(group);
if (null == consumerGroupInfo) {
@@ -107,8 +105,8 @@ public class ConsumerManager {
}
boolean r1 =
- consumerGroupInfo.updateChannel(clientChannelInfo, consumeType, messageModel,
- consumeFromWhere);
+ consumerGroupInfo.updateChannel(clientChannelInfo, consumeType, messageModel,
+ consumeFromWhere);
boolean r2 = consumerGroupInfo.updateSubscription(subList);
if (r1 || r2) {
@@ -143,7 +141,7 @@ public class ConsumerManager {
String group = next.getKey();
ConsumerGroupInfo consumerGroupInfo = next.getValue();
ConcurrentHashMap<Channel, ClientChannelInfo> channelInfoTable =
- consumerGroupInfo.getChannelInfoTable();
+ consumerGroupInfo.getChannelInfoTable();
Iterator<Entry<Channel, ClientChannelInfo>> itChannel = channelInfoTable.entrySet().iterator();
while (itChannel.hasNext()) {
@@ -152,8 +150,8 @@ public class ConsumerManager {
long diff = System.currentTimeMillis() - clientChannelInfo.getLastUpdateTimestamp();
if (diff > CHANNEL_EXPIRED_TIMEOUT) {
log.warn(
- "SCAN: remove expired channel from ConsumerManager consumerTable. channel={}, consumerGroup={}",
- RemotingHelper.parseChannelRemoteAddr(clientChannelInfo.getChannel()), group);
+ "SCAN: remove expired channel from ConsumerManager consumerTable. channel={}, consumerGroup={}",
+ RemotingHelper.parseChannelRemoteAddr(clientChannelInfo.getChannel()), group);
RemotingUtil.closeChannel(clientChannelInfo.getChannel());
itChannel.remove();
}
@@ -161,8 +159,8 @@ public class ConsumerManager {
if (channelInfoTable.isEmpty()) {
log.warn(
- "SCAN: remove expired channel from ConsumerManager consumerTable, all clear, consumerGroup={}",
- group);
+ "SCAN: remove expired channel from ConsumerManager consumerTable, all clear, consumerGroup={}",
+ group);
it.remove();
}
}
@@ -174,7 +172,7 @@ public class ConsumerManager {
while (it.hasNext()) {
Entry<String, ConsumerGroupInfo> entry = it.next();
ConcurrentHashMap<String, SubscriptionData> subscriptionTable =
- entry.getValue().getSubscriptionTable();
+ entry.getValue().getSubscriptionTable();
if (subscriptionTable.containsKey(topic)) {
groups.add(entry.getKey());
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java b/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java
index b60fcb3..93f73b8 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java
@@ -6,31 +6,27 @@
* (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
+ * 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.
+ * 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.broker.client;
-import org.apache.rocketmq.broker.BrokerController;
import io.netty.channel.Channel;
-
import java.util.List;
-
+import org.apache.rocketmq.broker.BrokerController;
public class DefaultConsumerIdsChangeListener implements ConsumerIdsChangeListener {
private final BrokerController brokerController;
-
public DefaultConsumerIdsChangeListener(BrokerController brokerController) {
this.brokerController = brokerController;
}
-
@Override
public void consumerIdsChanged(String group, List<Channel> channels) {
if (channels != null && brokerController.getBrokerConfig().isNotifyConsumerIdsChangedEnable()) {
[52/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Delete
unused unit tests.
Posted by yu...@apache.org.
ROCKETMQ-18 Delete unused unit tests.
Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/commit/07a8862c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/tree/07a8862c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/diff/07a8862c
Branch: refs/heads/master
Commit: 07a8862c30f732f18addc74c823c710ca3f21eaf
Parents: de6f941
Author: yukon <yu...@apache.org>
Authored: Tue Dec 27 18:52:24 2016 +0800
Committer: yukon <yu...@apache.org>
Committed: Tue Dec 27 18:52:24 2016 +0800
----------------------------------------------------------------------
.../AllocateMessageQueueAveragelyTest.java | 272 -------------------
.../rocketmq/common/filter/PolishExprTest.java | 67 -----
.../common/protocol/MQProtosHelperTest.java | 25 --
pom.xml | 10 -
.../apache/rocketmq/remoting/ExceptionTest.java | 94 -------
.../rocketmq/remoting/NettyConnectionTest.java | 109 --------
.../apache/rocketmq/remoting/NettyIdleTest.java | 91 -------
.../rocketmq/remoting/SyncInvokeTest.java | 54 ----
.../org/apache/rocketmq/store/RecoverTest.java | 213 ---------------
9 files changed, 935 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/07a8862c/client/src/test/java/org/apache/rocketmq/client/consumer/loadbalance/AllocateMessageQueueAveragelyTest.java
----------------------------------------------------------------------
diff --git a/client/src/test/java/org/apache/rocketmq/client/consumer/loadbalance/AllocateMessageQueueAveragelyTest.java b/client/src/test/java/org/apache/rocketmq/client/consumer/loadbalance/AllocateMessageQueueAveragelyTest.java
deleted file mode 100644
index 7b568c5..0000000
--- a/client/src/test/java/org/apache/rocketmq/client/consumer/loadbalance/AllocateMessageQueueAveragelyTest.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/**
- * 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.
- */
-
-/*
- * @author yubao.fyb@taoboa.com
- * @version $id$
- */
-package org.apache.rocketmq.client.consumer.loadbalance;
-
-import org.apache.rocketmq.client.consumer.AllocateMessageQueueStrategy;
-import org.apache.rocketmq.client.consumer.rebalance.AllocateMessageQueueAveragely;
-import org.apache.rocketmq.client.consumer.rebalance.AllocateMessageQueueAveragelyByCircle;
-import org.apache.rocketmq.common.message.MessageQueue;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * @author yubao.fyb@alibaba-inc.com created on 2013-07-03 16:24
- */
-public class AllocateMessageQueueAveragelyTest {
- private AllocateMessageQueueStrategy allocateMessageQueueAveragely;
- private String currentCID;
- private String topic;
- private List<MessageQueue> messageQueueList;
- private List<String> consumerIdList;
-
- @Before
- public void init() {
- allocateMessageQueueAveragely = new AllocateMessageQueueAveragely();
- topic = "topic_test";
- }
-
- @Test
- public void testConsumer1() {
- currentCID = "0";
- createConsumerIdList(1);
- createMessageQueueList(5);
- List<MessageQueue> result =
- allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
- printMessageQueue(result, "testConsumer1");
- Assert.assertEquals(result.size(), 5);
- Assert.assertEquals(result.containsAll(getMessageQueueList()), true);
- }
-
- public void createConsumerIdList(int size) {
- consumerIdList = new ArrayList<String>(size);
- for (int i = 0; i < size; i++) {
- consumerIdList.add(String.valueOf(i));
- }
- }
-
- public void createMessageQueueList(int size) {
- messageQueueList = new ArrayList<MessageQueue>(size);
- for (int i = 0; i < size; i++) {
- MessageQueue mq = new MessageQueue(topic, "brokerName", i);
- messageQueueList.add(mq);
- }
- }
-
- public void printMessageQueue(List<MessageQueue> messageQueueList, String name) {
- if (messageQueueList == null || messageQueueList.size() < 1)
- return;
- System.out.println(name + ".......................................start");
- for (MessageQueue messageQueue : messageQueueList) {
- System.out.println(messageQueue);
- }
- System.out.println(name + ".......................................end");
- }
-
- public List<MessageQueue> getMessageQueueList() {
- return messageQueueList;
- }
-
- public void setMessageQueueList(List<MessageQueue> messageQueueList) {
- this.messageQueueList = messageQueueList;
- }
-
- @Test
- public void testConsumer2() {
- currentCID = "1";
- createConsumerIdList(2);
- createMessageQueueList(5);
- List<MessageQueue> result =
- allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
- printMessageQueue(result, "testConsumer2");
- Assert.assertEquals(result.size(), 3);
- Assert.assertEquals(result.containsAll(getMessageQueueList().subList(2, 5)), true);
-
- }
-
- @Test
- public void testConsumer3CurrentCID0() {
- currentCID = "0";
- createConsumerIdList(3);
- createMessageQueueList(5);
- List<MessageQueue> result =
- allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
- printMessageQueue(result, "testConsumer3CurrentCID0");
- Assert.assertEquals(result.size(), 1);
- Assert.assertEquals(result.containsAll(getMessageQueueList().subList(0, 1)), true);
- }
-
- @Test
- public void testConsumer3CurrentCID1() {
- currentCID = "1";
- createConsumerIdList(3);
- createMessageQueueList(5);
- List<MessageQueue> result =
- allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
- printMessageQueue(result, "testConsumer3CurrentCID1");
- Assert.assertEquals(result.size(), 1);
- Assert.assertEquals(result.containsAll(getMessageQueueList().subList(1, 2)), true);
- }
-
- @Test
- public void testConsumer3CurrentCID2() {
- currentCID = "2";
- createConsumerIdList(3);
- createMessageQueueList(5);
- List<MessageQueue> result =
- allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
- printMessageQueue(result, "testConsumer3CurrentCID2");
- Assert.assertEquals(result.size(), 3);
- Assert.assertEquals(result.containsAll(getMessageQueueList().subList(2, 5)), true);
- }
-
- @Test
- public void testConsumer4() {
- currentCID = "1";
- createConsumerIdList(4);
- createMessageQueueList(5);
- List<MessageQueue> result =
- allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
- printMessageQueue(result, "testConsumer4");
- Assert.assertEquals(result.size(), 1);
- Assert.assertEquals(result.containsAll(getMessageQueueList().subList(1, 2)), true);
- }
-
- @Test
- public void testConsumer5() {
- currentCID = "1";
- createConsumerIdList(5);
- createMessageQueueList(5);
- List<MessageQueue> result =
- allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
- printMessageQueue(result, "testConsumer5");
- Assert.assertEquals(result.size(), 1);
- Assert.assertEquals(result.containsAll(getMessageQueueList().subList(1, 2)), true);
- }
-
- @Test
- public void testConsumer6() {
- currentCID = "1";
- createConsumerIdList(2);
- createMessageQueueList(6);
- List<MessageQueue> result =
- allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
- printMessageQueue(result, "testConsumer");
- Assert.assertEquals(result.size(), 3);
- Assert.assertEquals(result.containsAll(getMessageQueueList().subList(3, 6)), true);
- }
-
- @Test
- public void testCurrentCIDNotExists() {
- currentCID = String.valueOf(Integer.MAX_VALUE);
- createConsumerIdList(2);
- createMessageQueueList(6);
- List<MessageQueue> result =
- allocateMessageQueueAveragely.allocate("", currentCID, messageQueueList, consumerIdList);
- printMessageQueue(result, "testCurrentCIDNotExists");
- Assert.assertEquals(result.size(), 0);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testCurrentCIDIllegalArgument() {
- createConsumerIdList(2);
- createMessageQueueList(6);
- allocateMessageQueueAveragely.allocate("", "", getMessageQueueList(), getConsumerIdList());
- }
-
- public List<String> getConsumerIdList() {
- return consumerIdList;
- }
-
- public void setConsumerIdList(List<String> consumerIdList) {
- this.consumerIdList = consumerIdList;
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testMessageQueueIllegalArgument() {
- currentCID = "0";
- createConsumerIdList(2);
- allocateMessageQueueAveragely.allocate("", currentCID, null, getConsumerIdList());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testConsumerIdIllegalArgument() {
- currentCID = "0";
- createMessageQueueList(6);
- allocateMessageQueueAveragely.allocate("", currentCID, getMessageQueueList(), null);
- }
-
- @Test
- public void testAllocate() {
- AllocateMessageQueueAveragely allocateMessageQueueAveragely = new AllocateMessageQueueAveragely();
- String topic = "topic_test";
- String currentCID = "CID";
- int queueSize = 19;
- int consumerSize = 10;
- List<MessageQueue> mqAll = new ArrayList<MessageQueue>();
- for (int i = 0; i < queueSize; i++) {
- MessageQueue mq = new MessageQueue(topic, "brokerName", i);
- mqAll.add(mq);
- }
-
- List<String> cidAll = new ArrayList<String>();
- for (int j = 0; j < consumerSize; j++) {
- cidAll.add("CID" + j);
- }
- System.out.println(mqAll.toString());
- System.out.println(cidAll.toString());
- for (int i = 0; i < consumerSize; i++) {
- List<MessageQueue> rs = allocateMessageQueueAveragely.allocate("", currentCID + i, mqAll, cidAll);
- System.out.println("rs[" + currentCID + i + "]:" + rs.toString());
- }
- }
-
-
- @Test
- public void testAllocateByCircle() {
- AllocateMessageQueueAveragelyByCircle circle = new AllocateMessageQueueAveragelyByCircle();
- String topic = "topic_test";
- String currentCID = "CID";
- int consumerSize = 3;
- int queueSize = 13;
- List<MessageQueue> mqAll = new ArrayList<MessageQueue>();
- for (int i = 0; i < queueSize; i++) {
- MessageQueue mq = new MessageQueue(topic, "brokerName", i);
- mqAll.add(mq);
- }
-
- List<String> cidAll = new ArrayList<String>();
- for (int j = 0; j < consumerSize; j++) {
- cidAll.add("CID" + j);
- }
- System.out.println(mqAll.toString());
- System.out.println(cidAll.toString());
- for (int i = 0; i < consumerSize; i++) {
- List<MessageQueue> rs = circle.allocate("", currentCID + i, mqAll, cidAll);
- System.out.println("rs[" + currentCID + i + "]:" + rs.toString());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/07a8862c/common/src/test/java/org/apache/rocketmq/common/filter/PolishExprTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/rocketmq/common/filter/PolishExprTest.java b/common/src/test/java/org/apache/rocketmq/common/filter/PolishExprTest.java
deleted file mode 100644
index f2ba2a3..0000000
--- a/common/src/test/java/org/apache/rocketmq/common/filter/PolishExprTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * 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.common.filter;
-
-import org.apache.rocketmq.common.filter.impl.Op;
-import org.apache.rocketmq.common.filter.impl.PolishExpr;
-import junit.framework.Assert;
-import org.junit.Test;
-
-import java.util.List;
-
-
-/**
- * @author lansheng.zj
- */
-public class PolishExprTest {
-
- private String expression = "tag1||(tag2&&tag3)&&tag4||tag5&&(tag6 && tag7)|| tag8 && tag9";
- private PolishExpr polishExpr;
-
-
- public void init() {
- polishExpr = new PolishExpr();
- }
-
-
- @Test
- public void testReversePolish() {
- List<Op> antiPolishExpression = polishExpr.reversePolish(expression);
- System.out.println(antiPolishExpression);
- }
-
-
- @Test
- public void testReversePolish_Performance() {
- // prepare
- for (int i = 0; i < 100000; i++) {
- polishExpr.reversePolish(expression);
- }
-
- long start = System.currentTimeMillis();
- for (int i = 0; i < 100000; i++) {
- polishExpr.reversePolish(expression);
- }
- long cost = System.currentTimeMillis() - start;
- System.out.println(cost);
- // System.out.println(cost / 100000F);
-
- Assert.assertTrue(cost < 500);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/07a8862c/common/src/test/java/org/apache/rocketmq/common/protocol/MQProtosHelperTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/rocketmq/common/protocol/MQProtosHelperTest.java b/common/src/test/java/org/apache/rocketmq/common/protocol/MQProtosHelperTest.java
deleted file mode 100644
index cd56627..0000000
--- a/common/src/test/java/org/apache/rocketmq/common/protocol/MQProtosHelperTest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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.common.protocol;
-
-/**
- * @author shijia.wxr
- */
-public class MQProtosHelperTest {
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/07a8862c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 8812213..39ea763 100644
--- a/pom.xml
+++ b/pom.xml
@@ -233,16 +233,6 @@
<includes>
<include>**/*Test.java</include>
</includes>
- <excludes>
- <exclude>org/apache/rocketmq/remoting/ExceptionTest.java</exclude>
- <exclude>org/apache/rocketmq/remoting/SyncInvokeTest.java</exclude>
- <exclude>org/apache/rocketmq/remoting/NettyIdleTest.java</exclude>
- <exclude>org/apache/rocketmq/remoting/NettyConnectionTest.java</exclude>
- <exclude>org/apache/rocketmq/common/filter/PolishExprTest.java</exclude>
- <exclude>org/apache/rocketmq/common/protocol/MQProtosHelperTest.java</exclude>
- <exclude>org/apache/rocketmq/client/consumer/loadbalance/AllocateMessageQueueAveragelyTest.java</exclude>
- <exclude>org/apache/rocketmq/store/RecoverTest.java</exclude>
- </excludes>
</configuration>
</plugin>
<plugin>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/07a8862c/remoting/src/test/java/org/apache/rocketmq/remoting/ExceptionTest.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/ExceptionTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/ExceptionTest.java
deleted file mode 100644
index d5c1f37..0000000
--- a/remoting/src/test/java/org/apache/rocketmq/remoting/ExceptionTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: ExceptionTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
- */
-package org.apache.rocketmq.remoting;
-
-import org.apache.rocketmq.remoting.exception.RemotingConnectException;
-import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
-import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
-import org.apache.rocketmq.remoting.netty.*;
-import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-import io.netty.channel.ChannelHandlerContext;
-import org.junit.Test;
-
-import java.util.concurrent.Executors;
-
-import static org.junit.Assert.assertTrue;
-
-
-/**
- * @author shijia.wxr
- */
-public class ExceptionTest {
- private static RemotingServer createRemotingServer() throws InterruptedException {
- NettyServerConfig config = new NettyServerConfig();
- RemotingServer client = new NettyRemotingServer(config);
- client.registerProcessor(0, new NettyRequestProcessor() {
- private int i = 0;
-
-
- @Override
- public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) {
- System.out.println("processRequest=" + request + " " + (i++));
- request.setRemark("hello, I am respponse " + ctx.channel().remoteAddress());
- return request;
- }
-
- @Override
- public boolean rejectRequest() {
- return false;
- }
- }, Executors.newCachedThreadPool());
- client.start();
- return client;
- }
-
- @Test
- public void test_CONNECT_EXCEPTION() {
- RemotingClient client = createRemotingClient();
-
- RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
- RemotingCommand response = null;
- try {
- response = client.invokeSync("localhost:8888", request, 1000 * 3);
- } catch (RemotingConnectException e) {
- e.printStackTrace();
- } catch (RemotingSendRequestException e) {
- e.printStackTrace();
- } catch (RemotingTimeoutException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- System.out.println("invoke result = " + response);
- assertTrue(null == response);
-
- client.shutdown();
- System.out.println("-----------------------------------------------------------------");
- }
-
- private static RemotingClient createRemotingClient() {
- NettyClientConfig config = new NettyClientConfig();
- RemotingClient client = new NettyRemotingClient(config);
- client.start();
- return client;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/07a8862c/remoting/src/test/java/org/apache/rocketmq/remoting/NettyConnectionTest.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/NettyConnectionTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/NettyConnectionTest.java
deleted file mode 100644
index 3ceba50..0000000
--- a/remoting/src/test/java/org/apache/rocketmq/remoting/NettyConnectionTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * 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.remoting;
-
-import org.apache.rocketmq.remoting.exception.RemotingConnectException;
-import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
-import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
-import org.apache.rocketmq.remoting.netty.NettyClientConfig;
-import org.apache.rocketmq.remoting.netty.NettyRemotingClient;
-import org.apache.rocketmq.remoting.netty.ResponseFuture;
-import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-
-/**
-
- *
- * @author shijia.wxr
- *
- */
-public class NettyConnectionTest {
- @Test
- public void test_connect_timeout() throws InterruptedException, RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException {
- RemotingClient client = createRemotingClient();
-
- for (int i = 0; i < 100; i++) {
- try {
- RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
- RemotingCommand response = client.invokeSync("localhost:8888", request, 1000 * 3);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- client.shutdown();
- System.out.println("-----------------------------------------------------------------");
- }
-
- @Test
- public void test_async_timeout() throws InterruptedException, RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException {
- RemotingClient client = createRemotingClient();
- final AtomicInteger ai = new AtomicInteger(0);
- final CountDownLatch latch = new CountDownLatch(100);
- for (int i = 0; i < 100; i++) {
- try {
- RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
- client.invokeAsync("localhost:8888", request, 5, new InvokeCallback() {//very easy to timeout
- @Override
- public void operationComplete(ResponseFuture responseFuture) {
- if (responseFuture.isTimeout()) {
- if (ai.getAndIncrement() == 4) {
- try {
- System.out.println("First try timeout, blocking 10s" + Thread.currentThread().getName());
- Thread.sleep(10 * 1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- } else {
- System.out.println("Timeout callback execute,very short." + Thread.currentThread().getName());
- }
- } else {
- System.out.println("Success." + Thread.currentThread().getName());
- }
- latch.countDown();
-
- }
- });
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
-
- latch.await(1000, TimeUnit.MILLISECONDS);
- Assert.assertEquals(1, latch.getCount());//only one should be blocked
- client.shutdown();
- System.out.println("-----------------------------------------------------------------");
- }
-
- public static RemotingClient createRemotingClient() {
- NettyClientConfig config = new NettyClientConfig();
- config.setClientChannelMaxIdleTimeSeconds(15);
- RemotingClient client = new NettyRemotingClient(config);
- client.start();
- return client;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/07a8862c/remoting/src/test/java/org/apache/rocketmq/remoting/NettyIdleTest.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/NettyIdleTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/NettyIdleTest.java
deleted file mode 100644
index 741dc14..0000000
--- a/remoting/src/test/java/org/apache/rocketmq/remoting/NettyIdleTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * 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.remoting;
-
-import org.apache.rocketmq.remoting.exception.RemotingConnectException;
-import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
-import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
-import org.apache.rocketmq.remoting.netty.*;
-import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-import io.netty.channel.ChannelHandlerContext;
-
-import java.util.concurrent.Executors;
-
-import static org.junit.Assert.assertTrue;
-
-
-/**
- * @author shijia.wxr
- *
- */
-public class NettyIdleTest {
- // @Test
- public void test_idle_event() throws InterruptedException, RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException {
- RemotingServer server = createRemotingServer();
- RemotingClient client = createRemotingClient();
-
- for (int i = 0; i < 10; i++) {
- RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
- RemotingCommand response = client.invokeSync("localhost:8888", request, 1000 * 3);
- System.out.println(i + " invoke result = " + response);
- assertTrue(response != null);
-
- Thread.sleep(1000 * 10);
- }
-
- Thread.sleep(1000 * 60);
-
- client.shutdown();
- server.shutdown();
- System.out.println("-----------------------------------------------------------------");
- }
-
- public static RemotingServer createRemotingServer() throws InterruptedException {
- NettyServerConfig config = new NettyServerConfig();
- config.setServerChannelMaxIdleTimeSeconds(30);
- RemotingServer remotingServer = new NettyRemotingServer(config);
- remotingServer.registerProcessor(0, new NettyRequestProcessor() {
- private int i = 0;
-
-
- @Override
- public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) {
- System.out.println("processRequest=" + request + " " + (i++));
- request.setRemark("hello, I am respponse " + ctx.channel().remoteAddress());
- return request;
- }
-
- @Override
- public boolean rejectRequest() {
- return false;
- }
- }, Executors.newCachedThreadPool());
- remotingServer.start();
- return remotingServer;
- }
-
- public static RemotingClient createRemotingClient() {
- NettyClientConfig config = new NettyClientConfig();
- config.setClientChannelMaxIdleTimeSeconds(15);
- RemotingClient client = new NettyRemotingClient(config);
- client.start();
- return client;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/07a8862c/remoting/src/test/java/org/apache/rocketmq/remoting/SyncInvokeTest.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/SyncInvokeTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/SyncInvokeTest.java
deleted file mode 100644
index 6d454f4..0000000
--- a/remoting/src/test/java/org/apache/rocketmq/remoting/SyncInvokeTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: SyncInvokeTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
- */
-package org.apache.rocketmq.remoting;
-
-import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-
-/**
- * @author shijia.wxr
- */
-public class SyncInvokeTest {
- @Test
- public void test_RPC_Sync() throws Exception {
- RemotingServer server = NettyRPCTest.createRemotingServer();
- RemotingClient client = NettyRPCTest.createRemotingClient();
-
- for (int i = 0; i < 100; i++) {
- try {
- RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
- RemotingCommand response = client.invokeSync("localhost:8888", request, 1000 * 3);
- System.out.println(i + "\t" + "invoke result = " + response);
- assertTrue(response != null);
- } catch (Exception e) {
- e.printStackTrace();
- throw e;
- }
- }
-
- client.shutdown();
- server.shutdown();
- System.out.println("-----------------------------------------------------------------");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/07a8862c/store/src/test/java/org/apache/rocketmq/store/RecoverTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/RecoverTest.java b/store/src/test/java/org/apache/rocketmq/store/RecoverTest.java
deleted file mode 100644
index 699422c..0000000
--- a/store/src/test/java/org/apache/rocketmq/store/RecoverTest.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: RecoverTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
- */
-package org.apache.rocketmq.store;
-
-import org.apache.rocketmq.common.message.MessageDecoder;
-import org.apache.rocketmq.common.message.MessageExt;
-import org.apache.rocketmq.store.config.MessageStoreConfig;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.nio.ByteBuffer;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
-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";
-
- private static int QUEUE_TOTAL = 10;
-
- private static AtomicInteger QueueId = new AtomicInteger(0);
-
- private static SocketAddress BornHost;
-
- private static SocketAddress StoreHost;
-
- private static byte[] MessageBody;
- private MessageStore storeWrite1;
- private MessageStore storeWrite2;
- private MessageStore storeRead;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- StoreHost = new InetSocketAddress(InetAddress.getLocalHost(), 8123);
- BornHost = new InetSocketAddress(InetAddress.getByName("127.0.0.1"), 0);
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
-
- @Test
- public void test_recover_normally() throws Exception {
- this.writeMessage(true, true);
- Thread.sleep(1000 * 3);
- this.readMessage(1000);
- this.destroy();
- }
-
- public void writeMessage(boolean normal, boolean first) throws Exception {
- System.out.println("================================================================");
- long totalMsgs = 100;
- QUEUE_TOTAL = 3;
-
- MessageBody = StoreMessage.getBytes();
- MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
- messageStoreConfig.setMapedFileSizeCommitLog(1024 * 32);
- messageStoreConfig.setMapedFileSizeConsumeQueue(100 * 20);
- messageStoreConfig.setMessageIndexEnable(false);
-
- MessageStore messageStore = new DefaultMessageStore(messageStoreConfig, null, null, null);
- if (first) {
- this.storeWrite1 = messageStore;
- } else {
- this.storeWrite2 = messageStore;
- }
-
- boolean loadResult = messageStore.load();
- assertTrue(loadResult);
- messageStore.start();
- for (long i = 0; i < totalMsgs; i++) {
- PutMessageResult result = messageStore.putMessage(buildMessage());
- System.out.println(i + "\t" + result.getAppendMessageResult().getMsgId());
- }
-
- if (normal) {
- messageStore.shutdown();
- }
- System.out.println("========================writeMessage OK========================================");
- }
-
- public void readMessage(final long msgCnt) throws Exception {
- System.out.println("================================================================");
- QUEUE_TOTAL = 3;
- MessageBody = StoreMessage.getBytes();
- MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
- messageStoreConfig.setMapedFileSizeCommitLog(1024 * 32);
- messageStoreConfig.setMapedFileSizeConsumeQueue(100 * 20);
- messageStoreConfig.setMessageIndexEnable(false);
- storeRead = new DefaultMessageStore(messageStoreConfig, null, null, null);
- boolean loadResult = storeRead.load();
- assertTrue(loadResult);
- storeRead.start();
-
- long readCnt = 0;
- for (int queueId = 0; queueId < QUEUE_TOTAL; queueId++) {
- for (long offset = 0; ; ) {
- GetMessageResult result = storeRead.getMessage("GROUP_A", "TOPIC_A", queueId, offset, 1024 * 1024, null);
- if (result.getStatus() == GetMessageStatus.FOUND) {
- System.out.println(queueId + "\t" + result.getMessageCount());
- this.veryReadMessage(queueId, offset, result.getMessageBufferList());
- offset += result.getMessageCount();
- readCnt += result.getMessageCount();
- result.release();
- } else {
- break;
- }
- }
- }
-
- System.out.println("readCnt = " + readCnt);
- assertTrue(readCnt == msgCnt);
- System.out.println("========================readMessage OK========================================");
- }
-
- private void destroy() {
- if (storeWrite1 != null) {
- storeWrite1.shutdown();
- storeWrite1.destroy();
- }
-
- if (storeWrite2 != null) {
- storeWrite2.shutdown();
- storeWrite2.destroy();
- }
-
- if (storeRead != null) {
- storeRead.shutdown();
- storeRead.destroy();
- }
- }
-
- public MessageExtBrokerInner buildMessage() {
- MessageExtBrokerInner msg = new MessageExtBrokerInner();
- msg.setTopic("TOPIC_A");
- msg.setTags("TAG1");
- msg.setKeys("Hello");
- msg.setBody(MessageBody);
- msg.setKeys(String.valueOf(System.currentTimeMillis()));
- msg.setQueueId(Math.abs(QueueId.getAndIncrement()) % QUEUE_TOTAL);
- msg.setSysFlag(4);
- msg.setBornTimestamp(System.currentTimeMillis());
- msg.setStoreHost(StoreHost);
- msg.setBornHost(BornHost);
-
- return msg;
- }
-
- private void veryReadMessage(int queueId, long queueOffset, List<ByteBuffer> byteBuffers) {
- for (ByteBuffer byteBuffer : byteBuffers) {
- MessageExt msg = MessageDecoder.decode(byteBuffer);
- System.out.println("request queueId " + queueId + ", request queueOffset " + queueOffset + " msg queue offset "
- + msg.getQueueOffset());
-
- assertTrue(msg.getQueueOffset() == queueOffset);
-
- queueOffset++;
- }
- }
-
- @Test
- public void test_recover_normally_write() throws Exception {
- this.writeMessage(true, true);
- Thread.sleep(1000 * 3);
- this.writeMessage(true, false);
- Thread.sleep(1000 * 3);
- this.readMessage(2000);
- this.destroy();
- }
-
- @Test
- public void test_recover_abnormally() throws Exception {
- this.writeMessage(false, true);
- Thread.sleep(1000 * 3);
- this.readMessage(1000);
- this.destroy();
- }
-
- @Test
- public void test_recover_abnormally_write() throws Exception {
- this.writeMessage(false, true);
- Thread.sleep(1000 * 3);
- this.writeMessage(false, false);
- Thread.sleep(1000 * 3);
- this.readMessage(2000);
- this.destroy();
- }
-}
[93/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java
index 0f9954b..3047faf 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java
@@ -6,23 +6,17 @@
* (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
+ * 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.
+ * 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.broker.client;
-import org.apache.rocketmq.common.constant.LoggerName;
-import org.apache.rocketmq.remoting.common.RemotingHelper;
-import org.apache.rocketmq.remoting.common.RemotingUtil;
import io.netty.channel.Channel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -30,7 +24,11 @@ import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.common.RemotingUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ProducerManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
@@ -38,16 +36,14 @@ public class ProducerManager {
private static final long CHANNEL_EXPIRED_TIMEOUT = 1000 * 120;
private final Lock groupChannelLock = new ReentrantLock();
private final HashMap<String /* group name */, HashMap<Channel, ClientChannelInfo>> groupChannelTable =
- new HashMap<String, HashMap<Channel, ClientChannelInfo>>();
-
+ new HashMap<String, HashMap<Channel, ClientChannelInfo>>();
public ProducerManager() {
}
-
public HashMap<String, HashMap<Channel, ClientChannelInfo>> getGroupChannelTable() {
HashMap<String /* group name */, HashMap<Channel, ClientChannelInfo>> newGroupChannelTable =
- new HashMap<String, HashMap<Channel, ClientChannelInfo>>();
+ new HashMap<String, HashMap<Channel, ClientChannelInfo>>();
try {
if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
try {
@@ -62,13 +58,12 @@ public class ProducerManager {
return newGroupChannelTable;
}
-
public void scanNotActiveChannel() {
try {
if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
try {
for (final Map.Entry<String, HashMap<Channel, ClientChannelInfo>> entry : this.groupChannelTable
- .entrySet()) {
+ .entrySet()) {
final String group = entry.getKey();
final HashMap<Channel, ClientChannelInfo> chlMap = entry.getValue();
@@ -82,8 +77,8 @@ public class ProducerManager {
if (diff > CHANNEL_EXPIRED_TIMEOUT) {
it.remove();
log.warn(
- "SCAN: remove expired channel[{}] from ProducerManager groupChannelTable, producer group name: {}",
- RemotingHelper.parseChannelRemoteAddr(info.getChannel()), group);
+ "SCAN: remove expired channel[{}] from ProducerManager groupChannelTable, producer group name: {}",
+ RemotingHelper.parseChannelRemoteAddr(info.getChannel()), group);
RemotingUtil.closeChannel(info.getChannel());
}
}
@@ -99,23 +94,22 @@ public class ProducerManager {
}
}
-
public void doChannelCloseEvent(final String remoteAddr, final Channel channel) {
if (channel != null) {
try {
if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
try {
for (final Map.Entry<String, HashMap<Channel, ClientChannelInfo>> entry : this.groupChannelTable
- .entrySet()) {
+ .entrySet()) {
final String group = entry.getKey();
final HashMap<Channel, ClientChannelInfo> clientChannelInfoTable =
- entry.getValue();
+ entry.getValue();
final ClientChannelInfo clientChannelInfo =
- clientChannelInfoTable.remove(channel);
+ clientChannelInfoTable.remove(channel);
if (clientChannelInfo != null) {
log.info(
- "NETTY EVENT: remove channel[{}][{}] from ProducerManager groupChannelTable, producer group: {}",
- clientChannelInfo.toString(), remoteAddr, group);
+ "NETTY EVENT: remove channel[{}][{}] from ProducerManager groupChannelTable, producer group: {}",
+ clientChannelInfo.toString(), remoteAddr, group);
}
}
@@ -131,7 +125,6 @@ public class ProducerManager {
}
}
-
public void registerProducer(final String group, final ClientChannelInfo clientChannelInfo) {
try {
ClientChannelInfo clientChannelInfoFound = null;
@@ -148,7 +141,7 @@ public class ProducerManager {
if (null == clientChannelInfoFound) {
channelTable.put(clientChannelInfo.getChannel(), clientChannelInfo);
log.info("new producer connected, group: {} channel: {}", group,
- clientChannelInfo.toString());
+ clientChannelInfo.toString());
}
} finally {
this.groupChannelLock.unlock();
@@ -165,7 +158,6 @@ public class ProducerManager {
}
}
-
public void unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo) {
try {
if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
@@ -175,7 +167,7 @@ public class ProducerManager {
ClientChannelInfo old = channelTable.remove(clientChannelInfo.getChannel());
if (old != null) {
log.info("unregister a producer[{}] from groupChannelTable {}", group,
- clientChannelInfo.toString());
+ clientChannelInfo.toString());
}
if (channelTable.isEmpty()) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java b/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
index 40eff81..f6d7955 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
@@ -16,6 +16,16 @@
*/
package org.apache.rocketmq.broker.client.net;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelFutureListener;
+import io.netty.channel.FileRegion;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.rocketmq.broker.BrokerController;
import org.apache.rocketmq.broker.client.ClientChannelInfo;
import org.apache.rocketmq.broker.client.ConsumerGroupInfo;
@@ -40,21 +50,9 @@ import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.apache.rocketmq.store.SelectMappedBufferResult;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelFutureListener;
-import io.netty.channel.FileRegion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-
-
public class Broker2Client {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final BrokerController brokerController;
@@ -64,17 +62,17 @@ public class Broker2Client {
}
public void checkProducerTransactionState(
- final Channel channel,
- final CheckTransactionStateRequestHeader requestHeader,
- final SelectMappedBufferResult selectMappedBufferResult) {
+ final Channel channel,
+ final CheckTransactionStateRequestHeader requestHeader,
+ final SelectMappedBufferResult selectMappedBufferResult) {
RemotingCommand request =
- RemotingCommand.createRequestCommand(RequestCode.CHECK_TRANSACTION_STATE, requestHeader);
+ RemotingCommand.createRequestCommand(RequestCode.CHECK_TRANSACTION_STATE, requestHeader);
request.markOnewayRPC();
try {
FileRegion fileRegion =
- new OneMessageTransfer(request.encodeHeader(selectMappedBufferResult.getSize()),
- selectMappedBufferResult);
+ new OneMessageTransfer(request.encodeHeader(selectMappedBufferResult.getSize()),
+ selectMappedBufferResult);
channel.writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
@@ -91,14 +89,14 @@ public class Broker2Client {
}
public RemotingCommand callClient(final Channel channel,
- final RemotingCommand request
+ final RemotingCommand request
) throws RemotingSendRequestException, RemotingTimeoutException, InterruptedException {
return this.brokerController.getRemotingServer().invokeSync(channel, request, 10000);
}
public void notifyConsumerIdsChanged(
- final Channel channel,
- final String consumerGroup) {
+ final Channel channel,
+ final String consumerGroup) {
if (null == consumerGroup) {
log.error("notifyConsumerIdsChanged consumerGroup is null");
return;
@@ -107,7 +105,7 @@ public class Broker2Client {
NotifyConsumerIdsChangedRequestHeader requestHeader = new NotifyConsumerIdsChangedRequestHeader();
requestHeader.setConsumerGroup(consumerGroup);
RemotingCommand request =
- RemotingCommand.createRequestCommand(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, requestHeader);
+ RemotingCommand.createRequestCommand(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, requestHeader);
try {
this.brokerController.getRemotingServer().invokeOneway(channel, request, 10);
@@ -121,7 +119,7 @@ public class Broker2Client {
}
public RemotingCommand resetOffset(String topic, String group, long timeStamp, boolean isForce,
- boolean isC) {
+ boolean isC) {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
@@ -141,7 +139,7 @@ public class Broker2Client {
mq.setQueueId(i);
long consumerOffset =
- this.brokerController.getConsumerOffsetManager().queryOffset(group, topic, i);
+ this.brokerController.getConsumerOffsetManager().queryOffset(group, topic, i);
if (-1 == consumerOffset) {
response.setCode(ResponseCode.SYSTEM_ERROR);
response.setRemark(String.format("THe consumer group <%s> not exist", group));
@@ -173,7 +171,7 @@ public class Broker2Client {
requestHeader.setGroup(group);
requestHeader.setTimestamp(timeStamp);
RemotingCommand request =
- RemotingCommand.createRequestCommand(RequestCode.RESET_CONSUMER_CLIENT_OFFSET, requestHeader);
+ RemotingCommand.createRequestCommand(RequestCode.RESET_CONSUMER_CLIENT_OFFSET, requestHeader);
if (isC) {
// c++ language
ResetOffsetBodyForC body = new ResetOffsetBodyForC();
@@ -188,37 +186,37 @@ public class Broker2Client {
}
ConsumerGroupInfo consumerGroupInfo =
- this.brokerController.getConsumerManager().getConsumerGroupInfo(group);
+ this.brokerController.getConsumerManager().getConsumerGroupInfo(group);
if (consumerGroupInfo != null && !consumerGroupInfo.getAllChannel().isEmpty()) {
ConcurrentHashMap<Channel, ClientChannelInfo> channelInfoTable =
- consumerGroupInfo.getChannelInfoTable();
+ consumerGroupInfo.getChannelInfoTable();
for (Map.Entry<Channel, ClientChannelInfo> entry : channelInfoTable.entrySet()) {
int version = entry.getValue().getVersion();
if (version >= MQVersion.Version.V3_0_7_SNAPSHOT.ordinal()) {
try {
this.brokerController.getRemotingServer().invokeOneway(entry.getKey(), request, 5000);
log.info("[reset-offset] reset offset success. topic={}, group={}, clientId={}",
- topic, group, entry.getValue().getClientId());
+ topic, group, entry.getValue().getClientId());
} catch (Exception e) {
log.error("[reset-offset] reset offset exception. topic={}, group={}",
- new Object[]{topic, group}, e);
+ new Object[] {topic, group}, e);
}
} else {
response.setCode(ResponseCode.SYSTEM_ERROR);
response.setRemark("the client does not support this feature. version="
- + MQVersion.getVersionDesc(version));
+ + MQVersion.getVersionDesc(version));
log.warn("[reset-offset] the client does not support this feature. version={}",
- RemotingHelper.parseChannelRemoteAddr(entry.getKey()), MQVersion.getVersionDesc(version));
+ RemotingHelper.parseChannelRemoteAddr(entry.getKey()), MQVersion.getVersionDesc(version));
return response;
}
}
} else {
String errorInfo =
- String.format("Consumer not online, so can not reset offset, Group: %s Topic: %s Timestamp: %d",
- requestHeader.getGroup(),
- requestHeader.getTopic(),
- requestHeader.getTimestamp());
+ String.format("Consumer not online, so can not reset offset, Group: %s Topic: %s Timestamp: %d",
+ requestHeader.getGroup(),
+ requestHeader.getTopic(),
+ requestHeader.getTimestamp());
log.error(errorInfo);
response.setCode(ResponseCode.CONSUMER_NOT_ONLINE);
response.setRemark(errorInfo);
@@ -236,7 +234,7 @@ public class Broker2Client {
for (Entry<MessageQueue, Long> entry : table.entrySet()) {
MessageQueue mq = entry.getKey();
MessageQueueForC tmp =
- new MessageQueueForC(mq.getTopic(), mq.getBrokerName(), mq.getQueueId(), entry.getValue());
+ new MessageQueueForC(mq.getTopic(), mq.getBrokerName(), mq.getQueueId(), entry.getValue());
list.add(tmp);
}
return list;
@@ -249,13 +247,13 @@ public class Broker2Client {
requestHeader.setTopic(topic);
requestHeader.setGroup(group);
RemotingCommand request =
- RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT,
- requestHeader);
+ RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT,
+ requestHeader);
Map<String, Map<MessageQueue, Long>> consumerStatusTable =
- new HashMap<String, Map<MessageQueue, Long>>();
+ new HashMap<String, Map<MessageQueue, Long>>();
ConcurrentHashMap<Channel, ClientChannelInfo> channelInfoTable =
- this.brokerController.getConsumerManager().getConsumerGroupInfo(group).getChannelInfoTable();
+ this.brokerController.getConsumerManager().getConsumerGroupInfo(group).getChannelInfoTable();
if (null == channelInfoTable || channelInfoTable.isEmpty()) {
result.setCode(ResponseCode.SYSTEM_ERROR);
result.setRemark(String.format("No Any Consumer online in the consumer group: [%s]", group));
@@ -268,26 +266,26 @@ public class Broker2Client {
if (version < MQVersion.Version.V3_0_7_SNAPSHOT.ordinal()) {
result.setCode(ResponseCode.SYSTEM_ERROR);
result.setRemark("the client does not support this feature. version="
- + MQVersion.getVersionDesc(version));
+ + MQVersion.getVersionDesc(version));
log.warn("[get-consumer-status] the client does not support this feature. version={}",
- RemotingHelper.parseChannelRemoteAddr(entry.getKey()), MQVersion.getVersionDesc(version));
+ RemotingHelper.parseChannelRemoteAddr(entry.getKey()), MQVersion.getVersionDesc(version));
return result;
} else if (UtilAll.isBlank(originClientId) || originClientId.equals(clientId)) {
try {
RemotingCommand response =
- this.brokerController.getRemotingServer().invokeSync(entry.getKey(), request, 5000);
+ this.brokerController.getRemotingServer().invokeSync(entry.getKey(), request, 5000);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
if (response.getBody() != null) {
GetConsumerStatusBody body =
- GetConsumerStatusBody.decode(response.getBody(),
- GetConsumerStatusBody.class);
+ GetConsumerStatusBody.decode(response.getBody(),
+ GetConsumerStatusBody.class);
consumerStatusTable.put(clientId, body.getMessageQueueTable());
log.info(
- "[get-consumer-status] get consumer status success. topic={}, group={}, channelRemoteAddr={}",
- topic, group, clientId);
+ "[get-consumer-status] get consumer status success. topic={}, group={}, channelRemoteAddr={}",
+ topic, group, clientId);
}
}
default:
@@ -295,8 +293,8 @@ public class Broker2Client {
}
} catch (Exception e) {
log.error(
- "[get-consumer-status] get consumer status exception. topic={}, group={}, offset={}",
- new Object[]{topic, group}, e);
+ "[get-consumer-status] get consumer status exception. topic={}, group={}, offset={}",
+ new Object[] {topic, group}, e);
}
if (!UtilAll.isBlank(originClientId) && originClientId.equals(clientId)) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java b/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java
index 82ca014..88c044a 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java
@@ -16,25 +16,23 @@
*/
package org.apache.rocketmq.broker.client.rebalance;
-import org.apache.rocketmq.common.constant.LoggerName;
-import org.apache.rocketmq.common.message.MessageQueue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class RebalanceLockManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.REBALANCE_LOCK_LOGGER_NAME);
private final static long REBALANCE_LOCK_MAX_LIVE_TIME = Long.parseLong(System.getProperty(
- "rocketmq.broker.rebalance.lockMaxLiveTime", "60000"));
+ "rocketmq.broker.rebalance.lockMaxLiveTime", "60000"));
private final Lock lock = new ReentrantLock();
private final ConcurrentHashMap<String/* group */, ConcurrentHashMap<MessageQueue, LockEntry>> mqLockTable =
- new ConcurrentHashMap<String, ConcurrentHashMap<MessageQueue, LockEntry>>(1024);
+ new ConcurrentHashMap<String, ConcurrentHashMap<MessageQueue, LockEntry>>(1024);
public boolean tryLock(final String group, final MessageQueue mq, final String clientId) {
@@ -54,9 +52,9 @@ public class RebalanceLockManager {
lockEntry.setClientId(clientId);
groupValue.put(mq, lockEntry);
log.info("tryLock, message queue not locked, I got it. Group: {} NewClientId: {} {}", //
- group, //
- clientId, //
- mq);
+ group, //
+ clientId, //
+ mq);
}
if (lockEntry.isLocked(clientId)) {
@@ -66,26 +64,24 @@ public class RebalanceLockManager {
String oldClientId = lockEntry.getClientId();
-
if (lockEntry.isExpired()) {
lockEntry.setClientId(clientId);
lockEntry.setLastUpdateTimestamp(System.currentTimeMillis());
log.warn(
- "tryLock, message queue lock expired, I got it. Group: {} OldClientId: {} NewClientId: {} {}", //
- group, //
- oldClientId, //
- clientId, //
- mq);
- return true;
- }
-
-
- log.warn(
- "tryLock, message queue locked by other client. Group: {} OtherClientId: {} NewClientId: {} {}", //
+ "tryLock, message queue lock expired, I got it. Group: {} OldClientId: {} NewClientId: {} {}", //
group, //
oldClientId, //
clientId, //
mq);
+ return true;
+ }
+
+ log.warn(
+ "tryLock, message queue locked by other client. Group: {} OtherClientId: {} NewClientId: {} {}", //
+ group, //
+ oldClientId, //
+ clientId, //
+ mq);
return false;
} finally {
this.lock.unlock();
@@ -118,11 +114,10 @@ public class RebalanceLockManager {
}
public Set<MessageQueue> tryLockBatch(final String group, final Set<MessageQueue> mqs,
- final String clientId) {
+ final String clientId) {
Set<MessageQueue> lockedMqs = new HashSet<MessageQueue>(mqs.size());
Set<MessageQueue> notLockedMqs = new HashSet<MessageQueue>(mqs.size());
-
for (MessageQueue mq : mqs) {
if (this.isLocked(group, mq, clientId)) {
lockedMqs.add(mq);
@@ -141,7 +136,6 @@ public class RebalanceLockManager {
this.mqLockTable.put(group, groupValue);
}
-
for (MessageQueue mq : notLockedMqs) {
LockEntry lockEntry = groupValue.get(mq);
if (null == lockEntry) {
@@ -149,13 +143,12 @@ public class RebalanceLockManager {
lockEntry.setClientId(clientId);
groupValue.put(mq, lockEntry);
log.info(
- "tryLockBatch, message queue not locked, I got it. Group: {} NewClientId: {} {}", //
- group, //
- clientId, //
- mq);
+ "tryLockBatch, message queue not locked, I got it. Group: {} NewClientId: {} {}", //
+ group, //
+ clientId, //
+ mq);
}
-
if (lockEntry.isLocked(clientId)) {
lockEntry.setLastUpdateTimestamp(System.currentTimeMillis());
lockedMqs.add(mq);
@@ -164,27 +157,25 @@ public class RebalanceLockManager {
String oldClientId = lockEntry.getClientId();
-
if (lockEntry.isExpired()) {
lockEntry.setClientId(clientId);
lockEntry.setLastUpdateTimestamp(System.currentTimeMillis());
log.warn(
- "tryLockBatch, message queue lock expired, I got it. Group: {} OldClientId: {} NewClientId: {} {}", //
- group, //
- oldClientId, //
- clientId, //
- mq);
+ "tryLockBatch, message queue lock expired, I got it. Group: {} OldClientId: {} NewClientId: {} {}", //
+ group, //
+ oldClientId, //
+ clientId, //
+ mq);
lockedMqs.add(mq);
continue;
}
-
log.warn(
- "tryLockBatch, message queue locked by other client. Group: {} OtherClientId: {} NewClientId: {} {}", //
- group, //
- oldClientId, //
- clientId, //
- mq);
+ "tryLockBatch, message queue locked by other client. Group: {} OtherClientId: {} NewClientId: {} {}", //
+ group, //
+ oldClientId, //
+ clientId, //
+ mq);
}
} finally {
this.lock.unlock();
@@ -209,27 +200,27 @@ public class RebalanceLockManager {
if (lockEntry.getClientId().equals(clientId)) {
groupValue.remove(mq);
log.info("unlockBatch, Group: {} {} {}",
- group,
- mq,
- clientId);
+ group,
+ mq,
+ clientId);
} else {
log.warn("unlockBatch, but mq locked by other client: {}, Group: {} {} {}",
- lockEntry.getClientId(),
- group,
- mq,
- clientId);
- }
- } else {
- log.warn("unlockBatch, but mq not locked, Group: {} {} {}",
+ lockEntry.getClientId(),
group,
mq,
clientId);
+ }
+ } else {
+ log.warn("unlockBatch, but mq not locked, Group: {} {} {}",
+ group,
+ mq,
+ clientId);
}
}
} else {
log.warn("unlockBatch, group not exist, Group: {} {}",
- group,
- clientId);
+ group,
+ clientId);
}
} finally {
this.lock.unlock();
@@ -243,22 +234,18 @@ public class RebalanceLockManager {
private String clientId;
private volatile long lastUpdateTimestamp = System.currentTimeMillis();
-
public String getClientId() {
return clientId;
}
-
public void setClientId(String clientId) {
this.clientId = clientId;
}
-
public long getLastUpdateTimestamp() {
return lastUpdateTimestamp;
}
-
public void setLastUpdateTimestamp(long lastUpdateTimestamp) {
this.lastUpdateTimestamp = lastUpdateTimestamp;
}
@@ -270,7 +257,7 @@ public class RebalanceLockManager {
public boolean isExpired() {
boolean expired =
- (System.currentTimeMillis() - this.lastUpdateTimestamp) > REBALANCE_LOCK_MAX_LIVE_TIME;
+ (System.currentTimeMillis() - this.lastUpdateTimestamp) > REBALANCE_LOCK_MAX_LIVE_TIME;
return expired;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerManager.java b/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerManager.java
index 5b86d99..c1b67ae 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerManager.java
@@ -17,15 +17,7 @@
package org.apache.rocketmq.broker.filtersrv;
-import org.apache.rocketmq.broker.BrokerController;
-import org.apache.rocketmq.broker.BrokerStartup;
-import org.apache.rocketmq.common.ThreadFactoryImpl;
-import org.apache.rocketmq.common.constant.LoggerName;
-import org.apache.rocketmq.remoting.common.RemotingUtil;
import io.netty.channel.Channel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -34,18 +26,24 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.broker.BrokerStartup;
+import org.apache.rocketmq.common.ThreadFactoryImpl;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.remoting.common.RemotingUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class FilterServerManager {
public static final long FILTER_SERVER_MAX_IDLE_TIME_MILLS = 30000;
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final ConcurrentHashMap<Channel, FilterServerInfo> filterServerTable =
- new ConcurrentHashMap<Channel, FilterServerInfo>(16);
+ new ConcurrentHashMap<Channel, FilterServerInfo>(16);
private final BrokerController brokerController;
private ScheduledExecutorService scheduledExecutorService = Executors
- .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("FilterServerManagerScheduledThread"));
+ .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("FilterServerManagerScheduledThread"));
public FilterServerManager(final BrokerController brokerController) {
this.brokerController = brokerController;
@@ -67,7 +65,7 @@ public class FilterServerManager {
public void createFilterServer() {
int more =
- this.brokerController.getBrokerConfig().getFilterServerNums() - this.filterServerTable.size();
+ this.brokerController.getBrokerConfig().getFilterServerNums() - this.filterServerTable.size();
String cmd = this.buildStartCommand();
for (int i = 0; i < more; i++) {
FilterServerUtil.callShell(cmd, log);
@@ -86,12 +84,12 @@ public class FilterServerManager {
if (RemotingUtil.isWindowsPlatform()) {
return String.format("start /b %s\\bin\\mqfiltersrv.exe %s",
- this.brokerController.getBrokerConfig().getRocketmqHome(),
- config);
+ this.brokerController.getBrokerConfig().getRocketmqHome(),
+ config);
} else {
return String.format("sh %s/bin/startfsrv.sh %s",
- this.brokerController.getBrokerConfig().getRocketmqHome(),
- config);
+ this.brokerController.getBrokerConfig().getRocketmqHome(),
+ config);
}
}
@@ -134,7 +132,7 @@ public class FilterServerManager {
FilterServerInfo old = this.filterServerTable.remove(channel);
if (old != null) {
log.warn("The Filter Server<{}> connection<{}> closed, remove it", old.getFilterServerAddr(),
- remoteAddr);
+ remoteAddr);
}
}
@@ -152,22 +150,18 @@ public class FilterServerManager {
private String filterServerAddr;
private long lastUpdateTimestamp;
-
public String getFilterServerAddr() {
return filterServerAddr;
}
-
public void setFilterServerAddr(String filterServerAddr) {
this.filterServerAddr = filterServerAddr;
}
-
public long getLastUpdateTimestamp() {
return lastUpdateTimestamp;
}
-
public void setLastUpdateTimestamp(long lastUpdateTimestamp) {
this.lastUpdateTimestamp = lastUpdateTimestamp;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerUtil.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerUtil.java b/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerUtil.java
index de4cc37..9edfbe4 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerUtil.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerUtil.java
@@ -6,20 +6,19 @@
* (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
+ * 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.
+ * 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.broker.filtersrv;
import org.slf4j.Logger;
-
public class FilterServerUtil {
public static void callShell(final String shellString, final Logger log) {
Process process = null;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
index 5359368..f616e33 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
@@ -6,16 +6,19 @@
* (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
+ * 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.
+ * 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.broker.latency;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
import org.apache.rocketmq.broker.BrokerController;
import org.apache.rocketmq.common.ThreadFactoryImpl;
import org.apache.rocketmq.common.constant.LoggerName;
@@ -24,21 +27,27 @@ import org.apache.rocketmq.remoting.protocol.RemotingSysResponseCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-
public class BrokerFastFailure {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl(
- "BrokerFastFailureScheduledThread"));
+ "BrokerFastFailureScheduledThread"));
private final BrokerController brokerController;
public BrokerFastFailure(final BrokerController brokerController) {
this.brokerController = brokerController;
}
+ public static RequestTask castRunnable(final Runnable runnable) {
+ try {
+ FutureTaskExt object = (FutureTaskExt)runnable;
+ return (RequestTask)object.getRunnable();
+ } catch (Throwable e) {
+ log.error(String.format("castRunnable exception, %s", runnable.getClass().getName()), e);
+ }
+
+ return null;
+ }
+
public void start() {
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
@@ -95,17 +104,6 @@ public class BrokerFastFailure {
}
}
- public static RequestTask castRunnable(final Runnable runnable) {
- try {
- FutureTaskExt object = (FutureTaskExt) runnable;
- return (RequestTask) object.getRunnable();
- } catch (Throwable e) {
- log.error(String.format("castRunnable exception, %s", runnable.getClass().getName()), e);
- }
-
- return null;
- }
-
public void shutdown() {
this.scheduledExecutorService.shutdown();
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java
index 8c4c5e8..5a4ad2d 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java
@@ -17,22 +17,31 @@
package org.apache.rocketmq.broker.latency;
-import java.util.concurrent.*;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.RejectedExecutionHandler;
+import java.util.concurrent.RunnableFuture;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
public class BrokerFixedThreadPoolExecutor extends ThreadPoolExecutor {
- public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit, final BlockingQueue<Runnable> workQueue) {
+ public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit,
+ final BlockingQueue<Runnable> workQueue) {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
}
- public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit, final BlockingQueue<Runnable> workQueue, final ThreadFactory threadFactory) {
+ public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit,
+ final BlockingQueue<Runnable> workQueue, final ThreadFactory threadFactory) {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory);
}
- public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit, final BlockingQueue<Runnable> workQueue, final RejectedExecutionHandler handler) {
+ public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit,
+ final BlockingQueue<Runnable> workQueue, final RejectedExecutionHandler handler) {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, handler);
}
- public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit, final BlockingQueue<Runnable> workQueue, final ThreadFactory threadFactory, final RejectedExecutionHandler handler) {
+ public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit,
+ final BlockingQueue<Runnable> workQueue, final ThreadFactory threadFactory, final RejectedExecutionHandler handler) {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
index e261b40..0ee02ad 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
@@ -6,37 +6,33 @@
* (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
+ * 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.
+ * 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.broker.longpolling;
import java.util.ArrayList;
import java.util.List;
-
public class ManyPullRequest {
private final ArrayList<PullRequest> pullRequestList = new ArrayList<PullRequest>();
-
public synchronized void addPullRequest(final PullRequest pullRequest) {
this.pullRequestList.add(pullRequest);
}
-
public synchronized void addPullRequest(final List<PullRequest> many) {
this.pullRequestList.addAll(many);
}
-
public synchronized List<PullRequest> cloneListAndClear() {
if (!this.pullRequestList.isEmpty()) {
- List<PullRequest> result = (ArrayList<PullRequest>) this.pullRequestList.clone();
+ List<PullRequest> result = (ArrayList<PullRequest>)this.pullRequestList.clone();
this.pullRequestList.clear();
return result;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/longpolling/NotifyMessageArrivingListener.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/NotifyMessageArrivingListener.java b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/NotifyMessageArrivingListener.java
index f953c1e..97e54f9 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/NotifyMessageArrivingListener.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/NotifyMessageArrivingListener.java
@@ -6,29 +6,26 @@
* (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
+ * 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.
+ * 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.broker.longpolling;
import org.apache.rocketmq.store.MessageArrivingListener;
-
public class NotifyMessageArrivingListener implements MessageArrivingListener {
private final PullRequestHoldService pullRequestHoldService;
-
public NotifyMessageArrivingListener(final PullRequestHoldService pullRequestHoldService) {
this.pullRequestHoldService = pullRequestHoldService;
}
-
@Override
public void arriving(String topic, int queueId, long logicOffset, long tagsCode) {
this.pullRequestHoldService.notifyMessageArriving(topic, queueId, logicOffset, tagsCode);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java
index 40716f8..1cceec8 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java
@@ -6,20 +6,19 @@
* (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
+ * 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.
+ * 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.broker.longpolling;
+import io.netty.channel.Channel;
import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-import io.netty.channel.Channel;
-
public class PullRequest {
private final RemotingCommand requestCommand;
@@ -29,9 +28,8 @@ public class PullRequest {
private final long pullFromThisOffset;
private final SubscriptionData subscriptionData;
-
public PullRequest(RemotingCommand requestCommand, Channel clientChannel, long timeoutMillis, long suspendTimestamp,
- long pullFromThisOffset, SubscriptionData subscriptionData) {
+ long pullFromThisOffset, SubscriptionData subscriptionData) {
this.requestCommand = requestCommand;
this.clientChannel = clientChannel;
this.timeoutMillis = timeoutMillis;
@@ -40,27 +38,22 @@ public class PullRequest {
this.subscriptionData = subscriptionData;
}
-
public RemotingCommand getRequestCommand() {
return requestCommand;
}
-
public Channel getClientChannel() {
return clientChannel;
}
-
public long getTimeoutMillis() {
return timeoutMillis;
}
-
public long getSuspendTimestamp() {
return suspendTimestamp;
}
-
public long getPullFromThisOffset() {
return pullFromThisOffset;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java
index 5182664..0e5be9b 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java
@@ -16,6 +16,9 @@
*/
package org.apache.rocketmq.broker.longpolling;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.rocketmq.broker.BrokerController;
import org.apache.rocketmq.common.ServiceThread;
import org.apache.rocketmq.common.SystemClock;
@@ -25,11 +28,6 @@ import org.apache.rocketmq.store.MessageFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-
-
public class PullRequestHoldService extends ServiceThread {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private static final String TOPIC_QUEUEID_SEPARATOR = "@";
@@ -37,8 +35,7 @@ public class PullRequestHoldService extends ServiceThread {
private final SystemClock systemClock = new SystemClock();
private final MessageFilter messageFilter = new DefaultMessageFilter();
private ConcurrentHashMap<String/* topic@queueId */, ManyPullRequest> pullRequestTable =
- new ConcurrentHashMap<String, ManyPullRequest>(1024);
-
+ new ConcurrentHashMap<String, ManyPullRequest>(1024);
public PullRequestHoldService(final BrokerController brokerController) {
this.brokerController = brokerController;
@@ -135,7 +132,7 @@ public class PullRequestHoldService extends ServiceThread {
if (this.messageFilter.isMessageMatched(request.getSubscriptionData(), tmp)) {
try {
this.brokerController.getPullMessageProcessor().excuteRequestWhenWakeup(request.getClientChannel(),
- request.getRequestCommand());
+ request.getRequestCommand());
} catch (Throwable e) {
log.error("execute request when wakeup failed.", e);
}
@@ -146,14 +143,13 @@ public class PullRequestHoldService extends ServiceThread {
if (System.currentTimeMillis() >= (request.getSuspendTimestamp() + request.getTimeoutMillis())) {
try {
this.brokerController.getPullMessageProcessor().excuteRequestWhenWakeup(request.getClientChannel(),
- request.getRequestCommand());
+ request.getRequestCommand());
} catch (Throwable e) {
log.error("execute request when wakeup failed.", e);
}
continue;
}
-
replayList.add(request);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageContext.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageContext.java b/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageContext.java
index 3a167fa..cc2f218 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageContext.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageContext.java
@@ -6,20 +6,18 @@
* (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
+ * 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.
+ * 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.broker.mqtrace;
-import org.apache.rocketmq.store.stats.BrokerStatsManager;
-
import java.util.Map;
-
+import org.apache.rocketmq.store.stats.BrokerStatsManager;
public class ConsumeMessageContext {
private String consumerGroup;
@@ -38,102 +36,82 @@ public class ConsumeMessageContext {
private int commercialRcvTimes;
private int commercialRcvSize;
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public Integer getQueueId() {
return queueId;
}
-
public void setQueueId(Integer queueId) {
this.queueId = queueId;
}
-
public String getClientHost() {
return clientHost;
}
-
public void setClientHost(String clientHost) {
this.clientHost = clientHost;
}
-
public String getStoreHost() {
return storeHost;
}
-
public void setStoreHost(String storeHost) {
this.storeHost = storeHost;
}
-
public Map<String, Long> getMessageIds() {
return messageIds;
}
-
public void setMessageIds(Map<String, Long> messageIds) {
this.messageIds = messageIds;
}
-
public boolean isSuccess() {
return success;
}
-
public void setSuccess(boolean success) {
this.success = success;
}
-
public String getStatus() {
return status;
}
-
public void setStatus(String status) {
this.status = status;
}
-
public Object getMqTraceContext() {
return mqTraceContext;
}
-
public void setMqTraceContext(Object mqTraceContext) {
this.mqTraceContext = mqTraceContext;
}
-
public int getBodyLength() {
return bodyLength;
}
-
public void setBodyLength(int bodyLength) {
this.bodyLength = bodyLength;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageHook.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageHook.java b/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageHook.java
index c4b7f36..7e724a0 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageHook.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageHook.java
@@ -6,22 +6,20 @@
* (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
+ * 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.
+ * 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.broker.mqtrace;
public interface ConsumeMessageHook {
String hookName();
-
void consumeMessageBefore(final ConsumeMessageContext context);
-
void consumeMessageAfter(final ConsumeMessageContext context);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageContext.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageContext.java b/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageContext.java
index ca8121d..8ad7919 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageContext.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageContext.java
@@ -6,22 +6,20 @@
* (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
+ * 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.
+ * 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.broker.mqtrace;
+import java.util.Properties;
import org.apache.rocketmq.common.message.MessageType;
import org.apache.rocketmq.store.stats.BrokerStatsManager;
-import java.util.Properties;
-
-
public class SendMessageContext {
private String producerGroup;
private String topic;
@@ -92,137 +90,110 @@ public class SendMessageContext {
return producerGroup;
}
-
public void setProducerGroup(String producerGroup) {
this.producerGroup = producerGroup;
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public String getMsgId() {
return msgId;
}
-
public void setMsgId(String msgId) {
this.msgId = msgId;
}
-
public String getOriginMsgId() {
return originMsgId;
}
-
public void setOriginMsgId(String originMsgId) {
this.originMsgId = originMsgId;
}
-
public Integer getQueueId() {
return queueId;
}
-
public void setQueueId(Integer queueId) {
this.queueId = queueId;
}
-
public Long getQueueOffset() {
return queueOffset;
}
-
public void setQueueOffset(Long queueOffset) {
this.queueOffset = queueOffset;
}
-
public String getBrokerAddr() {
return brokerAddr;
}
-
public void setBrokerAddr(String brokerAddr) {
this.brokerAddr = brokerAddr;
}
-
public String getBornHost() {
return bornHost;
}
-
public void setBornHost(String bornHost) {
this.bornHost = bornHost;
}
-
public int getBodyLength() {
return bodyLength;
}
-
public void setBodyLength(int bodyLength) {
this.bodyLength = bodyLength;
}
-
public int getCode() {
return code;
}
-
public void setCode(int code) {
this.code = code;
}
-
public String getErrorMsg() {
return errorMsg;
}
-
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
-
public String getMsgProps() {
return msgProps;
}
-
public void setMsgProps(String msgProps) {
this.msgProps = msgProps;
}
-
public Object getMqTraceContext() {
return mqTraceContext;
}
-
public void setMqTraceContext(Object mqTraceContext) {
this.mqTraceContext = mqTraceContext;
}
-
public Properties getExtProps() {
return extProps;
}
-
public void setExtProps(Properties extProps) {
this.extProps = extProps;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageHook.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageHook.java b/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageHook.java
index 84cbdcb..a84d899 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageHook.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageHook.java
@@ -6,22 +6,20 @@
* (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
+ * 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.
+ * 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.broker.mqtrace;
public interface SendMessageHook {
public String hookName();
-
public void sendMessageBefore(final SendMessageContext context);
-
public void sendMessageAfter(final SendMessageContext context);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java b/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
index 06ceb36..9346067 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
@@ -6,16 +6,23 @@
* (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
+ * 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.
+ * 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.broker.offset;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.rocketmq.broker.BrokerController;
import org.apache.rocketmq.broker.BrokerPathConfigHelper;
import org.apache.rocketmq.common.ConfigManager;
@@ -25,30 +32,22 @@ import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-
-
public class ConsumerOffsetManager extends ConfigManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private static final String TOPIC_GROUP_SEPARATOR = "@";
private ConcurrentHashMap<String/* topic@group */, ConcurrentHashMap<Integer, Long>> offsetTable =
- new ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>>(512);
+ new ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>>(512);
private transient BrokerController brokerController;
-
public ConsumerOffsetManager() {
}
-
public ConsumerOffsetManager(BrokerController brokerController) {
this.brokerController = brokerController;
}
-
public void scanUnsubscribedTopic() {
Iterator<Entry<String, ConcurrentHashMap<Integer, Long>>> it = this.offsetTable.entrySet().iterator();
while (it.hasNext()) {
@@ -60,7 +59,7 @@ public class ConsumerOffsetManager extends ConfigManager {
String group = arrays[1];
if (null == brokerController.getConsumerManager().findSubscriptionData(group, topic)
- && this.offsetBehindMuchThanData(topic, next.getValue())) {
+ && this.offsetBehindMuchThanData(topic, next.getValue())) {
it.remove();
log.warn("remove topic offset, {}", topicAtGroup);
}
@@ -68,7 +67,6 @@ public class ConsumerOffsetManager extends ConfigManager {
}
}
-
private boolean offsetBehindMuchThanData(final String topic, ConcurrentHashMap<Integer, Long> table) {
Iterator<Entry<Integer, Long>> it = table.entrySet().iterator();
boolean result = !table.isEmpty();
@@ -83,7 +81,6 @@ public class ConsumerOffsetManager extends ConfigManager {
return result;
}
-
public Set<String> whichTopicByConsumer(final String group) {
Set<String> topics = new HashSet<String>();
@@ -102,7 +99,6 @@ public class ConsumerOffsetManager extends ConfigManager {
return topics;
}
-
public Set<String> whichGroupByTopic(final String topic) {
Set<String> groups = new HashSet<String>();
@@ -121,7 +117,6 @@ public class ConsumerOffsetManager extends ConfigManager {
return groups;
}
-
public void commitOffset(final String clientHost, final String group, final String topic, final int queueId, final long offset) {
// topic@group
String key = topic + TOPIC_GROUP_SEPARATOR + group;
@@ -182,12 +177,10 @@ public class ConsumerOffsetManager extends ConfigManager {
return offsetTable;
}
-
public void setOffsetTable(ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>> offsetTable) {
this.offsetTable = offsetTable;
}
-
public Map<Integer, Long> queryMinOffsetInAllGroup(final String topic, final String filterGroups) {
Map<Integer, Long> queueMinOffset = new HashMap<Integer, Long>();
@@ -224,14 +217,12 @@ public class ConsumerOffsetManager extends ConfigManager {
return queueMinOffset;
}
-
public Map<Integer, Long> queryOffset(final String group, final String topic) {
// topic@group
String key = topic + TOPIC_GROUP_SEPARATOR + group;
return this.offsetTable.get(key);
}
-
public void cloneOffset(final String srcGroup, final String destGroup, final String topic) {
ConcurrentHashMap<Integer, Long> offsets = this.offsetTable.get(topic + TOPIC_GROUP_SEPARATOR + srcGroup);
if (offsets != null) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java b/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
index 3d969c4..25b333a 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
@@ -16,6 +16,9 @@
*/
package org.apache.rocketmq.broker.out;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.constant.LoggerName;
@@ -23,24 +26,27 @@ import org.apache.rocketmq.common.namesrv.RegisterBrokerResult;
import org.apache.rocketmq.common.namesrv.TopAddressing;
import org.apache.rocketmq.common.protocol.RequestCode;
import org.apache.rocketmq.common.protocol.ResponseCode;
-import org.apache.rocketmq.common.protocol.body.*;
+import org.apache.rocketmq.common.protocol.body.ConsumerOffsetSerializeWrapper;
+import org.apache.rocketmq.common.protocol.body.KVTable;
+import org.apache.rocketmq.common.protocol.body.RegisterBrokerBody;
+import org.apache.rocketmq.common.protocol.body.SubscriptionGroupWrapper;
+import org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper;
import org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerRequestHeader;
import org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerResponseHeader;
import org.apache.rocketmq.common.protocol.header.namesrv.UnRegisterBrokerRequestHeader;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.remoting.RemotingClient;
-import org.apache.rocketmq.remoting.exception.*;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.exception.RemotingConnectException;
+import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
+import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
+import org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException;
import org.apache.rocketmq.remoting.netty.NettyClientConfig;
import org.apache.rocketmq.remoting.netty.NettyRemotingClient;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.List;
-
-
public class BrokerOuterAPI {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final RemotingClient remotingClient;
@@ -92,15 +98,15 @@ public class BrokerOuterAPI {
}
public RegisterBrokerResult registerBrokerAll(
- final String clusterName,
- final String brokerAddr,
- final String brokerName,
- final long brokerId,
- final String haServerAddr,
- final TopicConfigSerializeWrapper topicConfigWrapper,
- final List<String> filterServerList,
- final boolean oneway,
- final int timeoutMills) {
+ final String clusterName,
+ final String brokerAddr,
+ final String brokerName,
+ final long brokerId,
+ final String haServerAddr,
+ final TopicConfigSerializeWrapper topicConfigWrapper,
+ final List<String> filterServerList,
+ final boolean oneway,
+ final int timeoutMills) {
RegisterBrokerResult registerBrokerResult = null;
List<String> nameServerAddressList = this.remotingClient.getNameServerAddressList();
@@ -108,7 +114,7 @@ public class BrokerOuterAPI {
for (String namesrvAddr : nameServerAddressList) {
try {
RegisterBrokerResult result = this.registerBroker(namesrvAddr, clusterName, brokerAddr, brokerName, brokerId,
- haServerAddr, topicConfigWrapper, filterServerList, oneway, timeoutMills);
+ haServerAddr, topicConfigWrapper, filterServerList, oneway, timeoutMills);
if (result != null) {
registerBrokerResult = result;
}
@@ -124,18 +130,18 @@ public class BrokerOuterAPI {
}
private RegisterBrokerResult registerBroker(
- final String namesrvAddr,
- final String clusterName,
- final String brokerAddr,
- final String brokerName,
- final long brokerId,
- final String haServerAddr,
- final TopicConfigSerializeWrapper topicConfigWrapper,
- final List<String> filterServerList,
- final boolean oneway,
- final int timeoutMills
+ final String namesrvAddr,
+ final String clusterName,
+ final String brokerAddr,
+ final String brokerName,
+ final long brokerId,
+ final String haServerAddr,
+ final TopicConfigSerializeWrapper topicConfigWrapper,
+ final List<String> filterServerList,
+ final boolean oneway,
+ final int timeoutMills
) throws RemotingCommandException, MQBrokerException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
- InterruptedException {
+ InterruptedException {
RegisterBrokerRequestHeader requestHeader = new RegisterBrokerRequestHeader();
requestHeader.setBrokerAddr(brokerAddr);
requestHeader.setBrokerId(brokerId);
@@ -163,7 +169,7 @@ public class BrokerOuterAPI {
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
RegisterBrokerResponseHeader responseHeader =
- (RegisterBrokerResponseHeader) response.decodeCommandCustomHeader(RegisterBrokerResponseHeader.class);
+ (RegisterBrokerResponseHeader)response.decodeCommandCustomHeader(RegisterBrokerResponseHeader.class);
RegisterBrokerResult result = new RegisterBrokerResult();
result.setMasterAddr(responseHeader.getMasterAddr());
result.setHaServerAddr(responseHeader.getHaServerAddr());
@@ -181,10 +187,10 @@ public class BrokerOuterAPI {
}
public void unregisterBrokerAll(
- final String clusterName,
- final String brokerAddr,
- final String brokerName,
- final long brokerId
+ final String clusterName,
+ final String brokerAddr,
+ final String brokerName,
+ final long brokerId
) {
List<String> nameServerAddressList = this.remotingClient.getNameServerAddressList();
if (nameServerAddressList != null) {
@@ -200,11 +206,11 @@ public class BrokerOuterAPI {
}
public void unregisterBroker(
- final String namesrvAddr,
- final String clusterName,
- final String brokerAddr,
- final String brokerName,
- final long brokerId
+ final String namesrvAddr,
+ final String clusterName,
+ final String brokerAddr,
+ final String brokerName,
+ final long brokerId
) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException {
UnRegisterBrokerRequestHeader requestHeader = new UnRegisterBrokerRequestHeader();
requestHeader.setBrokerAddr(brokerAddr);
@@ -227,7 +233,7 @@ public class BrokerOuterAPI {
}
public TopicConfigSerializeWrapper getAllTopicConfig(final String addr) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, InterruptedException, MQBrokerException {
+ RemotingTimeoutException, InterruptedException, MQBrokerException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_CONFIG, null);
RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(true, addr), request, 3000);
@@ -244,7 +250,7 @@ public class BrokerOuterAPI {
}
public ConsumerOffsetSerializeWrapper getAllConsumerOffset(final String addr) throws InterruptedException, RemotingTimeoutException,
- RemotingSendRequestException, RemotingConnectException, MQBrokerException {
+ RemotingSendRequestException, RemotingConnectException, MQBrokerException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_CONSUMER_OFFSET, null);
RemotingCommand response = this.remotingClient.invokeSync(addr, request, 3000);
assert response != null;
@@ -260,7 +266,7 @@ public class BrokerOuterAPI {
}
public String getAllDelayOffset(final String addr) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException,
- RemotingConnectException, MQBrokerException, UnsupportedEncodingException {
+ RemotingConnectException, MQBrokerException, UnsupportedEncodingException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_DELAY_OFFSET, null);
RemotingCommand response = this.remotingClient.invokeSync(addr, request, 3000);
assert response != null;
@@ -276,7 +282,7 @@ public class BrokerOuterAPI {
}
public SubscriptionGroupWrapper getAllSubscriptionGroupConfig(final String addr) throws InterruptedException, RemotingTimeoutException,
- RemotingSendRequestException, RemotingConnectException, MQBrokerException {
+ RemotingSendRequestException, RemotingConnectException, MQBrokerException {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_SUBSCRIPTIONGROUP_CONFIG, null);
RemotingCommand response = this.remotingClient.invokeSync(addr, request, 3000);
assert response != null;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java
index e4c3045..1b1d5bb 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java
@@ -6,38 +6,34 @@
* (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
+ * 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.
+ * 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.broker.pagecache;
-import org.apache.rocketmq.store.GetMessageResult;
import io.netty.channel.FileRegion;
import io.netty.util.AbstractReferenceCounted;
-
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.WritableByteChannel;
import java.util.List;
-
+import org.apache.rocketmq.store.GetMessageResult;
public class ManyMessageTransfer extends AbstractReferenceCounted implements FileRegion {
private final ByteBuffer byteBufferHeader;
private final GetMessageResult getMessageResult;
private long transfered; // the bytes which was transfered already
-
public ManyMessageTransfer(ByteBuffer byteBufferHeader, GetMessageResult getMessageResult) {
this.byteBufferHeader = byteBufferHeader;
this.getMessageResult = getMessageResult;
}
-
@Override
public long position() {
int pos = byteBufferHeader.position();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java
index 3f00ece..b4cf0da 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java
@@ -6,37 +6,33 @@
* (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
+ * 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.
+ * 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.broker.pagecache;
-import org.apache.rocketmq.store.SelectMappedBufferResult;
import io.netty.channel.FileRegion;
import io.netty.util.AbstractReferenceCounted;
-
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.WritableByteChannel;
-
+import org.apache.rocketmq.store.SelectMappedBufferResult;
public class OneMessageTransfer extends AbstractReferenceCounted implements FileRegion {
private final ByteBuffer byteBufferHeader;
private final SelectMappedBufferResult selectMappedBufferResult;
private long transfered; // the bytes which was transfered already
-
public OneMessageTransfer(ByteBuffer byteBufferHeader, SelectMappedBufferResult selectMappedBufferResult) {
this.byteBufferHeader = byteBufferHeader;
this.selectMappedBufferResult = selectMappedBufferResult;
}
-
@Override
public long position() {
return this.byteBufferHeader.position() + this.selectMappedBufferResult.getByteBuffer().position();
[92/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java
index 146770a..2971b6c 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java
@@ -6,38 +6,34 @@
* (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
+ * 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.
+ * 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.broker.pagecache;
-import org.apache.rocketmq.store.QueryMessageResult;
import io.netty.channel.FileRegion;
import io.netty.util.AbstractReferenceCounted;
-
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.WritableByteChannel;
import java.util.List;
-
+import org.apache.rocketmq.store.QueryMessageResult;
public class QueryMessageTransfer extends AbstractReferenceCounted implements FileRegion {
private final ByteBuffer byteBufferHeader;
private final QueryMessageResult queryMessageResult;
private long transfered; // the bytes which was transfered already
-
public QueryMessageTransfer(ByteBuffer byteBufferHeader, QueryMessageResult queryMessageResult) {
this.byteBufferHeader = byteBufferHeader;
this.queryMessageResult = queryMessageResult;
}
-
@Override
public long position() {
int pos = byteBufferHeader.position();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/plugin/AbstractPluginMessageStore.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/plugin/AbstractPluginMessageStore.java b/broker/src/main/java/org/apache/rocketmq/broker/plugin/AbstractPluginMessageStore.java
index 601e2f3..bac941d 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/plugin/AbstractPluginMessageStore.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/plugin/AbstractPluginMessageStore.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.
*/
/**
@@ -20,12 +20,16 @@
*/
package org.apache.rocketmq.broker.plugin;
-import org.apache.rocketmq.common.message.MessageExt;
-import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
-import org.apache.rocketmq.store.*;
-
import java.util.HashMap;
import java.util.Set;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
+import org.apache.rocketmq.store.GetMessageResult;
+import org.apache.rocketmq.store.MessageExtBrokerInner;
+import org.apache.rocketmq.store.MessageStore;
+import org.apache.rocketmq.store.PutMessageResult;
+import org.apache.rocketmq.store.QueryMessageResult;
+import org.apache.rocketmq.store.SelectMappedBufferResult;
public abstract class AbstractPluginMessageStore implements MessageStore {
protected MessageStore next = null;
@@ -83,7 +87,7 @@ public abstract class AbstractPluginMessageStore implements MessageStore {
@Override
public GetMessageResult getMessage(String group, String topic, int queueId, long offset,
- int maxMsgNums, SubscriptionData subscriptionData) {
+ int maxMsgNums, SubscriptionData subscriptionData) {
return next.getMessage(group, topic, queueId, offset, maxMsgNums, subscriptionData);
}
@@ -174,7 +178,7 @@ public abstract class AbstractPluginMessageStore implements MessageStore {
@Override
public QueryMessageResult queryMessage(String topic, String key, int maxNum, long begin,
- long end) {
+ long end) {
return next.queryMessage(topic, key, maxNum, begin, end);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java b/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java
index 42793ae..294bf8c 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.
*/
/**
@@ -20,14 +20,13 @@
*/
package org.apache.rocketmq.broker.plugin;
-import org.apache.rocketmq.store.MessageStore;
-
import java.io.IOException;
import java.lang.reflect.Constructor;
+import org.apache.rocketmq.store.MessageStore;
public final class MessageStoreFactory {
public final static MessageStore build(MessageStorePluginContext context, MessageStore messageStore)
- throws IOException {
+ throws IOException {
String plugin = context.getBrokerConfig().getMessageStorePlugIn();
if (plugin != null && plugin.trim().length() != 0) {
String[] pluginClasses = plugin.split(",");
@@ -35,12 +34,12 @@ public final class MessageStoreFactory {
String pluginClass = pluginClasses[i];
try {
@SuppressWarnings("unchecked")
- Class<AbstractPluginMessageStore> clazz = (Class<AbstractPluginMessageStore>) Class.forName(pluginClass);
+ Class<AbstractPluginMessageStore> clazz = (Class<AbstractPluginMessageStore>)Class.forName(pluginClass);
Constructor<AbstractPluginMessageStore> construct = clazz.getConstructor(MessageStorePluginContext.class, MessageStore.class);
messageStore = construct.newInstance(context, messageStore);
} catch (Throwable e) {
throw new RuntimeException(String.format(
- "Initialize plugin's class %s not found!", pluginClass), e);
+ "Initialize plugin's class %s not found!", pluginClass), e);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStorePluginContext.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStorePluginContext.java b/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStorePluginContext.java
index 32af402..fcab1e6 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStorePluginContext.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStorePluginContext.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.
*/
/**
@@ -32,8 +32,8 @@ public class MessageStorePluginContext {
private BrokerConfig brokerConfig;
public MessageStorePluginContext(MessageStoreConfig messageStoreConfig,
- BrokerStatsManager brokerStatsManager, MessageArrivingListener messageArrivingListener,
- BrokerConfig brokerConfig) {
+ BrokerStatsManager brokerStatsManager, MessageArrivingListener messageArrivingListener,
+ BrokerConfig brokerConfig) {
super();
this.messageStoreConfig = messageStoreConfig;
this.brokerStatsManager = brokerStatsManager;
@@ -57,5 +57,4 @@ public class MessageStorePluginContext {
return brokerConfig;
}
-
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
index f04e86c..75e5766 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
@@ -6,16 +6,22 @@
* (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
+ * 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.
+ * 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.broker.processor;
+import io.netty.channel.ChannelHandlerContext;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
import org.apache.rocketmq.broker.BrokerController;
import org.apache.rocketmq.broker.mqtrace.SendMessageContext;
import org.apache.rocketmq.broker.mqtrace.SendMessageHook;
@@ -42,17 +48,9 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.apache.rocketmq.store.MessageExtBrokerInner;
-import io.netty.channel.ChannelHandlerContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-
-
public abstract class AbstractSendMessageProcessor implements NettyRequestProcessor {
protected static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
@@ -62,16 +60,15 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
protected final SocketAddress storeHost;
private List<SendMessageHook> sendMessageHookList;
-
public AbstractSendMessageProcessor(final BrokerController brokerController) {
this.brokerController = brokerController;
this.storeHost =
- new InetSocketAddress(brokerController.getBrokerConfig().getBrokerIP1(), brokerController
- .getNettyServerConfig().getListenPort());
+ new InetSocketAddress(brokerController.getBrokerConfig().getBrokerIP1(), brokerController
+ .getNettyServerConfig().getListenPort());
}
protected SendMessageContext buildMsgContext(ChannelHandlerContext ctx,
- SendMessageRequestHeader requestHeader) {
+ SendMessageRequestHeader requestHeader) {
if (!this.hasSendMessageHook()) {
return null;
}
@@ -91,7 +88,6 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
properties.put(MessageConst.PROPERTY_TRACE_SWITCH, String.valueOf(this.brokerController.getBrokerConfig().isTraceOn()));
requestHeader.setProperties(MessageDecoder.messageProperties2String(properties));
-
if (uniqueKey == null) {
uniqueKey = "";
}
@@ -104,7 +100,7 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
}
protected MessageExtBrokerInner buildInnerMsg(final ChannelHandlerContext ctx,
- final SendMessageRequestHeader requestHeader, final byte[] body, TopicConfig topicConfig) {
+ final SendMessageRequestHeader requestHeader, final byte[] body, TopicConfig topicConfig) {
int queueIdInt = requestHeader.getQueueId();
if (queueIdInt < 0) {
queueIdInt = Math.abs(this.random.nextInt() % 99999999) % topicConfig.getWriteQueueNums();
@@ -120,10 +116,10 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
msgInner.setBody(body);
msgInner.setFlag(requestHeader.getFlag());
MessageAccessor.setProperties(msgInner,
- MessageDecoder.string2messageProperties(requestHeader.getProperties()));
+ MessageDecoder.string2messageProperties(requestHeader.getProperties()));
msgInner.setPropertiesString(requestHeader.getProperties());
msgInner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(topicConfig.getTopicFilterType(),
- msgInner.getTags()));
+ msgInner.getTags()));
msgInner.setQueueId(queueIdInt);
msgInner.setSysFlag(sysFlag);
@@ -131,7 +127,7 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
msgInner.setBornHost(ctx.channel().remoteAddress());
msgInner.setStoreHost(this.getStoreHost());
msgInner.setReconsumeTimes(requestHeader.getReconsumeTimes() == null ? 0 : requestHeader
- .getReconsumeTimes());
+ .getReconsumeTimes());
return msgInner;
}
@@ -140,8 +136,8 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
}
protected RemotingCommand msgContentCheck(final ChannelHandlerContext ctx,
- final SendMessageRequestHeader requestHeader, RemotingCommand request,
- final RemotingCommand response) {
+ final SendMessageRequestHeader requestHeader, RemotingCommand request,
+ final RemotingCommand response) {
if (requestHeader.getTopic().length() > Byte.MAX_VALUE) {
log.warn("putMessage message topic length too long " + requestHeader.getTopic().length());
response.setCode(ResponseCode.MESSAGE_ILLEGAL);
@@ -149,13 +145,13 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
}
if (requestHeader.getProperties() != null && requestHeader.getProperties().length() > Short.MAX_VALUE) {
log.warn("putMessage message properties length too long "
- + requestHeader.getProperties().length());
+ + requestHeader.getProperties().length());
response.setCode(ResponseCode.MESSAGE_ILLEGAL);
return response;
}
if (request.getBody().length > DBMsgConstants.MAX_BODY_SIZE) {
log.warn(" topic {} msg body size {} from {}", requestHeader.getTopic(),
- request.getBody().length, ChannelUtil.getRemoteIp(ctx.channel()));
+ request.getBody().length, ChannelUtil.getRemoteIp(ctx.channel()));
response.setRemark("msg body must be less 64KB");
response.setCode(ResponseCode.MESSAGE_ILLEGAL);
return response;
@@ -164,12 +160,12 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
}
protected RemotingCommand msgCheck(final ChannelHandlerContext ctx,
- final SendMessageRequestHeader requestHeader, final RemotingCommand response) {
+ final SendMessageRequestHeader requestHeader, final RemotingCommand response) {
if (!PermName.isWriteable(this.brokerController.getBrokerConfig().getBrokerPermission())
- && this.brokerController.getTopicConfigManager().isOrderTopic(requestHeader.getTopic())) {
+ && this.brokerController.getTopicConfigManager().isOrderTopic(requestHeader.getTopic())) {
response.setCode(ResponseCode.NO_PERMISSION);
response.setRemark("the broker[" + this.brokerController.getBrokerConfig().getBrokerIP1()
- + "] sending message is forbidden");
+ + "] sending message is forbidden");
return response;
}
if (!this.brokerController.getTopicConfigManager().isTopicCanSendMessage(requestHeader.getTopic())) {
@@ -181,7 +177,7 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
}
TopicConfig topicConfig =
- this.brokerController.getTopicConfigManager().selectTopicConfig(requestHeader.getTopic());
+ this.brokerController.getTopicConfigManager().selectTopicConfig(requestHeader.getTopic());
if (null == topicConfig) {
int topicSysFlag = 0;
if (requestHeader.isUnitMode()) {
@@ -193,26 +189,26 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
}
log.warn("the topic " + requestHeader.getTopic() + " not exist, producer: "
- + ctx.channel().remoteAddress());
+ + ctx.channel().remoteAddress());
topicConfig = this.brokerController.getTopicConfigManager().createTopicInSendMessageMethod(//
- requestHeader.getTopic(), //
- requestHeader.getDefaultTopic(), //
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()), //
- requestHeader.getDefaultTopicQueueNums(), topicSysFlag);
+ requestHeader.getTopic(), //
+ requestHeader.getDefaultTopic(), //
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()), //
+ requestHeader.getDefaultTopicQueueNums(), topicSysFlag);
if (null == topicConfig) {
if (requestHeader.getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
topicConfig =
- this.brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(
- requestHeader.getTopic(), 1, PermName.PERM_WRITE | PermName.PERM_READ,
- topicSysFlag);
+ this.brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(
+ requestHeader.getTopic(), 1, PermName.PERM_WRITE | PermName.PERM_READ,
+ topicSysFlag);
}
}
if (null == topicConfig) {
response.setCode(ResponseCode.TOPIC_NOT_EXIST);
response.setRemark("topic[" + requestHeader.getTopic() + "] not exist, apply first please!"
- + FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
+ + FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
return response;
}
}
@@ -221,9 +217,9 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
int idValid = Math.max(topicConfig.getWriteQueueNums(), topicConfig.getReadQueueNums());
if (queueIdInt >= idValid) {
String errorInfo = String.format("request queueId[%d] is illagal, %s Producer: %s",
- queueIdInt,
- topicConfig.toString(),
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
+ queueIdInt,
+ topicConfig.toString(),
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
log.warn(errorInfo);
response.setCode(ResponseCode.SYSTEM_ERROR);
@@ -239,7 +235,7 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
}
protected void doResponse(ChannelHandlerContext ctx, RemotingCommand request,
- final RemotingCommand response) {
+ final RemotingCommand response) {
if (!request.isOnewayRPC()) {
try {
ctx.writeAndFlush(response);
@@ -252,7 +248,7 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
}
public void executeSendMessageHookBefore(final ChannelHandlerContext ctx, final RemotingCommand request,
- SendMessageContext context) {
+ SendMessageContext context) {
if (hasSendMessageHook()) {
for (SendMessageHook hook : this.sendMessageHookList) {
try {
@@ -280,20 +276,20 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
}
protected SendMessageRequestHeader parseRequestHeader(RemotingCommand request)
- throws RemotingCommandException {
+ throws RemotingCommandException {
SendMessageRequestHeaderV2 requestHeaderV2 = null;
SendMessageRequestHeader requestHeader = null;
switch (request.getCode()) {
case RequestCode.SEND_MESSAGE_V2:
requestHeaderV2 =
- (SendMessageRequestHeaderV2) request
- .decodeCommandCustomHeader(SendMessageRequestHeaderV2.class);
+ (SendMessageRequestHeaderV2)request
+ .decodeCommandCustomHeader(SendMessageRequestHeaderV2.class);
case RequestCode.SEND_MESSAGE:
if (null == requestHeaderV2) {
requestHeader =
- (SendMessageRequestHeader) request
- .decodeCommandCustomHeader(SendMessageRequestHeader.class);
+ (SendMessageRequestHeader)request
+ .decodeCommandCustomHeader(SendMessageRequestHeader.class);
} else {
requestHeader = SendMessageRequestHeaderV2.createSendMessageRequestHeaderV1(requestHeaderV2);
}
@@ -309,7 +305,7 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
try {
if (response != null) {
final SendMessageResponseHeader responseHeader =
- (SendMessageResponseHeader) response.readCustomHeader();
+ (SendMessageResponseHeader)response.readCustomHeader();
context.setMsgId(responseHeader.getMsgId());
context.setQueueId(responseHeader.getQueueId());
context.setQueueOffset(responseHeader.getQueueOffset());
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
index d2d4bc7..722bec2 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
@@ -16,6 +16,19 @@
*/
package org.apache.rocketmq.broker.processor;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import java.io.UnsupportedEncodingException;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.rocketmq.broker.BrokerController;
import org.apache.rocketmq.broker.client.ClientChannelInfo;
import org.apache.rocketmq.broker.client.ConsumerGroupInfo;
@@ -33,8 +46,48 @@ import org.apache.rocketmq.common.message.MessageId;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.RequestCode;
import org.apache.rocketmq.common.protocol.ResponseCode;
-import org.apache.rocketmq.common.protocol.body.*;
-import org.apache.rocketmq.common.protocol.header.*;
+import org.apache.rocketmq.common.protocol.body.BrokerStatsData;
+import org.apache.rocketmq.common.protocol.body.BrokerStatsItem;
+import org.apache.rocketmq.common.protocol.body.Connection;
+import org.apache.rocketmq.common.protocol.body.ConsumeStatsList;
+import org.apache.rocketmq.common.protocol.body.ConsumerConnection;
+import org.apache.rocketmq.common.protocol.body.GroupList;
+import org.apache.rocketmq.common.protocol.body.KVTable;
+import org.apache.rocketmq.common.protocol.body.LockBatchRequestBody;
+import org.apache.rocketmq.common.protocol.body.LockBatchResponseBody;
+import org.apache.rocketmq.common.protocol.body.ProducerConnection;
+import org.apache.rocketmq.common.protocol.body.QueryConsumeTimeSpanBody;
+import org.apache.rocketmq.common.protocol.body.QueryCorrectionOffsetBody;
+import org.apache.rocketmq.common.protocol.body.QueueTimeSpan;
+import org.apache.rocketmq.common.protocol.body.TopicList;
+import org.apache.rocketmq.common.protocol.body.UnlockBatchRequestBody;
+import org.apache.rocketmq.common.protocol.header.CloneGroupOffsetRequestHeader;
+import org.apache.rocketmq.common.protocol.header.ConsumeMessageDirectlyResultRequestHeader;
+import org.apache.rocketmq.common.protocol.header.CreateTopicRequestHeader;
+import org.apache.rocketmq.common.protocol.header.DeleteSubscriptionGroupRequestHeader;
+import org.apache.rocketmq.common.protocol.header.DeleteTopicRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetAllTopicConfigResponseHeader;
+import org.apache.rocketmq.common.protocol.header.GetBrokerConfigResponseHeader;
+import org.apache.rocketmq.common.protocol.header.GetConsumeStatsInBrokerHeader;
+import org.apache.rocketmq.common.protocol.header.GetConsumeStatsRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetConsumerConnectionListRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetConsumerRunningInfoRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetConsumerStatusRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetEarliestMsgStoretimeRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetEarliestMsgStoretimeResponseHeader;
+import org.apache.rocketmq.common.protocol.header.GetMaxOffsetRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetMaxOffsetResponseHeader;
+import org.apache.rocketmq.common.protocol.header.GetMinOffsetRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetMinOffsetResponseHeader;
+import org.apache.rocketmq.common.protocol.header.GetProducerConnectionListRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetTopicStatsInfoRequestHeader;
+import org.apache.rocketmq.common.protocol.header.QueryConsumeTimeSpanRequestHeader;
+import org.apache.rocketmq.common.protocol.header.QueryCorrectionOffsetHeader;
+import org.apache.rocketmq.common.protocol.header.QueryTopicConsumeByWhoRequestHeader;
+import org.apache.rocketmq.common.protocol.header.ResetOffsetRequestHeader;
+import org.apache.rocketmq.common.protocol.header.SearchOffsetRequestHeader;
+import org.apache.rocketmq.common.protocol.header.SearchOffsetResponseHeader;
+import org.apache.rocketmq.common.protocol.header.ViewBrokerStatsDataRequestHeader;
import org.apache.rocketmq.common.protocol.header.filtersrv.RegisterFilterServerRequestHeader;
import org.apache.rocketmq.common.protocol.header.filtersrv.RegisterFilterServerResponseHeader;
import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
@@ -50,17 +103,9 @@ import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
import org.apache.rocketmq.store.DefaultMessageStore;
import org.apache.rocketmq.store.SelectMappedBufferResult;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandlerContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.UnsupportedEncodingException;
-import java.net.UnknownHostException;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-
-
public class AdminBrokerProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final BrokerController brokerController;
@@ -157,10 +202,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand updateAndCreateTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final CreateTopicRequestHeader requestHeader =
- (CreateTopicRequestHeader) request.decodeCommandCustomHeader(CreateTopicRequestHeader.class);
+ (CreateTopicRequestHeader)request.decodeCommandCustomHeader(CreateTopicRequestHeader.class);
log.info("updateAndCreateTopic called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
-
if (requestHeader.getTopic().equals(this.brokerController.getBrokerConfig().getBrokerClusterName())) {
String errorMsg = "the topic[" + requestHeader.getTopic() + "] is conflict with system reserved words.";
log.warn(errorMsg);
@@ -193,13 +237,13 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand deleteTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
DeleteTopicRequestHeader requestHeader =
- (DeleteTopicRequestHeader) request.decodeCommandCustomHeader(DeleteTopicRequestHeader.class);
+ (DeleteTopicRequestHeader)request.decodeCommandCustomHeader(DeleteTopicRequestHeader.class);
log.info("deleteTopic called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
this.brokerController.getTopicConfigManager().deleteTopicConfig(requestHeader.getTopic());
this.brokerController.getMessageStore()
- .cleanUnusedTopic(this.brokerController.getTopicConfigManager().getTopicConfigTable().keySet());
+ .cleanUnusedTopic(this.brokerController.getTopicConfigManager().getTopicConfigTable().keySet());
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
@@ -274,7 +318,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand getBrokerConfig(ChannelHandlerContext ctx, RemotingCommand request) {
final RemotingCommand response = RemotingCommand.createResponseCommand(GetBrokerConfigResponseHeader.class);
- final GetBrokerConfigResponseHeader responseHeader = (GetBrokerConfigResponseHeader) response.readCustomHeader();
+ final GetBrokerConfigResponseHeader responseHeader = (GetBrokerConfigResponseHeader)response.readCustomHeader();
String content = this.brokerController.getConfiguration().getAllConfigsFormatString();
if (content != null && content.length() > 0) {
@@ -298,12 +342,12 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand searchOffsetByTimestamp(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(SearchOffsetResponseHeader.class);
- final SearchOffsetResponseHeader responseHeader = (SearchOffsetResponseHeader) response.readCustomHeader();
+ final SearchOffsetResponseHeader responseHeader = (SearchOffsetResponseHeader)response.readCustomHeader();
final SearchOffsetRequestHeader requestHeader =
- (SearchOffsetRequestHeader) request.decodeCommandCustomHeader(SearchOffsetRequestHeader.class);
+ (SearchOffsetRequestHeader)request.decodeCommandCustomHeader(SearchOffsetRequestHeader.class);
long offset = this.brokerController.getMessageStore().getOffsetInQueueByTime(requestHeader.getTopic(), requestHeader.getQueueId(),
- requestHeader.getTimestamp());
+ requestHeader.getTimestamp());
responseHeader.setOffset(offset);
@@ -314,9 +358,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand getMaxOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(GetMaxOffsetResponseHeader.class);
- final GetMaxOffsetResponseHeader responseHeader = (GetMaxOffsetResponseHeader) response.readCustomHeader();
+ final GetMaxOffsetResponseHeader responseHeader = (GetMaxOffsetResponseHeader)response.readCustomHeader();
final GetMaxOffsetRequestHeader requestHeader =
- (GetMaxOffsetRequestHeader) request.decodeCommandCustomHeader(GetMaxOffsetRequestHeader.class);
+ (GetMaxOffsetRequestHeader)request.decodeCommandCustomHeader(GetMaxOffsetRequestHeader.class);
long offset = this.brokerController.getMessageStore().getMaxOffsetInQuque(requestHeader.getTopic(), requestHeader.getQueueId());
@@ -329,9 +373,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand getMinOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(GetMinOffsetResponseHeader.class);
- final GetMinOffsetResponseHeader responseHeader = (GetMinOffsetResponseHeader) response.readCustomHeader();
+ final GetMinOffsetResponseHeader responseHeader = (GetMinOffsetResponseHeader)response.readCustomHeader();
final GetMinOffsetRequestHeader requestHeader =
- (GetMinOffsetRequestHeader) request.decodeCommandCustomHeader(GetMinOffsetRequestHeader.class);
+ (GetMinOffsetRequestHeader)request.decodeCommandCustomHeader(GetMinOffsetRequestHeader.class);
long offset = this.brokerController.getMessageStore().getMinOffsetInQuque(requestHeader.getTopic(), requestHeader.getQueueId());
@@ -343,12 +387,12 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand getEarliestMsgStoretime(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(GetEarliestMsgStoretimeResponseHeader.class);
- final GetEarliestMsgStoretimeResponseHeader responseHeader = (GetEarliestMsgStoretimeResponseHeader) response.readCustomHeader();
+ final GetEarliestMsgStoretimeResponseHeader responseHeader = (GetEarliestMsgStoretimeResponseHeader)response.readCustomHeader();
final GetEarliestMsgStoretimeRequestHeader requestHeader =
- (GetEarliestMsgStoretimeRequestHeader) request.decodeCommandCustomHeader(GetEarliestMsgStoretimeRequestHeader.class);
+ (GetEarliestMsgStoretimeRequestHeader)request.decodeCommandCustomHeader(GetEarliestMsgStoretimeRequestHeader.class);
long timestamp =
- this.brokerController.getMessageStore().getEarliestMessageTime(requestHeader.getTopic(), requestHeader.getQueueId());
+ this.brokerController.getMessageStore().getEarliestMessageTime(requestHeader.getTopic(), requestHeader.getQueueId());
responseHeader.setTimestamp(timestamp);
response.setCode(ResponseCode.SUCCESS);
@@ -375,9 +419,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
LockBatchRequestBody requestBody = LockBatchRequestBody.decode(request.getBody(), LockBatchRequestBody.class);
Set<MessageQueue> lockOKMQSet = this.brokerController.getRebalanceLockManager().tryLockBatch(//
- requestBody.getConsumerGroup(), //
- requestBody.getMqSet(), //
- requestBody.getClientId());
+ requestBody.getConsumerGroup(), //
+ requestBody.getMqSet(), //
+ requestBody.getClientId());
LockBatchResponseBody responseBody = new LockBatchResponseBody();
responseBody.setLockOKMQSet(lockOKMQSet);
@@ -393,9 +437,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
UnlockBatchRequestBody requestBody = UnlockBatchRequestBody.decode(request.getBody(), UnlockBatchRequestBody.class);
this.brokerController.getRebalanceLockManager().unlockBatch(//
- requestBody.getConsumerGroup(), //
- requestBody.getMqSet(), //
- requestBody.getClientId());
+ requestBody.getConsumerGroup(), //
+ requestBody.getMqSet(), //
+ requestBody.getClientId());
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
@@ -403,7 +447,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
}
private RemotingCommand updateAndCreateSubscriptionGroup(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
+ throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
log.info("updateAndCreateSubscriptionGroup called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
@@ -447,7 +491,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand deleteSubscriptionGroup(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
DeleteSubscriptionGroupRequestHeader requestHeader =
- (DeleteSubscriptionGroupRequestHeader) request.decodeCommandCustomHeader(DeleteSubscriptionGroupRequestHeader.class);
+ (DeleteSubscriptionGroupRequestHeader)request.decodeCommandCustomHeader(DeleteSubscriptionGroupRequestHeader.class);
log.info("deleteSubscriptionGroup called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
@@ -461,7 +505,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand getTopicStatsInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetTopicStatsInfoRequestHeader requestHeader =
- (GetTopicStatsInfoRequestHeader) request.decodeCommandCustomHeader(GetTopicStatsInfoRequestHeader.class);
+ (GetTopicStatsInfoRequestHeader)request.decodeCommandCustomHeader(GetTopicStatsInfoRequestHeader.class);
final String topic = requestHeader.getTopic();
TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
@@ -509,10 +553,10 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand getConsumerConnectionList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetConsumerConnectionListRequestHeader requestHeader =
- (GetConsumerConnectionListRequestHeader) request.decodeCommandCustomHeader(GetConsumerConnectionListRequestHeader.class);
+ (GetConsumerConnectionListRequestHeader)request.decodeCommandCustomHeader(GetConsumerConnectionListRequestHeader.class);
ConsumerGroupInfo consumerGroupInfo =
- this.brokerController.getConsumerManager().getConsumerGroupInfo(requestHeader.getConsumerGroup());
+ this.brokerController.getConsumerManager().getConsumerGroupInfo(requestHeader.getConsumerGroup());
if (consumerGroupInfo != null) {
ConsumerConnection bodydata = new ConsumerConnection();
bodydata.setConsumeFromWhere(consumerGroupInfo.getConsumeFromWhere());
@@ -548,11 +592,11 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand getProducerConnectionList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetProducerConnectionListRequestHeader requestHeader =
- (GetProducerConnectionListRequestHeader) request.decodeCommandCustomHeader(GetProducerConnectionListRequestHeader.class);
+ (GetProducerConnectionListRequestHeader)request.decodeCommandCustomHeader(GetProducerConnectionListRequestHeader.class);
ProducerConnection bodydata = new ProducerConnection();
HashMap<Channel, ClientChannelInfo> channelInfoHashMap =
- this.brokerController.getProducerManager().getGroupChannelTable().get(requestHeader.getProducerGroup());
+ this.brokerController.getProducerManager().getGroupChannelTable().get(requestHeader.getProducerGroup());
if (channelInfoHashMap != null) {
Iterator<Map.Entry<Channel, ClientChannelInfo>> it = channelInfoHashMap.entrySet().iterator();
while (it.hasNext()) {
@@ -581,7 +625,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand getConsumeStats(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetConsumeStatsRequestHeader requestHeader =
- (GetConsumeStatsRequestHeader) request.decodeCommandCustomHeader(GetConsumeStatsRequestHeader.class);
+ (GetConsumeStatsRequestHeader)request.decodeCommandCustomHeader(GetConsumeStatsRequestHeader.class);
ConsumeStats consumeStats = new ConsumeStats();
@@ -604,10 +648,10 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
*/
{
SubscriptionData findSubscriptionData =
- this.brokerController.getConsumerManager().findSubscriptionData(requestHeader.getConsumerGroup(), topic);
+ this.brokerController.getConsumerManager().findSubscriptionData(requestHeader.getConsumerGroup(), topic);
if (null == findSubscriptionData //
- && this.brokerController.getConsumerManager().findSubscriptionDataCount(requestHeader.getConsumerGroup()) > 0) {
+ && this.brokerController.getConsumerManager().findSubscriptionDataCount(requestHeader.getConsumerGroup()) > 0) {
log.warn("consumeStats, the consumer group[{}], topic[{}] not exist", requestHeader.getConsumerGroup(), topic);
continue;
}
@@ -626,16 +670,15 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
brokerOffset = 0;
long consumerOffset = this.brokerController.getConsumerOffsetManager().queryOffset(//
- requestHeader.getConsumerGroup(), //
- topic, //
- i);
+ requestHeader.getConsumerGroup(), //
+ topic, //
+ i);
if (consumerOffset < 0)
consumerOffset = 0;
offsetWrapper.setBrokerOffset(brokerOffset);
offsetWrapper.setConsumerOffset(consumerOffset);
-
long timeOffset = consumerOffset - 1;
if (timeOffset >= 0) {
long lastTimestamp = this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i, timeOffset);
@@ -690,7 +733,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand getAllDelayOffset(ChannelHandlerContext ctx, RemotingCommand request) {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- String content = ((DefaultMessageStore) this.brokerController.getMessageStore()).getScheduleMessageService().encode();
+ String content = ((DefaultMessageStore)this.brokerController.getMessageStore()).getScheduleMessageService().encode();
if (content != null && content.length() > 0) {
try {
response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
@@ -716,10 +759,10 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
public RemotingCommand resetOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final ResetOffsetRequestHeader requestHeader =
- (ResetOffsetRequestHeader) request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
+ (ResetOffsetRequestHeader)request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
log.info("[reset-offset] reset offset started by {}. topic={}, group={}, timestamp={}, isForce={}",
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
- requestHeader.getTimestamp(), requestHeader.isForce());
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
+ requestHeader.getTimestamp(), requestHeader.isForce());
boolean isC = false;
LanguageCode language = request.getLanguage();
switch (language) {
@@ -728,25 +771,24 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
break;
}
return this.brokerController.getBroker2Client().resetOffset(requestHeader.getTopic(), requestHeader.getGroup(),
- requestHeader.getTimestamp(), requestHeader.isForce(), isC);
+ requestHeader.getTimestamp(), requestHeader.isForce(), isC);
}
public RemotingCommand getConsumerStatus(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final GetConsumerStatusRequestHeader requestHeader =
- (GetConsumerStatusRequestHeader) request.decodeCommandCustomHeader(GetConsumerStatusRequestHeader.class);
+ (GetConsumerStatusRequestHeader)request.decodeCommandCustomHeader(GetConsumerStatusRequestHeader.class);
log.info("[get-consumer-status] get consumer status by {}. topic={}, group={}",
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup());
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup());
return this.brokerController.getBroker2Client().getConsumeStatus(requestHeader.getTopic(), requestHeader.getGroup(),
- requestHeader.getClientAddr());
+ requestHeader.getClientAddr());
}
private RemotingCommand queryTopicConsumeByWho(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
QueryTopicConsumeByWhoRequestHeader requestHeader =
- (QueryTopicConsumeByWhoRequestHeader) request.decodeCommandCustomHeader(QueryTopicConsumeByWhoRequestHeader.class);
-
+ (QueryTopicConsumeByWhoRequestHeader)request.decodeCommandCustomHeader(QueryTopicConsumeByWhoRequestHeader.class);
HashSet<String> groups = this.brokerController.getConsumerManager().queryTopicConsumeByWho(requestHeader.getTopic());
@@ -767,9 +809,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand registerFilterServer(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterFilterServerResponseHeader.class);
- final RegisterFilterServerResponseHeader responseHeader = (RegisterFilterServerResponseHeader) response.readCustomHeader();
+ final RegisterFilterServerResponseHeader responseHeader = (RegisterFilterServerResponseHeader)response.readCustomHeader();
final RegisterFilterServerRequestHeader requestHeader =
- (RegisterFilterServerRequestHeader) request.decodeCommandCustomHeader(RegisterFilterServerRequestHeader.class);
+ (RegisterFilterServerRequestHeader)request.decodeCommandCustomHeader(RegisterFilterServerRequestHeader.class);
this.brokerController.getFilterServerManager().registerFilterServer(ctx.channel(), requestHeader.getFilterServerAddr());
@@ -784,7 +826,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand queryConsumeTimeSpan(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
QueryConsumeTimeSpanRequestHeader requestHeader =
- (QueryConsumeTimeSpanRequestHeader) request.decodeCommandCustomHeader(QueryConsumeTimeSpanRequestHeader.class);
+ (QueryConsumeTimeSpanRequestHeader)request.decodeCommandCustomHeader(QueryConsumeTimeSpanRequestHeader.class);
final String topic = requestHeader.getTopic();
TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
@@ -812,7 +854,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
long consumeTime;
long consumerOffset = this.brokerController.getConsumerOffsetManager().queryOffset(
- requestHeader.getGroup(), topic, i);
+ requestHeader.getGroup(), topic, i);
if (consumerOffset > 0) {
consumeTime = this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i, consumerOffset - 1);
} else {
@@ -837,7 +879,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
}
private RemotingCommand getSystemTopicListFromBroker(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
+ throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
Set<String> topics = this.brokerController.getTopicConfigManager().getSystemTopic();
@@ -874,28 +916,28 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
*/
private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final GetConsumerRunningInfoRequestHeader requestHeader =
- (GetConsumerRunningInfoRequestHeader) request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);
+ (GetConsumerRunningInfoRequestHeader)request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);
return this.callConsumer(RequestCode.GET_CONSUMER_RUNNING_INFO, request, requestHeader.getConsumerGroup(),
- requestHeader.getClientId());
+ requestHeader.getClientId());
}
private RemotingCommand queryCorrectionOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
QueryCorrectionOffsetHeader requestHeader =
- (QueryCorrectionOffsetHeader) request.decodeCommandCustomHeader(QueryCorrectionOffsetHeader.class);
+ (QueryCorrectionOffsetHeader)request.decodeCommandCustomHeader(QueryCorrectionOffsetHeader.class);
Map<Integer, Long> correctionOffset = this.brokerController.getConsumerOffsetManager()
- .queryMinOffsetInAllGroup(requestHeader.getTopic(), requestHeader.getFilterGroups());
+ .queryMinOffsetInAllGroup(requestHeader.getTopic(), requestHeader.getFilterGroups());
Map<Integer, Long> compareOffset =
- this.brokerController.getConsumerOffsetManager().queryOffset(requestHeader.getTopic(), requestHeader.getCompareGroup());
+ this.brokerController.getConsumerOffsetManager().queryOffset(requestHeader.getTopic(), requestHeader.getCompareGroup());
if (compareOffset != null && !compareOffset.isEmpty()) {
for (Map.Entry<Integer, Long> entry : compareOffset.entrySet()) {
Integer queueId = entry.getKey();
correctionOffset.put(queueId,
- correctionOffset.get(queueId) > entry.getValue() ? Long.MAX_VALUE : correctionOffset.get(queueId));
+ correctionOffset.get(queueId) > entry.getValue() ? Long.MAX_VALUE : correctionOffset.get(queueId));
}
}
@@ -908,8 +950,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
}
private RemotingCommand consumeMessageDirectly(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final ConsumeMessageDirectlyResultRequestHeader requestHeader = (ConsumeMessageDirectlyResultRequestHeader) request
- .decodeCommandCustomHeader(ConsumeMessageDirectlyResultRequestHeader.class);
+ final ConsumeMessageDirectlyResultRequestHeader requestHeader = (ConsumeMessageDirectlyResultRequestHeader)request
+ .decodeCommandCustomHeader(ConsumeMessageDirectlyResultRequestHeader.class);
request.getExtFields().put("brokerName", this.brokerController.getBrokerConfig().getBrokerName());
SelectMappedBufferResult selectMappedBufferResult = null;
@@ -928,13 +970,13 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
}
return this.callConsumer(RequestCode.CONSUME_MESSAGE_DIRECTLY, request, requestHeader.getConsumerGroup(),
- requestHeader.getClientId());
+ requestHeader.getClientId());
}
private RemotingCommand cloneGroupOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
CloneGroupOffsetRequestHeader requestHeader =
- (CloneGroupOffsetRequestHeader) request.decodeCommandCustomHeader(CloneGroupOffsetRequestHeader.class);
+ (CloneGroupOffsetRequestHeader)request.decodeCommandCustomHeader(CloneGroupOffsetRequestHeader.class);
Set<String> topics;
if (UtilAll.isBlank(requestHeader.getTopic())) {
@@ -957,16 +999,16 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
if (!requestHeader.isOffline()) {
SubscriptionData findSubscriptionData =
- this.brokerController.getConsumerManager().findSubscriptionData(requestHeader.getSrcGroup(), topic);
+ this.brokerController.getConsumerManager().findSubscriptionData(requestHeader.getSrcGroup(), topic);
if (this.brokerController.getConsumerManager().findSubscriptionDataCount(requestHeader.getSrcGroup()) > 0
- && findSubscriptionData == null) {
+ && findSubscriptionData == null) {
log.warn("[cloneGroupOffset], the consumer group[{}], topic[{}] not exist", requestHeader.getSrcGroup(), topic);
continue;
}
}
this.brokerController.getConsumerOffsetManager().cloneOffset(requestHeader.getSrcGroup(), requestHeader.getDestGroup(),
- requestHeader.getTopic());
+ requestHeader.getTopic());
}
response.setCode(ResponseCode.SUCCESS);
@@ -976,9 +1018,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand ViewBrokerStatsData(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final ViewBrokerStatsDataRequestHeader requestHeader =
- (ViewBrokerStatsDataRequestHeader) request.decodeCommandCustomHeader(ViewBrokerStatsDataRequestHeader.class);
+ (ViewBrokerStatsDataRequestHeader)request.decodeCommandCustomHeader(ViewBrokerStatsDataRequestHeader.class);
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- DefaultMessageStore messageStore = (DefaultMessageStore) this.brokerController.getMessageStore();
+ DefaultMessageStore messageStore = (DefaultMessageStore)this.brokerController.getMessageStore();
StatsItem statsItem = messageStore.getBrokerStatsManager().getStatsItem(requestHeader.getStatsName(), requestHeader.getStatsKey());
if (null == statsItem) {
@@ -998,7 +1040,6 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
brokerStatsData.setStatsMinute(it);
}
-
{
BrokerStatsItem it = new BrokerStatsItem();
StatsSnapshot ss = statsItem.getStatsDataInHour();
@@ -1008,7 +1049,6 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
brokerStatsData.setStatsHour(it);
}
-
{
BrokerStatsItem it = new BrokerStatsItem();
StatsSnapshot ss = statsItem.getStatsDataInDay();
@@ -1025,16 +1065,16 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
}
private RemotingCommand fetchAllConsumeStatsInBroker(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
+ throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
GetConsumeStatsInBrokerHeader requestHeader =
- (GetConsumeStatsInBrokerHeader) request.decodeCommandCustomHeader(GetConsumeStatsInBrokerHeader.class);
+ (GetConsumeStatsInBrokerHeader)request.decodeCommandCustomHeader(GetConsumeStatsInBrokerHeader.class);
boolean isOrder = requestHeader.isOrder();
ConcurrentHashMap<String, SubscriptionGroupConfig> subscriptionGroups =
- brokerController.getSubscriptionGroupManager().getSubscriptionGroupTable();
+ brokerController.getSubscriptionGroupManager().getSubscriptionGroupTable();
List<Map<String/* subscriptionGroupName */, List<ConsumeStats>>> brokerConsumeStatsList =
- new ArrayList<Map<String, List<ConsumeStats>>>();
+ new ArrayList<Map<String, List<ConsumeStats>>>();
long totalDiff = 0L;
@@ -1060,7 +1100,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
SubscriptionData findSubscriptionData = this.brokerController.getConsumerManager().findSubscriptionData(group, topic);
if (null == findSubscriptionData //
- && this.brokerController.getConsumerManager().findSubscriptionDataCount(group) > 0) {
+ && this.brokerController.getConsumerManager().findSubscriptionDataCount(group) > 0) {
log.warn("consumeStats, the consumer group[{}], topic[{}] not exist", group, topic);
continue;
}
@@ -1076,16 +1116,15 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
if (brokerOffset < 0)
brokerOffset = 0;
long consumerOffset = this.brokerController.getConsumerOffsetManager().queryOffset(//
- group, //
- topic, //
- i);
+ group, //
+ topic, //
+ i);
if (consumerOffset < 0)
consumerOffset = 0;
offsetWrapper.setBrokerOffset(brokerOffset);
offsetWrapper.setConsumerOffset(consumerOffset);
-
long timeOffset = consumerOffset - 1;
if (timeOffset >= 0) {
long lastTimestamp = this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i, timeOffset);
@@ -1120,23 +1159,23 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
runtimeInfo.put("brokerVersion", String.valueOf(MQVersion.CURRENT_VERSION));
runtimeInfo.put("msgPutTotalYesterdayMorning",
- String.valueOf(this.brokerController.getBrokerStats().getMsgPutTotalYesterdayMorning()));
+ String.valueOf(this.brokerController.getBrokerStats().getMsgPutTotalYesterdayMorning()));
runtimeInfo.put("msgPutTotalTodayMorning", String.valueOf(this.brokerController.getBrokerStats().getMsgPutTotalTodayMorning()));
runtimeInfo.put("msgPutTotalTodayNow", String.valueOf(this.brokerController.getBrokerStats().getMsgPutTotalTodayNow()));
runtimeInfo.put("msgGetTotalYesterdayMorning",
- String.valueOf(this.brokerController.getBrokerStats().getMsgGetTotalYesterdayMorning()));
+ String.valueOf(this.brokerController.getBrokerStats().getMsgGetTotalYesterdayMorning()));
runtimeInfo.put("msgGetTotalTodayMorning", String.valueOf(this.brokerController.getBrokerStats().getMsgGetTotalTodayMorning()));
runtimeInfo.put("msgGetTotalTodayNow", String.valueOf(this.brokerController.getBrokerStats().getMsgGetTotalTodayNow()));
runtimeInfo.put("sendThreadPoolQueueSize", String.valueOf(this.brokerController.getSendThreadPoolQueue().size()));
runtimeInfo.put("sendThreadPoolQueueCapacity",
- String.valueOf(this.brokerController.getBrokerConfig().getSendThreadPoolQueueCapacity()));
+ String.valueOf(this.brokerController.getBrokerConfig().getSendThreadPoolQueueCapacity()));
runtimeInfo.put("pullThreadPoolQueueSize", String.valueOf(this.brokerController.getPullThreadPoolQueue().size()));
runtimeInfo.put("pullThreadPoolQueueCapacity",
- String.valueOf(this.brokerController.getBrokerConfig().getPullThreadPoolQueueCapacity()));
+ String.valueOf(this.brokerController.getBrokerConfig().getPullThreadPoolQueueCapacity()));
runtimeInfo.put("dispatchBehindBytes", String.valueOf(this.brokerController.getMessageStore().dispatchBehindBytes()));
runtimeInfo.put("pageCacheLockTimeMills", String.valueOf(this.brokerController.getMessageStore().lockTimeMills()));
@@ -1146,7 +1185,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
runtimeInfo.put("earliestMessageTimeStamp", String.valueOf(this.brokerController.getMessageStore().getEarliestMessageTime()));
runtimeInfo.put("startAcceptSendRequestTimeStamp", String.valueOf(this.brokerController.getBrokerConfig().getStartAcceptSendRequestTimeStamp()));
if (this.brokerController.getMessageStore() instanceof DefaultMessageStore) {
- DefaultMessageStore defaultMessageStore = (DefaultMessageStore) this.brokerController.getMessageStore();
+ DefaultMessageStore defaultMessageStore = (DefaultMessageStore)this.brokerController.getMessageStore();
runtimeInfo.put("remainTransientStoreBufferNumbs", String.valueOf(defaultMessageStore.remainTransientStoreBufferNumbs()));
if (defaultMessageStore.getMessageStoreConfig().isTransientStorePoolEnable()) {
runtimeInfo.put("remainHowManyDataToCommit", MixAll.humanReadableByteCount(defaultMessageStore.getCommitLog().remainHowManyDataToCommit(), false));
@@ -1163,10 +1202,10 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
}
private RemotingCommand callConsumer(//
- final int requestCode, //
- final RemotingCommand request, //
- final String consumerGroup, //
- final String clientId) throws RemotingCommandException {
+ final int requestCode, //
+ final RemotingCommand request, //
+ final String consumerGroup, //
+ final String clientId) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
ClientChannelInfo clientChannelInfo = this.brokerController.getConsumerManager().findChannel(consumerGroup, clientId);
@@ -1179,8 +1218,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
if (clientChannelInfo.getVersion() < MQVersion.Version.V3_1_8_SNAPSHOT.ordinal()) {
response.setCode(ResponseCode.SYSTEM_ERROR);
response.setRemark(String.format("The Consumer <%s> Version <%s> too low to finish, please upgrade it to V3_1_8_SNAPSHOT", //
- clientId, //
- MQVersion.getVersionDesc(clientChannelInfo.getVersion())));
+ clientId, //
+ MQVersion.getVersionDesc(clientChannelInfo.getVersion())));
return response;
}
@@ -1193,12 +1232,12 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
} catch (RemotingTimeoutException e) {
response.setCode(ResponseCode.CONSUME_MSG_TIMEOUT);
response
- .setRemark(String.format("consumer <%s> <%s> Timeout: %s", consumerGroup, clientId, RemotingHelper.exceptionSimpleDesc(e)));
+ .setRemark(String.format("consumer <%s> <%s> Timeout: %s", consumerGroup, clientId, RemotingHelper.exceptionSimpleDesc(e)));
return response;
} catch (Exception e) {
response.setCode(ResponseCode.SYSTEM_ERROR);
response.setRemark(
- String.format("invoke consumer <%s> <%s> Exception: %s", consumerGroup, clientId, RemotingHelper.exceptionSimpleDesc(e)));
+ String.format("invoke consumer <%s> <%s> Exception: %s", consumerGroup, clientId, RemotingHelper.exceptionSimpleDesc(e)));
return response;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
index 62de995..717afaf 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
@@ -16,6 +16,7 @@
*/
package org.apache.rocketmq.broker.processor;
+import io.netty.channel.ChannelHandlerContext;
import org.apache.rocketmq.broker.BrokerController;
import org.apache.rocketmq.broker.client.ClientChannelInfo;
import org.apache.rocketmq.common.MixAll;
@@ -34,11 +35,9 @@ import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-import io.netty.channel.ChannelHandlerContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
public class ClientManageProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final BrokerController brokerController;
@@ -49,7 +48,7 @@ public class ClientManageProcessor implements NettyRequestProcessor {
@Override
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
+ throws RemotingCommandException {
switch (request.getCode()) {
case RequestCode.HEART_BEAT:
return this.heartBeat(ctx, request);
@@ -70,16 +69,16 @@ public class ClientManageProcessor implements NettyRequestProcessor {
RemotingCommand response = RemotingCommand.createResponseCommand(null);
HeartbeatData heartbeatData = HeartbeatData.decode(request.getBody(), HeartbeatData.class);
ClientChannelInfo clientChannelInfo = new ClientChannelInfo(
- ctx.channel(),
- heartbeatData.getClientID(),
- request.getLanguage(),
- request.getVersion()
+ ctx.channel(),
+ heartbeatData.getClientID(),
+ request.getLanguage(),
+ request.getVersion()
);
for (ConsumerData data : heartbeatData.getConsumerDataSet()) {
SubscriptionGroupConfig subscriptionGroupConfig =
- this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(
- data.getGroupName());
+ this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(
+ data.getGroupName());
boolean isNotifyConsumerIdsChangedEnable = true;
if (null != subscriptionGroupConfig) {
isNotifyConsumerIdsChangedEnable = subscriptionGroupConfig.isNotifyConsumerIdsChangedEnable();
@@ -89,32 +88,32 @@ public class ClientManageProcessor implements NettyRequestProcessor {
}
String newTopic = MixAll.getRetryTopic(data.getGroupName());
this.brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(
- newTopic,
- subscriptionGroupConfig.getRetryQueueNums(),
- PermName.PERM_WRITE | PermName.PERM_READ, topicSysFlag);
+ newTopic,
+ subscriptionGroupConfig.getRetryQueueNums(),
+ PermName.PERM_WRITE | PermName.PERM_READ, topicSysFlag);
}
boolean changed = this.brokerController.getConsumerManager().registerConsumer(
- data.getGroupName(),
- clientChannelInfo,
- data.getConsumeType(),
- data.getMessageModel(),
- data.getConsumeFromWhere(),
- data.getSubscriptionDataSet(),
- isNotifyConsumerIdsChangedEnable
+ data.getGroupName(),
+ clientChannelInfo,
+ data.getConsumeType(),
+ data.getMessageModel(),
+ data.getConsumeFromWhere(),
+ data.getSubscriptionDataSet(),
+ isNotifyConsumerIdsChangedEnable
);
if (changed) {
log.info("registerConsumer info changed {} {}",
- data.toString(),
- RemotingHelper.parseChannelRemoteAddr(ctx.channel())
+ data.toString(),
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel())
);
}
}
for (ProducerData data : heartbeatData.getProducerDataSet()) {
this.brokerController.getProducerManager().registerProducer(data.getGroupName(),
- clientChannelInfo);
+ clientChannelInfo);
}
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
@@ -122,18 +121,18 @@ public class ClientManageProcessor implements NettyRequestProcessor {
}
public RemotingCommand unregisterClient(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
+ throws RemotingCommandException {
final RemotingCommand response =
- RemotingCommand.createResponseCommand(UnregisterClientResponseHeader.class);
+ RemotingCommand.createResponseCommand(UnregisterClientResponseHeader.class);
final UnregisterClientRequestHeader requestHeader =
- (UnregisterClientRequestHeader) request
- .decodeCommandCustomHeader(UnregisterClientRequestHeader.class);
+ (UnregisterClientRequestHeader)request
+ .decodeCommandCustomHeader(UnregisterClientRequestHeader.class);
ClientChannelInfo clientChannelInfo = new ClientChannelInfo(
- ctx.channel(),
- requestHeader.getClientID(),
- request.getLanguage(),
- request.getVersion());
+ ctx.channel(),
+ requestHeader.getClientID(),
+ request.getLanguage(),
+ request.getVersion());
{
final String group = requestHeader.getProducerGroup();
if (group != null) {
@@ -145,7 +144,7 @@ public class ClientManageProcessor implements NettyRequestProcessor {
final String group = requestHeader.getConsumerGroup();
if (group != null) {
SubscriptionGroupConfig subscriptionGroupConfig =
- this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(group);
+ this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(group);
boolean isNotifyConsumerIdsChangedEnable = true;
if (null != subscriptionGroupConfig) {
isNotifyConsumerIdsChangedEnable = subscriptionGroupConfig.isNotifyConsumerIdsChangedEnable();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
index c0c43e0..d2e6d7d 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
@@ -16,36 +16,39 @@
*/
package org.apache.rocketmq.broker.processor;
+import io.netty.channel.ChannelHandlerContext;
+import java.util.List;
import org.apache.rocketmq.broker.BrokerController;
import org.apache.rocketmq.broker.client.ConsumerGroupInfo;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.common.protocol.RequestCode;
import org.apache.rocketmq.common.protocol.ResponseCode;
+import org.apache.rocketmq.common.protocol.header.GetConsumerListByGroupRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetConsumerListByGroupResponseBody;
+import org.apache.rocketmq.common.protocol.header.GetConsumerListByGroupResponseHeader;
+import org.apache.rocketmq.common.protocol.header.QueryConsumerOffsetRequestHeader;
+import org.apache.rocketmq.common.protocol.header.QueryConsumerOffsetResponseHeader;
+import org.apache.rocketmq.common.protocol.header.UpdateConsumerOffsetRequestHeader;
+import org.apache.rocketmq.common.protocol.header.UpdateConsumerOffsetResponseHeader;
import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-import io.netty.channel.ChannelHandlerContext;
-import org.apache.rocketmq.common.protocol.header.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.List;
-
-
public class ConsumerManageProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final BrokerController brokerController;
-
public ConsumerManageProcessor(final BrokerController brokerController) {
this.brokerController = brokerController;
}
@Override
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
+ throws RemotingCommandException {
switch (request.getCode()) {
case RequestCode.GET_CONSUMER_LIST_BY_GROUP:
return this.getConsumerListByGroup(ctx, request);
@@ -64,18 +67,17 @@ public class ConsumerManageProcessor implements NettyRequestProcessor {
return false;
}
-
public RemotingCommand getConsumerListByGroup(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
+ throws RemotingCommandException {
final RemotingCommand response =
- RemotingCommand.createResponseCommand(GetConsumerListByGroupResponseHeader.class);
+ RemotingCommand.createResponseCommand(GetConsumerListByGroupResponseHeader.class);
final GetConsumerListByGroupRequestHeader requestHeader =
- (GetConsumerListByGroupRequestHeader) request
- .decodeCommandCustomHeader(GetConsumerListByGroupRequestHeader.class);
+ (GetConsumerListByGroupRequestHeader)request
+ .decodeCommandCustomHeader(GetConsumerListByGroupRequestHeader.class);
ConsumerGroupInfo consumerGroupInfo =
- this.brokerController.getConsumerManager().getConsumerGroupInfo(
- requestHeader.getConsumerGroup());
+ this.brokerController.getConsumerManager().getConsumerGroupInfo(
+ requestHeader.getConsumerGroup());
if (consumerGroupInfo != null) {
List<String> clientIds = consumerGroupInfo.getAllClientId();
if (!clientIds.isEmpty()) {
@@ -87,11 +89,11 @@ public class ConsumerManageProcessor implements NettyRequestProcessor {
return response;
} else {
log.warn("getAllClientId failed, {} {}", requestHeader.getConsumerGroup(),
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
}
} else {
log.warn("getConsumerGroupInfo failed, {} {}", requestHeader.getConsumerGroup(),
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
}
response.setCode(ResponseCode.SYSTEM_ERROR);
@@ -100,34 +102,32 @@ public class ConsumerManageProcessor implements NettyRequestProcessor {
}
private RemotingCommand updateConsumerOffset(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
+ throws RemotingCommandException {
final RemotingCommand response =
- RemotingCommand.createResponseCommand(UpdateConsumerOffsetResponseHeader.class);
+ RemotingCommand.createResponseCommand(UpdateConsumerOffsetResponseHeader.class);
final UpdateConsumerOffsetRequestHeader requestHeader =
- (UpdateConsumerOffsetRequestHeader) request
- .decodeCommandCustomHeader(UpdateConsumerOffsetRequestHeader.class);
+ (UpdateConsumerOffsetRequestHeader)request
+ .decodeCommandCustomHeader(UpdateConsumerOffsetRequestHeader.class);
this.brokerController.getConsumerOffsetManager().commitOffset(RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getConsumerGroup(),
- requestHeader.getTopic(), requestHeader.getQueueId(), requestHeader.getCommitOffset());
+ requestHeader.getTopic(), requestHeader.getQueueId(), requestHeader.getCommitOffset());
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
return response;
}
-
private RemotingCommand queryConsumerOffset(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
+ throws RemotingCommandException {
final RemotingCommand response =
- RemotingCommand.createResponseCommand(QueryConsumerOffsetResponseHeader.class);
+ RemotingCommand.createResponseCommand(QueryConsumerOffsetResponseHeader.class);
final QueryConsumerOffsetResponseHeader responseHeader =
- (QueryConsumerOffsetResponseHeader) response.readCustomHeader();
+ (QueryConsumerOffsetResponseHeader)response.readCustomHeader();
final QueryConsumerOffsetRequestHeader requestHeader =
- (QueryConsumerOffsetRequestHeader) request
- .decodeCommandCustomHeader(QueryConsumerOffsetRequestHeader.class);
+ (QueryConsumerOffsetRequestHeader)request
+ .decodeCommandCustomHeader(QueryConsumerOffsetRequestHeader.class);
long offset =
- this.brokerController.getConsumerOffsetManager().queryOffset(
- requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueId());
-
+ this.brokerController.getConsumerOffsetManager().queryOffset(
+ requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueId());
if (offset >= 0) {
responseHeader.setOffset(offset);
@@ -135,11 +135,11 @@ public class ConsumerManageProcessor implements NettyRequestProcessor {
response.setRemark(null);
} else {
long minOffset =
- this.brokerController.getMessageStore().getMinOffsetInQuque(requestHeader.getTopic(),
- requestHeader.getQueueId());
+ this.brokerController.getMessageStore().getMinOffsetInQuque(requestHeader.getTopic(),
+ requestHeader.getQueueId());
if (minOffset <= 0
- && !this.brokerController.getMessageStore().checkInDiskByConsumeOffset(
- requestHeader.getTopic(), requestHeader.getQueueId(), 0)) {
+ && !this.brokerController.getMessageStore().checkInDiskByConsumeOffset(
+ requestHeader.getTopic(), requestHeader.getQueueId(), 0)) {
responseHeader.setOffset(0L);
response.setCode(ResponseCode.SUCCESS);
response.setRemark(null);
[36/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/MQClientAPIImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/MQClientAPIImpl.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/MQClientAPIImpl.java
deleted file mode 100644
index 3d5ba28..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/MQClientAPIImpl.java
+++ /dev/null
@@ -1,1996 +0,0 @@
-/**
- * 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.client.impl;
-
-import com.alibaba.rocketmq.client.ClientConfig;
-import com.alibaba.rocketmq.client.consumer.PullCallback;
-import com.alibaba.rocketmq.client.consumer.PullResult;
-import com.alibaba.rocketmq.client.consumer.PullStatus;
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.hook.SendMessageContext;
-import com.alibaba.rocketmq.client.impl.consumer.PullResultExt;
-import com.alibaba.rocketmq.client.impl.factory.MQClientInstance;
-import com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl;
-import com.alibaba.rocketmq.client.impl.producer.TopicPublishInfo;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.client.producer.SendCallback;
-import com.alibaba.rocketmq.client.producer.SendResult;
-import com.alibaba.rocketmq.client.producer.SendStatus;
-import com.alibaba.rocketmq.common.MQVersion;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.TopicConfig;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.admin.ConsumeStats;
-import com.alibaba.rocketmq.common.admin.TopicStatsTable;
-import com.alibaba.rocketmq.common.message.*;
-import com.alibaba.rocketmq.common.namesrv.TopAddressing;
-import com.alibaba.rocketmq.common.protocol.RequestCode;
-import com.alibaba.rocketmq.common.protocol.ResponseCode;
-import com.alibaba.rocketmq.common.protocol.body.*;
-import com.alibaba.rocketmq.common.protocol.header.*;
-import com.alibaba.rocketmq.common.protocol.header.filtersrv.RegisterMessageFilterClassRequestHeader;
-import com.alibaba.rocketmq.common.protocol.header.namesrv.*;
-import com.alibaba.rocketmq.common.protocol.heartbeat.HeartbeatData;
-import com.alibaba.rocketmq.common.protocol.route.TopicRouteData;
-import com.alibaba.rocketmq.common.subscription.SubscriptionGroupConfig;
-import com.alibaba.rocketmq.remoting.InvokeCallback;
-import com.alibaba.rocketmq.remoting.RPCHook;
-import com.alibaba.rocketmq.remoting.RemotingClient;
-import com.alibaba.rocketmq.remoting.exception.*;
-import com.alibaba.rocketmq.remoting.netty.NettyClientConfig;
-import com.alibaba.rocketmq.remoting.netty.NettyRemotingClient;
-import com.alibaba.rocketmq.remoting.netty.ResponseFuture;
-import com.alibaba.rocketmq.remoting.protocol.LanguageCode;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-import org.slf4j.Logger;
-
-import java.io.UnsupportedEncodingException;
-import java.nio.ByteBuffer;
-import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
-
-
-/**
- * @author shijia.wxr
- */
-public class MQClientAPIImpl {
-
- private final static Logger log = ClientLogger.getLog();
- public static boolean sendSmartMsg =
- Boolean.parseBoolean(System.getProperty("com.alibaba.rocketmq.client.sendSmartMsg", "true"));
-
- static {
- System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));
- }
-
- private final RemotingClient remotingClient;
- private final TopAddressing topAddressing;
- private final ClientRemotingProcessor clientRemotingProcessor;
- private String nameSrvAddr = null;
- private ClientConfig clientConfig;
-
- public MQClientAPIImpl(final NettyClientConfig nettyClientConfig, final ClientRemotingProcessor clientRemotingProcessor,
- RPCHook rpcHook, final ClientConfig clientConfig) {
- this.clientConfig = clientConfig;
- topAddressing = new TopAddressing(MixAll.WS_ADDR, clientConfig.getUnitName());
- this.remotingClient = new NettyRemotingClient(nettyClientConfig, null);
- this.clientRemotingProcessor = clientRemotingProcessor;
-
- this.remotingClient.registerRPCHook(rpcHook);
- this.remotingClient.registerProcessor(RequestCode.CHECK_TRANSACTION_STATE, this.clientRemotingProcessor, null);
-
- this.remotingClient.registerProcessor(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, this.clientRemotingProcessor, null);
-
- this.remotingClient.registerProcessor(RequestCode.RESET_CONSUMER_CLIENT_OFFSET, this.clientRemotingProcessor, null);
-
- this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT, this.clientRemotingProcessor, null);
-
- this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_RUNNING_INFO, this.clientRemotingProcessor, null);
-
- this.remotingClient.registerProcessor(RequestCode.CONSUME_MESSAGE_DIRECTLY, this.clientRemotingProcessor, null);
- }
-
- public List<String> getNameServerAddressList() {
- return this.remotingClient.getNameServerAddressList();
- }
-
- public RemotingClient getRemotingClient() {
- return remotingClient;
- }
-
- public String fetchNameServerAddr() {
- try {
- String addrs = this.topAddressing.fetchNSAddr();
- if (addrs != null) {
- if (!addrs.equals(this.nameSrvAddr)) {
- log.info("name server address changed, old=" + this.nameSrvAddr + ", new=" + addrs);
- this.updateNameServerAddressList(addrs);
- this.nameSrvAddr = addrs;
- return nameSrvAddr;
- }
- }
- } catch (Exception e) {
- log.error("fetchNameServerAddr Exception", e);
- }
- return nameSrvAddr;
- }
-
- public void updateNameServerAddressList(final String addrs) {
- List<String> lst = new ArrayList<String>();
- String[] addrArray = addrs.split(";");
- if (addrArray != null) {
- for (String addr : addrArray) {
- lst.add(addr);
- }
-
- this.remotingClient.updateNameServerAddressList(lst);
- }
- }
-
- public void start() {
- this.remotingClient.start();
- }
-
- public void shutdown() {
- this.remotingClient.shutdown();
- }
-
- public void createSubscriptionGroup(final String addr, final SubscriptionGroupConfig config, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_SUBSCRIPTIONGROUP, null);
-
- byte[] body = RemotingSerializable.encode(config);
- request.setBody(body);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return;
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
-
- }
-
- public void createTopic(final String addr, final String defaultTopic, final TopicConfig topicConfig, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- CreateTopicRequestHeader requestHeader = new CreateTopicRequestHeader();
- requestHeader.setTopic(topicConfig.getTopicName());
- requestHeader.setDefaultTopic(defaultTopic);
- requestHeader.setReadQueueNums(topicConfig.getReadQueueNums());
- requestHeader.setWriteQueueNums(topicConfig.getWriteQueueNums());
- requestHeader.setPerm(topicConfig.getPerm());
- requestHeader.setTopicFilterType(topicConfig.getTopicFilterType().name());
- requestHeader.setTopicSysFlag(topicConfig.getTopicSysFlag());
- requestHeader.setOrder(topicConfig.isOrder());
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_AND_CREATE_TOPIC, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return;
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
- public SendResult sendMessage(//
- final String addr, // 1
- final String brokerName, // 2
- final Message msg, // 3
- final SendMessageRequestHeader requestHeader, // 4
- final long timeoutMillis, // 5
- final CommunicationMode communicationMode, // 6
- final SendMessageContext context, // 7
- final DefaultMQProducerImpl producer // 8
- ) throws RemotingException, MQBrokerException, InterruptedException {
- return sendMessage(addr, brokerName, msg, requestHeader, timeoutMillis, communicationMode, null, null, null, 0, context, producer);
- }
-
- public SendResult sendMessage(//
- final String addr, // 1
- final String brokerName, // 2
- final Message msg, // 3
- final SendMessageRequestHeader requestHeader, // 4
- final long timeoutMillis, // 5
- final CommunicationMode communicationMode, // 6
- final SendCallback sendCallback, // 7
- final TopicPublishInfo topicPublishInfo, // 8
- final MQClientInstance instance, // 9
- final int retryTimesWhenSendFailed, // 10
- final SendMessageContext context, // 11
- final DefaultMQProducerImpl producer // 12
- ) throws RemotingException, MQBrokerException, InterruptedException {
- RemotingCommand request = null;
- if (sendSmartMsg) {
- SendMessageRequestHeaderV2 requestHeaderV2 = SendMessageRequestHeaderV2.createSendMessageRequestHeaderV2(requestHeader);
- request = RemotingCommand.createRequestCommand(RequestCode.SEND_MESSAGE_V2, requestHeaderV2);
- } else {
- request = RemotingCommand.createRequestCommand(RequestCode.SEND_MESSAGE, requestHeader);
- }
-
- request.setBody(msg.getBody());
-
- switch (communicationMode) {
- case ONEWAY:
- this.remotingClient.invokeOneway(addr, request, timeoutMillis);
- return null;
- case ASYNC:
- final AtomicInteger times = new AtomicInteger();
- this.sendMessageAsync(addr, brokerName, msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance,
- retryTimesWhenSendFailed, times, context, producer);
- return null;
- case SYNC:
- return this.sendMessageSync(addr, brokerName, msg, timeoutMillis, request);
- default:
- assert false;
- break;
- }
-
- return null;
- }
-
- private SendResult sendMessageSync(//
- final String addr, //
- final String brokerName, //
- final Message msg, //
- final long timeoutMillis, //
- final RemotingCommand request//
- ) throws RemotingException, MQBrokerException, InterruptedException {
- RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
- assert response != null;
- return this.processSendResponse(brokerName, msg, response);
- }
-
- private void sendMessageAsync(//
- final String addr, //
- final String brokerName, //
- final Message msg, //
- final long timeoutMillis, //
- final RemotingCommand request, //
- final SendCallback sendCallback, //
- final TopicPublishInfo topicPublishInfo, //
- final MQClientInstance instance, //
- final int retryTimesWhenSendFailed, //
- final AtomicInteger times, //
- final SendMessageContext context, //
- final DefaultMQProducerImpl producer //
- ) throws InterruptedException, RemotingException {
- this.remotingClient.invokeAsync(addr, request, timeoutMillis, new InvokeCallback() {
- @Override
- public void operationComplete(ResponseFuture responseFuture) {
- RemotingCommand response = responseFuture.getResponseCommand();
- if (null == sendCallback && response != null) {
-
- try {
- SendResult sendResult = MQClientAPIImpl.this.processSendResponse(brokerName, msg, response);
- if (context != null && sendResult != null) {
- context.setSendResult(sendResult);
- context.getProducer().executeSendMessageHookAfter(context);
- }
- } catch (Throwable e) {
- //
- }
-
- producer.updateFaultItem(brokerName, System.currentTimeMillis() - responseFuture.getBeginTimestamp(), false);
- return;
- }
-
- if (response != null) {
- try {
- SendResult sendResult = MQClientAPIImpl.this.processSendResponse(brokerName, msg, response);
- assert sendResult != null;
- if (context != null) {
- context.setSendResult(sendResult);
- context.getProducer().executeSendMessageHookAfter(context);
- }
-
- try {
- sendCallback.onSuccess(sendResult);
- } catch (Throwable e) {
- }
-
- producer.updateFaultItem(brokerName, System.currentTimeMillis() - responseFuture.getBeginTimestamp(), false);
- } catch (Exception e) {
- producer.updateFaultItem(brokerName, System.currentTimeMillis() - responseFuture.getBeginTimestamp(), true);
- onExceptionImpl(brokerName, msg, 0L, request, sendCallback, topicPublishInfo, instance,
- retryTimesWhenSendFailed, times, e, context, false, producer);
- }
- } else {
- producer.updateFaultItem(brokerName, System.currentTimeMillis() - responseFuture.getBeginTimestamp(), true);
- if (!responseFuture.isSendRequestOK()) {
- MQClientException ex = new MQClientException("send request failed", responseFuture.getCause());
- onExceptionImpl(brokerName, msg, 0L, request, sendCallback, topicPublishInfo, instance,
- retryTimesWhenSendFailed, times, ex, context, true, producer);
- } else if (responseFuture.isTimeout()) {
- MQClientException ex = new MQClientException("wait response timeout " + responseFuture.getTimeoutMillis() + "ms",
- responseFuture.getCause());
- onExceptionImpl(brokerName, msg, 0L, request, sendCallback, topicPublishInfo, instance,
- retryTimesWhenSendFailed, times, ex, context, true, producer);
- } else {
- MQClientException ex = new MQClientException("unknow reseaon", responseFuture.getCause());
- onExceptionImpl(brokerName, msg, 0L, request, sendCallback, topicPublishInfo, instance,
- retryTimesWhenSendFailed, times, ex, context, true, producer);
- }
- }
- }
- });
- }
-
-
- private void onExceptionImpl(final String brokerName, //
- final Message msg, //
- final long timeoutMillis, //
- final RemotingCommand request, //
- final SendCallback sendCallback, //
- final TopicPublishInfo topicPublishInfo, //
- final MQClientInstance instance, //
- final int timesTotal, //
- final AtomicInteger curTimes, //
- final Exception e, //
- final SendMessageContext context, //
- final boolean needRetry, //
- final DefaultMQProducerImpl producer // 12
- ) {
- int tmp = curTimes.incrementAndGet();
- if (needRetry && tmp <= timesTotal) {
- MessageQueue tmpmq = producer.selectOneMessageQueue(topicPublishInfo, brokerName);
- String addr = instance.findBrokerAddressInPublish(tmpmq.getBrokerName());
- log.info("async send msg by retry {} times. topic={}, brokerAddr={}, brokerName={}", tmp, msg.getTopic(), addr,
- tmpmq.getBrokerName());
- try {
- request.setOpaque(RemotingCommand.createNewRequestId());
- sendMessageAsync(addr, tmpmq.getBrokerName(), msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance,
- timesTotal, curTimes, context, producer);
- } catch (InterruptedException e1) {
- onExceptionImpl(tmpmq.getBrokerName(), msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance, timesTotal, curTimes, e1,
- context, false, producer);
- } catch (RemotingConnectException e1) {
- producer.updateFaultItem(brokerName, 3000, true);
- onExceptionImpl(tmpmq.getBrokerName(), msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance, timesTotal, curTimes, e1,
- context, true, producer);
- } catch (RemotingTooMuchRequestException e1) {
- onExceptionImpl(tmpmq.getBrokerName(), msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance, timesTotal, curTimes, e1,
- context, false, producer);
- } catch (RemotingException e1) {
- producer.updateFaultItem(brokerName, 3000, true);
- onExceptionImpl(tmpmq.getBrokerName(), msg, timeoutMillis, request, sendCallback, topicPublishInfo, instance, timesTotal, curTimes, e1,
- context, true, producer);
- }
- } else {
- if (context != null) {
- context.setException(e);
- context.getProducer().executeSendMessageHookAfter(context);
- }
- try {
- sendCallback.onException(e);
- } catch (Exception e2) {
- }
- }
- }
-
-
- private SendResult processSendResponse(//
- final String brokerName, //
- final Message msg, //
- final RemotingCommand response//
- ) throws MQBrokerException, RemotingCommandException {
- switch (response.getCode()) {
- case ResponseCode.FLUSH_DISK_TIMEOUT:
- case ResponseCode.FLUSH_SLAVE_TIMEOUT:
- case ResponseCode.SLAVE_NOT_AVAILABLE: {
- // TODO LOG
- }
- case ResponseCode.SUCCESS: {
- SendStatus sendStatus = SendStatus.SEND_OK;
- switch (response.getCode()) {
- case ResponseCode.FLUSH_DISK_TIMEOUT:
- sendStatus = SendStatus.FLUSH_DISK_TIMEOUT;
- break;
- case ResponseCode.FLUSH_SLAVE_TIMEOUT:
- sendStatus = SendStatus.FLUSH_SLAVE_TIMEOUT;
- break;
- case ResponseCode.SLAVE_NOT_AVAILABLE:
- sendStatus = SendStatus.SLAVE_NOT_AVAILABLE;
- break;
- case ResponseCode.SUCCESS:
- sendStatus = SendStatus.SEND_OK;
- break;
- default:
- assert false;
- break;
- }
-
- SendMessageResponseHeader responseHeader =
- (SendMessageResponseHeader) response.decodeCommandCustomHeader(SendMessageResponseHeader.class);
-
- MessageQueue messageQueue = new MessageQueue(msg.getTopic(), brokerName, responseHeader.getQueueId());
-
- SendResult sendResult = new SendResult(sendStatus,
- MessageClientIDSetter.getUniqID(msg),
- responseHeader.getMsgId(), messageQueue, responseHeader.getQueueOffset());
- sendResult.setTransactionId(responseHeader.getTransactionId());
- String regionId = response.getExtFields().get(MessageConst.PROPERTY_MSG_REGION);
- String traceOn = response.getExtFields().get(MessageConst.PROPERTY_TRACE_SWITCH);
- if (regionId == null || regionId.isEmpty()) {
- regionId = MixAll.DEFAULT_TRACE_REGION_ID;
- }
- if (traceOn != null && traceOn.equals("false")) {
- sendResult.setTraceOn(false);
- } else {
- sendResult.setTraceOn(true);
- }
- sendResult.setRegionId(regionId);
- return sendResult;
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public PullResult pullMessage(//
- final String addr, //
- final PullMessageRequestHeader requestHeader, //
- final long timeoutMillis, //
- final CommunicationMode communicationMode, //
- final PullCallback pullCallback//
- ) throws RemotingException, MQBrokerException, InterruptedException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.PULL_MESSAGE, requestHeader);
-
- switch (communicationMode) {
- case ONEWAY:
- assert false;
- return null;
- case ASYNC:
- this.pullMessageAsync(addr, request, timeoutMillis, pullCallback);
- return null;
- case SYNC:
- return this.pullMessageSync(addr, request, timeoutMillis);
- default:
- assert false;
- break;
- }
-
- return null;
- }
-
-
- private void pullMessageAsync(//
- final String addr, // 1
- final RemotingCommand request, //
- final long timeoutMillis, //
- final PullCallback pullCallback//
- ) throws RemotingException, InterruptedException {
- this.remotingClient.invokeAsync(addr, request, timeoutMillis, new InvokeCallback() {
- @Override
- public void operationComplete(ResponseFuture responseFuture) {
- RemotingCommand response = responseFuture.getResponseCommand();
- if (response != null) {
- try {
- PullResult pullResult = MQClientAPIImpl.this.processPullResponse(response);
- assert pullResult != null;
- pullCallback.onSuccess(pullResult);
- } catch (Exception e) {
- pullCallback.onException(e);
- }
- } else {
- if (!responseFuture.isSendRequestOK()) {
- pullCallback.onException(new MQClientException("send request failed", responseFuture.getCause()));
- } else if (responseFuture.isTimeout()) {
- pullCallback.onException(new MQClientException("wait response timeout " + responseFuture.getTimeoutMillis() + "ms",
- responseFuture.getCause()));
- } else {
- pullCallback.onException(new MQClientException("unknow reseaon", responseFuture.getCause()));
- }
- }
- }
- });
- }
-
- private PullResult pullMessageSync(//
- final String addr, // 1
- final RemotingCommand request, // 2
- final long timeoutMillis// 3
- ) throws RemotingException, InterruptedException, MQBrokerException {
- RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
- assert response != null;
- return this.processPullResponse(response);
- }
-
- private PullResult processPullResponse(final RemotingCommand response) throws MQBrokerException, RemotingCommandException {
- PullStatus pullStatus = PullStatus.NO_NEW_MSG;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS:
- pullStatus = PullStatus.FOUND;
- break;
- case ResponseCode.PULL_NOT_FOUND:
- pullStatus = PullStatus.NO_NEW_MSG;
- break;
- case ResponseCode.PULL_RETRY_IMMEDIATELY:
- pullStatus = PullStatus.NO_MATCHED_MSG;
- break;
- case ResponseCode.PULL_OFFSET_MOVED:
- pullStatus = PullStatus.OFFSET_ILLEGAL;
- break;
-
- default:
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
- PullMessageResponseHeader responseHeader =
- (PullMessageResponseHeader) response.decodeCommandCustomHeader(PullMessageResponseHeader.class);
-
- return new PullResultExt(pullStatus, responseHeader.getNextBeginOffset(), responseHeader.getMinOffset(),
- responseHeader.getMaxOffset(), null, responseHeader.getSuggestWhichBrokerId(), response.getBody());
- }
-
- public MessageExt viewMessage(final String addr, final long phyoffset, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException {
- ViewMessageRequestHeader requestHeader = new ViewMessageRequestHeader();
- requestHeader.setOffset(phyoffset);
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.VIEW_MESSAGE_BY_ID, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- ByteBuffer byteBuffer = ByteBuffer.wrap(response.getBody());
- MessageExt messageExt = MessageDecoder.clientDecode(byteBuffer, true);
- return messageExt;
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public long searchOffset(final String addr, final String topic, final int queueId, final long timestamp, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException {
- SearchOffsetRequestHeader requestHeader = new SearchOffsetRequestHeader();
- requestHeader.setTopic(topic);
- requestHeader.setQueueId(queueId);
- requestHeader.setTimestamp(timestamp);
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.SEARCH_OFFSET_BY_TIMESTAMP, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- SearchOffsetResponseHeader responseHeader =
- (SearchOffsetResponseHeader) response.decodeCommandCustomHeader(SearchOffsetResponseHeader.class);
- return responseHeader.getOffset();
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public long getMaxOffset(final String addr, final String topic, final int queueId, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException {
- GetMaxOffsetRequestHeader requestHeader = new GetMaxOffsetRequestHeader();
- requestHeader.setTopic(topic);
- requestHeader.setQueueId(queueId);
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_MAX_OFFSET, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- GetMaxOffsetResponseHeader responseHeader =
- (GetMaxOffsetResponseHeader) response.decodeCommandCustomHeader(GetMaxOffsetResponseHeader.class);
-
- return responseHeader.getOffset();
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public List<String> getConsumerIdListByGroup(//
- final String addr, //
- final String consumerGroup, //
- final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
- MQBrokerException, InterruptedException {
- GetConsumerListByGroupRequestHeader requestHeader = new GetConsumerListByGroupRequestHeader();
- requestHeader.setConsumerGroup(consumerGroup);
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_LIST_BY_GROUP, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- if (response.getBody() != null) {
- GetConsumerListByGroupResponseBody body =
- GetConsumerListByGroupResponseBody.decode(response.getBody(), GetConsumerListByGroupResponseBody.class);
- return body.getConsumerIdList();
- }
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public long getMinOffset(final String addr, final String topic, final int queueId, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException {
- GetMinOffsetRequestHeader requestHeader = new GetMinOffsetRequestHeader();
- requestHeader.setTopic(topic);
- requestHeader.setQueueId(queueId);
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_MIN_OFFSET, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- GetMinOffsetResponseHeader responseHeader =
- (GetMinOffsetResponseHeader) response.decodeCommandCustomHeader(GetMinOffsetResponseHeader.class);
-
- return responseHeader.getOffset();
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public long getEarliestMsgStoretime(final String addr, final String topic, final int queueId, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException {
- GetEarliestMsgStoretimeRequestHeader requestHeader = new GetEarliestMsgStoretimeRequestHeader();
- requestHeader.setTopic(topic);
- requestHeader.setQueueId(queueId);
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_EARLIEST_MSG_STORETIME, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- GetEarliestMsgStoretimeResponseHeader responseHeader =
- (GetEarliestMsgStoretimeResponseHeader) response.decodeCommandCustomHeader(GetEarliestMsgStoretimeResponseHeader.class);
-
- return responseHeader.getTimestamp();
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public long queryConsumerOffset(//
- final String addr, //
- final QueryConsumerOffsetRequestHeader requestHeader, //
- final long timeoutMillis//
- ) throws RemotingException, MQBrokerException, InterruptedException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CONSUMER_OFFSET, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- QueryConsumerOffsetResponseHeader responseHeader =
- (QueryConsumerOffsetResponseHeader) response.decodeCommandCustomHeader(QueryConsumerOffsetResponseHeader.class);
-
- return responseHeader.getOffset();
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public void updateConsumerOffset(//
- final String addr, //
- final UpdateConsumerOffsetRequestHeader requestHeader, //
- final long timeoutMillis//
- ) throws RemotingException, MQBrokerException, InterruptedException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_CONSUMER_OFFSET, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return;
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public void updateConsumerOffsetOneway(//
- final String addr, //
- final UpdateConsumerOffsetRequestHeader requestHeader, //
- final long timeoutMillis//
- ) throws RemotingConnectException, RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException,
- InterruptedException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_CONSUMER_OFFSET, requestHeader);
-
- this.remotingClient.invokeOneway(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
- }
-
-
- public void sendHearbeat(//
- final String addr, //
- final HeartbeatData heartbeatData, //
- final long timeoutMillis//
- ) throws RemotingException, MQBrokerException, InterruptedException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.HEART_BEAT, null);
-
- request.setBody(heartbeatData.encode());
- RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return;
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public void unregisterClient(//
- final String addr, //
- final String clientID, //
- final String producerGroup, //
- final String consumerGroup, //
- final long timeoutMillis//
- ) throws RemotingException, MQBrokerException, InterruptedException {
- final UnregisterClientRequestHeader requestHeader = new UnregisterClientRequestHeader();
- requestHeader.setClientID(clientID);
- requestHeader.setProducerGroup(producerGroup);
- requestHeader.setConsumerGroup(consumerGroup);
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UNREGISTER_CLIENT, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return;
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public void endTransactionOneway(//
- final String addr, //
- final EndTransactionRequestHeader requestHeader, //
- final String remark, //
- final long timeoutMillis//
- ) throws RemotingException, MQBrokerException, InterruptedException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.END_TRANSACTION, requestHeader);
-
- request.setRemark(remark);
- this.remotingClient.invokeOneway(addr, request, timeoutMillis);
- }
-
-
- public void queryMessage(
- final String addr,
- final QueryMessageRequestHeader requestHeader,
- final long timeoutMillis,
- final InvokeCallback invokeCallback,
- final Boolean isUnqiueKey
- ) throws RemotingException, MQBrokerException, InterruptedException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_MESSAGE, requestHeader);
- request.addExtField(MixAll.UNIQUE_MSG_QUERY_FLAG, isUnqiueKey.toString());
- this.remotingClient.invokeAsync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis,
- invokeCallback);
- }
-
-
- public boolean registerClient(final String addr, final HeartbeatData heartbeat, final long timeoutMillis)
- throws RemotingException, InterruptedException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.HEART_BEAT, null);
-
- request.setBody(heartbeat.encode());
- RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
- return response.getCode() == ResponseCode.SUCCESS;
- }
-
-
- public void consumerSendMessageBack(
- final String addr,
- final MessageExt msg,
- final String consumerGroup,
- final int delayLevel,
- final long timeoutMillis,
- final int maxConsumeRetryTimes
- ) throws RemotingException, MQBrokerException, InterruptedException {
- ConsumerSendMsgBackRequestHeader requestHeader = new ConsumerSendMsgBackRequestHeader();
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.CONSUMER_SEND_MSG_BACK, requestHeader);
-
- requestHeader.setGroup(consumerGroup);
- requestHeader.setOriginTopic(msg.getTopic());
- requestHeader.setOffset(msg.getCommitLogOffset());
- requestHeader.setDelayLevel(delayLevel);
- requestHeader.setOriginMsgId(msg.getMsgId());
- requestHeader.setMaxReconsumeTimes(maxConsumeRetryTimes);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return;
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public Set<MessageQueue> lockBatchMQ(//
- final String addr, //
- final LockBatchRequestBody requestBody, //
- final long timeoutMillis) throws RemotingException, MQBrokerException, InterruptedException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.LOCK_BATCH_MQ, null);
-
- request.setBody(requestBody.encode());
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- LockBatchResponseBody responseBody = LockBatchResponseBody.decode(response.getBody(), LockBatchResponseBody.class);
- Set<MessageQueue> messageQueues = responseBody.getLockOKMQSet();
- return messageQueues;
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public void unlockBatchMQ(//
- final String addr, //
- final UnlockBatchRequestBody requestBody, //
- final long timeoutMillis, //
- final boolean oneway//
- ) throws RemotingException, MQBrokerException, InterruptedException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UNLOCK_BATCH_MQ, null);
-
- request.setBody(requestBody.encode());
-
- if (oneway) {
- this.remotingClient.invokeOneway(addr, request, timeoutMillis);
- } else {
- RemotingCommand response = this.remotingClient
- .invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return;
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
- }
-
-
- public TopicStatsTable getTopicStatsInfo(final String addr, final String topic, final long timeoutMillis) throws InterruptedException,
- RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
- GetTopicStatsInfoRequestHeader requestHeader = new GetTopicStatsInfoRequestHeader();
- requestHeader.setTopic(topic);
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPIC_STATS_INFO, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- TopicStatsTable topicStatsTable = TopicStatsTable.decode(response.getBody(), TopicStatsTable.class);
- return topicStatsTable;
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public ConsumeStats getConsumeStats(final String addr, final String consumerGroup, final long timeoutMillis)
- throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException,
- MQBrokerException {
- return getConsumeStats(addr, consumerGroup, null, timeoutMillis);
- }
-
-
- public ConsumeStats getConsumeStats(final String addr, final String consumerGroup, final String topic, final long timeoutMillis)
- throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException,
- MQBrokerException {
- GetConsumeStatsRequestHeader requestHeader = new GetConsumeStatsRequestHeader();
- requestHeader.setConsumerGroup(consumerGroup);
- requestHeader.setTopic(topic);
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUME_STATS, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- ConsumeStats consumeStats = ConsumeStats.decode(response.getBody(), ConsumeStats.class);
- return consumeStats;
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public ProducerConnection getProducerConnectionList(final String addr, final String producerGroup, final long timeoutMillis)
- throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
- MQBrokerException {
- GetProducerConnectionListRequestHeader requestHeader = new GetProducerConnectionListRequestHeader();
- requestHeader.setProducerGroup(producerGroup);
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_PRODUCER_CONNECTION_LIST, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return ProducerConnection.decode(response.getBody(), ProducerConnection.class);
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public ConsumerConnection getConsumerConnectionList(final String addr, final String consumerGroup, final long timeoutMillis)
- throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
- MQBrokerException {
- GetConsumerConnectionListRequestHeader requestHeader = new GetConsumerConnectionListRequestHeader();
- requestHeader.setConsumerGroup(consumerGroup);
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_CONNECTION_LIST, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- ConsumerConnection consumerConnection = ConsumerConnection.decode(response.getBody(), ConsumerConnection.class);
- return consumerConnection;
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public KVTable getBrokerRuntimeInfo(final String addr, final long timeoutMillis) throws RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException {
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_RUNTIME_INFO, null);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return KVTable.decode(response.getBody(), KVTable.class);
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public void updateBrokerConfig(final String addr, final Properties properties, final long timeoutMillis)
- throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
- MQBrokerException, UnsupportedEncodingException {
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UPDATE_BROKER_CONFIG, null);
-
- String str = MixAll.properties2String(properties);
- if (str != null && str.length() > 0) {
- request.setBody(str.getBytes(MixAll.DEFAULT_CHARSET));
- RemotingCommand response = this.remotingClient
- .invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis);
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return;
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
- }
-
-
- public Properties getBrokerConfig(final String addr, final long timeoutMillis)
- throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
- MQBrokerException, UnsupportedEncodingException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_CONFIG, null);
-
- RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return MixAll.string2Properties(new String(response.getBody(), MixAll.DEFAULT_CHARSET));
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
- public ClusterInfo getBrokerClusterInfo(final long timeoutMillis) throws InterruptedException, RemotingTimeoutException,
- RemotingSendRequestException, RemotingConnectException, MQBrokerException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_CLUSTER_INFO, null);
-
- RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- ClusterInfo responseBody = ClusterInfo.decode(response.getBody(), ClusterInfo.class);
- return responseBody;
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public TopicRouteData getDefaultTopicRouteInfoFromNameServer(final String topic, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
- GetRouteInfoRequestHeader requestHeader = new GetRouteInfoRequestHeader();
- requestHeader.setTopic(topic);
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ROUTEINTO_BY_TOPIC, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.TOPIC_NOT_EXIST: {
- // TODO LOG
- break;
- }
- case ResponseCode.SUCCESS: {
- byte[] body = response.getBody();
- if (body != null) {
- return TopicRouteData.decode(body, TopicRouteData.class);
- }
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public TopicRouteData getTopicRouteInfoFromNameServer(final String topic, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
- GetRouteInfoRequestHeader requestHeader = new GetRouteInfoRequestHeader();
- requestHeader.setTopic(topic);
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ROUTEINTO_BY_TOPIC, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.TOPIC_NOT_EXIST: {
- if (!topic.equals(MixAll.DEFAULT_TOPIC))
- log.warn("get Topic [{}] RouteInfoFromNameServer is not exist value", topic);
- break;
- }
- case ResponseCode.SUCCESS: {
- byte[] body = response.getBody();
- if (body != null) {
- return TopicRouteData.decode(body, TopicRouteData.class);
- }
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public TopicList getTopicListFromNameServer(final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_LIST_FROM_NAMESERVER, null);
-
- RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- byte[] body = response.getBody();
- if (body != null) {
- TopicList topicList = TopicList.decode(body, TopicList.class);
- return topicList;
- }
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public int wipeWritePermOfBroker(final String namesrvAddr, String brokerName, final long timeoutMillis) throws RemotingCommandException,
- RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQClientException {
- WipeWritePermOfBrokerRequestHeader requestHeader = new WipeWritePermOfBrokerRequestHeader();
- requestHeader.setBrokerName(brokerName);
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.WIPE_WRITE_PERM_OF_BROKER, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(namesrvAddr, request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- WipeWritePermOfBrokerResponseHeader responseHeader =
- (WipeWritePermOfBrokerResponseHeader) response.decodeCommandCustomHeader(WipeWritePermOfBrokerResponseHeader.class);
- return responseHeader.getWipeTopicCount();
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public void deleteTopicInBroker(final String addr, final String topic, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- DeleteTopicRequestHeader requestHeader = new DeleteTopicRequestHeader();
- requestHeader.setTopic(topic);
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.DELETE_TOPIC_IN_BROKER, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return;
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public void deleteTopicInNameServer(final String addr, final String topic, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- DeleteTopicRequestHeader requestHeader = new DeleteTopicRequestHeader();
- requestHeader.setTopic(topic);
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.DELETE_TOPIC_IN_NAMESRV, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return;
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public void deleteSubscriptionGroup(final String addr, final String groupName, final long timeoutMillis)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- DeleteSubscriptionGroupRequestHeader requestHeader = new DeleteSubscriptionGroupRequestHeader();
- requestHeader.setGroupName(groupName);
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.DELETE_SUBSCRIPTIONGROUP, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return;
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public String getKVConfigValue(final String namespace, final String key, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
- GetKVConfigRequestHeader requestHeader = new GetKVConfigRequestHeader();
- requestHeader.setNamespace(namespace);
- requestHeader.setKey(key);
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_KV_CONFIG, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- GetKVConfigResponseHeader responseHeader =
- (GetKVConfigResponseHeader) response.decodeCommandCustomHeader(GetKVConfigResponseHeader.class);
- return responseHeader.getValue();
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public void putKVConfigValue(final String namespace, final String key, final String value, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
- PutKVConfigRequestHeader requestHeader = new PutKVConfigRequestHeader();
- requestHeader.setNamespace(namespace);
- requestHeader.setKey(key);
- requestHeader.setValue(value);
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.PUT_KV_CONFIG, requestHeader);
-
- List<String> nameServerAddressList = this.remotingClient.getNameServerAddressList();
- if (nameServerAddressList != null) {
- RemotingCommand errResponse = null;
- for (String namesrvAddr : nameServerAddressList) {
- RemotingCommand response = this.remotingClient.invokeSync(namesrvAddr, request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- break;
- }
- default:
- errResponse = response;
- }
- }
-
- if (errResponse != null) {
- throw new MQClientException(errResponse.getCode(), errResponse.getRemark());
- }
- }
- }
-
-
- public void deleteKVConfigValue(final String namespace, final String key, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
- DeleteKVConfigRequestHeader requestHeader = new DeleteKVConfigRequestHeader();
- requestHeader.setNamespace(namespace);
- requestHeader.setKey(key);
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.DELETE_KV_CONFIG, requestHeader);
-
- List<String> nameServerAddressList = this.remotingClient.getNameServerAddressList();
- if (nameServerAddressList != null) {
- RemotingCommand errResponse = null;
- for (String namesrvAddr : nameServerAddressList) {
- RemotingCommand response = this.remotingClient.invokeSync(namesrvAddr, request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- break;
- }
- default:
- errResponse = response;
- }
- }
- if (errResponse != null) {
- throw new MQClientException(errResponse.getCode(), errResponse.getRemark());
- }
- }
- }
-
-
- public KVTable getKVListByNamespace(final String namespace, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
- GetKVListByNamespaceRequestHeader requestHeader = new GetKVListByNamespaceRequestHeader();
- requestHeader.setNamespace(namespace);
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_KVLIST_BY_NAMESPACE, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return KVTable.decode(response.getBody(), KVTable.class);
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public Map<MessageQueue, Long> invokeBrokerToResetOffset(final String addr, final String topic, final String group,
- final long timestamp, final boolean isForce, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
- return invokeBrokerToResetOffset(addr, topic, group, timestamp, isForce, timeoutMillis, false);
- }
-
-
- public Map<MessageQueue, Long> invokeBrokerToResetOffset(final String addr, final String topic, final String group,
- final long timestamp, final boolean isForce, final long timeoutMillis, boolean isC)
- throws RemotingException, MQClientException, InterruptedException {
- ResetOffsetRequestHeader requestHeader = new ResetOffsetRequestHeader();
- requestHeader.setTopic(topic);
- requestHeader.setGroup(group);
- requestHeader.setTimestamp(timestamp);
- requestHeader.setForce(isForce);
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.INVOKE_BROKER_TO_RESET_OFFSET, requestHeader);
- if (isC) {
- request.setLanguage(LanguageCode.CPP);
- }
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- if (response.getBody() != null) {
- ResetOffsetBody body = ResetOffsetBody.decode(response.getBody(), ResetOffsetBody.class);
- return body.getOffsetTable();
- }
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public Map<String, Map<MessageQueue, Long>> invokeBrokerToGetConsumerStatus(final String addr, final String topic, final String group,
- final String clientAddr, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
- GetConsumerStatusRequestHeader requestHeader = new GetConsumerStatusRequestHeader();
- requestHeader.setTopic(topic);
- requestHeader.setGroup(group);
- requestHeader.setClientAddr(clientAddr);
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.INVOKE_BROKER_TO_GET_CONSUMER_STATUS, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- if (response.getBody() != null) {
- GetConsumerStatusBody body = GetConsumerStatusBody.decode(response.getBody(), GetConsumerStatusBody.class);
- return body.getConsumerTable();
- }
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public GroupList queryTopicConsumeByWho(final String addr, final String topic, final long timeoutMillis)
- throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
- MQBrokerException {
- QueryTopicConsumeByWhoRequestHeader requestHeader = new QueryTopicConsumeByWhoRequestHeader();
- requestHeader.setTopic(topic);
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_TOPIC_CONSUME_BY_WHO, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- GroupList groupList = GroupList.decode(response.getBody(), GroupList.class);
- return groupList;
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public List<QueueTimeSpan> queryConsumeTimeSpan(final String addr, final String topic, final String group, final long timeoutMillis)
- throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException,
- MQBrokerException {
- QueryConsumeTimeSpanRequestHeader requestHeader = new QueryConsumeTimeSpanRequestHeader();
- requestHeader.setTopic(topic);
- requestHeader.setGroup(group);
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CONSUME_TIME_SPAN, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- QueryConsumeTimeSpanBody consumeTimeSpanBody = GroupList.decode(response.getBody(), QueryConsumeTimeSpanBody.class);
- return consumeTimeSpanBody.getConsumeTimeSpanSet();
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public TopicList getTopicsByCluster(final String cluster, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
- GetTopicsByClusterRequestHeader requestHeader = new GetTopicsByClusterRequestHeader();
- requestHeader.setCluster(cluster);
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_TOPICS_BY_CLUSTER, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- byte[] body = response.getBody();
- if (body != null) {
- TopicList topicList = TopicList.decode(body, TopicList.class);
- return topicList;
- }
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public void registerMessageFilterClass(final String addr, //
- final String consumerGroup, //
- final String topic, //
- final String className, //
- final int classCRC, //
- final byte[] classBody, //
- final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
- InterruptedException, MQBrokerException {
- RegisterMessageFilterClassRequestHeader requestHeader = new RegisterMessageFilterClassRequestHeader();
- requestHeader.setConsumerGroup(consumerGroup);
- requestHeader.setClassName(className);
- requestHeader.setTopic(topic);
- requestHeader.setClassCRC(classCRC);
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.REGISTER_MESSAGE_FILTER_CLASS, requestHeader);
- request.setBody(classBody);
- RemotingCommand response = this.remotingClient.invokeSync(addr, request, timeoutMillis);
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return;
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
-
- public TopicList getSystemTopicList(final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_SYSTEM_TOPIC_LIST_FROM_NS, null);
-
- RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- byte[] body = response.getBody();
- if (body != null) {
- TopicList topicList = TopicList.decode(response.getBody(), TopicList.class);
- if (topicList.getTopicList() != null && !topicList.getTopicList().isEmpty()
- && !UtilAll.isBlank(topicList.getBrokerAddr())) {
- TopicList tmp = getSystemTopicListFromBroker(topicList.getBrokerAddr(), timeoutMillis);
- if (tmp.getTopicList() != null && !tmp.getTopicList().isEmpty()) {
- topicList.getTopicList().addAll(tmp.getTopicList());
- }
- }
- return topicList;
- }
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public TopicList getSystemTopicListFromBroker(final String addr, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_SYSTEM_TOPIC_LIST_FROM_BROKER, null);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- byte[] body = response.getBody();
- if (body != null) {
- TopicList topicList = TopicList.decode(body, TopicList.class);
- return topicList;
- }
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public boolean cleanExpiredConsumeQueue(final String addr, long timeoutMillis) throws MQClientException, RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException, InterruptedException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.CLEAN_EXPIRED_CONSUMEQUEUE, null);
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return true;
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public boolean cleanUnusedTopicByAddr(final String addr, long timeoutMillis) throws MQClientException, RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException, InterruptedException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.CLEAN_UNUSED_TOPIC, null);
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return true;
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
- public ConsumerRunningInfo getConsumerRunningInfo(final String addr, String consumerGroup, String clientId, boolean jstack,
- final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
- GetConsumerRunningInfoRequestHeader requestHeader = new GetConsumerRunningInfoRequestHeader();
- requestHeader.setConsumerGroup(consumerGroup);
- requestHeader.setClientId(clientId);
- requestHeader.setJstackEnable(jstack);
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_RUNNING_INFO, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- byte[] body = response.getBody();
- if (body != null) {
- ConsumerRunningInfo info = ConsumerRunningInfo.decode(body, ConsumerRunningInfo.class);
- return info;
- }
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
- public ConsumeMessageDirectlyResult consumeMessageDirectly(final String addr, //
- String consumerGroup, //
- String clientId, //
- String msgId, //
- final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
- ConsumeMessageDirectlyResultRequestHeader requestHeader = new ConsumeMessageDirectlyResultRequestHeader();
- requestHeader.setConsumerGroup(consumerGroup);
- requestHeader.setClientId(clientId);
- requestHeader.setMsgId(msgId);
-
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.CONSUME_MESSAGE_DIRECTLY, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- byte[] body = response.getBody();
- if (body != null) {
- ConsumeMessageDirectlyResult info = ConsumeMessageDirectlyResult.decode(body, ConsumeMessageDirectlyResult.class);
- return info;
- }
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
- public Map<Integer, Long> queryCorrectionOffset(final String addr, final String topic, final String group, Set<String> filterGroup,
- long timeoutMillis) throws MQClientException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
- InterruptedException {
- QueryCorrectionOffsetHeader requestHeader = new QueryCorrectionOffsetHeader();
- requestHeader.setCompareGroup(group);
- requestHeader.setTopic(topic);
- if (filterGroup != null) {
- StringBuilder sb = new StringBuilder();
- String splitor = "";
- for (String s : filterGroup) {
- sb.append(splitor).append(s);
- splitor = ",";
- }
- requestHeader.setFilterGroups(sb.toString());
- }
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CORRECTION_OFFSET, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- if (response.getBody() != null) {
- QueryCorrectionOffsetBody body = QueryCorrectionOffsetBody.decode(response.getBody(), QueryCorrectionOffsetBody.class);
- return body.getCorrectionOffsets();
- }
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
- public TopicList getUnitTopicList(final boolean containRetry, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_UNIT_TOPIC_LIST, null);
-
- RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- byte[] body = response.getBody();
- if (body != null) {
- TopicList topicList = TopicList.decode(response.getBody(), TopicList.class);
- if (!containRetry) {
- Iterator<String> it = topicList.getTopicList().iterator();
- while (it.hasNext()) {
- String topic = it.next();
- if (topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX))
- it.remove();
- }
- }
-
- return topicList;
- }
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public TopicList getHasUnitSubTopicList(final boolean containRetry, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_HAS_UNIT_SUB_TOPIC_LIST, null);
-
- RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- byte[] body = response.getBody();
- if (body != null) {
- TopicList topicList = TopicList.decode(response.getBody(), TopicList.class);
- if (!containRetry) {
- Iterator<String> it = topicList.getTopicList().iterator();
- while (it.hasNext()) {
- String topic = it.next();
- if (topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX))
- it.remove();
- }
- }
- return topicList;
- }
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public TopicList getHasUnitSubUnUnitTopicList(final boolean containRetry, final long timeoutMillis)
- throws RemotingException, MQClientException, InterruptedException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_HAS_UNIT_SUB_UNUNIT_TOPIC_LIST, null);
-
- RemotingCommand response = this.remotingClient.invokeSync(null, request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- byte[] body = response.getBody();
- if (body != null) {
- TopicList topicList = TopicList.decode(response.getBody(), TopicList.class);
- if (!containRetry) {
- Iterator<String> it = topicList.getTopicList().iterator();
- while (it.hasNext()) {
- String topic = it.next();
- if (topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX))
- it.remove();
- }
- }
- return topicList;
- }
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public void cloneGroupOffset(final String addr, final String srcGroup, final String destGroup, final String topic,
- final boolean isOffline, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException {
- CloneGroupOffsetRequestHeader requestHeader = new CloneGroupOffsetRequestHeader();
- requestHeader.setSrcGroup(srcGroup);
- requestHeader.setDestGroup(destGroup);
- requestHeader.setTopic(topic);
- requestHeader.setOffline(isOffline);
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.CLONE_GROUP_OFFSET, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr),
- request, timeoutMillis);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return;
- }
- default:
- break;
- }
-
- throw new MQClientException(response.getCode(), response.getRemark());
- }
-
-
- public BrokerStatsData viewBrokerStatsData(String brokerAddr, String statsName, String statsKey, long timeoutMillis)
- throws MQClientException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
- InterruptedException
<TRUNCATED>
[95/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Fix the
conflicts between code and check style.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java b/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
index 49455c6..f4e976d 100644
--- a/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
+++ b/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
@@ -81,13 +81,13 @@ public class MappedFileQueue {
return null;
for (int i = 0; i < mfs.length; i++) {
- MappedFile mappedFile = (MappedFile)mfs[i];
+ MappedFile mappedFile = (MappedFile) mfs[i];
if (mappedFile.getLastModifiedTimestamp() >= timestamp) {
return mappedFile;
}
}
- return (MappedFile)mfs[mfs.length - 1];
+ return (MappedFile) mfs[mfs.length - 1];
}
private Object[] copyMappedFiles(final int reservedMappedFiles) {
@@ -108,9 +108,9 @@ public class MappedFileQueue {
long fileTailOffset = file.getFileFromOffset() + this.mappedFileSize;
if (fileTailOffset > offset) {
if (offset >= file.getFileFromOffset()) {
- file.setWrotePosition((int)(offset % this.mappedFileSize));
- file.setCommittedPosition((int)(offset % this.mappedFileSize));
- file.setFlushedPosition((int)(offset % this.mappedFileSize));
+ file.setWrotePosition((int) (offset % this.mappedFileSize));
+ file.setCommittedPosition((int) (offset % this.mappedFileSize));
+ file.setFlushedPosition((int) (offset % this.mappedFileSize));
} else {
file.destroy(1000);
willRemoveFiles.add(file);
@@ -273,7 +273,7 @@ public class MappedFileQueue {
while (iterator.hasPrevious()) {
mappedFileLast = iterator.previous();
if (offset >= mappedFileLast.getFileFromOffset()) {
- int where = (int)(offset % mappedFileLast.getFileSize());
+ int where = (int) (offset % mappedFileLast.getFileSize());
mappedFileLast.setFlushedPosition(where);
mappedFileLast.setWrotePosition(where);
mappedFileLast.setCommittedPosition(where);
@@ -347,7 +347,7 @@ public class MappedFileQueue {
List<MappedFile> files = new ArrayList<MappedFile>();
if (null != mfs) {
for (int i = 0; i < mfsLength; i++) {
- MappedFile mappedFile = (MappedFile)mfs[i];
+ MappedFile mappedFile = (MappedFile) mfs[i];
long liveMaxTimestamp = mappedFile.getLastModifiedTimestamp() + expiredTime;
if (System.currentTimeMillis() >= liveMaxTimestamp || cleanImmediately) {
if (mappedFile.destroy(intervalForcibly)) {
@@ -387,7 +387,7 @@ public class MappedFileQueue {
for (int i = 0; i < mfsLength; i++) {
boolean destroy;
- MappedFile mappedFile = (MappedFile)mfs[i];
+ MappedFile mappedFile = (MappedFile) mfs[i];
SelectMappedBufferResult result = mappedFile.selectMappedBuffer(this.mappedFileSize - unitSize);
if (result != null) {
long maxOffsetInLogicQueue = result.getByteBuffer().getLong();
@@ -457,7 +457,7 @@ public class MappedFileQueue {
try {
MappedFile mappedFile = this.getFirstMappedFile();
if (mappedFile != null) {
- int index = (int)((offset / this.mappedFileSize) - (mappedFile.getFileFromOffset() / this.mappedFileSize));
+ int index = (int) ((offset / this.mappedFileSize) - (mappedFile.getFileFromOffset() / this.mappedFileSize));
if (index < 0 || index >= this.mappedFiles.size()) {
LOG_ERROR.warn("Offset for {} not matched. Request offset: {}, index: {}, " +
"mappedFileSize: {}, mappedFiles count: {}",
@@ -510,7 +510,7 @@ public class MappedFileQueue {
Object[] mfs = this.copyMappedFiles(0);
if (mfs != null) {
for (Object mf : mfs) {
- if (((ReferenceResource)mf).isAvailable()) {
+ if (((ReferenceResource) mf).isAvailable()) {
size += this.mappedFileSize;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java b/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java
index 9cd7145..e97052f 100644
--- a/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java
+++ b/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java
@@ -30,7 +30,7 @@ public class StoreUtil {
long physicalTotal = 1024 * 1024 * 1024 * 24;
OperatingSystemMXBean osmxb = ManagementFactory.getOperatingSystemMXBean();
if (osmxb instanceof com.sun.management.OperatingSystemMXBean) {
- physicalTotal = ((com.sun.management.OperatingSystemMXBean)osmxb).getTotalPhysicalMemorySize();
+ physicalTotal = ((com.sun.management.OperatingSystemMXBean) osmxb).getTotalPhysicalMemorySize();
}
return physicalTotal;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java b/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java
index 3e332ba..ffbc313 100644
--- a/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java
+++ b/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java
@@ -50,7 +50,7 @@ public class TransientStorePool {
for (int i = 0; i < poolSize; i++) {
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(fileSize);
- final long address = ((DirectBuffer)byteBuffer).address();
+ final long address = ((DirectBuffer) byteBuffer).address();
Pointer pointer = new Pointer(address);
LibC.INSTANCE.mlock(pointer, new NativeLong(fileSize));
@@ -60,7 +60,7 @@ public class TransientStorePool {
public void destroy() {
for (ByteBuffer byteBuffer : availableBuffers) {
- final long address = ((DirectBuffer)byteBuffer).address();
+ final long address = ((DirectBuffer) byteBuffer).address();
Pointer pointer = new Pointer(address);
LibC.INSTANCE.munlock(pointer, new NativeLong(fileSize));
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java b/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java
index d1e2bfe..741a712 100644
--- a/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java
+++ b/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java
@@ -182,8 +182,8 @@ public class MessageStoreConfig {
public int getMapedFileSizeConsumeQueue() {
- int factor = (int)Math.ceil(this.mapedFileSizeConsumeQueue / (ConsumeQueue.CQ_STORE_UNIT_SIZE * 1.0));
- return (int)(factor * ConsumeQueue.CQ_STORE_UNIT_SIZE);
+ int factor = (int) Math.ceil(this.mapedFileSizeConsumeQueue / (ConsumeQueue.CQ_STORE_UNIT_SIZE * 1.0));
+ return (int) (factor * ConsumeQueue.CQ_STORE_UNIT_SIZE);
}
public void setMapedFileSizeConsumeQueue(int mapedFileSizeConsumeQueue) {
@@ -444,14 +444,14 @@ public class MessageStoreConfig {
return brokerRole;
}
- public void setBrokerRole(String brokerRole) {
- this.brokerRole = BrokerRole.valueOf(brokerRole);
- }
-
public void setBrokerRole(BrokerRole brokerRole) {
this.brokerRole = brokerRole;
}
+ public void setBrokerRole(String brokerRole) {
+ this.brokerRole = BrokerRole.valueOf(brokerRole);
+ }
+
public int getHaTransferBatchSize() {
return haTransferBatchSize;
}
@@ -472,14 +472,14 @@ public class MessageStoreConfig {
return flushDiskType;
}
- public void setFlushDiskType(String type) {
- this.flushDiskType = FlushDiskType.valueOf(type);
- }
-
public void setFlushDiskType(FlushDiskType flushDiskType) {
this.flushDiskType = flushDiskType;
}
+ public void setFlushDiskType(String type) {
+ this.flushDiskType = FlushDiskType.valueOf(type);
+ }
+
public int getSyncFlushTimeout() {
return syncFlushTimeout;
}
@@ -570,6 +570,7 @@ public class MessageStoreConfig {
/**
* Enable transient commitLog store poll only if transientStorePoolEnable is true and the FlushDiskType is ASYNC_FLUSH
+ *
* @return <tt>true</tt> or <tt>false</tt>
*/
public boolean isTransientStorePoolEnable() {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java b/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
index 82fe8f4..bab3d1e 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
@@ -207,7 +207,7 @@ public class HAService {
if (selected != null) {
for (SelectionKey k : selected) {
if ((k.readyOps() & SelectionKey.OP_ACCEPT) != 0) {
- SocketChannel sc = ((ServerSocketChannel)k.channel()).accept();
+ SocketChannel sc = ((ServerSocketChannel) k.channel()).accept();
if (sc != null) {
HAService.log.info("HAService receive new connection, "
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java b/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
index de1a31d..97f3920 100644
--- a/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
+++ b/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
@@ -124,7 +124,7 @@ public class IndexFile {
this.mappedByteBuffer.putInt(absIndexPos, keyHash);
this.mappedByteBuffer.putLong(absIndexPos + 4, phyOffset);
- this.mappedByteBuffer.putInt(absIndexPos + 4 + 8, (int)timeDiff);
+ this.mappedByteBuffer.putInt(absIndexPos + 4 + 8, (int) timeDiff);
this.mappedByteBuffer.putInt(absIndexPos + 4 + 8 + 4, slotValue);
this.mappedByteBuffer.putInt(absSlotPos, this.indexHeader.getIndexCount());
@@ -183,15 +183,8 @@ public class IndexFile {
boolean result =
begin < this.indexHeader.getBeginTimestamp() && end > this.indexHeader.getEndTimestamp();
- result =
- result
- || (begin >= this.indexHeader.getBeginTimestamp() && begin <= this.indexHeader
- .getEndTimestamp());
-
- result =
- result
- || (end >= this.indexHeader.getBeginTimestamp() && end <= this.indexHeader
- .getEndTimestamp());
+ result = result || (begin >= this.indexHeader.getBeginTimestamp() && begin <= this.indexHeader.getEndTimestamp());
+ result = result || (end >= this.indexHeader.getBeginTimestamp() && end <= this.indexHeader.getEndTimestamp());
return result;
}
@@ -219,7 +212,7 @@ public class IndexFile {
|| this.indexHeader.getIndexCount() <= 1) {
// TODO NOTFOUND
} else {
- for (int nextIndexToRead = slotValue; ; ) {
+ for (int nextIndexToRead = slotValue;;) {
if (phyOffsets.size() >= maxNum) {
break;
}
@@ -231,7 +224,7 @@ public class IndexFile {
int keyHashRead = this.mappedByteBuffer.getInt(absIndexPos);
long phyOffsetRead = this.mappedByteBuffer.getLong(absIndexPos + 4);
- long timeDiff = (long)this.mappedByteBuffer.getInt(absIndexPos + 4 + 8);
+ long timeDiff = (long) this.mappedByteBuffer.getInt(absIndexPos + 4 + 8);
int prevIndexRead = this.mappedByteBuffer.getInt(absIndexPos + 4 + 8 + 4);
if (timeDiff < 0) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java b/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java
index b72ffe9..4d07e83 100644
--- a/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java
@@ -106,7 +106,7 @@ public class IndexService {
if (files != null) {
List<IndexFile> fileList = new ArrayList<IndexFile>();
for (int i = 0; i < (files.length - 1); i++) {
- IndexFile f = (IndexFile)files[i];
+ IndexFile f = (IndexFile) files[i];
if (f.getEndPhyOffset() < offset) {
fileList.add(f);
} else {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java b/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java
index 3df4806..259eb3b 100644
--- a/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java
@@ -224,8 +224,6 @@ public class ScheduleMessageService extends ConfigManager {
}
/**
-
- *
* @return
*/
private long correctDeliverTimestamp(final long now, final long deliverTimestamp) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/main/java/org/apache/rocketmq/store/util/LibC.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/util/LibC.java b/store/src/main/java/org/apache/rocketmq/store/util/LibC.java
index dc5d6a9..ae70efd 100644
--- a/store/src/main/java/org/apache/rocketmq/store/util/LibC.java
+++ b/store/src/main/java/org/apache/rocketmq/store/util/LibC.java
@@ -23,7 +23,7 @@ import com.sun.jna.Platform;
import com.sun.jna.Pointer;
public interface LibC extends Library {
- LibC INSTANCE = (LibC)Native.loadLibrary(Platform.isWindows() ? "msvcrt" : "c", LibC.class);
+ LibC INSTANCE = (LibC) Native.loadLibrary(Platform.isWindows() ? "msvcrt" : "c", LibC.class);
int MADV_WILLNEED = 3;
int MADV_DONTNEED = 4;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/test/java/org/apache/rocketmq/store/MappedFileQueueTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/MappedFileQueueTest.java b/store/src/test/java/org/apache/rocketmq/store/MappedFileQueueTest.java
index 018cf99..1948fc7 100644
--- a/store/src/test/java/org/apache/rocketmq/store/MappedFileQueueTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/MappedFileQueueTest.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: MappedFileQueueTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
+ *
+ * $Id: MappedFileQueueTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/test/java/org/apache/rocketmq/store/MappedFileTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/MappedFileTest.java b/store/src/test/java/org/apache/rocketmq/store/MappedFileTest.java
index a10f4eb..2aa9000 100644
--- a/store/src/test/java/org/apache/rocketmq/store/MappedFileTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/MappedFileTest.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: MappedFileTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
+ *
+ * $Id: MappedFileTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/test/java/org/apache/rocketmq/store/StoreCheckpointTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/StoreCheckpointTest.java b/store/src/test/java/org/apache/rocketmq/store/StoreCheckpointTest.java
index 2fe4d46..0f7ce39 100644
--- a/store/src/test/java/org/apache/rocketmq/store/StoreCheckpointTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/StoreCheckpointTest.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: StoreCheckpointTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
+ *
+ * $Id: StoreCheckpointTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/test/java/org/apache/rocketmq/store/index/IndexFileTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/index/IndexFileTest.java b/store/src/test/java/org/apache/rocketmq/store/index/IndexFileTest.java
index cdecb20..c9c1071 100644
--- a/store/src/test/java/org/apache/rocketmq/store/index/IndexFileTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/index/IndexFileTest.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: IndexFileTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
+ *
+ * $Id: IndexFileTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/store/src/test/java/org/apache/rocketmq/store/schedule/ScheduleMessageTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/schedule/ScheduleMessageTest.java b/store/src/test/java/org/apache/rocketmq/store/schedule/ScheduleMessageTest.java
index c5d9756..e3b09bd 100644
--- a/store/src/test/java/org/apache/rocketmq/store/schedule/ScheduleMessageTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/schedule/ScheduleMessageTest.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: ScheduleMessageTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
+ *
+ * $Id: ScheduleMessageTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/style/rmq_checkstyle.xml
----------------------------------------------------------------------
diff --git a/style/rmq_checkstyle.xml b/style/rmq_checkstyle.xml
new file mode 100644
index 0000000..e2049b6
--- /dev/null
+++ b/style/rmq_checkstyle.xml
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module PUBLIC
+ "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
+<!--
+ 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.
+ -->
+<!--Refer http://checkstyle.sourceforge.net/reports/google-java-style.html#s2.2-file-encoding -->
+<module name="Checker">
+
+ <property name="localeLanguage" value="en"/>
+
+ <!--To configure the check to report on the first instance in each file-->
+ <module name="FileTabCharacter"/>
+
+ <!-- header -->
+ <module name="RegexpHeader">
+ <property name="header" value="/\*\*\nLicensed to the Apache Software Foundation*"/>
+ </module>
+
+ <module name="RegexpSingleline">
+ <property name="format" value="System\.out\.println"/>
+ <property name="message" value="Prohibit invoking System.out.println in source code !"/>
+ </module>
+
+ <module name="RegexpSingleline">
+ <property name="format" value="//FIXME"/>
+ <property name="message" value="Recommended fix FIXME task !"/>
+ </module>
+
+ <module name="RegexpSingleline">
+ <property name="format" value="//TODO"/>
+ <property name="message" value="Recommended fix TODO task !"/>
+ </module>
+
+ <module name="RegexpSingleline">
+ <property name="format" value="@alibaba"/>
+ <property name="message" value="Recommended remove @alibaba keyword!"/>
+ </module>
+
+ <module name="RegexpSingleline">
+ <property name="format"
+ value=".*[\u3400-\u4DB5\u4E00-\u9FA5\u9FA6-\u9FBB\uF900-\uFA2D\uFA30-\uFA6A\uFA70-\uFAD9\uFF00-\uFFEF\u2E80-\u2EFF\u3000-\u303F\u31C0-\u31EF]+.*"/>
+ <property name="message" value="Not allow chinese character !"/>
+ </module>
+
+ <module name="FileLength">
+ <property name="max" value="3000"/>
+ </module>
+
+ <module name="TreeWalker">
+
+ <module name="UnusedImports">
+ <property name="processJavadoc" value="true"/>
+ </module>
+ <module name="RedundantImport"/>
+
+ <!--<module name="IllegalImport" />-->
+
+ <!--Checks that classes that override equals() also override hashCode()-->
+ <module name="EqualsHashCode"/>
+ <!--Checks for over-complicated boolean expressions. Currently finds code like if (topic == true), topic || true, !false, etc.-->
+ <module name="SimplifyBooleanExpression"/>
+ <module name="OneStatementPerLine"/>
+ <module name="UnnecessaryParentheses"/>
+ <!--Checks for over-complicated boolean return statements. For example the following code-->
+ <module name="SimplifyBooleanReturn"/>
+
+ <!--Check that the default is after all the cases in producerGroup switch statement-->
+ <module name="DefaultComesLast"/>
+ <!--Detects empty statements (standalone ";" semicolon)-->
+ <module name="EmptyStatement"/>
+ <!--Checks that long constants are defined with an upper ell-->
+ <module name="UpperEll"/>
+ <module name="ConstantName">
+ <property name="format" value="(^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)|(^log$)"/>
+ </module>
+ <!--Checks that local, non-final variable names conform to producerGroup format specified by the format property-->
+ <module name="LocalVariableName"/>
+ <!--Validates identifiers for local, final variables, including catch parameters-->
+ <module name="LocalFinalVariableName"/>
+ <!--Validates identifiers for non-static fields-->
+ <module name="MemberName"/>
+ <!--Validates identifiers for class type parameters-->
+ <module name="ClassTypeParameterName">
+ <property name="format" value="^[A-Z0-9]*$"/>
+ </module>
+ <!--Validates identifiers for method type parameters-->
+ <module name="MethodTypeParameterName">
+ <property name="format" value="^[A-Z0-9]*$"/>
+ </module>
+ <module name="PackageName"/>
+ <module name="ParameterName"/>
+ <module name="StaticVariableName"/>
+ <module name="TypeName"/>
+ <!--Checks that there are no import statements that use the * notation-->
+ <module name="AvoidStarImport"/>
+
+ <!--whitespace-->
+ <module name="GenericWhitespace"/>
+ <module name="NoWhitespaceBefore"/>
+ <module name="WhitespaceAfter"/>
+ <module name="NoWhitespaceAfter"/>
+ <module name="WhitespaceAround">
+ <property name="allowEmptyConstructors" value="true"/>
+ <property name="allowEmptyMethods" value="true"/>
+ </module>
+ <module name="Indentation"/>
+ <module name="MethodParamPad"/>
+ <module name="ParenPad"/>
+ <module name="TypecastParenPad"/>
+ </module>
+</module>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
index 847a2c0..f133c43 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
@@ -708,7 +708,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
return this.mqClientInstance.getMQClientAPIImpl().consumeMessageDirectly(RemotingUtil.socketAddress2String(msg.getStoreHost()),
consumerGroup, clientId, msgId, timeoutMillis * 3);
} else {
- MessageClientExt msgClient = (MessageClientExt)msg;
+ MessageClientExt msgClient = (MessageClientExt) msg;
return this.mqClientInstance.getMQClientAPIImpl().consumeMessageDirectly(RemotingUtil.socketAddress2String(msg.getStoreHost()),
consumerGroup, clientId, msgClient.getOffsetMsgId(), timeoutMillis * 3);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java b/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java
index a1753c1..38089c3 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java
@@ -194,7 +194,7 @@ public class MQAdminStartup {
private static void initLogback() throws JoranException {
String rocketmqHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV));
- LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory();
+ LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/CLusterSendMsgRTCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/CLusterSendMsgRTCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/CLusterSendMsgRTCommand.java
index 1ae6d52..a6e592a 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/CLusterSendMsgRTCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/CLusterSendMsgRTCommand.java
@@ -161,7 +161,7 @@ public class CLusterSendMsgRTCommand implements SubCommand {
}
}
- double rt = (double)elapsed / (amount - 1);
+ double rt = (double) elapsed / (amount - 1);
if (!printAsTlog) {
System.out.printf("%-24s %-24s %-8s %-16s %-16s%n",
clusterName,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
index 3e70614..692d060 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
@@ -141,7 +141,7 @@ public class ConsumerProgressSubCommand implements SubCommand {
groupConsumeInfo.setGroup(consumerGroup);
if (consumeStats != null) {
- groupConsumeInfo.setConsumeTps((int)consumeStats.getConsumeTps());
+ groupConsumeInfo.setConsumeTps((int) consumeStats.getConsumeTps());
groupConsumeInfo.setDiffTotal(consumeStats.computeTotalDiff());
}
@@ -251,7 +251,7 @@ class GroupConsumeInfo implements Comparable<GroupConsumeInfo> {
return o.count - this.count;
}
- return (int)(o.diffTotal - diffTotal);
+ return (int) (o.diffTotal - diffTotal);
}
public int getConsumeTps() {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/tools/src/main/java/org/apache/rocketmq/tools/command/message/CheckMsgSendRTCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/CheckMsgSendRTCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/CheckMsgSendRTCommand.java
index cade0e0..22d351f 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/CheckMsgSendRTCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/CheckMsgSendRTCommand.java
@@ -88,7 +88,7 @@ public class CheckMsgSendRTCommand implements SubCommand {
producer.send(msg, new MessageQueueSelector() {
@Override
public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
- int queueIndex = (Integer)arg % mqs.size();
+ int queueIndex = (Integer) arg % mqs.size();
MessageQueue queue = mqs.get(queueIndex);
brokerName = queue.getBrokerName();
queueId = queue.getQueueId();
@@ -114,7 +114,7 @@ public class CheckMsgSendRTCommand implements SubCommand {
);
}
- double rt = (double)timeElapsed / (amount - 1);
+ double rt = (double) timeElapsed / (amount - 1);
System.out.printf("Avg RT: %s%n", String.format("%.2f", rt));
} catch (Exception e) {
e.printStackTrace();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageByQueueCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageByQueueCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageByQueueCommand.java
index aad1644..e810e86 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageByQueueCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageByQueueCommand.java
@@ -246,7 +246,7 @@ public class PrintMessageByQueueCommand implements SubCommand {
@Override
public int compareTo(final TagCountBean o) {
- return (int)(o.getCount().get() - this.count.get());
+ return (int) (o.getCount().get() - this.count.get());
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java
index 38f9a72..4211780 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java
@@ -57,7 +57,7 @@ public class QueryMsgByIdSubCommand implements SubCommand {
String bodyTmpFilePath = createBodyFile(msg);
String msgId = msg.getMsgId();
if (msg instanceof MessageClientExt) {
- msgId = ((MessageClientExt)msg).getOffsetMsgId();
+ msgId = ((MessageClientExt) msg).getOffsetMsgId();
}
System.out.printf("%-20s %s%n",
[48/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/offset/ConsumerOffsetManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/offset/ConsumerOffsetManager.java b/broker/src/main/java/com/alibaba/rocketmq/broker/offset/ConsumerOffsetManager.java
deleted file mode 100644
index 269918a..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/offset/ConsumerOffsetManager.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/**
- * 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.offset;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import com.alibaba.rocketmq.broker.BrokerPathConfigHelper;
-import com.alibaba.rocketmq.common.ConfigManager;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-
-
-/**
- * @author shijia.wxr
- */
-public class ConsumerOffsetManager extends ConfigManager {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
- private static final String TOPIC_GROUP_SEPARATOR = "@";
-
- private ConcurrentHashMap<String/* topic@group */, ConcurrentHashMap<Integer, Long>> offsetTable =
- new ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>>(512);
-
- private transient BrokerController brokerController;
-
-
- public ConsumerOffsetManager() {
- }
-
-
- public ConsumerOffsetManager(BrokerController brokerController) {
- this.brokerController = brokerController;
- }
-
-
- public void scanUnsubscribedTopic() {
- Iterator<Entry<String, ConcurrentHashMap<Integer, Long>>> it = this.offsetTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, ConcurrentHashMap<Integer, Long>> next = it.next();
- String topicAtGroup = next.getKey();
- String[] arrays = topicAtGroup.split(TOPIC_GROUP_SEPARATOR);
- if (arrays != null && arrays.length == 2) {
- String topic = arrays[0];
- String group = arrays[1];
-
- if (null == brokerController.getConsumerManager().findSubscriptionData(group, topic)
- && this.offsetBehindMuchThanData(topic, next.getValue())) {
- it.remove();
- log.warn("remove topic offset, {}", topicAtGroup);
- }
- }
- }
- }
-
-
- private boolean offsetBehindMuchThanData(final String topic, ConcurrentHashMap<Integer, Long> table) {
- Iterator<Entry<Integer, Long>> it = table.entrySet().iterator();
- boolean result = !table.isEmpty();
-
- while (it.hasNext() && result) {
- Entry<Integer, Long> next = it.next();
- long minOffsetInStore = this.brokerController.getMessageStore().getMinOffsetInQuque(topic, next.getKey());
- long offsetInPersist = next.getValue();
- if (offsetInPersist > minOffsetInStore) {
- result = false;
- } else {
- result = true;
- }
- }
-
- return result;
- }
-
-
- public Set<String> whichTopicByConsumer(final String group) {
- Set<String> topics = new HashSet<String>();
-
- Iterator<Entry<String, ConcurrentHashMap<Integer, Long>>> it = this.offsetTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, ConcurrentHashMap<Integer, Long>> next = it.next();
- String topicAtGroup = next.getKey();
- String[] arrays = topicAtGroup.split(TOPIC_GROUP_SEPARATOR);
- if (arrays != null && arrays.length == 2) {
- if (group.equals(arrays[1])) {
- topics.add(arrays[0]);
- }
- }
- }
-
- return topics;
- }
-
-
- public Set<String> whichGroupByTopic(final String topic) {
- Set<String> groups = new HashSet<String>();
-
- Iterator<Entry<String, ConcurrentHashMap<Integer, Long>>> it = this.offsetTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, ConcurrentHashMap<Integer, Long>> next = it.next();
- String topicAtGroup = next.getKey();
- String[] arrays = topicAtGroup.split(TOPIC_GROUP_SEPARATOR);
- if (arrays != null && arrays.length == 2) {
- if (topic.equals(arrays[0])) {
- groups.add(arrays[1]);
- }
- }
- }
-
- return groups;
- }
-
-
- public void commitOffset(final String clientHost, final String group, final String topic, final int queueId, final long offset) {
- // topic@group
- String key = topic + TOPIC_GROUP_SEPARATOR + group;
- this.commitOffset(clientHost, key, queueId, offset);
- }
-
- private void commitOffset(final String clientHost, final String key, final int queueId, final long offset) {
- ConcurrentHashMap<Integer, Long> map = this.offsetTable.get(key);
- if (null == map) {
- map = new ConcurrentHashMap<Integer, Long>(32);
- map.put(queueId, offset);
- this.offsetTable.put(key, map);
- } else {
- Long storeOffset = map.put(queueId, offset);
- if (storeOffset != null && offset < storeOffset) {
- log.warn("[NOTIFYME]update consumer offset less than store. clientHost={}, key={}, queueId={}, requestOffset={}, storeOffset={}", clientHost, key, queueId, offset, storeOffset);
- }
- }
- }
-
- public long queryOffset(final String group, final String topic, final int queueId) {
- // topic@group
- String key = topic + TOPIC_GROUP_SEPARATOR + group;
- ConcurrentHashMap<Integer, Long> map = this.offsetTable.get(key);
- if (null != map) {
- Long offset = map.get(queueId);
- if (offset != null)
- return offset;
- }
-
- return -1;
- }
-
- public String encode() {
- return this.encode(false);
- }
-
- @Override
- public String configFilePath() {
- return BrokerPathConfigHelper.getConsumerOffsetPath(this.brokerController.getMessageStoreConfig().getStorePathRootDir());
- }
-
- @Override
- public void decode(String jsonString) {
- if (jsonString != null) {
- ConsumerOffsetManager obj = RemotingSerializable.fromJson(jsonString, ConsumerOffsetManager.class);
- if (obj != null) {
- this.offsetTable = obj.offsetTable;
- }
- }
- }
-
- public String encode(final boolean prettyFormat) {
- return RemotingSerializable.toJson(this, prettyFormat);
- }
-
- public ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>> getOffsetTable() {
- return offsetTable;
- }
-
-
- public void setOffsetTable(ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>> offsetTable) {
- this.offsetTable = offsetTable;
- }
-
-
- public Map<Integer, Long> queryMinOffsetInAllGroup(final String topic, final String filterGroups) {
-
- Map<Integer, Long> queueMinOffset = new HashMap<Integer, Long>();
- Set<String> topicGroups = this.offsetTable.keySet();
- if (!UtilAll.isBlank(filterGroups)) {
- for (String group : filterGroups.split(",")) {
- Iterator<String> it = topicGroups.iterator();
- while (it.hasNext()) {
- if (group.equals(it.next().split(TOPIC_GROUP_SEPARATOR)[1])) {
- it.remove();
- }
- }
- }
- }
-
- for (Map.Entry<String, ConcurrentHashMap<Integer, Long>> offSetEntry : this.offsetTable.entrySet()) {
- String topicGroup = offSetEntry.getKey();
- String[] topicGroupArr = topicGroup.split(TOPIC_GROUP_SEPARATOR);
- if (topic.equals(topicGroupArr[0])) {
- for (Entry<Integer, Long> entry : offSetEntry.getValue().entrySet()) {
- long minOffset = this.brokerController.getMessageStore().getMinOffsetInQuque(topic, entry.getKey());
- if (entry.getValue() >= minOffset) {
- Long offset = queueMinOffset.get(entry.getKey());
- if (offset == null) {
- queueMinOffset.put(entry.getKey(), Math.min(Long.MAX_VALUE, entry.getValue()));
- } else {
- queueMinOffset.put(entry.getKey(), Math.min(entry.getValue(), offset));
- }
- }
- }
- }
-
- }
- return queueMinOffset;
- }
-
-
- public Map<Integer, Long> queryOffset(final String group, final String topic) {
- // topic@group
- String key = topic + TOPIC_GROUP_SEPARATOR + group;
- return this.offsetTable.get(key);
- }
-
-
- public void cloneOffset(final String srcGroup, final String destGroup, final String topic) {
- ConcurrentHashMap<Integer, Long> offsets = this.offsetTable.get(topic + TOPIC_GROUP_SEPARATOR + srcGroup);
- if (offsets != null) {
- this.offsetTable.put(topic + TOPIC_GROUP_SEPARATOR + destGroup, new ConcurrentHashMap<Integer, Long>(offsets));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/out/BrokerOuterAPI.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/out/BrokerOuterAPI.java b/broker/src/main/java/com/alibaba/rocketmq/broker/out/BrokerOuterAPI.java
deleted file mode 100644
index f051d29..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/out/BrokerOuterAPI.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/**
- * 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.out;
-
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.namesrv.RegisterBrokerResult;
-import com.alibaba.rocketmq.common.namesrv.TopAddressing;
-import com.alibaba.rocketmq.common.protocol.RequestCode;
-import com.alibaba.rocketmq.common.protocol.ResponseCode;
-import com.alibaba.rocketmq.common.protocol.body.*;
-import com.alibaba.rocketmq.common.protocol.header.namesrv.RegisterBrokerRequestHeader;
-import com.alibaba.rocketmq.common.protocol.header.namesrv.RegisterBrokerResponseHeader;
-import com.alibaba.rocketmq.common.protocol.header.namesrv.UnRegisterBrokerRequestHeader;
-import com.alibaba.rocketmq.remoting.RPCHook;
-import com.alibaba.rocketmq.remoting.RemotingClient;
-import com.alibaba.rocketmq.remoting.exception.*;
-import com.alibaba.rocketmq.remoting.netty.NettyClientConfig;
-import com.alibaba.rocketmq.remoting.netty.NettyRemotingClient;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- * @author manhong.yqd
- */
-public class BrokerOuterAPI {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
- private final RemotingClient remotingClient;
- private final TopAddressing topAddressing = new TopAddressing(MixAll.WS_ADDR);
- private String nameSrvAddr = null;
-
- public BrokerOuterAPI(final NettyClientConfig nettyClientConfig) {
- this(nettyClientConfig, null);
- }
-
- public BrokerOuterAPI(final NettyClientConfig nettyClientConfig, RPCHook rpcHook) {
- this.remotingClient = new NettyRemotingClient(nettyClientConfig);
- this.remotingClient.registerRPCHook(rpcHook);
- }
-
- public void start() {
- this.remotingClient.start();
- }
-
- public void shutdown() {
- this.remotingClient.shutdown();
- }
-
- public String fetchNameServerAddr() {
- try {
- String addrs = this.topAddressing.fetchNSAddr();
- if (addrs != null) {
- if (!addrs.equals(this.nameSrvAddr)) {
- log.info("name server address changed, old: " + this.nameSrvAddr + " new: " + addrs);
- this.updateNameServerAddressList(addrs);
- this.nameSrvAddr = addrs;
- return nameSrvAddr;
- }
- }
- } catch (Exception e) {
- log.error("fetchNameServerAddr Exception", e);
- }
- return nameSrvAddr;
- }
-
- public void updateNameServerAddressList(final String addrs) {
- List<String> lst = new ArrayList<String>();
- String[] addrArray = addrs.split(";");
- if (addrArray != null) {
- for (String addr : addrArray) {
- lst.add(addr);
- }
-
- this.remotingClient.updateNameServerAddressList(lst);
- }
- }
-
- public RegisterBrokerResult registerBrokerAll(
- final String clusterName,
- final String brokerAddr,
- final String brokerName,
- final long brokerId,
- final String haServerAddr,
- final TopicConfigSerializeWrapper topicConfigWrapper,
- final List<String> filterServerList,
- final boolean oneway,
- final int timeoutMills) {
- RegisterBrokerResult registerBrokerResult = null;
-
- List<String> nameServerAddressList = this.remotingClient.getNameServerAddressList();
- if (nameServerAddressList != null) {
- for (String namesrvAddr : nameServerAddressList) {
- try {
- RegisterBrokerResult result = this.registerBroker(namesrvAddr, clusterName, brokerAddr, brokerName, brokerId,
- haServerAddr, topicConfigWrapper, filterServerList, oneway, timeoutMills);
- if (result != null) {
- registerBrokerResult = result;
- }
-
- log.info("register broker to name server {} OK", namesrvAddr);
- } catch (Exception e) {
- log.warn("registerBroker Exception, " + namesrvAddr, e);
- }
- }
- }
-
- return registerBrokerResult;
- }
-
- private RegisterBrokerResult registerBroker(
- final String namesrvAddr,
- final String clusterName,
- final String brokerAddr,
- final String brokerName,
- final long brokerId,
- final String haServerAddr,
- final TopicConfigSerializeWrapper topicConfigWrapper,
- final List<String> filterServerList,
- final boolean oneway,
- final int timeoutMills
- ) throws RemotingCommandException, MQBrokerException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
- InterruptedException {
- RegisterBrokerRequestHeader requestHeader = new RegisterBrokerRequestHeader();
- requestHeader.setBrokerAddr(brokerAddr);
- requestHeader.setBrokerId(brokerId);
- requestHeader.setBrokerName(brokerName);
- requestHeader.setClusterName(clusterName);
- requestHeader.setHaServerAddr(haServerAddr);
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.REGISTER_BROKER, requestHeader);
-
- RegisterBrokerBody requestBody = new RegisterBrokerBody();
- requestBody.setTopicConfigSerializeWrapper(topicConfigWrapper);
- requestBody.setFilterServerList(filterServerList);
- request.setBody(requestBody.encode());
-
- if (oneway) {
- try {
- this.remotingClient.invokeOneway(namesrvAddr, request, timeoutMills);
- } catch (RemotingTooMuchRequestException e) {
- }
- return null;
- }
-
- RemotingCommand response = this.remotingClient.invokeSync(namesrvAddr, request, timeoutMills);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- RegisterBrokerResponseHeader responseHeader =
- (RegisterBrokerResponseHeader) response.decodeCommandCustomHeader(RegisterBrokerResponseHeader.class);
- RegisterBrokerResult result = new RegisterBrokerResult();
- result.setMasterAddr(responseHeader.getMasterAddr());
- result.setHaServerAddr(responseHeader.getHaServerAddr());
- result.setHaServerAddr(responseHeader.getHaServerAddr());
- if (response.getBody() != null) {
- result.setKvTable(KVTable.decode(response.getBody(), KVTable.class));
- }
- return result;
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
- public void unregisterBrokerAll(
- final String clusterName,
- final String brokerAddr,
- final String brokerName,
- final long brokerId
- ) {
- List<String> nameServerAddressList = this.remotingClient.getNameServerAddressList();
- if (nameServerAddressList != null) {
- for (String namesrvAddr : nameServerAddressList) {
- try {
- this.unregisterBroker(namesrvAddr, clusterName, brokerAddr, brokerName, brokerId);
- log.info("unregisterBroker OK, NamesrvAddr: {}", namesrvAddr);
- } catch (Exception e) {
- log.warn("unregisterBroker Exception, " + namesrvAddr, e);
- }
- }
- }
- }
-
- public void unregisterBroker(
- final String namesrvAddr,
- final String clusterName,
- final String brokerAddr,
- final String brokerName,
- final long brokerId
- ) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException {
- UnRegisterBrokerRequestHeader requestHeader = new UnRegisterBrokerRequestHeader();
- requestHeader.setBrokerAddr(brokerAddr);
- requestHeader.setBrokerId(brokerId);
- requestHeader.setBrokerName(brokerName);
- requestHeader.setClusterName(clusterName);
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UNREGISTER_BROKER, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(namesrvAddr, request, 3000);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return;
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
- public TopicConfigSerializeWrapper getAllTopicConfig(final String addr) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, InterruptedException, MQBrokerException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_CONFIG, null);
-
- RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(true, addr), request, 3000);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return TopicConfigSerializeWrapper.decode(response.getBody(), TopicConfigSerializeWrapper.class);
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
- public ConsumerOffsetSerializeWrapper getAllConsumerOffset(final String addr) throws InterruptedException, RemotingTimeoutException,
- RemotingSendRequestException, RemotingConnectException, MQBrokerException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_CONSUMER_OFFSET, null);
- RemotingCommand response = this.remotingClient.invokeSync(addr, request, 3000);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return ConsumerOffsetSerializeWrapper.decode(response.getBody(), ConsumerOffsetSerializeWrapper.class);
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
- public String getAllDelayOffset(final String addr) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException,
- RemotingConnectException, MQBrokerException, UnsupportedEncodingException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_DELAY_OFFSET, null);
- RemotingCommand response = this.remotingClient.invokeSync(addr, request, 3000);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return new String(response.getBody(), MixAll.DEFAULT_CHARSET);
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
- public SubscriptionGroupWrapper getAllSubscriptionGroupConfig(final String addr) throws InterruptedException, RemotingTimeoutException,
- RemotingSendRequestException, RemotingConnectException, MQBrokerException {
- RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_SUBSCRIPTIONGROUP_CONFIG, null);
- RemotingCommand response = this.remotingClient.invokeSync(addr, request, 3000);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- return SubscriptionGroupWrapper.decode(response.getBody(), SubscriptionGroupWrapper.class);
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-
- public void registerRPCHook(RPCHook rpcHook) {
- remotingClient.registerRPCHook(rpcHook);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/pagecache/ManyMessageTransfer.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/pagecache/ManyMessageTransfer.java b/broker/src/main/java/com/alibaba/rocketmq/broker/pagecache/ManyMessageTransfer.java
deleted file mode 100644
index 8050bc1..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/pagecache/ManyMessageTransfer.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * 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.pagecache;
-
-import com.alibaba.rocketmq.store.GetMessageResult;
-import io.netty.channel.FileRegion;
-import io.netty.util.AbstractReferenceCounted;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.channels.WritableByteChannel;
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public class ManyMessageTransfer extends AbstractReferenceCounted implements FileRegion {
- private final ByteBuffer byteBufferHeader;
- private final GetMessageResult getMessageResult;
- private long transfered; // the bytes which was transfered already
-
-
- public ManyMessageTransfer(ByteBuffer byteBufferHeader, GetMessageResult getMessageResult) {
- this.byteBufferHeader = byteBufferHeader;
- this.getMessageResult = getMessageResult;
- }
-
-
- @Override
- public long position() {
- int pos = byteBufferHeader.position();
- List<ByteBuffer> messageBufferList = this.getMessageResult.getMessageBufferList();
- for (ByteBuffer bb : messageBufferList) {
- pos += bb.position();
- }
- return pos;
- }
-
- @Override
- public long transfered() {
- return transfered;
- }
-
- @Override
- public long count() {
- return byteBufferHeader.limit() + this.getMessageResult.getBufferTotalSize();
- }
-
- @Override
- public long transferTo(WritableByteChannel target, long position) throws IOException {
- if (this.byteBufferHeader.hasRemaining()) {
- transfered += target.write(this.byteBufferHeader);
- return transfered;
- } else {
- List<ByteBuffer> messageBufferList = this.getMessageResult.getMessageBufferList();
- for (ByteBuffer bb : messageBufferList) {
- if (bb.hasRemaining()) {
- transfered += target.write(bb);
- return transfered;
- }
- }
- }
-
- return 0;
- }
-
- public void close() {
- this.deallocate();
- }
-
- @Override
- protected void deallocate() {
- this.getMessageResult.release();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/pagecache/OneMessageTransfer.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/pagecache/OneMessageTransfer.java b/broker/src/main/java/com/alibaba/rocketmq/broker/pagecache/OneMessageTransfer.java
deleted file mode 100644
index df742c5..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/pagecache/OneMessageTransfer.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * 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.pagecache;
-
-import com.alibaba.rocketmq.store.SelectMappedBufferResult;
-import io.netty.channel.FileRegion;
-import io.netty.util.AbstractReferenceCounted;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.channels.WritableByteChannel;
-
-
-/**
- * @author shijia.wxr
- */
-public class OneMessageTransfer extends AbstractReferenceCounted implements FileRegion {
- private final ByteBuffer byteBufferHeader;
- private final SelectMappedBufferResult selectMappedBufferResult;
- private long transfered; // the bytes which was transfered already
-
-
- public OneMessageTransfer(ByteBuffer byteBufferHeader, SelectMappedBufferResult selectMappedBufferResult) {
- this.byteBufferHeader = byteBufferHeader;
- this.selectMappedBufferResult = selectMappedBufferResult;
- }
-
-
- @Override
- public long position() {
- return this.byteBufferHeader.position() + this.selectMappedBufferResult.getByteBuffer().position();
- }
-
- @Override
- public long transfered() {
- return transfered;
- }
-
- @Override
- public long count() {
- return this.byteBufferHeader.limit() + this.selectMappedBufferResult.getSize();
- }
-
- @Override
- public long transferTo(WritableByteChannel target, long position) throws IOException {
- if (this.byteBufferHeader.hasRemaining()) {
- transfered += target.write(this.byteBufferHeader);
- return transfered;
- } else if (this.selectMappedBufferResult.getByteBuffer().hasRemaining()) {
- transfered += target.write(this.selectMappedBufferResult.getByteBuffer());
- return transfered;
- }
-
- return 0;
- }
-
- public void close() {
- this.deallocate();
- }
-
- @Override
- protected void deallocate() {
- this.selectMappedBufferResult.release();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/pagecache/QueryMessageTransfer.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/pagecache/QueryMessageTransfer.java b/broker/src/main/java/com/alibaba/rocketmq/broker/pagecache/QueryMessageTransfer.java
deleted file mode 100644
index cbcbc74..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/pagecache/QueryMessageTransfer.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * 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.pagecache;
-
-import com.alibaba.rocketmq.store.QueryMessageResult;
-import io.netty.channel.FileRegion;
-import io.netty.util.AbstractReferenceCounted;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.channels.WritableByteChannel;
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public class QueryMessageTransfer extends AbstractReferenceCounted implements FileRegion {
- private final ByteBuffer byteBufferHeader;
- private final QueryMessageResult queryMessageResult;
- private long transfered; // the bytes which was transfered already
-
-
- public QueryMessageTransfer(ByteBuffer byteBufferHeader, QueryMessageResult queryMessageResult) {
- this.byteBufferHeader = byteBufferHeader;
- this.queryMessageResult = queryMessageResult;
- }
-
-
- @Override
- public long position() {
- int pos = byteBufferHeader.position();
- List<ByteBuffer> messageBufferList = this.queryMessageResult.getMessageBufferList();
- for (ByteBuffer bb : messageBufferList) {
- pos += bb.position();
- }
- return pos;
- }
-
- @Override
- public long transfered() {
- return transfered;
- }
-
- @Override
- public long count() {
- return byteBufferHeader.limit() + this.queryMessageResult.getBufferTotalSize();
- }
-
- @Override
- public long transferTo(WritableByteChannel target, long position) throws IOException {
- if (this.byteBufferHeader.hasRemaining()) {
- transfered += target.write(this.byteBufferHeader);
- return transfered;
- } else {
- List<ByteBuffer> messageBufferList = this.queryMessageResult.getMessageBufferList();
- for (ByteBuffer bb : messageBufferList) {
- if (bb.hasRemaining()) {
- transfered += target.write(bb);
- return transfered;
- }
- }
- }
-
- return 0;
- }
-
- public void close() {
- this.deallocate();
- }
-
- @Override
- protected void deallocate() {
- this.queryMessageResult.release();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/plugin/AbstractPluginMessageStore.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/plugin/AbstractPluginMessageStore.java b/broker/src/main/java/com/alibaba/rocketmq/broker/plugin/AbstractPluginMessageStore.java
deleted file mode 100644
index 141ba69..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/plugin/AbstractPluginMessageStore.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/**
- * 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.plugin;
-
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.protocol.heartbeat.SubscriptionData;
-import com.alibaba.rocketmq.store.*;
-
-import java.util.HashMap;
-import java.util.Set;
-
-public abstract class AbstractPluginMessageStore implements MessageStore {
- protected MessageStore next = null;
- protected MessageStorePluginContext context;
-
- public AbstractPluginMessageStore(MessageStorePluginContext context, MessageStore next) {
- this.next = next;
- this.context = context;
- }
-
- @Override
- public long getEarliestMessageTime() {
- return next.getEarliestMessageTime();
- }
-
- @Override
- public long lockTimeMills() {
- return next.lockTimeMills();
- }
-
- @Override
- public boolean isOSPageCacheBusy() {
- return next.isOSPageCacheBusy();
- }
-
- @Override
- public boolean isTransientStorePoolDeficient() {
- return next.isTransientStorePoolDeficient();
- }
-
- @Override
- public boolean load() {
- return next.load();
- }
-
- @Override
- public void start() throws Exception {
- next.start();
- }
-
- @Override
- public void shutdown() {
- next.shutdown();
- }
-
- @Override
- public void destroy() {
- next.destroy();
- }
-
- @Override
- public PutMessageResult putMessage(MessageExtBrokerInner msg) {
- return next.putMessage(msg);
- }
-
- @Override
- public GetMessageResult getMessage(String group, String topic, int queueId, long offset,
- int maxMsgNums, SubscriptionData subscriptionData) {
- return next.getMessage(group, topic, queueId, offset, maxMsgNums, subscriptionData);
- }
-
- @Override
- public long getMaxOffsetInQuque(String topic, int queueId) {
- return next.getMaxOffsetInQuque(topic, queueId);
- }
-
- @Override
- public long getMinOffsetInQuque(String topic, int queueId) {
- return next.getMinOffsetInQuque(topic, queueId);
- }
-
- @Override
- public long getCommitLogOffsetInQueue(String topic, int queueId, long cqOffset) {
- return next.getCommitLogOffsetInQueue(topic, queueId, cqOffset);
- }
-
- @Override
- public long getOffsetInQueueByTime(String topic, int queueId, long timestamp) {
- return next.getOffsetInQueueByTime(topic, queueId, timestamp);
- }
-
- @Override
- public MessageExt lookMessageByOffset(long commitLogOffset) {
- return next.lookMessageByOffset(commitLogOffset);
- }
-
- @Override
- public SelectMappedBufferResult selectOneMessageByOffset(long commitLogOffset) {
- return next.selectOneMessageByOffset(commitLogOffset);
- }
-
- @Override
- public SelectMappedBufferResult selectOneMessageByOffset(long commitLogOffset, int msgSize) {
- return next.selectOneMessageByOffset(commitLogOffset, msgSize);
- }
-
- @Override
- public String getRunningDataInfo() {
- return next.getRunningDataInfo();
- }
-
- @Override
- public HashMap<String, String> getRuntimeInfo() {
- return next.getRuntimeInfo();
- }
-
- @Override
- public long getMaxPhyOffset() {
- return next.getMaxPhyOffset();
- }
-
- @Override
- public long getMinPhyOffset() {
- return next.getMinPhyOffset();
- }
-
- @Override
- public long getEarliestMessageTime(String topic, int queueId) {
- return next.getEarliestMessageTime(topic, queueId);
- }
-
- @Override
- public long getMessageStoreTimeStamp(String topic, int queueId, long offset) {
- return next.getMessageStoreTimeStamp(topic, queueId, offset);
- }
-
- @Override
- public long getMessageTotalInQueue(String topic, int queueId) {
- return next.getMessageTotalInQueue(topic, queueId);
- }
-
- @Override
- public SelectMappedBufferResult getCommitLogData(long offset) {
- return next.getCommitLogData(offset);
- }
-
- @Override
- public boolean appendToCommitLog(long startOffset, byte[] data) {
- return next.appendToCommitLog(startOffset, data);
- }
-
- @Override
- public void excuteDeleteFilesManualy() {
- next.excuteDeleteFilesManualy();
- }
-
- @Override
- public QueryMessageResult queryMessage(String topic, String key, int maxNum, long begin,
- long end) {
- return next.queryMessage(topic, key, maxNum, begin, end);
- }
-
- @Override
- public void updateHaMasterAddress(String newAddr) {
- next.updateHaMasterAddress(newAddr);
- }
-
- @Override
- public long slaveFallBehindMuch() {
- return next.slaveFallBehindMuch();
- }
-
- @Override
- public long now() {
- return next.now();
- }
-
- @Override
- public int cleanUnusedTopic(Set<String> topics) {
- return next.cleanUnusedTopic(topics);
- }
-
- @Override
- public void cleanExpiredConsumerQueue() {
- next.cleanExpiredConsumerQueue();
- }
-
- @Override
- public boolean checkInDiskByConsumeOffset(String topic, int queueId, long consumeOffset) {
- return next.checkInDiskByConsumeOffset(topic, queueId, consumeOffset);
- }
-
- @Override
- public long dispatchBehindBytes() {
- return next.dispatchBehindBytes();
- }
-
- @Override
- public long flush() {
- return next.flush();
- }
-
- @Override
- public boolean resetWriteOffset(long phyOffset) {
- return next.resetWriteOffset(phyOffset);
- }
-
- @Override
- public long getConfirmOffset() {
- return next.getConfirmOffset();
- }
-
- @Override
- public void setConfirmOffset(long phyOffset) {
- next.setConfirmOffset(phyOffset);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/plugin/MessageStoreFactory.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/plugin/MessageStoreFactory.java b/broker/src/main/java/com/alibaba/rocketmq/broker/plugin/MessageStoreFactory.java
deleted file mode 100644
index 84f5be7..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/plugin/MessageStoreFactory.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * 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.plugin;
-
-import com.alibaba.rocketmq.store.MessageStore;
-
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-
-public final class MessageStoreFactory {
- public final static MessageStore build(MessageStorePluginContext context, MessageStore messageStore)
- throws IOException {
- String plugin = context.getBrokerConfig().getMessageStorePlugIn();
- if (plugin != null && plugin.trim().length() != 0) {
- String[] pluginClasses = plugin.split(",");
- for (int i = pluginClasses.length - 1; i >= 0; --i) {
- String pluginClass = pluginClasses[i];
- try {
- @SuppressWarnings("unchecked")
- Class<AbstractPluginMessageStore> clazz = (Class<AbstractPluginMessageStore>) Class.forName(pluginClass);
- Constructor<AbstractPluginMessageStore> construct = clazz.getConstructor(MessageStorePluginContext.class, MessageStore.class);
- AbstractPluginMessageStore pluginMessageStore = (AbstractPluginMessageStore) construct.newInstance(context, messageStore);
- messageStore = pluginMessageStore;
- } catch (Throwable e) {
- throw new RuntimeException(String.format(
- "Initialize plugin's class %s not found!", pluginClass), e);
- }
- }
- }
- return messageStore;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/plugin/MessageStorePluginContext.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/plugin/MessageStorePluginContext.java b/broker/src/main/java/com/alibaba/rocketmq/broker/plugin/MessageStorePluginContext.java
deleted file mode 100644
index 15e8b07..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/plugin/MessageStorePluginContext.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * 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.plugin;
-
-import com.alibaba.rocketmq.common.BrokerConfig;
-import com.alibaba.rocketmq.store.MessageArrivingListener;
-import com.alibaba.rocketmq.store.config.MessageStoreConfig;
-import com.alibaba.rocketmq.store.stats.BrokerStatsManager;
-
-public class MessageStorePluginContext {
- private MessageStoreConfig messageStoreConfig;
- private BrokerStatsManager brokerStatsManager;
- private MessageArrivingListener messageArrivingListener;
- private BrokerConfig brokerConfig;
-
- public MessageStorePluginContext(MessageStoreConfig messageStoreConfig,
- BrokerStatsManager brokerStatsManager, MessageArrivingListener messageArrivingListener,
- BrokerConfig brokerConfig) {
- super();
- this.messageStoreConfig = messageStoreConfig;
- this.brokerStatsManager = brokerStatsManager;
- this.messageArrivingListener = messageArrivingListener;
- this.brokerConfig = brokerConfig;
- }
-
- public MessageStoreConfig getMessageStoreConfig() {
- return messageStoreConfig;
- }
-
- public BrokerStatsManager getBrokerStatsManager() {
- return brokerStatsManager;
- }
-
- public MessageArrivingListener getMessageArrivingListener() {
- return messageArrivingListener;
- }
-
- public BrokerConfig getBrokerConfig() {
- return brokerConfig;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/processor/AbstractSendMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/processor/AbstractSendMessageProcessor.java b/broker/src/main/java/com/alibaba/rocketmq/broker/processor/AbstractSendMessageProcessor.java
deleted file mode 100644
index 95db52d..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/processor/AbstractSendMessageProcessor.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/**
- * 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.processor;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import com.alibaba.rocketmq.broker.mqtrace.SendMessageContext;
-import com.alibaba.rocketmq.broker.mqtrace.SendMessageHook;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.TopicConfig;
-import com.alibaba.rocketmq.common.TopicFilterType;
-import com.alibaba.rocketmq.common.constant.DBMsgConstants;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.constant.PermName;
-import com.alibaba.rocketmq.common.help.FAQUrl;
-import com.alibaba.rocketmq.common.message.MessageAccessor;
-import com.alibaba.rocketmq.common.message.MessageConst;
-import com.alibaba.rocketmq.common.message.MessageDecoder;
-import com.alibaba.rocketmq.common.protocol.RequestCode;
-import com.alibaba.rocketmq.common.protocol.ResponseCode;
-import com.alibaba.rocketmq.common.protocol.header.SendMessageRequestHeader;
-import com.alibaba.rocketmq.common.protocol.header.SendMessageRequestHeaderV2;
-import com.alibaba.rocketmq.common.protocol.header.SendMessageResponseHeader;
-import com.alibaba.rocketmq.common.sysflag.MessageSysFlag;
-import com.alibaba.rocketmq.common.sysflag.TopicSysFlag;
-import com.alibaba.rocketmq.common.utils.ChannelUtil;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-import com.alibaba.rocketmq.remoting.netty.NettyRequestProcessor;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import com.alibaba.rocketmq.store.MessageExtBrokerInner;
-import io.netty.channel.ChannelHandlerContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-
-
-/**
- * @author shijia.wxr
- */
-public abstract class AbstractSendMessageProcessor implements NettyRequestProcessor {
- protected static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
-
- protected final static int DLQ_NUMS_PER_GROUP = 1;
- protected final BrokerController brokerController;
- protected final Random random = new Random(System.currentTimeMillis());
- protected final SocketAddress storeHost;
- private List<SendMessageHook> sendMessageHookList;
-
-
- public AbstractSendMessageProcessor(final BrokerController brokerController) {
- this.brokerController = brokerController;
- this.storeHost =
- new InetSocketAddress(brokerController.getBrokerConfig().getBrokerIP1(), brokerController
- .getNettyServerConfig().getListenPort());
- }
-
- protected SendMessageContext buildMsgContext(ChannelHandlerContext ctx,
- SendMessageRequestHeader requestHeader) {
- if (!this.hasSendMessageHook()) {
- return null;
- }
- SendMessageContext mqtraceContext;
- mqtraceContext = new SendMessageContext();
- mqtraceContext.setProducerGroup(requestHeader.getProducerGroup());
- mqtraceContext.setTopic(requestHeader.getTopic());
- mqtraceContext.setMsgProps(requestHeader.getProperties());
- mqtraceContext.setBornHost(RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
- mqtraceContext.setBrokerAddr(this.brokerController.getBrokerAddr());
- mqtraceContext.setBrokerRegionId(this.brokerController.getBrokerConfig().getRegionId());
- mqtraceContext.setBornTimeStamp(requestHeader.getBornTimestamp());
-
- Map<String, String> properties = MessageDecoder.string2messageProperties(requestHeader.getProperties());
- String uniqueKey = properties.get(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX);
- properties.put(MessageConst.PROPERTY_MSG_REGION, this.brokerController.getBrokerConfig().getRegionId());
- properties.put(MessageConst.PROPERTY_TRACE_SWITCH, String.valueOf(this.brokerController.getBrokerConfig().isTraceOn()));
- requestHeader.setProperties(MessageDecoder.messageProperties2String(properties));
-
-
- if (uniqueKey == null) {
- uniqueKey = "";
- }
- mqtraceContext.setMsgUniqueKey(uniqueKey);
- return mqtraceContext;
- }
-
- public boolean hasSendMessageHook() {
- return sendMessageHookList != null && !this.sendMessageHookList.isEmpty();
- }
-
- protected MessageExtBrokerInner buildInnerMsg(final ChannelHandlerContext ctx,
- final SendMessageRequestHeader requestHeader, final byte[] body, TopicConfig topicConfig) {
- int queueIdInt = requestHeader.getQueueId();
- if (queueIdInt < 0) {
- queueIdInt = Math.abs(this.random.nextInt() % 99999999) % topicConfig.getWriteQueueNums();
- }
- int sysFlag = requestHeader.getSysFlag();
-
- if (TopicFilterType.MULTI_TAG == topicConfig.getTopicFilterType()) {
- sysFlag |= MessageSysFlag.MULTI_TAGS_FLAG;
- }
-
- MessageExtBrokerInner msgInner = new MessageExtBrokerInner();
- msgInner.setTopic(requestHeader.getTopic());
- msgInner.setBody(body);
- msgInner.setFlag(requestHeader.getFlag());
- MessageAccessor.setProperties(msgInner,
- MessageDecoder.string2messageProperties(requestHeader.getProperties()));
- msgInner.setPropertiesString(requestHeader.getProperties());
- msgInner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(topicConfig.getTopicFilterType(),
- msgInner.getTags()));
-
- msgInner.setQueueId(queueIdInt);
- msgInner.setSysFlag(sysFlag);
- msgInner.setBornTimestamp(requestHeader.getBornTimestamp());
- msgInner.setBornHost(ctx.channel().remoteAddress());
- msgInner.setStoreHost(this.getStoreHost());
- msgInner.setReconsumeTimes(requestHeader.getReconsumeTimes() == null ? 0 : requestHeader
- .getReconsumeTimes());
- return msgInner;
- }
-
- public SocketAddress getStoreHost() {
- return storeHost;
- }
-
- protected RemotingCommand msgContentCheck(final ChannelHandlerContext ctx,
- final SendMessageRequestHeader requestHeader, RemotingCommand request,
- final RemotingCommand response) {
- if (requestHeader.getTopic().length() > Byte.MAX_VALUE) {
- log.warn("putMessage message topic length too long " + requestHeader.getTopic().length());
- response.setCode(ResponseCode.MESSAGE_ILLEGAL);
- return response;
- }
- if (requestHeader.getProperties() != null && requestHeader.getProperties().length() > Short.MAX_VALUE) {
- log.warn("putMessage message properties length too long "
- + requestHeader.getProperties().length());
- response.setCode(ResponseCode.MESSAGE_ILLEGAL);
- return response;
- }
- if (request.getBody().length > DBMsgConstants.MAX_BODY_SIZE) {
- log.warn(" topic {} msg body size {} from {}", requestHeader.getTopic(),
- request.getBody().length, ChannelUtil.getRemoteIp(ctx.channel()));
- response.setRemark("msg body must be less 64KB");
- response.setCode(ResponseCode.MESSAGE_ILLEGAL);
- return response;
- }
- return response;
- }
-
- protected RemotingCommand msgCheck(final ChannelHandlerContext ctx,
- final SendMessageRequestHeader requestHeader, final RemotingCommand response) {
- if (!PermName.isWriteable(this.brokerController.getBrokerConfig().getBrokerPermission())
- && this.brokerController.getTopicConfigManager().isOrderTopic(requestHeader.getTopic())) {
- response.setCode(ResponseCode.NO_PERMISSION);
- response.setRemark("the broker[" + this.brokerController.getBrokerConfig().getBrokerIP1()
- + "] sending message is forbidden");
- return response;
- }
- if (!this.brokerController.getTopicConfigManager().isTopicCanSendMessage(requestHeader.getTopic())) {
- String errorMsg =
- "the topic[" + requestHeader.getTopic() + "] is conflict with system reserved words.";
- log.warn(errorMsg);
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark(errorMsg);
- return response;
- }
-
- TopicConfig topicConfig =
- this.brokerController.getTopicConfigManager().selectTopicConfig(requestHeader.getTopic());
- if (null == topicConfig) {
- int topicSysFlag = 0;
- if (requestHeader.isUnitMode()) {
- if (requestHeader.getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
- topicSysFlag = TopicSysFlag.buildSysFlag(false, true);
- } else {
- topicSysFlag = TopicSysFlag.buildSysFlag(true, false);
- }
- }
-
- log.warn("the topic " + requestHeader.getTopic() + " not exist, producer: "
- + ctx.channel().remoteAddress());
- topicConfig = this.brokerController.getTopicConfigManager().createTopicInSendMessageMethod(//
- requestHeader.getTopic(), //
- requestHeader.getDefaultTopic(), //
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()), //
- requestHeader.getDefaultTopicQueueNums(), topicSysFlag);
-
- if (null == topicConfig) {
- if (requestHeader.getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
- topicConfig =
- this.brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(
- requestHeader.getTopic(), 1, PermName.PERM_WRITE | PermName.PERM_READ,
- topicSysFlag);
- }
- }
-
- if (null == topicConfig) {
- response.setCode(ResponseCode.TOPIC_NOT_EXIST);
- response.setRemark("topic[" + requestHeader.getTopic() + "] not exist, apply first please!"
- + FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
- return response;
- }
- }
-
- int queueIdInt = requestHeader.getQueueId();
- int idValid = Math.max(topicConfig.getWriteQueueNums(), topicConfig.getReadQueueNums());
- if (queueIdInt >= idValid) {
- String errorInfo = String.format("request queueId[%d] is illagal, %s Producer: %s",
- queueIdInt,
- topicConfig.toString(),
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
-
- log.warn(errorInfo);
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark(errorInfo);
-
- return response;
- }
- return response;
- }
-
- public void registerSendMessageHook(List<SendMessageHook> sendMessageHookList) {
- this.sendMessageHookList = sendMessageHookList;
- }
-
- protected void doResponse(ChannelHandlerContext ctx, RemotingCommand request,
- final RemotingCommand response) {
- if (!request.isOnewayRPC()) {
- try {
- ctx.writeAndFlush(response);
- } catch (Throwable e) {
- log.error("SendMessageProcessor process request over, but response failed", e);
- log.error(request.toString());
- log.error(response.toString());
- }
- }
- }
-
- public void executeSendMessageHookBefore(final ChannelHandlerContext ctx, final RemotingCommand request,
- SendMessageContext context) {
- if (hasSendMessageHook()) {
- for (SendMessageHook hook : this.sendMessageHookList) {
- try {
- final SendMessageRequestHeader requestHeader = parseRequestHeader(request);
-
- if (null != requestHeader) {
- context.setProducerGroup(requestHeader.getProducerGroup());
- context.setTopic(requestHeader.getTopic());
- context.setBodyLength(request.getBody().length);
- context.setMsgProps(requestHeader.getProperties());
- context.setBornHost(RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
- context.setBrokerAddr(this.brokerController.getBrokerAddr());
- context.setQueueId(requestHeader.getQueueId());
- }
-
- hook.sendMessageBefore(context);
- requestHeader.setProperties(context.getMsgProps());
- } catch (Throwable e) {
- }
- }
- }
- }
-
- protected SendMessageRequestHeader parseRequestHeader(RemotingCommand request)
- throws RemotingCommandException {
-
- SendMessageRequestHeaderV2 requestHeaderV2 = null;
- SendMessageRequestHeader requestHeader = null;
- switch (request.getCode()) {
- case RequestCode.SEND_MESSAGE_V2:
- requestHeaderV2 =
- (SendMessageRequestHeaderV2) request
- .decodeCommandCustomHeader(SendMessageRequestHeaderV2.class);
- case RequestCode.SEND_MESSAGE:
- if (null == requestHeaderV2) {
- requestHeader =
- (SendMessageRequestHeader) request
- .decodeCommandCustomHeader(SendMessageRequestHeader.class);
- } else {
- requestHeader = SendMessageRequestHeaderV2.createSendMessageRequestHeaderV1(requestHeaderV2);
- }
- default:
- break;
- }
- return requestHeader;
- }
-
- public void executeSendMessageHookAfter(final RemotingCommand response, final SendMessageContext context) {
- if (hasSendMessageHook()) {
- for (SendMessageHook hook : this.sendMessageHookList) {
- try {
- if (response != null) {
- final SendMessageResponseHeader responseHeader =
- (SendMessageResponseHeader) response.readCustomHeader();
- context.setMsgId(responseHeader.getMsgId());
- context.setQueueId(responseHeader.getQueueId());
- context.setQueueOffset(responseHeader.getQueueOffset());
- context.setCode(response.getCode());
- context.setErrorMsg(response.getRemark());
- }
- hook.sendMessageAfter(context);
- } catch (Throwable e) {
-
- }
- }
- }
- }
-
- @Override
- public boolean rejectRequest() {
- return false;
- }
-}
[56/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Use apache
email as author.
Posted by yu...@apache.org.
ROCKETMQ-18 Use apache email as author.
Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/commit/f56e0383
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/tree/f56e0383
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/diff/f56e0383
Branch: refs/heads/master
Commit: f56e03837259bf1b357901d6c146850a46653667
Parents: 07a8862
Author: yukon <yu...@apache.org>
Authored: Tue Dec 27 18:59:17 2016 +0800
Committer: yukon <yu...@apache.org>
Committed: Tue Dec 27 18:59:17 2016 +0800
----------------------------------------------------------------------
README.md | 2 +-
benchmark/consumer.sh | 3 -
benchmark/producer.sh | 2 +-
benchmark/runclass.sh | 2 +-
benchmark/tproducer.sh | 2 +-
.../rocketmq/broker/BrokerController.java | 2 +-
.../apache/rocketmq/broker/BrokerStartup.java | 2 +-
.../broker/client/ClientChannelInfo.java | 2 +-
.../client/ClientHousekeepingService.java | 2 +-
.../broker/client/ConsumerGroupInfo.java | 2 +-
.../client/ConsumerIdsChangeListener.java | 4 +-
.../rocketmq/broker/client/ConsumerManager.java | 2 +-
.../DefaultConsumerIdsChangeListener.java | 2 +-
.../rocketmq/broker/client/ProducerManager.java | 2 +-
.../broker/client/net/Broker2Client.java | 2 +-
.../client/rebalance/RebalanceLockManager.java | 2 +-
.../broker/latency/BrokerFastFailure.java | 2 +-
.../latency/BrokerFixedThreadPoolExecutor.java | 2 +-
.../rocketmq/broker/latency/FutureTaskExt.java | 2 +-
.../broker/longpolling/ManyPullRequest.java | 2 +-
.../broker/longpolling/PullRequest.java | 2 +-
.../longpolling/PullRequestHoldService.java | 2 +-
.../broker/offset/ConsumerOffsetManager.java | 2 +-
.../rocketmq/broker/out/BrokerOuterAPI.java | 2 +-
.../broker/pagecache/ManyMessageTransfer.java | 2 +-
.../broker/pagecache/OneMessageTransfer.java | 2 +-
.../broker/pagecache/QueryMessageTransfer.java | 2 +-
.../processor/AbstractSendMessageProcessor.java | 2 +-
.../broker/processor/AdminBrokerProcessor.java | 2 +-
.../broker/processor/ClientManageProcessor.java | 2 +-
.../processor/ConsumerManageProcessor.java | 2 +-
.../processor/EndTransactionProcessor.java | 2 +-
.../processor/ForwardRequestProcessor.java | 2 +-
.../broker/processor/PullMessageProcessor.java | 2 +-
.../broker/processor/QueryMessageProcessor.java | 2 +-
.../broker/processor/SendMessageProcessor.java | 2 +-
.../rocketmq/broker/slave/SlaveSynchronize.java | 2 +-
.../subscription/SubscriptionGroupManager.java | 2 +-
.../broker/topic/TopicConfigManager.java | 2 +-
.../rocketmq/broker/BrokerTestHarness.java | 2 +-
.../rocketmq/broker/api/SendMessageTest.java | 2 +-
.../offset/ConsumerOffsetManagerTest.java | 2 +-
.../broker/topic/TopicConfigManagerTest.java | 2 +-
.../apache/rocketmq/client/ClientConfig.java | 4 +-
.../org/apache/rocketmq/client/MQAdmin.java | 2 +-
.../org/apache/rocketmq/client/MQHelper.java | 2 +-
.../org/apache/rocketmq/client/QueryResult.java | 2 +-
.../rocketmq/client/admin/MQAdminExtInner.java | 2 +-
.../consumer/AllocateMessageQueueStrategy.java | 4 +-
.../client/consumer/DefaultMQPullConsumer.java | 2 +-
.../client/consumer/DefaultMQPushConsumer.java | 2 +-
.../rocketmq/client/consumer/MQConsumer.java | 2 +-
.../client/consumer/MQPullConsumer.java | 2 +-
.../consumer/MQPullConsumerScheduleService.java | 2 +-
.../client/consumer/MQPushConsumer.java | 2 +-
.../client/consumer/MessageQueueListener.java | 4 +-
.../rocketmq/client/consumer/PullCallback.java | 2 +-
.../rocketmq/client/consumer/PullResult.java | 2 +-
.../rocketmq/client/consumer/PullStatus.java | 2 +-
.../listener/ConsumeConcurrentlyContext.java | 2 +-
.../listener/ConsumeConcurrentlyStatus.java | 2 +-
.../listener/ConsumeOrderlyContext.java | 2 +-
.../consumer/listener/ConsumeOrderlyStatus.java | 2 +-
.../consumer/listener/MessageListener.java | 2 +-
.../listener/MessageListenerConcurrently.java | 2 +-
.../listener/MessageListenerOrderly.java | 2 +-
.../rebalance/AllocateMessageQueueByConfig.java | 2 +-
.../consumer/store/LocalFileOffsetStore.java | 2 +-
.../consumer/store/OffsetSerializeWrapper.java | 2 +-
.../client/consumer/store/OffsetStore.java | 2 +-
.../consumer/store/RemoteBrokerOffsetStore.java | 2 +-
.../client/exception/MQBrokerException.java | 2 +-
.../client/exception/MQClientException.java | 2 +-
.../client/impl/ClientRemotingProcessor.java | 2 +-
.../rocketmq/client/impl/CommunicationMode.java | 2 +-
.../rocketmq/client/impl/FindBrokerResult.java | 2 +-
.../rocketmq/client/impl/MQAdminImpl.java | 2 +-
.../rocketmq/client/impl/MQClientAPIImpl.java | 2 +-
.../rocketmq/client/impl/MQClientManager.java | 2 +-
.../ConsumeMessageConcurrentlyService.java | 2 +-
.../consumer/ConsumeMessageOrderlyService.java | 2 +-
.../impl/consumer/ConsumeMessageService.java | 2 +-
.../consumer/DefaultMQPullConsumerImpl.java | 2 +-
.../consumer/DefaultMQPushConsumerImpl.java | 2 +-
.../client/impl/consumer/MQConsumerInner.java | 2 +-
.../client/impl/consumer/MessageQueueLock.java | 2 +-
.../client/impl/consumer/ProcessQueue.java | 2 +-
.../client/impl/consumer/PullAPIWrapper.java | 2 +-
.../impl/consumer/PullMessageService.java | 2 +-
.../client/impl/consumer/PullRequest.java | 2 +-
.../client/impl/consumer/PullResultExt.java | 2 +-
.../client/impl/consumer/RebalanceImpl.java | 2 +-
.../client/impl/consumer/RebalancePullImpl.java | 2 +-
.../client/impl/consumer/RebalancePushImpl.java | 2 +-
.../client/impl/consumer/RebalanceService.java | 2 +-
.../client/impl/factory/MQClientInstance.java | 2 +-
.../impl/producer/DefaultMQProducerImpl.java | 2 +-
.../client/impl/producer/MQProducerInner.java | 2 +-
.../client/impl/producer/TopicPublishInfo.java | 2 +-
.../client/latency/LatencyFaultTolerance.java | 2 +-
.../latency/LatencyFaultToleranceImpl.java | 2 +-
.../client/latency/MQFaultStrategy.java | 2 +-
.../rocketmq/client/log/ClientLogger.java | 2 +-
.../client/producer/DefaultMQProducer.java | 2 +-
.../producer/LocalTransactionExecuter.java | 2 +-
.../client/producer/LocalTransactionState.java | 2 +-
.../rocketmq/client/producer/MQProducer.java | 2 +-
.../client/producer/MessageQueueSelector.java | 2 +-
.../rocketmq/client/producer/SendCallback.java | 2 +-
.../rocketmq/client/producer/SendResult.java | 2 +-
.../rocketmq/client/producer/SendStatus.java | 2 +-
.../producer/TransactionCheckListener.java | 2 +-
.../client/producer/TransactionMQProducer.java | 2 +-
.../client/producer/TransactionSendResult.java | 2 +-
.../selector/SelectMessageQueueByHash.java | 2 +-
.../SelectMessageQueueByMachineRoom.java | 2 +-
.../selector/SelectMessageQueueByRandoom.java | 2 +-
.../apache/rocketmq/common/BrokerConfig.java | 2 +-
.../apache/rocketmq/common/ConfigManager.java | 2 +-
.../apache/rocketmq/common/CountDownLatch.java | 207 -------------------
.../apache/rocketmq/common/CountDownLatch2.java | 207 +++++++++++++++++++
.../org/apache/rocketmq/common/DataVersion.java | 2 +-
.../org/apache/rocketmq/common/MQVersion.java | 2 +-
.../java/org/apache/rocketmq/common/MixAll.java | 2 +-
.../java/org/apache/rocketmq/common/Pair.java | 2 +-
.../apache/rocketmq/common/ServiceState.java | 2 +-
.../apache/rocketmq/common/ServiceThread.java | 6 +-
.../org/apache/rocketmq/common/TopicConfig.java | 2 +-
.../apache/rocketmq/common/TopicFilterType.java | 2 +-
.../org/apache/rocketmq/common/UtilAll.java | 2 +-
.../rocketmq/common/admin/ConsumeStats.java | 2 +-
.../rocketmq/common/admin/OffsetWrapper.java | 2 +-
.../rocketmq/common/admin/TopicOffset.java | 2 +-
.../rocketmq/common/admin/TopicStatsTable.java | 2 +-
.../rocketmq/common/constant/LoggerName.java | 2 +-
.../rocketmq/common/constant/PermName.java | 2 +-
.../common/consumer/ConsumeFromWhere.java | 2 +-
.../rocketmq/common/filter/FilterAPI.java | 2 +-
.../org/apache/rocketmq/common/help/FAQUrl.java | 2 +-
.../apache/rocketmq/common/message/Message.java | 2 +-
.../rocketmq/common/message/MessageDecoder.java | 2 +-
.../rocketmq/common/message/MessageExt.java | 2 +-
.../rocketmq/common/message/MessageId.java | 2 +-
.../rocketmq/common/message/MessageQueue.java | 2 +-
.../rocketmq/common/namesrv/NamesrvConfig.java | 4 +-
.../rocketmq/common/namesrv/NamesrvUtil.java | 2 +-
.../common/namesrv/RegisterBrokerResult.java | 2 +-
.../rocketmq/common/namesrv/TopAddressing.java | 4 +-
.../common/protocol/MQProtosHelper.java | 2 +-
.../common/protocol/body/ClusterInfo.java | 2 +-
.../common/protocol/body/Connection.java | 2 +-
.../common/protocol/body/ConsumeByWho.java | 2 +-
.../common/protocol/body/ConsumeStatsList.java | 2 +-
.../protocol/body/ConsumerConnection.java | 2 +-
.../common/protocol/body/GroupList.java | 2 +-
.../rocketmq/common/protocol/body/KVTable.java | 2 +-
.../protocol/body/LockBatchRequestBody.java | 2 +-
.../protocol/body/LockBatchResponseBody.java | 2 +-
.../protocol/body/ProducerConnection.java | 2 +-
.../common/protocol/body/TopicList.java | 2 +-
.../protocol/body/UnlockBatchRequestBody.java | 2 +-
.../CheckTransactionStateRequestHeader.java | 4 +-
.../CheckTransactionStateResponseHeader.java | 4 +-
.../header/CloneGroupOffsetRequestHeader.java | 2 +-
.../ConsumerSendMsgBackRequestHeader.java | 2 +-
.../header/CreateTopicRequestHeader.java | 4 +-
.../header/DeleteTopicRequestHeader.java | 4 +-
.../header/EndTransactionRequestHeader.java | 4 +-
.../header/EndTransactionResponseHeader.java | 4 +-
.../header/GetAllTopicConfigResponseHeader.java | 4 +-
.../header/GetBrokerConfigResponseHeader.java | 4 +-
.../header/GetConsumeStatsRequestHeader.java | 2 +-
.../GetConsumerConnectionListRequestHeader.java | 2 +-
.../GetConsumerListByGroupRequestHeader.java | 2 +-
.../GetConsumerListByGroupResponseBody.java | 2 +-
.../GetConsumerListByGroupResponseHeader.java | 2 +-
.../GetConsumerRunningInfoRequestHeader.java | 2 +-
.../GetEarliestMsgStoretimeRequestHeader.java | 4 +-
.../GetEarliestMsgStoretimeResponseHeader.java | 4 +-
.../header/GetMaxOffsetRequestHeader.java | 4 +-
.../header/GetMaxOffsetResponseHeader.java | 4 +-
.../header/GetMinOffsetRequestHeader.java | 4 +-
.../header/GetMinOffsetResponseHeader.java | 4 +-
.../GetProducerConnectionListRequestHeader.java | 2 +-
.../header/GetTopicStatsInfoRequestHeader.java | 2 +-
.../NotifyConsumerIdsChangedRequestHeader.java | 2 +-
.../header/PullMessageRequestHeader.java | 4 +-
.../header/PullMessageResponseHeader.java | 4 +-
.../QueryConsumerOffsetRequestHeader.java | 4 +-
.../QueryConsumerOffsetResponseHeader.java | 4 +-
.../header/QueryCorrectionOffsetHeader.java | 2 +-
.../header/QueryMessageRequestHeader.java | 4 +-
.../header/QueryMessageResponseHeader.java | 4 +-
.../QueryTopicConsumeByWhoRequestHeader.java | 4 +-
.../header/SearchOffsetRequestHeader.java | 4 +-
.../header/SearchOffsetResponseHeader.java | 4 +-
.../header/SendMessageRequestHeader.java | 4 +-
.../header/SendMessageRequestHeaderV2.java | 2 +-
.../header/SendMessageResponseHeader.java | 4 +-
.../header/UnregisterClientRequestHeader.java | 2 +-
.../header/UnregisterClientResponseHeader.java | 2 +-
.../UpdateConsumerOffsetRequestHeader.java | 4 +-
.../UpdateConsumerOffsetResponseHeader.java | 4 +-
.../header/ViewMessageRequestHeader.java | 4 +-
.../header/ViewMessageResponseHeader.java | 4 +-
.../namesrv/DeleteKVConfigRequestHeader.java | 2 +-
.../DeleteTopicInNamesrvRequestHeader.java | 2 +-
.../namesrv/GetKVConfigRequestHeader.java | 2 +-
.../namesrv/GetKVConfigResponseHeader.java | 2 +-
.../GetKVListByNamespaceRequestHeader.java | 2 +-
.../namesrv/GetRouteInfoRequestHeader.java | 4 +-
.../namesrv/GetRouteInfoResponseHeader.java | 4 +-
.../namesrv/RegisterBrokerRequestHeader.java | 2 +-
.../namesrv/RegisterBrokerResponseHeader.java | 2 +-
.../RegisterOrderTopicRequestHeader.java | 4 +-
.../namesrv/UnRegisterBrokerRequestHeader.java | 2 +-
.../WipeWritePermOfBrokerRequestHeader.java | 2 +-
.../WipeWritePermOfBrokerResponseHeader.java | 2 +-
.../common/protocol/heartbeat/ConsumeType.java | 4 +-
.../common/protocol/heartbeat/ConsumerData.java | 4 +-
.../protocol/heartbeat/HeartbeatData.java | 4 +-
.../common/protocol/heartbeat/MessageModel.java | 4 +-
.../common/protocol/heartbeat/ProducerData.java | 4 +-
.../protocol/heartbeat/SubscriptionData.java | 4 +-
.../common/protocol/route/BrokerData.java | 4 +-
.../common/protocol/route/QueueData.java | 2 +-
.../common/protocol/route/TopicRouteData.java | 4 +-
.../subscription/SubscriptionGroupConfig.java | 2 +-
.../rocketmq/common/sysflag/MessageSysFlag.java | 2 +-
.../rocketmq/common/sysflag/PullSysFlag.java | 2 +-
.../rocketmq/common/filter/FilterAPITest.java | 2 +-
.../filtersrv/FilterServerOuterAPI.java | 2 +-
.../rocketmq/filtersrv/FiltersrvController.java | 2 +-
.../rocketmq/filtersrv/FiltersrvStartup.java | 2 +-
.../processor/DefaultRequestProcessor.java | 2 +-
.../rocketmq/namesrv/NamesrvController.java | 2 +-
.../apache/rocketmq/namesrv/NamesrvStartup.java | 2 +-
.../namesrv/kvconfig/KVConfigManager.java | 2 +-
.../kvconfig/KVConfigSerializeWrapper.java | 2 +-
.../processor/DefaultRequestProcessor.java | 2 +-
.../routeinfo/BrokerHousekeepingService.java | 2 +-
.../namesrv/routeinfo/RouteInfoManager.java | 2 +-
pom.xml | 10 +-
.../rocketmq/remoting/ChannelEventListener.java | 2 +-
.../rocketmq/remoting/CommandCustomHeader.java | 2 +-
.../rocketmq/remoting/InvokeCallback.java | 2 +-
.../rocketmq/remoting/RemotingClient.java | 2 +-
.../rocketmq/remoting/RemotingServer.java | 2 +-
.../rocketmq/remoting/annotation/CFNotNull.java | 2 +-
.../remoting/annotation/CFNullable.java | 2 +-
.../apache/rocketmq/remoting/common/Pair.java | 2 +-
.../remoting/common/RemotingHelper.java | 2 +-
.../rocketmq/remoting/common/RemotingUtil.java | 2 +-
.../common/SemaphoreReleaseOnlyOnce.java | 2 +-
.../rocketmq/remoting/common/ServiceThread.java | 2 +-
.../exception/RemotingCommandException.java | 2 +-
.../exception/RemotingConnectException.java | 2 +-
.../remoting/exception/RemotingException.java | 2 +-
.../exception/RemotingSendRequestException.java | 2 +-
.../exception/RemotingTimeoutException.java | 2 +-
.../RemotingTooMuchRequestException.java | 2 +-
.../remoting/netty/NettyClientConfig.java | 2 +-
.../rocketmq/remoting/netty/NettyDecoder.java | 2 +-
.../rocketmq/remoting/netty/NettyEncoder.java | 2 +-
.../rocketmq/remoting/netty/NettyEvent.java | 2 +-
.../rocketmq/remoting/netty/NettyEventType.java | 2 +-
.../remoting/netty/NettyRemotingAbstract.java | 2 +-
.../remoting/netty/NettyRemotingClient.java | 2 +-
.../remoting/netty/NettyRequestProcessor.java | 2 +-
.../remoting/netty/NettyServerConfig.java | 2 +-
.../rocketmq/remoting/netty/ResponseFuture.java | 2 +-
.../remoting/protocol/RemotingCommand.java | 2 +-
.../remoting/protocol/RemotingCommandType.java | 2 +-
.../remoting/protocol/RemotingSerializable.java | 2 +-
.../org/apache/rocketmq/remoting/MixTest.java | 4 +-
.../apache/rocketmq/remoting/NettyRPCTest.java | 4 +-
.../rocketmq/subclass/TestSubClassAuto.java | 2 +-
.../store/AllocateMappedFileService.java | 2 +-
.../rocketmq/store/AppendMessageCallback.java | 2 +-
.../rocketmq/store/AppendMessageResult.java | 2 +-
.../rocketmq/store/AppendMessageStatus.java | 2 +-
.../org/apache/rocketmq/store/CommitLog.java | 2 +-
.../org/apache/rocketmq/store/ConsumeQueue.java | 2 +-
.../rocketmq/store/DefaultMessageFilter.java | 2 +-
.../rocketmq/store/DefaultMessageStore.java | 2 +-
.../apache/rocketmq/store/DispatchRequest.java | 2 +-
.../apache/rocketmq/store/GetMessageResult.java | 2 +-
.../apache/rocketmq/store/GetMessageStatus.java | 2 +-
.../org/apache/rocketmq/store/MappedFile.java | 2 +-
.../apache/rocketmq/store/MappedFileQueue.java | 2 +-
.../rocketmq/store/MessageExtBrokerInner.java | 2 +-
.../apache/rocketmq/store/MessageFilter.java | 2 +-
.../org/apache/rocketmq/store/MessageStore.java | 2 +-
.../apache/rocketmq/store/PutMessageResult.java | 2 +-
.../apache/rocketmq/store/PutMessageStatus.java | 2 +-
.../rocketmq/store/QueryMessageResult.java | 2 +-
.../rocketmq/store/ReferenceResource.java | 2 +-
.../org/apache/rocketmq/store/RunningFlags.java | 2 +-
.../store/SelectMappedBufferResult.java | 2 +-
.../apache/rocketmq/store/StoreCheckpoint.java | 2 +-
.../rocketmq/store/StoreStatsService.java | 2 +-
.../org/apache/rocketmq/store/StoreUtil.java | 2 +-
.../rocketmq/store/TransientStorePool.java | 2 +-
.../rocketmq/store/config/BrokerRole.java | 2 +-
.../rocketmq/store/config/FlushDiskType.java | 2 +-
.../store/config/MessageStoreConfig.java | 4 +-
.../apache/rocketmq/store/ha/HAConnection.java | 6 +-
.../org/apache/rocketmq/store/ha/HAService.java | 2 +-
.../rocketmq/store/ha/WaitNotifyObject.java | 2 +-
.../apache/rocketmq/store/index/IndexFile.java | 2 +-
.../rocketmq/store/index/IndexHeader.java | 2 +-
.../rocketmq/store/index/IndexService.java | 2 +-
.../rocketmq/store/index/QueryOffsetResult.java | 2 +-
.../schedule/DelayOffsetSerializeWrapper.java | 2 +-
.../store/schedule/ScheduleMessageService.java | 2 +-
.../rocketmq/store/stats/BrokerStats.java | 2 +-
.../rocketmq/store/DefaultMessageStoreTest.java | 2 +-
.../rocketmq/store/MappedFileQueueTest.java | 2 +-
.../apache/rocketmq/store/MappedFileTest.java | 2 +-
.../rocketmq/store/StoreCheckpointTest.java | 2 +-
.../rocketmq/store/index/IndexFileTest.java | 2 +-
.../store/schedule/ScheduleMessageTest.java | 2 +-
.../rocketmq/tools/admin/DefaultMQAdminExt.java | 2 +-
.../tools/admin/DefaultMQAdminExtImpl.java | 2 +-
.../rocketmq/tools/command/CommandUtil.java | 2 +-
.../rocketmq/tools/command/MQAdminStartup.java | 2 +-
.../rocketmq/tools/command/SubCommand.java | 2 +-
.../broker/BrokerConsumeStatsSubCommad.java | 2 +-
.../command/broker/BrokerStatusSubCommand.java | 2 +-
.../broker/UpdateBrokerConfigSubCommand.java | 2 +-
.../command/cluster/ClusterListSubCommand.java | 2 +-
.../ConsumerConnectionSubCommand.java | 2 +-
.../ProducerConnectionSubCommand.java | 2 +-
.../consumer/ConsumerProgressSubCommand.java | 2 +-
.../consumer/ConsumerStatusSubCommand.java | 2 +-
.../command/consumer/ConsumerSubCommand.java | 2 +-
.../consumer/StartMonitoringSubCommand.java | 2 +-
.../consumer/UpdateSubGroupSubCommand.java | 2 +-
.../command/message/PrintMessageSubCommand.java | 2 +-
.../command/message/QueryMsgByIdSubCommand.java | 2 +-
.../message/QueryMsgByKeySubCommand.java | 2 +-
.../message/QueryMsgByOffsetSubCommand.java | 2 +-
.../command/topic/TopicListSubCommand.java | 2 +-
.../command/topic/TopicRouteSubCommand.java | 2 +-
.../command/topic/TopicStatusSubCommand.java | 2 +-
.../command/topic/UpdateTopicSubCommand.java | 2 +-
346 files changed, 607 insertions(+), 610 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 7b1157b..47abbe1 100644
--- a/README.md
+++ b/README.md
@@ -31,7 +31,7 @@ It offers a variety of features as follows:
----------
## RocketMQ Community
-* [`Docker images`](https://registry.hub.docker.com/u/vongosling/rocketmq/)
+* [`Docker images`](https://registry.hub.docker.com/u/vongosling@apache.org/rocketmq/)
* [RocketMQ Community Projects](https://github.com/rocketmq)
----------
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/benchmark/consumer.sh
----------------------------------------------------------------------
diff --git a/benchmark/consumer.sh b/benchmark/consumer.sh
index 8cbbbd9..8ab7fae 100644
--- a/benchmark/consumer.sh
+++ b/benchmark/consumer.sh
@@ -15,7 +15,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-#
-# $Id: consumer.sh 1831 2013-05-16 01:39:51Z shijia.wxr $
-#
sh ./runclass.sh org.apache.rocketmq.example.benchmark.Consumer $@ &
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/benchmark/producer.sh
----------------------------------------------------------------------
diff --git a/benchmark/producer.sh b/benchmark/producer.sh
index 4eb5ca7..c5df34d 100644
--- a/benchmark/producer.sh
+++ b/benchmark/producer.sh
@@ -15,6 +15,6 @@
# limitations under the License.
#
-# $Id: producer.sh 1831 2013-05-16 01:39:51Z shijia.wxr $
+# $Id: producer.sh 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
#
sh ./runclass.sh -Dorg.apache.rocketmq.client.sendSmartMsg=true org.apache.rocketmq.example.benchmark.Producer $@ &
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/benchmark/runclass.sh
----------------------------------------------------------------------
diff --git a/benchmark/runclass.sh b/benchmark/runclass.sh
index 14e712f..bf4f275 100644
--- a/benchmark/runclass.sh
+++ b/benchmark/runclass.sh
@@ -15,7 +15,7 @@
# limitations under the License.
#
-# $Id: runserver.sh 1831 2013-05-16 01:39:51Z shijia.wxr $
+# $Id: runserver.sh 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
#
if [ $# -lt 1 ];
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/benchmark/tproducer.sh
----------------------------------------------------------------------
diff --git a/benchmark/tproducer.sh b/benchmark/tproducer.sh
index bf64802..89676cc 100644
--- a/benchmark/tproducer.sh
+++ b/benchmark/tproducer.sh
@@ -15,6 +15,6 @@
# limitations under the License.
#
-# $Id: producer.sh 1831 2013-05-16 01:39:51Z shijia.wxr $
+# $Id: producer.sh 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
#
sh ./runclass.sh org.apache.rocketmq.example.benchmark.TransactionProducer $@
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
index c5c05f4..869e4ab 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
@@ -64,7 +64,7 @@ import java.util.concurrent.*;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class BrokerController {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
index 1749e91..2882d2d 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
@@ -45,7 +45,7 @@ import java.util.concurrent.atomic.AtomicInteger;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class BrokerStartup {
public static Properties properties = null;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
index e15a22a..8144b48 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
@@ -21,7 +21,7 @@ import io.netty.channel.Channel;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ClientChannelInfo {
private final Channel channel;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java
index 2d1ad9b..2842bd6 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientHousekeepingService.java
@@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ClientHousekeepingService implements ChannelEventListener {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java
index 10795f5..6265d43 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerGroupInfo.java
@@ -34,7 +34,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ConsumerGroupInfo {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java
index e8d23db..d580b26 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerIdsChangeListener.java
@@ -22,8 +22,8 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface ConsumerIdsChangeListener {
- public void consumerIdsChanged(final String group, final List<Channel> channels);
+ void consumerIdsChanged(final String group, final List<Channel> channels);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java
index 561fec6..a9490a6 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java
@@ -35,7 +35,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ConsumerManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java b/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java
index 501d665..b974db4 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/DefaultConsumerIdsChangeListener.java
@@ -23,7 +23,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class DefaultConsumerIdsChangeListener implements ConsumerIdsChangeListener {
private final BrokerController brokerController;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java
index 6656ab0..8abb903 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ProducerManager.java
@@ -33,7 +33,7 @@ import java.util.concurrent.locks.ReentrantLock;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ProducerManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java b/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
index 7d7064a..152f373 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/net/Broker2Client.java
@@ -56,7 +56,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class Broker2Client {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java b/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java
index adb1819..1fa835c 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java
@@ -29,7 +29,7 @@ import java.util.concurrent.locks.ReentrantLock;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class RebalanceLockManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.REBALANCE_LOCK_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
index 57a451f..4810d77 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
@@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class BrokerFastFailure {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java
index 352543e..9891222 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java
@@ -20,7 +20,7 @@ package org.apache.rocketmq.broker.latency;
import java.util.concurrent.*;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class BrokerFixedThreadPoolExecutor extends ThreadPoolExecutor {
public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit, final BlockingQueue<Runnable> workQueue) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/latency/FutureTaskExt.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/latency/FutureTaskExt.java b/broker/src/main/java/org/apache/rocketmq/broker/latency/FutureTaskExt.java
index 642cdd9..a6a01b2 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/latency/FutureTaskExt.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/latency/FutureTaskExt.java
@@ -21,7 +21,7 @@ import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class FutureTaskExt<V> extends FutureTask<V> {
private final Runnable runnable;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
index 7e9e40a..a6510c7 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
@@ -21,7 +21,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ManyPullRequest {
private final ArrayList<PullRequest> pullRequestList = new ArrayList<PullRequest>();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java
index cf03b03..b3cf00b 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java
@@ -22,7 +22,7 @@ import io.netty.channel.Channel;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class PullRequest {
private final RemotingCommand requestCommand;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java
index 19a3f54..d6e4ac9 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java
@@ -31,7 +31,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class PullRequestHoldService extends ServiceThread {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java b/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
index 8a1773a..ef9065e 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
@@ -31,7 +31,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ConsumerOffsetManager extends ConfigManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java b/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
index 2836c4c..ab02ceb 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
@@ -42,7 +42,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
* @author manhong.yqd
*/
public class BrokerOuterAPI {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java
index d26eab8..9369bd0 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java
@@ -27,7 +27,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ManyMessageTransfer extends AbstractReferenceCounted implements FileRegion {
private final ByteBuffer byteBufferHeader;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java
index 97d1faa..ed56be0 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java
@@ -26,7 +26,7 @@ import java.nio.channels.WritableByteChannel;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class OneMessageTransfer extends AbstractReferenceCounted implements FileRegion {
private final ByteBuffer byteBufferHeader;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java
index 2d21c19..ec51508 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java
@@ -27,7 +27,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class QueryMessageTransfer extends AbstractReferenceCounted implements FileRegion {
private final ByteBuffer byteBufferHeader;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
index 3cf28b3..81a239b 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
@@ -54,7 +54,7 @@ import java.util.Random;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public abstract class AbstractSendMessageProcessor implements NettyRequestProcessor {
protected static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
index c1241bb..94aa414 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
@@ -62,7 +62,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
* @author manhong.yqd
*/
public class AdminBrokerProcessor implements NettyRequestProcessor {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
index bdceeb0..c7b2972 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
@@ -40,7 +40,7 @@ import org.slf4j.LoggerFactory;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ClientManageProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
index 09a2607..ef15589 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
@@ -34,7 +34,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ConsumerManageProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
index fc38238..d86d03b 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
@@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class EndTransactionProcessor implements NettyRequestProcessor {
private static final Logger LOGGER = LoggerFactory.getLogger(LoggerName.TRANSACTION_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java
index acf25ea..781bd69 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java
@@ -26,7 +26,7 @@ import org.slf4j.LoggerFactory;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ForwardRequestProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
index 3094079..7f88593 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
@@ -58,7 +58,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class PullMessageProcessor implements NettyRequestProcessor {
private static final Logger LOG = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
index 5390e28..b41e0a5 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
@@ -40,7 +40,7 @@ import org.slf4j.LoggerFactory;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class QueryMessageProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
index 7a0ddae..defe7e3 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
@@ -49,7 +49,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class SendMessageProcessor extends AbstractSendMessageProcessor implements NettyRequestProcessor {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java b/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
index 45914d7..049c07d 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
@@ -31,7 +31,7 @@ import java.io.IOException;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
* @author manhong.yqd
*/
public class SlaveSynchronize {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java b/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java
index 364d5c8..c4432fa 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/subscription/SubscriptionGroupManager.java
@@ -34,7 +34,7 @@ import java.util.concurrent.ConcurrentHashMap;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class SubscriptionGroupManager extends ConfigManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java b/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java
index 40fdd68..26a898c 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/topic/TopicConfigManager.java
@@ -43,7 +43,7 @@ import java.util.concurrent.locks.ReentrantLock;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class TopicConfigManager extends ConfigManager {
private static final Logger LOG = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java b/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
index 4b4fd95..cbc041f 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: SendMessageTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
+ * $Id: SendMessageTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
package org.apache.rocketmq.broker;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java b/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
index 9988a7c..79013af 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: SendMessageTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
+ * $Id: SendMessageTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
package org.apache.rocketmq.broker.api;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java b/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
index cdbddf9..8063ff9 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: ConsumerOffsetManagerTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
+ * $Id: ConsumerOffsetManagerTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
package org.apache.rocketmq.broker.offset;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java b/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
index 1de17e6..e199f8d 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
@@ -16,7 +16,7 @@
*/
/**
- * $Id: TopicConfigManagerTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
+ * $Id: TopicConfigManagerTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
package org.apache.rocketmq.broker.topic;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/ClientConfig.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 8d15108..b4cd41c 100644
--- a/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java
+++ b/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java
@@ -24,8 +24,8 @@ import org.apache.rocketmq.remoting.common.RemotingUtil;
/**
* Client Common configuration
*
- * @author shijia.wxr
- * @author vongosling
+ * @author vintagewang@apache.org
+ * @author vongosling@apache.org
*/
public class ClientConfig {
public static final String SEND_MESSAGE_WITH_VIP_CHANNEL_PROPERTY = "com.rocketmq.sendMessageWithVIPChannel";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java b/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
index 9e85283..f350073 100644
--- a/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
+++ b/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
@@ -26,7 +26,7 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
/**
* Base interface for MQ management
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface MQAdmin {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/MQHelper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/MQHelper.java b/client/src/main/java/org/apache/rocketmq/client/MQHelper.java
index 41009c5..efca00f 100644
--- a/client/src/main/java/org/apache/rocketmq/client/MQHelper.java
+++ b/client/src/main/java/org/apache/rocketmq/client/MQHelper.java
@@ -27,7 +27,7 @@ import java.util.TreeSet;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MQHelper {
public static void resetOffsetByTimestamp(
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/QueryResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/QueryResult.java b/client/src/main/java/org/apache/rocketmq/client/QueryResult.java
index cdbf1e7..16f0f83 100644
--- a/client/src/main/java/org/apache/rocketmq/client/QueryResult.java
+++ b/client/src/main/java/org/apache/rocketmq/client/QueryResult.java
@@ -22,7 +22,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class QueryResult {
private final long indexLastUpdateTimestamp;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java b/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java
index cfff17e..2cc0f2c 100644
--- a/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java
+++ b/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.client.admin;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface MQAdminExtInner {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java b/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java
index cb98b62..9fb2c48 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java
@@ -24,8 +24,8 @@ import java.util.List;
/**
* Strategy Algorithm for message allocating between consumers
*
- * @author shijia.wxr
- * @author vongosling
+ * @author vintagewang@apache.org
+ * @author vongosling@apache.org
*/
public interface AllocateMessageQueueStrategy {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
index c4e91a3..a8dd766 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
@@ -38,7 +38,7 @@ import java.util.Set;
/**
* Default pulling consumer
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class DefaultMQPullConsumer extends ClientConfig implements MQPullConsumer {
protected final transient DefaultMQPullConsumerImpl defaultMQPullConsumerImpl;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
index cbed53b..38c4649 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
@@ -44,7 +44,7 @@ import java.util.Set;
/**
* Wrapped push consumer.in fact,it works as remarkable as the pull consumer
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsumer {
protected final transient DefaultMQPushConsumerImpl defaultMQPushConsumerImpl;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
index 3e26ed6..6d5f7da 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
@@ -29,7 +29,7 @@ import java.util.Set;
/**
* Message queue consumer interface
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface MQConsumer extends MQAdmin {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
index d651562..036fca2 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
@@ -28,7 +28,7 @@ import java.util.Set;
/**
* Pulling consumer interface
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface MQPullConsumer extends MQConsumer {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java
index 33cc1c9..5a36ce6 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java
@@ -34,7 +34,7 @@ import java.util.concurrent.TimeUnit;
/**
* Schedule service for pull consumer
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MQPullConsumerScheduleService {
private final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
index 982c839..76f7cea 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
@@ -25,7 +25,7 @@ import org.apache.rocketmq.client.exception.MQClientException;
/**
* Push consumer
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface MQPushConsumer extends MQConsumer {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
index e59a3ce..5d50252 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
@@ -24,8 +24,8 @@ import java.util.Set;
/**
* A MessageQueueListener is implemented by the application and may be specified when a message queue changed
*
- * @author shijia.wxr
- * @author vongosling
+ * @author vintagewang@apache.org
+ * @author vongosling@apache.org
*/
public interface MessageQueueListener {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
index 2429d5a..fd2be0e 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
@@ -19,7 +19,7 @@ package org.apache.rocketmq.client.consumer;
/**
* Async message pulling interface
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface PullCallback {
public void onSuccess(final PullResult pullResult);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java
index 81dd497..4bd9a78 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java
@@ -22,7 +22,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class PullResult {
private final PullStatus pullStatus;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java
index b63a4c4..79378a3 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.client.consumer;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public enum PullStatus {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java
index 03223ba..75fffe8 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java
@@ -22,7 +22,7 @@ import org.apache.rocketmq.common.message.MessageQueue;
/**
* Consumer concurrent consumption context
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ConsumeConcurrentlyContext {
private final MessageQueue messageQueue;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java
index 433ce36..21febbd 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.client.consumer.listener;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public enum ConsumeConcurrentlyStatus {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
index 2adeb29..cfca174 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
@@ -22,7 +22,7 @@ import org.apache.rocketmq.common.message.MessageQueue;
/**
* Consumer Orderly consumption context
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ConsumeOrderlyContext {
private final MessageQueue messageQueue;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java
index 7da0b1f..2783714 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.client.consumer.listener;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public enum ConsumeOrderlyStatus {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
index adc2651..9148b33 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
@@ -19,7 +19,7 @@ package org.apache.rocketmq.client.consumer.listener;
/**
* A MessageListener object is used to receive asynchronously delivered messages.
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface MessageListener {
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
index 3df6cc2..1c807ce 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
@@ -24,7 +24,7 @@ import java.util.List;
/**
* A MessageListenerConcurrently object is used to receive asynchronously delivered messages concurrently
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface MessageListenerConcurrently extends MessageListener {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
index d1b6c79..1efd19f 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
@@ -24,7 +24,7 @@ import java.util.List;
/**
* A MessageListenerConcurrently object is used to receive asynchronously delivered messages orderly.one queue,one thread
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface MessageListenerOrderly extends MessageListener {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java
index 3784752..8886cb3 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java
@@ -23,7 +23,7 @@ import java.util.List;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class AllocateMessageQueueByConfig implements AllocateMessageQueueStrategy {
private List<MessageQueue> messageQueueList;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
index f4d87e7..2e32700 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
@@ -39,7 +39,7 @@ import java.util.concurrent.atomic.AtomicLong;
/**
* Local storage implementation
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class LocalFileOffsetStore implements OffsetStore {
public final static String LOCAL_OFFSET_STORE_DIR = System.getProperty(
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
index e69ad23..b103084 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
@@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicLong;
/**
* Wrapper class for offset serialization
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class OffsetSerializeWrapper extends RemotingSerializable {
private ConcurrentHashMap<MessageQueue, AtomicLong> offsetTable =
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
index 7c7ccc6..2d8c2a6 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
@@ -28,7 +28,7 @@ import java.util.Set;
/**
* Offset store interface
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public interface OffsetStore {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
index 082e7e8..4fd6911 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
@@ -40,7 +40,7 @@ import java.util.concurrent.atomic.AtomicLong;
/**
* Remote storage implementation
*
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class RemoteBrokerOffsetStore implements OffsetStore {
private final static Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java b/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java
index 5e8d1b9..1765fd6 100644
--- a/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java
+++ b/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java
@@ -21,7 +21,7 @@ import org.apache.rocketmq.common.help.FAQUrl;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MQBrokerException extends Exception {
private static final long serialVersionUID = 5975020272601250368L;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java b/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java
index 5f32d12..5000ac5 100644
--- a/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java
+++ b/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java
@@ -21,7 +21,7 @@ import org.apache.rocketmq.common.help.FAQUrl;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MQClientException extends Exception {
private static final long serialVersionUID = -5758410930844185841L;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java b/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
index 50e9b45..c751c44 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
@@ -44,7 +44,7 @@ import java.util.Map;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ClientRemotingProcessor implements NettyRequestProcessor {
private final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java b/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java
index 0f57339..db9f6fb 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.client.impl;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public enum CommunicationMode {
SYNC,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java b/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java
index 56528ef..4e2b058 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java
@@ -17,7 +17,7 @@
package org.apache.rocketmq.client.impl;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class FindBrokerResult {
private final String brokerAddr;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
index b6255c4..6ae4f94 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
@@ -49,7 +49,7 @@ import java.util.concurrent.TimeUnit;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MQAdminImpl {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
index 99204b0..e45d593 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
@@ -67,7 +67,7 @@ import java.util.concurrent.atomic.AtomicInteger;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MQClientAPIImpl {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java
index 8700ef1..585e8c7 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java
@@ -25,7 +25,7 @@ import java.util.concurrent.atomic.AtomicInteger;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class MQClientManager {
private static MQClientManager instance = new MQClientManager();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
index 88fe25f..e1bfd96 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
@@ -40,7 +40,7 @@ import java.util.concurrent.*;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ConsumeMessageConcurrentlyService implements ConsumeMessageService {
private static final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/f56e0383/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
index 010fd2f..7b84cef 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
@@ -42,7 +42,7 @@ import java.util.concurrent.*;
/**
- * @author shijia.wxr
+ * @author vintagewang@apache.org
*/
public class ConsumeMessageOrderlyService implements ConsumeMessageService {
private static final Logger log = ClientLogger.getLog();
[80/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java
index 9daff00..8b95d73 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java
@@ -6,32 +6,28 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.ArrayList;
import java.util.List;
-
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
public class QueryConsumeTimeSpanBody extends RemotingSerializable {
List<QueueTimeSpan> consumeTimeSpanSet = new ArrayList<QueueTimeSpan>();
-
public List<QueueTimeSpan> getConsumeTimeSpanSet() {
return consumeTimeSpanSet;
}
-
public void setConsumeTimeSpanSet(List<QueueTimeSpan> consumeTimeSpanSet) {
this.consumeTimeSpanSet = consumeTimeSpanSet;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java
index 18b1ff4..f2be75c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java
@@ -6,31 +6,27 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.HashMap;
import java.util.Map;
-
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
public class QueryCorrectionOffsetBody extends RemotingSerializable {
private Map<Integer, Long> correctionOffsets = new HashMap<Integer, Long>();
-
public Map<Integer, Long> getCorrectionOffsets() {
return correctionOffsets;
}
-
public void setCorrectionOffsets(Map<Integer, Long> correctionOffsets) {
this.correctionOffsets = correctionOffsets;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueueTimeSpan.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueueTimeSpan.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueueTimeSpan.java
index df1daf9..5d41664 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueueTimeSpan.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueueTimeSpan.java
@@ -6,23 +6,21 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
+import java.util.Date;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.message.MessageQueue;
-import java.util.Date;
-
-
public class QueueTimeSpan {
private MessageQueue messageQueue;
private long minTimeStamp;
@@ -30,67 +28,54 @@ public class QueueTimeSpan {
private long consumeTimeStamp;
private long delayTime;
-
public MessageQueue getMessageQueue() {
return messageQueue;
}
-
public void setMessageQueue(MessageQueue messageQueue) {
this.messageQueue = messageQueue;
}
-
public long getMinTimeStamp() {
return minTimeStamp;
}
-
public void setMinTimeStamp(long minTimeStamp) {
this.minTimeStamp = minTimeStamp;
}
-
public long getMaxTimeStamp() {
return maxTimeStamp;
}
-
public void setMaxTimeStamp(long maxTimeStamp) {
this.maxTimeStamp = maxTimeStamp;
}
-
public long getConsumeTimeStamp() {
return consumeTimeStamp;
}
-
public void setConsumeTimeStamp(long consumeTimeStamp) {
this.consumeTimeStamp = consumeTimeStamp;
}
-
public String getMinTimeStampStr() {
return UtilAll.formatDate(new Date(minTimeStamp), UtilAll.YYYY_MM_DD_HH_MM_SS_SSS);
}
-
public String getMaxTimeStampStr() {
return UtilAll.formatDate(new Date(maxTimeStamp), UtilAll.YYYY_MM_DD_HH_MM_SS_SSS);
}
-
public String getConsumeTimeStampStr() {
return UtilAll.formatDate(new Date(consumeTimeStamp), UtilAll.YYYY_MM_DD_HH_MM_SS_SSS);
}
-
public long getDelayTime() {
return delayTime;
}
-
public void setDelayTime(long delayTime) {
this.delayTime = delayTime;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/RegisterBrokerBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/RegisterBrokerBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/RegisterBrokerBody.java
index 45a4a29..dfb6f10 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/RegisterBrokerBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/RegisterBrokerBody.java
@@ -6,43 +6,37 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.ArrayList;
import java.util.List;
-
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
public class RegisterBrokerBody extends RemotingSerializable {
private TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper();
private List<String> filterServerList = new ArrayList<String>();
-
public TopicConfigSerializeWrapper getTopicConfigSerializeWrapper() {
return topicConfigSerializeWrapper;
}
-
public void setTopicConfigSerializeWrapper(TopicConfigSerializeWrapper topicConfigSerializeWrapper) {
this.topicConfigSerializeWrapper = topicConfigSerializeWrapper;
}
-
public List<String> getFilterServerList() {
return filterServerList;
}
-
public void setFilterServerList(List<String> filterServerList) {
this.filterServerList = filterServerList;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBody.java
index cefaa1f..3a249f0 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBody.java
@@ -6,35 +6,31 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
+import java.util.Map;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-import java.util.Map;
-
-
/**
*
*/
public class ResetOffsetBody extends RemotingSerializable {
private Map<MessageQueue, Long> offsetTable;
-
public Map<MessageQueue, Long> getOffsetTable() {
return offsetTable;
}
-
public void setOffsetTable(Map<MessageQueue, Long> offsetTable) {
this.offsetTable = offsetTable;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBodyForC.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBodyForC.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBodyForC.java
index 3502605..f566a5a 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBodyForC.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBodyForC.java
@@ -6,32 +6,29 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
+import java.util.List;
import org.apache.rocketmq.common.message.MessageQueueForC;
import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-import java.util.List;
-
public class ResetOffsetBodyForC extends RemotingSerializable {
private List<MessageQueueForC> offsetTable;
-
public List<MessageQueueForC> getOffsetTable() {
return offsetTable;
}
-
public void setOffsetTable(List<MessageQueueForC> offsetTable) {
this.offsetTable = offsetTable;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/SubscriptionGroupWrapper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/SubscriptionGroupWrapper.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/SubscriptionGroupWrapper.java
index 88b863e..bc6a326 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/SubscriptionGroupWrapper.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/SubscriptionGroupWrapper.java
@@ -6,46 +6,40 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.rocketmq.common.DataVersion;
import org.apache.rocketmq.common.subscription.SubscriptionGroupConfig;
import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-import java.util.concurrent.ConcurrentHashMap;
-
-
public class SubscriptionGroupWrapper extends RemotingSerializable {
private ConcurrentHashMap<String, SubscriptionGroupConfig> subscriptionGroupTable =
- new ConcurrentHashMap<String, SubscriptionGroupConfig>(1024);
+ new ConcurrentHashMap<String, SubscriptionGroupConfig>(1024);
private DataVersion dataVersion = new DataVersion();
-
public ConcurrentHashMap<String, SubscriptionGroupConfig> getSubscriptionGroupTable() {
return subscriptionGroupTable;
}
-
public void setSubscriptionGroupTable(
- ConcurrentHashMap<String, SubscriptionGroupConfig> subscriptionGroupTable) {
+ ConcurrentHashMap<String, SubscriptionGroupConfig> subscriptionGroupTable) {
this.subscriptionGroupTable = subscriptionGroupTable;
}
-
public DataVersion getDataVersion() {
return dataVersion;
}
-
public void setDataVersion(DataVersion dataVersion) {
this.dataVersion = dataVersion;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicConfigSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicConfigSerializeWrapper.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicConfigSerializeWrapper.java
index f91caa6..bc4df0c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicConfigSerializeWrapper.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicConfigSerializeWrapper.java
@@ -6,45 +6,39 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.rocketmq.common.DataVersion;
import org.apache.rocketmq.common.TopicConfig;
import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-import java.util.concurrent.ConcurrentHashMap;
-
-
public class TopicConfigSerializeWrapper extends RemotingSerializable {
private ConcurrentHashMap<String, TopicConfig> topicConfigTable =
- new ConcurrentHashMap<String, TopicConfig>();
+ new ConcurrentHashMap<String, TopicConfig>();
private DataVersion dataVersion = new DataVersion();
-
public ConcurrentHashMap<String, TopicConfig> getTopicConfigTable() {
return topicConfigTable;
}
-
public void setTopicConfigTable(ConcurrentHashMap<String, TopicConfig> topicConfigTable) {
this.topicConfigTable = topicConfigTable;
}
-
public DataVersion getDataVersion() {
return dataVersion;
}
-
public void setDataVersion(DataVersion dataVersion) {
this.dataVersion = dataVersion;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java
index 4be52ee..80ebb85 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java
@@ -6,42 +6,36 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.HashSet;
import java.util.Set;
-
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
public class TopicList extends RemotingSerializable {
private Set<String> topicList = new HashSet<String>();
private String brokerAddr;
-
public Set<String> getTopicList() {
return topicList;
}
-
public void setTopicList(Set<String> topicList) {
this.topicList = topicList;
}
-
public String getBrokerAddr() {
return brokerAddr;
}
-
public void setBrokerAddr(String brokerAddr) {
this.brokerAddr = brokerAddr;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java
index 8142b12..741c473 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java
@@ -6,55 +6,47 @@
* (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
+ * 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.
+ * 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.common.protocol.body;
-import org.apache.rocketmq.common.message.MessageQueue;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.HashSet;
import java.util.Set;
-
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
public class UnlockBatchRequestBody extends RemotingSerializable {
private String consumerGroup;
private String clientId;
private Set<MessageQueue> mqSet = new HashSet<MessageQueue>();
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public String getClientId() {
return clientId;
}
-
public void setClientId(String clientId) {
this.clientId = clientId;
}
-
public Set<MessageQueue> getMqSet() {
return mqSet;
}
-
public void setMqSet(Set<MessageQueue> mqSet) {
this.mqSet = mqSet;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
index 5b6e67f..eb08c19 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: EndTransactionRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,7 +26,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class CheckTransactionStateRequestHeader implements CommandCustomHeader {
@CFNotNull
private Long tranStateTableOffset;
@@ -33,27 +34,22 @@ public class CheckTransactionStateRequestHeader implements CommandCustomHeader {
private String msgId;
private String transactionId;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public Long getTranStateTableOffset() {
return tranStateTableOffset;
}
-
public void setTranStateTableOffset(Long tranStateTableOffset) {
this.tranStateTableOffset = tranStateTableOffset;
}
-
public Long getCommitLogOffset() {
return commitLogOffset;
}
-
public void setCommitLogOffset(Long commitLogOffset) {
this.commitLogOffset = commitLogOffset;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
index 805e3ac..7ad665f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: EndTransactionResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -25,7 +27,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class CheckTransactionStateResponseHeader implements CommandCustomHeader {
@CFNotNull
private String producerGroup;
@@ -36,7 +37,6 @@ public class CheckTransactionStateResponseHeader implements CommandCustomHeader
@CFNotNull
private Integer commitOrRollback; // TRANSACTION_COMMIT_TYPE
-
// TRANSACTION_ROLLBACK_TYPE
@Override
@@ -52,42 +52,34 @@ public class CheckTransactionStateResponseHeader implements CommandCustomHeader
throw new RemotingCommandException("commitOrRollback field wrong");
}
-
public String getProducerGroup() {
return producerGroup;
}
-
public void setProducerGroup(String producerGroup) {
this.producerGroup = producerGroup;
}
-
public Long getTranStateTableOffset() {
return tranStateTableOffset;
}
-
public void setTranStateTableOffset(Long tranStateTableOffset) {
this.tranStateTableOffset = tranStateTableOffset;
}
-
public Long getCommitLogOffset() {
return commitLogOffset;
}
-
public void setCommitLogOffset(Long commitLogOffset) {
this.commitLogOffset = commitLogOffset;
}
-
public Integer getCommitOrRollback() {
return commitOrRollback;
}
-
public void setCommitOrRollback(Integer commitOrRollback) {
this.commitOrRollback = commitOrRollback;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
index 1752b88..46c183e 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: DeleteTopicRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,7 +26,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class CloneGroupOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
private String srcGroup;
@@ -33,48 +34,39 @@ public class CloneGroupOffsetRequestHeader implements CommandCustomHeader {
private String topic;
private boolean offline;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getDestGroup() {
return destGroup;
}
-
public void setDestGroup(String destGroup) {
this.destGroup = destGroup;
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public String getSrcGroup() {
return srcGroup;
}
-
public void setSrcGroup(String srcGroup) {
this.srcGroup = srcGroup;
}
-
public boolean isOffline() {
return offline;
}
-
public void setOffline(boolean offline) {
this.offline = offline;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumeMessageDirectlyResultRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumeMessageDirectlyResultRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumeMessageDirectlyResultRequestHeader.java
index aea3092..917d69f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumeMessageDirectlyResultRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumeMessageDirectlyResultRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header;
@@ -22,7 +22,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.annotation.CFNullable;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class ConsumeMessageDirectlyResultRequestHeader implements CommandCustomHeader {
@CFNotNull
private String consumerGroup;
@@ -33,47 +32,38 @@ public class ConsumeMessageDirectlyResultRequestHeader implements CommandCustomH
@CFNullable
private String brokerName;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public String getBrokerName() {
return brokerName;
}
-
public void setBrokerName(String brokerName) {
this.brokerName = brokerName;
}
-
public String getClientId() {
return clientId;
}
-
public void setClientId(String clientId) {
this.clientId = clientId;
}
-
public String getMsgId() {
return msgId;
}
-
public void setMsgId(String msgId) {
this.msgId = msgId;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java
index d108f02..ffde8f7 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header;
@@ -22,7 +22,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.annotation.CFNullable;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
/**
*
*/
@@ -39,86 +38,70 @@ public class ConsumerSendMsgBackRequestHeader implements CommandCustomHeader {
private boolean unitMode = false;
private Integer maxReconsumeTimes;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public Long getOffset() {
return offset;
}
-
public void setOffset(Long offset) {
this.offset = offset;
}
-
public String getGroup() {
return group;
}
-
public void setGroup(String group) {
this.group = group;
}
-
public Integer getDelayLevel() {
return delayLevel;
}
-
public void setDelayLevel(Integer delayLevel) {
this.delayLevel = delayLevel;
}
-
public String getOriginMsgId() {
return originMsgId;
}
-
public void setOriginMsgId(String originMsgId) {
this.originMsgId = originMsgId;
}
-
public String getOriginTopic() {
return originTopic;
}
-
public void setOriginTopic(String originTopic) {
this.originTopic = originTopic;
}
-
public boolean isUnitMode() {
return unitMode;
}
-
public void setUnitMode(boolean unitMode) {
this.unitMode = unitMode;
}
-
public Integer getMaxReconsumeTimes() {
return maxReconsumeTimes;
}
-
public void setMaxReconsumeTimes(final Integer maxReconsumeTimes) {
this.maxReconsumeTimes = maxReconsumeTimes;
}
-
@Override
public String toString() {
return "ConsumerSendMsgBackRequestHeader [group=" + group + ", originTopic=" + originTopic + ", originMsgId=" + originMsgId
- + ", delayLevel=" + delayLevel + ", unitMode=" + unitMode + ", maxReconsumeTimes=" + maxReconsumeTimes + "]";
+ + ", delayLevel=" + delayLevel + ", unitMode=" + unitMode + ", maxReconsumeTimes=" + maxReconsumeTimes + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
index fff2b99..609d46d 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: CreateTopicRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -25,7 +27,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class CreateTopicRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
@@ -43,7 +44,6 @@ public class CreateTopicRequestHeader implements CommandCustomHeader {
@CFNotNull
private Boolean order = false;
-
@Override
public void checkFields() throws RemotingCommandException {
try {
@@ -53,87 +53,70 @@ public class CreateTopicRequestHeader implements CommandCustomHeader {
}
}
-
public TopicFilterType getTopicFilterTypeEnum() {
return TopicFilterType.valueOf(this.topicFilterType);
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public String getDefaultTopic() {
return defaultTopic;
}
-
public void setDefaultTopic(String defaultTopic) {
this.defaultTopic = defaultTopic;
}
-
public Integer getReadQueueNums() {
return readQueueNums;
}
-
public void setReadQueueNums(Integer readQueueNums) {
this.readQueueNums = readQueueNums;
}
-
public Integer getWriteQueueNums() {
return writeQueueNums;
}
-
public void setWriteQueueNums(Integer writeQueueNums) {
this.writeQueueNums = writeQueueNums;
}
-
public Integer getPerm() {
return perm;
}
-
public void setPerm(Integer perm) {
this.perm = perm;
}
-
public String getTopicFilterType() {
return topicFilterType;
}
-
public void setTopicFilterType(String topicFilterType) {
this.topicFilterType = topicFilterType;
}
-
public Integer getTopicSysFlag() {
return topicSysFlag;
}
-
public void setTopicSysFlag(Integer topicSysFlag) {
this.topicSysFlag = topicSysFlag;
}
-
public Boolean getOrder() {
return order;
}
-
public void setOrder(Boolean order) {
this.order = order;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java
index cdb4358..a9f6aa3 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header;
@@ -21,22 +21,18 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class DeleteSubscriptionGroupRequestHeader implements CommandCustomHeader {
@CFNotNull
private String groupName;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getGroupName() {
return groupName;
}
-
public void setGroupName(String groupName) {
this.groupName = groupName;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
index 93e2dd4..73d6556 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: DeleteTopicRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,22 +26,18 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class DeleteTopicRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
index 2d93e62..e21016a 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: EndTransactionRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -26,7 +28,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.annotation.CFNullable;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class EndTransactionRequestHeader implements CommandCustomHeader {
@CFNotNull
private String producerGroup;
@@ -64,62 +65,50 @@ public class EndTransactionRequestHeader implements CommandCustomHeader {
throw new RemotingCommandException("commitOrRollback field wrong");
}
-
public String getProducerGroup() {
return producerGroup;
}
-
public void setProducerGroup(String producerGroup) {
this.producerGroup = producerGroup;
}
-
public Long getTranStateTableOffset() {
return tranStateTableOffset;
}
-
public void setTranStateTableOffset(Long tranStateTableOffset) {
this.tranStateTableOffset = tranStateTableOffset;
}
-
public Long getCommitLogOffset() {
return commitLogOffset;
}
-
public void setCommitLogOffset(Long commitLogOffset) {
this.commitLogOffset = commitLogOffset;
}
-
public Integer getCommitOrRollback() {
return commitOrRollback;
}
-
public void setCommitOrRollback(Integer commitOrRollback) {
this.commitOrRollback = commitOrRollback;
}
-
public Boolean getFromTransactionCheck() {
return fromTransactionCheck;
}
-
public void setFromTransactionCheck(Boolean fromTransactionCheck) {
this.fromTransactionCheck = fromTransactionCheck;
}
-
public String getMsgId() {
return msgId;
}
-
public void setMsgId(String msgId) {
this.msgId = msgId;
}
@@ -135,8 +124,8 @@ public class EndTransactionRequestHeader implements CommandCustomHeader {
@Override
public String toString() {
return "EndTransactionRequestHeader [producerGroup=" + producerGroup + ", tranStateTableOffset="
- + tranStateTableOffset + ", commitLogOffset=" + commitLogOffset + ", commitOrRollback="
- + commitOrRollback + ", fromTransactionCheck=" + fromTransactionCheck + ", msgId=" + msgId
- + "]";
+ + tranStateTableOffset + ", commitLogOffset=" + commitLogOffset + ", commitOrRollback="
+ + commitOrRollback + ", fromTransactionCheck=" + fromTransactionCheck + ", msgId=" + msgId
+ + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
index 85ad2e4..377a73c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: EndTransactionResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -23,7 +25,6 @@ package org.apache.rocketmq.common.protocol.header;
import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class EndTransactionResponseHeader implements CommandCustomHeader {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
index 96030e5..c8de641 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: GetAllTopicConfigResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -23,7 +25,6 @@ package org.apache.rocketmq.common.protocol.header;
import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class GetAllTopicConfigResponseHeader implements CommandCustomHeader {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
index d15b1e9..a6b6bc0 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: GetBrokerConfigResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,22 +26,18 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class GetBrokerConfigResponseHeader implements CommandCustomHeader {
@CFNotNull
private String version;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getVersion() {
return version;
}
-
public void setVersion(String version) {
this.version = version;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsInBrokerHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsInBrokerHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsInBrokerHeader.java
index b17a558..cc2c2da 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsInBrokerHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsInBrokerHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header;
@@ -21,7 +21,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class GetConsumeStatsInBrokerHeader implements CommandCustomHeader {
@CFNotNull
private boolean isOrder;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
index 25d8041..43bd8a7 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header;
@@ -20,35 +20,29 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class GetConsumeStatsRequestHeader implements CommandCustomHeader {
@CFNotNull
private String consumerGroup;
private String topic;
-
@Override
public void checkFields() throws RemotingCommandException {
// TODO Auto-generated method stub
}
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
index a31b8ab..8f12c79 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header;
@@ -21,7 +21,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
/**
*
*
@@ -30,19 +29,16 @@ public class GetConsumerConnectionListRequestHeader implements CommandCustomHead
@CFNotNull
private String consumerGroup;
-
@Override
public void checkFields() throws RemotingCommandException {
// To change body of implemented methods use File | Settings | File
// Templates.
}
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java
index 0a7e4e4..ecd224d 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header;
@@ -21,22 +21,18 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class GetConsumerListByGroupRequestHeader implements CommandCustomHeader {
@CFNotNull
private String consumerGroup;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java
index 0934831..23e24a8 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java
@@ -6,31 +6,27 @@
* (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
+ * 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.
+ * 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.common.protocol.header;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.List;
-
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
public class GetConsumerListByGroupResponseBody extends RemotingSerializable {
private List<String> consumerIdList;
-
public List<String> getConsumerIdList() {
return consumerIdList;
}
-
public void setConsumerIdList(List<String> consumerIdList) {
this.consumerIdList = consumerIdList;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java
index 7e2a174..5d90e89 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header;
@@ -20,7 +20,6 @@ package org.apache.rocketmq.common.protocol.header;
import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class GetConsumerListByGroupResponseHeader implements CommandCustomHeader {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java
index e44a5ac..f1144e9 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header;
@@ -22,7 +22,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.annotation.CFNullable;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class GetConsumerRunningInfoRequestHeader implements CommandCustomHeader {
@CFNotNull
private String consumerGroup;
@@ -31,37 +30,30 @@ public class GetConsumerRunningInfoRequestHeader implements CommandCustomHeader
@CFNullable
private boolean jstackEnable;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public String getClientId() {
return clientId;
}
-
public void setClientId(String clientId) {
this.clientId = clientId;
}
-
public boolean isJstackEnable() {
return jstackEnable;
}
-
public void setJstackEnable(boolean jstackEnable) {
this.jstackEnable = jstackEnable;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java
index b577ac8..954df8f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header;
@@ -22,7 +22,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.annotation.CFNullable;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
/**
*
*/
@@ -34,38 +33,31 @@ public class GetConsumerStatusRequestHeader implements CommandCustomHeader {
@CFNullable
private String clientAddr;
-
@Override
public void checkFields() throws RemotingCommandException {
// TODO Auto-generated method stub
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public String getGroup() {
return group;
}
-
public void setGroup(String group) {
this.group = group;
}
-
public String getClientAddr() {
return clientAddr;
}
-
public void setClientAddr(String clientAddr) {
this.clientAddr = clientAddr;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
index 9d5b75d..a99bbc6 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: GetEarliestMsgStoretimeRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,35 +26,29 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class GetEarliestMsgStoretimeRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
@CFNotNull
private Integer queueId;
-
@Override
public void checkFields() throws RemotingCommandException {
// TODO Auto-generated method stub
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public Integer getQueueId() {
return queueId;
}
-
public void setQueueId(Integer queueId) {
this.queueId = queueId;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
index 658388a..d074a91 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: GetEarliestMsgStoretimeResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,22 +26,18 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class GetEarliestMsgStoretimeResponseHeader implements CommandCustomHeader {
@CFNotNull
private Long timestamp;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public Long getTimestamp() {
return timestamp;
}
-
public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
index 6d33dcb..714d1b5 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: GetMaxOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,34 +26,28 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class GetMaxOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
@CFNotNull
private Integer queueId;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public Integer getQueueId() {
return queueId;
}
-
public void setQueueId(Integer queueId) {
this.queueId = queueId;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
index 0143ef8..e89ef21 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: GetMaxOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,22 +26,18 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class GetMaxOffsetResponseHeader implements CommandCustomHeader {
@CFNotNull
private Long offset;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public Long getOffset() {
return offset;
}
-
public void setOffset(Long offset) {
this.offset = offset;
}
[09/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java
new file mode 100644
index 0000000..09b090b
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java
@@ -0,0 +1,40 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.HashMap;
+
+
+/**
+ * @author shijia.wxr
+ *
+ */
+public class KVTable extends RemotingSerializable {
+ private HashMap<String, String> table = new HashMap<String, String>();
+
+
+ public HashMap<String, String> getTable() {
+ return table;
+ }
+
+
+ public void setTable(HashMap<String, String> table) {
+ this.table = table;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java
new file mode 100644
index 0000000..87e4d6a
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java
@@ -0,0 +1,65 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.HashSet;
+import java.util.Set;
+
+
+/**
+ * @author shijia.wxr
+ *
+ */
+public class LockBatchRequestBody extends RemotingSerializable {
+ private String consumerGroup;
+ private String clientId;
+ private Set<MessageQueue> mqSet = new HashSet<MessageQueue>();
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+
+ public String getClientId() {
+ return clientId;
+ }
+
+
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
+
+ public Set<MessageQueue> getMqSet() {
+ return mqSet;
+ }
+
+
+ public void setMqSet(Set<MessageQueue> mqSet) {
+ this.mqSet = mqSet;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java
new file mode 100644
index 0000000..04a5106
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java
@@ -0,0 +1,45 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.HashSet;
+import java.util.Set;
+
+
+/**
+ * @author shijia.wxr
+ *
+ */
+public class LockBatchResponseBody extends RemotingSerializable {
+
+ private Set<MessageQueue> lockOKMQSet = new HashSet<MessageQueue>();
+
+
+ public Set<MessageQueue> getLockOKMQSet() {
+ return lockOKMQSet;
+ }
+
+
+ public void setLockOKMQSet(Set<MessageQueue> lockOKMQSet) {
+ this.lockOKMQSet = lockOKMQSet;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProcessQueueInfo.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProcessQueueInfo.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProcessQueueInfo.java
new file mode 100644
index 0000000..0ceaa69
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProcessQueueInfo.java
@@ -0,0 +1,185 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.common.UtilAll;
+
+
+public class ProcessQueueInfo {
+ private long commitOffset;
+
+ private long cachedMsgMinOffset;
+ private long cachedMsgMaxOffset;
+ private int cachedMsgCount;
+
+ private long transactionMsgMinOffset;
+ private long transactionMsgMaxOffset;
+ private int transactionMsgCount;
+
+ private boolean locked;
+ private long tryUnlockTimes;
+ private long lastLockTimestamp;
+
+ private boolean droped;
+ private long lastPullTimestamp;
+ private long lastConsumeTimestamp;
+
+
+ public long getCommitOffset() {
+ return commitOffset;
+ }
+
+
+ public void setCommitOffset(long commitOffset) {
+ this.commitOffset = commitOffset;
+ }
+
+
+ public long getCachedMsgMinOffset() {
+ return cachedMsgMinOffset;
+ }
+
+
+ public void setCachedMsgMinOffset(long cachedMsgMinOffset) {
+ this.cachedMsgMinOffset = cachedMsgMinOffset;
+ }
+
+
+ public long getCachedMsgMaxOffset() {
+ return cachedMsgMaxOffset;
+ }
+
+
+ public void setCachedMsgMaxOffset(long cachedMsgMaxOffset) {
+ this.cachedMsgMaxOffset = cachedMsgMaxOffset;
+ }
+
+
+ public int getCachedMsgCount() {
+ return cachedMsgCount;
+ }
+
+
+ public void setCachedMsgCount(int cachedMsgCount) {
+ this.cachedMsgCount = cachedMsgCount;
+ }
+
+
+ public long getTransactionMsgMinOffset() {
+ return transactionMsgMinOffset;
+ }
+
+
+ public void setTransactionMsgMinOffset(long transactionMsgMinOffset) {
+ this.transactionMsgMinOffset = transactionMsgMinOffset;
+ }
+
+
+ public long getTransactionMsgMaxOffset() {
+ return transactionMsgMaxOffset;
+ }
+
+
+ public void setTransactionMsgMaxOffset(long transactionMsgMaxOffset) {
+ this.transactionMsgMaxOffset = transactionMsgMaxOffset;
+ }
+
+
+ public int getTransactionMsgCount() {
+ return transactionMsgCount;
+ }
+
+
+ public void setTransactionMsgCount(int transactionMsgCount) {
+ this.transactionMsgCount = transactionMsgCount;
+ }
+
+
+ public boolean isLocked() {
+ return locked;
+ }
+
+
+ public void setLocked(boolean locked) {
+ this.locked = locked;
+ }
+
+
+ public long getTryUnlockTimes() {
+ return tryUnlockTimes;
+ }
+
+
+ public void setTryUnlockTimes(long tryUnlockTimes) {
+ this.tryUnlockTimes = tryUnlockTimes;
+ }
+
+
+ public long getLastLockTimestamp() {
+ return lastLockTimestamp;
+ }
+
+
+ public void setLastLockTimestamp(long lastLockTimestamp) {
+ this.lastLockTimestamp = lastLockTimestamp;
+ }
+
+
+ public boolean isDroped() {
+ return droped;
+ }
+
+
+ public void setDroped(boolean droped) {
+ this.droped = droped;
+ }
+
+
+ public long getLastPullTimestamp() {
+ return lastPullTimestamp;
+ }
+
+
+ public void setLastPullTimestamp(long lastPullTimestamp) {
+ this.lastPullTimestamp = lastPullTimestamp;
+ }
+
+
+ public long getLastConsumeTimestamp() {
+ return lastConsumeTimestamp;
+ }
+
+
+ public void setLastConsumeTimestamp(long lastConsumeTimestamp) {
+ this.lastConsumeTimestamp = lastConsumeTimestamp;
+ }
+
+
+ @Override
+ public String toString() {
+ return "ProcessQueueInfo [commitOffset=" + commitOffset + ", cachedMsgMinOffset="
+ + cachedMsgMinOffset + ", cachedMsgMaxOffset=" + cachedMsgMaxOffset + ", cachedMsgCount="
+ + cachedMsgCount + ", transactionMsgMinOffset=" + transactionMsgMinOffset
+ + ", transactionMsgMaxOffset=" + transactionMsgMaxOffset + ", transactionMsgCount="
+ + transactionMsgCount + ", locked=" + locked + ", tryUnlockTimes=" + tryUnlockTimes
+ + ", lastLockTimestamp=" + UtilAll.timeMillisToHumanString(lastLockTimestamp) + ", droped="
+ + droped + ", lastPullTimestamp=" + UtilAll.timeMillisToHumanString(lastPullTimestamp)
+ + ", lastConsumeTimestamp=" + UtilAll.timeMillisToHumanString(lastConsumeTimestamp) + "]";
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java
new file mode 100644
index 0000000..3d036fc
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java
@@ -0,0 +1,40 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.HashSet;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ProducerConnection extends RemotingSerializable {
+ private HashSet<Connection> connectionSet = new HashSet<Connection>();
+
+
+ public HashSet<Connection> getConnectionSet() {
+ return connectionSet;
+ }
+
+
+ public void setConnectionSet(HashSet<Connection> connectionSet) {
+ this.connectionSet = connectionSet;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java
new file mode 100644
index 0000000..98279c8
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java
@@ -0,0 +1,41 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @author manhong.yqd
+ */
+public class QueryConsumeTimeSpanBody extends RemotingSerializable {
+ List<QueueTimeSpan> consumeTimeSpanSet = new ArrayList<QueueTimeSpan>();
+
+
+ public List<QueueTimeSpan> getConsumeTimeSpanSet() {
+ return consumeTimeSpanSet;
+ }
+
+
+ public void setConsumeTimeSpanSet(List<QueueTimeSpan> consumeTimeSpanSet) {
+ this.consumeTimeSpanSet = consumeTimeSpanSet;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java
new file mode 100644
index 0000000..efe491d
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java
@@ -0,0 +1,40 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * @author manhong.yqd
+ */
+public class QueryCorrectionOffsetBody extends RemotingSerializable {
+ private Map<Integer, Long> correctionOffsets = new HashMap<Integer, Long>();
+
+
+ public Map<Integer, Long> getCorrectionOffsets() {
+ return correctionOffsets;
+ }
+
+
+ public void setCorrectionOffsets(Map<Integer, Long> correctionOffsets) {
+ this.correctionOffsets = correctionOffsets;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueueTimeSpan.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueueTimeSpan.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueueTimeSpan.java
new file mode 100644
index 0000000..c959c59
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueueTimeSpan.java
@@ -0,0 +1,100 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.message.MessageQueue;
+
+import java.util.Date;
+
+
+/**
+ * @author manhong.yqd
+ */
+public class QueueTimeSpan {
+ private MessageQueue messageQueue;
+ private long minTimeStamp;
+ private long maxTimeStamp;
+ private long consumeTimeStamp;
+ private long delayTime;
+
+
+ public MessageQueue getMessageQueue() {
+ return messageQueue;
+ }
+
+
+ public void setMessageQueue(MessageQueue messageQueue) {
+ this.messageQueue = messageQueue;
+ }
+
+
+ public long getMinTimeStamp() {
+ return minTimeStamp;
+ }
+
+
+ public void setMinTimeStamp(long minTimeStamp) {
+ this.minTimeStamp = minTimeStamp;
+ }
+
+
+ public long getMaxTimeStamp() {
+ return maxTimeStamp;
+ }
+
+
+ public void setMaxTimeStamp(long maxTimeStamp) {
+ this.maxTimeStamp = maxTimeStamp;
+ }
+
+
+ public long getConsumeTimeStamp() {
+ return consumeTimeStamp;
+ }
+
+
+ public void setConsumeTimeStamp(long consumeTimeStamp) {
+ this.consumeTimeStamp = consumeTimeStamp;
+ }
+
+
+ public String getMinTimeStampStr() {
+ return UtilAll.formatDate(new Date(minTimeStamp), UtilAll.YYYY_MM_DD_HH_MM_SS_SSS);
+ }
+
+
+ public String getMaxTimeStampStr() {
+ return UtilAll.formatDate(new Date(maxTimeStamp), UtilAll.YYYY_MM_DD_HH_MM_SS_SSS);
+ }
+
+
+ public String getConsumeTimeStampStr() {
+ return UtilAll.formatDate(new Date(consumeTimeStamp), UtilAll.YYYY_MM_DD_HH_MM_SS_SSS);
+ }
+
+
+ public long getDelayTime() {
+ return delayTime;
+ }
+
+
+ public void setDelayTime(long delayTime) {
+ this.delayTime = delayTime;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/RegisterBrokerBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/RegisterBrokerBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/RegisterBrokerBody.java
new file mode 100644
index 0000000..45a4a29
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/RegisterBrokerBody.java
@@ -0,0 +1,49 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class RegisterBrokerBody extends RemotingSerializable {
+ private TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper();
+ private List<String> filterServerList = new ArrayList<String>();
+
+
+ public TopicConfigSerializeWrapper getTopicConfigSerializeWrapper() {
+ return topicConfigSerializeWrapper;
+ }
+
+
+ public void setTopicConfigSerializeWrapper(TopicConfigSerializeWrapper topicConfigSerializeWrapper) {
+ this.topicConfigSerializeWrapper = topicConfigSerializeWrapper;
+ }
+
+
+ public List<String> getFilterServerList() {
+ return filterServerList;
+ }
+
+
+ public void setFilterServerList(List<String> filterServerList) {
+ this.filterServerList = filterServerList;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBody.java
new file mode 100644
index 0000000..c311436
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBody.java
@@ -0,0 +1,42 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.Map;
+
+
+/**
+ * @author manhong.yqd
+ *
+ */
+public class ResetOffsetBody extends RemotingSerializable {
+ private Map<MessageQueue, Long> offsetTable;
+
+
+ public Map<MessageQueue, Long> getOffsetTable() {
+ return offsetTable;
+ }
+
+
+ public void setOffsetTable(Map<MessageQueue, Long> offsetTable) {
+ this.offsetTable = offsetTable;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBodyForC.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBodyForC.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBodyForC.java
new file mode 100644
index 0000000..3502605
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBodyForC.java
@@ -0,0 +1,38 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.common.message.MessageQueueForC;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.List;
+
+public class ResetOffsetBodyForC extends RemotingSerializable {
+
+ private List<MessageQueueForC> offsetTable;
+
+
+ public List<MessageQueueForC> getOffsetTable() {
+ return offsetTable;
+ }
+
+
+ public void setOffsetTable(List<MessageQueueForC> offsetTable) {
+ this.offsetTable = offsetTable;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/SubscriptionGroupWrapper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/SubscriptionGroupWrapper.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/SubscriptionGroupWrapper.java
new file mode 100644
index 0000000..ba63926
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/SubscriptionGroupWrapper.java
@@ -0,0 +1,55 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.common.DataVersion;
+import org.apache.rocketmq.common.subscription.SubscriptionGroupConfig;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * @author manhong.yqd
+ */
+public class SubscriptionGroupWrapper extends RemotingSerializable {
+ private ConcurrentHashMap<String, SubscriptionGroupConfig> subscriptionGroupTable =
+ new ConcurrentHashMap<String, SubscriptionGroupConfig>(1024);
+ private DataVersion dataVersion = new DataVersion();
+
+
+ public ConcurrentHashMap<String, SubscriptionGroupConfig> getSubscriptionGroupTable() {
+ return subscriptionGroupTable;
+ }
+
+
+ public void setSubscriptionGroupTable(
+ ConcurrentHashMap<String, SubscriptionGroupConfig> subscriptionGroupTable) {
+ this.subscriptionGroupTable = subscriptionGroupTable;
+ }
+
+
+ public DataVersion getDataVersion() {
+ return dataVersion;
+ }
+
+
+ public void setDataVersion(DataVersion dataVersion) {
+ this.dataVersion = dataVersion;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicConfigSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicConfigSerializeWrapper.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicConfigSerializeWrapper.java
new file mode 100644
index 0000000..f91caa6
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicConfigSerializeWrapper.java
@@ -0,0 +1,51 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.common.DataVersion;
+import org.apache.rocketmq.common.TopicConfig;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+
+public class TopicConfigSerializeWrapper extends RemotingSerializable {
+ private ConcurrentHashMap<String, TopicConfig> topicConfigTable =
+ new ConcurrentHashMap<String, TopicConfig>();
+ private DataVersion dataVersion = new DataVersion();
+
+
+ public ConcurrentHashMap<String, TopicConfig> getTopicConfigTable() {
+ return topicConfigTable;
+ }
+
+
+ public void setTopicConfigTable(ConcurrentHashMap<String, TopicConfig> topicConfigTable) {
+ this.topicConfigTable = topicConfigTable;
+ }
+
+
+ public DataVersion getDataVersion() {
+ return dataVersion;
+ }
+
+
+ public void setDataVersion(DataVersion dataVersion) {
+ this.dataVersion = dataVersion;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java
new file mode 100644
index 0000000..7cc7b30
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicList.java
@@ -0,0 +1,51 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.HashSet;
+import java.util.Set;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class TopicList extends RemotingSerializable {
+ private Set<String> topicList = new HashSet<String>();
+ private String brokerAddr;
+
+
+ public Set<String> getTopicList() {
+ return topicList;
+ }
+
+
+ public void setTopicList(Set<String> topicList) {
+ this.topicList = topicList;
+ }
+
+
+ public String getBrokerAddr() {
+ return brokerAddr;
+ }
+
+
+ public void setBrokerAddr(String brokerAddr) {
+ this.brokerAddr = brokerAddr;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java
new file mode 100644
index 0000000..66e902c
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/UnlockBatchRequestBody.java
@@ -0,0 +1,64 @@
+/**
+ * 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.common.protocol.body;
+
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.HashSet;
+import java.util.Set;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class UnlockBatchRequestBody extends RemotingSerializable {
+ private String consumerGroup;
+ private String clientId;
+ private Set<MessageQueue> mqSet = new HashSet<MessageQueue>();
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+
+ public String getClientId() {
+ return clientId;
+ }
+
+
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
+
+ public Set<MessageQueue> getMqSet() {
+ return mqSet;
+ }
+
+
+ public void setMqSet(Set<MessageQueue> mqSet) {
+ this.mqSet = mqSet;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
new file mode 100644
index 0000000..5a7da65
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
@@ -0,0 +1,79 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: EndTransactionRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class CheckTransactionStateRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private Long tranStateTableOffset;
+ @CFNotNull
+ private Long commitLogOffset;
+ private String msgId;
+ private String transactionId;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public Long getTranStateTableOffset() {
+ return tranStateTableOffset;
+ }
+
+
+ public void setTranStateTableOffset(Long tranStateTableOffset) {
+ this.tranStateTableOffset = tranStateTableOffset;
+ }
+
+
+ public Long getCommitLogOffset() {
+ return commitLogOffset;
+ }
+
+
+ public void setCommitLogOffset(Long commitLogOffset) {
+ this.commitLogOffset = commitLogOffset;
+ }
+
+ public String getMsgId() {
+ return msgId;
+ }
+
+ public void setMsgId(String msgId) {
+ this.msgId = msgId;
+ }
+
+ public String getTransactionId() {
+ return transactionId;
+ }
+
+ public void setTransactionId(String transactionId) {
+ this.transactionId = transactionId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
new file mode 100644
index 0000000..4f8864e
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
@@ -0,0 +1,97 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: EndTransactionResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.common.sysflag.MessageSysFlag;
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class CheckTransactionStateResponseHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String producerGroup;
+ @CFNotNull
+ private Long tranStateTableOffset;
+ @CFNotNull
+ private Long commitLogOffset;
+ @CFNotNull
+ private Integer commitOrRollback; // TRANSACTION_COMMIT_TYPE
+
+
+ // TRANSACTION_ROLLBACK_TYPE
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ if (MessageSysFlag.TRANSACTION_COMMIT_TYPE == this.commitOrRollback) {
+ return;
+ }
+
+ if (MessageSysFlag.TRANSACTION_ROLLBACK_TYPE == this.commitOrRollback) {
+ return;
+ }
+
+ throw new RemotingCommandException("commitOrRollback field wrong");
+ }
+
+
+ public String getProducerGroup() {
+ return producerGroup;
+ }
+
+
+ public void setProducerGroup(String producerGroup) {
+ this.producerGroup = producerGroup;
+ }
+
+
+ public Long getTranStateTableOffset() {
+ return tranStateTableOffset;
+ }
+
+
+ public void setTranStateTableOffset(Long tranStateTableOffset) {
+ this.tranStateTableOffset = tranStateTableOffset;
+ }
+
+
+ public Long getCommitLogOffset() {
+ return commitLogOffset;
+ }
+
+
+ public void setCommitLogOffset(Long commitLogOffset) {
+ this.commitLogOffset = commitLogOffset;
+ }
+
+
+ public Integer getCommitOrRollback() {
+ return commitOrRollback;
+ }
+
+
+ public void setCommitOrRollback(Integer commitOrRollback) {
+ this.commitOrRollback = commitOrRollback;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
new file mode 100644
index 0000000..50722f3
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
@@ -0,0 +1,84 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: DeleteTopicRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author manhong.yqd
+ */
+public class CloneGroupOffsetRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String srcGroup;
+ @CFNotNull
+ private String destGroup;
+ private String topic;
+ private boolean offline;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getDestGroup() {
+ return destGroup;
+ }
+
+
+ public void setDestGroup(String destGroup) {
+ this.destGroup = destGroup;
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public String getSrcGroup() {
+
+ return srcGroup;
+ }
+
+
+ public void setSrcGroup(String srcGroup) {
+ this.srcGroup = srcGroup;
+ }
+
+
+ public boolean isOffline() {
+ return offline;
+ }
+
+
+ public void setOffline(boolean offline) {
+ this.offline = offline;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumeMessageDirectlyResultRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumeMessageDirectlyResultRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumeMessageDirectlyResultRequestHeader.java
new file mode 100644
index 0000000..aea3092
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumeMessageDirectlyResultRequestHeader.java
@@ -0,0 +1,80 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.annotation.CFNullable;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+public class ConsumeMessageDirectlyResultRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String consumerGroup;
+ @CFNullable
+ private String clientId;
+ @CFNullable
+ private String msgId;
+ @CFNullable
+ private String brokerName;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+
+ public String getBrokerName() {
+ return brokerName;
+ }
+
+
+ public void setBrokerName(String brokerName) {
+ this.brokerName = brokerName;
+ }
+
+
+ public String getClientId() {
+ return clientId;
+ }
+
+
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
+
+ public String getMsgId() {
+ return msgId;
+ }
+
+
+ public void setMsgId(String msgId) {
+ this.msgId = msgId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java
new file mode 100644
index 0000000..64a60b0
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ConsumerSendMsgBackRequestHeader.java
@@ -0,0 +1,125 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.annotation.CFNullable;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ *
+ */
+public class ConsumerSendMsgBackRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private Long offset;
+ @CFNotNull
+ private String group;
+ @CFNotNull
+ private Integer delayLevel;
+ private String originMsgId;
+ private String originTopic;
+ @CFNullable
+ private boolean unitMode = false;
+ private Integer maxReconsumeTimes;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+
+ }
+
+
+ public Long getOffset() {
+ return offset;
+ }
+
+
+ public void setOffset(Long offset) {
+ this.offset = offset;
+ }
+
+
+ public String getGroup() {
+ return group;
+ }
+
+
+ public void setGroup(String group) {
+ this.group = group;
+ }
+
+
+ public Integer getDelayLevel() {
+ return delayLevel;
+ }
+
+
+ public void setDelayLevel(Integer delayLevel) {
+ this.delayLevel = delayLevel;
+ }
+
+
+ public String getOriginMsgId() {
+ return originMsgId;
+ }
+
+
+ public void setOriginMsgId(String originMsgId) {
+ this.originMsgId = originMsgId;
+ }
+
+
+ public String getOriginTopic() {
+ return originTopic;
+ }
+
+
+ public void setOriginTopic(String originTopic) {
+ this.originTopic = originTopic;
+ }
+
+
+ public boolean isUnitMode() {
+ return unitMode;
+ }
+
+
+ public void setUnitMode(boolean unitMode) {
+ this.unitMode = unitMode;
+ }
+
+
+ public Integer getMaxReconsumeTimes() {
+ return maxReconsumeTimes;
+ }
+
+
+ public void setMaxReconsumeTimes(final Integer maxReconsumeTimes) {
+ this.maxReconsumeTimes = maxReconsumeTimes;
+ }
+
+
+ @Override
+ public String toString() {
+ return "ConsumerSendMsgBackRequestHeader [group=" + group + ", originTopic=" + originTopic + ", originMsgId=" + originMsgId
+ + ", delayLevel=" + delayLevel + ", unitMode=" + unitMode + ", maxReconsumeTimes=" + maxReconsumeTimes + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
new file mode 100644
index 0000000..6eb85b0
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
@@ -0,0 +1,143 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: CreateTopicRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.common.TopicFilterType;
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class CreateTopicRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String topic;
+ @CFNotNull
+ private String defaultTopic;
+ @CFNotNull
+ private Integer readQueueNums;
+ @CFNotNull
+ private Integer writeQueueNums;
+ @CFNotNull
+ private Integer perm;
+ @CFNotNull
+ private String topicFilterType;
+ private Integer topicSysFlag;
+ @CFNotNull
+ private Boolean order = false;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ try {
+ TopicFilterType.valueOf(this.topicFilterType);
+ } catch (Exception e) {
+ throw new RemotingCommandException("topicFilterType = [" + topicFilterType + "] value invalid", e);
+ }
+ }
+
+
+ public TopicFilterType getTopicFilterTypeEnum() {
+ return TopicFilterType.valueOf(this.topicFilterType);
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public String getDefaultTopic() {
+ return defaultTopic;
+ }
+
+
+ public void setDefaultTopic(String defaultTopic) {
+ this.defaultTopic = defaultTopic;
+ }
+
+
+ public Integer getReadQueueNums() {
+ return readQueueNums;
+ }
+
+
+ public void setReadQueueNums(Integer readQueueNums) {
+ this.readQueueNums = readQueueNums;
+ }
+
+
+ public Integer getWriteQueueNums() {
+ return writeQueueNums;
+ }
+
+
+ public void setWriteQueueNums(Integer writeQueueNums) {
+ this.writeQueueNums = writeQueueNums;
+ }
+
+
+ public Integer getPerm() {
+ return perm;
+ }
+
+
+ public void setPerm(Integer perm) {
+ this.perm = perm;
+ }
+
+
+ public String getTopicFilterType() {
+ return topicFilterType;
+ }
+
+
+ public void setTopicFilterType(String topicFilterType) {
+ this.topicFilterType = topicFilterType;
+ }
+
+
+ public Integer getTopicSysFlag() {
+ return topicSysFlag;
+ }
+
+
+ public void setTopicSysFlag(Integer topicSysFlag) {
+ this.topicSysFlag = topicSysFlag;
+ }
+
+
+ public Boolean getOrder() {
+ return order;
+ }
+
+
+ public void setOrder(Boolean order) {
+ this.order = order;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java
new file mode 100644
index 0000000..783b37c
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java
@@ -0,0 +1,46 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author manhong.yqd
+ */
+public class DeleteSubscriptionGroupRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String groupName;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getGroupName() {
+ return groupName;
+ }
+
+
+ public void setGroupName(String groupName) {
+ this.groupName = groupName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
new file mode 100644
index 0000000..cc0c324
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
@@ -0,0 +1,49 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: DeleteTopicRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class DeleteTopicRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String topic;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
new file mode 100644
index 0000000..ce9f170
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
@@ -0,0 +1,145 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: EndTransactionRequestHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.common.sysflag.MessageSysFlag;
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.annotation.CFNullable;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class EndTransactionRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String producerGroup;
+ @CFNotNull
+ private Long tranStateTableOffset;
+ @CFNotNull
+ private Long commitLogOffset;
+ @CFNotNull
+ private Integer commitOrRollback; // TRANSACTION_COMMIT_TYPE
+ // TRANSACTION_ROLLBACK_TYPE
+ // TRANSACTION_NOT_TYPE
+
+ @CFNullable
+ private Boolean fromTransactionCheck = false;
+
+ @CFNotNull
+ private String msgId;
+
+ private String transactionId;
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ if (MessageSysFlag.TRANSACTION_NOT_TYPE == this.commitOrRollback) {
+ return;
+ }
+
+ if (MessageSysFlag.TRANSACTION_COMMIT_TYPE == this.commitOrRollback) {
+ return;
+ }
+
+ if (MessageSysFlag.TRANSACTION_ROLLBACK_TYPE == this.commitOrRollback) {
+ return;
+ }
+
+ throw new RemotingCommandException("commitOrRollback field wrong");
+ }
+
+
+ public String getProducerGroup() {
+ return producerGroup;
+ }
+
+
+ public void setProducerGroup(String producerGroup) {
+ this.producerGroup = producerGroup;
+ }
+
+
+ public Long getTranStateTableOffset() {
+ return tranStateTableOffset;
+ }
+
+
+ public void setTranStateTableOffset(Long tranStateTableOffset) {
+ this.tranStateTableOffset = tranStateTableOffset;
+ }
+
+
+ public Long getCommitLogOffset() {
+ return commitLogOffset;
+ }
+
+
+ public void setCommitLogOffset(Long commitLogOffset) {
+ this.commitLogOffset = commitLogOffset;
+ }
+
+
+ public Integer getCommitOrRollback() {
+ return commitOrRollback;
+ }
+
+
+ public void setCommitOrRollback(Integer commitOrRollback) {
+ this.commitOrRollback = commitOrRollback;
+ }
+
+
+ public Boolean getFromTransactionCheck() {
+ return fromTransactionCheck;
+ }
+
+
+ public void setFromTransactionCheck(Boolean fromTransactionCheck) {
+ this.fromTransactionCheck = fromTransactionCheck;
+ }
+
+
+ public String getMsgId() {
+ return msgId;
+ }
+
+
+ public void setMsgId(String msgId) {
+ this.msgId = msgId;
+ }
+
+ public String getTransactionId() {
+ return transactionId;
+ }
+
+ public void setTransactionId(String transactionId) {
+ this.transactionId = transactionId;
+ }
+
+ @Override
+ public String toString() {
+ return "EndTransactionRequestHeader [producerGroup=" + producerGroup + ", tranStateTableOffset="
+ + tranStateTableOffset + ", commitLogOffset=" + commitLogOffset + ", commitOrRollback="
+ + commitOrRollback + ", fromTransactionCheck=" + fromTransactionCheck + ", msgId=" + msgId
+ + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
new file mode 100644
index 0000000..eb28b6a
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
@@ -0,0 +1,37 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: EndTransactionResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class EndTransactionResponseHeader implements CommandCustomHeader {
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
new file mode 100644
index 0000000..4a39a25
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
@@ -0,0 +1,35 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: GetAllTopicConfigResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class GetAllTopicConfigResponseHeader implements CommandCustomHeader {
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
new file mode 100644
index 0000000..67cc8eb
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
@@ -0,0 +1,49 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: GetBrokerConfigResponseHeader.java 1835 2013-05-16 02:00:50Z shijia.wxr $
+ */
+package org.apache.rocketmq.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class GetBrokerConfigResponseHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String version;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getVersion() {
+ return version;
+ }
+
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsInBrokerHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsInBrokerHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsInBrokerHeader.java
new file mode 100644
index 0000000..b17a558
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsInBrokerHeader.java
@@ -0,0 +1,41 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+public class GetConsumeStatsInBrokerHeader implements CommandCustomHeader {
+ @CFNotNull
+ private boolean isOrder;
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+
+ }
+
+ public boolean isOrder() {
+ return isOrder;
+ }
+
+ public void setIsOrder(boolean isOrder) {
+ this.isOrder = isOrder;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
new file mode 100644
index 0000000..2a84db6
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
@@ -0,0 +1,58 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class GetConsumeStatsRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String consumerGroup;
+ private String topic;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
new file mode 100644
index 0000000..e49f775
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerConnectionListRequestHeader.java
@@ -0,0 +1,50 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ *
+ * @author shijia.wxr
+ *
+ */
+public class GetConsumerConnectionListRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String consumerGroup;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ // To change body of implemented methods use File | Settings | File
+ // Templates.
+ }
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java
new file mode 100644
index 0000000..45d3a2c
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupRequestHeader.java
@@ -0,0 +1,46 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class GetConsumerListByGroupRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String consumerGroup;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java
new file mode 100644
index 0000000..6563ed5
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseBody.java
@@ -0,0 +1,40 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class GetConsumerListByGroupResponseBody extends RemotingSerializable {
+ private List<String> consumerIdList;
+
+
+ public List<String> getConsumerIdList() {
+ return consumerIdList;
+ }
+
+
+ public void setConsumerIdList(List<String> consumerIdList) {
+ this.consumerIdList = consumerIdList;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java
new file mode 100644
index 0000000..8719826
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerListByGroupResponseHeader.java
@@ -0,0 +1,32 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class GetConsumerListByGroupResponseHeader implements CommandCustomHeader {
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java
new file mode 100644
index 0000000..fd1e589
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerRunningInfoRequestHeader.java
@@ -0,0 +1,71 @@
+/**
+ * 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.common.protocol.header;
+
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.annotation.CFNullable;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class GetConsumerRunningInfoRequestHeader implements CommandCustomHeader {
+ @CFNotNull
+ private String consumerGroup;
+ @CFNotNull
+ private String clientId;
+ @CFNullable
+ private boolean jstackEnable;
+
+
+ @Override
+ public void checkFields() throws RemotingCommandException {
+ }
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+
+ public String getClientId() {
+ return clientId;
+ }
+
+
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
+
+ public boolean isJstackEnable() {
+ return jstackEnable;
+ }
+
+
+ public void setJstackEnable(boolean jstackEnable) {
+ this.jstackEnable = jstackEnable;
+ }
+}
[73/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/LanguageCode.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/LanguageCode.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/LanguageCode.java
index 125fbd3..bdb02c6 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/LanguageCode.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/LanguageCode.java
@@ -6,27 +6,27 @@
* (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
+ * 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.
+ * 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.remoting.protocol;
public enum LanguageCode {
- JAVA((byte) 0),
- CPP((byte) 1),
- DOTNET((byte) 2),
- PYTHON((byte) 3),
- DELPHI((byte) 4),
- ERLANG((byte) 5),
- RUBY((byte) 6),
- OTHER((byte) 7),
- HTTP((byte) 8);
+ JAVA((byte)0),
+ CPP((byte)1),
+ DOTNET((byte)2),
+ PYTHON((byte)3),
+ DELPHI((byte)4),
+ ERLANG((byte)5),
+ RUBY((byte)6),
+ OTHER((byte)7),
+ HTTP((byte)8);
private byte code;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
index 60dd498..6b253dc 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
@@ -6,24 +6,17 @@
* (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
+ * 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.
+ * 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.remoting.protocol;
import com.alibaba.fastjson.annotation.JSONField;
-import org.apache.rocketmq.remoting.CommandCustomHeader;
-import org.apache.rocketmq.remoting.annotation.CFNotNull;
-import org.apache.rocketmq.remoting.common.RemotingHelper;
-import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@@ -31,22 +24,26 @@ import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
-
+import org.apache.rocketmq.remoting.CommandCustomHeader;
+import org.apache.rocketmq.remoting.annotation.CFNotNull;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class RemotingCommand {
public static final String SERIALIZE_TYPE_PROPERTY = "rocketmq.serialize.type";
public static final String SERIALIZE_TYPE_ENV = "ROCKETMQ_SERIALIZE_TYPE";
+ public static final String REMOTING_VERSION_KEY = "rocketmq.remoting.version";
private static final Logger log = LoggerFactory.getLogger(RemotingHelper.ROCKETMQ_REMOTING);
private static final int RPC_TYPE = 0; // 0, REQUEST_COMMAND
private static final int RPC_ONEWAY = 1; // 0, RPC
-
private static final Map<Class<? extends CommandCustomHeader>, Field[]> CLASS_HASH_MAP =
- new HashMap<Class<? extends CommandCustomHeader>, Field[]>();
+ new HashMap<Class<? extends CommandCustomHeader>, Field[]>();
private static final Map<Class, String> CANONICAL_NAME_CACHE = new HashMap<Class, String>();
+ // 1, Oneway
// 1, RESPONSE_COMMAND
private static final Map<Field, Annotation> NOT_NULL_ANNOTATION_CACHE = new HashMap<Field, Annotation>();
- // 1, Oneway
-
private static final String STRING_CANONICAL_NAME = String.class.getCanonicalName();
private static final String DOUBLE_CANONICAL_NAME_1 = Double.class.getCanonicalName();
private static final String DOUBLE_CANONICAL_NAME_2 = double.class.getCanonicalName();
@@ -56,7 +53,6 @@ public class RemotingCommand {
private static final String LONG_CANONICAL_NAME_2 = long.class.getCanonicalName();
private static final String BOOLEAN_CANONICAL_NAME_1 = Boolean.class.getCanonicalName();
private static final String BOOLEAN_CANONICAL_NAME_2 = boolean.class.getCanonicalName();
- public static final String REMOTING_VERSION_KEY = "rocketmq.remoting.version";
private static volatile int configVersion = -1;
private static AtomicInteger requestId = new AtomicInteger(0);
@@ -93,7 +89,6 @@ public class RemotingCommand {
*/
private transient byte[] body;
-
protected RemotingCommand() {
}
@@ -148,11 +143,6 @@ public class RemotingCommand {
return cmd;
}
- public void markResponseType() {
- int bits = 1 << RPC_TYPE;
- this.flag |= bits;
- }
-
public static RemotingCommand createResponseCommand(int code, String remark) {
return createResponseCommand(code, remark, null);
}
@@ -205,7 +195,7 @@ public class RemotingCommand {
}
public static SerializeType getProtocolType(int source) {
- return SerializeType.valueOf((byte) ((source >> 24) & 0xFF));
+ return SerializeType.valueOf((byte)((source >> 24) & 0xFF));
}
public static int createNewRequestId() {
@@ -229,6 +219,21 @@ public class RemotingCommand {
return true;
}
+ public static byte[] markProtocolType(int source, SerializeType type) {
+ byte[] result = new byte[4];
+
+ result[0] = type.getCode();
+ result[1] = (byte)((source >> 16) & 0xFF);
+ result[2] = (byte)((source >> 8) & 0xFF);
+ result[3] = (byte)(source & 0xFF);
+ return result;
+ }
+
+ public void markResponseType() {
+ int bits = 1 << RPC_TYPE;
+ this.flag |= bits;
+ }
+
public CommandCustomHeader readCustomHeader() {
return customHeader;
}
@@ -376,16 +381,6 @@ public class RemotingCommand {
}
}
- public static byte[] markProtocolType(int source, SerializeType type) {
- byte[] result = new byte[4];
-
- result[0] = type.getCode();
- result[1] = (byte) ((source >> 16) & 0xFF);
- result[2] = (byte) ((source >> 8) & 0xFF);
- result[3] = (byte) (source & 0xFF);
- return result;
- }
-
public void makeCustomHeaderToNet() {
if (this.customHeader != null) {
Field[] fields = getClazzFields(customHeader.getClass());
@@ -550,16 +545,14 @@ public class RemotingCommand {
@Override
public String toString() {
return "RemotingCommand [code=" + code + ", language=" + language + ", version=" + version + ", opaque=" + opaque + ", flag(B)="
- + Integer.toBinaryString(flag) + ", remark=" + remark + ", extFields=" + extFields + ", serializeTypeCurrentRPC="
- + serializeTypeCurrentRPC + "]";
+ + Integer.toBinaryString(flag) + ", remark=" + remark + ", extFields=" + extFields + ", serializeTypeCurrentRPC="
+ + serializeTypeCurrentRPC + "]";
}
-
public SerializeType getSerializeTypeCurrentRPC() {
return serializeTypeCurrentRPC;
}
-
public void setSerializeTypeCurrentRPC(SerializeType serializeTypeCurrentRPC) {
this.serializeTypeCurrentRPC = serializeTypeCurrentRPC;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommandType.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommandType.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommandType.java
index 3adf06f..de4a5c9 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommandType.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommandType.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.remoting.protocol;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java
index e543ce1..8a5d76e 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java
@@ -6,21 +6,19 @@
* (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
+ * 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.
+ * 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.remoting.protocol;
import com.alibaba.fastjson.JSON;
-
import java.nio.charset.Charset;
-
/**
*
*/
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSysResponseCode.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSysResponseCode.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSysResponseCode.java
index e92bc49..f2836fe 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSysResponseCode.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSysResponseCode.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.remoting.protocol;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java
index 6b0d825..64b37db 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.remoting.protocol;
@@ -22,7 +22,6 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-
/**
*
*/
@@ -52,11 +51,11 @@ public class RocketMQSerializable {
// ################### content
ByteBuffer headerBuffer = ByteBuffer.allocate(totalLen);
// int code(~32767)
- headerBuffer.putShort((short) cmd.getCode());
+ headerBuffer.putShort((short)cmd.getCode());
// LanguageCode language
headerBuffer.put(cmd.getLanguage().getCode());
// int version(~32767)
- headerBuffer.putShort((short) cmd.getVersion());
+ headerBuffer.putShort((short)cmd.getVersion());
// int opaque
headerBuffer.putInt(cmd.getOpaque());
// int flag
@@ -92,10 +91,10 @@ public class RocketMQSerializable {
Map.Entry<String, String> entry = it.next();
if (entry.getKey() != null && entry.getValue() != null) {
kvLength =
- // keySize + Key
- 2 + entry.getKey().getBytes(RemotingSerializable.CHARSET_UTF8).length
- // valSize + val
- + 4 + entry.getValue().getBytes(RemotingSerializable.CHARSET_UTF8).length;
+ // keySize + Key
+ 2 + entry.getKey().getBytes(RemotingSerializable.CHARSET_UTF8).length
+ // valSize + val
+ + 4 + entry.getValue().getBytes(RemotingSerializable.CHARSET_UTF8).length;
totalLength += kvLength;
}
}
@@ -110,7 +109,7 @@ public class RocketMQSerializable {
key = entry.getKey().getBytes(RemotingSerializable.CHARSET_UTF8);
val = entry.getValue().getBytes(RemotingSerializable.CHARSET_UTF8);
- content.putShort((short) key.length);
+ content.putShort((short)key.length);
content.put(key);
content.putInt(val.length);
@@ -124,18 +123,18 @@ public class RocketMQSerializable {
private static int calTotalLen(int remark, int ext) {
// int code(~32767)
int length = 2
- // LanguageCode language
- + 1
- // int version(~32767)
- + 2
- // int opaque
- + 4
- // int flag
- + 4
- // String remark
- + 4 + remark
- // HashMap<String, String> extFields
- + 4 + ext;
+ // LanguageCode language
+ + 1
+ // int version(~32767)
+ + 2
+ // int opaque
+ + 4
+ // int flag
+ + 4
+ // String remark
+ + 4 + remark
+ // HashMap<String, String> extFields
+ + 4 + ext;
return length;
}
@@ -192,12 +191,11 @@ public class RocketMQSerializable {
byteBuffer.get(valContent);
map.put(new String(keyContent, RemotingSerializable.CHARSET_UTF8), new String(valContent,
- RemotingSerializable.CHARSET_UTF8));
+ RemotingSerializable.CHARSET_UTF8));
}
return map;
}
-
public static boolean isBlank(String str) {
int strLen;
if (str == null || (strLen = str.length()) == 0) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/SerializeType.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/SerializeType.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/SerializeType.java
index cebd48f..6bfd42c 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/SerializeType.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/SerializeType.java
@@ -6,20 +6,20 @@
* (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
+ * 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.
+ * 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.remoting.protocol;
public enum SerializeType {
- JSON((byte) 0),
- ROCKETMQ((byte) 1);
+ JSON((byte)0),
+ ROCKETMQ((byte)1);
private byte code;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
index 3b73e46..984ecd1 100644
--- a/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
+++ b/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: MixTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
@@ -22,7 +24,6 @@ package org.apache.rocketmq.remoting;
import org.junit.Test;
-
public class MixTest {
@Test
public void test_extFieldsValue() {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
index 15330bc..15a9aa3 100644
--- a/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
+++ b/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: NettyRPCTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
@@ -20,47 +22,32 @@
*/
package org.apache.rocketmq.remoting;
+import io.netty.channel.ChannelHandlerContext;
+import java.util.concurrent.Executors;
import org.apache.rocketmq.remoting.annotation.CFNullable;
-import org.apache.rocketmq.remoting.exception.*;
-import org.apache.rocketmq.remoting.netty.*;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.exception.RemotingConnectException;
+import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
+import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
+import org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException;
+import org.apache.rocketmq.remoting.netty.NettyClientConfig;
+import org.apache.rocketmq.remoting.netty.NettyRemotingClient;
+import org.apache.rocketmq.remoting.netty.NettyRemotingServer;
+import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
+import org.apache.rocketmq.remoting.netty.NettyServerConfig;
+import org.apache.rocketmq.remoting.netty.ResponseFuture;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-import io.netty.channel.ChannelHandlerContext;
import org.junit.Test;
-import java.util.concurrent.Executors;
-
import static org.junit.Assert.assertTrue;
-
public class NettyRPCTest {
- @Test
- public void test_RPC_Sync() throws InterruptedException, RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException {
- RemotingServer server = createRemotingServer();
- RemotingClient client = createRemotingClient();
-
- for (int i = 0; i < 100; i++) {
- TestRequestHeader requestHeader = new TestRequestHeader();
- requestHeader.setCount(i);
- requestHeader.setMessageTitle("HelloMessageTitle");
- RemotingCommand request = RemotingCommand.createRequestCommand(0, requestHeader);
- RemotingCommand response = client.invokeSync("localhost:8888", request, 1000 * 3000);
- System.out.println("invoke result = " + response);
- assertTrue(response != null);
- }
-
- client.shutdown();
- server.shutdown();
- System.out.println("-----------------------------------------------------------------");
- }
-
public static RemotingServer createRemotingServer() throws InterruptedException {
NettyServerConfig config = new NettyServerConfig();
RemotingServer remotingServer = new NettyRemotingServer(config);
remotingServer.registerProcessor(0, new NettyRequestProcessor() {
private int i = 0;
-
@Override
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) {
System.out.println("processRequest=" + request + " " + (i++));
@@ -85,8 +72,29 @@ public class NettyRPCTest {
}
@Test
+ public void test_RPC_Sync() throws InterruptedException, RemotingConnectException,
+ RemotingSendRequestException, RemotingTimeoutException {
+ RemotingServer server = createRemotingServer();
+ RemotingClient client = createRemotingClient();
+
+ for (int i = 0; i < 100; i++) {
+ TestRequestHeader requestHeader = new TestRequestHeader();
+ requestHeader.setCount(i);
+ requestHeader.setMessageTitle("HelloMessageTitle");
+ RemotingCommand request = RemotingCommand.createRequestCommand(0, requestHeader);
+ RemotingCommand response = client.invokeSync("localhost:8888", request, 1000 * 3000);
+ System.out.println("invoke result = " + response);
+ assertTrue(response != null);
+ }
+
+ client.shutdown();
+ server.shutdown();
+ System.out.println("-----------------------------------------------------------------");
+ }
+
+ @Test
public void test_RPC_Oneway() throws InterruptedException, RemotingConnectException,
- RemotingTimeoutException, RemotingTooMuchRequestException, RemotingSendRequestException {
+ RemotingTimeoutException, RemotingTooMuchRequestException, RemotingSendRequestException {
RemotingServer server = createRemotingServer();
RemotingClient client = createRemotingClient();
@@ -101,10 +109,9 @@ public class NettyRPCTest {
System.out.println("-----------------------------------------------------------------");
}
-
@Test
public void test_RPC_Async() throws InterruptedException, RemotingConnectException,
- RemotingTimeoutException, RemotingTooMuchRequestException, RemotingSendRequestException {
+ RemotingTimeoutException, RemotingTooMuchRequestException, RemotingSendRequestException {
RemotingServer server = createRemotingServer();
RemotingClient client = createRemotingClient();
@@ -126,10 +133,9 @@ public class NettyRPCTest {
System.out.println("-----------------------------------------------------------------");
}
-
@Test
public void test_server_call_client() throws InterruptedException, RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException {
+ RemotingSendRequestException, RemotingTimeoutException {
final RemotingServer server = createRemotingServer();
final RemotingClient client = createRemotingClient();
@@ -183,7 +189,6 @@ public class NettyRPCTest {
}
-
class TestRequestHeader implements CommandCustomHeader {
@CFNullable
private Integer count;
@@ -191,33 +196,27 @@ class TestRequestHeader implements CommandCustomHeader {
@CFNullable
private String messageTitle;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public Integer getCount() {
return count;
}
-
public void setCount(Integer count) {
this.count = count;
}
-
public String getMessageTitle() {
return messageTitle;
}
-
public void setMessageTitle(String messageTitle) {
this.messageTitle = messageTitle;
}
}
-
class TestResponseHeader implements CommandCustomHeader {
@CFNullable
private Integer count;
@@ -246,5 +245,4 @@ class TestResponseHeader implements CommandCustomHeader {
this.messageTitle = messageTitle;
}
-
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java b/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java
index 3c27697..16aa9b1 100644
--- a/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java
+++ b/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.
*/
/**
@@ -22,7 +22,6 @@ package org.apache.rocketmq.subclass;
import org.junit.Test;
-
public class TestSubClassAuto {
@Test
public void test_sub() {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/srvutil/pom.xml
----------------------------------------------------------------------
diff --git a/srvutil/pom.xml b/srvutil/pom.xml
index 0873ee8..af884cb 100644
--- a/srvutil/pom.xml
+++ b/srvutil/pom.xml
@@ -15,7 +15,7 @@
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.rocketmq</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/srvutil/src/main/java/org/apache/rocketmq/srvutil/ServerUtil.java
----------------------------------------------------------------------
diff --git a/srvutil/src/main/java/org/apache/rocketmq/srvutil/ServerUtil.java b/srvutil/src/main/java/org/apache/rocketmq/srvutil/ServerUtil.java
index 0a25dd1..1774150 100644
--- a/srvutil/src/main/java/org/apache/rocketmq/srvutil/ServerUtil.java
+++ b/srvutil/src/main/java/org/apache/rocketmq/srvutil/ServerUtil.java
@@ -6,19 +6,23 @@
* (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
+ * 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.
+ * 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.srvutil;
-import org.apache.commons.cli.*;
-
import java.util.Properties;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
public class ServerUtil {
@@ -28,17 +32,16 @@ public class ServerUtil {
options.addOption(opt);
opt =
- new Option("n", "namesrvAddr", true,
- "Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876");
+ new Option("n", "namesrvAddr", true,
+ "Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876");
opt.setRequired(false);
options.addOption(opt);
return options;
}
-
public static CommandLine parseCmdLine(final String appName, String[] args, Options options,
- CommandLineParser parser) {
+ CommandLineParser parser) {
HelpFormatter hf = new HelpFormatter();
hf.setWidth(110);
CommandLine commandLine = null;
@@ -55,14 +58,12 @@ public class ServerUtil {
return commandLine;
}
-
public static void printCommandLineHelp(final String appName, final Options options) {
HelpFormatter hf = new HelpFormatter();
hf.setWidth(110);
hf.printHelp(appName, options, true);
}
-
public static Properties commandLine2Properties(final CommandLine commandLine) {
Properties properties = new Properties();
Option[] opts = commandLine.getOptions();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/pom.xml
----------------------------------------------------------------------
diff --git a/store/pom.xml b/store/pom.xml
index 10b13b9..29be589 100644
--- a/store/pom.xml
+++ b/store/pom.xml
@@ -15,7 +15,7 @@
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.rocketmq</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java b/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
index 94362ea..27b957f 100644
--- a/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
@@ -16,13 +16,6 @@
*/
package org.apache.rocketmq.store;
-import org.apache.rocketmq.common.ServiceThread;
-import org.apache.rocketmq.common.UtilAll;
-import org.apache.rocketmq.common.constant.LoggerName;
-import org.apache.rocketmq.store.config.BrokerRole;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.File;
import java.io.IOException;
import java.util.ServiceLoader;
@@ -30,33 +23,35 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.TimeUnit;
-
+import org.apache.rocketmq.common.ServiceThread;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.store.config.BrokerRole;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Create MappedFile in advance
- *
*/
public class AllocateMappedFileService extends ServiceThread {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
private static int waitTimeOut = 1000 * 5;
private ConcurrentHashMap<String, AllocateRequest> requestTable =
- new ConcurrentHashMap<String, AllocateRequest>();
+ new ConcurrentHashMap<String, AllocateRequest>();
private PriorityBlockingQueue<AllocateRequest> requestQueue =
- new PriorityBlockingQueue<AllocateRequest>();
+ new PriorityBlockingQueue<AllocateRequest>();
private volatile boolean hasException = false;
private DefaultMessageStore messageStore;
-
public AllocateMappedFileService(DefaultMessageStore messageStore) {
this.messageStore = messageStore;
}
-
public MappedFile putRequestAndReturnMappedFile(String nextFilePath, String nextNextFilePath, int fileSize) {
int canSubmitRequests = 2;
if (this.messageStore.getMessageStoreConfig().isTransientStorePoolEnable()) {
if (this.messageStore.getMessageStoreConfig().isFastFailIfNoBufferInStorePool()
- && BrokerRole.SLAVE != this.messageStore.getMessageStoreConfig().getBrokerRole()) { //if broker is slave, don't fast fail even no buffer in pool
+ && BrokerRole.SLAVE != this.messageStore.getMessageStoreConfig().getBrokerRole()) { //if broker is slave, don't fast fail even no buffer in pool
canSubmitRequests = this.messageStore.getTransientStorePool().remainBufferNumbs() - this.requestQueue.size();
}
}
@@ -67,7 +62,7 @@ public class AllocateMappedFileService extends ServiceThread {
if (nextPutOK) {
if (canSubmitRequests <= 0) {
log.warn("[NOTIFYME]TransientStorePool is not enough, so create mapped file error, " +
- "RequestQueueSize : {}, StorePoolSize: {}", this.requestQueue.size(), this.messageStore.getTransientStorePool().remainBufferNumbs());
+ "RequestQueueSize : {}, StorePoolSize: {}", this.requestQueue.size(), this.messageStore.getTransientStorePool().remainBufferNumbs());
this.requestTable.remove(nextFilePath);
return null;
}
@@ -83,7 +78,7 @@ public class AllocateMappedFileService extends ServiceThread {
if (nextNextPutOK) {
if (canSubmitRequests <= 0) {
log.warn("[NOTIFYME]TransientStorePool is not enough, so skip preallocate mapped file, " +
- "RequestQueueSize : {}, StorePoolSize: {}", this.requestQueue.size(), this.messageStore.getTransientStorePool().remainBufferNumbs());
+ "RequestQueueSize : {}, StorePoolSize: {}", this.requestQueue.size(), this.messageStore.getTransientStorePool().remainBufferNumbs());
this.requestTable.remove(nextNextFilePath);
} else {
boolean offerOK = this.requestQueue.offer(nextNextReq);
@@ -119,13 +114,11 @@ public class AllocateMappedFileService extends ServiceThread {
return null;
}
-
@Override
public String getServiceName() {
return AllocateMappedFileService.class.getSimpleName();
}
-
public void shutdown() {
this.stopped = true;
this.thread.interrupt();
@@ -144,7 +137,6 @@ public class AllocateMappedFileService extends ServiceThread {
}
}
-
public void run() {
log.info(this.getServiceName() + " service started");
@@ -154,7 +146,6 @@ public class AllocateMappedFileService extends ServiceThread {
log.info(this.getServiceName() + " service end");
}
-
/**
* Only interrupted by the external thread, will return false
*/
@@ -166,12 +157,12 @@ public class AllocateMappedFileService extends ServiceThread {
AllocateRequest expectedRequest = this.requestTable.get(req.getFilePath());
if (null == expectedRequest) {
log.warn("this mmap request expired, maybe cause timeout " + req.getFilePath() + " "
- + req.getFileSize());
+ + req.getFileSize());
return true;
}
if (expectedRequest != req) {
log.warn("never expected here, maybe cause timeout " + req.getFilePath() + " "
- + req.getFileSize() + ", req:" + req + ", expectedRequest:" + expectedRequest);
+ + req.getFileSize() + ", req:" + req + ", expectedRequest:" + expectedRequest);
return true;
}
@@ -195,16 +186,16 @@ public class AllocateMappedFileService extends ServiceThread {
if (eclipseTime > 10) {
int queueSize = this.requestQueue.size();
log.warn("create mappedFile spent time(ms) " + eclipseTime + " queue size " + queueSize
- + " " + req.getFilePath() + " " + req.getFileSize());
+ + " " + req.getFilePath() + " " + req.getFileSize());
}
// pre write mappedFile
if (mappedFile.getFileSize() >= this.messageStore.getMessageStoreConfig()
- .getMapedFileSizeCommitLog()
- &&
- this.messageStore.getMessageStoreConfig().isWarmMapedFileEnable()) {
+ .getMapedFileSizeCommitLog()
+ &&
+ this.messageStore.getMessageStoreConfig().isWarmMapedFileEnable()) {
mappedFile.warmMappedFile(this.messageStore.getMessageStoreConfig().getFlushDiskType(),
- this.messageStore.getMessageStoreConfig().getFlushLeastPagesWhenWarmMapedFile());
+ this.messageStore.getMessageStoreConfig().getFlushLeastPagesWhenWarmMapedFile());
}
req.setMappedFile(mappedFile);
@@ -239,53 +230,43 @@ public class AllocateMappedFileService extends ServiceThread {
private CountDownLatch countDownLatch = new CountDownLatch(1);
private volatile MappedFile mappedFile = null;
-
public AllocateRequest(String filePath, int fileSize) {
this.filePath = filePath;
this.fileSize = fileSize;
}
-
public String getFilePath() {
return filePath;
}
-
public void setFilePath(String filePath) {
this.filePath = filePath;
}
-
public int getFileSize() {
return fileSize;
}
-
public void setFileSize(int fileSize) {
this.fileSize = fileSize;
}
-
public CountDownLatch getCountDownLatch() {
return countDownLatch;
}
-
public void setCountDownLatch(CountDownLatch countDownLatch) {
this.countDownLatch = countDownLatch;
}
-
public MappedFile getMappedFile() {
return mappedFile;
}
-
public void setMappedFile(MappedFile mappedFile) {
this.mappedFile = mappedFile;
}
-
public int compareTo(AllocateRequest other) {
if (this.fileSize < other.fileSize)
return 1;
@@ -308,7 +289,6 @@ public class AllocateMappedFileService extends ServiceThread {
// other.fileSize ? -1 : 0;
}
-
@Override
public int hashCode() {
final int prime = 31;
@@ -318,7 +298,6 @@ public class AllocateMappedFileService extends ServiceThread {
return result;
}
-
@Override
public boolean equals(Object obj) {
if (this == obj)
@@ -327,7 +306,7 @@ public class AllocateMappedFileService extends ServiceThread {
return false;
if (getClass() != obj.getClass())
return false;
- AllocateRequest other = (AllocateRequest) obj;
+ AllocateRequest other = (AllocateRequest)obj;
if (filePath == null) {
if (other.filePath != null)
return false;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java b/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java
index 0e8678c..6d158d3 100644
--- a/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java
+++ b/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java
@@ -6,19 +6,18 @@
* (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
+ * 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.
+ * 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.store;
import java.nio.ByteBuffer;
-
/**
* Write messages callback interface
*
@@ -36,5 +35,5 @@ public interface AppendMessageCallback {
* @return How many bytes to write
*/
AppendMessageResult doAppend(final long fileFromOffset, final ByteBuffer byteBuffer,
- final int maxBlank, final MessageExtBrokerInner msg);
+ final int maxBlank, final MessageExtBrokerInner msg);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java b/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java
index 8541208..965097f 100644
--- a/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.store;
@@ -40,7 +40,7 @@ public class AppendMessageResult {
}
public AppendMessageResult(AppendMessageStatus status, long wroteOffset, int wroteBytes, String msgId,
- long storeTimestamp, long logicsOffset, long pagecacheRT) {
+ long storeTimestamp, long logicsOffset, long pagecacheRT) {
this.status = status;
this.wroteOffset = wroteOffset;
this.wroteBytes = wroteBytes;
@@ -62,62 +62,50 @@ public class AppendMessageResult {
return this.status == AppendMessageStatus.PUT_OK;
}
-
public AppendMessageStatus getStatus() {
return status;
}
-
public void setStatus(AppendMessageStatus status) {
this.status = status;
}
-
public long getWroteOffset() {
return wroteOffset;
}
-
public void setWroteOffset(long wroteOffset) {
this.wroteOffset = wroteOffset;
}
-
public int getWroteBytes() {
return wroteBytes;
}
-
public void setWroteBytes(int wroteBytes) {
this.wroteBytes = wroteBytes;
}
-
public String getMsgId() {
return msgId;
}
-
public void setMsgId(String msgId) {
this.msgId = msgId;
}
-
public long getStoreTimestamp() {
return storeTimestamp;
}
-
public void setStoreTimestamp(long storeTimestamp) {
this.storeTimestamp = storeTimestamp;
}
-
public long getLogicsOffset() {
return logicsOffset;
}
-
public void setLogicsOffset(long logicsOffset) {
this.logicsOffset = logicsOffset;
}
@@ -125,13 +113,13 @@ public class AppendMessageResult {
@Override
public String toString() {
return "AppendMessageResult{" +
- "status=" + status +
- ", wroteOffset=" + wroteOffset +
- ", wroteBytes=" + wroteBytes +
- ", msgId='" + msgId + '\'' +
- ", storeTimestamp=" + storeTimestamp +
- ", logicsOffset=" + logicsOffset +
- ", pagecacheRT=" + pagecacheRT +
- '}';
+ "status=" + status +
+ ", wroteOffset=" + wroteOffset +
+ ", wroteBytes=" + wroteBytes +
+ ", msgId='" + msgId + '\'' +
+ ", storeTimestamp=" + storeTimestamp +
+ ", logicsOffset=" + logicsOffset +
+ ", pagecacheRT=" + pagecacheRT +
+ '}';
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java b/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java
index 34f70b1..39cf9fa 100644
--- a/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java
+++ b/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.store;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/CommitLog.java b/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
index ddd6be3..17625f4 100644
--- a/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
+++ b/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
@@ -16,6 +16,15 @@
*/
package org.apache.rocketmq.store;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.locks.ReentrantLock;
import org.apache.rocketmq.common.ServiceThread;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.constant.LoggerName;
@@ -31,20 +40,8 @@ import org.apache.rocketmq.store.schedule.ScheduleMessageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.locks.ReentrantLock;
-
-
/**
* Store all metadata downtime for recovery, data protection reliability
- *
*/
public class CommitLog {
// Message's MAGIC CODE daa320a7
@@ -72,7 +69,7 @@ public class CommitLog {
public CommitLog(final DefaultMessageStore defaultMessageStore) {
this.mappedFileQueue = new MappedFileQueue(defaultMessageStore.getMessageStoreConfig().getStorePathCommitLog(),
- defaultMessageStore.getMessageStoreConfig().getMapedFileSizeCommitLog(), defaultMessageStore.getAllocateMappedFileService());
+ defaultMessageStore.getMessageStoreConfig().getMapedFileSizeCommitLog(), defaultMessageStore.getAllocateMappedFileService());
this.defaultMessageStore = defaultMessageStore;
if (FlushDiskType.SYNC_FLUSH == defaultMessageStore.getMessageStoreConfig().getFlushDiskType()) {
@@ -126,17 +123,15 @@ public class CommitLog {
return this.mappedFileQueue.remainHowManyDataToFlush();
}
-
public int deleteExpiredFile(//
- final long expiredTime, //
- final int deleteFilesInterval, //
- final long intervalForcibly, //
- final boolean cleanImmediately//
+ final long expiredTime, //
+ final int deleteFilesInterval, //
+ final long intervalForcibly, //
+ final boolean cleanImmediately//
) {
return this.mappedFileQueue.deleteExpiredFileByTime(expiredTime, deleteFilesInterval, intervalForcibly, cleanImmediately);
}
-
/**
* Read CommitLog data, use data replication
*/
@@ -144,12 +139,11 @@ public class CommitLog {
return this.getData(offset, offset == 0);
}
-
public SelectMappedBufferResult getData(final long offset, final boolean returnFirstOnNotFound) {
int mappedFileSize = this.defaultMessageStore.getMessageStoreConfig().getMapedFileSizeCommitLog();
MappedFile mappedFile = this.mappedFileQueue.findMappedFileByOffset(offset, returnFirstOnNotFound);
if (mappedFile != null) {
- int pos = (int) (offset % mappedFileSize);
+ int pos = (int)(offset % mappedFileSize);
SelectMappedBufferResult result = mappedFile.selectMappedBuffer(pos);
return result;
}
@@ -157,7 +151,6 @@ public class CommitLog {
return null;
}
-
/**
* When the normal exit, data recovery, all memory data have been flush
*/
@@ -227,8 +220,7 @@ public class CommitLog {
/**
* check the message and returns the message size
*
- * @return 0 Come the end of the file // >0 Normal messages // -1 Message
- * checksum failure
+ * @return 0 Come the end of the file // >0 Normal messages // -1 Message checksum failure
*/
public DispatchRequest checkMessageAndReturnSize(java.nio.ByteBuffer byteBuffer, final boolean checkCRC, final boolean readBody) {
try {
@@ -340,7 +332,7 @@ public class CommitLog {
if (delayLevel > 0) {
tagsCode = this.defaultMessageStore.getScheduleMessageService().computeDeliverTimestamp(delayLevel,
- storeTimestamp);
+ storeTimestamp);
}
}
}
@@ -354,23 +346,23 @@ public class CommitLog {
doNothingForDeadCode(byteBuffer1);
doNothingForDeadCode(byteBuffer2);
log.error(
- "[BUG]read total count not equals msg total size. totalSize={}, readTotalCount={}, bodyLen={}, topicLen={}, propertiesLength={}",
- totalSize, readLength, bodyLen, topicLen, propertiesLength);
+ "[BUG]read total count not equals msg total size. totalSize={}, readTotalCount={}, bodyLen={}, topicLen={}, propertiesLength={}",
+ totalSize, readLength, bodyLen, topicLen, propertiesLength);
return new DispatchRequest(totalSize, false/* success */);
}
return new DispatchRequest(//
- topic, // 1
- queueId, // 2
- physicOffset, // 3
- totalSize, // 4
- tagsCode, // 5
- storeTimestamp, // 6
- queueOffset, // 7
- keys, // 8
- uniqKey, //9
- sysFlag, // 9
- preparedTransactionOffset// 10
+ topic, // 1
+ queueId, // 2
+ physicOffset, // 3
+ totalSize, // 4
+ tagsCode, // 5
+ storeTimestamp, // 6
+ queueOffset, // 7
+ keys, // 8
+ uniqKey, //9
+ sysFlag, // 9
+ preparedTransactionOffset// 10
);
} catch (Exception e) {
}
@@ -380,24 +372,24 @@ public class CommitLog {
private int calMsgLength(int bodyLength, int topicLength, int propertiesLength) {
final int msgLen = 4 // 1 TOTALSIZE
- + 4 // 2 MAGICCODE
- + 4 // 3 BODYCRC
- + 4 // 4 QUEUEID
- + 4 // 5 FLAG
- + 8 // 6 QUEUEOFFSET
- + 8 // 7 PHYSICALOFFSET
- + 4 // 8 SYSFLAG
- + 8 // 9 BORNTIMESTAMP
- + 8 // 10 BORNHOST
- + 8 // 11 STORETIMESTAMP
- + 8 // 12 STOREHOSTADDRESS
- + 4 // 13 RECONSUMETIMES
- + 8 // 14 Prepared Transaction Offset
- + 4 + (bodyLength > 0 ? bodyLength : 0) // 14 BODY
- + 1 + topicLength // 15 TOPIC
- + 2 + (propertiesLength > 0 ? propertiesLength : 0) // 16
- // propertiesLength
- + 0;
+ + 4 // 2 MAGICCODE
+ + 4 // 3 BODYCRC
+ + 4 // 4 QUEUEID
+ + 4 // 5 FLAG
+ + 8 // 6 QUEUEOFFSET
+ + 8 // 7 PHYSICALOFFSET
+ + 4 // 8 SYSFLAG
+ + 8 // 9 BORNTIMESTAMP
+ + 8 // 10 BORNHOST
+ + 8 // 11 STORETIMESTAMP
+ + 8 // 12 STOREHOSTADDRESS
+ + 4 // 13 RECONSUMETIMES
+ + 8 // 14 Prepared Transaction Offset
+ + 4 + (bodyLength > 0 ? bodyLength : 0) // 14 BODY
+ + 1 + topicLength // 15 TOPIC
+ + 2 + (propertiesLength > 0 ? propertiesLength : 0) // 16
+ // propertiesLength
+ + 0;
return msgLen;
}
@@ -441,7 +433,6 @@ public class CommitLog {
if (size > 0) {
mappedFileOffset += size;
-
if (this.defaultMessageStore.getMessageStoreConfig().isDuplicationEnable()) {
if (dispatchRequest.getCommitLogOffset() < this.defaultMessageStore.getConfirmOffset()) {
this.defaultMessageStore.doDispatch(dispatchRequest);
@@ -505,18 +496,18 @@ public class CommitLog {
}
if (this.defaultMessageStore.getMessageStoreConfig().isMessageIndexEnable()//
- && this.defaultMessageStore.getMessageStoreConfig().isMessageIndexSafe()) {
+ && this.defaultMessageStore.getMessageStoreConfig().isMessageIndexSafe()) {
if (storeTimestamp <= this.defaultMessageStore.getStoreCheckpoint().getMinTimestampIndex()) {
log.info("find check timestamp, {} {}", //
- storeTimestamp, //
- UtilAll.timeMillisToHumanString(storeTimestamp));
+ storeTimestamp, //
+ UtilAll.timeMillisToHumanString(storeTimestamp));
return true;
}
} else {
if (storeTimestamp <= this.defaultMessageStore.getStoreCheckpoint().getMinTimestamp()) {
log.info("find check timestamp, {} {}", //
- storeTimestamp, //
- UtilAll.timeMillisToHumanString(storeTimestamp));
+ storeTimestamp, //
+ UtilAll.timeMillisToHumanString(storeTimestamp));
return true;
}
}
@@ -552,7 +543,7 @@ public class CommitLog {
final int tranType = MessageSysFlag.getTransactionValue(msg.getSysFlag());
if (tranType == MessageSysFlag.TRANSACTION_NOT_TYPE//
- || tranType == MessageSysFlag.TRANSACTION_COMMIT_TYPE) {
+ || tranType == MessageSysFlag.TRANSACTION_COMMIT_TYPE) {
// Delay Delivery
if (msg.getDelayTimeLevel() > 0) {
if (msg.getDelayTimeLevel() > this.defaultMessageStore.getScheduleMessageService().getMaxDelayLevel()) {
@@ -636,7 +627,6 @@ public class CommitLog {
this.defaultMessageStore.unlockMappedFile(unlockMappedFile);
}
-
PutMessageResult putMessageResult = new PutMessageResult(PutMessageStatus.PUT_OK, result);
// Statistics
@@ -647,14 +637,14 @@ public class CommitLog {
// Synchronization flush
if (FlushDiskType.SYNC_FLUSH == this.defaultMessageStore.getMessageStoreConfig().getFlushDiskType()) {
- final GroupCommitService service = (GroupCommitService) this.flushCommitLogService;
+ final GroupCommitService service = (GroupCommitService)this.flushCommitLogService;
if (msg.isWaitStoreMsgOK()) {
request = new GroupCommitRequest(result.getWroteOffset() + result.getWroteBytes());
service.putRequest(request);
boolean flushOK = request.waitForFlush(this.defaultMessageStore.getMessageStoreConfig().getSyncFlushTimeout());
if (!flushOK) {
log.error("do groupcommit, wait for flush failed, topic: " + msg.getTopic() + " tags: " + msg.getTags()
- + " client address: " + msg.getBornHostString());
+ + " client address: " + msg.getBornHostString());
putMessageResult.setPutMessageStatus(PutMessageStatus.FLUSH_DISK_TIMEOUT);
}
} else {
@@ -684,11 +674,11 @@ public class CommitLog {
service.getWaitNotifyObject().wakeupAll();
boolean flushOK =
- // TODO
- request.waitForFlush(this.defaultMessageStore.getMessageStoreConfig().getSyncFlushTimeout());
+ // TODO
+ request.waitForFlush(this.defaultMessageStore.getMessageStoreConfig().getSyncFlushTimeout());
if (!flushOK) {
log.error("do sync transfer other node, wait return, but failed, topic: " + msg.getTopic() + " tags: "
- + msg.getTags() + " client address: " + msg.getBornHostString());
+ + msg.getTags() + " client address: " + msg.getBornHostString());
putMessageResult.setPutMessageStatus(PutMessageStatus.FLUSH_SLAVE_TIMEOUT);
}
}
@@ -739,7 +729,7 @@ public class CommitLog {
int mappedFileSize = this.defaultMessageStore.getMessageStoreConfig().getMapedFileSizeCommitLog();
MappedFile mappedFile = this.mappedFileQueue.findMappedFileByOffset(offset, offset == 0);
if (mappedFile != null) {
- int pos = (int) (offset % mappedFileSize);
+ int pos = (int)(offset % mappedFileSize);
return mappedFile.selectMappedBuffer(pos, size);
}
return null;
@@ -754,17 +744,14 @@ public class CommitLog {
return topicQueueTable;
}
-
public void setTopicQueueTable(HashMap<String, Long> topicQueueTable) {
this.topicQueueTable = topicQueueTable;
}
-
public void destroy() {
this.mappedFileQueue.destroy();
}
-
public boolean appendData(long startOffset, byte[] data) {
lockForPutMessage(); //spin...
try {
@@ -780,7 +767,6 @@ public class CommitLog {
}
}
-
public boolean retryDeleteFirstFile(final long intervalForcibly) {
return this.mappedFileQueue.retryDeleteFirstFile(intervalForcibly);
}
@@ -798,6 +784,72 @@ public class CommitLog {
mappedFileQueue.checkSelf();
}
+ public long lockTimeMills() {
+ long diff = 0;
+ long begin = this.beginTimeInLock;
+ if (begin > 0) {
+ diff = this.defaultMessageStore.now() - begin;
+ }
+
+ if (diff < 0) {
+ diff = 0;
+ }
+
+ return diff;
+ }
+
+ /**
+ * Spin util acquired the lock.
+ */
+ private void lockForPutMessage() {
+ if (this.defaultMessageStore.getMessageStoreConfig().isUseReentrantLockWhenPutMessage()) {
+ putMessageNormalLock.lock();
+ } else {
+ boolean flag;
+ do {
+ flag = this.putMessageSpinLock.compareAndSet(true, false);
+ }
+ while (!flag);
+ }
+ }
+
+ private void releasePutMessageLock() {
+ if (this.defaultMessageStore.getMessageStoreConfig().isUseReentrantLockWhenPutMessage()) {
+ putMessageNormalLock.unlock();
+ } else {
+ this.putMessageSpinLock.compareAndSet(false, true);
+ }
+ }
+
+ public static class GroupCommitRequest {
+ private final long nextOffset;
+ private final CountDownLatch countDownLatch = new CountDownLatch(1);
+ private volatile boolean flushOK = false;
+
+ public GroupCommitRequest(long nextOffset) {
+ this.nextOffset = nextOffset;
+ }
+
+ public long getNextOffset() {
+ return nextOffset;
+ }
+
+ public void wakeupCustomer(final boolean flushOK) {
+ this.flushOK = flushOK;
+ this.countDownLatch.countDown();
+ }
+
+ public boolean waitForFlush(long timeout) {
+ try {
+ this.countDownLatch.await(timeout, TimeUnit.MILLISECONDS);
+ return this.flushOK;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+ }
+
abstract class FlushCommitLogService extends ServiceThread {
protected static final int RETRY_TIMES_OVER = 10;
}
@@ -820,7 +872,7 @@ public class CommitLog {
int commitDataLeastPages = CommitLog.this.defaultMessageStore.getMessageStoreConfig().getCommitCommitLogLeastPages();
int commitDataThoroughInterval =
- CommitLog.this.defaultMessageStore.getMessageStoreConfig().getCommitCommitLogThoroughInterval();
+ CommitLog.this.defaultMessageStore.getMessageStoreConfig().getCommitCommitLogThoroughInterval();
long begin = System.currentTimeMillis();
if (begin >= (this.lastCommitTimestamp + commitDataThoroughInterval)) {
@@ -859,7 +911,6 @@ public class CommitLog {
private long lastFlushTimestamp = 0;
private long printTimes = 0;
-
public void run() {
CommitLog.log.info(this.getServiceName() + " service started");
@@ -870,7 +921,7 @@ public class CommitLog {
int flushPhysicQueueLeastPages = CommitLog.this.defaultMessageStore.getMessageStoreConfig().getFlushCommitLogLeastPages();
int flushPhysicQueueThoroughInterval =
- CommitLog.this.defaultMessageStore.getMessageStoreConfig().getFlushCommitLogThoroughInterval();
+ CommitLog.this.defaultMessageStore.getMessageStoreConfig().getFlushCommitLogThoroughInterval();
boolean printFlushProgress = false;
@@ -921,58 +972,22 @@ public class CommitLog {
CommitLog.log.info(this.getServiceName() + " service end");
}
-
@Override
public String getServiceName() {
return FlushRealTimeService.class.getSimpleName();
}
-
private void printFlushProgress() {
// CommitLog.log.info("how much disk fall behind memory, "
// + CommitLog.this.mappedFileQueue.howMuchFallBehind());
}
-
@Override
public long getJointime() {
return 1000 * 60 * 5;
}
}
- public static class GroupCommitRequest {
- private final long nextOffset;
- private final CountDownLatch countDownLatch = new CountDownLatch(1);
- private volatile boolean flushOK = false;
-
-
- public GroupCommitRequest(long nextOffset) {
- this.nextOffset = nextOffset;
- }
-
-
- public long getNextOffset() {
- return nextOffset;
- }
-
-
- public void wakeupCustomer(final boolean flushOK) {
- this.flushOK = flushOK;
- this.countDownLatch.countDown();
- }
-
-
- public boolean waitForFlush(long timeout) {
- try {
- this.countDownLatch.await(timeout, TimeUnit.MILLISECONDS);
- return this.flushOK;
- } catch (InterruptedException e) {
- e.printStackTrace();
- return false;
- }
- }
- }
-
/**
* GroupCommit Service
*/
@@ -980,7 +995,6 @@ public class CommitLog {
private volatile List<GroupCommitRequest> requestsWrite = new ArrayList<GroupCommitRequest>();
private volatile List<GroupCommitRequest> requestsRead = new ArrayList<GroupCommitRequest>();
-
public void putRequest(final GroupCommitRequest request) {
synchronized (this) {
this.requestsWrite.add(request);
@@ -990,14 +1004,12 @@ public class CommitLog {
}
}
-
private void swapRequests() {
List<GroupCommitRequest> tmp = this.requestsWrite;
this.requestsWrite = this.requestsRead;
this.requestsRead = tmp;
}
-
private void doCommit() {
if (!this.requestsRead.isEmpty()) {
for (GroupCommitRequest req : this.requestsRead) {
@@ -1028,7 +1040,6 @@ public class CommitLog {
}
}
-
public void run() {
CommitLog.log.info(this.getServiceName() + " service started");
@@ -1058,19 +1069,16 @@ public class CommitLog {
CommitLog.log.info(this.getServiceName() + " service end");
}
-
@Override
protected void onWaitEnd() {
this.swapRequests();
}
-
@Override
public String getServiceName() {
return GroupCommitService.class.getSimpleName();
}
-
@Override
public long getJointime() {
return 1000 * 60 * 5;
@@ -1090,19 +1098,16 @@ public class CommitLog {
private final ByteBuffer hostHolder = ByteBuffer.allocate(8);
-
DefaultAppendMessageCallback(final int size) {
this.msgIdMemory = ByteBuffer.allocate(MessageDecoder.MSG_ID_LENGTH);
this.msgStoreItemMemory = ByteBuffer.allocate(size + END_FILE_MIN_BLANK_LENGTH);
this.maxMessageSize = size;
}
-
public ByteBuffer getMsgStoreItemMemory() {
return msgStoreItemMemory;
}
-
public AppendMessageResult doAppend(final long fileFromOffset, final ByteBuffer byteBuffer, final int maxBlank, final MessageExtBrokerInner msgInner) {
// STORETIMESTAMP + STOREHOSTADDRESS + OFFSET <br>
@@ -1143,9 +1148,9 @@ public class CommitLog {
* Serialize message
*/
final byte[] propertiesData =
- msgInner.getPropertiesString() == null ? null : msgInner.getPropertiesString().getBytes(MessageDecoder.CHARSET_UTF8);
+ msgInner.getPropertiesString() == null ? null : msgInner.getPropertiesString().getBytes(MessageDecoder.CHARSET_UTF8);
- final short propertiesLength = propertiesData == null ? 0 : (short) propertiesData.length;
+ final short propertiesLength = propertiesData == null ? 0 : (short)propertiesData.length;
if (propertiesLength > Short.MAX_VALUE) {
log.warn("putMessage message properties length too long. length={}", propertiesData.length);
@@ -1162,7 +1167,7 @@ public class CommitLog {
// Exceeds the maximum message
if (msgLen > this.maxMessageSize) {
CommitLog.log.warn("message size exceeded, msg total size: " + msgLen + ", msg body size: " + bodyLength
- + ", maxMessageSize: " + this.maxMessageSize);
+ + ", maxMessageSize: " + this.maxMessageSize);
return new AppendMessageResult(AppendMessageStatus.MESSAGE_SIZE_EXCEEDED);
}
@@ -1180,7 +1185,7 @@ public class CommitLog {
final long beginTimeMills = CommitLog.this.defaultMessageStore.now();
byteBuffer.put(this.msgStoreItemMemory.array(), 0, maxBlank);
return new AppendMessageResult(AppendMessageStatus.END_OF_FILE, wroteOffset, maxBlank, msgId, msgInner.getStoreTimestamp(),
- queueOffset, CommitLog.this.defaultMessageStore.now() - beginTimeMills);
+ queueOffset, CommitLog.this.defaultMessageStore.now() - beginTimeMills);
}
// Initialization of storage space
@@ -1221,7 +1226,7 @@ public class CommitLog {
if (bodyLength > 0)
this.msgStoreItemMemory.put(msgInner.getBody());
// 16 TOPIC
- this.msgStoreItemMemory.put((byte) topicLength);
+ this.msgStoreItemMemory.put((byte)topicLength);
this.msgStoreItemMemory.put(topicData);
// 17 PROPERTIES
this.msgStoreItemMemory.putShort(propertiesLength);
@@ -1233,7 +1238,7 @@ public class CommitLog {
byteBuffer.put(this.msgStoreItemMemory.array(), 0, msgLen);
AppendMessageResult result = new AppendMessageResult(AppendMessageStatus.PUT_OK, wroteOffset, msgLen, msgId,
- msgInner.getStoreTimestamp(), queueOffset, CommitLog.this.defaultMessageStore.now() - beginTimeMills);
+ msgInner.getStoreTimestamp(), queueOffset, CommitLog.this.defaultMessageStore.now() - beginTimeMills);
switch (tranType) {
case MessageSysFlag.TRANSACTION_PREPARED_TYPE:
@@ -1250,46 +1255,9 @@ public class CommitLog {
return result;
}
-
private void resetByteBuffer(final ByteBuffer byteBuffer, final int limit) {
byteBuffer.flip();
byteBuffer.limit(limit);
}
}
-
- public long lockTimeMills() {
- long diff = 0;
- long begin = this.beginTimeInLock;
- if (begin > 0) {
- diff = this.defaultMessageStore.now() - begin;
- }
-
- if (diff < 0) {
- diff = 0;
- }
-
- return diff;
- }
-
- /**
- * Spin util acquired the lock.
- */
- private void lockForPutMessage() {
- if (this.defaultMessageStore.getMessageStoreConfig().isUseReentrantLockWhenPutMessage()) {
- putMessageNormalLock.lock();
- } else {
- boolean flag;
- do {
- flag = this.putMessageSpinLock.compareAndSet(true, false);
- } while (!flag);
- }
- }
-
- private void releasePutMessageLock() {
- if (this.defaultMessageStore.getMessageStoreConfig().isUseReentrantLockWhenPutMessage()) {
- putMessageNormalLock.unlock();
- } else {
- this.putMessageSpinLock.compareAndSet(false, true);
- }
- }
}
[67/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerStatusSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerStatusSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerStatusSubCommand.java
index e15ce1f..b3f4377 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerStatusSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerStatusSubCommand.java
@@ -16,6 +16,12 @@
*/
package org.apache.rocketmq.tools.command.consumer;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.TreeMap;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.common.MQVersion;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.protocol.body.Connection;
@@ -25,20 +31,12 @@ import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.MQAdminStartup;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.TreeMap;
-
public class ConsumerStatusSubCommand implements SubCommand {
public static void main(String[] args) {
System.setProperty(MixAll.NAMESRV_ADDR_PROPERTY, "127.0.0.1:9876");
- MQAdminStartup.main(new String[]{new ConsumerStatusSubCommand().commandName(), "-g", "benchmark_consumer"});
+ MQAdminStartup.main(new String[] {new ConsumerStatusSubCommand().commandName(), "-g", "benchmark_consumer"});
}
@Override
@@ -86,16 +84,16 @@ public class ConsumerStatusSubCommand implements SubCommand {
for (Connection conn : cc.getConnectionSet()) {
try {
ConsumerRunningInfo consumerRunningInfo =
- defaultMQAdminExt.getConsumerRunningInfo(group, conn.getClientId(), jstack);
+ defaultMQAdminExt.getConsumerRunningInfo(group, conn.getClientId(), jstack);
if (consumerRunningInfo != null) {
criTable.put(conn.getClientId(), consumerRunningInfo);
String filePath = now + "/" + conn.getClientId();
MixAll.string2FileNotSafe(consumerRunningInfo.formatString(), filePath);
System.out.printf("%03d %-40s %-20s %s%n",
- i++,
- conn.getClientId(),
- MQVersion.getVersionDesc(conn.getVersion()),
- filePath);
+ i++,
+ conn.getClientId(),
+ MQVersion.getVersionDesc(conn.getVersion()),
+ filePath);
}
} catch (Exception e) {
e.printStackTrace();
@@ -114,7 +112,7 @@ public class ConsumerStatusSubCommand implements SubCommand {
while (it.hasNext()) {
Entry<String, ConsumerRunningInfo> next = it.next();
String result =
- ConsumerRunningInfo.analyzeProcessQueue(next.getKey(), next.getValue());
+ ConsumerRunningInfo.analyzeProcessQueue(next.getKey(), next.getValue());
if (result.length() > 0) {
System.out.printf(result);
}
@@ -126,7 +124,7 @@ public class ConsumerStatusSubCommand implements SubCommand {
} else {
String clientId = commandLine.getOptionValue('i').trim();
ConsumerRunningInfo consumerRunningInfo =
- defaultMQAdminExt.getConsumerRunningInfo(group, clientId, jstack);
+ defaultMQAdminExt.getConsumerRunningInfo(group, clientId, jstack);
if (consumerRunningInfo != null) {
System.out.printf("%s", consumerRunningInfo.formatString());
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerSubCommand.java
index 6e7cc27..699625d 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerSubCommand.java
@@ -16,6 +16,12 @@
*/
package org.apache.rocketmq.tools.command.consumer;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.TreeMap;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.common.MQVersion;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.protocol.body.Connection;
@@ -25,20 +31,12 @@ import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.MQAdminStartup;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.TreeMap;
-
public class ConsumerSubCommand implements SubCommand {
public static void main(String[] args) {
System.setProperty(MixAll.NAMESRV_ADDR_PROPERTY, "127.0.0.1:9876");
- MQAdminStartup.main(new String[]{new ConsumerSubCommand().commandName(), "-g", "benchmark_consumer"});
+ MQAdminStartup.main(new String[] {new ConsumerSubCommand().commandName(), "-g", "benchmark_consumer"});
}
@Override
@@ -81,20 +79,20 @@ public class ConsumerSubCommand implements SubCommand {
int i = 1;
long now = System.currentTimeMillis();
final TreeMap<String/* clientId */, ConsumerRunningInfo> criTable =
- new TreeMap<String, ConsumerRunningInfo>();
+ new TreeMap<String, ConsumerRunningInfo>();
for (Connection conn : cc.getConnectionSet()) {
try {
ConsumerRunningInfo consumerRunningInfo =
- defaultMQAdminExt.getConsumerRunningInfo(group, conn.getClientId(), jstack);
+ defaultMQAdminExt.getConsumerRunningInfo(group, conn.getClientId(), jstack);
if (consumerRunningInfo != null) {
criTable.put(conn.getClientId(), consumerRunningInfo);
String filePath = now + "/" + conn.getClientId();
MixAll.string2FileNotSafe(consumerRunningInfo.formatString(), filePath);
System.out.printf("%03d %-40s %-20s %s%n",
- i++,
- conn.getClientId(),
- MQVersion.getVersionDesc(conn.getVersion()),
- filePath);
+ i++,
+ conn.getClientId(),
+ MQVersion.getVersionDesc(conn.getVersion()),
+ filePath);
}
} catch (Exception e) {
e.printStackTrace();
@@ -113,7 +111,7 @@ public class ConsumerSubCommand implements SubCommand {
while (it.hasNext()) {
Entry<String, ConsumerRunningInfo> next = it.next();
String result =
- ConsumerRunningInfo.analyzeProcessQueue(next.getKey(), next.getValue());
+ ConsumerRunningInfo.analyzeProcessQueue(next.getKey(), next.getValue());
if (result.length() > 0) {
System.out.printf(result);
}
@@ -125,7 +123,7 @@ public class ConsumerSubCommand implements SubCommand {
} else {
String clientId = commandLine.getOptionValue('i').trim();
ConsumerRunningInfo consumerRunningInfo =
- defaultMQAdminExt.getConsumerRunningInfo(group, clientId, jstack);
+ defaultMQAdminExt.getConsumerRunningInfo(group, clientId, jstack);
if (consumerRunningInfo != null) {
System.out.printf(consumerRunningInfo.formatString());
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/DeleteSubscriptionGroupCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/DeleteSubscriptionGroupCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/DeleteSubscriptionGroupCommand.java
index 0cc5879..75e6b65 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/DeleteSubscriptionGroupCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/DeleteSubscriptionGroupCommand.java
@@ -6,16 +6,20 @@
* (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
+ * 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.
+ * 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.tools.command.consumer;
+import java.util.Set;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.srvutil.ServerUtil;
@@ -23,12 +27,6 @@ import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.CommandUtil;
import org.apache.rocketmq.tools.command.SubCommand;
import org.apache.rocketmq.tools.command.topic.DeleteTopicSubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.Set;
-
public class DeleteSubscriptionGroupCommand implements SubCommand {
@Override
@@ -36,13 +34,11 @@ public class DeleteSubscriptionGroupCommand implements SubCommand {
return "deleteSubGroup";
}
-
@Override
public String commandDesc() {
return "Delete subscription group from broker.";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("b", "brokerAddr", true, "delete subscription group from which broker");
@@ -60,7 +56,6 @@ public class DeleteSubscriptionGroupCommand implements SubCommand {
return options;
}
-
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
DefaultMQAdminExt adminExt = new DefaultMQAdminExt(rpcHook);
@@ -75,7 +70,7 @@ public class DeleteSubscriptionGroupCommand implements SubCommand {
adminExt.deleteSubscriptionGroup(addr, groupName);
System.out.printf("delete subscription group [%s] from broker [%s] success.%n", groupName,
- addr);
+ addr);
return;
} else if (commandLine.hasOption('c')) {
@@ -86,15 +81,15 @@ public class DeleteSubscriptionGroupCommand implements SubCommand {
for (String master : masterSet) {
adminExt.deleteSubscriptionGroup(master, groupName);
System.out.printf(
- "delete subscription group [%s] from broker [%s] in cluster [%s] success.%n",
- groupName, master, clusterName);
+ "delete subscription group [%s] from broker [%s] in cluster [%s] success.%n",
+ groupName, master, clusterName);
}
try {
DeleteTopicSubCommand.deleteTopic(adminExt, clusterName, MixAll.RETRY_GROUP_TOPIC_PREFIX
- + groupName);
+ + groupName);
DeleteTopicSubCommand.deleteTopic(adminExt, clusterName, MixAll.DLQ_GROUP_TOPIC_PREFIX
- + groupName);
+ + groupName);
} catch (Exception e) {
}
return;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/StartMonitoringSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/StartMonitoringSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/StartMonitoringSubCommand.java
index 4d5315b..8bb7c0d 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/StartMonitoringSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/StartMonitoringSubCommand.java
@@ -6,54 +6,49 @@
* (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
+ * 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.
+ * 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.tools.command.consumer;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.client.log.ClientLogger;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.command.SubCommand;
import org.apache.rocketmq.tools.monitor.DefaultMonitorListener;
import org.apache.rocketmq.tools.monitor.MonitorConfig;
import org.apache.rocketmq.tools.monitor.MonitorService;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Options;
import org.slf4j.Logger;
-
public class StartMonitoringSubCommand implements SubCommand {
private final Logger log = ClientLogger.getLog();
-
@Override
public String commandName() {
return "startMonitoring";
}
-
@Override
public String commandDesc() {
return "Start Monitoring";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
return options;
}
-
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
try {
MonitorService monitorService =
- new MonitorService(new MonitorConfig(), new DefaultMonitorListener(), rpcHook);
+ new MonitorService(new MonitorConfig(), new DefaultMonitorListener(), rpcHook);
monitorService.start();
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/UpdateSubGroupSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/UpdateSubGroupSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/UpdateSubGroupSubCommand.java
index 93eb8ec..4ff032e 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/UpdateSubGroupSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/UpdateSubGroupSubCommand.java
@@ -16,18 +16,16 @@
*/
package org.apache.rocketmq.tools.command.consumer;
+import java.util.Set;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.common.subscription.SubscriptionGroupConfig;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.srvutil.ServerUtil;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.CommandUtil;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.Set;
-
public class UpdateSubGroupSubCommand implements SubCommand {
@@ -36,13 +34,11 @@ public class UpdateSubGroupSubCommand implements SubCommand {
return "updateSubGroup";
}
-
@Override
public String commandDesc() {
return "Update or create subscription group";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("b", "brokerAddr", true, "create subscription group to which broker");
@@ -92,7 +88,6 @@ public class UpdateSubGroupSubCommand implements SubCommand {
return options;
}
-
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
@@ -110,31 +105,31 @@ public class UpdateSubGroupSubCommand implements SubCommand {
// consumeEnable
if (commandLine.hasOption('s')) {
subscriptionGroupConfig.setConsumeEnable(Boolean.parseBoolean(commandLine.getOptionValue('s')
- .trim()));
+ .trim()));
}
// consumeFromMinEnable
if (commandLine.hasOption('m')) {
subscriptionGroupConfig.setConsumeFromMinEnable(Boolean.parseBoolean(commandLine
- .getOptionValue('m').trim()));
+ .getOptionValue('m').trim()));
}
// consumeBroadcastEnable
if (commandLine.hasOption('d')) {
subscriptionGroupConfig.setConsumeBroadcastEnable(Boolean.parseBoolean(commandLine
- .getOptionValue('d').trim()));
+ .getOptionValue('d').trim()));
}
// retryQueueNums
if (commandLine.hasOption('q')) {
subscriptionGroupConfig.setRetryQueueNums(Integer.parseInt(commandLine.getOptionValue('q')
- .trim()));
+ .trim()));
}
// retryMaxTimes
if (commandLine.hasOption('r')) {
subscriptionGroupConfig.setRetryMaxTimes(Integer.parseInt(commandLine.getOptionValue('r')
- .trim()));
+ .trim()));
}
// brokerId
@@ -145,13 +140,13 @@ public class UpdateSubGroupSubCommand implements SubCommand {
// whichBrokerWhenConsumeSlowly
if (commandLine.hasOption('w')) {
subscriptionGroupConfig.setWhichBrokerWhenConsumeSlowly(Long.parseLong(commandLine
- .getOptionValue('w').trim()));
+ .getOptionValue('w').trim()));
}
// notifyConsumerIdsChanged
if (commandLine.hasOption('a')) {
subscriptionGroupConfig.setNotifyConsumerIdsChangedEnable(Boolean.parseBoolean(commandLine
- .getOptionValue('a').trim()));
+ .getOptionValue('a').trim()));
}
if (commandLine.hasOption('b')) {
@@ -169,7 +164,7 @@ public class UpdateSubGroupSubCommand implements SubCommand {
defaultMQAdminExt.start();
Set<String> masterSet =
- CommandUtil.fetchMasterAddrByClusterName(defaultMQAdminExt, clusterName);
+ CommandUtil.fetchMasterAddrByClusterName(defaultMQAdminExt, clusterName);
for (String addr : masterSet) {
try {
defaultMQAdminExt.createAndUpdateSubscriptionGroupConfig(addr, subscriptionGroupConfig);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/message/CheckMsgSendRTCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/CheckMsgSendRTCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/CheckMsgSendRTCommand.java
index fb0061e..cade0e0 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/CheckMsgSendRTCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/CheckMsgSendRTCommand.java
@@ -16,6 +16,10 @@
*/
package org.apache.rocketmq.tools.command.message;
+import java.util.List;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.MessageQueueSelector;
import org.apache.rocketmq.common.MixAll;
@@ -23,11 +27,6 @@ import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.List;
public class CheckMsgSendRTCommand implements SubCommand {
private static String brokerName = "";
@@ -72,16 +71,16 @@ public class CheckMsgSendRTCommand implements SubCommand {
boolean sendSuccess = false;
String topic = commandLine.getOptionValue('t').trim();
long amount = !commandLine.hasOption('a') ? 100 : Long.parseLong(commandLine
- .getOptionValue('a').trim());
+ .getOptionValue('a').trim());
long msgSize = !commandLine.hasOption('s') ? 128 : Long.parseLong(commandLine
- .getOptionValue('s').trim());
+ .getOptionValue('s').trim());
Message msg = new Message(topic, getStringBySize(msgSize).getBytes(MixAll.DEFAULT_CHARSET));
System.out.printf("%-32s %-4s %-20s %s%n",
- "#Broker Name",
- "#QID",
- "#Send Result",
- "#RT"
+ "#Broker Name",
+ "#QID",
+ "#Send Result",
+ "#RT"
);
for (int i = 0; i < amount; i++) {
start = System.currentTimeMillis();
@@ -89,7 +88,7 @@ public class CheckMsgSendRTCommand implements SubCommand {
producer.send(msg, new MessageQueueSelector() {
@Override
public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
- int queueIndex = (Integer) arg % mqs.size();
+ int queueIndex = (Integer)arg % mqs.size();
MessageQueue queue = mqs.get(queueIndex);
brokerName = queue.getBrokerName();
queueId = queue.getQueueId();
@@ -103,20 +102,19 @@ public class CheckMsgSendRTCommand implements SubCommand {
end = System.currentTimeMillis();
}
-
if (i != 0) {
timeElapsed += end - start;
}
System.out.printf("%-32s %-4s %-20s %s%n",
- brokerName,
- queueId,
- sendSuccess,
- end - start
+ brokerName,
+ queueId,
+ sendSuccess,
+ end - start
);
}
- double rt = (double) timeElapsed / (amount - 1);
+ double rt = (double)timeElapsed / (amount - 1);
System.out.printf("Avg RT: %s%n", String.format("%.2f", rt));
} catch (Exception e) {
e.printStackTrace();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/message/DecodeMessageIdCommond.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/DecodeMessageIdCommond.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/DecodeMessageIdCommond.java
index 88264b5..40adec9 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/DecodeMessageIdCommond.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/DecodeMessageIdCommond.java
@@ -6,23 +6,23 @@
* (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
+ * 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.
+ * 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.tools.command.message;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.message.MessageClientIDSetter;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
public class DecodeMessageIdCommond implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageByQueueCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageByQueueCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageByQueueCommand.java
index 33e6804..aad1644 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageByQueueCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageByQueueCommand.java
@@ -17,6 +17,17 @@
package org.apache.rocketmq.tools.command.message;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.client.consumer.DefaultMQPullConsumer;
import org.apache.rocketmq.client.consumer.PullResult;
import org.apache.rocketmq.common.MixAll;
@@ -25,33 +36,77 @@ import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.lang3.StringUtils;
-
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
public class PrintMessageByQueueCommand implements SubCommand {
+ public static long timestampFormat(final String value) {
+ long timestamp = 0;
+ try {
+ timestamp = Long.parseLong(value);
+ } catch (NumberFormatException e) {
+
+ timestamp = UtilAll.parseDate(value, UtilAll.YYYY_MM_DD_HH_MM_SS_SSS).getTime();
+ }
+
+ return timestamp;
+ }
+
+ private static void calculateByTag(final List<MessageExt> msgs, final Map<String, AtomicLong> tagCalmap, final boolean calByTag) {
+ if (!calByTag)
+ return;
+
+ for (MessageExt msg : msgs) {
+ String tag = msg.getTags();
+ if (StringUtils.isNotBlank(tag)) {
+ AtomicLong count = tagCalmap.get(tag);
+ if (count == null) {
+ count = new AtomicLong();
+ tagCalmap.put(tag, count);
+ }
+ count.incrementAndGet();
+ }
+ }
+ }
+
+ private static void printCalculateByTag(final Map<String, AtomicLong> tagCalmap, final boolean calByTag) {
+ if (!calByTag)
+ return;
+
+ List<TagCountBean> list = new ArrayList<TagCountBean>();
+ for (Map.Entry<String, AtomicLong> entry : tagCalmap.entrySet()) {
+ TagCountBean tagBean = new TagCountBean(entry.getKey(), entry.getValue());
+ list.add(tagBean);
+ }
+ Collections.sort(list);
+
+ for (TagCountBean tagCountBean : list) {
+ System.out.printf("Tag: %-30s Count: %s%n", tagCountBean.getTag(), tagCountBean.getCount());
+ }
+ }
+
+ public static void printMessage(final List<MessageExt> msgs, final String charsetName, boolean printMsg, boolean printBody) {
+ if (!printMsg)
+ return;
+
+ for (MessageExt msg : msgs) {
+ try {
+ System.out.printf("MSGID: %s %s BODY: %s%n", msg.getMsgId(), msg.toString(),
+ printBody ? new String(msg.getBody(), charsetName) : "NOT PRINT BODY");
+ } catch (UnsupportedEncodingException e) {
+ }
+ }
+ }
+
@Override
public String commandName() {
return "printMsgByQueue";
}
-
@Override
public String commandDesc() {
return "Print Message Detail";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("t", "topic", true, "topic name");
@@ -94,7 +149,6 @@ public class PrintMessageByQueueCommand implements SubCommand {
opt.setRequired(false);
options.addOption(opt);
-
return options;
}
@@ -104,15 +158,15 @@ public class PrintMessageByQueueCommand implements SubCommand {
try {
String charsetName =
- !commandLine.hasOption('c') ? "UTF-8" : commandLine.getOptionValue('c').trim();
+ !commandLine.hasOption('c') ? "UTF-8" : commandLine.getOptionValue('c').trim();
boolean printMsg =
- !commandLine.hasOption('p') ? false : Boolean.parseBoolean(commandLine.getOptionValue('p').trim());
+ !commandLine.hasOption('p') ? false : Boolean.parseBoolean(commandLine.getOptionValue('p').trim());
boolean printBody =
- !commandLine.hasOption('d') ? false : Boolean.parseBoolean(commandLine.getOptionValue('d').trim());
+ !commandLine.hasOption('d') ? false : Boolean.parseBoolean(commandLine.getOptionValue('d').trim());
boolean calByTag =
- !commandLine.hasOption('f') ? false : Boolean.parseBoolean(commandLine.getOptionValue('f').trim());
+ !commandLine.hasOption('f') ? false : Boolean.parseBoolean(commandLine.getOptionValue('f').trim());
String subExpression =
- !commandLine.hasOption('s') ? "*" : commandLine.getOptionValue('s').trim();
+ !commandLine.hasOption('s') ? "*" : commandLine.getOptionValue('s').trim();
String topic = commandLine.getOptionValue('t').trim();
String brokerName = commandLine.getOptionValue('a').trim();
@@ -165,70 +219,10 @@ public class PrintMessageByQueueCommand implements SubCommand {
}
}
- public static long timestampFormat(final String value) {
- long timestamp = 0;
- try {
- timestamp = Long.parseLong(value);
- } catch (NumberFormatException e) {
-
- timestamp = UtilAll.parseDate(value, UtilAll.YYYY_MM_DD_HH_MM_SS_SSS).getTime();
- }
-
- return timestamp;
- }
-
-
- private static void calculateByTag(final List<MessageExt> msgs, final Map<String, AtomicLong> tagCalmap, final boolean calByTag) {
- if (!calByTag)
- return;
-
- for (MessageExt msg : msgs) {
- String tag = msg.getTags();
- if (StringUtils.isNotBlank(tag)) {
- AtomicLong count = tagCalmap.get(tag);
- if (count == null) {
- count = new AtomicLong();
- tagCalmap.put(tag, count);
- }
- count.incrementAndGet();
- }
- }
- }
-
- private static void printCalculateByTag(final Map<String, AtomicLong> tagCalmap, final boolean calByTag) {
- if (!calByTag)
- return;
-
- List<TagCountBean> list = new ArrayList<TagCountBean>();
- for (Map.Entry<String, AtomicLong> entry : tagCalmap.entrySet()) {
- TagCountBean tagBean = new TagCountBean(entry.getKey(), entry.getValue());
- list.add(tagBean);
- }
- Collections.sort(list);
-
- for (TagCountBean tagCountBean : list) {
- System.out.printf("Tag: %-30s Count: %s%n", tagCountBean.getTag(), tagCountBean.getCount());
- }
- }
-
- public static void printMessage(final List<MessageExt> msgs, final String charsetName, boolean printMsg, boolean printBody) {
- if (!printMsg)
- return;
-
- for (MessageExt msg : msgs) {
- try {
- System.out.printf("MSGID: %s %s BODY: %s%n", msg.getMsgId(), msg.toString(),
- printBody ? new String(msg.getBody(), charsetName) : "NOT PRINT BODY");
- } catch (UnsupportedEncodingException e) {
- }
- }
- }
-
static class TagCountBean implements Comparable<TagCountBean> {
private String tag;
private AtomicLong count;
-
public TagCountBean(final String tag, final AtomicLong count) {
this.tag = tag;
this.count = count;
@@ -250,10 +244,9 @@ public class PrintMessageByQueueCommand implements SubCommand {
this.count = count;
}
-
@Override
public int compareTo(final TagCountBean o) {
- return (int) (o.getCount().get() - this.count.get());
+ return (int)(o.getCount().get() - this.count.get());
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageSubCommand.java
index e8c9368..4f87d77 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageSubCommand.java
@@ -16,6 +16,12 @@
*/
package org.apache.rocketmq.tools.command.message;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+import java.util.Set;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.client.consumer.DefaultMQPullConsumer;
import org.apache.rocketmq.client.consumer.PullResult;
import org.apache.rocketmq.common.MixAll;
@@ -24,29 +30,41 @@ import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-import java.util.Set;
+public class PrintMessageSubCommand implements SubCommand {
+
+ public static long timestampFormat(final String value) {
+ long timestamp = 0;
+ try {
+ timestamp = Long.parseLong(value);
+ } catch (NumberFormatException e) {
+ timestamp = UtilAll.parseDate(value, UtilAll.YYYY_MM_DD_HH_MM_SS_SSS).getTime();
+ }
+ return timestamp;
+ }
-public class PrintMessageSubCommand implements SubCommand {
+ public static void printMessage(final List<MessageExt> msgs, final String charsetName, boolean printBody) {
+ for (MessageExt msg : msgs) {
+ try {
+ System.out.printf("MSGID: %s %s BODY: %s%n", msg.getMsgId(), msg.toString(),
+ printBody ? new String(msg.getBody(), charsetName) : "NOT PRINT BODY");
+ } catch (UnsupportedEncodingException e) {
+ //
+ }
+ }
+ }
@Override
public String commandName() {
return "printMsg";
}
-
@Override
public String commandDesc() {
return "Print Message Detail";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("t", "topic", true, "topic name");
@@ -62,20 +80,20 @@ public class PrintMessageSubCommand implements SubCommand {
options.addOption(opt);
opt =
- new Option("b", "beginTimestamp ", true,
- "Begin timestamp[currentTimeMillis|yyyy-MM-dd#HH:mm:ss:SSS]");
+ new Option("b", "beginTimestamp ", true,
+ "Begin timestamp[currentTimeMillis|yyyy-MM-dd#HH:mm:ss:SSS]");
opt.setRequired(false);
options.addOption(opt);
opt =
- new Option("e", "endTimestamp ", true,
- "End timestamp[currentTimeMillis|yyyy-MM-dd#HH:mm:ss:SSS]");
+ new Option("e", "endTimestamp ", true,
+ "End timestamp[currentTimeMillis|yyyy-MM-dd#HH:mm:ss:SSS]");
opt.setRequired(false);
options.addOption(opt);
opt =
- new Option("d", "printBody ", true,
- "print body");
+ new Option("d", "printBody ", true,
+ "print body");
opt.setRequired(false);
options.addOption(opt);
@@ -90,13 +108,13 @@ public class PrintMessageSubCommand implements SubCommand {
String topic = commandLine.getOptionValue('t').trim();
String charsetName = //
- !commandLine.hasOption('c') ? "UTF-8" : commandLine.getOptionValue('c').trim();
+ !commandLine.hasOption('c') ? "UTF-8" : commandLine.getOptionValue('c').trim();
String subExpression = //
- !commandLine.hasOption('s') ? "*" : commandLine.getOptionValue('s').trim();
+ !commandLine.hasOption('s') ? "*" : commandLine.getOptionValue('s').trim();
boolean printBody = //
- !commandLine.hasOption('d') ? true : Boolean.parseBoolean(commandLine.getOptionValue('d').trim());
+ !commandLine.hasOption('d') ? true : Boolean.parseBoolean(commandLine.getOptionValue('d').trim());
consumer.start();
@@ -149,26 +167,4 @@ public class PrintMessageSubCommand implements SubCommand {
consumer.shutdown();
}
}
-
- public static long timestampFormat(final String value) {
- long timestamp = 0;
- try {
- timestamp = Long.parseLong(value);
- } catch (NumberFormatException e) {
- timestamp = UtilAll.parseDate(value, UtilAll.YYYY_MM_DD_HH_MM_SS_SSS).getTime();
- }
-
- return timestamp;
- }
-
- public static void printMessage(final List<MessageExt> msgs, final String charsetName, boolean printBody) {
- for (MessageExt msg : msgs) {
- try {
- System.out.printf("MSGID: %s %s BODY: %s%n", msg.getMsgId(), msg.toString(),
- printBody ? new String(msg.getBody(), charsetName) : "NOT PRINT BODY");
- } catch (UnsupportedEncodingException e) {
- //
- }
- }
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java
index fded7b6..38f9a72 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java
@@ -16,6 +16,15 @@
*/
package org.apache.rocketmq.tools.command.message;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.List;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
@@ -30,19 +39,140 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.admin.api.MessageTrack;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.lang3.StringUtils;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.List;
+public class QueryMsgByIdSubCommand implements SubCommand {
+ public static void queryById(final DefaultMQAdminExt admin, final String msgId) throws MQClientException,
+ RemotingException, MQBrokerException, InterruptedException, IOException {
+ MessageExt msg = admin.viewMessage(msgId);
+ printMsg(admin, msg);
+ }
+
+ public static void printMsg(final DefaultMQAdminExt admin, final MessageExt msg) throws IOException {
+ if (msg == null) {
+ System.out.printf("%nMessage not found!");
+ return;
+ }
+
+ String bodyTmpFilePath = createBodyFile(msg);
+ String msgId = msg.getMsgId();
+ if (msg instanceof MessageClientExt) {
+ msgId = ((MessageClientExt)msg).getOffsetMsgId();
+ }
+
+ System.out.printf("%-20s %s%n",
+ "OffsetID:",
+ msgId
+ );
+
+ System.out.printf("%-20s %s%n",
+ "OffsetID:",
+ msgId
+ );
+
+ System.out.printf("%-20s %s%n",
+ "Topic:",
+ msg.getTopic()
+ );
+
+ System.out.printf("%-20s %s%n",
+ "Tags:",
+ "[" + msg.getTags() + "]"
+ );
+
+ System.out.printf("%-20s %s%n",
+ "Keys:",
+ "[" + msg.getKeys() + "]"
+ );
+
+ System.out.printf("%-20s %d%n",
+ "Queue ID:",
+ msg.getQueueId()
+ );
+
+ System.out.printf("%-20s %d%n",
+ "Queue Offset:",
+ msg.getQueueOffset()
+ );
+
+ System.out.printf("%-20s %d%n",
+ "CommitLog Offset:",
+ msg.getCommitLogOffset()
+ );
+
+ System.out.printf("%-20s %d%n",
+ "Reconsume Times:",
+ msg.getReconsumeTimes()
+ );
+
+ System.out.printf("%-20s %s%n",
+ "Born Timestamp:",
+ UtilAll.timeMillisToHumanString2(msg.getBornTimestamp())
+ );
+
+ System.out.printf("%-20s %s%n",
+ "Store Timestamp:",
+ UtilAll.timeMillisToHumanString2(msg.getStoreTimestamp())
+ );
+
+ System.out.printf("%-20s %s%n",
+ "Born Host:",
+ RemotingHelper.parseSocketAddressAddr(msg.getBornHost())
+ );
+
+ System.out.printf("%-20s %s%n",
+ "Store Host:",
+ RemotingHelper.parseSocketAddressAddr(msg.getStoreHost())
+ );
+
+ System.out.printf("%-20s %d%n",
+ "System Flag:",
+ msg.getSysFlag()
+ );
+
+ System.out.printf("%-20s %s%n",
+ "Properties:",
+ msg.getProperties() != null ? msg.getProperties().toString() : ""
+ );
+
+ System.out.printf("%-20s %s%n",
+ "Message Body Path:",
+ bodyTmpFilePath
+ );
+
+ try {
+ List<MessageTrack> mtdList = admin.messageTrackDetail(msg);
+ if (mtdList.isEmpty()) {
+ System.out.printf("%n%nWARN: No Consumer");
+ } else {
+ System.out.printf("%n%n");
+ for (MessageTrack mt : mtdList) {
+ System.out.printf("%s", mt);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static String createBodyFile(MessageExt msg) throws IOException {
+ DataOutputStream dos = null;
+ try {
+ String bodyTmpFilePath = "/tmp/rocketmq/msgbodys";
+ File file = new File(bodyTmpFilePath);
+ if (!file.exists()) {
+ file.mkdirs();
+ }
+ bodyTmpFilePath = bodyTmpFilePath + "/" + msg.getMsgId();
+ dos = new DataOutputStream(new FileOutputStream(bodyTmpFilePath));
+ dos.write(msg.getBody());
+ return bodyTmpFilePath;
+ } finally {
+ if (dos != null)
+ dos.close();
+ }
+ }
-public class QueryMsgByIdSubCommand implements SubCommand {
@Override
public String commandName() {
return "queryMsgById";
@@ -134,14 +264,15 @@ public class QueryMsgByIdSubCommand implements SubCommand {
private void pushMsg(final DefaultMQAdminExt defaultMQAdminExt, final String consumerGroup, final String clientId, final String msgId) {
try {
ConsumeMessageDirectlyResult result =
- defaultMQAdminExt.consumeMessageDirectly(consumerGroup, clientId, msgId);
+ defaultMQAdminExt.consumeMessageDirectly(consumerGroup, clientId, msgId);
System.out.printf("%s", result);
} catch (Exception e) {
e.printStackTrace();
}
}
- private void sendMsg(final DefaultMQAdminExt defaultMQAdminExt, final DefaultMQProducer defaultMQProducer, final String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ private void sendMsg(final DefaultMQAdminExt defaultMQAdminExt, final DefaultMQProducer defaultMQProducer,
+ final String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
try {
MessageExt msg = defaultMQAdminExt.viewMessage(msgId);
if (msg != null) {
@@ -156,136 +287,4 @@ public class QueryMsgByIdSubCommand implements SubCommand {
e.printStackTrace();
}
}
-
- public static void queryById(final DefaultMQAdminExt admin, final String msgId) throws MQClientException,
- RemotingException, MQBrokerException, InterruptedException, IOException {
- MessageExt msg = admin.viewMessage(msgId);
-
- printMsg(admin, msg);
- }
-
- public static void printMsg(final DefaultMQAdminExt admin, final MessageExt msg) throws IOException {
- if (msg == null) {
- System.out.printf("%nMessage not found!");
- return;
- }
-
- String bodyTmpFilePath = createBodyFile(msg);
- String msgId = msg.getMsgId();
- if (msg instanceof MessageClientExt) {
- msgId = ((MessageClientExt) msg).getOffsetMsgId();
- }
-
- System.out.printf("%-20s %s%n",
- "OffsetID:",
- msgId
- );
-
- System.out.printf("%-20s %s%n",
- "OffsetID:",
- msgId
- );
-
- System.out.printf("%-20s %s%n",
- "Topic:",
- msg.getTopic()
- );
-
- System.out.printf("%-20s %s%n",
- "Tags:",
- "[" + msg.getTags() + "]"
- );
-
- System.out.printf("%-20s %s%n",
- "Keys:",
- "[" + msg.getKeys() + "]"
- );
-
- System.out.printf("%-20s %d%n",
- "Queue ID:",
- msg.getQueueId()
- );
-
- System.out.printf("%-20s %d%n",
- "Queue Offset:",
- msg.getQueueOffset()
- );
-
- System.out.printf("%-20s %d%n",
- "CommitLog Offset:",
- msg.getCommitLogOffset()
- );
-
- System.out.printf("%-20s %d%n",
- "Reconsume Times:",
- msg.getReconsumeTimes()
- );
-
- System.out.printf("%-20s %s%n",
- "Born Timestamp:",
- UtilAll.timeMillisToHumanString2(msg.getBornTimestamp())
- );
-
- System.out.printf("%-20s %s%n",
- "Store Timestamp:",
- UtilAll.timeMillisToHumanString2(msg.getStoreTimestamp())
- );
-
- System.out.printf("%-20s %s%n",
- "Born Host:",
- RemotingHelper.parseSocketAddressAddr(msg.getBornHost())
- );
-
- System.out.printf("%-20s %s%n",
- "Store Host:",
- RemotingHelper.parseSocketAddressAddr(msg.getStoreHost())
- );
-
- System.out.printf("%-20s %d%n",
- "System Flag:",
- msg.getSysFlag()
- );
-
- System.out.printf("%-20s %s%n",
- "Properties:",
- msg.getProperties() != null ? msg.getProperties().toString() : ""
- );
-
- System.out.printf("%-20s %s%n",
- "Message Body Path:",
- bodyTmpFilePath
- );
-
- try {
- List<MessageTrack> mtdList = admin.messageTrackDetail(msg);
- if (mtdList.isEmpty()) {
- System.out.printf("%n%nWARN: No Consumer");
- } else {
- System.out.printf("%n%n");
- for (MessageTrack mt : mtdList) {
- System.out.printf("%s", mt);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private static String createBodyFile(MessageExt msg) throws IOException {
- DataOutputStream dos = null;
- try {
- String bodyTmpFilePath = "/tmp/rocketmq/msgbodys";
- File file = new File(bodyTmpFilePath);
- if (!file.exists()) {
- file.mkdirs();
- }
- bodyTmpFilePath = bodyTmpFilePath + "/" + msg.getMsgId();
- dos = new DataOutputStream(new FileOutputStream(bodyTmpFilePath));
- dos.write(msg.getBody());
- return bodyTmpFilePath;
- } finally {
- if (dos != null)
- dos.close();
- }
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java
index ebfc80e..159bd6e 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java
@@ -6,26 +6,25 @@
* (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
+ * 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.
+ * 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.tools.command.message;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.client.QueryResult;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
/**
*
@@ -75,14 +74,14 @@ public class QueryMsgByKeySubCommand implements SubCommand {
}
void queryByKey(final DefaultMQAdminExt admin, final String topic, final String key)
- throws MQClientException, InterruptedException {
+ throws MQClientException, InterruptedException {
admin.start();
QueryResult queryResult = admin.queryMessage(topic, key, 64, 0, Long.MAX_VALUE);
System.out.printf("%-50s %4s %40s%n",
- "#Message ID",
- "#QID",
- "#Offset");
+ "#Message ID",
+ "#QID",
+ "#Offset");
for (MessageExt msg : queryResult.getMessageList()) {
System.out.printf("%-50s %4d %40d%n", msg.getMsgId(), msg.getQueueId(), msg.getQueueOffset());
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByOffsetSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByOffsetSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByOffsetSubCommand.java
index fc5fd56..2133636 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByOffsetSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByOffsetSubCommand.java
@@ -16,6 +16,9 @@
*/
package org.apache.rocketmq.tools.command.message;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.client.consumer.DefaultMQPullConsumer;
import org.apache.rocketmq.client.consumer.PullResult;
import org.apache.rocketmq.common.MixAll;
@@ -23,10 +26,6 @@ import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
public class QueryMsgByOffsetSubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByUniqueKeySubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByUniqueKeySubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByUniqueKeySubCommand.java
index 4e4bd61..2a6904e 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByUniqueKeySubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByUniqueKeySubCommand.java
@@ -16,6 +16,14 @@
*/
package org.apache.rocketmq.tools.command.message;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.List;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.UtilAll;
@@ -27,125 +35,83 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.admin.api.MessageTrack;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.List;
public class QueryMsgByUniqueKeySubCommand implements SubCommand {
- @Override
- public String commandName() {
- return "queryMsgByUniqueKey";
- }
-
- @Override
- public String commandDesc() {
- return "Query Message by Unique key";
- }
-
- @Override
- public Options buildCommandlineOptions(Options options) {
- Option opt = new Option("i", "msgId", true, "Message Id");
- opt.setRequired(true);
- options.addOption(opt);
-
- opt = new Option("g", "consumerGroup", true, "consumer group name");
- opt.setRequired(false);
- options.addOption(opt);
-
- opt = new Option("d", "clientId", true, "The consumer's client id");
- opt.setRequired(false);
- options.addOption(opt);
-
- opt = new Option("t", "topic", true, "The topic of msg");
- opt.setRequired(true);
- options.addOption(opt);
-
- return options;
- }
-
-
public static void queryById(final DefaultMQAdminExt admin, final String topic, final String msgId) throws MQClientException,
- RemotingException, MQBrokerException, InterruptedException, IOException {
+ RemotingException, MQBrokerException, InterruptedException, IOException {
MessageExt msg = admin.viewMessage(topic, msgId);
-
String bodyTmpFilePath = createBodyFile(msg);
System.out.printf("%-20s %s%n",
- "Topic:",
- msg.getTopic()
+ "Topic:",
+ msg.getTopic()
);
System.out.printf("%-20s %s%n",
- "Tags:",
- "[" + msg.getTags() + "]"
+ "Tags:",
+ "[" + msg.getTags() + "]"
);
System.out.printf("%-20s %s%n",
- "Keys:",
- "[" + msg.getKeys() + "]"
+ "Keys:",
+ "[" + msg.getKeys() + "]"
);
System.out.printf("%-20s %d%n",
- "Queue ID:",
- msg.getQueueId()
+ "Queue ID:",
+ msg.getQueueId()
);
System.out.printf("%-20s %d%n",
- "Queue Offset:",
- msg.getQueueOffset()
+ "Queue Offset:",
+ msg.getQueueOffset()
);
System.out.printf("%-20s %d%n",
- "CommitLog Offset:",
- msg.getCommitLogOffset()
+ "CommitLog Offset:",
+ msg.getCommitLogOffset()
);
System.out.printf("%-20s %d%n",
- "Reconsume Times:",
- msg.getReconsumeTimes()
+ "Reconsume Times:",
+ msg.getReconsumeTimes()
);
System.out.printf("%-20s %s%n",
- "Born Timestamp:",
- UtilAll.timeMillisToHumanString2(msg.getBornTimestamp())
+ "Born Timestamp:",
+ UtilAll.timeMillisToHumanString2(msg.getBornTimestamp())
);
System.out.printf("%-20s %s%n",
- "Store Timestamp:",
- UtilAll.timeMillisToHumanString2(msg.getStoreTimestamp())
+ "Store Timestamp:",
+ UtilAll.timeMillisToHumanString2(msg.getStoreTimestamp())
);
System.out.printf("%-20s %s%n",
- "Born Host:",
- RemotingHelper.parseSocketAddressAddr(msg.getBornHost())
+ "Born Host:",
+ RemotingHelper.parseSocketAddressAddr(msg.getBornHost())
);
System.out.printf("%-20s %s%n",
- "Store Host:",
- RemotingHelper.parseSocketAddressAddr(msg.getStoreHost())
+ "Store Host:",
+ RemotingHelper.parseSocketAddressAddr(msg.getStoreHost())
);
System.out.printf("%-20s %d%n",
- "System Flag:",
- msg.getSysFlag()
+ "System Flag:",
+ msg.getSysFlag()
);
System.out.printf("%-20s %s%n",
- "Properties:",
- msg.getProperties() != null ? msg.getProperties().toString() : ""
+ "Properties:",
+ msg.getProperties() != null ? msg.getProperties().toString() : ""
);
System.out.printf("%-20s %s%n",
- "Message Body Path:",
- bodyTmpFilePath
+ "Message Body Path:",
+ bodyTmpFilePath
);
try {
@@ -163,6 +129,54 @@ public class QueryMsgByUniqueKeySubCommand implements SubCommand {
}
}
+ private static String createBodyFile(MessageExt msg) throws IOException {
+ DataOutputStream dos = null;
+ try {
+ String bodyTmpFilePath = "/tmp/rocketmq/msgbodys";
+ File file = new File(bodyTmpFilePath);
+ if (!file.exists()) {
+ file.mkdirs();
+ }
+ bodyTmpFilePath = bodyTmpFilePath + "/" + msg.getMsgId();
+ dos = new DataOutputStream(new FileOutputStream(bodyTmpFilePath));
+ dos.write(msg.getBody());
+ return bodyTmpFilePath;
+ } finally {
+ if (dos != null)
+ dos.close();
+ }
+ }
+
+ @Override
+ public String commandName() {
+ return "queryMsgByUniqueKey";
+ }
+
+ @Override
+ public String commandDesc() {
+ return "Query Message by Unique key";
+ }
+
+ @Override
+ public Options buildCommandlineOptions(Options options) {
+ Option opt = new Option("i", "msgId", true, "Message Id");
+ opt.setRequired(true);
+ options.addOption(opt);
+
+ opt = new Option("g", "consumerGroup", true, "consumer group name");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+ opt = new Option("d", "clientId", true, "The consumer's client id");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+ opt = new Option("t", "topic", true, "The topic of msg");
+ opt.setRequired(true);
+ options.addOption(opt);
+
+ return options;
+ }
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
@@ -178,7 +192,7 @@ public class QueryMsgByUniqueKeySubCommand implements SubCommand {
final String consumerGroup = commandLine.getOptionValue('g').trim();
final String clientId = commandLine.getOptionValue('d').trim();
ConsumeMessageDirectlyResult result =
- defaultMQAdminExt.consumeMessageDirectly(consumerGroup, clientId, topic, msgId);
+ defaultMQAdminExt.consumeMessageDirectly(consumerGroup, clientId, topic, msgId);
System.out.printf("%s", result);
} else {
queryById(defaultMQAdminExt, topic, msgId);
@@ -189,23 +203,4 @@ public class QueryMsgByUniqueKeySubCommand implements SubCommand {
defaultMQAdminExt.shutdown();
}
}
-
-
- private static String createBodyFile(MessageExt msg) throws IOException {
- DataOutputStream dos = null;
- try {
- String bodyTmpFilePath = "/tmp/rocketmq/msgbodys";
- File file = new File(bodyTmpFilePath);
- if (!file.exists()) {
- file.mkdirs();
- }
- bodyTmpFilePath = bodyTmpFilePath + "/" + msg.getMsgId();
- dos = new DataOutputStream(new FileOutputStream(bodyTmpFilePath));
- dos.write(msg.getBody());
- return bodyTmpFilePath;
- } finally {
- if (dos != null)
- dos.close();
- }
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/message/Store.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/Store.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/Store.java
index ee923c6..e25c61f 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/Store.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/Store.java
@@ -17,19 +17,18 @@
package org.apache.rocketmq.tools.command.message;
-import org.apache.rocketmq.common.MixAll;
-import org.apache.rocketmq.store.ConsumeQueue;
-import org.apache.rocketmq.store.MappedFile;
-import org.apache.rocketmq.store.MappedFileQueue;
-import org.apache.rocketmq.store.SelectMappedBufferResult;
-import org.apache.rocketmq.store.config.StorePathConfigHelper;
-
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.store.ConsumeQueue;
+import org.apache.rocketmq.store.MappedFile;
+import org.apache.rocketmq.store.MappedFileQueue;
+import org.apache.rocketmq.store.SelectMappedBufferResult;
+import org.apache.rocketmq.store.config.StorePathConfigHelper;
public class Store {
public final static int MESSAGE_MAGIC_CODE = 0xAABBCCDD ^ 1880681586 + 8;
@@ -49,7 +48,7 @@ public class Store {
this.lSize = lSize;
mapedFileQueue = new MappedFileQueue(cStorePath, cSize, null);
consumeQueueTable =
- new ConcurrentHashMap<String/* topic */, ConcurrentHashMap<Integer/* queueId */, ConsumeQueue>>();
+ new ConcurrentHashMap<String/* topic */, ConcurrentHashMap<Integer/* queueId */, ConsumeQueue>>();
}
public boolean load() {
@@ -75,11 +74,11 @@ public class Store {
for (File fileQueueId : fileQueueIdList) {
int queueId = Integer.parseInt(fileQueueId.getName());
ConsumeQueue logic = new ConsumeQueue(
- topic,
- queueId,
- StorePathConfigHelper.getStorePathConsumeQueue(lStorePath),
- lSize,
- null);
+ topic,
+ queueId,
+ StorePathConfigHelper.getStorePathConsumeQueue(lStorePath),
+ lSize,
+ null);
this.putConsumeQueue(topic, queueId, logic);
if (!logic.load()) {
return false;
@@ -92,7 +91,6 @@ public class Store {
return true;
}
-
private void putConsumeQueue(final String topic, final int queueId, final ConsumeQueue consumeQueue) {
ConcurrentHashMap<Integer/* queueId */, ConsumeQueue> map = this.consumeQueueTable.get(topic);
if (null == map) {
@@ -181,16 +179,14 @@ public class Store {
e.printStackTrace();
}
-
Date storeTime = new Date(storeTimestamp);
-
long currentPhyOffset = startOffset + position;
if (physicOffset != currentPhyOffset) {
System.out.printf(storeTime
- + " [fetal error] physicOffset != currentPhyOffset. position=" + position
- + ", msgCount=" + msgCount + ", physicOffset=" + physicOffset
- + ", currentPhyOffset=" + currentPhyOffset);
+ + " [fetal error] physicOffset != currentPhyOffset. position=" + position
+ + ", msgCount=" + msgCount + ", physicOffset=" + physicOffset
+ + ", currentPhyOffset=" + currentPhyOffset);
errorCount++;
if (!openAll) {
success = false;
@@ -205,8 +201,8 @@ public class Store {
int sizePy = smb.getByteBuffer().getInt();
if (physicOffset != offsetPy) {
System.out.printf(storeTime + " [fetal error] physicOffset != offsetPy. position="
- + position + ", msgCount=" + msgCount + ", physicOffset=" + physicOffset
- + ", offsetPy=" + offsetPy);
+ + position + ", msgCount=" + msgCount + ", physicOffset=" + physicOffset
+ + ", offsetPy=" + offsetPy);
errorCount++;
if (!openAll) {
success = false;
@@ -215,8 +211,8 @@ public class Store {
}
if (totalSize != sizePy) {
System.out.printf(storeTime + " [fetal error] totalSize != sizePy. position="
- + position + ", msgCount=" + msgCount + ", totalSize=" + totalSize
- + ", sizePy=" + sizePy);
+ + position + ", msgCount=" + msgCount + ", totalSize=" + totalSize
+ + ", sizePy=" + sizePy);
errorCount++;
if (!openAll) {
success = false;
@@ -233,7 +229,7 @@ public class Store {
}
System.out.printf("end travel " + mapedFile.getFileName() + ", total msg=" + msgCount
- + ", error count=" + errorCount + ", cost:" + (System.currentTimeMillis() - startTime));
+ + ", error count=" + errorCount + ", cost:" + (System.currentTimeMillis() - startTime));
}
System.out.printf("travel " + (success ? "ok" : "fail"));
@@ -243,7 +239,7 @@ public class Store {
ConcurrentHashMap<Integer, ConsumeQueue> map = consumeQueueTable.get(topic);
if (null == map) {
ConcurrentHashMap<Integer, ConsumeQueue> newMap =
- new ConcurrentHashMap<Integer, ConsumeQueue>(128);
+ new ConcurrentHashMap<Integer, ConsumeQueue>(128);
ConcurrentHashMap<Integer, ConsumeQueue> oldMap = consumeQueueTable.putIfAbsent(topic, newMap);
if (oldMap != null) {
map = oldMap;
@@ -254,11 +250,11 @@ public class Store {
ConsumeQueue logic = map.get(queueId);
if (null == logic) {
ConsumeQueue newLogic = new ConsumeQueue(
- topic,
- queueId,
- StorePathConfigHelper.getStorePathConsumeQueue(lStorePath),
- lSize,
- null);
+ topic,
+ queueId,
+ StorePathConfigHelper.getStorePathConsumeQueue(lStorePath),
+ lSize,
+ null);
ConsumeQueue oldLogic = map.putIfAbsent(queueId, newLogic);
if (oldLogic != null) {
logic = oldLogic;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/DeleteKvConfigCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/DeleteKvConfigCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/DeleteKvConfigCommand.java
index 0ae8f44..b4fb7dd 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/DeleteKvConfigCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/DeleteKvConfigCommand.java
@@ -6,23 +6,22 @@
* (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
+ * 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.
+ * 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.tools.command.namesrv;
-import org.apache.rocketmq.remoting.RPCHook;
-import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
-import org.apache.rocketmq.tools.command.SubCommand;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
-
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
+import org.apache.rocketmq.tools.command.SubCommand;
/**
*
@@ -34,13 +33,11 @@ public class DeleteKvConfigCommand implements SubCommand {
return "deleteKvConfig";
}
-
@Override
public String commandDesc() {
return "Delete KV config.";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("s", "namespace", true, "set the namespace");
@@ -53,7 +50,6 @@ public class DeleteKvConfigCommand implements SubCommand {
return options;
}
-
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/GetNamesrvConfigCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/GetNamesrvConfigCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/GetNamesrvConfigCommand.java
index b2c95d3..f4c95d3 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/GetNamesrvConfigCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/GetNamesrvConfigCommand.java
@@ -6,27 +6,26 @@
* (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
+ * 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.
+ * 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.tools.command.namesrv;
-import org.apache.rocketmq.remoting.RPCHook;
-import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
-import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Options;
-
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Options;
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
+import org.apache.rocketmq.tools.command.SubCommand;
public class GetNamesrvConfigCommand implements SubCommand {
@@ -67,7 +66,7 @@ public class GetNamesrvConfigCommand implements SubCommand {
for (String server : nameServerConfigs.keySet()) {
System.out.printf("============%s============\n",
- server);
+ server);
for (Object key : nameServerConfigs.get(server).keySet()) {
System.out.printf("%-50s= %s\n", key, nameServerConfigs.get(server).get(key));
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateKvConfigCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateKvConfigCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateKvConfigCommand.java
index a2d4f43..9d5f7a9 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateKvConfigCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateKvConfigCommand.java
@@ -6,23 +6,22 @@
* (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
+ * 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.
+ * 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.tools.command.namesrv;
-import org.apache.rocketmq.remoting.RPCHook;
-import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
-import org.apache.rocketmq.tools.command.SubCommand;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
-
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
+import org.apache.rocketmq.tools.command.SubCommand;
/**
*
@@ -34,13 +33,11 @@ public class UpdateKvConfigCommand implements SubCommand {
return "updateKvConfig";
}
-
@Override
public String commandDesc() {
return "Create or update KV config.";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("s", "namespace", true, "set the namespace");
@@ -57,7 +54,6 @@ public class UpdateKvConfigCommand implements SubCommand {
return options;
}
-
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateNamesrvConfigCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateNamesrvConfigCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateNamesrvConfigCommand.java
index c6517d6..807636c 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateNamesrvConfigCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateNamesrvConfigCommand.java
@@ -6,27 +6,26 @@
* (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
+ * 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.
+ * 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.tools.command.namesrv;
-import org.apache.rocketmq.remoting.RPCHook;
-import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
-import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
+import org.apache.rocketmq.tools.command.SubCommand;
public class UpdateNamesrvConfigCommand implements SubCommand {
@Override
@@ -80,7 +79,7 @@ public class UpdateNamesrvConfigCommand implements SubCommand {
defaultMQAdminExt.updateNameServerConfig(properties, serverList);
System.out.printf("update name server config success!%s\n%s : %s\n",
- serverList == null ? "" : serverList, key, value);
+ serverList == null ? "" : serverList, key, value);
return;
} catch (Exception e) {
e.printStackTrace();
[84/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java b/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
index 6e0e379..42b7a82 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
@@ -16,11 +16,40 @@
*/
package org.apache.rocketmq.client.impl.factory;
+import java.io.UnsupportedEncodingException;
+import java.net.DatagramSocket;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
import org.apache.rocketmq.client.ClientConfig;
import org.apache.rocketmq.client.admin.MQAdminExtInner;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
-import org.apache.rocketmq.client.impl.*;
+import org.apache.rocketmq.client.impl.ClientRemotingProcessor;
+import org.apache.rocketmq.client.impl.FindBrokerResult;
+import org.apache.rocketmq.client.impl.MQAdminImpl;
+import org.apache.rocketmq.client.impl.MQClientAPIImpl;
+import org.apache.rocketmq.client.impl.MQClientManager;
+import org.apache.rocketmq.client.impl.consumer.DefaultMQPullConsumerImpl;
+import org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl;
+import org.apache.rocketmq.client.impl.consumer.MQConsumerInner;
+import org.apache.rocketmq.client.impl.consumer.ProcessQueue;
+import org.apache.rocketmq.client.impl.consumer.PullMessageService;
+import org.apache.rocketmq.client.impl.consumer.RebalanceService;
import org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl;
import org.apache.rocketmq.client.impl.producer.MQProducerInner;
import org.apache.rocketmq.client.impl.producer.TopicPublishInfo;
@@ -36,7 +65,11 @@ import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
-import org.apache.rocketmq.common.protocol.heartbeat.*;
+import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
+import org.apache.rocketmq.common.protocol.heartbeat.ConsumerData;
+import org.apache.rocketmq.common.protocol.heartbeat.HeartbeatData;
+import org.apache.rocketmq.common.protocol.heartbeat.ProducerData;
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
import org.apache.rocketmq.common.protocol.route.BrokerData;
import org.apache.rocketmq.common.protocol.route.QueueData;
import org.apache.rocketmq.common.protocol.route.TopicRouteData;
@@ -45,19 +78,8 @@ import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.apache.rocketmq.remoting.exception.RemotingException;
import org.apache.rocketmq.remoting.netty.NettyClientConfig;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-import org.apache.rocketmq.client.impl.consumer.*;
import org.slf4j.Logger;
-import java.io.UnsupportedEncodingException;
-import java.net.DatagramSocket;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-
public class MQClientInstance {
private final static long LOCK_TIMEOUT_MILLIS = 3000;
private final Logger log = ClientLogger.getLog();
@@ -75,7 +97,7 @@ public class MQClientInstance {
private final Lock lockNamesrv = new ReentrantLock();
private final Lock lockHeartbeat = new ReentrantLock();
private final ConcurrentHashMap<String/* Broker Name */, HashMap<Long/* brokerId */, String/* address */>> brokerAddrTable =
- new ConcurrentHashMap<String, HashMap<Long, String>>();
+ new ConcurrentHashMap<String, HashMap<Long, String>>();
private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
@@ -92,12 +114,10 @@ public class MQClientInstance {
private DatagramSocket datagramSocket;
private Random random = new Random();
-
public MQClientInstance(ClientConfig clientConfig, int instanceIndex, String clientId) {
this(clientConfig, instanceIndex, clientId, null);
}
-
public MQClientInstance(ClientConfig clientConfig, int instanceIndex, String clientId, RPCHook rpcHook) {
this.clientConfig = clientConfig;
this.instanceIndex = instanceIndex;
@@ -125,10 +145,74 @@ public class MQClientInstance {
this.consumerStatsManager = new ConsumerStatsManager(this.scheduledExecutorService);
log.info("created a new client Instance, FactoryIndex: {} ClinetID: {} {} {}, serializeType={}", //
- this.instanceIndex, //
- this.clientId, //
- this.clientConfig, //
- MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION), RemotingCommand.getSerializeTypeConfigInThisServer());
+ this.instanceIndex, //
+ this.clientId, //
+ this.clientConfig, //
+ MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION), RemotingCommand.getSerializeTypeConfigInThisServer());
+ }
+
+ public static TopicPublishInfo topicRouteData2TopicPublishInfo(final String topic, final TopicRouteData route) {
+ TopicPublishInfo info = new TopicPublishInfo();
+ info.setTopicRouteData(route);
+ if (route.getOrderTopicConf() != null && route.getOrderTopicConf().length() > 0) {
+ String[] brokers = route.getOrderTopicConf().split(";");
+ for (String broker : brokers) {
+ String[] item = broker.split(":");
+ int nums = Integer.parseInt(item[1]);
+ for (int i = 0; i < nums; i++) {
+ MessageQueue mq = new MessageQueue(topic, item[0], i);
+ info.getMessageQueueList().add(mq);
+ }
+ }
+
+ info.setOrderTopic(true);
+ } else {
+ List<QueueData> qds = route.getQueueDatas();
+ Collections.sort(qds);
+ for (QueueData qd : qds) {
+ if (PermName.isWriteable(qd.getPerm())) {
+ BrokerData brokerData = null;
+ for (BrokerData bd : route.getBrokerDatas()) {
+ if (bd.getBrokerName().equals(qd.getBrokerName())) {
+ brokerData = bd;
+ break;
+ }
+ }
+
+ if (null == brokerData) {
+ continue;
+ }
+
+ if (!brokerData.getBrokerAddrs().containsKey(MixAll.MASTER_ID)) {
+ continue;
+ }
+
+ for (int i = 0; i < qd.getWriteQueueNums(); i++) {
+ MessageQueue mq = new MessageQueue(topic, qd.getBrokerName(), i);
+ info.getMessageQueueList().add(mq);
+ }
+ }
+ }
+
+ info.setOrderTopic(false);
+ }
+
+ return info;
+ }
+
+ public static Set<MessageQueue> topicRouteData2TopicSubscribeInfo(final String topic, final TopicRouteData route) {
+ Set<MessageQueue> mqList = new HashSet<MessageQueue>();
+ List<QueueData> qds = route.getQueueDatas();
+ for (QueueData qd : qds) {
+ if (PermName.isReadable(qd.getPerm())) {
+ for (int i = 0; i < qd.getReadQueueNums(); i++) {
+ MessageQueue mq = new MessageQueue(topic, qd.getBrokerName(), i);
+ mqList.add(mq);
+ }
+ }
+ }
+
+ return mqList;
}
public void start() throws MQClientException {
@@ -166,7 +250,6 @@ public class MQClientInstance {
}
}
-
private void startScheduledTask() {
if (null == this.clientConfig.getNamesrvAddr()) {
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@@ -353,7 +436,7 @@ public class MQClientInstance {
if (impl != null) {
try {
if (impl instanceof DefaultMQPushConsumerImpl) {
- DefaultMQPushConsumerImpl dmq = (DefaultMQPushConsumerImpl) impl;
+ DefaultMQPushConsumerImpl dmq = (DefaultMQPushConsumerImpl)impl;
dmq.adjustThreadPool();
}
} catch (Exception e) {
@@ -420,7 +503,7 @@ public class MQClientInstance {
log.error("send heart beat to broker exception", e);
} else {
log.info("send heart beat to broker[{} {} {}] exception, because the broker not up, forget it", brokerName,
- id, addr);
+ id, addr);
}
}
}
@@ -460,7 +543,7 @@ public class MQClientInstance {
TopicRouteData topicRouteData;
if (isDefault && defaultMQProducer != null) {
topicRouteData = this.mQClientAPIImpl.getDefaultTopicRouteInfoFromNameServer(defaultMQProducer.getCreateTopicKey(),
- 1000 * 3);
+ 1000 * 3);
if (topicRouteData != null) {
for (QueueData data : topicRouteData.getQueueDatas()) {
int queueNums = Math.min(defaultMQProducer.getDefaultTopicQueueNums(), data.getReadQueueNums());
@@ -559,7 +642,6 @@ public class MQClientInstance {
}
}
-
// Producer
for (Map.Entry<String/* group */, MQProducerInner> entry : this.producerTable.entrySet()) {
MQProducerInner impl = entry.getValue();
@@ -590,7 +672,7 @@ public class MQClientInstance {
}
private void uploadFilterClassToAllFilterServer(final String consumerGroup, final String fullClassName, final String topic,
- final String filterClassSource) throws UnsupportedEncodingException {
+ final String filterClassSource) throws UnsupportedEncodingException {
byte[] classBody = null;
int classCRC = 0;
try {
@@ -598,13 +680,13 @@ public class MQClientInstance {
classCRC = UtilAll.crc32(classBody);
} catch (Exception e1) {
log.warn("uploadFilterClassToAllFilterServer Exception, ClassName: {} {}", //
- fullClassName, //
- RemotingHelper.exceptionSimpleDesc(e1));
+ fullClassName, //
+ RemotingHelper.exceptionSimpleDesc(e1));
}
TopicRouteData topicRouteData = this.topicRouteTable.get(topic);
if (topicRouteData != null //
- && topicRouteData.getFilterServerTable() != null && !topicRouteData.getFilterServerTable().isEmpty()) {
+ && topicRouteData.getFilterServerTable() != null && !topicRouteData.getFilterServerTable().isEmpty()) {
Iterator<Entry<String, List<String>>> it = topicRouteData.getFilterServerTable().entrySet().iterator();
while (it.hasNext()) {
Entry<String, List<String>> next = it.next();
@@ -612,10 +694,10 @@ public class MQClientInstance {
for (final String fsAddr : value) {
try {
this.mQClientAPIImpl.registerMessageFilterClass(fsAddr, consumerGroup, topic, fullClassName, classCRC, classBody,
- 5000);
+ 5000);
log.info("register message class filter to {} OK, ConsumerGroup: {} Topic: {} ClassName: {}", fsAddr, consumerGroup,
- topic, fullClassName);
+ topic, fullClassName);
} catch (Exception e) {
log.error("uploadFilterClassToAllFilterServer Exception", e);
@@ -624,7 +706,7 @@ public class MQClientInstance {
}
} else {
log.warn("register message class filter failed, because no filter server, ConsumerGroup: {} Topic: {} ClassName: {}",
- consumerGroup, topic, fullClassName);
+ consumerGroup, topic, fullClassName);
}
}
@@ -668,70 +750,6 @@ public class MQClientInstance {
return result;
}
- public static TopicPublishInfo topicRouteData2TopicPublishInfo(final String topic, final TopicRouteData route) {
- TopicPublishInfo info = new TopicPublishInfo();
- info.setTopicRouteData(route);
- if (route.getOrderTopicConf() != null && route.getOrderTopicConf().length() > 0) {
- String[] brokers = route.getOrderTopicConf().split(";");
- for (String broker : brokers) {
- String[] item = broker.split(":");
- int nums = Integer.parseInt(item[1]);
- for (int i = 0; i < nums; i++) {
- MessageQueue mq = new MessageQueue(topic, item[0], i);
- info.getMessageQueueList().add(mq);
- }
- }
-
- info.setOrderTopic(true);
- } else {
- List<QueueData> qds = route.getQueueDatas();
- Collections.sort(qds);
- for (QueueData qd : qds) {
- if (PermName.isWriteable(qd.getPerm())) {
- BrokerData brokerData = null;
- for (BrokerData bd : route.getBrokerDatas()) {
- if (bd.getBrokerName().equals(qd.getBrokerName())) {
- brokerData = bd;
- break;
- }
- }
-
- if (null == brokerData) {
- continue;
- }
-
- if (!brokerData.getBrokerAddrs().containsKey(MixAll.MASTER_ID)) {
- continue;
- }
-
- for (int i = 0; i < qd.getWriteQueueNums(); i++) {
- MessageQueue mq = new MessageQueue(topic, qd.getBrokerName(), i);
- info.getMessageQueueList().add(mq);
- }
- }
- }
-
- info.setOrderTopic(false);
- }
-
- return info;
- }
-
- public static Set<MessageQueue> topicRouteData2TopicSubscribeInfo(final String topic, final TopicRouteData route) {
- Set<MessageQueue> mqList = new HashSet<MessageQueue>();
- List<QueueData> qds = route.getQueueDatas();
- for (QueueData qd : qds) {
- if (PermName.isReadable(qd.getPerm())) {
- for (int i = 0; i < qd.getReadQueueNums(); i++) {
- MessageQueue mq = new MessageQueue(topic, qd.getBrokerName(), i);
- mqList.add(mq);
- }
- }
- }
-
- return mqList;
- }
-
public void shutdown() {
// Consumer
if (!this.consumerTable.isEmpty())
@@ -824,7 +842,7 @@ public class MQClientInstance {
try {
this.mQClientAPIImpl.unregisterClient(addr, this.clientId, producerGroup, consumerGroup, 3000);
log.info("unregister client[Producer: {} Consumer: {}] from broker[{} {} {}] success", producerGroup,
- consumerGroup, brokerName, entry1.getKey(), addr);
+ consumerGroup, brokerName, entry1.getKey(), addr);
} catch (RemotingException e) {
log.error("unregister client exception from broker: " + addr, e);
} catch (MQBrokerException e) {
@@ -942,9 +960,9 @@ public class MQClientInstance {
}
public FindBrokerResult findBrokerAddressInSubscribe(//
- final String brokerName, //
- final long brokerId, //
- final boolean onlyThisBroker//
+ final String brokerName, //
+ final long brokerId, //
+ final boolean onlyThisBroker//
) {
String brokerAddr = null;
boolean slave = false;
@@ -1008,7 +1026,7 @@ public class MQClientInstance {
try {
MQConsumerInner impl = this.consumerTable.get(group);
if (impl != null && impl instanceof DefaultMQPushConsumerImpl) {
- consumer = (DefaultMQPushConsumerImpl) impl;
+ consumer = (DefaultMQPushConsumerImpl)impl;
} else {
log.info("[reset-offset] consumer dose not exist. group={}", group);
return;
@@ -1053,10 +1071,10 @@ public class MQClientInstance {
public Map<MessageQueue, Long> getConsumerStatus(String topic, String group) {
MQConsumerInner impl = this.consumerTable.get(group);
if (impl != null && impl instanceof DefaultMQPushConsumerImpl) {
- DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) impl;
+ DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl)impl;
return consumer.getOffsetStore().cloneOffsetTable(topic);
} else if (impl != null && impl instanceof DefaultMQPullConsumerImpl) {
- DefaultMQPullConsumerImpl consumer = (DefaultMQPullConsumerImpl) impl;
+ DefaultMQPullConsumerImpl consumer = (DefaultMQPullConsumerImpl)impl;
return consumer.getOffsetStore().cloneOffsetTable(topic);
} else {
return Collections.EMPTY_MAP;
@@ -1096,11 +1114,11 @@ public class MQClientInstance {
}
public ConsumeMessageDirectlyResult consumeMessageDirectly(final MessageExt msg, //
- final String consumerGroup, //
- final String brokerName) {
+ final String consumerGroup, //
+ final String brokerName) {
MQConsumerInner mqConsumerInner = this.consumerTable.get(consumerGroup);
if (null != mqConsumerInner) {
- DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) mqConsumerInner;
+ DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl)mqConsumerInner;
ConsumeMessageDirectlyResult result = consumer.getConsumeMessageService().consumeMessageDirectly(msg, brokerName);
return result;
@@ -1109,7 +1127,6 @@ public class MQClientInstance {
return null;
}
-
public ConsumerRunningInfo consumerRunningInfo(final String consumerGroup) {
MQConsumerInner mqConsumerInner = this.consumerTable.get(consumerGroup);
@@ -1128,12 +1145,11 @@ public class MQClientInstance {
consumerRunningInfo.getProperties().put(ConsumerRunningInfo.PROP_NAMESERVER_ADDR, nsAddr);
consumerRunningInfo.getProperties().put(ConsumerRunningInfo.PROP_CONSUME_TYPE, mqConsumerInner.consumeType().name());
consumerRunningInfo.getProperties().put(ConsumerRunningInfo.PROP_CLIENT_VERSION,
- MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION));
+ MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION));
return consumerRunningInfo;
}
-
public ConsumerStatsManager getConsumerStatsManager() {
return consumerStatsManager;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
index b53fa19..42bf360 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
@@ -16,6 +16,20 @@
*/
package org.apache.rocketmq.client.impl.producer;
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
import org.apache.rocketmq.client.QueryResult;
import org.apache.rocketmq.client.Validators;
import org.apache.rocketmq.client.common.ClientErrorCode;
@@ -30,11 +44,29 @@ import org.apache.rocketmq.client.impl.MQClientManager;
import org.apache.rocketmq.client.impl.factory.MQClientInstance;
import org.apache.rocketmq.client.latency.MQFaultStrategy;
import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.client.producer.DefaultMQProducer;
+import org.apache.rocketmq.client.producer.LocalTransactionExecuter;
+import org.apache.rocketmq.client.producer.LocalTransactionState;
+import org.apache.rocketmq.client.producer.MessageQueueSelector;
+import org.apache.rocketmq.client.producer.SendCallback;
+import org.apache.rocketmq.client.producer.SendResult;
+import org.apache.rocketmq.client.producer.SendStatus;
+import org.apache.rocketmq.client.producer.TransactionCheckListener;
+import org.apache.rocketmq.client.producer.TransactionMQProducer;
+import org.apache.rocketmq.client.producer.TransactionSendResult;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.ServiceState;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.help.FAQUrl;
-import org.apache.rocketmq.common.message.*;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageAccessor;
+import org.apache.rocketmq.common.message.MessageClientIDSetter;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageDecoder;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageId;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.message.MessageType;
import org.apache.rocketmq.common.protocol.ResponseCode;
import org.apache.rocketmq.common.protocol.header.CheckTransactionStateRequestHeader;
import org.apache.rocketmq.common.protocol.header.EndTransactionRequestHeader;
@@ -45,21 +77,14 @@ import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.apache.rocketmq.remoting.exception.RemotingConnectException;
import org.apache.rocketmq.remoting.exception.RemotingException;
import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
-import org.apache.rocketmq.client.producer.*;
import org.slf4j.Logger;
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.util.*;
-import java.util.concurrent.*;
-
-
public class DefaultMQProducerImpl implements MQProducerInner {
private final Logger log = ClientLogger.getLog();
private final Random random = new Random();
private final DefaultMQProducer defaultMQProducer;
private final ConcurrentHashMap<String/* topic */, TopicPublishInfo> topicPublishInfoTable =
- new ConcurrentHashMap<String, TopicPublishInfo>();
+ new ConcurrentHashMap<String, TopicPublishInfo>();
private final ArrayList<SendMessageHook> sendMessageHookList = new ArrayList<SendMessageHook>();
private final RPCHook rpcHook;
protected BlockingQueue<Runnable> checkRequestQueue;
@@ -71,12 +96,10 @@ public class DefaultMQProducerImpl implements MQProducerInner {
private MQFaultStrategy mqFaultStrategy = new MQFaultStrategy();
-
public DefaultMQProducerImpl(final DefaultMQProducer defaultMQProducer) {
this(defaultMQProducer, null);
}
-
public DefaultMQProducerImpl(final DefaultMQProducer defaultMQProducer, RPCHook rpcHook) {
this.defaultMQProducer = defaultMQProducer;
this.rpcHook = rpcHook;
@@ -85,18 +108,18 @@ public class DefaultMQProducerImpl implements MQProducerInner {
public void registerCheckForbiddenHook(CheckForbiddenHook checkForbiddenHook) {
this.checkForbiddenHookList.add(checkForbiddenHook);
log.info("register a new checkForbiddenHook. hookName={}, allHookSize={}", checkForbiddenHook.hookName(),
- checkForbiddenHookList.size());
+ checkForbiddenHookList.size());
}
public void initTransactionEnv() {
- TransactionMQProducer producer = (TransactionMQProducer) this.defaultMQProducer;
+ TransactionMQProducer producer = (TransactionMQProducer)this.defaultMQProducer;
this.checkRequestQueue = new LinkedBlockingQueue<Runnable>(producer.getCheckRequestHoldMax());
this.checkExecutor = new ThreadPoolExecutor(//
- producer.getCheckThreadPoolMinSize(), //
- producer.getCheckThreadPoolMaxSize(), //
- 1000 * 60, //
- TimeUnit.MILLISECONDS, //
- this.checkRequestQueue);
+ producer.getCheckThreadPoolMinSize(), //
+ producer.getCheckThreadPoolMaxSize(), //
+ 1000 * 60, //
+ TimeUnit.MILLISECONDS, //
+ this.checkRequestQueue);
}
public void destroyTransactionEnv() {
@@ -130,8 +153,8 @@ public class DefaultMQProducerImpl implements MQProducerInner {
if (!registerOK) {
this.serviceState = ServiceState.CREATE_JUST;
throw new MQClientException("The producer group[" + this.defaultMQProducer.getProducerGroup()
- + "] has been created before, specify another name please." + FAQUrl.suggestTodo(FAQUrl.GROUP_NAME_DUPLICATE_URL),
- null);
+ + "] has been created before, specify another name please." + FAQUrl.suggestTodo(FAQUrl.GROUP_NAME_DUPLICATE_URL),
+ null);
}
this.topicPublishInfoTable.put(this.defaultMQProducer.getCreateTopicKey(), new TopicPublishInfo());
@@ -141,16 +164,16 @@ public class DefaultMQProducerImpl implements MQProducerInner {
}
log.info("the producer [{}] start OK. sendMessageWithVIPChannel={}", this.defaultMQProducer.getProducerGroup(),
- this.defaultMQProducer.isSendMessageWithVIPChannel());
+ this.defaultMQProducer.isSendMessageWithVIPChannel());
this.serviceState = ServiceState.RUNNING;
break;
case RUNNING:
case START_FAILED:
case SHUTDOWN_ALREADY:
throw new MQClientException("The producer service state not OK, maybe started once, "//
- + this.serviceState//
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
- null);
+ + this.serviceState//
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
+ null);
default:
break;
}
@@ -167,7 +190,7 @@ public class DefaultMQProducerImpl implements MQProducerInner {
if (this.defaultMQProducer.getProducerGroup().equals(MixAll.DEFAULT_PRODUCER_GROUP)) {
throw new MQClientException("producerGroup can not equal " + MixAll.DEFAULT_PRODUCER_GROUP + ", please specify another one.",
- null);
+ null);
}
}
@@ -215,7 +238,7 @@ public class DefaultMQProducerImpl implements MQProducerInner {
@Override
public TransactionCheckListener checkListener() {
if (this.defaultMQProducer instanceof TransactionMQProducer) {
- TransactionMQProducer producer = (TransactionMQProducer) defaultMQProducer;
+ TransactionMQProducer producer = (TransactionMQProducer)defaultMQProducer;
return producer.getTransactionCheckListener();
}
@@ -230,7 +253,6 @@ public class DefaultMQProducerImpl implements MQProducerInner {
private final CheckTransactionStateRequestHeader checkRequestHeader = header;
private final String group = DefaultMQProducerImpl.this.defaultMQProducer.getProducerGroup();
-
@Override
public void run() {
TransactionCheckListener transactionCheckListener = DefaultMQProducerImpl.this.checkListener();
@@ -245,19 +267,18 @@ public class DefaultMQProducerImpl implements MQProducerInner {
}
this.processTransactionState(//
- localTransactionState, //
- group, //
- exception);
+ localTransactionState, //
+ group, //
+ exception);
} else {
log.warn("checkTransactionState, pick transactionCheckListener by group[{}] failed", group);
}
}
-
private void processTransactionState(//
- final LocalTransactionState localTransactionState, //
- final String producerGroup, //
- final Throwable exception) {
+ final LocalTransactionState localTransactionState, //
+ final String producerGroup, //
+ final Throwable exception) {
final EndTransactionRequestHeader thisHeader = new EndTransactionRequestHeader();
thisHeader.setCommitLogOffset(checkRequestHeader.getCommitLogOffset());
thisHeader.setProducerGroup(producerGroup);
@@ -293,7 +314,7 @@ public class DefaultMQProducerImpl implements MQProducerInner {
try {
DefaultMQProducerImpl.this.mQClientFactory.getMQClientAPIImpl().endTransactionOneway(brokerAddr, thisHeader, remark,
- 3000);
+ 3000);
} catch (Exception e) {
log.error("endTransactionOneway exception", e);
}
@@ -332,9 +353,9 @@ public class DefaultMQProducerImpl implements MQProducerInner {
private void makeSureStateOK() throws MQClientException {
if (this.serviceState != ServiceState.RUNNING) {
throw new MQClientException("The producer service state not OK, "//
- + this.serviceState//
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
- null);
+ + this.serviceState//
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
+ null);
}
}
@@ -370,13 +391,13 @@ public class DefaultMQProducerImpl implements MQProducerInner {
}
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
- throws MQClientException, InterruptedException {
+ throws MQClientException, InterruptedException {
this.makeSureStateOK();
return this.mQClientFactory.getMQAdminImpl().queryMessage(topic, key, maxNum, begin, end);
}
public MessageExt queryMessageByUniqKey(String topic, String uniqKey)
- throws MQClientException, InterruptedException {
+ throws MQClientException, InterruptedException {
this.makeSureStateOK();
return this.mQClientFactory.getMQAdminImpl().queryMessageByUniqKey(topic, uniqKey);
}
@@ -389,7 +410,7 @@ public class DefaultMQProducerImpl implements MQProducerInner {
}
public void send(Message msg, SendCallback sendCallback, long timeout)
- throws MQClientException, RemotingException, InterruptedException {
+ throws MQClientException, RemotingException, InterruptedException {
try {
this.sendDefaultImpl(msg, CommunicationMode.ASYNC, sendCallback, timeout);
} catch (MQBrokerException e) {
@@ -406,10 +427,10 @@ public class DefaultMQProducerImpl implements MQProducerInner {
}
private SendResult sendDefaultImpl(//
- Message msg, //
- final CommunicationMode communicationMode, //
- final SendCallback sendCallback, //
- final long timeout//
+ Message msg, //
+ final CommunicationMode communicationMode, //
+ final SendCallback sendCallback, //
+ final long timeout//
) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
this.makeSureStateOK();
Validators.checkMessage(msg, this.defaultMQProducer);
@@ -508,16 +529,16 @@ public class DefaultMQProducerImpl implements MQProducerInner {
}
String info = String.format("Send [%d] times, still failed, cost [%d]ms, Topic: %s, BrokersSent: %s",
- times,
- System.currentTimeMillis() - beginTimestampFirst,
- msg.getTopic(),
- Arrays.toString(brokersSent));
+ times,
+ System.currentTimeMillis() - beginTimestampFirst,
+ msg.getTopic(),
+ Arrays.toString(brokersSent));
info += FAQUrl.suggestTodo(FAQUrl.SEND_MSG_FAILED);
MQClientException mqClientException = new MQClientException(info, exception);
if (exception instanceof MQBrokerException) {
- mqClientException.setResponseCode(((MQBrokerException) exception).getResponseCode());
+ mqClientException.setResponseCode(((MQBrokerException)exception).getResponseCode());
} else if (exception instanceof RemotingConnectException) {
mqClientException.setResponseCode(ClientErrorCode.CONNECT_BROKER_EXCEPTION);
} else if (exception instanceof RemotingTimeoutException) {
@@ -532,11 +553,11 @@ public class DefaultMQProducerImpl implements MQProducerInner {
List<String> nsList = this.getmQClientFactory().getMQClientAPIImpl().getNameServerAddressList();
if (null == nsList || nsList.isEmpty()) {
throw new MQClientException(
- "No name server address, please set it." + FAQUrl.suggestTodo(FAQUrl.NAME_SERVER_ADDR_NOT_EXIST_URL), null).setResponseCode(ClientErrorCode.NO_NAME_SERVER_EXCEPTION);
+ "No name server address, please set it." + FAQUrl.suggestTodo(FAQUrl.NAME_SERVER_ADDR_NOT_EXIST_URL), null).setResponseCode(ClientErrorCode.NO_NAME_SERVER_EXCEPTION);
}
throw new MQClientException("No route info of this topic, " + msg.getTopic() + FAQUrl.suggestTodo(FAQUrl.NO_TOPIC_ROUTE_INFO),
- null).setResponseCode(ClientErrorCode.NOT_FOUND_TOPIC_EXCEPTION);
+ null).setResponseCode(ClientErrorCode.NOT_FOUND_TOPIC_EXCEPTION);
}
private TopicPublishInfo tryToFindTopicPublishInfo(final String topic) {
@@ -557,11 +578,11 @@ public class DefaultMQProducerImpl implements MQProducerInner {
}
private SendResult sendKernelImpl(final Message msg, //
- final MessageQueue mq, //
- final CommunicationMode communicationMode, //
- final SendCallback sendCallback, //
- final TopicPublishInfo topicPublishInfo, //
- final long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ final MessageQueue mq, //
+ final CommunicationMode communicationMode, //
+ final SendCallback sendCallback, //
+ final TopicPublishInfo topicPublishInfo, //
+ final long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(mq.getBrokerName());
if (null == brokerAddr) {
tryToFindTopicPublishInfo(mq.getTopic());
@@ -649,30 +670,30 @@ public class DefaultMQProducerImpl implements MQProducerInner {
switch (communicationMode) {
case ASYNC:
sendResult = this.mQClientFactory.getMQClientAPIImpl().sendMessage(//
- brokerAddr, // 1
- mq.getBrokerName(), // 2
- msg, // 3
- requestHeader, // 4
- timeout, // 5
- communicationMode, // 6
- sendCallback, // 7
- topicPublishInfo, // 8
- this.mQClientFactory, // 9
- this.defaultMQProducer.getRetryTimesWhenSendAsyncFailed(), // 10
- context, //
- this);
+ brokerAddr, // 1
+ mq.getBrokerName(), // 2
+ msg, // 3
+ requestHeader, // 4
+ timeout, // 5
+ communicationMode, // 6
+ sendCallback, // 7
+ topicPublishInfo, // 8
+ this.mQClientFactory, // 9
+ this.defaultMQProducer.getRetryTimesWhenSendAsyncFailed(), // 10
+ context, //
+ this);
break;
case ONEWAY:
case SYNC:
sendResult = this.mQClientFactory.getMQClientAPIImpl().sendMessage(
- brokerAddr,
- mq.getBrokerName(),
- msg,
- requestHeader,
- timeout,
- communicationMode,
- context,
- this);
+ brokerAddr,
+ mq.getBrokerName(),
+ msg,
+ requestHeader,
+ timeout,
+ communicationMode,
+ context,
+ this);
break;
default:
assert false;
@@ -790,12 +811,12 @@ public class DefaultMQProducerImpl implements MQProducerInner {
* KERNEL SYNC -------------------------------------------------------
*/
public SendResult send(Message msg, MessageQueue mq)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return send(msg, mq, this.defaultMQProducer.getSendMsgTimeout());
}
public SendResult send(Message msg, MessageQueue mq, long timeout)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
this.makeSureStateOK();
Validators.checkMessage(msg, this.defaultMQProducer);
@@ -810,12 +831,12 @@ public class DefaultMQProducerImpl implements MQProducerInner {
* KERNEL ASYNC -------------------------------------------------------
*/
public void send(Message msg, MessageQueue mq, SendCallback sendCallback)
- throws MQClientException, RemotingException, InterruptedException {
+ throws MQClientException, RemotingException, InterruptedException {
send(msg, mq, sendCallback, this.defaultMQProducer.getSendMsgTimeout());
}
public void send(Message msg, MessageQueue mq, SendCallback sendCallback, long timeout)
- throws MQClientException, RemotingException, InterruptedException {
+ throws MQClientException, RemotingException, InterruptedException {
this.makeSureStateOK();
Validators.checkMessage(msg, this.defaultMQProducer);
@@ -848,21 +869,21 @@ public class DefaultMQProducerImpl implements MQProducerInner {
* SELECT SYNC -------------------------------------------------------
*/
public SendResult send(Message msg, MessageQueueSelector selector, Object arg)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return send(msg, selector, arg, this.defaultMQProducer.getSendMsgTimeout());
}
public SendResult send(Message msg, MessageQueueSelector selector, Object arg, long timeout)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.sendSelectImpl(msg, selector, arg, CommunicationMode.SYNC, null, timeout);
}
private SendResult sendSelectImpl(//
- Message msg, //
- MessageQueueSelector selector, //
- Object arg, //
- final CommunicationMode communicationMode, //
- final SendCallback sendCallback, final long timeout//
+ Message msg, //
+ MessageQueueSelector selector, //
+ Object arg, //
+ final CommunicationMode communicationMode, //
+ final SendCallback sendCallback, final long timeout//
) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
this.makeSureStateOK();
Validators.checkMessage(msg, this.defaultMQProducer);
@@ -890,12 +911,12 @@ public class DefaultMQProducerImpl implements MQProducerInner {
* SELECT ASYNC -------------------------------------------------------
*/
public void send(Message msg, MessageQueueSelector selector, Object arg, SendCallback sendCallback)
- throws MQClientException, RemotingException, InterruptedException {
+ throws MQClientException, RemotingException, InterruptedException {
send(msg, selector, arg, sendCallback, this.defaultMQProducer.getSendMsgTimeout());
}
public void send(Message msg, MessageQueueSelector selector, Object arg, SendCallback sendCallback, long timeout)
- throws MQClientException, RemotingException, InterruptedException {
+ throws MQClientException, RemotingException, InterruptedException {
try {
this.sendSelectImpl(msg, selector, arg, CommunicationMode.ASYNC, sendCallback, timeout);
} catch (MQBrokerException e) {
@@ -907,7 +928,7 @@ public class DefaultMQProducerImpl implements MQProducerInner {
* SELECT ONEWAY -------------------------------------------------------
*/
public void sendOneway(Message msg, MessageQueueSelector selector, Object arg)
- throws MQClientException, RemotingException, InterruptedException {
+ throws MQClientException, RemotingException, InterruptedException {
try {
this.sendSelectImpl(msg, selector, arg, CommunicationMode.ONEWAY, null, this.defaultMQProducer.getSendMsgTimeout());
} catch (MQBrokerException e) {
@@ -916,7 +937,7 @@ public class DefaultMQProducerImpl implements MQProducerInner {
}
public TransactionSendResult sendMessageInTransaction(final Message msg, final LocalTransactionExecuter tranExecuter, final Object arg)
- throws MQClientException {
+ throws MQClientException {
if (null == tranExecuter) {
throw new MQClientException("tranExecutor is null", null);
}
@@ -988,9 +1009,9 @@ public class DefaultMQProducerImpl implements MQProducerInner {
}
public void endTransaction(//
- final SendResult sendResult, //
- final LocalTransactionState localTransactionState, //
- final Throwable localException) throws RemotingException, MQBrokerException, InterruptedException, UnknownHostException {
+ final SendResult sendResult, //
+ final LocalTransactionState localTransactionState, //
+ final Throwable localException) throws RemotingException, MQBrokerException, InterruptedException, UnknownHostException {
final MessageId id;
if (sendResult.getOffsetMsgId() != null) {
id = MessageDecoder.decodeMessageId(sendResult.getOffsetMsgId());
@@ -1021,7 +1042,7 @@ public class DefaultMQProducerImpl implements MQProducerInner {
requestHeader.setMsgId(sendResult.getMsgId());
String remark = localException != null ? ("executeLocalTransactionBranch exception: " + localException.toString()) : null;
this.mQClientFactory.getMQClientAPIImpl().endTransactionOneway(brokerAddr, requestHeader, remark,
- this.defaultMQProducer.getSendMsgTimeout());
+ this.defaultMQProducer.getSendMsgTimeout());
}
public SendResult send(Message msg, long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
@@ -1036,17 +1057,14 @@ public class DefaultMQProducerImpl implements MQProducerInner {
return zipCompressLevel;
}
-
public void setZipCompressLevel(int zipCompressLevel) {
this.zipCompressLevel = zipCompressLevel;
}
-
public ServiceState getServiceState() {
return serviceState;
}
-
public void setServiceState(ServiceState serviceState) {
this.serviceState = serviceState;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java b/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java
index cac77ae..cf61326 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java
@@ -6,41 +6,34 @@
* (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
+ * 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.
+ * 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.impl.producer;
+import java.util.Set;
import org.apache.rocketmq.client.producer.TransactionCheckListener;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.protocol.header.CheckTransactionStateRequestHeader;
-import java.util.Set;
-
-
public interface MQProducerInner {
Set<String> getPublishTopicList();
-
boolean isPublishTopicNeedUpdate(final String topic);
-
TransactionCheckListener checkListener();
-
void checkTransactionState(//
- final String addr, //
- final MessageExt msg, //
- final CheckTransactionStateRequestHeader checkRequestHeader);
-
+ final String addr, //
+ final MessageExt msg, //
+ final CheckTransactionStateRequestHeader checkRequestHeader);
void updateTopicPublishInfo(final String topic, final TopicPublishInfo info);
-
boolean isUnitMode();
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java b/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
index dca20cb..c6f9d45 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
@@ -16,15 +16,13 @@
*/
package org.apache.rocketmq.client.impl.producer;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.rocketmq.client.common.ThreadLocalIndex;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.route.QueueData;
import org.apache.rocketmq.common.protocol.route.TopicRouteData;
-import java.util.ArrayList;
-import java.util.List;
-
-
public class TopicPublishInfo {
private boolean orderTopic = false;
private boolean haveTopicRouterInfo = false;
@@ -32,7 +30,6 @@ public class TopicPublishInfo {
private volatile ThreadLocalIndex sendWhichQueue = new ThreadLocalIndex(0);
private TopicRouteData topicRouteData;
-
public boolean isOrderTopic() {
return orderTopic;
}
@@ -49,32 +46,26 @@ public class TopicPublishInfo {
return messageQueueList;
}
-
public void setMessageQueueList(List<MessageQueue> messageQueueList) {
this.messageQueueList = messageQueueList;
}
-
public ThreadLocalIndex getSendWhichQueue() {
return sendWhichQueue;
}
-
public void setSendWhichQueue(ThreadLocalIndex sendWhichQueue) {
this.sendWhichQueue = sendWhichQueue;
}
-
public boolean isHaveTopicRouterInfo() {
return haveTopicRouterInfo;
}
-
public void setHaveTopicRouterInfo(boolean haveTopicRouterInfo) {
this.haveTopicRouterInfo = haveTopicRouterInfo;
}
-
public MessageQueue selectOneMessageQueue(final String lastBrokerName) {
if (lastBrokerName == null) {
return selectOneMessageQueue();
@@ -93,7 +84,6 @@ public class TopicPublishInfo {
}
}
-
public MessageQueue selectOneMessageQueue() {
int index = this.sendWhichQueue.getAndIncrement();
int pos = Math.abs(index) % this.messageQueueList.size();
@@ -113,11 +103,10 @@ public class TopicPublishInfo {
return -1;
}
-
@Override
public String toString() {
return "TopicPublishInfo [orderTopic=" + orderTopic + ", messageQueueList=" + messageQueueList
- + ", sendWhichQueue=" + sendWhichQueue + ", haveTopicRouterInfo=" + haveTopicRouterInfo + "]";
+ + ", sendWhichQueue=" + sendWhichQueue + ", haveTopicRouterInfo=" + haveTopicRouterInfo + "]";
}
public TopicRouteData getTopicRouteData() {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java b/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
index 12dac4b..b61d855 100644
--- a/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
@@ -17,13 +17,12 @@
package org.apache.rocketmq.client.latency;
-import org.apache.rocketmq.client.common.ThreadLocalIndex;
-
import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
+import org.apache.rocketmq.client.common.ThreadLocalIndex;
public class LatencyFaultToleranceImpl implements LatencyFaultTolerance<String> {
private final ConcurrentHashMap<String, FaultItem> faultItemTable = new ConcurrentHashMap<String, FaultItem>(16);
@@ -89,6 +88,14 @@ public class LatencyFaultToleranceImpl implements LatencyFaultTolerance<String>
return null;
}
+ @Override
+ public String toString() {
+ return "LatencyFaultToleranceImpl{" +
+ "faultItemTable=" + faultItemTable +
+ ", whichItemWorst=" + whichItemWorst +
+ '}';
+ }
+
class FaultItem implements Comparable<FaultItem> {
private final String name;
private volatile long currentLatency;
@@ -101,9 +108,11 @@ public class LatencyFaultToleranceImpl implements LatencyFaultTolerance<String>
@Override
public int compareTo(final FaultItem other) {
if (this.isAvailable() != other.isAvailable()) {
- if (this.isAvailable()) return -1;
+ if (this.isAvailable())
+ return -1;
- if (other.isAvailable()) return 1;
+ if (other.isAvailable())
+ return 1;
}
if (this.currentLatency < other.currentLatency)
@@ -128,20 +137,24 @@ public class LatencyFaultToleranceImpl implements LatencyFaultTolerance<String>
@Override
public int hashCode() {
int result = getName() != null ? getName().hashCode() : 0;
- result = 31 * result + (int) (getCurrentLatency() ^ (getCurrentLatency() >>> 32));
- result = 31 * result + (int) (getStartTimestamp() ^ (getStartTimestamp() >>> 32));
+ result = 31 * result + (int)(getCurrentLatency() ^ (getCurrentLatency() >>> 32));
+ result = 31 * result + (int)(getStartTimestamp() ^ (getStartTimestamp() >>> 32));
return result;
}
@Override
public boolean equals(final Object o) {
- if (this == o) return true;
- if (!(o instanceof FaultItem)) return false;
+ if (this == o)
+ return true;
+ if (!(o instanceof FaultItem))
+ return false;
- final FaultItem faultItem = (FaultItem) o;
+ final FaultItem faultItem = (FaultItem)o;
- if (getCurrentLatency() != faultItem.getCurrentLatency()) return false;
- if (getStartTimestamp() != faultItem.getStartTimestamp()) return false;
+ if (getCurrentLatency() != faultItem.getCurrentLatency())
+ return false;
+ if (getStartTimestamp() != faultItem.getStartTimestamp())
+ return false;
return getName() != null ? getName().equals(faultItem.getName()) : faultItem.getName() == null;
}
@@ -149,10 +162,10 @@ public class LatencyFaultToleranceImpl implements LatencyFaultTolerance<String>
@Override
public String toString() {
return "FaultItem{" +
- "name='" + name + '\'' +
- ", currentLatency=" + currentLatency +
- ", startTimestamp=" + startTimestamp +
- '}';
+ "name='" + name + '\'' +
+ ", currentLatency=" + currentLatency +
+ ", startTimestamp=" + startTimestamp +
+ '}';
}
public String getName() {
@@ -175,14 +188,5 @@ public class LatencyFaultToleranceImpl implements LatencyFaultTolerance<String>
this.startTimestamp = startTimestamp;
}
-
- }
-
- @Override
- public String toString() {
- return "LatencyFaultToleranceImpl{" +
- "faultItemTable=" + faultItemTable +
- ", whichItemWorst=" + whichItemWorst +
- '}';
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java b/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java
index cdfd5d1..70758dc 100644
--- a/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java
+++ b/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java
@@ -25,8 +25,8 @@ public class MQFaultStrategy {
private boolean sendLatencyFaultEnable = false;
- private long[] latencyMax = {50L, 100L, 550L, 1000L, 2000L, 3000L, 15000L};
- private long[] notAvailableDuration = {0L, 0L, 30000L, 60000L, 120000L, 180000L, 600000L};
+ private long[] latencyMax = {50L, 100L, 550L, 1000L, 2000L, 3000L, 15000L};
+ private long[] notAvailableDuration = {0L, 0L, 30000L, 60000L, 120000L, 180000L, 600000L};
public long[] getNotAvailableDuration() {
return notAvailableDuration;
@@ -97,7 +97,8 @@ public class MQFaultStrategy {
private long computeNotAvailableDuration(final long currentLatency) {
for (int i = latencyMax.length - 1; i >= 0; i--) {
- if (currentLatency >= latencyMax[i]) return this.notAvailableDuration[i];
+ if (currentLatency >= latencyMax[i])
+ return this.notAvailableDuration[i];
}
return 0;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java b/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java
index 3055119..7a05e76 100644
--- a/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java
+++ b/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java
@@ -16,38 +16,35 @@
*/
package org.apache.rocketmq.client.log;
+import java.lang.reflect.Method;
+import java.net.URL;
import org.apache.rocketmq.common.constant.LoggerName;
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.lang.reflect.Method;
-import java.net.URL;
-
-
public class ClientLogger {
- private static Logger log;
public static final String CLIENT_LOG_ROOT = "rocketmq.client.logRoot";
public static final String CLIENT_LOG_MAXINDEX = "rocketmq.client.logFileMaxIndex";
public static final String CLIENT_LOG_LEVEL = "rocketmq.client.logLevel";
+ private static Logger log;
static {
log = createLogger(LoggerName.CLIENT_LOGGER_NAME);
}
-
private static Logger createLogger(final String loggerName) {
String logConfigFilePath =
- System.getProperty("rocketmq.client.log.configFile",
- System.getenv("ROCKETMQ_CLIENT_LOG_CONFIGFILE"));
+ System.getProperty("rocketmq.client.log.configFile",
+ System.getenv("ROCKETMQ_CLIENT_LOG_CONFIGFILE"));
Boolean isloadconfig =
- Boolean.parseBoolean(System.getProperty("rocketmq.client.log.loadconfig", "true"));
+ Boolean.parseBoolean(System.getProperty("rocketmq.client.log.loadconfig", "true"));
final String log4JResourceFile =
- System.getProperty("rocketmq.client.log4j.resource.fileName", "log4j_rocketmq_client.xml");
+ System.getProperty("rocketmq.client.log4j.resource.fileName", "log4j_rocketmq_client.xml");
final String logbackResourceFile =
- System.getProperty("rocketmq.client.logback.resource.fileName", "logback_rocketmq_client.xml");
+ System.getProperty("rocketmq.client.logback.resource.fileName", "logback_rocketmq_client.xml");
String clientLogRoot = System.getProperty(CLIENT_LOG_ROOT, "${user.home}/logs/rocketmqlogs");
System.setProperty("client.logRoot", clientLogRoot);
@@ -85,11 +82,11 @@ public class ClientLogger {
if (null == logConfigFilePath) {
URL url = ClientLogger.class.getClassLoader().getResource(logbackResourceFile);
Method doConfigure =
- joranConfiguratoroObj.getClass().getMethod("doConfigure", URL.class);
+ joranConfiguratoroObj.getClass().getMethod("doConfigure", URL.class);
doConfigure.invoke(joranConfiguratoroObj, url);
} else {
Method doConfigure =
- joranConfiguratoroObj.getClass().getMethod("doConfigure", String.class);
+ joranConfiguratoroObj.getClass().getMethod("doConfigure", String.class);
doConfigure.invoke(joranConfiguratoroObj, logConfigFilePath);
}
@@ -101,12 +98,10 @@ public class ClientLogger {
return LoggerFactory.getLogger(LoggerName.CLIENT_LOGGER_NAME);
}
-
public static Logger getLog() {
return log;
}
-
public static void setLog(Logger log) {
ClientLogger.log = log;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java
----------------------------------------------------------------------
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 340b1ff..736aa15 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
@@ -6,28 +6,30 @@
* (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
+ * 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.
+ * 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.producer;
+import java.util.List;
import org.apache.rocketmq.client.ClientConfig;
import org.apache.rocketmq.client.QueryResult;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl;
import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageDecoder;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageId;
+import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.remoting.exception.RemotingException;
-import org.apache.rocketmq.common.message.*;
-
-import java.util.List;
-
public class DefaultMQProducer extends ClientConfig implements MQProducer {
protected final transient DefaultMQProducerImpl defaultMQProducerImpl;
@@ -44,27 +46,24 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
private boolean retryAnotherBrokerWhenNotStoreOK = false;
private int maxMessageSize = 1024 * 1024 * 4; // 4M
+
public DefaultMQProducer() {
this(MixAll.DEFAULT_PRODUCER_GROUP, null);
}
-
public DefaultMQProducer(final String producerGroup, RPCHook rpcHook) {
this.producerGroup = producerGroup;
defaultMQProducerImpl = new DefaultMQProducerImpl(this, rpcHook);
}
-
public DefaultMQProducer(final String producerGroup) {
this(producerGroup, null);
}
-
public DefaultMQProducer(RPCHook rpcHook) {
this(MixAll.DEFAULT_PRODUCER_GROUP, rpcHook);
}
-
@Override
public void start() throws MQClientException {
this.defaultMQProducerImpl.start();
@@ -75,169 +74,143 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
this.defaultMQProducerImpl.shutdown();
}
-
@Override
public List<MessageQueue> fetchPublishMessageQueues(String topic) throws MQClientException {
return this.defaultMQProducerImpl.fetchPublishMessageQueues(topic);
}
-
@Override
public SendResult send(Message msg) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.defaultMQProducerImpl.send(msg);
}
-
@Override
public SendResult send(Message msg, long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.defaultMQProducerImpl.send(msg, timeout);
}
-
@Override
public void send(Message msg, SendCallback sendCallback) throws MQClientException, RemotingException, InterruptedException {
this.defaultMQProducerImpl.send(msg, sendCallback);
}
-
@Override
public void send(Message msg, SendCallback sendCallback, long timeout)
- throws MQClientException, RemotingException, InterruptedException {
+ throws MQClientException, RemotingException, InterruptedException {
this.defaultMQProducerImpl.send(msg, sendCallback, timeout);
}
-
@Override
public void sendOneway(Message msg) throws MQClientException, RemotingException, InterruptedException {
this.defaultMQProducerImpl.sendOneway(msg);
}
-
@Override
public SendResult send(Message msg, MessageQueue mq)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.defaultMQProducerImpl.send(msg, mq);
}
-
@Override
public SendResult send(Message msg, MessageQueue mq, long timeout)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.defaultMQProducerImpl.send(msg, mq, timeout);
}
-
@Override
public void send(Message msg, MessageQueue mq, SendCallback sendCallback)
- throws MQClientException, RemotingException, InterruptedException {
+ throws MQClientException, RemotingException, InterruptedException {
this.defaultMQProducerImpl.send(msg, mq, sendCallback);
}
-
@Override
public void send(Message msg, MessageQueue mq, SendCallback sendCallback, long timeout)
- throws MQClientException, RemotingException, InterruptedException {
+ throws MQClientException, RemotingException, InterruptedException {
this.defaultMQProducerImpl.send(msg, mq, sendCallback, timeout);
}
-
@Override
public void sendOneway(Message msg, MessageQueue mq) throws MQClientException, RemotingException, InterruptedException {
this.defaultMQProducerImpl.sendOneway(msg, mq);
}
-
@Override
public SendResult send(Message msg, MessageQueueSelector selector, Object arg)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.defaultMQProducerImpl.send(msg, selector, arg);
}
-
@Override
public SendResult send(Message msg, MessageQueueSelector selector, Object arg, long timeout)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.defaultMQProducerImpl.send(msg, selector, arg, timeout);
}
-
@Override
public void send(Message msg, MessageQueueSelector selector, Object arg, SendCallback sendCallback)
- throws MQClientException, RemotingException, InterruptedException {
+ throws MQClientException, RemotingException, InterruptedException {
this.defaultMQProducerImpl.send(msg, selector, arg, sendCallback);
}
-
@Override
public void send(Message msg, MessageQueueSelector selector, Object arg, SendCallback sendCallback, long timeout)
- throws MQClientException, RemotingException, InterruptedException {
+ throws MQClientException, RemotingException, InterruptedException {
this.defaultMQProducerImpl.send(msg, selector, arg, sendCallback, timeout);
}
-
@Override
public void sendOneway(Message msg, MessageQueueSelector selector, Object arg)
- throws MQClientException, RemotingException, InterruptedException {
+ throws MQClientException, RemotingException, InterruptedException {
this.defaultMQProducerImpl.sendOneway(msg, selector, arg);
}
-
@Override
public TransactionSendResult sendMessageInTransaction(Message msg, LocalTransactionExecuter tranExecuter, final Object arg)
- throws MQClientException {
+ throws MQClientException {
throw new RuntimeException("sendMessageInTransaction not implement, please use TransactionMQProducer class");
}
-
@Override
public void createTopic(String key, String newTopic, int queueNum) throws MQClientException {
createTopic(key, newTopic, queueNum, 0);
}
-
@Override
public void createTopic(String key, String newTopic, int queueNum, int topicSysFlag) throws MQClientException {
this.defaultMQProducerImpl.createTopic(key, newTopic, queueNum, topicSysFlag);
}
-
@Override
public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
return this.defaultMQProducerImpl.searchOffset(mq, timestamp);
}
-
@Override
public long maxOffset(MessageQueue mq) throws MQClientException {
return this.defaultMQProducerImpl.maxOffset(mq);
}
-
@Override
public long minOffset(MessageQueue mq) throws MQClientException {
return this.defaultMQProducerImpl.minOffset(mq);
}
-
@Override
public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
return this.defaultMQProducerImpl.earliestMsgStoreTime(mq);
}
-
@Override
public MessageExt viewMessage(String offsetMsgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
return this.defaultMQProducerImpl.viewMessage(offsetMsgId);
}
-
@Override
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
- throws MQClientException, InterruptedException {
+ throws MQClientException, InterruptedException {
return this.defaultMQProducerImpl.queryMessage(topic, key, maxNum, begin, end);
}
-
@Override
public MessageExt viewMessage(String topic, String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
try {
@@ -252,97 +225,78 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
return producerGroup;
}
-
public void setProducerGroup(String producerGroup) {
this.producerGroup = producerGroup;
}
-
public String getCreateTopicKey() {
return createTopicKey;
}
-
public void setCreateTopicKey(String createTopicKey) {
this.createTopicKey = createTopicKey;
}
-
public int getSendMsgTimeout() {
return sendMsgTimeout;
}
-
public void setSendMsgTimeout(int sendMsgTimeout) {
this.sendMsgTimeout = sendMsgTimeout;
}
-
public int getCompressMsgBodyOverHowmuch() {
return compressMsgBodyOverHowmuch;
}
-
public void setCompressMsgBodyOverHowmuch(int compressMsgBodyOverHowmuch) {
this.compressMsgBodyOverHowmuch = compressMsgBodyOverHowmuch;
}
-
public DefaultMQProducerImpl getDefaultMQProducerImpl() {
return defaultMQProducerImpl;
}
-
public boolean isRetryAnotherBrokerWhenNotStoreOK() {
return retryAnotherBrokerWhenNotStoreOK;
}
-
public void setRetryAnotherBrokerWhenNotStoreOK(boolean retryAnotherBrokerWhenNotStoreOK) {
this.retryAnotherBrokerWhenNotStoreOK = retryAnotherBrokerWhenNotStoreOK;
}
-
public int getMaxMessageSize() {
return maxMessageSize;
}
-
public void setMaxMessageSize(int maxMessageSize) {
this.maxMessageSize = maxMessageSize;
}
-
public int getDefaultTopicQueueNums() {
return defaultTopicQueueNums;
}
-
public void setDefaultTopicQueueNums(int defaultTopicQueueNums) {
this.defaultTopicQueueNums = defaultTopicQueueNums;
}
-
public int getRetryTimesWhenSendFailed() {
return retryTimesWhenSendFailed;
}
-
public void setRetryTimesWhenSendFailed(int retryTimesWhenSendFailed) {
this.retryTimesWhenSendFailed = retryTimesWhenSendFailed;
}
-
public boolean isSendMessageWithVIPChannel() {
return isVipChannelEnabled();
}
-
public void setSendMessageWithVIPChannel(final boolean sendMessageWithVIPChannel) {
this.setVipChannelEnabled(sendMessageWithVIPChannel);
}
-
public long[] getNotAvailableDuration() {
return this.defaultMQProducerImpl.getNotAvailableDuration();
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java b/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java
index a7246e0..1083f9b 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java
@@ -6,19 +6,18 @@
* (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
+ * 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.
+ * 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.producer;
import org.apache.rocketmq.common.message.Message;
-
public interface LocalTransactionExecuter {
public LocalTransactionState executeLocalTransactionBranch(final Message msg, final Object arg);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java b/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java
index b907f81..209619a 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.producer;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java b/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java
index 492604e..b53652a 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java
@@ -6,16 +6,17 @@
* (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
+ * 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.
+ * 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.producer;
+import java.util.List;
import org.apache.rocketmq.client.MQAdmin;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
@@ -23,81 +24,61 @@ import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.exception.RemotingException;
-import java.util.List;
-
-
public interface MQProducer extends MQAdmin {
void start() throws MQClientException;
void shutdown();
-
List<MessageQueue> fetchPublishMessageQueues(final String topic) throws MQClientException;
-
SendResult send(final Message msg) throws MQClientException, RemotingException, MQBrokerException,
- InterruptedException;
-
+ InterruptedException;
SendResult send(final Message msg, final long timeout) throws MQClientException,
- RemotingException, MQBrokerException, InterruptedException;
-
+ RemotingException, MQBrokerException, InterruptedException;
void send(final Message msg, final SendCallback sendCallback) throws MQClientException,
- RemotingException, InterruptedException;
-
+ RemotingException, InterruptedException;
void send(final Message msg, final SendCallback sendCallback, final long timeout)
- throws MQClientException, RemotingException, InterruptedException;
-
+ throws MQClientException, RemotingException, InterruptedException;
void sendOneway(final Message msg) throws MQClientException, RemotingException,
- InterruptedException;
-
+ InterruptedException;
SendResult send(final Message msg, final MessageQueue mq) throws MQClientException,
- RemotingException, MQBrokerException, InterruptedException;
-
+ RemotingException, MQBrokerException, InterruptedException;
SendResult send(final Message msg, final MessageQueue mq, final long timeout)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException;
-
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException;
void send(final Message msg, final MessageQueue mq, final SendCallback sendCallback)
- throws MQClientException, RemotingException, InterruptedException;
-
+ throws MQClientException, RemotingException, InterruptedException;
void send(final Message msg, final MessageQueue mq, final SendCallback sendCallback, long timeout)
- throws MQClientException, RemotingException, InterruptedException;
-
+ throws MQClientException, RemotingException, InterruptedException;
void sendOneway(final Message msg, final MessageQueue mq) throws MQClientException,
- RemotingException, InterruptedException;
-
+ RemotingException, InterruptedException;
SendResult send(final Message msg, final MessageQueueSelector selector, final Object arg)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException;
-
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException;
SendResult send(final Message msg, final MessageQueueSelector selector, final Object arg,
- final long timeout) throws MQClientException, RemotingException, MQBrokerException,
- InterruptedException;
-
+ final long timeout) throws MQClientException, RemotingException, MQBrokerException,
+ InterruptedException;
void send(final Message msg, final MessageQueueSelector selector, final Object arg,
- final SendCallback sendCallback) throws MQClientException, RemotingException,
- InterruptedException;
-
+ final SendCallback sendCallback) throws MQClientException, RemotingException,
+ InterruptedException;
void send(final Message msg, final MessageQueueSelector selector, final Object arg,
- final SendCallback sendCallback, final long timeout) throws MQClientException, RemotingException,
- InterruptedException;
-
+ final SendCallback sendCallback, final long timeout) throws MQClientException, RemotingException,
+ InterruptedException;
void sendOneway(final Message msg, final MessageQueueSelector selector, final Object arg)
- throws MQClientException, RemotingException, InterruptedException;
-
+ throws MQClientException, RemotingException, InterruptedException;
TransactionSendResult sendMessageInTransaction(final Message msg,
- final LocalTransactionExecuter tranExecuter, final Object arg) throws MQClientException;
+ final LocalTransactionExecuter tranExecuter, final Object arg) throws MQClientException;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java b/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java
index 47956bb..761f45e 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java
@@ -6,22 +6,20 @@
* (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
+ * 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.
+ * 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.producer;
+import java.util.List;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageQueue;
-import java.util.List;
-
-
public interface MessageQueueSelector {
MessageQueue select(final List<MessageQueue> mqs, final Message msg, final Object arg);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java b/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java
index f599d83..178e79a 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java
@@ -6,19 +6,18 @@
* (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
+ * 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.
+ * 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.producer;
public interface SendCallback {
public void onSuccess(final SendResult sendResult);
-
public void onException(final Throwable e);
}
[35/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/MQClientManager.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/MQClientManager.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/MQClientManager.java
deleted file mode 100644
index 19016ca..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/MQClientManager.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * 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.client.impl;
-
-import com.alibaba.rocketmq.client.ClientConfig;
-import com.alibaba.rocketmq.client.impl.factory.MQClientInstance;
-import com.alibaba.rocketmq.remoting.RPCHook;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
-
-/**
- * @author shijia.wxr
- */
-public class MQClientManager {
- private static MQClientManager instance = new MQClientManager();
- private AtomicInteger factoryIndexGenerator = new AtomicInteger();
- private ConcurrentHashMap<String/* clientId */, MQClientInstance> factoryTable =
- new ConcurrentHashMap<String, MQClientInstance>();
-
-
- private MQClientManager() {
-
- }
-
-
- public static MQClientManager getInstance() {
- return instance;
- }
-
- public MQClientInstance getAndCreateMQClientInstance(final ClientConfig clientConfig) {
- return getAndCreateMQClientInstance(clientConfig, null);
- }
-
- public MQClientInstance getAndCreateMQClientInstance(final ClientConfig clientConfig, RPCHook rpcHook) {
- String clientId = clientConfig.buildMQClientId();
- MQClientInstance instance = this.factoryTable.get(clientId);
- if (null == instance) {
- instance =
- new MQClientInstance(clientConfig.cloneClientConfig(),
- this.factoryIndexGenerator.getAndIncrement(), clientId, rpcHook);
- MQClientInstance prev = this.factoryTable.putIfAbsent(clientId, instance);
- if (prev != null) {
- instance = prev;
- } else {
- // TODO log
- }
- }
-
- return instance;
- }
-
- public void removeClientFactory(final String clientId) {
- this.factoryTable.remove(clientId);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
deleted file mode 100644
index 4dee764..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
+++ /dev/null
@@ -1,471 +0,0 @@
-/**
- * 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.client.impl.consumer;
-
-import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
-import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
-import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
-import com.alibaba.rocketmq.client.consumer.listener.ConsumeReturnType;
-import com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
-import com.alibaba.rocketmq.client.hook.ConsumeMessageContext;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.client.stat.ConsumerStatsManager;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.ThreadFactoryImpl;
-import com.alibaba.rocketmq.common.message.MessageAccessor;
-import com.alibaba.rocketmq.common.message.MessageConst;
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.body.CMResult;
-import com.alibaba.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import org.slf4j.Logger;
-
-import java.util.*;
-import java.util.concurrent.*;
-
-
-/**
- * @author shijia.wxr
- */
-public class ConsumeMessageConcurrentlyService implements ConsumeMessageService {
- private static final Logger log = ClientLogger.getLog();
- private final DefaultMQPushConsumerImpl defaultMQPushConsumerImpl;
- private final DefaultMQPushConsumer defaultMQPushConsumer;
- private final MessageListenerConcurrently messageListener;
- private final BlockingQueue<Runnable> consumeRequestQueue;
- private final ThreadPoolExecutor consumeExecutor;
- private final String consumerGroup;
-
- private final ScheduledExecutorService scheduledExecutorService;
- private final ScheduledExecutorService cleanExpireMsgExecutors;
-
-
- public ConsumeMessageConcurrentlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl,
- MessageListenerConcurrently messageListener) {
- this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
- this.messageListener = messageListener;
-
- this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
- this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
- this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();
-
- this.consumeExecutor = new ThreadPoolExecutor(//
- this.defaultMQPushConsumer.getConsumeThreadMin(), //
- this.defaultMQPushConsumer.getConsumeThreadMax(), //
- 1000 * 60, //
- TimeUnit.MILLISECONDS, //
- this.consumeRequestQueue, //
- new ThreadFactoryImpl("ConsumeMessageThread_"));
-
- this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
- this.cleanExpireMsgExecutors = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("CleanExpireMsgScheduledThread_"));
- }
-
-
- public void start() {
- this.cleanExpireMsgExecutors.scheduleAtFixedRate(new Runnable() {
-
- @Override
- public void run() {
- cleanExpireMsg();
- }
-
- }, this.defaultMQPushConsumer.getConsumeTimeout(), this.defaultMQPushConsumer.getConsumeTimeout(), TimeUnit.MINUTES);
- }
-
-
- public void shutdown() {
- this.scheduledExecutorService.shutdown();
- this.consumeExecutor.shutdown();
- this.cleanExpireMsgExecutors.shutdown();
- }
-
- @Override
- public void updateCorePoolSize(int corePoolSize) {
- if (corePoolSize > 0 //
- && corePoolSize <= Short.MAX_VALUE //
- && corePoolSize < this.defaultMQPushConsumer.getConsumeThreadMax()) {
- this.consumeExecutor.setCorePoolSize(corePoolSize);
- }
- }
-
- @Override
- public void incCorePoolSize() {
- // long corePoolSize = this.consumeExecutor.getCorePoolSize();
- // if (corePoolSize < this.defaultMQPushConsumer.getConsumeThreadMax())
- // {
- // this.consumeExecutor.setCorePoolSize(this.consumeExecutor.getCorePoolSize()
- // + 1);
- // }
- //
- // log.info("incCorePoolSize Concurrently from {} to {}, ConsumerGroup:
- // {}", //
- // corePoolSize,//
- // this.consumeExecutor.getCorePoolSize(),//
- // this.consumerGroup);
- }
-
- @Override
- public void decCorePoolSize() {
- // long corePoolSize = this.consumeExecutor.getCorePoolSize();
- // if (corePoolSize > this.defaultMQPushConsumer.getConsumeThreadMin())
- // {
- // this.consumeExecutor.setCorePoolSize(this.consumeExecutor.getCorePoolSize()
- // - 1);
- // }
- //
- // log.info("decCorePoolSize Concurrently from {} to {}, ConsumerGroup:
- // {}", //
- // corePoolSize,//
- // this.consumeExecutor.getCorePoolSize(),//
- // this.consumerGroup);
- }
-
- @Override
- public int getCorePoolSize() {
- return this.consumeExecutor.getCorePoolSize();
- }
-
- @Override
- public ConsumeMessageDirectlyResult consumeMessageDirectly(MessageExt msg, String brokerName) {
- ConsumeMessageDirectlyResult result = new ConsumeMessageDirectlyResult();
- result.setOrder(false);
- result.setAutoCommit(true);
-
- List<MessageExt> msgs = new ArrayList<MessageExt>();
- msgs.add(msg);
- MessageQueue mq = new MessageQueue();
- mq.setBrokerName(brokerName);
- mq.setTopic(msg.getTopic());
- mq.setQueueId(msg.getQueueId());
-
- ConsumeConcurrentlyContext context = new ConsumeConcurrentlyContext(mq);
-
- this.resetRetryTopic(msgs);
-
- final long beginTime = System.currentTimeMillis();
-
- log.info("consumeMessageDirectly receive new messge: {}", msg);
-
- try {
- ConsumeConcurrentlyStatus status = this.messageListener.consumeMessage(msgs, context);
- if (status != null) {
- switch (status) {
- case CONSUME_SUCCESS:
- result.setConsumeResult(CMResult.CR_SUCCESS);
- break;
- case RECONSUME_LATER:
- result.setConsumeResult(CMResult.CR_LATER);
- break;
- default:
- break;
- }
- } else {
- result.setConsumeResult(CMResult.CR_RETURN_NULL);
- }
- } catch (Throwable e) {
- result.setConsumeResult(CMResult.CR_THROW_EXCEPTION);
- result.setRemark(RemotingHelper.exceptionSimpleDesc(e));
-
- log.warn(String.format("consumeMessageDirectly exception: %s Group: %s Msgs: %s MQ: %s", //
- RemotingHelper.exceptionSimpleDesc(e), //
- ConsumeMessageConcurrentlyService.this.consumerGroup, //
- msgs, //
- mq), e);
- }
-
- result.setSpentTimeMills(System.currentTimeMillis() - beginTime);
-
- log.info("consumeMessageDirectly Result: {}", result);
-
- return result;
- }
-
- @Override
- public void submitConsumeRequest(//
- final List<MessageExt> msgs, //
- final ProcessQueue processQueue, //
- final MessageQueue messageQueue, //
- final boolean dispatchToConsume) {
- final int consumeBatchSize = this.defaultMQPushConsumer.getConsumeMessageBatchMaxSize();
- if (msgs.size() <= consumeBatchSize) {
- ConsumeRequest consumeRequest = new ConsumeRequest(msgs, processQueue, messageQueue);
- try {
- this.consumeExecutor.submit(consumeRequest);
- } catch (RejectedExecutionException e) {
- this.submitConsumeRequestLater(consumeRequest);
- }
- } else {
- for (int total = 0; total < msgs.size(); ) {
- List<MessageExt> msgThis = new ArrayList<MessageExt>(consumeBatchSize);
- for (int i = 0; i < consumeBatchSize; i++, total++) {
- if (total < msgs.size()) {
- msgThis.add(msgs.get(total));
- } else {
- break;
- }
- }
-
- ConsumeRequest consumeRequest = new ConsumeRequest(msgThis, processQueue, messageQueue);
- try {
- this.consumeExecutor.submit(consumeRequest);
- } catch (RejectedExecutionException e) {
- for (; total < msgs.size(); total++) {
- msgThis.add(msgs.get(total));
- }
-
- this.submitConsumeRequestLater(consumeRequest);
- }
- }
- }
- }
-
- public void resetRetryTopic(final List<MessageExt> msgs) {
- final String groupTopic = MixAll.getRetryTopic(consumerGroup);
- for (MessageExt msg : msgs) {
- String retryTopic = msg.getProperty(MessageConst.PROPERTY_RETRY_TOPIC);
- if (retryTopic != null && groupTopic.equals(msg.getTopic())) {
- msg.setTopic(retryTopic);
- }
- }
- }
-
- private void cleanExpireMsg() {
- Iterator<Map.Entry<MessageQueue, ProcessQueue>> it =
- this.defaultMQPushConsumerImpl.getRebalanceImpl().getProcessQueueTable().entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry<MessageQueue, ProcessQueue> next = it.next();
- ProcessQueue pq = next.getValue();
- pq.cleanExpiredMsg(this.defaultMQPushConsumer);
- }
- }
-
- public void processConsumeResult(//
- final ConsumeConcurrentlyStatus status, //
- final ConsumeConcurrentlyContext context, //
- final ConsumeRequest consumeRequest//
- ) {
- int ackIndex = context.getAckIndex();
-
- if (consumeRequest.getMsgs().isEmpty())
- return;
-
- switch (status) {
- case CONSUME_SUCCESS:
- if (ackIndex >= consumeRequest.getMsgs().size()) {
- ackIndex = consumeRequest.getMsgs().size() - 1;
- }
- int ok = ackIndex + 1;
- int failed = consumeRequest.getMsgs().size() - ok;
- this.getConsumerStatsManager().incConsumeOKTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(), ok);
- this.getConsumerStatsManager().incConsumeFailedTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(), failed);
- break;
- case RECONSUME_LATER:
- ackIndex = -1;
- this.getConsumerStatsManager().incConsumeFailedTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(),
- consumeRequest.getMsgs().size());
- break;
- default:
- break;
- }
-
- switch (this.defaultMQPushConsumer.getMessageModel()) {
- case BROADCASTING:
- for (int i = ackIndex + 1; i < consumeRequest.getMsgs().size(); i++) {
- MessageExt msg = consumeRequest.getMsgs().get(i);
- log.warn("BROADCASTING, the message consume failed, drop it, {}", msg.toString());
- }
- break;
- case CLUSTERING:
- List<MessageExt> msgBackFailed = new ArrayList<MessageExt>(consumeRequest.getMsgs().size());
- for (int i = ackIndex + 1; i < consumeRequest.getMsgs().size(); i++) {
- MessageExt msg = consumeRequest.getMsgs().get(i);
- boolean result = this.sendMessageBack(msg, context);
- if (!result) {
- msg.setReconsumeTimes(msg.getReconsumeTimes() + 1);
- msgBackFailed.add(msg);
- }
- }
-
- if (!msgBackFailed.isEmpty()) {
- consumeRequest.getMsgs().removeAll(msgBackFailed);
-
- this.submitConsumeRequestLater(msgBackFailed, consumeRequest.getProcessQueue(), consumeRequest.getMessageQueue());
- }
- break;
- default:
- break;
- }
-
- long offset = consumeRequest.getProcessQueue().removeMessage(consumeRequest.getMsgs());
- if (offset >= 0 && !consumeRequest.getProcessQueue().isDropped()) {
- this.defaultMQPushConsumerImpl.getOffsetStore().updateOffset(consumeRequest.getMessageQueue(), offset, true);
- }
- }
-
- public ConsumerStatsManager getConsumerStatsManager() {
- return this.defaultMQPushConsumerImpl.getConsumerStatsManager();
- }
-
- public boolean sendMessageBack(final MessageExt msg, final ConsumeConcurrentlyContext context) {
- int delayLevel = context.getDelayLevelWhenNextConsume();
-
- try {
- this.defaultMQPushConsumerImpl.sendMessageBack(msg, delayLevel, context.getMessageQueue().getBrokerName());
- return true;
- } catch (Exception e) {
- log.error("sendMessageBack exception, group: " + this.consumerGroup + " msg: " + msg.toString(), e);
- }
-
- return false;
- }
-
- private void submitConsumeRequestLater(//
- final List<MessageExt> msgs, //
- final ProcessQueue processQueue, //
- final MessageQueue messageQueue//
- ) {
-
- this.scheduledExecutorService.schedule(new Runnable() {
-
- @Override
- public void run() {
- ConsumeMessageConcurrentlyService.this.submitConsumeRequest(msgs, processQueue, messageQueue, true);
- }
- }, 5000, TimeUnit.MILLISECONDS);
- }
-
- private void submitConsumeRequestLater(final ConsumeRequest consumeRequest//
- ) {
-
- this.scheduledExecutorService.schedule(new Runnable() {
-
- @Override
- public void run() {
- ConsumeMessageConcurrentlyService.this.consumeExecutor.submit(consumeRequest);
- }
- }, 5000, TimeUnit.MILLISECONDS);
- }
-
- class ConsumeRequest implements Runnable {
- private final List<MessageExt> msgs;
- private final ProcessQueue processQueue;
- private final MessageQueue messageQueue;
-
-
- public ConsumeRequest(List<MessageExt> msgs, ProcessQueue processQueue, MessageQueue messageQueue) {
- this.msgs = msgs;
- this.processQueue = processQueue;
- this.messageQueue = messageQueue;
- }
-
- public List<MessageExt> getMsgs() {
- return msgs;
- }
-
- public ProcessQueue getProcessQueue() {
- return processQueue;
- }
-
- @Override
- public void run() {
- if (this.processQueue.isDropped()) {
- log.info("the message queue not be able to consume, because it's dropped. group={} {}", ConsumeMessageConcurrentlyService.this.consumerGroup, this.messageQueue);
- return;
- }
-
- MessageListenerConcurrently listener = ConsumeMessageConcurrentlyService.this.messageListener;
- ConsumeConcurrentlyContext context = new ConsumeConcurrentlyContext(messageQueue);
- ConsumeConcurrentlyStatus status = null;
-
- ConsumeMessageContext consumeMessageContext = null;
- if (ConsumeMessageConcurrentlyService.this.defaultMQPushConsumerImpl.hasHook()) {
- consumeMessageContext = new ConsumeMessageContext();
- consumeMessageContext.setConsumerGroup(defaultMQPushConsumer.getConsumerGroup());
- consumeMessageContext.setProps(new HashMap<String, String>());
- consumeMessageContext.setMq(messageQueue);
- consumeMessageContext.setMsgList(msgs);
- consumeMessageContext.setSuccess(false);
- ConsumeMessageConcurrentlyService.this.defaultMQPushConsumerImpl.executeHookBefore(consumeMessageContext);
- }
-
- long beginTimestamp = System.currentTimeMillis();
- boolean hasException = false;
- ConsumeReturnType returnType = ConsumeReturnType.SUCCESS;
- try {
- ConsumeMessageConcurrentlyService.this.resetRetryTopic(msgs);
- if (msgs != null && !msgs.isEmpty()) {
- for (MessageExt msg : msgs) {
- MessageAccessor.setConsumeStartTimeStamp(msg, String.valueOf(System.currentTimeMillis()));
- }
- }
- status = listener.consumeMessage(Collections.unmodifiableList(msgs), context);
- } catch (Throwable e) {
- log.warn("consumeMessage exception: {} Group: {} Msgs: {} MQ: {}",
- RemotingHelper.exceptionSimpleDesc(e), //
- ConsumeMessageConcurrentlyService.this.consumerGroup,
- msgs,
- messageQueue);
- hasException = true;
- }
- long consumeRT = System.currentTimeMillis() - beginTimestamp;
- if (null == status) {
- if (hasException) {
- returnType = ConsumeReturnType.EXCEPTION;
- } else {
- returnType = ConsumeReturnType.RETURNNULL;
- }
- } else if (consumeRT >= defaultMQPushConsumer.getConsumeTimeout() * 60 * 1000) {
- returnType = ConsumeReturnType.TIME_OUT;
- } else if (ConsumeConcurrentlyStatus.RECONSUME_LATER == status) {
- returnType = ConsumeReturnType.FAILED;
- } else if (ConsumeConcurrentlyStatus.CONSUME_SUCCESS == status) {
- returnType = ConsumeReturnType.SUCCESS;
- }
- consumeMessageContext.getProps().put(MixAll.CONSUME_CONTEXT_TYPE, returnType.name());
- if (null == status) {
- log.warn("consumeMessage return null, Group: {} Msgs: {} MQ: {}",
- ConsumeMessageConcurrentlyService.this.consumerGroup,
- msgs,
- messageQueue);
- status = ConsumeConcurrentlyStatus.RECONSUME_LATER;
- }
-
- if (ConsumeMessageConcurrentlyService.this.defaultMQPushConsumerImpl.hasHook()) {
- consumeMessageContext.setStatus(status.toString());
- consumeMessageContext.setSuccess(ConsumeConcurrentlyStatus.CONSUME_SUCCESS == status);
- ConsumeMessageConcurrentlyService.this.defaultMQPushConsumerImpl.executeHookAfter(consumeMessageContext);
- }
-
- ConsumeMessageConcurrentlyService.this.getConsumerStatsManager()
- .incConsumeRT(ConsumeMessageConcurrentlyService.this.consumerGroup, messageQueue.getTopic(), consumeRT);
-
- if (!processQueue.isDropped()) {
- ConsumeMessageConcurrentlyService.this.processConsumeResult(status, context, this);
- } else {
- log.warn("processQueue is dropped without process consume result. messageQueue={}, msgs={}", messageQueue, msgs);
- }
- }
-
- public MessageQueue getMessageQueue() {
- return messageQueue;
- }
-
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
deleted file mode 100644
index 82903b0..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
+++ /dev/null
@@ -1,536 +0,0 @@
-/**
- * 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.client.impl.consumer;
-
-import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
-import com.alibaba.rocketmq.client.consumer.listener.*;
-import com.alibaba.rocketmq.client.hook.ConsumeMessageContext;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.client.stat.ConsumerStatsManager;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.ThreadFactoryImpl;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.message.*;
-import com.alibaba.rocketmq.common.protocol.body.CMResult;
-import com.alibaba.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
-import com.alibaba.rocketmq.common.protocol.heartbeat.MessageModel;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import org.slf4j.Logger;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.concurrent.*;
-
-
-/**
- * @author shijia.wxr
- */
-public class ConsumeMessageOrderlyService implements ConsumeMessageService {
- private static final Logger log = ClientLogger.getLog();
- private final static long MAX_TIME_CONSUME_CONTINUOUSLY =
- Long.parseLong(System.getProperty("rocketmq.client.maxTimeConsumeContinuously", "60000"));
- private final DefaultMQPushConsumerImpl defaultMQPushConsumerImpl;
- private final DefaultMQPushConsumer defaultMQPushConsumer;
- private final MessageListenerOrderly messageListener;
- private final BlockingQueue<Runnable> consumeRequestQueue;
- private final ThreadPoolExecutor consumeExecutor;
- private final String consumerGroup;
- private final MessageQueueLock messageQueueLock = new MessageQueueLock();
- private final ScheduledExecutorService scheduledExecutorService;
- private volatile boolean stopped = false;
-
-
- public ConsumeMessageOrderlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl, MessageListenerOrderly messageListener) {
- this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
- this.messageListener = messageListener;
-
- this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
- this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
- this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();
-
- this.consumeExecutor = new ThreadPoolExecutor(//
- this.defaultMQPushConsumer.getConsumeThreadMin(), //
- this.defaultMQPushConsumer.getConsumeThreadMax(), //
- 1000 * 60, //
- TimeUnit.MILLISECONDS, //
- this.consumeRequestQueue, //
- new ThreadFactoryImpl("ConsumeMessageThread_"));
-
- this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
- }
-
-
- public void start() {
- if (MessageModel.CLUSTERING.equals(ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.messageModel())) {
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- ConsumeMessageOrderlyService.this.lockMQPeriodically();
- }
- }, 1000 * 1, ProcessQueue.REBALANCE_LOCK_INTERVAL, TimeUnit.MILLISECONDS);
- }
- }
-
-
- public void shutdown() {
- this.stopped = true;
- this.scheduledExecutorService.shutdown();
- this.consumeExecutor.shutdown();
- if (MessageModel.CLUSTERING.equals(this.defaultMQPushConsumerImpl.messageModel())) {
- this.unlockAllMQ();
- }
- }
-
-
- public synchronized void unlockAllMQ() {
- this.defaultMQPushConsumerImpl.getRebalanceImpl().unlockAll(false);
- }
-
- @Override
- public void updateCorePoolSize(int corePoolSize) {
- if (corePoolSize > 0 //
- && corePoolSize <= Short.MAX_VALUE //
- && corePoolSize < this.defaultMQPushConsumer.getConsumeThreadMax()) {
- this.consumeExecutor.setCorePoolSize(corePoolSize);
- }
- }
-
- @Override
- public void incCorePoolSize() {
- }
-
- @Override
- public void decCorePoolSize() {
- }
-
- @Override
- public int getCorePoolSize() {
- return this.consumeExecutor.getCorePoolSize();
- }
-
- @Override
- public ConsumeMessageDirectlyResult consumeMessageDirectly(MessageExt msg, String brokerName) {
- ConsumeMessageDirectlyResult result = new ConsumeMessageDirectlyResult();
- result.setOrder(true);
-
- List<MessageExt> msgs = new ArrayList<MessageExt>();
- msgs.add(msg);
- MessageQueue mq = new MessageQueue();
- mq.setBrokerName(brokerName);
- mq.setTopic(msg.getTopic());
- mq.setQueueId(msg.getQueueId());
-
- ConsumeOrderlyContext context = new ConsumeOrderlyContext(mq);
-
- final long beginTime = System.currentTimeMillis();
-
- log.info("consumeMessageDirectly receive new messge: {}", msg);
-
- try {
- ConsumeOrderlyStatus status = this.messageListener.consumeMessage(msgs, context);
- if (status != null) {
- switch (status) {
- case COMMIT:
- result.setConsumeResult(CMResult.CR_COMMIT);
- break;
- case ROLLBACK:
- result.setConsumeResult(CMResult.CR_ROLLBACK);
- break;
- case SUCCESS:
- result.setConsumeResult(CMResult.CR_SUCCESS);
- break;
- case SUSPEND_CURRENT_QUEUE_A_MOMENT:
- result.setConsumeResult(CMResult.CR_LATER);
- break;
- default:
- break;
- }
- } else {
- result.setConsumeResult(CMResult.CR_RETURN_NULL);
- }
- } catch (Throwable e) {
- result.setConsumeResult(CMResult.CR_THROW_EXCEPTION);
- result.setRemark(RemotingHelper.exceptionSimpleDesc(e));
-
- log.warn(String.format("consumeMessageDirectly exception: %s Group: %s Msgs: %s MQ: %s", //
- RemotingHelper.exceptionSimpleDesc(e), //
- ConsumeMessageOrderlyService.this.consumerGroup, //
- msgs, //
- mq), e);
- }
-
- result.setAutoCommit(context.isAutoCommit());
- result.setSpentTimeMills(System.currentTimeMillis() - beginTime);
-
- log.info("consumeMessageDirectly Result: {}", result);
-
- return result;
- }
-
- @Override
- public void submitConsumeRequest(//
- final List<MessageExt> msgs, //
- final ProcessQueue processQueue, //
- final MessageQueue messageQueue, //
- final boolean dispathToConsume) {
- if (dispathToConsume) {
- ConsumeRequest consumeRequest = new ConsumeRequest(processQueue, messageQueue);
- this.consumeExecutor.submit(consumeRequest);
- }
- }
-
- public synchronized void lockMQPeriodically() {
- if (!this.stopped) {
- this.defaultMQPushConsumerImpl.getRebalanceImpl().lockAll();
- }
- }
-
- public void tryLockLaterAndReconsume(final MessageQueue mq, final ProcessQueue processQueue, final long delayMills) {
- this.scheduledExecutorService.schedule(new Runnable() {
- @Override
- public void run() {
- boolean lockOK = ConsumeMessageOrderlyService.this.lockOneMQ(mq);
- if (lockOK) {
- ConsumeMessageOrderlyService.this.submitConsumeRequestLater(processQueue, mq, 10);
- } else {
- ConsumeMessageOrderlyService.this.submitConsumeRequestLater(processQueue, mq, 3000);
- }
- }
- }, delayMills, TimeUnit.MILLISECONDS);
- }
-
- public synchronized boolean lockOneMQ(final MessageQueue mq) {
- if (!this.stopped) {
- return this.defaultMQPushConsumerImpl.getRebalanceImpl().lock(mq);
- }
-
- return false;
- }
-
- private void submitConsumeRequestLater(//
- final ProcessQueue processQueue, //
- final MessageQueue messageQueue, //
- final long suspendTimeMillis//
- ) {
- long timeMillis = suspendTimeMillis;
- if (timeMillis == -1) {
- timeMillis = this.defaultMQPushConsumer.getSuspendCurrentQueueTimeMillis();
- }
-
- if (timeMillis < 10) {
- timeMillis = 10;
- } else if (timeMillis > 30000) {
- timeMillis = 30000;
- }
-
- this.scheduledExecutorService.schedule(new Runnable() {
-
- @Override
- public void run() {
- ConsumeMessageOrderlyService.this.submitConsumeRequest(null, processQueue, messageQueue, true);
- }
- }, timeMillis, TimeUnit.MILLISECONDS);
- }
-
- public boolean processConsumeResult(//
- final List<MessageExt> msgs, //
- final ConsumeOrderlyStatus status, //
- final ConsumeOrderlyContext context, //
- final ConsumeRequest consumeRequest//
- ) {
- boolean continueConsume = true;
- long commitOffset = -1L;
- if (context.isAutoCommit()) {
- switch (status) {
- case COMMIT:
- case ROLLBACK:
- log.warn("the message queue consume result is illegal, we think you want to ack these message {}",
- consumeRequest.getMessageQueue());
- case SUCCESS:
- commitOffset = consumeRequest.getProcessQueue().commit();
- this.getConsumerStatsManager().incConsumeOKTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(), msgs.size());
- break;
- case SUSPEND_CURRENT_QUEUE_A_MOMENT:
- this.getConsumerStatsManager().incConsumeFailedTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(), msgs.size());
- if (checkReconsumeTimes(msgs)) {
- consumeRequest.getProcessQueue().makeMessageToCosumeAgain(msgs);
- this.submitConsumeRequestLater(//
- consumeRequest.getProcessQueue(), //
- consumeRequest.getMessageQueue(), //
- context.getSuspendCurrentQueueTimeMillis());
- continueConsume = false;
- } else {
- commitOffset = consumeRequest.getProcessQueue().commit();
- }
- break;
- default:
- break;
- }
- } else {
- switch (status) {
- case SUCCESS:
- this.getConsumerStatsManager().incConsumeOKTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(), msgs.size());
- break;
- case COMMIT:
- commitOffset = consumeRequest.getProcessQueue().commit();
- break;
- case ROLLBACK:
- consumeRequest.getProcessQueue().rollback();
- this.submitConsumeRequestLater(//
- consumeRequest.getProcessQueue(), //
- consumeRequest.getMessageQueue(), //
- context.getSuspendCurrentQueueTimeMillis());
- continueConsume = false;
- break;
- case SUSPEND_CURRENT_QUEUE_A_MOMENT:
- this.getConsumerStatsManager().incConsumeFailedTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(), msgs.size());
- if (checkReconsumeTimes(msgs)) {
- consumeRequest.getProcessQueue().makeMessageToCosumeAgain(msgs);
- this.submitConsumeRequestLater(//
- consumeRequest.getProcessQueue(), //
- consumeRequest.getMessageQueue(), //
- context.getSuspendCurrentQueueTimeMillis());
- continueConsume = false;
- }
- break;
- default:
- break;
- }
- }
-
- if (commitOffset >= 0 && !consumeRequest.getProcessQueue().isDropped()) {
- this.defaultMQPushConsumerImpl.getOffsetStore().updateOffset(consumeRequest.getMessageQueue(), commitOffset, false);
- }
-
- return continueConsume;
- }
-
- public ConsumerStatsManager getConsumerStatsManager() {
- return this.defaultMQPushConsumerImpl.getConsumerStatsManager();
- }
-
- private int getMaxReconsumeTimes() {
- // default reconsume times: Integer.MAX_VALUE
- if (this.defaultMQPushConsumer.getMaxReconsumeTimes() == -1) {
- return Integer.MAX_VALUE;
- } else {
- return this.defaultMQPushConsumer.getMaxReconsumeTimes();
- }
- }
-
- private boolean checkReconsumeTimes(List<MessageExt> msgs) {
- boolean suspend = false;
- if (msgs != null && !msgs.isEmpty()) {
- for (MessageExt msg : msgs) {
- if (msg.getReconsumeTimes() >= getMaxReconsumeTimes()) {
- MessageAccessor.setReconsumeTime(msg, String.valueOf(msg.getReconsumeTimes()));
- if (!sendMessageBack(msg)) {
- suspend = true;
- msg.setReconsumeTimes(msg.getReconsumeTimes() + 1);
- }
- } else {
- suspend = true;
- msg.setReconsumeTimes(msg.getReconsumeTimes() + 1);
- }
- }
- }
- return suspend;
- }
-
- public boolean sendMessageBack(final MessageExt msg) {
- try {
- // max reconsume times exceeded then send to dead letter queue.
- Message newMsg = new Message(MixAll.getRetryTopic(this.defaultMQPushConsumer.getConsumerGroup()), msg.getBody());
- String originMsgId = MessageAccessor.getOriginMessageId(msg);
- MessageAccessor.setOriginMessageId(newMsg, UtilAll.isBlank(originMsgId) ? msg.getMsgId() : originMsgId);
- newMsg.setFlag(msg.getFlag());
- MessageAccessor.setProperties(newMsg, msg.getProperties());
- MessageAccessor.putProperty(newMsg, MessageConst.PROPERTY_RETRY_TOPIC, msg.getTopic());
- MessageAccessor.setReconsumeTime(newMsg, String.valueOf(msg.getReconsumeTimes()));
- MessageAccessor.setMaxReconsumeTimes(newMsg, String.valueOf(getMaxReconsumeTimes()));
- newMsg.setDelayTimeLevel(3 + msg.getReconsumeTimes());
-
- this.defaultMQPushConsumer.getDefaultMQPushConsumerImpl().getmQClientFactory().getDefaultMQProducer().send(newMsg);
- return true;
- } catch (Exception e) {
- log.error("sendMessageBack exception, group: " + this.consumerGroup + " msg: " + msg.toString(), e);
- }
-
- return false;
- }
-
- class ConsumeRequest implements Runnable {
- private final ProcessQueue processQueue;
- private final MessageQueue messageQueue;
-
-
- public ConsumeRequest(ProcessQueue processQueue, MessageQueue messageQueue) {
- this.processQueue = processQueue;
- this.messageQueue = messageQueue;
- }
-
- public ProcessQueue getProcessQueue() {
- return processQueue;
- }
-
- public MessageQueue getMessageQueue() {
- return messageQueue;
- }
-
- @Override
- public void run() {
- if (this.processQueue.isDropped()) {
- log.warn("run, the message queue not be able to consume, because it's dropped. {}", this.messageQueue);
- return;
- }
-
- final Object objLock = messageQueueLock.fetchLockObject(this.messageQueue);
- synchronized (objLock) {
- if (MessageModel.BROADCASTING.equals(ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.messageModel())
- || (this.processQueue.isLocked() && !this.processQueue.isLockExpired())) {
- final long beginTime = System.currentTimeMillis();
- for (boolean continueConsume = true; continueConsume; ) {
- if (this.processQueue.isDropped()) {
- log.warn("the message queue not be able to consume, because it's dropped. {}", this.messageQueue);
- break;
- }
-
- if (MessageModel.CLUSTERING.equals(ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.messageModel())
- && !this.processQueue.isLocked()) {
- log.warn("the message queue not locked, so consume later, {}", this.messageQueue);
- ConsumeMessageOrderlyService.this.tryLockLaterAndReconsume(this.messageQueue, this.processQueue, 10);
- break;
- }
-
- if (MessageModel.CLUSTERING.equals(ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.messageModel())
- && this.processQueue.isLockExpired()) {
- log.warn("the message queue lock expired, so consume later, {}", this.messageQueue);
- ConsumeMessageOrderlyService.this.tryLockLaterAndReconsume(this.messageQueue, this.processQueue, 10);
- break;
- }
-
- long interval = System.currentTimeMillis() - beginTime;
- if (interval > MAX_TIME_CONSUME_CONTINUOUSLY) {
- ConsumeMessageOrderlyService.this.submitConsumeRequestLater(processQueue, messageQueue, 10);
- break;
- }
-
- final int consumeBatchSize =
- ConsumeMessageOrderlyService.this.defaultMQPushConsumer.getConsumeMessageBatchMaxSize();
-
- List<MessageExt> msgs = this.processQueue.takeMessags(consumeBatchSize);
- if (!msgs.isEmpty()) {
- final ConsumeOrderlyContext context = new ConsumeOrderlyContext(this.messageQueue);
-
- ConsumeOrderlyStatus status = null;
-
- ConsumeMessageContext consumeMessageContext = null;
- if (ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.hasHook()) {
- consumeMessageContext = new ConsumeMessageContext();
- consumeMessageContext
- .setConsumerGroup(ConsumeMessageOrderlyService.this.defaultMQPushConsumer.getConsumerGroup());
- consumeMessageContext.setMq(messageQueue);
- consumeMessageContext.setMsgList(msgs);
- consumeMessageContext.setSuccess(false);
- // init the consume context type
- consumeMessageContext.setProps(new HashMap<String, String>());
- ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.executeHookBefore(consumeMessageContext);
- }
-
- long beginTimestamp = System.currentTimeMillis();
- ConsumeReturnType returnType = ConsumeReturnType.SUCCESS;
- boolean hasException = false;
- try {
- this.processQueue.getLockConsume().lock();
- if (this.processQueue.isDropped()) {
- log.warn("consumeMessage, the message queue not be able to consume, because it's dropped. {}",
- this.messageQueue);
- break;
- }
-
- status = messageListener.consumeMessage(Collections.unmodifiableList(msgs), context);
- } catch (Throwable e) {
- log.warn("consumeMessage exception: {} Group: {} Msgs: {} MQ: {}", //
- RemotingHelper.exceptionSimpleDesc(e), //
- ConsumeMessageOrderlyService.this.consumerGroup, //
- msgs, //
- messageQueue);
- hasException = true;
- } finally {
- this.processQueue.getLockConsume().unlock();
- }
-
- if (null == status //
- || ConsumeOrderlyStatus.ROLLBACK == status//
- || ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT == status) {
- log.warn("consumeMessage Orderly return not OK, Group: {} Msgs: {} MQ: {}", //
- ConsumeMessageOrderlyService.this.consumerGroup, //
- msgs, //
- messageQueue);
- }
-
- long consumeRT = System.currentTimeMillis() - beginTimestamp;
- if (null == status) {
- if (hasException) {
- returnType = ConsumeReturnType.EXCEPTION;
- } else {
- returnType = ConsumeReturnType.RETURNNULL;
- }
- } else if (consumeRT >= defaultMQPushConsumer.getConsumeTimeout() * 60 * 1000) {
- returnType = ConsumeReturnType.TIME_OUT;
- } else if (ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT == status) {
- returnType = ConsumeReturnType.FAILED;
- } else if (ConsumeOrderlyStatus.SUCCESS == status) {
- returnType = ConsumeReturnType.SUCCESS;
- }
- consumeMessageContext.getProps().put(MixAll.CONSUME_CONTEXT_TYPE, returnType.name());
- if (null == status) {
- status = ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT;
- }
-
- if (ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.hasHook()) {
- consumeMessageContext.setStatus(status.toString());
- consumeMessageContext
- .setSuccess(ConsumeOrderlyStatus.SUCCESS == status || ConsumeOrderlyStatus.COMMIT == status);
- ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.executeHookAfter(consumeMessageContext);
- }
-
- ConsumeMessageOrderlyService.this.getConsumerStatsManager()
- .incConsumeRT(ConsumeMessageOrderlyService.this.consumerGroup, messageQueue.getTopic(), consumeRT);
-
- continueConsume = ConsumeMessageOrderlyService.this.processConsumeResult(msgs, status, context, this);
- } else {
- continueConsume = false;
- }
- }
- } else {
- if (this.processQueue.isDropped()) {
- log.warn("the message queue not be able to consume, because it's dropped. {}", this.messageQueue);
- return;
- }
-
- ConsumeMessageOrderlyService.this.tryLockLaterAndReconsume(this.messageQueue, this.processQueue, 100);
- }
- }
- }
-
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/ConsumeMessageService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/ConsumeMessageService.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/ConsumeMessageService.java
deleted file mode 100644
index 1f7f0d9..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/ConsumeMessageService.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * 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.client.impl.consumer;
-
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
-
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public interface ConsumeMessageService {
- void start();
-
-
- void shutdown();
-
-
- void updateCorePoolSize(int corePoolSize);
-
-
- void incCorePoolSize();
-
-
- void decCorePoolSize();
-
-
- int getCorePoolSize();
-
-
- ConsumeMessageDirectlyResult consumeMessageDirectly(final MessageExt msg, final String brokerName);
-
-
- void submitConsumeRequest(//
- final List<MessageExt> msgs, //
- final ProcessQueue processQueue, //
- final MessageQueue messageQueue, //
- final boolean dispathToConsume);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
deleted file mode 100644
index 1785ec9..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
+++ /dev/null
@@ -1,706 +0,0 @@
-/**
- * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.client.impl.consumer;
-
-import com.alibaba.rocketmq.client.QueryResult;
-import com.alibaba.rocketmq.client.Validators;
-import com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer;
-import com.alibaba.rocketmq.client.consumer.PullCallback;
-import com.alibaba.rocketmq.client.consumer.PullResult;
-import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
-import com.alibaba.rocketmq.client.consumer.store.LocalFileOffsetStore;
-import com.alibaba.rocketmq.client.consumer.store.OffsetStore;
-import com.alibaba.rocketmq.client.consumer.store.ReadOffsetType;
-import com.alibaba.rocketmq.client.consumer.store.RemoteBrokerOffsetStore;
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.hook.ConsumeMessageContext;
-import com.alibaba.rocketmq.client.hook.ConsumeMessageHook;
-import com.alibaba.rocketmq.client.hook.FilterMessageHook;
-import com.alibaba.rocketmq.client.impl.CommunicationMode;
-import com.alibaba.rocketmq.client.impl.MQClientManager;
-import com.alibaba.rocketmq.client.impl.factory.MQClientInstance;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.ServiceState;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.consumer.ConsumeFromWhere;
-import com.alibaba.rocketmq.common.filter.FilterAPI;
-import com.alibaba.rocketmq.common.help.FAQUrl;
-import com.alibaba.rocketmq.common.message.*;
-import com.alibaba.rocketmq.common.protocol.body.ConsumerRunningInfo;
-import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType;
-import com.alibaba.rocketmq.common.protocol.heartbeat.MessageModel;
-import com.alibaba.rocketmq.common.protocol.heartbeat.SubscriptionData;
-import com.alibaba.rocketmq.common.sysflag.PullSysFlag;
-import com.alibaba.rocketmq.remoting.RPCHook;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import com.alibaba.rocketmq.remoting.exception.RemotingException;
-import org.slf4j.Logger;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-
-
-/**
- * @author shijia.wxr
- */
-public class DefaultMQPullConsumerImpl implements MQConsumerInner {
- private final Logger log = ClientLogger.getLog();
- private final DefaultMQPullConsumer defaultMQPullConsumer;
- private final long consumerStartTimestamp = System.currentTimeMillis();
- private final RPCHook rpcHook;
- private final ArrayList<ConsumeMessageHook> consumeMessageHookList = new ArrayList<ConsumeMessageHook>();
- private final ArrayList<FilterMessageHook> filterMessageHookList = new ArrayList<FilterMessageHook>();
- private ServiceState serviceState = ServiceState.CREATE_JUST;
- private MQClientInstance mQClientFactory;
- private PullAPIWrapper pullAPIWrapper;
- private OffsetStore offsetStore;
- private RebalanceImpl rebalanceImpl = new RebalancePullImpl(this);
-
-
- public DefaultMQPullConsumerImpl(final DefaultMQPullConsumer defaultMQPullConsumer, final RPCHook rpcHook) {
- this.defaultMQPullConsumer = defaultMQPullConsumer;
- this.rpcHook = rpcHook;
- }
-
- public void registerConsumeMessageHook(final ConsumeMessageHook hook) {
- this.consumeMessageHookList.add(hook);
- log.info("register consumeMessageHook Hook, {}", hook.hookName());
- }
-
- public void createTopic(String key, String newTopic, int queueNum) throws MQClientException {
- createTopic(key, newTopic, queueNum, 0);
- }
-
- public void createTopic(String key, String newTopic, int queueNum, int topicSysFlag) throws MQClientException {
- this.makeSureStateOK();
- this.mQClientFactory.getMQAdminImpl().createTopic(key, newTopic, queueNum, topicSysFlag);
- }
-
- private void makeSureStateOK() throws MQClientException {
- if (this.serviceState != ServiceState.RUNNING) {
- throw new MQClientException("The consumer service state not OK, "//
- + this.serviceState//
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
- null);
- }
- }
-
- public long fetchConsumeOffset(MessageQueue mq, boolean fromStore) throws MQClientException {
- this.makeSureStateOK();
- return this.offsetStore.readOffset(mq, fromStore ? ReadOffsetType.READ_FROM_STORE : ReadOffsetType.MEMORY_FIRST_THEN_STORE);
- }
-
- public Set<MessageQueue> fetchMessageQueuesInBalance(String topic) throws MQClientException {
- this.makeSureStateOK();
- if (null == topic) {
- throw new IllegalArgumentException("topic is null");
- }
-
- ConcurrentHashMap<MessageQueue, ProcessQueue> mqTable = this.rebalanceImpl.getProcessQueueTable();
- Set<MessageQueue> mqResult = new HashSet<MessageQueue>();
- for (MessageQueue mq : mqTable.keySet()) {
- if (mq.getTopic().equals(topic)) {
- mqResult.add(mq);
- }
- }
-
- return mqResult;
- }
-
- public List<MessageQueue> fetchPublishMessageQueues(String topic) throws MQClientException {
- this.makeSureStateOK();
- return this.mQClientFactory.getMQAdminImpl().fetchPublishMessageQueues(topic);
- }
-
- public Set<MessageQueue> fetchSubscribeMessageQueues(String topic) throws MQClientException {
- this.makeSureStateOK();
- return this.mQClientFactory.getMQAdminImpl().fetchSubscribeMessageQueues(topic);
- }
-
- public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
- this.makeSureStateOK();
- return this.mQClientFactory.getMQAdminImpl().earliestMsgStoreTime(mq);
- }
-
- public long maxOffset(MessageQueue mq) throws MQClientException {
- this.makeSureStateOK();
- return this.mQClientFactory.getMQAdminImpl().maxOffset(mq);
- }
-
- public long minOffset(MessageQueue mq) throws MQClientException {
- this.makeSureStateOK();
- return this.mQClientFactory.getMQAdminImpl().minOffset(mq);
- }
-
- public PullResult pull(MessageQueue mq, String subExpression, long offset, int maxNums)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- return pull(mq, subExpression, offset, maxNums, this.defaultMQPullConsumer.getConsumerPullTimeoutMillis());
- }
-
- public PullResult pull(MessageQueue mq, String subExpression, long offset, int maxNums, long timeout)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- return this.pullSyncImpl(mq, subExpression, offset, maxNums, false, timeout);
- }
-
- private PullResult pullSyncImpl(MessageQueue mq, String subExpression, long offset, int maxNums, boolean block, long timeout)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- this.makeSureStateOK();
-
- if (null == mq) {
- throw new MQClientException("mq is null", null);
-
- }
-
- if (offset < 0) {
- throw new MQClientException("offset < 0", null);
- }
-
- if (maxNums <= 0) {
- throw new MQClientException("maxNums <= 0", null);
- }
-
- this.subscriptionAutomatically(mq.getTopic());
-
- int sysFlag = PullSysFlag.buildSysFlag(false, block, true, false);
-
- SubscriptionData subscriptionData;
- try {
- subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(), //
- mq.getTopic(), subExpression);
- } catch (Exception e) {
- throw new MQClientException("parse subscription error", e);
- }
-
- long timeoutMillis = block ? this.defaultMQPullConsumer.getConsumerTimeoutMillisWhenSuspend() : timeout;
-
- PullResult pullResult = this.pullAPIWrapper.pullKernelImpl(//
- mq, // 1
- subscriptionData.getSubString(), // 2
- 0L, // 3
- offset, // 4
- maxNums, // 5
- sysFlag, // 6
- 0, // 7
- this.defaultMQPullConsumer.getBrokerSuspendMaxTimeMillis(), // 8
- timeoutMillis, // 9
- CommunicationMode.SYNC, // 10
- null// 11
- );
- this.pullAPIWrapper.processPullResult(mq, pullResult, subscriptionData);
- if (!this.consumeMessageHookList.isEmpty()) {
- ConsumeMessageContext consumeMessageContext = null;
- consumeMessageContext = new ConsumeMessageContext();
- consumeMessageContext.setConsumerGroup(this.groupName());
- consumeMessageContext.setMq(mq);
- consumeMessageContext.setMsgList(pullResult.getMsgFoundList());
- consumeMessageContext.setSuccess(false);
- this.executeHookBefore(consumeMessageContext);
- consumeMessageContext.setStatus(ConsumeConcurrentlyStatus.CONSUME_SUCCESS.toString());
- consumeMessageContext.setSuccess(true);
- this.executeHookAfter(consumeMessageContext);
- }
- return pullResult;
- }
-
- public void subscriptionAutomatically(final String topic) {
- if (!this.rebalanceImpl.getSubscriptionInner().containsKey(topic)) {
- try {
- SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(), //
- topic, SubscriptionData.SUB_ALL);
- this.rebalanceImpl.subscriptionInner.putIfAbsent(topic, subscriptionData);
- } catch (Exception e) {
- }
- }
- }
-
- public void unsubscribe(String topic) {
- this.rebalanceImpl.getSubscriptionInner().remove(topic);
- }
-
- @Override
- public String groupName() {
- return this.defaultMQPullConsumer.getConsumerGroup();
- }
-
- public void executeHookBefore(final ConsumeMessageContext context) {
- if (!this.consumeMessageHookList.isEmpty()) {
- for (ConsumeMessageHook hook : this.consumeMessageHookList) {
- try {
- hook.consumeMessageBefore(context);
- } catch (Throwable e) {
- }
- }
- }
- }
-
- public void executeHookAfter(final ConsumeMessageContext context) {
- if (!this.consumeMessageHookList.isEmpty()) {
- for (ConsumeMessageHook hook : this.consumeMessageHookList) {
- try {
- hook.consumeMessageAfter(context);
- } catch (Throwable e) {
- }
- }
- }
- }
-
- @Override
- public MessageModel messageModel() {
- return this.defaultMQPullConsumer.getMessageModel();
- }
-
- @Override
- public ConsumeType consumeType() {
- return ConsumeType.CONSUME_ACTIVELY;
- }
-
- @Override
- public ConsumeFromWhere consumeFromWhere() {
- return ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET;
- }
-
- @Override
- public Set<SubscriptionData> subscriptions() {
- Set<SubscriptionData> result = new HashSet<SubscriptionData>();
-
- Set<String> topics = this.defaultMQPullConsumer.getRegisterTopics();
- if (topics != null) {
- synchronized (topics) {
- for (String t : topics) {
- SubscriptionData ms = null;
- try {
- ms = FilterAPI.buildSubscriptionData(this.groupName(), t, SubscriptionData.SUB_ALL);
- } catch (Exception e) {
- log.error("parse subscription error", e);
- }
- ms.setSubVersion(0L);
- result.add(ms);
- }
- }
- }
-
- return result;
- }
-
- @Override
- public void doRebalance() {
- if (this.rebalanceImpl != null) {
- this.rebalanceImpl.doRebalance(false);
- }
- }
-
- @Override
- public void persistConsumerOffset() {
- try {
- this.makeSureStateOK();
- Set<MessageQueue> mqs = new HashSet<MessageQueue>();
- Set<MessageQueue> allocateMq = this.rebalanceImpl.getProcessQueueTable().keySet();
- if (allocateMq != null) {
- mqs.addAll(allocateMq);
- }
- this.offsetStore.persistAll(mqs);
- } catch (Exception e) {
- log.error("group: " + this.defaultMQPullConsumer.getConsumerGroup() + " persistConsumerOffset exception", e);
- }
- }
-
- @Override
- public void updateTopicSubscribeInfo(String topic, Set<MessageQueue> info) {
- Map<String, SubscriptionData> subTable = this.rebalanceImpl.getSubscriptionInner();
- if (subTable != null) {
- if (subTable.containsKey(topic)) {
- this.rebalanceImpl.getTopicSubscribeInfoTable().put(topic, info);
- }
- }
- }
-
- @Override
- public boolean isSubscribeTopicNeedUpdate(String topic) {
- Map<String, SubscriptionData> subTable = this.rebalanceImpl.getSubscriptionInner();
- if (subTable != null) {
- if (subTable.containsKey(topic)) {
- return !this.rebalanceImpl.topicSubscribeInfoTable.containsKey(topic);
- }
- }
-
- return false;
- }
-
- @Override
- public boolean isUnitMode() {
- return this.defaultMQPullConsumer.isUnitMode();
- }
-
- @Override
- public ConsumerRunningInfo consumerRunningInfo() {
- ConsumerRunningInfo info = new ConsumerRunningInfo();
-
- Properties prop = MixAll.object2Properties(this.defaultMQPullConsumer);
- prop.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, String.valueOf(this.consumerStartTimestamp));
- info.setProperties(prop);
-
- info.getSubscriptionSet().addAll(this.subscriptions());
- return info;
- }
-
- public void pull(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback)
- throws MQClientException, RemotingException, InterruptedException {
- pull(mq, subExpression, offset, maxNums, pullCallback, this.defaultMQPullConsumer.getConsumerPullTimeoutMillis());
- }
-
- public void pull(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback, long timeout)
- throws MQClientException, RemotingException, InterruptedException {
- this.pullAsyncImpl(mq, subExpression, offset, maxNums, pullCallback, false, timeout);
- }
-
- private void pullAsyncImpl(//
- final MessageQueue mq, //
- final String subExpression, //
- final long offset, //
- final int maxNums, //
- final PullCallback pullCallback, //
- final boolean block, //
- final long timeout) throws MQClientException, RemotingException, InterruptedException {
- this.makeSureStateOK();
-
- if (null == mq) {
- throw new MQClientException("mq is null", null);
- }
-
- if (offset < 0) {
- throw new MQClientException("offset < 0", null);
- }
-
- if (maxNums <= 0) {
- throw new MQClientException("maxNums <= 0", null);
- }
-
- if (null == pullCallback) {
- throw new MQClientException("pullCallback is null", null);
- }
-
- this.subscriptionAutomatically(mq.getTopic());
-
- try {
- int sysFlag = PullSysFlag.buildSysFlag(false, block, true, false);
-
- final SubscriptionData subscriptionData;
- try {
- subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(), //
- mq.getTopic(), subExpression);
- } catch (Exception e) {
- throw new MQClientException("parse subscription error", e);
- }
-
- long timeoutMillis = block ? this.defaultMQPullConsumer.getConsumerTimeoutMillisWhenSuspend() : timeout;
-
- this.pullAPIWrapper.pullKernelImpl(//
- mq, // 1
- subscriptionData.getSubString(), // 2
- 0L, // 3
- offset, // 4
- maxNums, // 5
- sysFlag, // 6
- 0, // 7
- this.defaultMQPullConsumer.getBrokerSuspendMaxTimeMillis(), // 8
- timeoutMillis, // 9
- CommunicationMode.ASYNC, // 10
- new PullCallback() {
-
- @Override
- public void onSuccess(PullResult pullResult) {
- pullCallback
- .onSuccess(DefaultMQPullConsumerImpl.this.pullAPIWrapper.processPullResult(mq, pullResult, subscriptionData));
- }
-
- @Override
- public void onException(Throwable e) {
- pullCallback.onException(e);
- }
- });
- } catch (MQBrokerException e) {
- throw new MQClientException("pullAsync unknow exception", e);
- }
- }
-
- public PullResult pullBlockIfNotFound(MessageQueue mq, String subExpression, long offset, int maxNums)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- return this.pullSyncImpl(mq, subExpression, offset, maxNums, true, this.getDefaultMQPullConsumer().getConsumerPullTimeoutMillis());
- }
-
- public DefaultMQPullConsumer getDefaultMQPullConsumer() {
- return defaultMQPullConsumer;
- }
-
- public void pullBlockIfNotFound(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback)
- throws MQClientException, RemotingException, InterruptedException {
- this.pullAsyncImpl(mq, subExpression, offset, maxNums, pullCallback, true,
- this.getDefaultMQPullConsumer().getConsumerPullTimeoutMillis());
- }
-
- public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
- throws MQClientException, InterruptedException {
- this.makeSureStateOK();
- return this.mQClientFactory.getMQAdminImpl().queryMessage(topic, key, maxNum, begin, end);
- }
-
- public MessageExt queryMessageByUniqKey(String topic, String uniqKey)
- throws MQClientException, InterruptedException {
- this.makeSureStateOK();
- return this.mQClientFactory.getMQAdminImpl().queryMessageByUniqKey(topic, uniqKey);
- }
-
- public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
- this.makeSureStateOK();
- return this.mQClientFactory.getMQAdminImpl().searchOffset(mq, timestamp);
- }
-
- public void sendMessageBack(MessageExt msg, int delayLevel, final String brokerName)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- sendMessageBack(msg, delayLevel, brokerName, this.defaultMQPullConsumer.getConsumerGroup());
- }
-
- public void updateConsumeOffsetToBroker(MessageQueue mq, long offset, boolean isOneway) throws RemotingException,
- MQBrokerException, InterruptedException, MQClientException {
- this.offsetStore.updateConsumeOffsetToBroker(mq, offset, isOneway);
- }
-
- public void sendMessageBack(MessageExt msg, int delayLevel, final String brokerName, String consumerGroup)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- try {
- String brokerAddr = (null != brokerName) ? this.mQClientFactory.findBrokerAddressInPublish(brokerName)
- : RemotingHelper.parseSocketAddressAddr(msg.getStoreHost());
-
- if (UtilAll.isBlank(consumerGroup)) {
- consumerGroup = this.defaultMQPullConsumer.getConsumerGroup();
- }
-
- this.mQClientFactory.getMQClientAPIImpl().consumerSendMessageBack(brokerAddr, msg, consumerGroup, delayLevel, 3000,
- this.defaultMQPullConsumer.getMaxReconsumeTimes());
- } catch (Exception e) {
- log.error("sendMessageBack Exception, " + this.defaultMQPullConsumer.getConsumerGroup(), e);
-
- Message newMsg = new Message(MixAll.getRetryTopic(this.defaultMQPullConsumer.getConsumerGroup()), msg.getBody());
- String originMsgId = MessageAccessor.getOriginMessageId(msg);
- MessageAccessor.setOriginMessageId(newMsg, UtilAll.isBlank(originMsgId) ? msg.getMsgId() : originMsgId);
- newMsg.setFlag(msg.getFlag());
- MessageAccessor.setProperties(newMsg, msg.getProperties());
- MessageAccessor.putProperty(newMsg, MessageConst.PROPERTY_RETRY_TOPIC, msg.getTopic());
- MessageAccessor.setReconsumeTime(newMsg, String.valueOf(msg.getReconsumeTimes() + 1));
- MessageAccessor.setMaxReconsumeTimes(newMsg, String.valueOf(this.defaultMQPullConsumer.getMaxReconsumeTimes()));
- newMsg.setDelayTimeLevel(3 + msg.getReconsumeTimes());
- this.mQClientFactory.getDefaultMQProducer().send(newMsg);
- }
- }
-
- public void shutdown() {
- switch (this.serviceState) {
- case CREATE_JUST:
- break;
- case RUNNING:
- this.persistConsumerOffset();
- this.mQClientFactory.unregisterConsumer(this.defaultMQPullConsumer.getConsumerGroup());
- this.mQClientFactory.shutdown();
- log.info("the consumer [{}] shutdown OK", this.defaultMQPullConsumer.getConsumerGroup());
- this.serviceState = ServiceState.SHUTDOWN_ALREADY;
- break;
- case SHUTDOWN_ALREADY:
- break;
- default:
- break;
- }
- }
-
- public void start() throws MQClientException {
- switch (this.serviceState) {
- case CREATE_JUST:
- this.serviceState = ServiceState.START_FAILED;
-
- this.checkConfig();
-
- this.copySubscription();
-
- if (this.defaultMQPullConsumer.getMessageModel() == MessageModel.CLUSTERING) {
- this.defaultMQPullConsumer.changeInstanceNameToPID();
- }
-
- this.mQClientFactory = MQClientManager.getInstance().getAndCreateMQClientInstance(this.defaultMQPullConsumer, this.rpcHook);
-
- this.rebalanceImpl.setConsumerGroup(this.defaultMQPullConsumer.getConsumerGroup());
- this.rebalanceImpl.setMessageModel(this.defaultMQPullConsumer.getMessageModel());
- this.rebalanceImpl.setAllocateMessageQueueStrategy(this.defaultMQPullConsumer.getAllocateMessageQueueStrategy());
- this.rebalanceImpl.setmQClientFactory(this.mQClientFactory);
-
- this.pullAPIWrapper = new PullAPIWrapper(//
- mQClientFactory, //
- this.defaultMQPullConsumer.getConsumerGroup(), isUnitMode());
- this.pullAPIWrapper.registerFilterMessageHook(filterMessageHookList);
-
- if (this.defaultMQPullConsumer.getOffsetStore() != null) {
- this.offsetStore = this.defaultMQPullConsumer.getOffsetStore();
- } else {
- switch (this.defaultMQPullConsumer.getMessageModel()) {
- case BROADCASTING:
- this.offsetStore = new LocalFileOffsetStore(this.mQClientFactory, this.defaultMQPullConsumer.getConsumerGroup());
- break;
- case CLUSTERING:
- this.offsetStore = new RemoteBrokerOffsetStore(this.mQClientFactory, this.defaultMQPullConsumer.getConsumerGroup());
- break;
- default:
- break;
- }
- }
-
- this.offsetStore.load();
-
- boolean registerOK = mQClientFactory.registerConsumer(this.defaultMQPullConsumer.getConsumerGroup(), this);
- if (!registerOK) {
- this.serviceState = ServiceState.CREATE_JUST;
-
- throw new MQClientException("The consumer group[" + this.defaultMQPullConsumer.getConsumerGroup()
- + "] has been created before, specify another name please." + FAQUrl.suggestTodo(FAQUrl.GROUP_NAME_DUPLICATE_URL),
- null);
- }
-
- mQClientFactory.start();
- log.info("the consumer [{}] start OK", this.defaultMQPullConsumer.getConsumerGroup());
- this.serviceState = ServiceState.RUNNING;
- break;
- case RUNNING:
- case START_FAILED:
- case SHUTDOWN_ALREADY:
- throw new MQClientException("The PullConsumer service state not OK, maybe started once, "//
- + this.serviceState//
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
- null);
- default:
- break;
- }
- }
-
- private void checkConfig() throws MQClientException {
- // check consumerGroup
- Validators.checkGroup(this.defaultMQPullConsumer.getConsumerGroup());
-
- // consumerGroup
- if (null == this.defaultMQPullConsumer.getConsumerGroup()) {
- throw new MQClientException(
- "consumerGroup is null" //
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
- null);
- }
-
- // consumerGroup
- if (this.defaultMQPullConsumer.getConsumerGroup().equals(MixAll.DEFAULT_CONSUMER_GROUP)) {
- throw new MQClientException(
- "consumerGroup can not equal "//
- + MixAll.DEFAULT_CONSUMER_GROUP //
- + ", please specify another one."//
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
- null);
- }
-
- // messageModel
- if (null == this.defaultMQPullConsumer.getMessageModel()) {
- throw new MQClientException(
- "messageModel is null" //
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
- null);
- }
-
- // allocateMessageQueueStrategy
- if (null == this.defaultMQPullConsumer.getAllocateMessageQueueStrategy()) {
- throw new MQClientException(
- "allocateMessageQueueStrategy is null" //
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
- null);
- }
-
- // allocateMessageQueueStrategy
- if (this.defaultMQPullConsumer.getConsumerTimeoutMillisWhenSuspend() < this.defaultMQPullConsumer.getBrokerSuspendMaxTimeMillis()) {
- throw new MQClientException(
- "Long polling mode, the consumer consumerTimeoutMillisWhenSuspend must greater than brokerSuspendMaxTimeMillis" //
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
- null);
- }
- }
-
- private void copySubscription() throws MQClientException {
- try {
- Set<String> registerTopics = this.defaultMQPullConsumer.getRegisterTopics();
- if (registerTopics != null) {
- for (final String topic : registerTopics) {
- SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(), //
- topic, SubscriptionData.SUB_ALL);
- this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData);
- }
- }
- } catch (Exception e) {
- throw new MQClientException("subscription exception", e);
- }
- }
-
- public void updateConsumeOffset(MessageQueue mq, long offset) throws MQClientException {
- this.makeSureStateOK();
- this.offsetStore.updateOffset(mq, offset, false);
- }
-
- public MessageExt viewMessage(String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- this.makeSureStateOK();
- return this.mQClientFactory.getMQAdminImpl().viewMessage(msgId);
- }
-
- public void registerFilterMessageHook(final FilterMessageHook hook) {
- this.filterMessageHookList.add(hook);
- log.info("register FilterMessageHook Hook, {}", hook.hookName());
- }
-
- public OffsetStore getOffsetStore() {
- return offsetStore;
- }
-
- public void setOffsetStore(OffsetStore offsetStore) {
- this.offsetStore = offsetStore;
- }
-
- public PullAPIWrapper getPullAPIWrapper() {
- return pullAPIWrapper;
- }
-
- public void setPullAPIWrapper(PullAPIWrapper pullAPIWrapper) {
- this.pullAPIWrapper = pullAPIWrapper;
- }
-
- public ServiceState getServiceState() {
- return serviceState;
- }
-
- public void setServiceState(ServiceState serviceState) {
- this.serviceState = serviceState;
- }
-
- public long getConsumerStartTimestamp() {
- return consumerStartTimestamp;
- }
-
-
- public RebalanceImpl getRebalanceImpl() {
- return rebalanceImpl;
- }
-}
[25/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java
new file mode 100644
index 0000000..8700ef1
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java
@@ -0,0 +1,71 @@
+/**
+ * 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.impl;
+
+import org.apache.rocketmq.client.ClientConfig;
+import org.apache.rocketmq.client.impl.factory.MQClientInstance;
+import org.apache.rocketmq.remoting.RPCHook;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class MQClientManager {
+ private static MQClientManager instance = new MQClientManager();
+ private AtomicInteger factoryIndexGenerator = new AtomicInteger();
+ private ConcurrentHashMap<String/* clientId */, MQClientInstance> factoryTable =
+ new ConcurrentHashMap<String, MQClientInstance>();
+
+
+ private MQClientManager() {
+
+ }
+
+
+ public static MQClientManager getInstance() {
+ return instance;
+ }
+
+ public MQClientInstance getAndCreateMQClientInstance(final ClientConfig clientConfig) {
+ return getAndCreateMQClientInstance(clientConfig, null);
+ }
+
+ public MQClientInstance getAndCreateMQClientInstance(final ClientConfig clientConfig, RPCHook rpcHook) {
+ String clientId = clientConfig.buildMQClientId();
+ MQClientInstance instance = this.factoryTable.get(clientId);
+ if (null == instance) {
+ instance =
+ new MQClientInstance(clientConfig.cloneClientConfig(),
+ this.factoryIndexGenerator.getAndIncrement(), clientId, rpcHook);
+ MQClientInstance prev = this.factoryTable.putIfAbsent(clientId, instance);
+ if (prev != null) {
+ instance = prev;
+ } else {
+ // TODO log
+ }
+ }
+
+ return instance;
+ }
+
+ public void removeClientFactory(final String clientId) {
+ this.factoryTable.remove(clientId);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
new file mode 100644
index 0000000..88fe25f
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
@@ -0,0 +1,471 @@
+/**
+ * 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.impl.consumer;
+
+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.ConsumeReturnType;
+import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
+import org.apache.rocketmq.client.hook.ConsumeMessageContext;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.client.stat.ConsumerStatsManager;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.ThreadFactoryImpl;
+import org.apache.rocketmq.common.message.MessageAccessor;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.body.CMResult;
+import org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.slf4j.Logger;
+
+import java.util.*;
+import java.util.concurrent.*;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ConsumeMessageConcurrentlyService implements ConsumeMessageService {
+ private static final Logger log = ClientLogger.getLog();
+ private final DefaultMQPushConsumerImpl defaultMQPushConsumerImpl;
+ private final DefaultMQPushConsumer defaultMQPushConsumer;
+ private final MessageListenerConcurrently messageListener;
+ private final BlockingQueue<Runnable> consumeRequestQueue;
+ private final ThreadPoolExecutor consumeExecutor;
+ private final String consumerGroup;
+
+ private final ScheduledExecutorService scheduledExecutorService;
+ private final ScheduledExecutorService cleanExpireMsgExecutors;
+
+
+ public ConsumeMessageConcurrentlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl,
+ MessageListenerConcurrently messageListener) {
+ this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
+ this.messageListener = messageListener;
+
+ this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
+ this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
+ this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();
+
+ this.consumeExecutor = new ThreadPoolExecutor(//
+ this.defaultMQPushConsumer.getConsumeThreadMin(), //
+ this.defaultMQPushConsumer.getConsumeThreadMax(), //
+ 1000 * 60, //
+ TimeUnit.MILLISECONDS, //
+ this.consumeRequestQueue, //
+ new ThreadFactoryImpl("ConsumeMessageThread_"));
+
+ this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
+ this.cleanExpireMsgExecutors = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("CleanExpireMsgScheduledThread_"));
+ }
+
+
+ public void start() {
+ this.cleanExpireMsgExecutors.scheduleAtFixedRate(new Runnable() {
+
+ @Override
+ public void run() {
+ cleanExpireMsg();
+ }
+
+ }, this.defaultMQPushConsumer.getConsumeTimeout(), this.defaultMQPushConsumer.getConsumeTimeout(), TimeUnit.MINUTES);
+ }
+
+
+ public void shutdown() {
+ this.scheduledExecutorService.shutdown();
+ this.consumeExecutor.shutdown();
+ this.cleanExpireMsgExecutors.shutdown();
+ }
+
+ @Override
+ public void updateCorePoolSize(int corePoolSize) {
+ if (corePoolSize > 0 //
+ && corePoolSize <= Short.MAX_VALUE //
+ && corePoolSize < this.defaultMQPushConsumer.getConsumeThreadMax()) {
+ this.consumeExecutor.setCorePoolSize(corePoolSize);
+ }
+ }
+
+ @Override
+ public void incCorePoolSize() {
+ // long corePoolSize = this.consumeExecutor.getCorePoolSize();
+ // if (corePoolSize < this.defaultMQPushConsumer.getConsumeThreadMax())
+ // {
+ // this.consumeExecutor.setCorePoolSize(this.consumeExecutor.getCorePoolSize()
+ // + 1);
+ // }
+ //
+ // log.info("incCorePoolSize Concurrently from {} to {}, ConsumerGroup:
+ // {}", //
+ // corePoolSize,//
+ // this.consumeExecutor.getCorePoolSize(),//
+ // this.consumerGroup);
+ }
+
+ @Override
+ public void decCorePoolSize() {
+ // long corePoolSize = this.consumeExecutor.getCorePoolSize();
+ // if (corePoolSize > this.defaultMQPushConsumer.getConsumeThreadMin())
+ // {
+ // this.consumeExecutor.setCorePoolSize(this.consumeExecutor.getCorePoolSize()
+ // - 1);
+ // }
+ //
+ // log.info("decCorePoolSize Concurrently from {} to {}, ConsumerGroup:
+ // {}", //
+ // corePoolSize,//
+ // this.consumeExecutor.getCorePoolSize(),//
+ // this.consumerGroup);
+ }
+
+ @Override
+ public int getCorePoolSize() {
+ return this.consumeExecutor.getCorePoolSize();
+ }
+
+ @Override
+ public ConsumeMessageDirectlyResult consumeMessageDirectly(MessageExt msg, String brokerName) {
+ ConsumeMessageDirectlyResult result = new ConsumeMessageDirectlyResult();
+ result.setOrder(false);
+ result.setAutoCommit(true);
+
+ List<MessageExt> msgs = new ArrayList<MessageExt>();
+ msgs.add(msg);
+ MessageQueue mq = new MessageQueue();
+ mq.setBrokerName(brokerName);
+ mq.setTopic(msg.getTopic());
+ mq.setQueueId(msg.getQueueId());
+
+ ConsumeConcurrentlyContext context = new ConsumeConcurrentlyContext(mq);
+
+ this.resetRetryTopic(msgs);
+
+ final long beginTime = System.currentTimeMillis();
+
+ log.info("consumeMessageDirectly receive new messge: {}", msg);
+
+ try {
+ ConsumeConcurrentlyStatus status = this.messageListener.consumeMessage(msgs, context);
+ if (status != null) {
+ switch (status) {
+ case CONSUME_SUCCESS:
+ result.setConsumeResult(CMResult.CR_SUCCESS);
+ break;
+ case RECONSUME_LATER:
+ result.setConsumeResult(CMResult.CR_LATER);
+ break;
+ default:
+ break;
+ }
+ } else {
+ result.setConsumeResult(CMResult.CR_RETURN_NULL);
+ }
+ } catch (Throwable e) {
+ result.setConsumeResult(CMResult.CR_THROW_EXCEPTION);
+ result.setRemark(RemotingHelper.exceptionSimpleDesc(e));
+
+ log.warn(String.format("consumeMessageDirectly exception: %s Group: %s Msgs: %s MQ: %s", //
+ RemotingHelper.exceptionSimpleDesc(e), //
+ ConsumeMessageConcurrentlyService.this.consumerGroup, //
+ msgs, //
+ mq), e);
+ }
+
+ result.setSpentTimeMills(System.currentTimeMillis() - beginTime);
+
+ log.info("consumeMessageDirectly Result: {}", result);
+
+ return result;
+ }
+
+ @Override
+ public void submitConsumeRequest(//
+ final List<MessageExt> msgs, //
+ final ProcessQueue processQueue, //
+ final MessageQueue messageQueue, //
+ final boolean dispatchToConsume) {
+ final int consumeBatchSize = this.defaultMQPushConsumer.getConsumeMessageBatchMaxSize();
+ if (msgs.size() <= consumeBatchSize) {
+ ConsumeRequest consumeRequest = new ConsumeRequest(msgs, processQueue, messageQueue);
+ try {
+ this.consumeExecutor.submit(consumeRequest);
+ } catch (RejectedExecutionException e) {
+ this.submitConsumeRequestLater(consumeRequest);
+ }
+ } else {
+ for (int total = 0; total < msgs.size(); ) {
+ List<MessageExt> msgThis = new ArrayList<MessageExt>(consumeBatchSize);
+ for (int i = 0; i < consumeBatchSize; i++, total++) {
+ if (total < msgs.size()) {
+ msgThis.add(msgs.get(total));
+ } else {
+ break;
+ }
+ }
+
+ ConsumeRequest consumeRequest = new ConsumeRequest(msgThis, processQueue, messageQueue);
+ try {
+ this.consumeExecutor.submit(consumeRequest);
+ } catch (RejectedExecutionException e) {
+ for (; total < msgs.size(); total++) {
+ msgThis.add(msgs.get(total));
+ }
+
+ this.submitConsumeRequestLater(consumeRequest);
+ }
+ }
+ }
+ }
+
+ public void resetRetryTopic(final List<MessageExt> msgs) {
+ final String groupTopic = MixAll.getRetryTopic(consumerGroup);
+ for (MessageExt msg : msgs) {
+ String retryTopic = msg.getProperty(MessageConst.PROPERTY_RETRY_TOPIC);
+ if (retryTopic != null && groupTopic.equals(msg.getTopic())) {
+ msg.setTopic(retryTopic);
+ }
+ }
+ }
+
+ private void cleanExpireMsg() {
+ Iterator<Map.Entry<MessageQueue, ProcessQueue>> it =
+ this.defaultMQPushConsumerImpl.getRebalanceImpl().getProcessQueueTable().entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry<MessageQueue, ProcessQueue> next = it.next();
+ ProcessQueue pq = next.getValue();
+ pq.cleanExpiredMsg(this.defaultMQPushConsumer);
+ }
+ }
+
+ public void processConsumeResult(//
+ final ConsumeConcurrentlyStatus status, //
+ final ConsumeConcurrentlyContext context, //
+ final ConsumeRequest consumeRequest//
+ ) {
+ int ackIndex = context.getAckIndex();
+
+ if (consumeRequest.getMsgs().isEmpty())
+ return;
+
+ switch (status) {
+ case CONSUME_SUCCESS:
+ if (ackIndex >= consumeRequest.getMsgs().size()) {
+ ackIndex = consumeRequest.getMsgs().size() - 1;
+ }
+ int ok = ackIndex + 1;
+ int failed = consumeRequest.getMsgs().size() - ok;
+ this.getConsumerStatsManager().incConsumeOKTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(), ok);
+ this.getConsumerStatsManager().incConsumeFailedTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(), failed);
+ break;
+ case RECONSUME_LATER:
+ ackIndex = -1;
+ this.getConsumerStatsManager().incConsumeFailedTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(),
+ consumeRequest.getMsgs().size());
+ break;
+ default:
+ break;
+ }
+
+ switch (this.defaultMQPushConsumer.getMessageModel()) {
+ case BROADCASTING:
+ for (int i = ackIndex + 1; i < consumeRequest.getMsgs().size(); i++) {
+ MessageExt msg = consumeRequest.getMsgs().get(i);
+ log.warn("BROADCASTING, the message consume failed, drop it, {}", msg.toString());
+ }
+ break;
+ case CLUSTERING:
+ List<MessageExt> msgBackFailed = new ArrayList<MessageExt>(consumeRequest.getMsgs().size());
+ for (int i = ackIndex + 1; i < consumeRequest.getMsgs().size(); i++) {
+ MessageExt msg = consumeRequest.getMsgs().get(i);
+ boolean result = this.sendMessageBack(msg, context);
+ if (!result) {
+ msg.setReconsumeTimes(msg.getReconsumeTimes() + 1);
+ msgBackFailed.add(msg);
+ }
+ }
+
+ if (!msgBackFailed.isEmpty()) {
+ consumeRequest.getMsgs().removeAll(msgBackFailed);
+
+ this.submitConsumeRequestLater(msgBackFailed, consumeRequest.getProcessQueue(), consumeRequest.getMessageQueue());
+ }
+ break;
+ default:
+ break;
+ }
+
+ long offset = consumeRequest.getProcessQueue().removeMessage(consumeRequest.getMsgs());
+ if (offset >= 0 && !consumeRequest.getProcessQueue().isDropped()) {
+ this.defaultMQPushConsumerImpl.getOffsetStore().updateOffset(consumeRequest.getMessageQueue(), offset, true);
+ }
+ }
+
+ public ConsumerStatsManager getConsumerStatsManager() {
+ return this.defaultMQPushConsumerImpl.getConsumerStatsManager();
+ }
+
+ public boolean sendMessageBack(final MessageExt msg, final ConsumeConcurrentlyContext context) {
+ int delayLevel = context.getDelayLevelWhenNextConsume();
+
+ try {
+ this.defaultMQPushConsumerImpl.sendMessageBack(msg, delayLevel, context.getMessageQueue().getBrokerName());
+ return true;
+ } catch (Exception e) {
+ log.error("sendMessageBack exception, group: " + this.consumerGroup + " msg: " + msg.toString(), e);
+ }
+
+ return false;
+ }
+
+ private void submitConsumeRequestLater(//
+ final List<MessageExt> msgs, //
+ final ProcessQueue processQueue, //
+ final MessageQueue messageQueue//
+ ) {
+
+ this.scheduledExecutorService.schedule(new Runnable() {
+
+ @Override
+ public void run() {
+ ConsumeMessageConcurrentlyService.this.submitConsumeRequest(msgs, processQueue, messageQueue, true);
+ }
+ }, 5000, TimeUnit.MILLISECONDS);
+ }
+
+ private void submitConsumeRequestLater(final ConsumeRequest consumeRequest//
+ ) {
+
+ this.scheduledExecutorService.schedule(new Runnable() {
+
+ @Override
+ public void run() {
+ ConsumeMessageConcurrentlyService.this.consumeExecutor.submit(consumeRequest);
+ }
+ }, 5000, TimeUnit.MILLISECONDS);
+ }
+
+ class ConsumeRequest implements Runnable {
+ private final List<MessageExt> msgs;
+ private final ProcessQueue processQueue;
+ private final MessageQueue messageQueue;
+
+
+ public ConsumeRequest(List<MessageExt> msgs, ProcessQueue processQueue, MessageQueue messageQueue) {
+ this.msgs = msgs;
+ this.processQueue = processQueue;
+ this.messageQueue = messageQueue;
+ }
+
+ public List<MessageExt> getMsgs() {
+ return msgs;
+ }
+
+ public ProcessQueue getProcessQueue() {
+ return processQueue;
+ }
+
+ @Override
+ public void run() {
+ if (this.processQueue.isDropped()) {
+ log.info("the message queue not be able to consume, because it's dropped. group={} {}", ConsumeMessageConcurrentlyService.this.consumerGroup, this.messageQueue);
+ return;
+ }
+
+ MessageListenerConcurrently listener = ConsumeMessageConcurrentlyService.this.messageListener;
+ ConsumeConcurrentlyContext context = new ConsumeConcurrentlyContext(messageQueue);
+ ConsumeConcurrentlyStatus status = null;
+
+ ConsumeMessageContext consumeMessageContext = null;
+ if (ConsumeMessageConcurrentlyService.this.defaultMQPushConsumerImpl.hasHook()) {
+ consumeMessageContext = new ConsumeMessageContext();
+ consumeMessageContext.setConsumerGroup(defaultMQPushConsumer.getConsumerGroup());
+ consumeMessageContext.setProps(new HashMap<String, String>());
+ consumeMessageContext.setMq(messageQueue);
+ consumeMessageContext.setMsgList(msgs);
+ consumeMessageContext.setSuccess(false);
+ ConsumeMessageConcurrentlyService.this.defaultMQPushConsumerImpl.executeHookBefore(consumeMessageContext);
+ }
+
+ long beginTimestamp = System.currentTimeMillis();
+ boolean hasException = false;
+ ConsumeReturnType returnType = ConsumeReturnType.SUCCESS;
+ try {
+ ConsumeMessageConcurrentlyService.this.resetRetryTopic(msgs);
+ if (msgs != null && !msgs.isEmpty()) {
+ for (MessageExt msg : msgs) {
+ MessageAccessor.setConsumeStartTimeStamp(msg, String.valueOf(System.currentTimeMillis()));
+ }
+ }
+ status = listener.consumeMessage(Collections.unmodifiableList(msgs), context);
+ } catch (Throwable e) {
+ log.warn("consumeMessage exception: {} Group: {} Msgs: {} MQ: {}",
+ RemotingHelper.exceptionSimpleDesc(e), //
+ ConsumeMessageConcurrentlyService.this.consumerGroup,
+ msgs,
+ messageQueue);
+ hasException = true;
+ }
+ long consumeRT = System.currentTimeMillis() - beginTimestamp;
+ if (null == status) {
+ if (hasException) {
+ returnType = ConsumeReturnType.EXCEPTION;
+ } else {
+ returnType = ConsumeReturnType.RETURNNULL;
+ }
+ } else if (consumeRT >= defaultMQPushConsumer.getConsumeTimeout() * 60 * 1000) {
+ returnType = ConsumeReturnType.TIME_OUT;
+ } else if (ConsumeConcurrentlyStatus.RECONSUME_LATER == status) {
+ returnType = ConsumeReturnType.FAILED;
+ } else if (ConsumeConcurrentlyStatus.CONSUME_SUCCESS == status) {
+ returnType = ConsumeReturnType.SUCCESS;
+ }
+ consumeMessageContext.getProps().put(MixAll.CONSUME_CONTEXT_TYPE, returnType.name());
+ if (null == status) {
+ log.warn("consumeMessage return null, Group: {} Msgs: {} MQ: {}",
+ ConsumeMessageConcurrentlyService.this.consumerGroup,
+ msgs,
+ messageQueue);
+ status = ConsumeConcurrentlyStatus.RECONSUME_LATER;
+ }
+
+ if (ConsumeMessageConcurrentlyService.this.defaultMQPushConsumerImpl.hasHook()) {
+ consumeMessageContext.setStatus(status.toString());
+ consumeMessageContext.setSuccess(ConsumeConcurrentlyStatus.CONSUME_SUCCESS == status);
+ ConsumeMessageConcurrentlyService.this.defaultMQPushConsumerImpl.executeHookAfter(consumeMessageContext);
+ }
+
+ ConsumeMessageConcurrentlyService.this.getConsumerStatsManager()
+ .incConsumeRT(ConsumeMessageConcurrentlyService.this.consumerGroup, messageQueue.getTopic(), consumeRT);
+
+ if (!processQueue.isDropped()) {
+ ConsumeMessageConcurrentlyService.this.processConsumeResult(status, context, this);
+ } else {
+ log.warn("processQueue is dropped without process consume result. messageQueue={}, msgs={}", messageQueue, msgs);
+ }
+ }
+
+ public MessageQueue getMessageQueue() {
+ return messageQueue;
+ }
+
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
new file mode 100644
index 0000000..010fd2f
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
@@ -0,0 +1,539 @@
+/**
+ * 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.impl.consumer;
+
+import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
+import org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyStatus;
+import org.apache.rocketmq.client.consumer.listener.ConsumeReturnType;
+import org.apache.rocketmq.client.hook.ConsumeMessageContext;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.client.stat.ConsumerStatsManager;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.ThreadFactoryImpl;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.message.*;
+import org.apache.rocketmq.common.protocol.body.CMResult;
+import org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyContext;
+import org.apache.rocketmq.client.consumer.listener.MessageListenerOrderly;
+import org.slf4j.Logger;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.*;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ConsumeMessageOrderlyService implements ConsumeMessageService {
+ private static final Logger log = ClientLogger.getLog();
+ private final static long MAX_TIME_CONSUME_CONTINUOUSLY =
+ Long.parseLong(System.getProperty("rocketmq.client.maxTimeConsumeContinuously", "60000"));
+ private final DefaultMQPushConsumerImpl defaultMQPushConsumerImpl;
+ private final DefaultMQPushConsumer defaultMQPushConsumer;
+ private final MessageListenerOrderly messageListener;
+ private final BlockingQueue<Runnable> consumeRequestQueue;
+ private final ThreadPoolExecutor consumeExecutor;
+ private final String consumerGroup;
+ private final MessageQueueLock messageQueueLock = new MessageQueueLock();
+ private final ScheduledExecutorService scheduledExecutorService;
+ private volatile boolean stopped = false;
+
+
+ public ConsumeMessageOrderlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl, MessageListenerOrderly messageListener) {
+ this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
+ this.messageListener = messageListener;
+
+ this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
+ this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
+ this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();
+
+ this.consumeExecutor = new ThreadPoolExecutor(//
+ this.defaultMQPushConsumer.getConsumeThreadMin(), //
+ this.defaultMQPushConsumer.getConsumeThreadMax(), //
+ 1000 * 60, //
+ TimeUnit.MILLISECONDS, //
+ this.consumeRequestQueue, //
+ new ThreadFactoryImpl("ConsumeMessageThread_"));
+
+ this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
+ }
+
+
+ public void start() {
+ if (MessageModel.CLUSTERING.equals(ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.messageModel())) {
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ ConsumeMessageOrderlyService.this.lockMQPeriodically();
+ }
+ }, 1000 * 1, ProcessQueue.REBALANCE_LOCK_INTERVAL, TimeUnit.MILLISECONDS);
+ }
+ }
+
+
+ public void shutdown() {
+ this.stopped = true;
+ this.scheduledExecutorService.shutdown();
+ this.consumeExecutor.shutdown();
+ if (MessageModel.CLUSTERING.equals(this.defaultMQPushConsumerImpl.messageModel())) {
+ this.unlockAllMQ();
+ }
+ }
+
+
+ public synchronized void unlockAllMQ() {
+ this.defaultMQPushConsumerImpl.getRebalanceImpl().unlockAll(false);
+ }
+
+ @Override
+ public void updateCorePoolSize(int corePoolSize) {
+ if (corePoolSize > 0 //
+ && corePoolSize <= Short.MAX_VALUE //
+ && corePoolSize < this.defaultMQPushConsumer.getConsumeThreadMax()) {
+ this.consumeExecutor.setCorePoolSize(corePoolSize);
+ }
+ }
+
+ @Override
+ public void incCorePoolSize() {
+ }
+
+ @Override
+ public void decCorePoolSize() {
+ }
+
+ @Override
+ public int getCorePoolSize() {
+ return this.consumeExecutor.getCorePoolSize();
+ }
+
+ @Override
+ public ConsumeMessageDirectlyResult consumeMessageDirectly(MessageExt msg, String brokerName) {
+ ConsumeMessageDirectlyResult result = new ConsumeMessageDirectlyResult();
+ result.setOrder(true);
+
+ List<MessageExt> msgs = new ArrayList<MessageExt>();
+ msgs.add(msg);
+ MessageQueue mq = new MessageQueue();
+ mq.setBrokerName(brokerName);
+ mq.setTopic(msg.getTopic());
+ mq.setQueueId(msg.getQueueId());
+
+ ConsumeOrderlyContext context = new ConsumeOrderlyContext(mq);
+
+ final long beginTime = System.currentTimeMillis();
+
+ log.info("consumeMessageDirectly receive new messge: {}", msg);
+
+ try {
+ ConsumeOrderlyStatus status = this.messageListener.consumeMessage(msgs, context);
+ if (status != null) {
+ switch (status) {
+ case COMMIT:
+ result.setConsumeResult(CMResult.CR_COMMIT);
+ break;
+ case ROLLBACK:
+ result.setConsumeResult(CMResult.CR_ROLLBACK);
+ break;
+ case SUCCESS:
+ result.setConsumeResult(CMResult.CR_SUCCESS);
+ break;
+ case SUSPEND_CURRENT_QUEUE_A_MOMENT:
+ result.setConsumeResult(CMResult.CR_LATER);
+ break;
+ default:
+ break;
+ }
+ } else {
+ result.setConsumeResult(CMResult.CR_RETURN_NULL);
+ }
+ } catch (Throwable e) {
+ result.setConsumeResult(CMResult.CR_THROW_EXCEPTION);
+ result.setRemark(RemotingHelper.exceptionSimpleDesc(e));
+
+ log.warn(String.format("consumeMessageDirectly exception: %s Group: %s Msgs: %s MQ: %s", //
+ RemotingHelper.exceptionSimpleDesc(e), //
+ ConsumeMessageOrderlyService.this.consumerGroup, //
+ msgs, //
+ mq), e);
+ }
+
+ result.setAutoCommit(context.isAutoCommit());
+ result.setSpentTimeMills(System.currentTimeMillis() - beginTime);
+
+ log.info("consumeMessageDirectly Result: {}", result);
+
+ return result;
+ }
+
+ @Override
+ public void submitConsumeRequest(//
+ final List<MessageExt> msgs, //
+ final ProcessQueue processQueue, //
+ final MessageQueue messageQueue, //
+ final boolean dispathToConsume) {
+ if (dispathToConsume) {
+ ConsumeRequest consumeRequest = new ConsumeRequest(processQueue, messageQueue);
+ this.consumeExecutor.submit(consumeRequest);
+ }
+ }
+
+ public synchronized void lockMQPeriodically() {
+ if (!this.stopped) {
+ this.defaultMQPushConsumerImpl.getRebalanceImpl().lockAll();
+ }
+ }
+
+ public void tryLockLaterAndReconsume(final MessageQueue mq, final ProcessQueue processQueue, final long delayMills) {
+ this.scheduledExecutorService.schedule(new Runnable() {
+ @Override
+ public void run() {
+ boolean lockOK = ConsumeMessageOrderlyService.this.lockOneMQ(mq);
+ if (lockOK) {
+ ConsumeMessageOrderlyService.this.submitConsumeRequestLater(processQueue, mq, 10);
+ } else {
+ ConsumeMessageOrderlyService.this.submitConsumeRequestLater(processQueue, mq, 3000);
+ }
+ }
+ }, delayMills, TimeUnit.MILLISECONDS);
+ }
+
+ public synchronized boolean lockOneMQ(final MessageQueue mq) {
+ if (!this.stopped) {
+ return this.defaultMQPushConsumerImpl.getRebalanceImpl().lock(mq);
+ }
+
+ return false;
+ }
+
+ private void submitConsumeRequestLater(//
+ final ProcessQueue processQueue, //
+ final MessageQueue messageQueue, //
+ final long suspendTimeMillis//
+ ) {
+ long timeMillis = suspendTimeMillis;
+ if (timeMillis == -1) {
+ timeMillis = this.defaultMQPushConsumer.getSuspendCurrentQueueTimeMillis();
+ }
+
+ if (timeMillis < 10) {
+ timeMillis = 10;
+ } else if (timeMillis > 30000) {
+ timeMillis = 30000;
+ }
+
+ this.scheduledExecutorService.schedule(new Runnable() {
+
+ @Override
+ public void run() {
+ ConsumeMessageOrderlyService.this.submitConsumeRequest(null, processQueue, messageQueue, true);
+ }
+ }, timeMillis, TimeUnit.MILLISECONDS);
+ }
+
+ public boolean processConsumeResult(//
+ final List<MessageExt> msgs, //
+ final ConsumeOrderlyStatus status, //
+ final ConsumeOrderlyContext context, //
+ final ConsumeRequest consumeRequest//
+ ) {
+ boolean continueConsume = true;
+ long commitOffset = -1L;
+ if (context.isAutoCommit()) {
+ switch (status) {
+ case COMMIT:
+ case ROLLBACK:
+ log.warn("the message queue consume result is illegal, we think you want to ack these message {}",
+ consumeRequest.getMessageQueue());
+ case SUCCESS:
+ commitOffset = consumeRequest.getProcessQueue().commit();
+ this.getConsumerStatsManager().incConsumeOKTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(), msgs.size());
+ break;
+ case SUSPEND_CURRENT_QUEUE_A_MOMENT:
+ this.getConsumerStatsManager().incConsumeFailedTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(), msgs.size());
+ if (checkReconsumeTimes(msgs)) {
+ consumeRequest.getProcessQueue().makeMessageToCosumeAgain(msgs);
+ this.submitConsumeRequestLater(//
+ consumeRequest.getProcessQueue(), //
+ consumeRequest.getMessageQueue(), //
+ context.getSuspendCurrentQueueTimeMillis());
+ continueConsume = false;
+ } else {
+ commitOffset = consumeRequest.getProcessQueue().commit();
+ }
+ break;
+ default:
+ break;
+ }
+ } else {
+ switch (status) {
+ case SUCCESS:
+ this.getConsumerStatsManager().incConsumeOKTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(), msgs.size());
+ break;
+ case COMMIT:
+ commitOffset = consumeRequest.getProcessQueue().commit();
+ break;
+ case ROLLBACK:
+ consumeRequest.getProcessQueue().rollback();
+ this.submitConsumeRequestLater(//
+ consumeRequest.getProcessQueue(), //
+ consumeRequest.getMessageQueue(), //
+ context.getSuspendCurrentQueueTimeMillis());
+ continueConsume = false;
+ break;
+ case SUSPEND_CURRENT_QUEUE_A_MOMENT:
+ this.getConsumerStatsManager().incConsumeFailedTPS(consumerGroup, consumeRequest.getMessageQueue().getTopic(), msgs.size());
+ if (checkReconsumeTimes(msgs)) {
+ consumeRequest.getProcessQueue().makeMessageToCosumeAgain(msgs);
+ this.submitConsumeRequestLater(//
+ consumeRequest.getProcessQueue(), //
+ consumeRequest.getMessageQueue(), //
+ context.getSuspendCurrentQueueTimeMillis());
+ continueConsume = false;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (commitOffset >= 0 && !consumeRequest.getProcessQueue().isDropped()) {
+ this.defaultMQPushConsumerImpl.getOffsetStore().updateOffset(consumeRequest.getMessageQueue(), commitOffset, false);
+ }
+
+ return continueConsume;
+ }
+
+ public ConsumerStatsManager getConsumerStatsManager() {
+ return this.defaultMQPushConsumerImpl.getConsumerStatsManager();
+ }
+
+ private int getMaxReconsumeTimes() {
+ // default reconsume times: Integer.MAX_VALUE
+ if (this.defaultMQPushConsumer.getMaxReconsumeTimes() == -1) {
+ return Integer.MAX_VALUE;
+ } else {
+ return this.defaultMQPushConsumer.getMaxReconsumeTimes();
+ }
+ }
+
+ private boolean checkReconsumeTimes(List<MessageExt> msgs) {
+ boolean suspend = false;
+ if (msgs != null && !msgs.isEmpty()) {
+ for (MessageExt msg : msgs) {
+ if (msg.getReconsumeTimes() >= getMaxReconsumeTimes()) {
+ MessageAccessor.setReconsumeTime(msg, String.valueOf(msg.getReconsumeTimes()));
+ if (!sendMessageBack(msg)) {
+ suspend = true;
+ msg.setReconsumeTimes(msg.getReconsumeTimes() + 1);
+ }
+ } else {
+ suspend = true;
+ msg.setReconsumeTimes(msg.getReconsumeTimes() + 1);
+ }
+ }
+ }
+ return suspend;
+ }
+
+ public boolean sendMessageBack(final MessageExt msg) {
+ try {
+ // max reconsume times exceeded then send to dead letter queue.
+ Message newMsg = new Message(MixAll.getRetryTopic(this.defaultMQPushConsumer.getConsumerGroup()), msg.getBody());
+ String originMsgId = MessageAccessor.getOriginMessageId(msg);
+ MessageAccessor.setOriginMessageId(newMsg, UtilAll.isBlank(originMsgId) ? msg.getMsgId() : originMsgId);
+ newMsg.setFlag(msg.getFlag());
+ MessageAccessor.setProperties(newMsg, msg.getProperties());
+ MessageAccessor.putProperty(newMsg, MessageConst.PROPERTY_RETRY_TOPIC, msg.getTopic());
+ MessageAccessor.setReconsumeTime(newMsg, String.valueOf(msg.getReconsumeTimes()));
+ MessageAccessor.setMaxReconsumeTimes(newMsg, String.valueOf(getMaxReconsumeTimes()));
+ newMsg.setDelayTimeLevel(3 + msg.getReconsumeTimes());
+
+ this.defaultMQPushConsumer.getDefaultMQPushConsumerImpl().getmQClientFactory().getDefaultMQProducer().send(newMsg);
+ return true;
+ } catch (Exception e) {
+ log.error("sendMessageBack exception, group: " + this.consumerGroup + " msg: " + msg.toString(), e);
+ }
+
+ return false;
+ }
+
+ class ConsumeRequest implements Runnable {
+ private final ProcessQueue processQueue;
+ private final MessageQueue messageQueue;
+
+
+ public ConsumeRequest(ProcessQueue processQueue, MessageQueue messageQueue) {
+ this.processQueue = processQueue;
+ this.messageQueue = messageQueue;
+ }
+
+ public ProcessQueue getProcessQueue() {
+ return processQueue;
+ }
+
+ public MessageQueue getMessageQueue() {
+ return messageQueue;
+ }
+
+ @Override
+ public void run() {
+ if (this.processQueue.isDropped()) {
+ log.warn("run, the message queue not be able to consume, because it's dropped. {}", this.messageQueue);
+ return;
+ }
+
+ final Object objLock = messageQueueLock.fetchLockObject(this.messageQueue);
+ synchronized (objLock) {
+ if (MessageModel.BROADCASTING.equals(ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.messageModel())
+ || (this.processQueue.isLocked() && !this.processQueue.isLockExpired())) {
+ final long beginTime = System.currentTimeMillis();
+ for (boolean continueConsume = true; continueConsume; ) {
+ if (this.processQueue.isDropped()) {
+ log.warn("the message queue not be able to consume, because it's dropped. {}", this.messageQueue);
+ break;
+ }
+
+ if (MessageModel.CLUSTERING.equals(ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.messageModel())
+ && !this.processQueue.isLocked()) {
+ log.warn("the message queue not locked, so consume later, {}", this.messageQueue);
+ ConsumeMessageOrderlyService.this.tryLockLaterAndReconsume(this.messageQueue, this.processQueue, 10);
+ break;
+ }
+
+ if (MessageModel.CLUSTERING.equals(ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.messageModel())
+ && this.processQueue.isLockExpired()) {
+ log.warn("the message queue lock expired, so consume later, {}", this.messageQueue);
+ ConsumeMessageOrderlyService.this.tryLockLaterAndReconsume(this.messageQueue, this.processQueue, 10);
+ break;
+ }
+
+ long interval = System.currentTimeMillis() - beginTime;
+ if (interval > MAX_TIME_CONSUME_CONTINUOUSLY) {
+ ConsumeMessageOrderlyService.this.submitConsumeRequestLater(processQueue, messageQueue, 10);
+ break;
+ }
+
+ final int consumeBatchSize =
+ ConsumeMessageOrderlyService.this.defaultMQPushConsumer.getConsumeMessageBatchMaxSize();
+
+ List<MessageExt> msgs = this.processQueue.takeMessags(consumeBatchSize);
+ if (!msgs.isEmpty()) {
+ final ConsumeOrderlyContext context = new ConsumeOrderlyContext(this.messageQueue);
+
+ ConsumeOrderlyStatus status = null;
+
+ ConsumeMessageContext consumeMessageContext = null;
+ if (ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.hasHook()) {
+ consumeMessageContext = new ConsumeMessageContext();
+ consumeMessageContext
+ .setConsumerGroup(ConsumeMessageOrderlyService.this.defaultMQPushConsumer.getConsumerGroup());
+ consumeMessageContext.setMq(messageQueue);
+ consumeMessageContext.setMsgList(msgs);
+ consumeMessageContext.setSuccess(false);
+ // init the consume context type
+ consumeMessageContext.setProps(new HashMap<String, String>());
+ ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.executeHookBefore(consumeMessageContext);
+ }
+
+ long beginTimestamp = System.currentTimeMillis();
+ ConsumeReturnType returnType = ConsumeReturnType.SUCCESS;
+ boolean hasException = false;
+ try {
+ this.processQueue.getLockConsume().lock();
+ if (this.processQueue.isDropped()) {
+ log.warn("consumeMessage, the message queue not be able to consume, because it's dropped. {}",
+ this.messageQueue);
+ break;
+ }
+
+ status = messageListener.consumeMessage(Collections.unmodifiableList(msgs), context);
+ } catch (Throwable e) {
+ log.warn("consumeMessage exception: {} Group: {} Msgs: {} MQ: {}", //
+ RemotingHelper.exceptionSimpleDesc(e), //
+ ConsumeMessageOrderlyService.this.consumerGroup, //
+ msgs, //
+ messageQueue);
+ hasException = true;
+ } finally {
+ this.processQueue.getLockConsume().unlock();
+ }
+
+ if (null == status //
+ || ConsumeOrderlyStatus.ROLLBACK == status//
+ || ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT == status) {
+ log.warn("consumeMessage Orderly return not OK, Group: {} Msgs: {} MQ: {}", //
+ ConsumeMessageOrderlyService.this.consumerGroup, //
+ msgs, //
+ messageQueue);
+ }
+
+ long consumeRT = System.currentTimeMillis() - beginTimestamp;
+ if (null == status) {
+ if (hasException) {
+ returnType = ConsumeReturnType.EXCEPTION;
+ } else {
+ returnType = ConsumeReturnType.RETURNNULL;
+ }
+ } else if (consumeRT >= defaultMQPushConsumer.getConsumeTimeout() * 60 * 1000) {
+ returnType = ConsumeReturnType.TIME_OUT;
+ } else if (ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT == status) {
+ returnType = ConsumeReturnType.FAILED;
+ } else if (ConsumeOrderlyStatus.SUCCESS == status) {
+ returnType = ConsumeReturnType.SUCCESS;
+ }
+ consumeMessageContext.getProps().put(MixAll.CONSUME_CONTEXT_TYPE, returnType.name());
+ if (null == status) {
+ status = ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT;
+ }
+
+ if (ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.hasHook()) {
+ consumeMessageContext.setStatus(status.toString());
+ consumeMessageContext
+ .setSuccess(ConsumeOrderlyStatus.SUCCESS == status || ConsumeOrderlyStatus.COMMIT == status);
+ ConsumeMessageOrderlyService.this.defaultMQPushConsumerImpl.executeHookAfter(consumeMessageContext);
+ }
+
+ ConsumeMessageOrderlyService.this.getConsumerStatsManager()
+ .incConsumeRT(ConsumeMessageOrderlyService.this.consumerGroup, messageQueue.getTopic(), consumeRT);
+
+ continueConsume = ConsumeMessageOrderlyService.this.processConsumeResult(msgs, status, context, this);
+ } else {
+ continueConsume = false;
+ }
+ }
+ } else {
+ if (this.processQueue.isDropped()) {
+ log.warn("the message queue not be able to consume, because it's dropped. {}", this.messageQueue);
+ return;
+ }
+
+ ConsumeMessageOrderlyService.this.tryLockLaterAndReconsume(this.messageQueue, this.processQueue, 100);
+ }
+ }
+ }
+
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java
new file mode 100644
index 0000000..86529ee
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java
@@ -0,0 +1,56 @@
+/**
+ * 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.impl.consumer;
+
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
+
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public interface ConsumeMessageService {
+ void start();
+
+
+ void shutdown();
+
+
+ void updateCorePoolSize(int corePoolSize);
+
+
+ void incCorePoolSize();
+
+
+ void decCorePoolSize();
+
+
+ int getCorePoolSize();
+
+
+ ConsumeMessageDirectlyResult consumeMessageDirectly(final MessageExt msg, final String brokerName);
+
+
+ void submitConsumeRequest(//
+ final List<MessageExt> msgs, //
+ final ProcessQueue processQueue, //
+ final MessageQueue messageQueue, //
+ final boolean dispathToConsume);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
new file mode 100644
index 0000000..affb652
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
@@ -0,0 +1,706 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.impl.consumer;
+
+import org.apache.rocketmq.client.QueryResult;
+import org.apache.rocketmq.client.Validators;
+import org.apache.rocketmq.client.consumer.DefaultMQPullConsumer;
+import org.apache.rocketmq.client.consumer.PullCallback;
+import org.apache.rocketmq.client.consumer.PullResult;
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
+import org.apache.rocketmq.client.consumer.store.LocalFileOffsetStore;
+import org.apache.rocketmq.client.consumer.store.OffsetStore;
+import org.apache.rocketmq.client.consumer.store.ReadOffsetType;
+import org.apache.rocketmq.client.consumer.store.RemoteBrokerOffsetStore;
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.hook.ConsumeMessageContext;
+import org.apache.rocketmq.client.hook.ConsumeMessageHook;
+import org.apache.rocketmq.client.hook.FilterMessageHook;
+import org.apache.rocketmq.client.impl.CommunicationMode;
+import org.apache.rocketmq.client.impl.MQClientManager;
+import org.apache.rocketmq.client.impl.factory.MQClientInstance;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.ServiceState;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
+import org.apache.rocketmq.common.filter.FilterAPI;
+import org.apache.rocketmq.common.help.FAQUrl;
+import org.apache.rocketmq.common.message.*;
+import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
+import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
+import org.apache.rocketmq.common.sysflag.PullSysFlag;
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+import org.slf4j.Logger;
+
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class DefaultMQPullConsumerImpl implements MQConsumerInner {
+ private final Logger log = ClientLogger.getLog();
+ private final DefaultMQPullConsumer defaultMQPullConsumer;
+ private final long consumerStartTimestamp = System.currentTimeMillis();
+ private final RPCHook rpcHook;
+ private final ArrayList<ConsumeMessageHook> consumeMessageHookList = new ArrayList<ConsumeMessageHook>();
+ private final ArrayList<FilterMessageHook> filterMessageHookList = new ArrayList<FilterMessageHook>();
+ private ServiceState serviceState = ServiceState.CREATE_JUST;
+ private MQClientInstance mQClientFactory;
+ private PullAPIWrapper pullAPIWrapper;
+ private OffsetStore offsetStore;
+ private RebalanceImpl rebalanceImpl = new RebalancePullImpl(this);
+
+
+ public DefaultMQPullConsumerImpl(final DefaultMQPullConsumer defaultMQPullConsumer, final RPCHook rpcHook) {
+ this.defaultMQPullConsumer = defaultMQPullConsumer;
+ this.rpcHook = rpcHook;
+ }
+
+ public void registerConsumeMessageHook(final ConsumeMessageHook hook) {
+ this.consumeMessageHookList.add(hook);
+ log.info("register consumeMessageHook Hook, {}", hook.hookName());
+ }
+
+ public void createTopic(String key, String newTopic, int queueNum) throws MQClientException {
+ createTopic(key, newTopic, queueNum, 0);
+ }
+
+ public void createTopic(String key, String newTopic, int queueNum, int topicSysFlag) throws MQClientException {
+ this.makeSureStateOK();
+ this.mQClientFactory.getMQAdminImpl().createTopic(key, newTopic, queueNum, topicSysFlag);
+ }
+
+ private void makeSureStateOK() throws MQClientException {
+ if (this.serviceState != ServiceState.RUNNING) {
+ throw new MQClientException("The consumer service state not OK, "//
+ + this.serviceState//
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
+ null);
+ }
+ }
+
+ public long fetchConsumeOffset(MessageQueue mq, boolean fromStore) throws MQClientException {
+ this.makeSureStateOK();
+ return this.offsetStore.readOffset(mq, fromStore ? ReadOffsetType.READ_FROM_STORE : ReadOffsetType.MEMORY_FIRST_THEN_STORE);
+ }
+
+ public Set<MessageQueue> fetchMessageQueuesInBalance(String topic) throws MQClientException {
+ this.makeSureStateOK();
+ if (null == topic) {
+ throw new IllegalArgumentException("topic is null");
+ }
+
+ ConcurrentHashMap<MessageQueue, ProcessQueue> mqTable = this.rebalanceImpl.getProcessQueueTable();
+ Set<MessageQueue> mqResult = new HashSet<MessageQueue>();
+ for (MessageQueue mq : mqTable.keySet()) {
+ if (mq.getTopic().equals(topic)) {
+ mqResult.add(mq);
+ }
+ }
+
+ return mqResult;
+ }
+
+ public List<MessageQueue> fetchPublishMessageQueues(String topic) throws MQClientException {
+ this.makeSureStateOK();
+ return this.mQClientFactory.getMQAdminImpl().fetchPublishMessageQueues(topic);
+ }
+
+ public Set<MessageQueue> fetchSubscribeMessageQueues(String topic) throws MQClientException {
+ this.makeSureStateOK();
+ return this.mQClientFactory.getMQAdminImpl().fetchSubscribeMessageQueues(topic);
+ }
+
+ public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
+ this.makeSureStateOK();
+ return this.mQClientFactory.getMQAdminImpl().earliestMsgStoreTime(mq);
+ }
+
+ public long maxOffset(MessageQueue mq) throws MQClientException {
+ this.makeSureStateOK();
+ return this.mQClientFactory.getMQAdminImpl().maxOffset(mq);
+ }
+
+ public long minOffset(MessageQueue mq) throws MQClientException {
+ this.makeSureStateOK();
+ return this.mQClientFactory.getMQAdminImpl().minOffset(mq);
+ }
+
+ public PullResult pull(MessageQueue mq, String subExpression, long offset, int maxNums)
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ return pull(mq, subExpression, offset, maxNums, this.defaultMQPullConsumer.getConsumerPullTimeoutMillis());
+ }
+
+ public PullResult pull(MessageQueue mq, String subExpression, long offset, int maxNums, long timeout)
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ return this.pullSyncImpl(mq, subExpression, offset, maxNums, false, timeout);
+ }
+
+ private PullResult pullSyncImpl(MessageQueue mq, String subExpression, long offset, int maxNums, boolean block, long timeout)
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ this.makeSureStateOK();
+
+ if (null == mq) {
+ throw new MQClientException("mq is null", null);
+
+ }
+
+ if (offset < 0) {
+ throw new MQClientException("offset < 0", null);
+ }
+
+ if (maxNums <= 0) {
+ throw new MQClientException("maxNums <= 0", null);
+ }
+
+ this.subscriptionAutomatically(mq.getTopic());
+
+ int sysFlag = PullSysFlag.buildSysFlag(false, block, true, false);
+
+ SubscriptionData subscriptionData;
+ try {
+ subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(), //
+ mq.getTopic(), subExpression);
+ } catch (Exception e) {
+ throw new MQClientException("parse subscription error", e);
+ }
+
+ long timeoutMillis = block ? this.defaultMQPullConsumer.getConsumerTimeoutMillisWhenSuspend() : timeout;
+
+ PullResult pullResult = this.pullAPIWrapper.pullKernelImpl(//
+ mq, // 1
+ subscriptionData.getSubString(), // 2
+ 0L, // 3
+ offset, // 4
+ maxNums, // 5
+ sysFlag, // 6
+ 0, // 7
+ this.defaultMQPullConsumer.getBrokerSuspendMaxTimeMillis(), // 8
+ timeoutMillis, // 9
+ CommunicationMode.SYNC, // 10
+ null// 11
+ );
+ this.pullAPIWrapper.processPullResult(mq, pullResult, subscriptionData);
+ if (!this.consumeMessageHookList.isEmpty()) {
+ ConsumeMessageContext consumeMessageContext = null;
+ consumeMessageContext = new ConsumeMessageContext();
+ consumeMessageContext.setConsumerGroup(this.groupName());
+ consumeMessageContext.setMq(mq);
+ consumeMessageContext.setMsgList(pullResult.getMsgFoundList());
+ consumeMessageContext.setSuccess(false);
+ this.executeHookBefore(consumeMessageContext);
+ consumeMessageContext.setStatus(ConsumeConcurrentlyStatus.CONSUME_SUCCESS.toString());
+ consumeMessageContext.setSuccess(true);
+ this.executeHookAfter(consumeMessageContext);
+ }
+ return pullResult;
+ }
+
+ public void subscriptionAutomatically(final String topic) {
+ if (!this.rebalanceImpl.getSubscriptionInner().containsKey(topic)) {
+ try {
+ SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(), //
+ topic, SubscriptionData.SUB_ALL);
+ this.rebalanceImpl.subscriptionInner.putIfAbsent(topic, subscriptionData);
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ public void unsubscribe(String topic) {
+ this.rebalanceImpl.getSubscriptionInner().remove(topic);
+ }
+
+ @Override
+ public String groupName() {
+ return this.defaultMQPullConsumer.getConsumerGroup();
+ }
+
+ public void executeHookBefore(final ConsumeMessageContext context) {
+ if (!this.consumeMessageHookList.isEmpty()) {
+ for (ConsumeMessageHook hook : this.consumeMessageHookList) {
+ try {
+ hook.consumeMessageBefore(context);
+ } catch (Throwable e) {
+ }
+ }
+ }
+ }
+
+ public void executeHookAfter(final ConsumeMessageContext context) {
+ if (!this.consumeMessageHookList.isEmpty()) {
+ for (ConsumeMessageHook hook : this.consumeMessageHookList) {
+ try {
+ hook.consumeMessageAfter(context);
+ } catch (Throwable e) {
+ }
+ }
+ }
+ }
+
+ @Override
+ public MessageModel messageModel() {
+ return this.defaultMQPullConsumer.getMessageModel();
+ }
+
+ @Override
+ public ConsumeType consumeType() {
+ return ConsumeType.CONSUME_ACTIVELY;
+ }
+
+ @Override
+ public ConsumeFromWhere consumeFromWhere() {
+ return ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET;
+ }
+
+ @Override
+ public Set<SubscriptionData> subscriptions() {
+ Set<SubscriptionData> result = new HashSet<SubscriptionData>();
+
+ Set<String> topics = this.defaultMQPullConsumer.getRegisterTopics();
+ if (topics != null) {
+ synchronized (topics) {
+ for (String t : topics) {
+ SubscriptionData ms = null;
+ try {
+ ms = FilterAPI.buildSubscriptionData(this.groupName(), t, SubscriptionData.SUB_ALL);
+ } catch (Exception e) {
+ log.error("parse subscription error", e);
+ }
+ ms.setSubVersion(0L);
+ result.add(ms);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public void doRebalance() {
+ if (this.rebalanceImpl != null) {
+ this.rebalanceImpl.doRebalance(false);
+ }
+ }
+
+ @Override
+ public void persistConsumerOffset() {
+ try {
+ this.makeSureStateOK();
+ Set<MessageQueue> mqs = new HashSet<MessageQueue>();
+ Set<MessageQueue> allocateMq = this.rebalanceImpl.getProcessQueueTable().keySet();
+ if (allocateMq != null) {
+ mqs.addAll(allocateMq);
+ }
+ this.offsetStore.persistAll(mqs);
+ } catch (Exception e) {
+ log.error("group: " + this.defaultMQPullConsumer.getConsumerGroup() + " persistConsumerOffset exception", e);
+ }
+ }
+
+ @Override
+ public void updateTopicSubscribeInfo(String topic, Set<MessageQueue> info) {
+ Map<String, SubscriptionData> subTable = this.rebalanceImpl.getSubscriptionInner();
+ if (subTable != null) {
+ if (subTable.containsKey(topic)) {
+ this.rebalanceImpl.getTopicSubscribeInfoTable().put(topic, info);
+ }
+ }
+ }
+
+ @Override
+ public boolean isSubscribeTopicNeedUpdate(String topic) {
+ Map<String, SubscriptionData> subTable = this.rebalanceImpl.getSubscriptionInner();
+ if (subTable != null) {
+ if (subTable.containsKey(topic)) {
+ return !this.rebalanceImpl.topicSubscribeInfoTable.containsKey(topic);
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean isUnitMode() {
+ return this.defaultMQPullConsumer.isUnitMode();
+ }
+
+ @Override
+ public ConsumerRunningInfo consumerRunningInfo() {
+ ConsumerRunningInfo info = new ConsumerRunningInfo();
+
+ Properties prop = MixAll.object2Properties(this.defaultMQPullConsumer);
+ prop.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, String.valueOf(this.consumerStartTimestamp));
+ info.setProperties(prop);
+
+ info.getSubscriptionSet().addAll(this.subscriptions());
+ return info;
+ }
+
+ public void pull(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback)
+ throws MQClientException, RemotingException, InterruptedException {
+ pull(mq, subExpression, offset, maxNums, pullCallback, this.defaultMQPullConsumer.getConsumerPullTimeoutMillis());
+ }
+
+ public void pull(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback, long timeout)
+ throws MQClientException, RemotingException, InterruptedException {
+ this.pullAsyncImpl(mq, subExpression, offset, maxNums, pullCallback, false, timeout);
+ }
+
+ private void pullAsyncImpl(//
+ final MessageQueue mq, //
+ final String subExpression, //
+ final long offset, //
+ final int maxNums, //
+ final PullCallback pullCallback, //
+ final boolean block, //
+ final long timeout) throws MQClientException, RemotingException, InterruptedException {
+ this.makeSureStateOK();
+
+ if (null == mq) {
+ throw new MQClientException("mq is null", null);
+ }
+
+ if (offset < 0) {
+ throw new MQClientException("offset < 0", null);
+ }
+
+ if (maxNums <= 0) {
+ throw new MQClientException("maxNums <= 0", null);
+ }
+
+ if (null == pullCallback) {
+ throw new MQClientException("pullCallback is null", null);
+ }
+
+ this.subscriptionAutomatically(mq.getTopic());
+
+ try {
+ int sysFlag = PullSysFlag.buildSysFlag(false, block, true, false);
+
+ final SubscriptionData subscriptionData;
+ try {
+ subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(), //
+ mq.getTopic(), subExpression);
+ } catch (Exception e) {
+ throw new MQClientException("parse subscription error", e);
+ }
+
+ long timeoutMillis = block ? this.defaultMQPullConsumer.getConsumerTimeoutMillisWhenSuspend() : timeout;
+
+ this.pullAPIWrapper.pullKernelImpl(//
+ mq, // 1
+ subscriptionData.getSubString(), // 2
+ 0L, // 3
+ offset, // 4
+ maxNums, // 5
+ sysFlag, // 6
+ 0, // 7
+ this.defaultMQPullConsumer.getBrokerSuspendMaxTimeMillis(), // 8
+ timeoutMillis, // 9
+ CommunicationMode.ASYNC, // 10
+ new PullCallback() {
+
+ @Override
+ public void onSuccess(PullResult pullResult) {
+ pullCallback
+ .onSuccess(DefaultMQPullConsumerImpl.this.pullAPIWrapper.processPullResult(mq, pullResult, subscriptionData));
+ }
+
+ @Override
+ public void onException(Throwable e) {
+ pullCallback.onException(e);
+ }
+ });
+ } catch (MQBrokerException e) {
+ throw new MQClientException("pullAsync unknow exception", e);
+ }
+ }
+
+ public PullResult pullBlockIfNotFound(MessageQueue mq, String subExpression, long offset, int maxNums)
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ return this.pullSyncImpl(mq, subExpression, offset, maxNums, true, this.getDefaultMQPullConsumer().getConsumerPullTimeoutMillis());
+ }
+
+ public DefaultMQPullConsumer getDefaultMQPullConsumer() {
+ return defaultMQPullConsumer;
+ }
+
+ public void pullBlockIfNotFound(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback)
+ throws MQClientException, RemotingException, InterruptedException {
+ this.pullAsyncImpl(mq, subExpression, offset, maxNums, pullCallback, true,
+ this.getDefaultMQPullConsumer().getConsumerPullTimeoutMillis());
+ }
+
+ public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
+ throws MQClientException, InterruptedException {
+ this.makeSureStateOK();
+ return this.mQClientFactory.getMQAdminImpl().queryMessage(topic, key, maxNum, begin, end);
+ }
+
+ public MessageExt queryMessageByUniqKey(String topic, String uniqKey)
+ throws MQClientException, InterruptedException {
+ this.makeSureStateOK();
+ return this.mQClientFactory.getMQAdminImpl().queryMessageByUniqKey(topic, uniqKey);
+ }
+
+ public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
+ this.makeSureStateOK();
+ return this.mQClientFactory.getMQAdminImpl().searchOffset(mq, timestamp);
+ }
+
+ public void sendMessageBack(MessageExt msg, int delayLevel, final String brokerName)
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ sendMessageBack(msg, delayLevel, brokerName, this.defaultMQPullConsumer.getConsumerGroup());
+ }
+
+ public void updateConsumeOffsetToBroker(MessageQueue mq, long offset, boolean isOneway) throws RemotingException,
+ MQBrokerException, InterruptedException, MQClientException {
+ this.offsetStore.updateConsumeOffsetToBroker(mq, offset, isOneway);
+ }
+
+ public void sendMessageBack(MessageExt msg, int delayLevel, final String brokerName, String consumerGroup)
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ try {
+ String brokerAddr = (null != brokerName) ? this.mQClientFactory.findBrokerAddressInPublish(brokerName)
+ : RemotingHelper.parseSocketAddressAddr(msg.getStoreHost());
+
+ if (UtilAll.isBlank(consumerGroup)) {
+ consumerGroup = this.defaultMQPullConsumer.getConsumerGroup();
+ }
+
+ this.mQClientFactory.getMQClientAPIImpl().consumerSendMessageBack(brokerAddr, msg, consumerGroup, delayLevel, 3000,
+ this.defaultMQPullConsumer.getMaxReconsumeTimes());
+ } catch (Exception e) {
+ log.error("sendMessageBack Exception, " + this.defaultMQPullConsumer.getConsumerGroup(), e);
+
+ Message newMsg = new Message(MixAll.getRetryTopic(this.defaultMQPullConsumer.getConsumerGroup()), msg.getBody());
+ String originMsgId = MessageAccessor.getOriginMessageId(msg);
+ MessageAccessor.setOriginMessageId(newMsg, UtilAll.isBlank(originMsgId) ? msg.getMsgId() : originMsgId);
+ newMsg.setFlag(msg.getFlag());
+ MessageAccessor.setProperties(newMsg, msg.getProperties());
+ MessageAccessor.putProperty(newMsg, MessageConst.PROPERTY_RETRY_TOPIC, msg.getTopic());
+ MessageAccessor.setReconsumeTime(newMsg, String.valueOf(msg.getReconsumeTimes() + 1));
+ MessageAccessor.setMaxReconsumeTimes(newMsg, String.valueOf(this.defaultMQPullConsumer.getMaxReconsumeTimes()));
+ newMsg.setDelayTimeLevel(3 + msg.getReconsumeTimes());
+ this.mQClientFactory.getDefaultMQProducer().send(newMsg);
+ }
+ }
+
+ public void shutdown() {
+ switch (this.serviceState) {
+ case CREATE_JUST:
+ break;
+ case RUNNING:
+ this.persistConsumerOffset();
+ this.mQClientFactory.unregisterConsumer(this.defaultMQPullConsumer.getConsumerGroup());
+ this.mQClientFactory.shutdown();
+ log.info("the consumer [{}] shutdown OK", this.defaultMQPullConsumer.getConsumerGroup());
+ this.serviceState = ServiceState.SHUTDOWN_ALREADY;
+ break;
+ case SHUTDOWN_ALREADY:
+ break;
+ default:
+ break;
+ }
+ }
+
+ public void start() throws MQClientException {
+ switch (this.serviceState) {
+ case CREATE_JUST:
+ this.serviceState = ServiceState.START_FAILED;
+
+ this.checkConfig();
+
+ this.copySubscription();
+
+ if (this.defaultMQPullConsumer.getMessageModel() == MessageModel.CLUSTERING) {
+ this.defaultMQPullConsumer.changeInstanceNameToPID();
+ }
+
+ this.mQClientFactory = MQClientManager.getInstance().getAndCreateMQClientInstance(this.defaultMQPullConsumer, this.rpcHook);
+
+ this.rebalanceImpl.setConsumerGroup(this.defaultMQPullConsumer.getConsumerGroup());
+ this.rebalanceImpl.setMessageModel(this.defaultMQPullConsumer.getMessageModel());
+ this.rebalanceImpl.setAllocateMessageQueueStrategy(this.defaultMQPullConsumer.getAllocateMessageQueueStrategy());
+ this.rebalanceImpl.setmQClientFactory(this.mQClientFactory);
+
+ this.pullAPIWrapper = new PullAPIWrapper(//
+ mQClientFactory, //
+ this.defaultMQPullConsumer.getConsumerGroup(), isUnitMode());
+ this.pullAPIWrapper.registerFilterMessageHook(filterMessageHookList);
+
+ if (this.defaultMQPullConsumer.getOffsetStore() != null) {
+ this.offsetStore = this.defaultMQPullConsumer.getOffsetStore();
+ } else {
+ switch (this.defaultMQPullConsumer.getMessageModel()) {
+ case BROADCASTING:
+ this.offsetStore = new LocalFileOffsetStore(this.mQClientFactory, this.defaultMQPullConsumer.getConsumerGroup());
+ break;
+ case CLUSTERING:
+ this.offsetStore = new RemoteBrokerOffsetStore(this.mQClientFactory, this.defaultMQPullConsumer.getConsumerGroup());
+ break;
+ default:
+ break;
+ }
+ }
+
+ this.offsetStore.load();
+
+ boolean registerOK = mQClientFactory.registerConsumer(this.defaultMQPullConsumer.getConsumerGroup(), this);
+ if (!registerOK) {
+ this.serviceState = ServiceState.CREATE_JUST;
+
+ throw new MQClientException("The consumer group[" + this.defaultMQPullConsumer.getConsumerGroup()
+ + "] has been created before, specify another name please." + FAQUrl.suggestTodo(FAQUrl.GROUP_NAME_DUPLICATE_URL),
+ null);
+ }
+
+ mQClientFactory.start();
+ log.info("the consumer [{}] start OK", this.defaultMQPullConsumer.getConsumerGroup());
+ this.serviceState = ServiceState.RUNNING;
+ break;
+ case RUNNING:
+ case START_FAILED:
+ case SHUTDOWN_ALREADY:
+ throw new MQClientException("The PullConsumer service state not OK, maybe started once, "//
+ + this.serviceState//
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
+ null);
+ default:
+ break;
+ }
+ }
+
+ private void checkConfig() throws MQClientException {
+ // check consumerGroup
+ Validators.checkGroup(this.defaultMQPullConsumer.getConsumerGroup());
+
+ // consumerGroup
+ if (null == this.defaultMQPullConsumer.getConsumerGroup()) {
+ throw new MQClientException(
+ "consumerGroup is null" //
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
+ null);
+ }
+
+ // consumerGroup
+ if (this.defaultMQPullConsumer.getConsumerGroup().equals(MixAll.DEFAULT_CONSUMER_GROUP)) {
+ throw new MQClientException(
+ "consumerGroup can not equal "//
+ + MixAll.DEFAULT_CONSUMER_GROUP //
+ + ", please specify another one."//
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
+ null);
+ }
+
+ // messageModel
+ if (null == this.defaultMQPullConsumer.getMessageModel()) {
+ throw new MQClientException(
+ "messageModel is null" //
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
+ null);
+ }
+
+ // allocateMessageQueueStrategy
+ if (null == this.defaultMQPullConsumer.getAllocateMessageQueueStrategy()) {
+ throw new MQClientException(
+ "allocateMessageQueueStrategy is null" //
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
+ null);
+ }
+
+ // allocateMessageQueueStrategy
+ if (this.defaultMQPullConsumer.getConsumerTimeoutMillisWhenSuspend() < this.defaultMQPullConsumer.getBrokerSuspendMaxTimeMillis()) {
+ throw new MQClientException(
+ "Long polling mode, the consumer consumerTimeoutMillisWhenSuspend must greater than brokerSuspendMaxTimeMillis" //
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), //
+ null);
+ }
+ }
+
+ private void copySubscription() throws MQClientException {
+ try {
+ Set<String> registerTopics = this.defaultMQPullConsumer.getRegisterTopics();
+ if (registerTopics != null) {
+ for (final String topic : registerTopics) {
+ SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPullConsumer.getConsumerGroup(), //
+ topic, SubscriptionData.SUB_ALL);
+ this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData);
+ }
+ }
+ } catch (Exception e) {
+ throw new MQClientException("subscription exception", e);
+ }
+ }
+
+ public void updateConsumeOffset(MessageQueue mq, long offset) throws MQClientException {
+ this.makeSureStateOK();
+ this.offsetStore.updateOffset(mq, offset, false);
+ }
+
+ public MessageExt viewMessage(String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ this.makeSureStateOK();
+ return this.mQClientFactory.getMQAdminImpl().viewMessage(msgId);
+ }
+
+ public void registerFilterMessageHook(final FilterMessageHook hook) {
+ this.filterMessageHookList.add(hook);
+ log.info("register FilterMessageHook Hook, {}", hook.hookName());
+ }
+
+ public OffsetStore getOffsetStore() {
+ return offsetStore;
+ }
+
+ public void setOffsetStore(OffsetStore offsetStore) {
+ this.offsetStore = offsetStore;
+ }
+
+ public PullAPIWrapper getPullAPIWrapper() {
+ return pullAPIWrapper;
+ }
+
+ public void setPullAPIWrapper(PullAPIWrapper pullAPIWrapper) {
+ this.pullAPIWrapper = pullAPIWrapper;
+ }
+
+ public ServiceState getServiceState() {
+ return serviceState;
+ }
+
+ public void setServiceState(ServiceState serviceState) {
+ this.serviceState = serviceState;
+ }
+
+ public long getConsumerStartTimestamp() {
+ return consumerStartTimestamp;
+ }
+
+
+ public RebalanceImpl getRebalanceImpl() {
+ return rebalanceImpl;
+ }
+}
[41/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
new file mode 100644
index 0000000..bdceeb0
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
@@ -0,0 +1,164 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.broker.processor;
+
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.broker.client.ClientChannelInfo;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.constant.PermName;
+import org.apache.rocketmq.common.protocol.RequestCode;
+import org.apache.rocketmq.common.protocol.ResponseCode;
+import org.apache.rocketmq.common.protocol.header.UnregisterClientRequestHeader;
+import org.apache.rocketmq.common.protocol.header.UnregisterClientResponseHeader;
+import org.apache.rocketmq.common.protocol.heartbeat.ConsumerData;
+import org.apache.rocketmq.common.protocol.heartbeat.HeartbeatData;
+import org.apache.rocketmq.common.protocol.heartbeat.ProducerData;
+import org.apache.rocketmq.common.subscription.SubscriptionGroupConfig;
+import org.apache.rocketmq.common.sysflag.TopicSysFlag;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import io.netty.channel.ChannelHandlerContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ClientManageProcessor implements NettyRequestProcessor {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+ private final BrokerController brokerController;
+
+ public ClientManageProcessor(final BrokerController brokerController) {
+ this.brokerController = brokerController;
+ }
+
+ @Override
+ public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request)
+ throws RemotingCommandException {
+ switch (request.getCode()) {
+ case RequestCode.HEART_BEAT:
+ return this.heartBeat(ctx, request);
+ case RequestCode.UNREGISTER_CLIENT:
+ return this.unregisterClient(ctx, request);
+ default:
+ break;
+ }
+ return null;
+ }
+
+ @Override
+ public boolean rejectRequest() {
+ return false;
+ }
+
+ public RemotingCommand heartBeat(ChannelHandlerContext ctx, RemotingCommand request) {
+ RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ HeartbeatData heartbeatData = HeartbeatData.decode(request.getBody(), HeartbeatData.class);
+ ClientChannelInfo clientChannelInfo = new ClientChannelInfo(
+ ctx.channel(),
+ heartbeatData.getClientID(),
+ request.getLanguage(),
+ request.getVersion()
+ );
+
+ for (ConsumerData data : heartbeatData.getConsumerDataSet()) {
+ SubscriptionGroupConfig subscriptionGroupConfig =
+ this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(
+ data.getGroupName());
+ boolean isNotifyConsumerIdsChangedEnable = true;
+ if (null != subscriptionGroupConfig) {
+ isNotifyConsumerIdsChangedEnable = subscriptionGroupConfig.isNotifyConsumerIdsChangedEnable();
+ int topicSysFlag = 0;
+ if (data.isUnitMode()) {
+ topicSysFlag = TopicSysFlag.buildSysFlag(false, true);
+ }
+ String newTopic = MixAll.getRetryTopic(data.getGroupName());
+ this.brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(
+ newTopic,
+ subscriptionGroupConfig.getRetryQueueNums(),
+ PermName.PERM_WRITE | PermName.PERM_READ, topicSysFlag);
+ }
+
+ boolean changed = this.brokerController.getConsumerManager().registerConsumer(
+ data.getGroupName(),
+ clientChannelInfo,
+ data.getConsumeType(),
+ data.getMessageModel(),
+ data.getConsumeFromWhere(),
+ data.getSubscriptionDataSet(),
+ isNotifyConsumerIdsChangedEnable
+ );
+
+ if (changed) {
+ log.info("registerConsumer info changed {} {}",
+ data.toString(),
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel())
+ );
+ }
+ }
+
+ for (ProducerData data : heartbeatData.getProducerDataSet()) {
+ this.brokerController.getProducerManager().registerProducer(data.getGroupName(),
+ clientChannelInfo);
+ }
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ public RemotingCommand unregisterClient(ChannelHandlerContext ctx, RemotingCommand request)
+ throws RemotingCommandException {
+ final RemotingCommand response =
+ RemotingCommand.createResponseCommand(UnregisterClientResponseHeader.class);
+ final UnregisterClientRequestHeader requestHeader =
+ (UnregisterClientRequestHeader) request
+ .decodeCommandCustomHeader(UnregisterClientRequestHeader.class);
+
+ ClientChannelInfo clientChannelInfo = new ClientChannelInfo(
+ ctx.channel(),
+ requestHeader.getClientID(),
+ request.getLanguage(),
+ request.getVersion());
+ {
+ final String group = requestHeader.getProducerGroup();
+ if (group != null) {
+ this.brokerController.getProducerManager().unregisterProducer(group, clientChannelInfo);
+ }
+ }
+
+ {
+ final String group = requestHeader.getConsumerGroup();
+ if (group != null) {
+ SubscriptionGroupConfig subscriptionGroupConfig =
+ this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(group);
+ boolean isNotifyConsumerIdsChangedEnable = true;
+ if (null != subscriptionGroupConfig) {
+ isNotifyConsumerIdsChangedEnable = subscriptionGroupConfig.isNotifyConsumerIdsChangedEnable();
+ }
+ this.brokerController.getConsumerManager().unregisterConsumer(group, clientChannelInfo, isNotifyConsumerIdsChangedEnable);
+ }
+ }
+
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
new file mode 100644
index 0000000..09a2607
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
@@ -0,0 +1,157 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.broker.processor;
+
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.broker.client.ConsumerGroupInfo;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.protocol.RequestCode;
+import org.apache.rocketmq.common.protocol.ResponseCode;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import io.netty.channel.ChannelHandlerContext;
+import org.apache.rocketmq.common.protocol.header.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ConsumerManageProcessor implements NettyRequestProcessor {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+
+ private final BrokerController brokerController;
+
+
+ public ConsumerManageProcessor(final BrokerController brokerController) {
+ this.brokerController = brokerController;
+ }
+
+ @Override
+ public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request)
+ throws RemotingCommandException {
+ switch (request.getCode()) {
+ case RequestCode.GET_CONSUMER_LIST_BY_GROUP:
+ return this.getConsumerListByGroup(ctx, request);
+ case RequestCode.UPDATE_CONSUMER_OFFSET:
+ return this.updateConsumerOffset(ctx, request);
+ case RequestCode.QUERY_CONSUMER_OFFSET:
+ return this.queryConsumerOffset(ctx, request);
+ default:
+ break;
+ }
+ return null;
+ }
+
+ @Override
+ public boolean rejectRequest() {
+ return false;
+ }
+
+
+ public RemotingCommand getConsumerListByGroup(ChannelHandlerContext ctx, RemotingCommand request)
+ throws RemotingCommandException {
+ final RemotingCommand response =
+ RemotingCommand.createResponseCommand(GetConsumerListByGroupResponseHeader.class);
+ final GetConsumerListByGroupRequestHeader requestHeader =
+ (GetConsumerListByGroupRequestHeader) request
+ .decodeCommandCustomHeader(GetConsumerListByGroupRequestHeader.class);
+
+ ConsumerGroupInfo consumerGroupInfo =
+ this.brokerController.getConsumerManager().getConsumerGroupInfo(
+ requestHeader.getConsumerGroup());
+ if (consumerGroupInfo != null) {
+ List<String> clientIds = consumerGroupInfo.getAllClientId();
+ if (!clientIds.isEmpty()) {
+ GetConsumerListByGroupResponseBody body = new GetConsumerListByGroupResponseBody();
+ body.setConsumerIdList(clientIds);
+ response.setBody(body.encode());
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ } else {
+ log.warn("getAllClientId failed, {} {}", requestHeader.getConsumerGroup(),
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
+ }
+ } else {
+ log.warn("getConsumerGroupInfo failed, {} {}", requestHeader.getConsumerGroup(),
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
+ }
+
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("no consumer for this group, " + requestHeader.getConsumerGroup());
+ return response;
+ }
+
+ private RemotingCommand updateConsumerOffset(ChannelHandlerContext ctx, RemotingCommand request)
+ throws RemotingCommandException {
+ final RemotingCommand response =
+ RemotingCommand.createResponseCommand(UpdateConsumerOffsetResponseHeader.class);
+ final UpdateConsumerOffsetRequestHeader requestHeader =
+ (UpdateConsumerOffsetRequestHeader) request
+ .decodeCommandCustomHeader(UpdateConsumerOffsetRequestHeader.class);
+ this.brokerController.getConsumerOffsetManager().commitOffset(RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getConsumerGroup(),
+ requestHeader.getTopic(), requestHeader.getQueueId(), requestHeader.getCommitOffset());
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+
+ private RemotingCommand queryConsumerOffset(ChannelHandlerContext ctx, RemotingCommand request)
+ throws RemotingCommandException {
+ final RemotingCommand response =
+ RemotingCommand.createResponseCommand(QueryConsumerOffsetResponseHeader.class);
+ final QueryConsumerOffsetResponseHeader responseHeader =
+ (QueryConsumerOffsetResponseHeader) response.readCustomHeader();
+ final QueryConsumerOffsetRequestHeader requestHeader =
+ (QueryConsumerOffsetRequestHeader) request
+ .decodeCommandCustomHeader(QueryConsumerOffsetRequestHeader.class);
+
+ long offset =
+ this.brokerController.getConsumerOffsetManager().queryOffset(
+ requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueId());
+
+
+ if (offset >= 0) {
+ responseHeader.setOffset(offset);
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ } else {
+ long minOffset =
+ this.brokerController.getMessageStore().getMinOffsetInQuque(requestHeader.getTopic(),
+ requestHeader.getQueueId());
+ if (minOffset <= 0
+ && !this.brokerController.getMessageStore().checkInDiskByConsumeOffset(
+ requestHeader.getTopic(), requestHeader.getQueueId(), 0)) {
+ responseHeader.setOffset(0L);
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ } else {
+ response.setCode(ResponseCode.QUERY_NOT_FOUND);
+ response.setRemark("Not found, V3_0_6_SNAPSHOT maybe this group consumer boot first");
+ }
+ }
+
+ return response;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
new file mode 100644
index 0000000..fc38238
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
@@ -0,0 +1,236 @@
+/**
+ * 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.broker.processor;
+
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.common.TopicFilterType;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.message.MessageAccessor;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageDecoder;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.protocol.ResponseCode;
+import org.apache.rocketmq.common.protocol.header.EndTransactionRequestHeader;
+import org.apache.rocketmq.common.sysflag.MessageSysFlag;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.apache.rocketmq.store.MessageExtBrokerInner;
+import org.apache.rocketmq.store.MessageStore;
+import org.apache.rocketmq.store.PutMessageResult;
+import io.netty.channel.ChannelHandlerContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class EndTransactionProcessor implements NettyRequestProcessor {
+ private static final Logger LOGGER = LoggerFactory.getLogger(LoggerName.TRANSACTION_LOGGER_NAME);
+ private final BrokerController brokerController;
+
+ public EndTransactionProcessor(final BrokerController brokerController) {
+ this.brokerController = brokerController;
+ }
+
+ @Override
+ public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ final EndTransactionRequestHeader requestHeader =
+ (EndTransactionRequestHeader) request.decodeCommandCustomHeader(EndTransactionRequestHeader.class);
+
+
+ if (requestHeader.getFromTransactionCheck()) {
+ switch (requestHeader.getCommitOrRollback()) {
+ case MessageSysFlag.TRANSACTION_NOT_TYPE: {
+ LOGGER.warn("check producer[{}] transaction state, but it's pending status."
+ + "RequestHeader: {} Remark: {}",
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
+ requestHeader.toString(),
+ request.getRemark());
+ return null;
+ }
+
+ case MessageSysFlag.TRANSACTION_COMMIT_TYPE: {
+ LOGGER.warn("check producer[{}] transaction state, the producer commit the message."
+ + "RequestHeader: {} Remark: {}",
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
+ requestHeader.toString(),
+ request.getRemark());
+
+ break;
+ }
+
+ case MessageSysFlag.TRANSACTION_ROLLBACK_TYPE: {
+ LOGGER.warn("check producer[{}] transaction state, the producer rollback the message."
+ + "RequestHeader: {} Remark: {}",
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
+ requestHeader.toString(),
+ request.getRemark());
+ break;
+ }
+ default:
+ return null;
+ }
+ } else {
+ switch (requestHeader.getCommitOrRollback()) {
+ case MessageSysFlag.TRANSACTION_NOT_TYPE: {
+ LOGGER.warn("the producer[{}] end transaction in sending message, and it's pending status."
+ + "RequestHeader: {} Remark: {}",
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
+ requestHeader.toString(),
+ request.getRemark());
+ return null;
+ }
+
+ case MessageSysFlag.TRANSACTION_COMMIT_TYPE: {
+ break;
+ }
+
+ case MessageSysFlag.TRANSACTION_ROLLBACK_TYPE: {
+ LOGGER.warn("the producer[{}] end transaction in sending message, rollback the message."
+ + "RequestHeader: {} Remark: {}",
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
+ requestHeader.toString(),
+ request.getRemark());
+ break;
+ }
+ default:
+ return null;
+ }
+ }
+
+ final MessageExt msgExt = this.brokerController.getMessageStore().lookMessageByOffset(requestHeader.getCommitLogOffset());
+ if (msgExt != null) {
+ final String pgroupRead = msgExt.getProperty(MessageConst.PROPERTY_PRODUCER_GROUP);
+ if (!pgroupRead.equals(requestHeader.getProducerGroup())) {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("the producer group wrong");
+ return response;
+ }
+
+ if (msgExt.getQueueOffset() != requestHeader.getTranStateTableOffset()) {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("the transaction state table offset wrong");
+ return response;
+ }
+
+ if (msgExt.getCommitLogOffset() != requestHeader.getCommitLogOffset()) {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("the commit log offset wrong");
+ return response;
+ }
+
+ MessageExtBrokerInner msgInner = this.endMessageTransaction(msgExt);
+ msgInner.setSysFlag(MessageSysFlag.resetTransactionValue(msgInner.getSysFlag(), requestHeader.getCommitOrRollback()));
+
+ msgInner.setQueueOffset(requestHeader.getTranStateTableOffset());
+ msgInner.setPreparedTransactionOffset(requestHeader.getCommitLogOffset());
+ msgInner.setStoreTimestamp(msgExt.getStoreTimestamp());
+ if (MessageSysFlag.TRANSACTION_ROLLBACK_TYPE == requestHeader.getCommitOrRollback()) {
+ msgInner.setBody(null);
+ }
+
+ final MessageStore messageStore = this.brokerController.getMessageStore();
+ final PutMessageResult putMessageResult = messageStore.putMessage(msgInner);
+ if (putMessageResult != null) {
+ switch (putMessageResult.getPutMessageStatus()) {
+ // Success
+ case PUT_OK:
+ case FLUSH_DISK_TIMEOUT:
+ case FLUSH_SLAVE_TIMEOUT:
+ case SLAVE_NOT_AVAILABLE:
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ break;
+ // Failed
+ case CREATE_MAPEDFILE_FAILED:
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("create maped file failed.");
+ break;
+ case MESSAGE_ILLEGAL:
+ case PROPERTIES_SIZE_EXCEEDED:
+ response.setCode(ResponseCode.MESSAGE_ILLEGAL);
+ response.setRemark("the message is illegal, maybe msg body or properties length not matched. msg body length limit 128k, msg properties length limit 32k.");
+ break;
+ case SERVICE_NOT_AVAILABLE:
+ response.setCode(ResponseCode.SERVICE_NOT_AVAILABLE);
+ response.setRemark("service not available now.");
+ break;
+ case OS_PAGECACHE_BUSY:
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("OS page cache busy, please try another machine");
+ break;
+ case UNKNOWN_ERROR:
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("UNKNOWN_ERROR");
+ break;
+ default:
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("UNKNOWN_ERROR DEFAULT");
+ break;
+ }
+
+ return response;
+ } else {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("store putMessage return null");
+ }
+ } else {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("find prepared transaction message failed");
+ return response;
+ }
+
+ return response;
+ }
+
+ @Override
+ public boolean rejectRequest() {
+ return false;
+ }
+
+ private MessageExtBrokerInner endMessageTransaction(MessageExt msgExt) {
+ MessageExtBrokerInner msgInner = new MessageExtBrokerInner();
+ msgInner.setBody(msgExt.getBody());
+ msgInner.setFlag(msgExt.getFlag());
+ MessageAccessor.setProperties(msgInner, msgExt.getProperties());
+
+ TopicFilterType topicFilterType =
+ (msgInner.getSysFlag() & MessageSysFlag.MULTI_TAGS_FLAG) == MessageSysFlag.MULTI_TAGS_FLAG ? TopicFilterType.MULTI_TAG
+ : TopicFilterType.SINGLE_TAG;
+ long tagsCodeValue = MessageExtBrokerInner.tagsString2tagsCode(topicFilterType, msgInner.getTags());
+ msgInner.setTagsCode(tagsCodeValue);
+ msgInner.setPropertiesString(MessageDecoder.messageProperties2String(msgExt.getProperties()));
+
+ msgInner.setSysFlag(msgExt.getSysFlag());
+ msgInner.setBornTimestamp(msgExt.getBornTimestamp());
+ msgInner.setBornHost(msgExt.getBornHost());
+ msgInner.setStoreHost(msgExt.getStoreHost());
+ msgInner.setReconsumeTimes(msgExt.getReconsumeTimes());
+
+ msgInner.setWaitStoreMsgOK(false);
+ MessageAccessor.clearProperty(msgInner, MessageConst.PROPERTY_DELAY_TIME_LEVEL);
+
+ msgInner.setTopic(msgExt.getTopic());
+ msgInner.setQueueId(msgExt.getQueueId());
+
+ return msgInner;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java
new file mode 100644
index 0000000..acf25ea
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/ForwardRequestProcessor.java
@@ -0,0 +1,51 @@
+/**
+ * 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.broker.processor;
+
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import io.netty.channel.ChannelHandlerContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ForwardRequestProcessor implements NettyRequestProcessor {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+
+ private final BrokerController brokerController;
+
+
+ public ForwardRequestProcessor(final BrokerController brokerController) {
+ this.brokerController = brokerController;
+ }
+
+
+ @Override
+ public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) {
+ return null;
+ }
+
+ @Override
+ public boolean rejectRequest() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
new file mode 100644
index 0000000..3094079
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
@@ -0,0 +1,542 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.broker.processor;
+
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.broker.client.ConsumerGroupInfo;
+import org.apache.rocketmq.broker.longpolling.PullRequest;
+import org.apache.rocketmq.broker.mqtrace.ConsumeMessageContext;
+import org.apache.rocketmq.broker.mqtrace.ConsumeMessageHook;
+import org.apache.rocketmq.broker.pagecache.ManyMessageTransfer;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.TopicConfig;
+import org.apache.rocketmq.common.TopicFilterType;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.constant.PermName;
+import org.apache.rocketmq.common.filter.FilterAPI;
+import org.apache.rocketmq.common.help.FAQUrl;
+import org.apache.rocketmq.common.message.MessageDecoder;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.ResponseCode;
+import org.apache.rocketmq.common.protocol.header.PullMessageRequestHeader;
+import org.apache.rocketmq.common.protocol.header.PullMessageResponseHeader;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
+import org.apache.rocketmq.common.protocol.topic.OffsetMovedEvent;
+import org.apache.rocketmq.common.subscription.SubscriptionGroupConfig;
+import org.apache.rocketmq.common.sysflag.PullSysFlag;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.common.RemotingUtil;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.apache.rocketmq.store.GetMessageResult;
+import org.apache.rocketmq.store.MessageExtBrokerInner;
+import org.apache.rocketmq.store.PutMessageResult;
+import org.apache.rocketmq.store.config.BrokerRole;
+import org.apache.rocketmq.store.stats.BrokerStatsManager;
+import io.netty.channel.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.nio.ByteBuffer;
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class PullMessageProcessor implements NettyRequestProcessor {
+ private static final Logger LOG = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+ private final BrokerController brokerController;
+ private List<ConsumeMessageHook> consumeMessageHookList;
+
+ public PullMessageProcessor(final BrokerController brokerController) {
+ this.brokerController = brokerController;
+ }
+
+ @Override
+ public RemotingCommand processRequest(final ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ return this.processRequest(ctx.channel(), request, true);
+ }
+
+ @Override
+ public boolean rejectRequest() {
+ return false;
+ }
+
+ private RemotingCommand processRequest(final Channel channel, RemotingCommand request, boolean brokerAllowSuspend)
+ throws RemotingCommandException {
+ RemotingCommand response = RemotingCommand.createResponseCommand(PullMessageResponseHeader.class);
+ final PullMessageResponseHeader responseHeader = (PullMessageResponseHeader) response.readCustomHeader();
+ final PullMessageRequestHeader requestHeader =
+ (PullMessageRequestHeader) request.decodeCommandCustomHeader(PullMessageRequestHeader.class);
+
+
+ response.setOpaque(request.getOpaque());
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("receive PullMessage request command, " + request);
+ }
+
+
+ if (!PermName.isReadable(this.brokerController.getBrokerConfig().getBrokerPermission())) {
+ response.setCode(ResponseCode.NO_PERMISSION);
+ response.setRemark("the broker[" + this.brokerController.getBrokerConfig().getBrokerIP1() + "] pulling message is forbidden");
+ return response;
+ }
+
+
+ SubscriptionGroupConfig subscriptionGroupConfig =
+ this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(requestHeader.getConsumerGroup());
+ if (null == subscriptionGroupConfig) {
+ response.setCode(ResponseCode.SUBSCRIPTION_GROUP_NOT_EXIST);
+ response.setRemark("subscription group not exist, " + requestHeader.getConsumerGroup() + " "
+ + FAQUrl.suggestTodo(FAQUrl.SUBSCRIPTION_GROUP_NOT_EXIST));
+ return response;
+ }
+
+
+ if (!subscriptionGroupConfig.isConsumeEnable()) {
+ response.setCode(ResponseCode.NO_PERMISSION);
+ response.setRemark("subscription group no permission, " + requestHeader.getConsumerGroup());
+ return response;
+ }
+
+ final boolean hasSuspendFlag = PullSysFlag.hasSuspendFlag(requestHeader.getSysFlag());
+ final boolean hasCommitOffsetFlag = PullSysFlag.hasCommitOffsetFlag(requestHeader.getSysFlag());
+ final boolean hasSubscriptionFlag = PullSysFlag.hasSubscriptionFlag(requestHeader.getSysFlag());
+
+ final long suspendTimeoutMillisLong = hasSuspendFlag ? requestHeader.getSuspendTimeoutMillis() : 0;
+
+
+ TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(requestHeader.getTopic());
+ if (null == topicConfig) {
+ LOG.error("the topic " + requestHeader.getTopic() + " not exist, consumer: " + RemotingHelper.parseChannelRemoteAddr(channel));
+ response.setCode(ResponseCode.TOPIC_NOT_EXIST);
+ response.setRemark(
+ "topic[" + requestHeader.getTopic() + "] not exist, apply first please!" + FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
+ return response;
+ }
+
+
+ if (!PermName.isReadable(topicConfig.getPerm())) {
+ response.setCode(ResponseCode.NO_PERMISSION);
+ response.setRemark("the topic[" + requestHeader.getTopic() + "] pulling message is forbidden");
+ return response;
+ }
+
+
+ if (requestHeader.getQueueId() < 0 || requestHeader.getQueueId() >= topicConfig.getReadQueueNums()) {
+ String errorInfo = "queueId[" + requestHeader.getQueueId() + "] is illagal,Topic :" + requestHeader.getTopic()
+ + " topicConfig.readQueueNums: " + topicConfig.getReadQueueNums() + " consumer: " + channel.remoteAddress();
+ LOG.warn(errorInfo);
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark(errorInfo);
+ return response;
+ }
+
+
+ SubscriptionData subscriptionData = null;
+ if (hasSubscriptionFlag) {
+ try {
+ subscriptionData = FilterAPI.buildSubscriptionData(requestHeader.getConsumerGroup(), requestHeader.getTopic(),
+ requestHeader.getSubscription());
+ } catch (Exception e) {
+ LOG.warn("parse the consumer's subscription[{}] failed, group: {}", requestHeader.getSubscription(), //
+ requestHeader.getConsumerGroup());
+ response.setCode(ResponseCode.SUBSCRIPTION_PARSE_FAILED);
+ response.setRemark("parse the consumer's subscription failed");
+ return response;
+ }
+ } else {
+ ConsumerGroupInfo consumerGroupInfo =
+ this.brokerController.getConsumerManager().getConsumerGroupInfo(requestHeader.getConsumerGroup());
+ if (null == consumerGroupInfo) {
+ LOG.warn("the consumer's group info not exist, group: {}", requestHeader.getConsumerGroup());
+ response.setCode(ResponseCode.SUBSCRIPTION_NOT_EXIST);
+ response.setRemark("the consumer's group info not exist" + FAQUrl.suggestTodo(FAQUrl.SAME_GROUP_DIFFERENT_TOPIC));
+ return response;
+ }
+
+ if (!subscriptionGroupConfig.isConsumeBroadcastEnable() //
+ && consumerGroupInfo.getMessageModel() == MessageModel.BROADCASTING) {
+ response.setCode(ResponseCode.NO_PERMISSION);
+ response.setRemark("the consumer group[" + requestHeader.getConsumerGroup() + "] can not consume by broadcast way");
+ return response;
+ }
+
+ subscriptionData = consumerGroupInfo.findSubscriptionData(requestHeader.getTopic());
+ if (null == subscriptionData) {
+ LOG.warn("the consumer's subscription not exist, group: {}, topic:{}", requestHeader.getConsumerGroup(), requestHeader.getTopic());
+ response.setCode(ResponseCode.SUBSCRIPTION_NOT_EXIST);
+ response.setRemark("the consumer's subscription not exist" + FAQUrl.suggestTodo(FAQUrl.SAME_GROUP_DIFFERENT_TOPIC));
+ return response;
+ }
+
+
+ if (subscriptionData.getSubVersion() < requestHeader.getSubVersion()) {
+ LOG.warn("the broker's subscription is not latest, group: {} {}", requestHeader.getConsumerGroup(),
+ subscriptionData.getSubString());
+ response.setCode(ResponseCode.SUBSCRIPTION_NOT_LATEST);
+ response.setRemark("the consumer's subscription not latest");
+ return response;
+ }
+ }
+
+ final GetMessageResult getMessageResult =
+ this.brokerController.getMessageStore().getMessage(requestHeader.getConsumerGroup(), requestHeader.getTopic(),
+ requestHeader.getQueueId(), requestHeader.getQueueOffset(), requestHeader.getMaxMsgNums(), subscriptionData);
+ if (getMessageResult != null) {
+ response.setRemark(getMessageResult.getStatus().name());
+ responseHeader.setNextBeginOffset(getMessageResult.getNextBeginOffset());
+ responseHeader.setMinOffset(getMessageResult.getMinOffset());
+ responseHeader.setMaxOffset(getMessageResult.getMaxOffset());
+
+
+ if (getMessageResult.isSuggestPullingFromSlave()) {
+ responseHeader.setSuggestWhichBrokerId(subscriptionGroupConfig.getWhichBrokerWhenConsumeSlowly());
+ } else {
+ responseHeader.setSuggestWhichBrokerId(MixAll.MASTER_ID);
+ }
+
+ switch (this.brokerController.getMessageStoreConfig().getBrokerRole()) {
+ case ASYNC_MASTER:
+ case SYNC_MASTER:
+ break;
+ case SLAVE:
+ if (!this.brokerController.getBrokerConfig().isSlaveReadEnable()) {
+ response.setCode(ResponseCode.PULL_RETRY_IMMEDIATELY);
+ responseHeader.setSuggestWhichBrokerId(MixAll.MASTER_ID);
+ }
+ break;
+ }
+
+ if (this.brokerController.getBrokerConfig().isSlaveReadEnable()) {
+ // consume too slow ,redirect to another machine
+ if (getMessageResult.isSuggestPullingFromSlave()) {
+ responseHeader.setSuggestWhichBrokerId(subscriptionGroupConfig.getWhichBrokerWhenConsumeSlowly());
+ }
+ // consume ok
+ else {
+ responseHeader.setSuggestWhichBrokerId(subscriptionGroupConfig.getBrokerId());
+ }
+ } else {
+ responseHeader.setSuggestWhichBrokerId(MixAll.MASTER_ID);
+ }
+
+ switch (getMessageResult.getStatus()) {
+ case FOUND:
+ response.setCode(ResponseCode.SUCCESS);
+ break;
+ case MESSAGE_WAS_REMOVING:
+ response.setCode(ResponseCode.PULL_RETRY_IMMEDIATELY);
+ break;
+ case NO_MATCHED_LOGIC_QUEUE:
+ case NO_MESSAGE_IN_QUEUE:
+ if (0 != requestHeader.getQueueOffset()) {
+ response.setCode(ResponseCode.PULL_OFFSET_MOVED);
+
+ // XXX: warn and notify me
+ LOG.info("the broker store no queue data, fix the request offset {} to {}, Topic: {} QueueId: {} Consumer Group: {}", //
+ requestHeader.getQueueOffset(), //
+ getMessageResult.getNextBeginOffset(), //
+ requestHeader.getTopic(), //
+ requestHeader.getQueueId(), //
+ requestHeader.getConsumerGroup()//
+ );
+ } else {
+ response.setCode(ResponseCode.PULL_NOT_FOUND);
+ }
+ break;
+ case NO_MATCHED_MESSAGE:
+ response.setCode(ResponseCode.PULL_RETRY_IMMEDIATELY);
+ break;
+ case OFFSET_FOUND_NULL:
+ response.setCode(ResponseCode.PULL_NOT_FOUND);
+ break;
+ case OFFSET_OVERFLOW_BADLY:
+ response.setCode(ResponseCode.PULL_OFFSET_MOVED);
+ // XXX: warn and notify me
+ LOG.info("the request offset: " + requestHeader.getQueueOffset() + " over flow badly, broker max offset: "
+ + getMessageResult.getMaxOffset() + ", consumer: " + channel.remoteAddress());
+ break;
+ case OFFSET_OVERFLOW_ONE:
+ response.setCode(ResponseCode.PULL_NOT_FOUND);
+ break;
+ case OFFSET_TOO_SMALL:
+ response.setCode(ResponseCode.PULL_OFFSET_MOVED);
+ LOG.info("the request offset too small. group={}, topic={}, requestOffset={}, brokerMinOffset={}, clientIp={}",
+ requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueOffset(),
+ getMessageResult.getMinOffset(), channel.remoteAddress());
+ break;
+ default:
+ assert false;
+ break;
+ }
+
+ if (this.hasConsumeMessageHook()) {
+ ConsumeMessageContext context = new ConsumeMessageContext();
+ context.setConsumerGroup(requestHeader.getConsumerGroup());
+ context.setTopic(requestHeader.getTopic());
+ context.setQueueId(requestHeader.getQueueId());
+
+ String owner = request.getExtFields().get(BrokerStatsManager.COMMERCIAL_OWNER);
+
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS:
+ int commercialBaseCount = brokerController.getBrokerConfig().getCommercialBaseCount();
+ int incValue = getMessageResult.getMsgCount4Commercial() * commercialBaseCount;
+
+ context.setCommercialRcvStats(BrokerStatsManager.StatsType.RCV_SUCCESS);
+ context.setCommercialRcvTimes(incValue);
+ context.setCommercialRcvSize(getMessageResult.getBufferTotalSize());
+ context.setCommercialOwner(owner);
+
+ break;
+ case ResponseCode.PULL_NOT_FOUND:
+ if (!brokerAllowSuspend) {
+
+
+ context.setCommercialRcvStats(BrokerStatsManager.StatsType.RCV_EPOLLS);
+ context.setCommercialRcvTimes(1);
+ context.setCommercialOwner(owner);
+
+ }
+ break;
+ case ResponseCode.PULL_RETRY_IMMEDIATELY:
+ case ResponseCode.PULL_OFFSET_MOVED:
+ context.setCommercialRcvStats(BrokerStatsManager.StatsType.RCV_EPOLLS);
+ context.setCommercialRcvTimes(1);
+ context.setCommercialOwner(owner);
+ break;
+ default:
+ assert false;
+ break;
+ }
+
+ this.executeConsumeMessageHookBefore(context);
+ }
+
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS:
+
+ this.brokerController.getBrokerStatsManager().incGroupGetNums(requestHeader.getConsumerGroup(), requestHeader.getTopic(),
+ getMessageResult.getMessageCount());
+
+ this.brokerController.getBrokerStatsManager().incGroupGetSize(requestHeader.getConsumerGroup(), requestHeader.getTopic(),
+ getMessageResult.getBufferTotalSize());
+
+ this.brokerController.getBrokerStatsManager().incBrokerGetNums(getMessageResult.getMessageCount());
+ if (this.brokerController.getBrokerConfig().isTransferMsgByHeap()) {
+ final long beginTimeMills = this.brokerController.getMessageStore().now();
+ final byte[] r = this.readGetMessageResult(getMessageResult, requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueId());
+ this.brokerController.getBrokerStatsManager().incGroupGetLatency(requestHeader.getConsumerGroup(),
+ requestHeader.getTopic(), requestHeader.getQueueId(),
+ (int) (this.brokerController.getMessageStore().now() - beginTimeMills));
+ response.setBody(r);
+ } else {
+ try {
+ FileRegion fileRegion =
+ new ManyMessageTransfer(response.encodeHeader(getMessageResult.getBufferTotalSize()), getMessageResult);
+ channel.writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
+ @Override
+ public void operationComplete(ChannelFuture future) throws Exception {
+ getMessageResult.release();
+ if (!future.isSuccess()) {
+ LOG.error("transfer many message by pagecache failed, " + channel.remoteAddress(), future.cause());
+ }
+ }
+ });
+ } catch (Throwable e) {
+ LOG.error("transfer many message by pagecache exception", e);
+ getMessageResult.release();
+ }
+
+ response = null;
+ }
+ break;
+ case ResponseCode.PULL_NOT_FOUND:
+
+ if (brokerAllowSuspend && hasSuspendFlag) {
+ long pollingTimeMills = suspendTimeoutMillisLong;
+ if (!this.brokerController.getBrokerConfig().isLongPollingEnable()) {
+ pollingTimeMills = this.brokerController.getBrokerConfig().getShortPollingTimeMills();
+ }
+
+ String topic = requestHeader.getTopic();
+ long offset = requestHeader.getQueueOffset();
+ int queueId = requestHeader.getQueueId();
+ PullRequest pullRequest = new PullRequest(request, channel, pollingTimeMills,
+ this.brokerController.getMessageStore().now(), offset, subscriptionData);
+ this.brokerController.getPullRequestHoldService().suspendPullRequest(topic, queueId, pullRequest);
+ response = null;
+ break;
+ }
+
+
+ case ResponseCode.PULL_RETRY_IMMEDIATELY:
+ break;
+ case ResponseCode.PULL_OFFSET_MOVED:
+ if (this.brokerController.getMessageStoreConfig().getBrokerRole() != BrokerRole.SLAVE
+ || this.brokerController.getMessageStoreConfig().isOffsetCheckInSlave()) {
+ MessageQueue mq = new MessageQueue();
+ mq.setTopic(requestHeader.getTopic());
+ mq.setQueueId(requestHeader.getQueueId());
+ mq.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());
+
+ OffsetMovedEvent event = new OffsetMovedEvent();
+ event.setConsumerGroup(requestHeader.getConsumerGroup());
+ event.setMessageQueue(mq);
+ event.setOffsetRequest(requestHeader.getQueueOffset());
+ event.setOffsetNew(getMessageResult.getNextBeginOffset());
+ this.generateOffsetMovedEvent(event);
+ LOG.warn(
+ "PULL_OFFSET_MOVED:correction offset. topic={}, groupId={}, requestOffset={}, newOffset={}, suggestBrokerId={}",
+ requestHeader.getTopic(), requestHeader.getConsumerGroup(), event.getOffsetRequest(), event.getOffsetNew(),
+ responseHeader.getSuggestWhichBrokerId());
+ } else {
+ responseHeader.setSuggestWhichBrokerId(subscriptionGroupConfig.getBrokerId());
+ response.setCode(ResponseCode.PULL_RETRY_IMMEDIATELY);
+ LOG.warn("PULL_OFFSET_MOVED:none correction. topic={}, groupId={}, requestOffset={}, suggestBrokerId={}",
+ requestHeader.getTopic(), requestHeader.getConsumerGroup(), requestHeader.getQueueOffset(),
+ responseHeader.getSuggestWhichBrokerId());
+ }
+
+ break;
+ default:
+ assert false;
+ }
+ } else {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("store getMessage return null");
+ }
+
+
+ boolean storeOffsetEnable = brokerAllowSuspend;
+ storeOffsetEnable = storeOffsetEnable && hasCommitOffsetFlag;
+ storeOffsetEnable = storeOffsetEnable
+ && this.brokerController.getMessageStoreConfig().getBrokerRole() != BrokerRole.SLAVE;
+ if (storeOffsetEnable) {
+ this.brokerController.getConsumerOffsetManager().commitOffset(RemotingHelper.parseChannelRemoteAddr(channel),
+ requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueId(), requestHeader.getCommitOffset());
+ }
+ return response;
+ }
+
+
+ public boolean hasConsumeMessageHook() {
+ return consumeMessageHookList != null && !this.consumeMessageHookList.isEmpty();
+ }
+
+ public void executeConsumeMessageHookBefore(final ConsumeMessageContext context) {
+ if (hasConsumeMessageHook()) {
+ for (ConsumeMessageHook hook : this.consumeMessageHookList) {
+ try {
+ hook.consumeMessageBefore(context);
+ } catch (Throwable e) {
+ }
+ }
+ }
+ }
+
+ private byte[] readGetMessageResult(final GetMessageResult getMessageResult, final String group, final String topic, final int queueId) {
+ final ByteBuffer byteBuffer = ByteBuffer.allocate(getMessageResult.getBufferTotalSize());
+
+ long storeTimestamp = 0;
+ try {
+ List<ByteBuffer> messageBufferList = getMessageResult.getMessageBufferList();
+ for (ByteBuffer bb : messageBufferList) {
+
+ byteBuffer.put(bb);
+ storeTimestamp = bb.getLong(MessageDecoder.MESSAGE_STORE_TIMESTAMP_POSTION);
+ }
+ } finally {
+ getMessageResult.release();
+ }
+
+ this.brokerController.getBrokerStatsManager().recordDiskFallBehindTime(group, topic, queueId, this.brokerController.getMessageStore().now() - storeTimestamp);
+ return byteBuffer.array();
+ }
+
+ private void generateOffsetMovedEvent(final OffsetMovedEvent event) {
+ try {
+ MessageExtBrokerInner msgInner = new MessageExtBrokerInner();
+ msgInner.setTopic(MixAll.OFFSET_MOVED_EVENT);
+ msgInner.setTags(event.getConsumerGroup());
+ msgInner.setDelayTimeLevel(0);
+ msgInner.setKeys(event.getConsumerGroup());
+ msgInner.setBody(event.encode());
+ msgInner.setFlag(0);
+ msgInner.setPropertiesString(MessageDecoder.messageProperties2String(msgInner.getProperties()));
+ msgInner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(TopicFilterType.SINGLE_TAG, msgInner.getTags()));
+
+ msgInner.setQueueId(0);
+ msgInner.setSysFlag(0);
+ msgInner.setBornTimestamp(System.currentTimeMillis());
+ msgInner.setBornHost(RemotingUtil.string2SocketAddress(this.brokerController.getBrokerAddr()));
+ msgInner.setStoreHost(msgInner.getBornHost());
+
+ msgInner.setReconsumeTimes(0);
+
+ PutMessageResult putMessageResult = this.brokerController.getMessageStore().putMessage(msgInner);
+ } catch (Exception e) {
+ LOG.warn(String.format("generateOffsetMovedEvent Exception, %s", event.toString()), e);
+ }
+ }
+
+ public void excuteRequestWhenWakeup(final Channel channel, final RemotingCommand request) throws RemotingCommandException {
+ Runnable run = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ final RemotingCommand response = PullMessageProcessor.this.processRequest(channel, request, false);
+
+ if (response != null) {
+ response.setOpaque(request.getOpaque());
+ response.markResponseType();
+ try {
+ channel.writeAndFlush(response).addListener(new ChannelFutureListener() {
+ @Override
+ public void operationComplete(ChannelFuture future) throws Exception {
+ if (!future.isSuccess()) {
+ LOG.error("processRequestWrapper response to " + future.channel().remoteAddress() + " failed",
+ future.cause());
+ LOG.error(request.toString());
+ LOG.error(response.toString());
+ }
+ }
+ });
+ } catch (Throwable e) {
+ LOG.error("processRequestWrapper process request over, but response failed", e);
+ LOG.error(request.toString());
+ LOG.error(response.toString());
+ }
+ }
+ } catch (RemotingCommandException e1) {
+ LOG.error("excuteRequestWhenWakeup run", e1);
+ }
+ }
+ };
+
+ this.brokerController.getPullMessageExecutor().submit(run);
+ }
+
+ public void registerConsumeMessageHook(List<ConsumeMessageHook> sendMessageHookList) {
+ this.consumeMessageHookList = sendMessageHookList;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
new file mode 100644
index 0000000..5390e28
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
@@ -0,0 +1,178 @@
+/**
+ * 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.broker.processor;
+
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.broker.pagecache.OneMessageTransfer;
+import org.apache.rocketmq.broker.pagecache.QueryMessageTransfer;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.protocol.RequestCode;
+import org.apache.rocketmq.common.protocol.ResponseCode;
+import org.apache.rocketmq.common.protocol.header.QueryMessageRequestHeader;
+import org.apache.rocketmq.common.protocol.header.QueryMessageResponseHeader;
+import org.apache.rocketmq.common.protocol.header.ViewMessageRequestHeader;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.apache.rocketmq.store.QueryMessageResult;
+import org.apache.rocketmq.store.SelectMappedBufferResult;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelFutureListener;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.FileRegion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class QueryMessageProcessor implements NettyRequestProcessor {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+
+ private final BrokerController brokerController;
+
+
+ public QueryMessageProcessor(final BrokerController brokerController) {
+ this.brokerController = brokerController;
+ }
+
+
+ @Override
+ public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request)
+ throws RemotingCommandException {
+ switch (request.getCode()) {
+ case RequestCode.QUERY_MESSAGE:
+ return this.queryMessage(ctx, request);
+ case RequestCode.VIEW_MESSAGE_BY_ID:
+ return this.viewMessageById(ctx, request);
+ default:
+ break;
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean rejectRequest() {
+ return false;
+ }
+
+
+ public RemotingCommand queryMessage(ChannelHandlerContext ctx, RemotingCommand request)
+ throws RemotingCommandException {
+ final RemotingCommand response =
+ RemotingCommand.createResponseCommand(QueryMessageResponseHeader.class);
+ final QueryMessageResponseHeader responseHeader =
+ (QueryMessageResponseHeader) response.readCustomHeader();
+ final QueryMessageRequestHeader requestHeader =
+ (QueryMessageRequestHeader) request
+ .decodeCommandCustomHeader(QueryMessageRequestHeader.class);
+
+
+ response.setOpaque(request.getOpaque());
+
+
+ String isUniqueKey = request.getExtFields().get(MixAll.UNIQUE_MSG_QUERY_FLAG);
+ if (isUniqueKey != null && isUniqueKey.equals("true")) {
+ requestHeader.setMaxNum(this.brokerController.getMessageStoreConfig().getDefaultQueryMaxNum());
+ }
+
+ final QueryMessageResult queryMessageResult =
+ this.brokerController.getMessageStore().queryMessage(requestHeader.getTopic(),
+ requestHeader.getKey(), requestHeader.getMaxNum(), requestHeader.getBeginTimestamp(),
+ requestHeader.getEndTimestamp());
+ assert queryMessageResult != null;
+
+ responseHeader.setIndexLastUpdatePhyoffset(queryMessageResult.getIndexLastUpdatePhyoffset());
+ responseHeader.setIndexLastUpdateTimestamp(queryMessageResult.getIndexLastUpdateTimestamp());
+
+
+ if (queryMessageResult.getBufferTotalSize() > 0) {
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+
+ try {
+ FileRegion fileRegion =
+ new QueryMessageTransfer(response.encodeHeader(queryMessageResult
+ .getBufferTotalSize()), queryMessageResult);
+ ctx.channel().writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
+ @Override
+ public void operationComplete(ChannelFuture future) throws Exception {
+ queryMessageResult.release();
+ if (!future.isSuccess()) {
+ log.error("transfer query message by pagecache failed, ", future.cause());
+ }
+ }
+ });
+ } catch (Throwable e) {
+ log.error("", e);
+ queryMessageResult.release();
+ }
+
+ return null;
+ }
+
+ response.setCode(ResponseCode.QUERY_NOT_FOUND);
+ response.setRemark("can not find message, maybe time range not correct");
+ return response;
+ }
+
+
+ public RemotingCommand viewMessageById(ChannelHandlerContext ctx, RemotingCommand request)
+ throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ final ViewMessageRequestHeader requestHeader =
+ (ViewMessageRequestHeader) request.decodeCommandCustomHeader(ViewMessageRequestHeader.class);
+
+
+ response.setOpaque(request.getOpaque());
+
+ final SelectMappedBufferResult selectMappedBufferResult =
+ this.brokerController.getMessageStore().selectOneMessageByOffset(requestHeader.getOffset());
+ if (selectMappedBufferResult != null) {
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+
+ try {
+ FileRegion fileRegion =
+ new OneMessageTransfer(response.encodeHeader(selectMappedBufferResult.getSize()),
+ selectMappedBufferResult);
+ ctx.channel().writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
+ @Override
+ public void operationComplete(ChannelFuture future) throws Exception {
+ selectMappedBufferResult.release();
+ if (!future.isSuccess()) {
+ log.error("transfer one message by pagecache failed, ", future.cause());
+ }
+ }
+ });
+ } catch (Throwable e) {
+ log.error("", e);
+ selectMappedBufferResult.release();
+ }
+
+ return null;
+ } else {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("can not find message by the offset, " + requestHeader.getOffset());
+ }
+
+ return response;
+ }
+}
[70/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java b/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
index 84a3af6..82fe8f4 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
@@ -16,19 +16,15 @@
*/
package org.apache.rocketmq.store.ha;
-import org.apache.rocketmq.common.ServiceThread;
-import org.apache.rocketmq.common.constant.LoggerName;
-import org.apache.rocketmq.remoting.common.RemotingUtil;
-import org.apache.rocketmq.store.DefaultMessageStore;
-import org.apache.rocketmq.store.CommitLog;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
-import java.nio.channels.*;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
@@ -36,7 +32,13 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
-
+import org.apache.rocketmq.common.ServiceThread;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.remoting.common.RemotingUtil;
+import org.apache.rocketmq.store.CommitLog;
+import org.apache.rocketmq.store.DefaultMessageStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class HAService {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
@@ -56,38 +58,33 @@ public class HAService {
private final HAClient haClient;
-
public HAService(final DefaultMessageStore defaultMessageStore) throws IOException {
this.defaultMessageStore = defaultMessageStore;
this.acceptSocketService =
- new AcceptSocketService(defaultMessageStore.getMessageStoreConfig().getHaListenPort());
+ new AcceptSocketService(defaultMessageStore.getMessageStoreConfig().getHaListenPort());
this.groupTransferService = new GroupTransferService();
this.haClient = new HAClient();
}
-
public void updateMasterAddress(final String newAddr) {
if (this.haClient != null) {
this.haClient.updateMasterAddress(newAddr);
}
}
-
public void putRequest(final CommitLog.GroupCommitRequest request) {
this.groupTransferService.putRequest(request);
}
-
public boolean isSlaveOK(final long masterPutWhere) {
boolean result = this.connectionCount.get() > 0;
result =
- result
- && ((masterPutWhere - this.push2SlaveMaxOffset.get()) < this.defaultMessageStore
- .getMessageStoreConfig().getHaSlaveFallbehindMax());
+ result
+ && ((masterPutWhere - this.push2SlaveMaxOffset.get()) < this.defaultMessageStore
+ .getMessageStoreConfig().getHaSlaveFallbehindMax());
return result;
}
-
/**
*/
@@ -103,12 +100,10 @@ public class HAService {
}
}
-
public AtomicInteger getConnectionCount() {
return connectionCount;
}
-
// public void notifyTransferSome() {
// this.groupTransferService.notifyTransferSome();
// }
@@ -120,21 +115,18 @@ public class HAService {
this.haClient.start();
}
-
public void addConnection(final HAConnection conn) {
synchronized (this.connectionList) {
this.connectionList.add(conn);
}
}
-
public void removeConnection(final HAConnection conn) {
synchronized (this.connectionList) {
this.connectionList.remove(conn);
}
}
-
public void shutdown() {
this.haClient.shutdown();
this.acceptSocketService.shutdown(true);
@@ -142,7 +134,6 @@ public class HAService {
this.groupTransferService.shutdown();
}
-
public void destroyConnections() {
synchronized (this.connectionList) {
for (HAConnection c : this.connectionList) {
@@ -153,12 +144,10 @@ public class HAService {
}
}
-
public DefaultMessageStore getDefaultMessageStore() {
return defaultMessageStore;
}
-
public WaitNotifyObject getWaitNotifyObject() {
return waitNotifyObject;
}
@@ -171,9 +160,9 @@ public class HAService {
* Listens to slave connections to create {@link HAConnection}.
*/
class AcceptSocketService extends ServiceThread {
+ private final SocketAddress socketAddressListen;
private ServerSocketChannel serverSocketChannel;
private Selector selector;
- private final SocketAddress socketAddressListen;
public AcceptSocketService(final int port) {
this.socketAddressListen = new InetSocketAddress(port);
@@ -181,6 +170,7 @@ public class HAService {
/**
* Starts listening to slave connections.
+ *
* @throws Exception If fails.
*/
public void beginAccept() throws Exception {
@@ -199,8 +189,7 @@ public class HAService {
try {
this.serverSocketChannel.close();
this.selector.close();
- }
- catch (IOException e) {
+ } catch (IOException e) {
log.error("AcceptSocketService shutdown exception", e);
}
}
@@ -218,11 +207,11 @@ public class HAService {
if (selected != null) {
for (SelectionKey k : selected) {
if ((k.readyOps() & SelectionKey.OP_ACCEPT) != 0) {
- SocketChannel sc = ((ServerSocketChannel) k.channel()).accept();
+ SocketChannel sc = ((ServerSocketChannel)k.channel()).accept();
if (sc != null) {
HAService.log.info("HAService receive new connection, "
- + sc.socket().getRemoteSocketAddress());
+ + sc.socket().getRemoteSocketAddress());
try {
HAConnection conn = new HAConnection(HAService.this, sc);
@@ -264,7 +253,6 @@ public class HAService {
private volatile List<CommitLog.GroupCommitRequest> requestsWrite = new ArrayList<>();
private volatile List<CommitLog.GroupCommitRequest> requestsRead = new ArrayList<>();
-
public void putRequest(final CommitLog.GroupCommitRequest request) {
synchronized (this) {
this.requestsWrite.add(request);
@@ -274,19 +262,16 @@ public class HAService {
}
}
-
public void notifyTransferSome() {
this.notifyTransferObject.wakeup();
}
-
private void swapRequests() {
List<CommitLog.GroupCommitRequest> tmp = this.requestsWrite;
this.requestsWrite = this.requestsRead;
this.requestsRead = tmp;
}
-
private void doWaitTransfer() {
if (!this.requestsRead.isEmpty()) {
for (CommitLog.GroupCommitRequest req : this.requestsRead) {
@@ -307,7 +292,6 @@ public class HAService {
}
}
-
public void run() {
log.info(this.getServiceName() + " service started");
@@ -323,13 +307,11 @@ public class HAService {
log.info(this.getServiceName() + " service end");
}
-
@Override
protected void onWaitEnd() {
this.swapRequests();
}
-
@Override
public String getServiceName() {
return GroupTransferService.class.getSimpleName();
@@ -349,12 +331,10 @@ public class HAService {
private ByteBuffer byteBufferRead = ByteBuffer.allocate(READ_MAX_BUFFER_SIZE);
private ByteBuffer byteBufferBackup = ByteBuffer.allocate(READ_MAX_BUFFER_SIZE);
-
public HAClient() throws IOException {
this.selector = RemotingUtil.openSelector();
}
-
public void updateMasterAddress(final String newAddr) {
String currentAddr = this.masterAddress.get();
if (currentAddr == null || !currentAddr.equals(newAddr)) {
@@ -363,17 +343,15 @@ public class HAService {
}
}
-
private boolean isTimeToReportOffset() {
long interval =
- HAService.this.defaultMessageStore.getSystemClock().now() - this.lastWriteTimestamp;
+ HAService.this.defaultMessageStore.getSystemClock().now() - this.lastWriteTimestamp;
boolean needHeart = interval > HAService.this.defaultMessageStore.getMessageStoreConfig()
- .getHaSendHeartbeatInterval();
+ .getHaSendHeartbeatInterval();
return needHeart;
}
-
private boolean reportSlaveMaxOffset(final long maxOffset) {
this.reportOffset.position(0);
this.reportOffset.limit(8);
@@ -386,7 +364,7 @@ public class HAService {
this.socketChannel.write(this.reportOffset);
} catch (IOException e) {
log.error(this.getServiceName()
- + "reportSlaveMaxOffset this.socketChannel.write exception", e);
+ + "reportSlaveMaxOffset this.socketChannel.write exception", e);
return false;
}
}
@@ -394,7 +372,6 @@ public class HAService {
return !this.reportOffset.hasRemaining();
}
-
// private void reallocateByteBuffer() {
// ByteBuffer bb = ByteBuffer.allocate(READ_MAX_BUFFER_SIZE);
// int remain = this.byteBufferRead.limit() - this.dispatchPostion;
@@ -423,14 +400,12 @@ public class HAService {
this.dispatchPostion = 0;
}
-
private void swapByteBuffer() {
ByteBuffer tmp = this.byteBufferRead;
this.byteBufferRead = this.byteBufferBackup;
this.byteBufferBackup = tmp;
}
-
private boolean processReadEvent() {
int readSizeZeroTimes = 0;
while (this.byteBufferRead.hasRemaining()) {
@@ -462,7 +437,6 @@ public class HAService {
return true;
}
-
private boolean dispatchReadRequest() {
final int msgHeaderSize = 8 + 4; // phyoffset + size
int readSocketPos = this.byteBufferRead.position();
@@ -475,22 +449,19 @@ public class HAService {
long slavePhyOffset = HAService.this.defaultMessageStore.getMaxPhyOffset();
-
if (slavePhyOffset != 0) {
if (slavePhyOffset != masterPhyOffset) {
log.error("master pushed offset not equal the max phy offset in slave, SLAVE: "
- + slavePhyOffset + " MASTER: " + masterPhyOffset);
+ + slavePhyOffset + " MASTER: " + masterPhyOffset);
return false;
}
}
-
if (diff >= (msgHeaderSize + bodySize)) {
byte[] bodyData = new byte[bodySize];
this.byteBufferRead.position(this.dispatchPostion + msgHeaderSize);
this.byteBufferRead.get(bodyData);
-
HAService.this.defaultMessageStore.appendToCommitLog(masterPhyOffset, bodyData);
this.byteBufferRead.position(readSocketPos);
@@ -514,7 +485,6 @@ public class HAService {
return true;
}
-
private boolean reportSlaveMaxOffsetPlus() {
boolean result = true;
long currentPhyOffset = HAService.this.defaultMessageStore.getMaxPhyOffset();
@@ -530,7 +500,6 @@ public class HAService {
return result;
}
-
private boolean connectMaster() throws ClosedChannelException {
if (null == socketChannel) {
String addr = this.masterAddress.get();
@@ -553,7 +522,6 @@ public class HAService {
return this.socketChannel != null;
}
-
private void closeMaster() {
if (null != this.socketChannel) {
try {
@@ -581,7 +549,6 @@ public class HAService {
}
}
-
@Override
public void run() {
log.info(this.getServiceName() + " service started");
@@ -597,10 +564,8 @@ public class HAService {
}
}
-
this.selector.select(1000);
-
boolean ok = this.processReadEvent();
if (!ok) {
this.closeMaster();
@@ -610,14 +575,13 @@ public class HAService {
continue;
}
-
long interval =
- HAService.this.getDefaultMessageStore().getSystemClock().now()
- - this.lastWriteTimestamp;
+ HAService.this.getDefaultMessageStore().getSystemClock().now()
+ - this.lastWriteTimestamp;
if (interval > HAService.this.getDefaultMessageStore().getMessageStoreConfig()
- .getHaHousekeepingInterval()) {
+ .getHaHousekeepingInterval()) {
log.warn("HAClient, housekeeping, found this connection[" + this.masterAddress
- + "] expired, " + interval);
+ + "] expired, " + interval);
this.closeMaster();
log.warn("HAClient, master not response some time, so close connection");
}
@@ -633,7 +597,6 @@ public class HAService {
log.info(this.getServiceName() + " service end");
}
-
//
// private void disableWriteFlag() {
// if (this.socketChannel != null) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/ha/WaitNotifyObject.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/ha/WaitNotifyObject.java b/store/src/main/java/org/apache/rocketmq/store/ha/WaitNotifyObject.java
index c059e10..a96af5e 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ha/WaitNotifyObject.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ha/WaitNotifyObject.java
@@ -6,27 +6,25 @@
* (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
+ * 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.
+ * 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.store.ha;
import java.util.HashMap;
-
public class WaitNotifyObject {
protected final HashMap<Long/* thread id */, Boolean/* notified */> waitingThreadTable =
- new HashMap<Long, Boolean>(16);
+ new HashMap<Long, Boolean>(16);
protected volatile boolean hasNotified = false;
-
public void wakeup() {
synchronized (this) {
if (!this.hasNotified) {
@@ -36,7 +34,6 @@ public class WaitNotifyObject {
}
}
-
protected void waitForRunning(long interval) {
synchronized (this) {
if (this.hasNotified) {
@@ -56,7 +53,6 @@ public class WaitNotifyObject {
}
}
-
protected void onWaitEnd() {
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java b/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
index d6a223d..de1a31d 100644
--- a/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
+++ b/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
@@ -6,28 +6,26 @@
* (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
+ * 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.
+ * 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.store.index;
-import org.apache.rocketmq.common.constant.LoggerName;
-import org.apache.rocketmq.store.MappedFile;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.util.List;
-
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.store.MappedFile;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class IndexFile {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
@@ -41,11 +39,10 @@ public class IndexFile {
private final MappedByteBuffer mappedByteBuffer;
private final IndexHeader indexHeader;
-
public IndexFile(final String fileName, final int hashSlotNum, final int indexNum,
- final long endPhyOffset, final long endTimestamp) throws IOException {
+ final long endPhyOffset, final long endTimestamp) throws IOException {
int fileTotalSize =
- IndexHeader.INDEX_HEADER_SIZE + (hashSlotNum * hashSlotSize) + (indexNum * indexSize);
+ IndexHeader.INDEX_HEADER_SIZE + (hashSlotNum * hashSlotSize) + (indexNum * indexSize);
this.mappedFile = new MappedFile(fileName, fileTotalSize);
this.fileChannel = this.mappedFile.getFileChannel();
this.mappedByteBuffer = this.mappedFile.getMappedByteBuffer();
@@ -66,17 +63,14 @@ public class IndexFile {
}
}
-
public String getFileName() {
return this.mappedFile.getFileName();
}
-
public void load() {
this.indexHeader.load();
}
-
public void flush() {
long beginTime = System.currentTimeMillis();
if (this.mappedFile.hold()) {
@@ -114,10 +108,8 @@ public class IndexFile {
long timeDiff = storeTimestamp - this.indexHeader.getBeginTimestamp();
-
timeDiff = timeDiff / 1000;
-
if (this.indexHeader.getBeginTimestamp() <= 0) {
timeDiff = 0;
} else if (timeDiff > Integer.MAX_VALUE) {
@@ -127,19 +119,16 @@ public class IndexFile {
}
int absIndexPos =
- IndexHeader.INDEX_HEADER_SIZE + this.hashSlotNum * hashSlotSize
- + this.indexHeader.getIndexCount() * indexSize;
-
+ IndexHeader.INDEX_HEADER_SIZE + this.hashSlotNum * hashSlotSize
+ + this.indexHeader.getIndexCount() * indexSize;
this.mappedByteBuffer.putInt(absIndexPos, keyHash);
this.mappedByteBuffer.putLong(absIndexPos + 4, phyOffset);
- this.mappedByteBuffer.putInt(absIndexPos + 4 + 8, (int) timeDiff);
+ this.mappedByteBuffer.putInt(absIndexPos + 4 + 8, (int)timeDiff);
this.mappedByteBuffer.putInt(absIndexPos + 4 + 8 + 4, slotValue);
-
this.mappedByteBuffer.putInt(absSlotPos, this.indexHeader.getIndexCount());
-
if (this.indexHeader.getIndexCount() <= 1) {
this.indexHeader.setBeginPhyOffset(phyOffset);
this.indexHeader.setBeginTimestamp(storeTimestamp);
@@ -192,22 +181,22 @@ public class IndexFile {
public boolean isTimeMatched(final long begin, final long end) {
boolean result =
- begin < this.indexHeader.getBeginTimestamp() && end > this.indexHeader.getEndTimestamp();
+ begin < this.indexHeader.getBeginTimestamp() && end > this.indexHeader.getEndTimestamp();
result =
- result
- || (begin >= this.indexHeader.getBeginTimestamp() && begin <= this.indexHeader
- .getEndTimestamp());
+ result
+ || (begin >= this.indexHeader.getBeginTimestamp() && begin <= this.indexHeader
+ .getEndTimestamp());
result =
- result
- || (end >= this.indexHeader.getBeginTimestamp() && end <= this.indexHeader
- .getEndTimestamp());
+ result
+ || (end >= this.indexHeader.getBeginTimestamp() && end <= this.indexHeader
+ .getEndTimestamp());
return result;
}
public void selectPhyOffset(final List<Long> phyOffsets, final String key, final int maxNum,
- final long begin, final long end, boolean lock) {
+ final long begin, final long end, boolean lock) {
if (this.mappedFile.hold()) {
int keyHash = indexKeyHashMethod(key);
int slotPos = keyHash % this.hashSlotNum;
@@ -227,25 +216,24 @@ public class IndexFile {
// }
if (slotValue <= invalidIndex || slotValue > this.indexHeader.getIndexCount()
- || this.indexHeader.getIndexCount() <= 1) {
+ || this.indexHeader.getIndexCount() <= 1) {
// TODO NOTFOUND
} else {
- for (int nextIndexToRead = slotValue;;) {
+ for (int nextIndexToRead = slotValue; ; ) {
if (phyOffsets.size() >= maxNum) {
break;
}
int absIndexPos =
- IndexHeader.INDEX_HEADER_SIZE + this.hashSlotNum * hashSlotSize
- + nextIndexToRead * indexSize;
+ IndexHeader.INDEX_HEADER_SIZE + this.hashSlotNum * hashSlotSize
+ + nextIndexToRead * indexSize;
int keyHashRead = this.mappedByteBuffer.getInt(absIndexPos);
long phyOffsetRead = this.mappedByteBuffer.getLong(absIndexPos + 4);
- long timeDiff = (long) this.mappedByteBuffer.getInt(absIndexPos + 4 + 8);
+ long timeDiff = (long)this.mappedByteBuffer.getInt(absIndexPos + 4 + 8);
int prevIndexRead = this.mappedByteBuffer.getInt(absIndexPos + 4 + 8 + 4);
-
if (timeDiff < 0) {
break;
}
@@ -260,8 +248,8 @@ public class IndexFile {
}
if (prevIndexRead <= invalidIndex
- || prevIndexRead > this.indexHeader.getIndexCount()
- || prevIndexRead == nextIndexToRead || timeRead < begin) {
+ || prevIndexRead > this.indexHeader.getIndexCount()
+ || prevIndexRead == nextIndexToRead || timeRead < begin) {
break;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/index/IndexHeader.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/index/IndexHeader.java b/store/src/main/java/org/apache/rocketmq/store/index/IndexHeader.java
index 130f08e..0c00abd 100644
--- a/store/src/main/java/org/apache/rocketmq/store/index/IndexHeader.java
+++ b/store/src/main/java/org/apache/rocketmq/store/index/IndexHeader.java
@@ -20,7 +20,6 @@ import java.nio.ByteBuffer;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
-
/**
*
@@ -43,12 +42,10 @@ public class IndexHeader {
private AtomicInteger indexCount = new AtomicInteger(1);
-
public IndexHeader(final ByteBuffer byteBuffer) {
this.byteBuffer = byteBuffer;
}
-
public void load() {
this.beginTimestamp.set(byteBuffer.getLong(beginTimestampIndex));
this.endTimestamp.set(byteBuffer.getLong(endTimestampIndex));
@@ -72,67 +69,55 @@ public class IndexHeader {
this.byteBuffer.putInt(indexCountIndex, this.indexCount.get());
}
-
public long getBeginTimestamp() {
return beginTimestamp.get();
}
-
public void setBeginTimestamp(long beginTimestamp) {
this.beginTimestamp.set(beginTimestamp);
this.byteBuffer.putLong(beginTimestampIndex, beginTimestamp);
}
-
public long getEndTimestamp() {
return endTimestamp.get();
}
-
public void setEndTimestamp(long endTimestamp) {
this.endTimestamp.set(endTimestamp);
this.byteBuffer.putLong(endTimestampIndex, endTimestamp);
}
-
public long getBeginPhyOffset() {
return beginPhyOffset.get();
}
-
public void setBeginPhyOffset(long beginPhyOffset) {
this.beginPhyOffset.set(beginPhyOffset);
this.byteBuffer.putLong(beginPhyoffsetIndex, beginPhyOffset);
}
-
public long getEndPhyOffset() {
return endPhyOffset.get();
}
-
public void setEndPhyOffset(long endPhyOffset) {
this.endPhyOffset.set(endPhyOffset);
this.byteBuffer.putLong(endPhyoffsetIndex, endPhyOffset);
}
-
public AtomicInteger getHashSlotCount() {
return hashSlotCount;
}
-
public void incHashSlotCount() {
int value = this.hashSlotCount.incrementAndGet();
this.byteBuffer.putInt(hashSlotcountIndex, value);
}
-
public int getIndexCount() {
return indexCount.get();
}
-
public void incIndexCount() {
int value = this.indexCount.incrementAndGet();
this.byteBuffer.putInt(indexCountIndex, value);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java b/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java
index 939ba2d..b72ffe9 100644
--- a/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java
@@ -16,6 +16,13 @@
*/
package org.apache.rocketmq.store.index;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.common.message.MessageConst;
@@ -26,39 +33,25 @@ import org.apache.rocketmq.store.config.StorePathConfigHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-
public class IndexService {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
+ /** Maximum times to attempt index file creation. */
+ private static final int MAX_TRY_IDX_CREATE = 3;
private final DefaultMessageStore defaultMessageStore;
-
private final int hashSlotNum;
private final int indexNum;
private final String storePath;
-
private final ArrayList<IndexFile> indexFileList = new ArrayList<IndexFile>();
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;
this.hashSlotNum = store.getMessageStoreConfig().getMaxHashSlotNum();
this.indexNum = store.getMessageStoreConfig().getMaxIndexNum();
this.storePath =
- StorePathConfigHelper.getStorePathIndex(store.getMessageStoreConfig().getStorePathRootDir());
+ StorePathConfigHelper.getStorePathIndex(store.getMessageStoreConfig().getStorePathRootDir());
}
-
public boolean load(final boolean lastExitOK) {
File dir = new File(this.storePath);
File[] files = dir.listFiles();
@@ -72,7 +65,7 @@ public class IndexService {
if (!lastExitOK) {
if (f.getEndTimestamp() > this.defaultMessageStore.getStoreCheckpoint()
- .getIndexMsgTimestamp()) {
+ .getIndexMsgTimestamp()) {
f.destroy(0);
continue;
}
@@ -113,7 +106,7 @@ public class IndexService {
if (files != null) {
List<IndexFile> fileList = new ArrayList<IndexFile>();
for (int i = 0; i < (files.length - 1); i++) {
- IndexFile f = (IndexFile) files[i];
+ IndexFile f = (IndexFile)files[i];
if (f.getEndPhyOffset() < offset) {
fileList.add(f);
} else {
@@ -145,7 +138,6 @@ public class IndexService {
}
}
-
public void destroy() {
try {
this.readWriteLock.readLock().lock();
@@ -160,7 +152,6 @@ public class IndexService {
}
}
-
public QueryOffsetResult queryOffset(String topic, String key, int maxNum, long begin, long end) {
List<Long> phyOffsets = new ArrayList<Long>(maxNum);
@@ -183,7 +174,6 @@ public class IndexService {
f.selectPhyOffset(phyOffsets, buildKey(topic, key), maxNum, begin, end, lastFile);
}
-
if (f.getBeginTimestamp() < begin) {
break;
}
@@ -202,12 +192,10 @@ public class IndexService {
return new QueryOffsetResult(phyOffsets, indexLastUpdateTimestamp, indexLastUpdatePhyoffset);
}
-
private String buildKey(final String topic, final String key) {
return topic + "#" + key;
}
-
public void buildIndex(DispatchRequest req) {
IndexFile indexFile = retryGetAndCreateIndexFile();
if (indexFile != null) {
@@ -255,7 +243,6 @@ public class IndexService {
}
}
-
private IndexFile putKey(IndexFile indexFile, DispatchRequest msg, String idxKey) {
for (boolean ok = indexFile.putKey(idxKey, msg.getCommitLogOffset(), msg.getStoreTimestamp()); !ok; ) {
log.warn("Index file [" + indexFile.getFileName() + "] is full, trying to create another one");
@@ -300,7 +287,6 @@ public class IndexService {
return indexFile;
}
-
public IndexFile getAndCreateLastIndexFile() {
IndexFile indexFile = null;
IndexFile prevIndexFile = null;
@@ -323,15 +309,14 @@ public class IndexService {
this.readWriteLock.readLock().unlock();
}
-
if (indexFile == null) {
try {
String fileName =
- this.storePath + File.separator
- + UtilAll.timeMillisToHumanString(System.currentTimeMillis());
+ this.storePath + File.separator
+ + UtilAll.timeMillisToHumanString(System.currentTimeMillis());
indexFile =
- new IndexFile(fileName, this.hashSlotNum, this.indexNum, lastUpdateEndPhyOffset,
- lastUpdateIndexTimestamp);
+ new IndexFile(fileName, this.hashSlotNum, this.indexNum, lastUpdateEndPhyOffset,
+ lastUpdateIndexTimestamp);
this.readWriteLock.writeLock().lock();
this.indexFileList.add(indexFile);
} catch (Exception e) {
@@ -340,7 +325,6 @@ public class IndexService {
this.readWriteLock.writeLock().unlock();
}
-
if (indexFile != null) {
final IndexFile flushThisFile = prevIndexFile;
Thread flushThread = new Thread(new Runnable() {
@@ -358,7 +342,6 @@ public class IndexService {
return indexFile;
}
-
public void flush(final IndexFile f) {
if (null == f)
return;
@@ -377,12 +360,10 @@ public class IndexService {
}
}
-
public void start() {
}
-
public void shutdown() {
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/index/QueryOffsetResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/index/QueryOffsetResult.java b/store/src/main/java/org/apache/rocketmq/store/index/QueryOffsetResult.java
index e126aee..a864c89 100644
--- a/store/src/main/java/org/apache/rocketmq/store/index/QueryOffsetResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/index/QueryOffsetResult.java
@@ -6,43 +6,38 @@
* (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
+ * 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.
+ * 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.store.index;
import java.util.List;
-
public class QueryOffsetResult {
private final List<Long> phyOffsets;
private final long indexLastUpdateTimestamp;
private final long indexLastUpdatePhyoffset;
-
public QueryOffsetResult(List<Long> phyOffsets, long indexLastUpdateTimestamp,
- long indexLastUpdatePhyoffset) {
+ long indexLastUpdatePhyoffset) {
this.phyOffsets = phyOffsets;
this.indexLastUpdateTimestamp = indexLastUpdateTimestamp;
this.indexLastUpdatePhyoffset = indexLastUpdatePhyoffset;
}
-
public List<Long> getPhyOffsets() {
return phyOffsets;
}
-
public long getIndexLastUpdateTimestamp() {
return indexLastUpdateTimestamp;
}
-
public long getIndexLastUpdatePhyoffset() {
return indexLastUpdatePhyoffset;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/schedule/DelayOffsetSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/schedule/DelayOffsetSerializeWrapper.java b/store/src/main/java/org/apache/rocketmq/store/schedule/DelayOffsetSerializeWrapper.java
index b1520e1..ebe3ffe 100644
--- a/store/src/main/java/org/apache/rocketmq/store/schedule/DelayOffsetSerializeWrapper.java
+++ b/store/src/main/java/org/apache/rocketmq/store/schedule/DelayOffsetSerializeWrapper.java
@@ -6,34 +6,30 @@
* (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
+ * 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.
+ * 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.store.schedule;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.concurrent.ConcurrentHashMap;
-
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
/**
*
*/
public class DelayOffsetSerializeWrapper extends RemotingSerializable {
private ConcurrentHashMap<Integer /* level */, Long/* offset */> offsetTable =
- new ConcurrentHashMap<Integer, Long>(32);
-
+ new ConcurrentHashMap<Integer, Long>(32);
public ConcurrentHashMap<Integer, Long> getOffsetTable() {
return offsetTable;
}
-
public void setOffsetTable(ConcurrentHashMap<Integer, Long> offsetTable) {
this.offsetTable = offsetTable;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java b/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java
index c03c181..3df4806 100644
--- a/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java
@@ -6,16 +6,23 @@
* (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
+ * 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.
+ * 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.store.schedule;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.rocketmq.common.ConfigManager;
import org.apache.rocketmq.common.TopicFilterType;
import org.apache.rocketmq.common.constant.LoggerName;
@@ -24,16 +31,16 @@ import org.apache.rocketmq.common.message.MessageConst;
import org.apache.rocketmq.common.message.MessageDecoder;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.running.RunningStats;
-import org.apache.rocketmq.store.*;
+import org.apache.rocketmq.store.ConsumeQueue;
+import org.apache.rocketmq.store.DefaultMessageStore;
+import org.apache.rocketmq.store.MessageExtBrokerInner;
+import org.apache.rocketmq.store.PutMessageResult;
+import org.apache.rocketmq.store.PutMessageStatus;
+import org.apache.rocketmq.store.SelectMappedBufferResult;
import org.apache.rocketmq.store.config.StorePathConfigHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-
-
/**
*
*/
@@ -45,10 +52,10 @@ public class ScheduleMessageService extends ConfigManager {
private static final long DELAY_FOR_A_PERIOD = 10000L;
private final ConcurrentHashMap<Integer /* level */, Long/* delay timeMillis */> delayLevelTable =
- new ConcurrentHashMap<Integer, Long>(32);
+ new ConcurrentHashMap<Integer, Long>(32);
private final ConcurrentHashMap<Integer /* level */, Long/* offset */> offsetTable =
- new ConcurrentHashMap<Integer, Long>(32);
+ new ConcurrentHashMap<Integer, Long>(32);
private final Timer timer = new Timer("ScheduleMessageTimerThread", true);
@@ -56,7 +63,6 @@ public class ScheduleMessageService extends ConfigManager {
private int maxDelayLevel;
-
public ScheduleMessageService(final DefaultMessageStore defaultMessageStore) {
this.defaultMessageStore = defaultMessageStore;
}
@@ -65,6 +71,10 @@ public class ScheduleMessageService extends ConfigManager {
return queueId + 1;
}
+ public static int delayLevel2QueueId(final int delayLevel) {
+ return delayLevel - 1;
+ }
+
public void buildRunningStats(HashMap<String, String> stats) {
Iterator<Entry<Integer, Long>> it = this.offsetTable.entrySet().iterator();
while (it.hasNext()) {
@@ -78,16 +88,10 @@ public class ScheduleMessageService extends ConfigManager {
}
}
- public static int delayLevel2QueueId(final int delayLevel) {
- return delayLevel - 1;
- }
-
-
private void updateOffset(int delayLevel, long offset) {
this.offsetTable.put(delayLevel, offset);
}
-
public long computeDeliverTimestamp(final int delayLevel, final long storeTimestamp) {
Long time = this.delayLevelTable.get(delayLevel);
if (time != null) {
@@ -97,7 +101,6 @@ public class ScheduleMessageService extends ConfigManager {
return storeTimestamp + 1000;
}
-
public void start() {
for (Map.Entry<Integer, Long> entry : this.delayLevelTable.entrySet()) {
@@ -126,17 +129,14 @@ public class ScheduleMessageService extends ConfigManager {
}, 10000, this.defaultMessageStore.getMessageStoreConfig().getFlushDelayOffsetInterval());
}
-
public void shutdown() {
this.timer.cancel();
}
-
public int getMaxDelayLevel() {
return maxDelayLevel;
}
-
public String encode() {
return this.encode(false);
}
@@ -150,14 +150,14 @@ public class ScheduleMessageService extends ConfigManager {
@Override
public String configFilePath() {
return StorePathConfigHelper.getDelayOffsetStorePath(this.defaultMessageStore.getMessageStoreConfig()
- .getStorePathRootDir());
+ .getStorePathRootDir());
}
@Override
public void decode(String jsonString) {
if (jsonString != null) {
DelayOffsetSerializeWrapper delayOffsetSerializeWrapper =
- DelayOffsetSerializeWrapper.fromJson(jsonString, DelayOffsetSerializeWrapper.class);
+ DelayOffsetSerializeWrapper.fromJson(jsonString, DelayOffsetSerializeWrapper.class);
if (delayOffsetSerializeWrapper != null) {
this.offsetTable.putAll(delayOffsetSerializeWrapper.getOffsetTable());
}
@@ -206,13 +206,11 @@ public class ScheduleMessageService extends ConfigManager {
private final int delayLevel;
private final long offset;
-
public DeliverDelayedMessageTimerTask(int delayLevel, long offset) {
this.delayLevel = delayLevel;
this.offset = offset;
}
-
@Override
public void run() {
try {
@@ -221,11 +219,10 @@ public class ScheduleMessageService extends ConfigManager {
// XXX: warn and notify me
log.error("ScheduleMessageService, executeOnTimeup exception", e);
ScheduleMessageService.this.timer.schedule(new DeliverDelayedMessageTimerTask(
- this.delayLevel, this.offset), DELAY_FOR_A_PERIOD);
+ this.delayLevel, this.offset), DELAY_FOR_A_PERIOD);
}
}
-
/**
*
@@ -243,11 +240,10 @@ public class ScheduleMessageService extends ConfigManager {
return result;
}
-
public void executeOnTimeup() {
ConsumeQueue cq =
- ScheduleMessageService.this.defaultMessageStore.findConsumeQueue(SCHEDULE_TOPIC,
- delayLevel2QueueId(delayLevel));
+ ScheduleMessageService.this.defaultMessageStore.findConsumeQueue(SCHEDULE_TOPIC,
+ delayLevel2QueueId(delayLevel));
long failScheduleOffset = offset;
@@ -262,7 +258,6 @@ public class ScheduleMessageService extends ConfigManager {
int sizePy = bufferCQ.getByteBuffer().getInt();
long tagsCode = bufferCQ.getByteBuffer().getLong();
-
long now = System.currentTimeMillis();
long deliverTimestamp = this.correctDeliverTimestamp(now, tagsCode);
@@ -272,31 +267,29 @@ public class ScheduleMessageService extends ConfigManager {
if (countdown <= 0) {
MessageExt msgExt =
- ScheduleMessageService.this.defaultMessageStore.lookMessageByOffset(
- offsetPy, sizePy);
+ ScheduleMessageService.this.defaultMessageStore.lookMessageByOffset(
+ offsetPy, sizePy);
if (msgExt != null) {
try {
MessageExtBrokerInner msgInner = this.messageTimeup(msgExt);
PutMessageResult putMessageResult =
- ScheduleMessageService.this.defaultMessageStore
- .putMessage(msgInner);
+ ScheduleMessageService.this.defaultMessageStore
+ .putMessage(msgInner);
if (putMessageResult != null
- && putMessageResult.getPutMessageStatus() == PutMessageStatus.PUT_OK) {
+ && putMessageResult.getPutMessageStatus() == PutMessageStatus.PUT_OK) {
continue;
- }
-
- else {
+ } else {
// XXX: warn and notify me
log.error(
- "ScheduleMessageService, a message time up, but reput it failed, topic: {} msgId {}",
- msgExt.getTopic(), msgExt.getMsgId());
+ "ScheduleMessageService, a message time up, but reput it failed, topic: {} msgId {}",
+ msgExt.getTopic(), msgExt.getMsgId());
ScheduleMessageService.this.timer.schedule(
- new DeliverDelayedMessageTimerTask(this.delayLevel,
- nextOffset), DELAY_FOR_A_PERIOD);
+ new DeliverDelayedMessageTimerTask(this.delayLevel,
+ nextOffset), DELAY_FOR_A_PERIOD);
ScheduleMessageService.this.updateOffset(this.delayLevel,
- nextOffset);
+ nextOffset);
return;
}
} catch (Exception e) {
@@ -307,17 +300,15 @@ public class ScheduleMessageService extends ConfigManager {
*/
log.error(
- "ScheduleMessageService, messageTimeup execute error, drop it. msgExt="
- + msgExt + ", nextOffset=" + nextOffset + ",offsetPy="
- + offsetPy + ",sizePy=" + sizePy, e);
+ "ScheduleMessageService, messageTimeup execute error, drop it. msgExt="
+ + msgExt + ", nextOffset=" + nextOffset + ",offsetPy="
+ + offsetPy + ",sizePy=" + sizePy, e);
}
}
- }
-
- else {
+ } else {
ScheduleMessageService.this.timer.schedule(
- new DeliverDelayedMessageTimerTask(this.delayLevel, nextOffset),
- countdown);
+ new DeliverDelayedMessageTimerTask(this.delayLevel, nextOffset),
+ countdown);
ScheduleMessageService.this.updateOffset(this.delayLevel, nextOffset);
return;
}
@@ -325,7 +316,7 @@ public class ScheduleMessageService extends ConfigManager {
nextOffset = offset + (i / ConsumeQueue.CQ_STORE_UNIT_SIZE);
ScheduleMessageService.this.timer.schedule(new DeliverDelayedMessageTimerTask(
- this.delayLevel, nextOffset), DELAY_FOR_A_WHILE);
+ this.delayLevel, nextOffset), DELAY_FOR_A_WHILE);
ScheduleMessageService.this.updateOffset(this.delayLevel, nextOffset);
return;
} finally {
@@ -342,16 +333,15 @@ public class ScheduleMessageService extends ConfigManager {
if (offset < cqMinOffset) {
failScheduleOffset = cqMinOffset;
log.error("schedule CQ offset invalid. offset=" + offset + ", cqMinOffset="
- + cqMinOffset + ", queueId=" + cq.getQueueId());
+ + cqMinOffset + ", queueId=" + cq.getQueueId());
}
}
} // end of if (cq != null)
ScheduleMessageService.this.timer.schedule(new DeliverDelayedMessageTimerTask(this.delayLevel,
- failScheduleOffset), DELAY_FOR_A_WHILE);
+ failScheduleOffset), DELAY_FOR_A_WHILE);
}
-
private MessageExtBrokerInner messageTimeup(MessageExt msgExt) {
MessageExtBrokerInner msgInner = new MessageExtBrokerInner();
msgInner.setBody(msgExt.getBody());
@@ -360,7 +350,7 @@ public class ScheduleMessageService extends ConfigManager {
TopicFilterType topicFilterType = MessageExt.parseTopicFilterType(msgInner.getSysFlag());
long tagsCodeValue =
- MessageExtBrokerInner.tagsString2tagsCode(topicFilterType, msgInner.getTags());
+ MessageExtBrokerInner.tagsString2tagsCode(topicFilterType, msgInner.getTags());
msgInner.setTagsCode(tagsCodeValue);
msgInner.setPropertiesString(MessageDecoder.messageProperties2String(msgExt.getProperties()));
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStats.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStats.java b/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStats.java
index dd4f6df..cd87b0d 100644
--- a/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStats.java
+++ b/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStats.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.store.stats;
@@ -21,7 +21,6 @@ import org.apache.rocketmq.store.DefaultMessageStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
public class BrokerStats {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final DefaultMessageStore defaultMessageStore;
@@ -34,12 +33,10 @@ public class BrokerStats {
private volatile long msgGetTotalTodayMorning;
-
public BrokerStats(DefaultMessageStore defaultMessageStore) {
this.defaultMessageStore = defaultMessageStore;
}
-
/**
*/
@@ -48,60 +45,50 @@ public class BrokerStats {
this.msgGetTotalYesterdayMorning = this.msgGetTotalTodayMorning;
this.msgPutTotalTodayMorning =
- this.defaultMessageStore.getStoreStatsService().getPutMessageTimesTotal();
+ this.defaultMessageStore.getStoreStatsService().getPutMessageTimesTotal();
this.msgGetTotalTodayMorning =
- this.defaultMessageStore.getStoreStatsService().getGetMessageTransferedMsgCount().get();
+ this.defaultMessageStore.getStoreStatsService().getGetMessageTransferedMsgCount().get();
log.info("yesterday put message total: {}", msgPutTotalTodayMorning - msgPutTotalYesterdayMorning);
log.info("yesterday get message total: {}", msgGetTotalTodayMorning - msgGetTotalYesterdayMorning);
}
-
public long getMsgPutTotalYesterdayMorning() {
return msgPutTotalYesterdayMorning;
}
-
public void setMsgPutTotalYesterdayMorning(long msgPutTotalYesterdayMorning) {
this.msgPutTotalYesterdayMorning = msgPutTotalYesterdayMorning;
}
-
public long getMsgPutTotalTodayMorning() {
return msgPutTotalTodayMorning;
}
-
public void setMsgPutTotalTodayMorning(long msgPutTotalTodayMorning) {
this.msgPutTotalTodayMorning = msgPutTotalTodayMorning;
}
-
public long getMsgGetTotalYesterdayMorning() {
return msgGetTotalYesterdayMorning;
}
-
public void setMsgGetTotalYesterdayMorning(long msgGetTotalYesterdayMorning) {
this.msgGetTotalYesterdayMorning = msgGetTotalYesterdayMorning;
}
-
public long getMsgGetTotalTodayMorning() {
return msgGetTotalTodayMorning;
}
-
public void setMsgGetTotalTodayMorning(long msgGetTotalTodayMorning) {
this.msgGetTotalTodayMorning = msgGetTotalTodayMorning;
}
-
public long getMsgPutTotalTodayNow() {
return this.defaultMessageStore.getStoreStatsService().getPutMessageTimesTotal();
}
-
public long getMsgGetTotalTodayNow() {
return this.defaultMessageStore.getStoreStatsService().getGetMessageTransferedMsgCount().get();
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStatsManager.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStatsManager.java b/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStatsManager.java
index b14780b..f128b09 100644
--- a/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStatsManager.java
+++ b/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStatsManager.java
@@ -6,16 +6,19 @@
* (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
+ * 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.
+ * 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.store.stats;
+import java.util.HashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
import org.apache.rocketmq.common.ThreadFactoryImpl;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.common.stats.MomentStatsItemSet;
@@ -24,11 +27,6 @@ import org.apache.rocketmq.common.stats.StatsItemSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.HashMap;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-
-
public class BrokerStatsManager {
public static final String TOPIC_PUT_NUMS = "TOPIC_PUT_NUMS";
@@ -65,9 +63,9 @@ public class BrokerStatsManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.ROCKETMQ_STATS_LOGGER_NAME);
private static final Logger COMMERCIAL_LOG = LoggerFactory.getLogger(LoggerName.COMMERCIAL_LOGGER_NAME);
private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl(
- "BrokerStatsThread"));
+ "BrokerStatsThread"));
private final ScheduledExecutorService commercialExecutor = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl(
- "CommercialStatsThread"));
+ "CommercialStatsThread"));
private final HashMap<String, StatsItemSet> statsTable = new HashMap<String, StatsItemSet>();
private final String clusterName;
private final MomentStatsItemSet momentStatsItemSetFallSize = new MomentStatsItemSet(GROUP_GET_FALL_SIZE, scheduledExecutorService, log);
@@ -89,7 +87,6 @@ public class BrokerStatsManager {
this.statsTable.put(BROKER_GET_FROM_DISK_NUMS, new StatsItemSet(BROKER_GET_FROM_DISK_NUMS, this.scheduledExecutorService, log));
this.statsTable.put(BROKER_GET_FROM_DISK_SIZE, new StatsItemSet(BROKER_GET_FROM_DISK_SIZE, this.scheduledExecutorService, log));
-
this.statsTable.put(COMMERCIAL_SEND_TIMES, new StatsItemSet(COMMERCIAL_SEND_TIMES, this.commercialExecutor, COMMERCIAL_LOG));
this.statsTable.put(COMMERCIAL_RCV_TIMES, new StatsItemSet(COMMERCIAL_RCV_TIMES, this.commercialExecutor, COMMERCIAL_LOG));
this.statsTable.put(COMMERCIAL_SEND_SIZE, new StatsItemSet(COMMERCIAL_SEND_SIZE, this.commercialExecutor, COMMERCIAL_LOG));
@@ -154,42 +151,36 @@ public class BrokerStatsManager {
this.statsTable.get(GROUP_GET_LATENCY).addValue(statsKey, incValue, 1);
}
-
public void incBrokerPutNums() {
this.statsTable.get(BROKER_PUT_NUMS).getAndCreateStatsItem(this.clusterName).getValue().incrementAndGet();
}
-
public void incBrokerGetNums(final int incValue) {
this.statsTable.get(BROKER_GET_NUMS).getAndCreateStatsItem(this.clusterName).getValue().addAndGet(incValue);
}
-
public void incSendBackNums(final String group, final String topic) {
final String statsKey = buildStatsKey(topic, group);
this.statsTable.get(SNDBCK_PUT_NUMS).addValue(statsKey, 1, 1);
}
-
public double tpsGroupGetNums(final String group, final String topic) {
final String statsKey = buildStatsKey(topic, group);
return this.statsTable.get(GROUP_GET_NUMS).getStatsDataInMinute(statsKey).getTps();
}
-
public void recordDiskFallBehindTime(final String group, final String topic, final int queueId, final long fallBehind) {
final String statsKey = String.format("%d@%s@%s", queueId, topic, group);
this.momentStatsItemSetFallTime.getAndCreateStatsItem(statsKey).getValue().set(fallBehind);
}
-
public void recordDiskFallBehindSize(final String group, final String topic, final int queueId, final long fallBehind) {
final String statsKey = String.format("%d@%s@%s", queueId, topic, group);
this.momentStatsItemSetFallSize.getAndCreateStatsItem(statsKey).getValue().set(fallBehind);
}
public void incCommercialValue(final String key, final String owner, final String group,
- final String topic, final String type, final int incValue) {
+ final String topic, final String type, final int incValue) {
final String statsKey = buildCommercialStatsKey(owner, topic, group, type);
this.statsTable.get(key).addValue(statsKey, incValue, 1);
}
@@ -206,7 +197,6 @@ public class BrokerStatsManager {
return strBuilder.toString();
}
-
public enum StatsType {
SEND_SUCCESS,
SEND_FAILURE,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/util/LibC.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/util/LibC.java b/store/src/main/java/org/apache/rocketmq/store/util/LibC.java
index ee9e68b..dc5d6a9 100644
--- a/store/src/main/java/org/apache/rocketmq/store/util/LibC.java
+++ b/store/src/main/java/org/apache/rocketmq/store/util/LibC.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.store.util;
@@ -22,9 +22,8 @@ import com.sun.jna.NativeLong;
import com.sun.jna.Platform;
import com.sun.jna.Pointer;
-
public interface LibC extends Library {
- LibC INSTANCE = (LibC) Native.loadLibrary(Platform.isWindows() ? "msvcrt" : "c", LibC.class);
+ LibC INSTANCE = (LibC)Native.loadLibrary(Platform.isWindows() ? "msvcrt" : "c", LibC.class);
int MADV_WILLNEED = 3;
int MADV_DONTNEED = 4;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java b/store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java
index bfcb33e..5c6bde2 100644
--- a/store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java
@@ -6,17 +6,21 @@
* (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
+ * 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.
+ * 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.store;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.util.concurrent.atomic.AtomicInteger;
import org.apache.rocketmq.common.BrokerConfig;
import org.apache.rocketmq.store.config.FlushDiskType;
import org.apache.rocketmq.store.config.MessageStoreConfig;
@@ -26,17 +30,11 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.util.concurrent.atomic.AtomicInteger;
-
import static org.junit.Assert.assertTrue;
-
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;
@@ -82,7 +80,7 @@ public class DefaultMessageStoreTest {
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) {
@@ -133,7 +131,7 @@ public class DefaultMessageStoreTest {
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) {
@@ -142,7 +140,7 @@ public class DefaultMessageStoreTest {
assertTrue(result != null);
result.release();
logger.debug("read " + i + " OK");
-
+
}
} finally {
master.shutdown();
@@ -150,9 +148,9 @@ public class DefaultMessageStoreTest {
}
logger.debug("================================================================");
}
-
+
private class MyMessageArrivingListener implements MessageArrivingListener {
-
+
@Override
public void arriving(String topic, int queueId, long logicOffset, long tagsCode) {
// Do nothing here
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/test/java/org/apache/rocketmq/store/MappedFileQueueTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/MappedFileQueueTest.java b/store/src/test/java/org/apache/rocketmq/store/MappedFileQueueTest.java
index ac1e016..018cf99 100644
--- a/store/src/test/java/org/apache/rocketmq/store/MappedFileQueueTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/MappedFileQueueTest.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: MappedFileQueueTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
@@ -20,12 +22,17 @@
*/
package org.apache.rocketmq.store;
-import org.junit.*;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.junit.Assert.*;
-
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
public class MappedFileQueueTest {
private static final Logger logger = LoggerFactory.getLogger(MappedFileQueueTest.class);
@@ -55,7 +62,7 @@ public class MappedFileQueueTest {
logger.debug("================================================================");
MappedFileQueue mappedFileQueue =
- new MappedFileQueue("target/unit_test_store/a/", 1024, null);
+ new MappedFileQueue("target/unit_test_store/a/", 1024, null);
for (int i = 0; i < 1024; i++) {
MappedFile mappedFile = mappedFileQueue.getLastMappedFile(0);
@@ -73,7 +80,6 @@ public class MappedFileQueueTest {
logger.debug("MappedFileQueue.getLastMappedFile() OK");
}
-
@Test
public void test_findMapedFileByOffset() {
// four-byte string.
@@ -81,7 +87,7 @@ public class MappedFileQueueTest {
logger.debug("================================================================");
MappedFileQueue mappedFileQueue =
- new MappedFileQueue("target/unit_test_store/b/", 1024, null);
+ new MappedFileQueue("target/unit_test_store/b/", 1024, null);
for (int i = 0; i < 1024; i++) {
MappedFile mappedFile = mappedFileQueue.getLastMappedFile(0);
@@ -96,23 +102,23 @@ public class MappedFileQueueTest {
MappedFile mappedFile = mappedFileQueue.findMappedFileByOffset(0);
assertTrue(mappedFile != null);
assertEquals(mappedFile.getFileFromOffset(), 0);
-
+
mappedFile = mappedFileQueue.findMappedFileByOffset(100);
assertTrue(mappedFile != null);
assertEquals(mappedFile.getFileFromOffset(), 0);
-
+
mappedFile = mappedFileQueue.findMappedFileByOffset(1024);
assertTrue(mappedFile != null);
assertEquals(mappedFile.getFileFromOffset(), 1024);
-
+
mappedFile = mappedFileQueue.findMappedFileByOffset(1024 + 100);
assertTrue(mappedFile != null);
assertEquals(mappedFile.getFileFromOffset(), 1024);
-
+
mappedFile = mappedFileQueue.findMappedFileByOffset(1024 * 2);
assertTrue(mappedFile != null);
assertEquals(mappedFile.getFileFromOffset(), 1024 * 2);
-
+
mappedFile = mappedFileQueue.findMappedFileByOffset(1024 * 2 + 100);
assertTrue(mappedFile != null);
assertEquals(mappedFile.getFileFromOffset(), 1024 * 2);
@@ -135,7 +141,7 @@ public class MappedFileQueueTest {
logger.debug("================================================================");
MappedFileQueue mappedFileQueue =
- new MappedFileQueue("target/unit_test_store/c/", 1024, null);
+ new MappedFileQueue("target/unit_test_store/c/", 1024, null);
for (int i = 0; i < 1024; i++) {
MappedFile mappedFile = mappedFileQueue.getLastMappedFile(0);
@@ -148,27 +154,27 @@ public class MappedFileQueueTest {
boolean result = mappedFileQueue.flush(0);
assertFalse(result);
assertEquals(1024 * 1, mappedFileQueue.getFlushedWhere());
-
+
result = mappedFileQueue.flush(0);
assertFalse(result);
assertEquals(1024 * 2, mappedFileQueue.getFlushedWhere());
-
+
result = mappedFileQueue.flush(0);
assertFalse(result);
assertEquals(1024 * 3, mappedFileQueue.getFlushedWhere());
-
+
result = mappedFileQueue.flush(0);
assertFalse(result);
assertEquals(1024 * 4, mappedFileQueue.getFlushedWhere());
-
+
result = mappedFileQueue.flush(0);
assertFalse(result);
assertEquals(1024 * 5, mappedFileQueue.getFlushedWhere());
-
+
result = mappedFileQueue.flush(0);
assertFalse(result);
assertEquals(1024 * 6, mappedFileQueue.getFlushedWhere());
-
+
mappedFileQueue.shutdown(1000);
mappedFileQueue.destroy();
logger.debug("MappedFileQueue.flush() OK");
@@ -180,7 +186,7 @@ public class MappedFileQueueTest {
logger.debug("================================================================");
MappedFileQueue mappedFileQueue =
- new MappedFileQueue("target/unit_test_store/d/", 1024, null);
+ new MappedFileQueue("target/unit_test_store/d/", 1024, null);
for (int i = 0; i < 1024; i++) {
MappedFile mappedFile = mappedFileQueue.getLastMappedFile(0);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/test/java/org/apache/rocketmq/store/MappedFileTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/MappedFileTest.java b/store/src/test/java/org/apache/rocketmq/store/MappedFileTest.java
index bfa09e9..a10f4eb 100644
--- a/store/src/test/java/org/apache/rocketmq/store/MappedFileTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/MappedFileTest.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: MappedFileTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
@@ -20,6 +22,7 @@
*/
package org.apache.rocketmq.store;
+import java.io.IOException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
@@ -27,16 +30,12 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-
import static org.junit.Assert.assertTrue;
-
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
@@ -54,15 +53,15 @@ public class MappedFileTest {
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();
@@ -76,11 +75,11 @@ public class MappedFileTest {
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);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/test/java/org/apache/rocketmq/store/StoreCheckpointTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/StoreCheckpointTest.java b/store/src/test/java/org/apache/rocketmq/store/StoreCheckpointTest.java
index f0245a9..2fe4d46 100644
--- a/store/src/test/java/org/apache/rocketmq/store/StoreCheckpointTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/StoreCheckpointTest.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: StoreCheckpointTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
@@ -20,15 +22,13 @@
*/
package org.apache.rocketmq.store;
+import java.io.IOException;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import java.io.IOException;
-
import static org.junit.Assert.assertTrue;
-
public class StoreCheckpointTest {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
@@ -47,7 +47,7 @@ public class StoreCheckpointTest {
storeCheckpoint.setPhysicMsgTimestamp(physicMsgTimestamp);
storeCheckpoint.setLogicsMsgTimestamp(logicsMsgTimestamp);
storeCheckpoint.flush();
-
+
long diff = physicMsgTimestamp - storeCheckpoint.getMinTimestamp();
assertTrue(diff == 3000);
storeCheckpoint.shutdown();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/test/java/org/apache/rocketmq/store/index/IndexFileTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/index/IndexFileTest.java b/store/src/test/java/org/apache/rocketmq/store/index/IndexFileTest.java
index 95cf0c8..cdecb20 100644
--- a/store/src/test/java/org/apache/rocketmq/store/index/IndexFileTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/index/IndexFileTest.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: IndexFileTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
@@ -20,16 +22,14 @@
*/
package org.apache.rocketmq.store.index;
-import org.junit.Test;
-
import java.util.ArrayList;
import java.util.List;
+import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-
public class IndexFileTest {
private static final int HASH_SLOT_NUM = 100;
private static final int INDEX_NUM = 400;
@@ -45,15 +45,14 @@ public class IndexFileTest {
// put over index file capacity.
boolean putResult = indexFile.putKey(Long.toString(400), 400, System.currentTimeMillis());
assertFalse(putResult);
-
+
indexFile.destroy(0);
}
-
@Test
public void test_put_get_index() throws Exception {
IndexFile indexFile = new IndexFile("200", 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);
@@ -62,7 +61,7 @@ public class IndexFileTest {
// put over index file capacity.
boolean putResult = indexFile.putKey(Long.toString(400), 400, System.currentTimeMillis());
assertFalse(putResult);
-
+
final List<Long> phyOffsets = new ArrayList<Long>();
indexFile.selectPhyOffset(phyOffsets, "60", 10, 0, Long.MAX_VALUE, true);
assertFalse(phyOffsets.isEmpty());
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/test/java/org/apache/rocketmq/store/schedule/ScheduleMessageTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/schedule/ScheduleMessageTest.java b/store/src/test/java/org/apache/rocketmq/store/schedule/ScheduleMessageTest.java
index 7ac8233..c5d9756 100644
--- a/store/src/test/java/org/apache/rocketmq/store/schedule/ScheduleMessageTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/schedule/ScheduleMessageTest.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: ScheduleMessageTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
@@ -20,19 +22,21 @@
*/
package org.apache.rocketmq.store.schedule;
-import org.apache.rocketmq.store.*;
-import org.apache.rocketmq.store.*;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.rocketmq.store.DefaultMessageStore;
+import org.apache.rocketmq.store.GetMessageResult;
+import org.apache.rocketmq.store.MessageExtBrokerInner;
+import org.apache.rocketmq.store.MessageStore;
+import org.apache.rocketmq.store.PutMessageResult;
import org.apache.rocketmq.store.config.MessageStoreConfig;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.util.concurrent.atomic.AtomicInteger;
-
import static org.junit.Assert.assertTrue;
@Ignore
@@ -65,7 +69,6 @@ public class ScheduleMessageTest {
long totalMsgs = 10000;
QUEUE_TOTAL = 32;
-
MessageBody = StoreMessage.getBytes();
MessageStoreConfig messageStoreConfig = new MessageStoreConfig();
@@ -79,7 +82,6 @@ public class ScheduleMessageTest {
boolean load = master.load();
assertTrue(load);
-
master.start();
for (int i = 0; i < totalMsgs; i++) {
MessageExtBrokerInner msg = buildMessage();
@@ -92,7 +94,6 @@ public class ScheduleMessageTest {
System.out.println("write message over, wait time up");
Thread.sleep(1000 * 20);
-
for (long i = 0; i < totalMsgs; i++) {
try {
GetMessageResult result = master.getMessage("GROUP_A", "TOPIC_A", 0, i, 1024 * 1024, null);
@@ -110,10 +111,8 @@ public class ScheduleMessageTest {
Thread.sleep(1000 * 15);
-
master.shutdown();
-
master.destroy();
System.out.println("================================================================");
}
[30/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/producer/DefaultMQProducer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/producer/DefaultMQProducer.java b/client/src/main/java/com/alibaba/rocketmq/client/producer/DefaultMQProducer.java
deleted file mode 100644
index 6f861d3..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/producer/DefaultMQProducer.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/**
- * 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.client.producer;
-
-import com.alibaba.rocketmq.client.ClientConfig;
-import com.alibaba.rocketmq.client.QueryResult;
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.impl.producer.DefaultMQProducerImpl;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.message.*;
-import com.alibaba.rocketmq.remoting.RPCHook;
-import com.alibaba.rocketmq.remoting.exception.RemotingException;
-
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public class DefaultMQProducer extends ClientConfig implements MQProducer {
- protected final transient DefaultMQProducerImpl defaultMQProducerImpl;
- private String producerGroup;
- /**
- * Just for testing or demo program
- */
- private String createTopicKey = MixAll.DEFAULT_TOPIC;
- private volatile int defaultTopicQueueNums = 4;
- private int sendMsgTimeout = 3000;
- private int compressMsgBodyOverHowmuch = 1024 * 4;
- private int retryTimesWhenSendFailed = 2;
- private int retryTimesWhenSendAsyncFailed = 2;
-
- private boolean retryAnotherBrokerWhenNotStoreOK = false;
- private int maxMessageSize = 1024 * 1024 * 4; // 4M
- public DefaultMQProducer() {
- this(MixAll.DEFAULT_PRODUCER_GROUP, null);
- }
-
-
- public DefaultMQProducer(final String producerGroup, RPCHook rpcHook) {
- this.producerGroup = producerGroup;
- defaultMQProducerImpl = new DefaultMQProducerImpl(this, rpcHook);
- }
-
-
- public DefaultMQProducer(final String producerGroup) {
- this(producerGroup, null);
- }
-
-
- public DefaultMQProducer(RPCHook rpcHook) {
- this(MixAll.DEFAULT_PRODUCER_GROUP, rpcHook);
- }
-
-
- @Override
- public void start() throws MQClientException {
- this.defaultMQProducerImpl.start();
- }
-
- @Override
- public void shutdown() {
- this.defaultMQProducerImpl.shutdown();
- }
-
-
- @Override
- public List<MessageQueue> fetchPublishMessageQueues(String topic) throws MQClientException {
- return this.defaultMQProducerImpl.fetchPublishMessageQueues(topic);
- }
-
-
- @Override
- public SendResult send(Message msg) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- return this.defaultMQProducerImpl.send(msg);
- }
-
-
- @Override
- public SendResult send(Message msg, long timeout) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- return this.defaultMQProducerImpl.send(msg, timeout);
- }
-
-
- @Override
- public void send(Message msg, SendCallback sendCallback) throws MQClientException, RemotingException, InterruptedException {
- this.defaultMQProducerImpl.send(msg, sendCallback);
- }
-
-
- @Override
- public void send(Message msg, SendCallback sendCallback, long timeout)
- throws MQClientException, RemotingException, InterruptedException {
- this.defaultMQProducerImpl.send(msg, sendCallback, timeout);
- }
-
-
- @Override
- public void sendOneway(Message msg) throws MQClientException, RemotingException, InterruptedException {
- this.defaultMQProducerImpl.sendOneway(msg);
- }
-
-
- @Override
- public SendResult send(Message msg, MessageQueue mq)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- return this.defaultMQProducerImpl.send(msg, mq);
- }
-
-
- @Override
- public SendResult send(Message msg, MessageQueue mq, long timeout)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- return this.defaultMQProducerImpl.send(msg, mq, timeout);
- }
-
-
- @Override
- public void send(Message msg, MessageQueue mq, SendCallback sendCallback)
- throws MQClientException, RemotingException, InterruptedException {
- this.defaultMQProducerImpl.send(msg, mq, sendCallback);
- }
-
-
- @Override
- public void send(Message msg, MessageQueue mq, SendCallback sendCallback, long timeout)
- throws MQClientException, RemotingException, InterruptedException {
- this.defaultMQProducerImpl.send(msg, mq, sendCallback, timeout);
- }
-
-
- @Override
- public void sendOneway(Message msg, MessageQueue mq) throws MQClientException, RemotingException, InterruptedException {
- this.defaultMQProducerImpl.sendOneway(msg, mq);
- }
-
-
- @Override
- public SendResult send(Message msg, MessageQueueSelector selector, Object arg)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- return this.defaultMQProducerImpl.send(msg, selector, arg);
- }
-
-
- @Override
- public SendResult send(Message msg, MessageQueueSelector selector, Object arg, long timeout)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- return this.defaultMQProducerImpl.send(msg, selector, arg, timeout);
- }
-
-
- @Override
- public void send(Message msg, MessageQueueSelector selector, Object arg, SendCallback sendCallback)
- throws MQClientException, RemotingException, InterruptedException {
- this.defaultMQProducerImpl.send(msg, selector, arg, sendCallback);
- }
-
-
- @Override
- public void send(Message msg, MessageQueueSelector selector, Object arg, SendCallback sendCallback, long timeout)
- throws MQClientException, RemotingException, InterruptedException {
- this.defaultMQProducerImpl.send(msg, selector, arg, sendCallback, timeout);
- }
-
-
- @Override
- public void sendOneway(Message msg, MessageQueueSelector selector, Object arg)
- throws MQClientException, RemotingException, InterruptedException {
- this.defaultMQProducerImpl.sendOneway(msg, selector, arg);
- }
-
-
- @Override
- public TransactionSendResult sendMessageInTransaction(Message msg, LocalTransactionExecuter tranExecuter, final Object arg)
- throws MQClientException {
- throw new RuntimeException("sendMessageInTransaction not implement, please use TransactionMQProducer class");
- }
-
-
- @Override
- public void createTopic(String key, String newTopic, int queueNum) throws MQClientException {
- createTopic(key, newTopic, queueNum, 0);
- }
-
-
- @Override
- public void createTopic(String key, String newTopic, int queueNum, int topicSysFlag) throws MQClientException {
- this.defaultMQProducerImpl.createTopic(key, newTopic, queueNum, topicSysFlag);
- }
-
-
- @Override
- public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
- return this.defaultMQProducerImpl.searchOffset(mq, timestamp);
- }
-
-
- @Override
- public long maxOffset(MessageQueue mq) throws MQClientException {
- return this.defaultMQProducerImpl.maxOffset(mq);
- }
-
-
- @Override
- public long minOffset(MessageQueue mq) throws MQClientException {
- return this.defaultMQProducerImpl.minOffset(mq);
- }
-
-
- @Override
- public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
- return this.defaultMQProducerImpl.earliestMsgStoreTime(mq);
- }
-
-
- @Override
- public MessageExt viewMessage(String offsetMsgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- return this.defaultMQProducerImpl.viewMessage(offsetMsgId);
- }
-
-
- @Override
- public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
- throws MQClientException, InterruptedException {
- return this.defaultMQProducerImpl.queryMessage(topic, key, maxNum, begin, end);
- }
-
-
- @Override
- public MessageExt viewMessage(String topic, String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- try {
- MessageId oldMsgId = MessageDecoder.decodeMessageId(msgId);
- return this.viewMessage(msgId);
- } catch (Exception e) {
- }
- return this.defaultMQProducerImpl.queryMessageByUniqKey(topic, msgId);
- }
-
- public String getProducerGroup() {
- return producerGroup;
- }
-
-
- public void setProducerGroup(String producerGroup) {
- this.producerGroup = producerGroup;
- }
-
-
- public String getCreateTopicKey() {
- return createTopicKey;
- }
-
-
- public void setCreateTopicKey(String createTopicKey) {
- this.createTopicKey = createTopicKey;
- }
-
-
- public int getSendMsgTimeout() {
- return sendMsgTimeout;
- }
-
-
- public void setSendMsgTimeout(int sendMsgTimeout) {
- this.sendMsgTimeout = sendMsgTimeout;
- }
-
-
- public int getCompressMsgBodyOverHowmuch() {
- return compressMsgBodyOverHowmuch;
- }
-
-
- public void setCompressMsgBodyOverHowmuch(int compressMsgBodyOverHowmuch) {
- this.compressMsgBodyOverHowmuch = compressMsgBodyOverHowmuch;
- }
-
-
- public DefaultMQProducerImpl getDefaultMQProducerImpl() {
- return defaultMQProducerImpl;
- }
-
-
- public boolean isRetryAnotherBrokerWhenNotStoreOK() {
- return retryAnotherBrokerWhenNotStoreOK;
- }
-
-
- public void setRetryAnotherBrokerWhenNotStoreOK(boolean retryAnotherBrokerWhenNotStoreOK) {
- this.retryAnotherBrokerWhenNotStoreOK = retryAnotherBrokerWhenNotStoreOK;
- }
-
-
- public int getMaxMessageSize() {
- return maxMessageSize;
- }
-
-
- public void setMaxMessageSize(int maxMessageSize) {
- this.maxMessageSize = maxMessageSize;
- }
-
-
- public int getDefaultTopicQueueNums() {
- return defaultTopicQueueNums;
- }
-
-
- public void setDefaultTopicQueueNums(int defaultTopicQueueNums) {
- this.defaultTopicQueueNums = defaultTopicQueueNums;
- }
-
-
- public int getRetryTimesWhenSendFailed() {
- return retryTimesWhenSendFailed;
- }
-
-
- public void setRetryTimesWhenSendFailed(int retryTimesWhenSendFailed) {
- this.retryTimesWhenSendFailed = retryTimesWhenSendFailed;
- }
-
-
- public boolean isSendMessageWithVIPChannel() {
- return isVipChannelEnabled();
- }
-
-
- public void setSendMessageWithVIPChannel(final boolean sendMessageWithVIPChannel) {
- this.setVipChannelEnabled(sendMessageWithVIPChannel);
- }
-
-
- public long[] getNotAvailableDuration() {
- return this.defaultMQProducerImpl.getNotAvailableDuration();
- }
-
- public void setNotAvailableDuration(final long[] notAvailableDuration) {
- this.defaultMQProducerImpl.setNotAvailableDuration(notAvailableDuration);
- }
-
- public long[] getLatencyMax() {
- return this.defaultMQProducerImpl.getLatencyMax();
- }
-
- public void setLatencyMax(final long[] latencyMax) {
- this.defaultMQProducerImpl.setLatencyMax(latencyMax);
- }
-
- public boolean isSendLatencyFaultEnable() {
- return this.defaultMQProducerImpl.isSendLatencyFaultEnable();
- }
-
- public void setSendLatencyFaultEnable(final boolean sendLatencyFaultEnable) {
- this.defaultMQProducerImpl.setSendLatencyFaultEnable(sendLatencyFaultEnable);
- }
-
- public int getRetryTimesWhenSendAsyncFailed() {
- return retryTimesWhenSendAsyncFailed;
- }
-
- public void setRetryTimesWhenSendAsyncFailed(final int retryTimesWhenSendAsyncFailed) {
- this.retryTimesWhenSendAsyncFailed = retryTimesWhenSendAsyncFailed;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/producer/LocalTransactionExecuter.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/producer/LocalTransactionExecuter.java b/client/src/main/java/com/alibaba/rocketmq/client/producer/LocalTransactionExecuter.java
deleted file mode 100644
index af3723a..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/producer/LocalTransactionExecuter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * 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.client.producer;
-
-import com.alibaba.rocketmq.common.message.Message;
-
-
-/**
- * @author shijia.wxr
- */
-public interface LocalTransactionExecuter {
- public LocalTransactionState executeLocalTransactionBranch(final Message msg, final Object arg);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/producer/LocalTransactionState.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/producer/LocalTransactionState.java b/client/src/main/java/com/alibaba/rocketmq/client/producer/LocalTransactionState.java
deleted file mode 100644
index ee2a93a..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/producer/LocalTransactionState.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * 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.client.producer;
-
-/**
- * @author shijia.wxr
- */
-public enum LocalTransactionState {
- COMMIT_MESSAGE,
- ROLLBACK_MESSAGE,
- UNKNOW,
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/producer/MQProducer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/producer/MQProducer.java b/client/src/main/java/com/alibaba/rocketmq/client/producer/MQProducer.java
deleted file mode 100644
index e21bc00..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/producer/MQProducer.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * 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.client.producer;
-
-import com.alibaba.rocketmq.client.MQAdmin;
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.remoting.exception.RemotingException;
-
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public interface MQProducer extends MQAdmin {
- void start() throws MQClientException;
-
- void shutdown();
-
-
- List<MessageQueue> fetchPublishMessageQueues(final String topic) throws MQClientException;
-
-
- SendResult send(final Message msg) throws MQClientException, RemotingException, MQBrokerException,
- InterruptedException;
-
-
- SendResult send(final Message msg, final long timeout) throws MQClientException,
- RemotingException, MQBrokerException, InterruptedException;
-
-
- void send(final Message msg, final SendCallback sendCallback) throws MQClientException,
- RemotingException, InterruptedException;
-
-
- void send(final Message msg, final SendCallback sendCallback, final long timeout)
- throws MQClientException, RemotingException, InterruptedException;
-
-
- void sendOneway(final Message msg) throws MQClientException, RemotingException,
- InterruptedException;
-
-
- SendResult send(final Message msg, final MessageQueue mq) throws MQClientException,
- RemotingException, MQBrokerException, InterruptedException;
-
-
- SendResult send(final Message msg, final MessageQueue mq, final long timeout)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException;
-
-
- void send(final Message msg, final MessageQueue mq, final SendCallback sendCallback)
- throws MQClientException, RemotingException, InterruptedException;
-
-
- void send(final Message msg, final MessageQueue mq, final SendCallback sendCallback, long timeout)
- throws MQClientException, RemotingException, InterruptedException;
-
-
- void sendOneway(final Message msg, final MessageQueue mq) throws MQClientException,
- RemotingException, InterruptedException;
-
-
- SendResult send(final Message msg, final MessageQueueSelector selector, final Object arg)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException;
-
-
- SendResult send(final Message msg, final MessageQueueSelector selector, final Object arg,
- final long timeout) throws MQClientException, RemotingException, MQBrokerException,
- InterruptedException;
-
-
- void send(final Message msg, final MessageQueueSelector selector, final Object arg,
- final SendCallback sendCallback) throws MQClientException, RemotingException,
- InterruptedException;
-
-
- void send(final Message msg, final MessageQueueSelector selector, final Object arg,
- final SendCallback sendCallback, final long timeout) throws MQClientException, RemotingException,
- InterruptedException;
-
-
- void sendOneway(final Message msg, final MessageQueueSelector selector, final Object arg)
- throws MQClientException, RemotingException, InterruptedException;
-
-
- TransactionSendResult sendMessageInTransaction(final Message msg,
- final LocalTransactionExecuter tranExecuter, final Object arg) throws MQClientException;
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/producer/MessageQueueSelector.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/producer/MessageQueueSelector.java b/client/src/main/java/com/alibaba/rocketmq/client/producer/MessageQueueSelector.java
deleted file mode 100644
index 924c145..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/producer/MessageQueueSelector.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * 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.client.producer;
-
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public interface MessageQueueSelector {
- MessageQueue select(final List<MessageQueue> mqs, final Message msg, final Object arg);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/producer/SendCallback.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/producer/SendCallback.java b/client/src/main/java/com/alibaba/rocketmq/client/producer/SendCallback.java
deleted file mode 100644
index 35d1a72..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/producer/SendCallback.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * 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.client.producer;
-
-/**
- * @author shijia.wxr
- */
-public interface SendCallback {
- public void onSuccess(final SendResult sendResult);
-
-
- public void onException(final Throwable e);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/producer/SendResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/producer/SendResult.java b/client/src/main/java/com/alibaba/rocketmq/client/producer/SendResult.java
deleted file mode 100644
index 183accf..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/producer/SendResult.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * 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.client.producer;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-
-/**
- * @author shijia.wxr
- */
-public class SendResult {
- private SendStatus sendStatus;
- private String msgId;
- private MessageQueue messageQueue;
- private long queueOffset;
- private String transactionId;
- private String offsetMsgId;
- private String regionId;
- private boolean traceOn = true;
-
- public SendResult() {
- }
-
- public SendResult(SendStatus sendStatus, String msgId, String offsetMsgId, MessageQueue messageQueue, long queueOffset) {
- this.sendStatus = sendStatus;
- this.msgId = msgId;
- this.offsetMsgId = offsetMsgId;
- this.messageQueue = messageQueue;
- this.queueOffset = queueOffset;
- }
-
- public SendResult(final SendStatus sendStatus, final String msgId, final MessageQueue messageQueue, final long queueOffset, final String transactionId, final String offsetMsgId, final String regionId) {
- this.sendStatus = sendStatus;
- this.msgId = msgId;
- this.messageQueue = messageQueue;
- this.queueOffset = queueOffset;
- this.transactionId = transactionId;
- this.offsetMsgId = offsetMsgId;
- this.regionId = regionId;
- }
-
- public boolean isTraceOn() {
- return traceOn;
- }
-
- public void setTraceOn(final boolean traceOn) {
- this.traceOn = traceOn;
- }
-
- public String getRegionId() {
- return regionId;
- }
-
- public void setRegionId(final String regionId) {
- this.regionId = regionId;
- }
-
- public static String encoderSendResultToJson(final Object obj) {
- return JSON.toJSONString(obj);
- }
-
- public static SendResult decoderSendResultFromJson(String json) {
- return JSON.parseObject(json, SendResult.class);
- }
-
- public String getMsgId() {
- return msgId;
- }
-
-
- public void setMsgId(String msgId) {
- this.msgId = msgId;
- }
-
-
- public SendStatus getSendStatus() {
- return sendStatus;
- }
-
-
- public void setSendStatus(SendStatus sendStatus) {
- this.sendStatus = sendStatus;
- }
-
-
- public MessageQueue getMessageQueue() {
- return messageQueue;
- }
-
-
- public void setMessageQueue(MessageQueue messageQueue) {
- this.messageQueue = messageQueue;
- }
-
-
- public long getQueueOffset() {
- return queueOffset;
- }
-
-
- public void setQueueOffset(long queueOffset) {
- this.queueOffset = queueOffset;
- }
-
-
- public String getTransactionId() {
- return transactionId;
- }
-
-
- public void setTransactionId(String transactionId) {
- this.transactionId = transactionId;
- }
-
- public String getOffsetMsgId() {
- return offsetMsgId;
- }
-
- public void setOffsetMsgId(String offsetMsgId) {
- this.offsetMsgId = offsetMsgId;
- }
-
- @Override
- public String toString() {
- return "SendResult [sendStatus=" + sendStatus + ", msgId=" + msgId + ", offsetMsgId=" + offsetMsgId + ", messageQueue=" + messageQueue
- + ", queueOffset=" + queueOffset + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/producer/SendStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/producer/SendStatus.java b/client/src/main/java/com/alibaba/rocketmq/client/producer/SendStatus.java
deleted file mode 100644
index 3bc572f..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/producer/SendStatus.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * 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.client.producer;
-
-/**
- * @author shijia.wxr
- */
-public enum SendStatus {
- SEND_OK,
- FLUSH_DISK_TIMEOUT,
- FLUSH_SLAVE_TIMEOUT,
- SLAVE_NOT_AVAILABLE,
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/producer/TransactionCheckListener.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/producer/TransactionCheckListener.java b/client/src/main/java/com/alibaba/rocketmq/client/producer/TransactionCheckListener.java
deleted file mode 100644
index 8440537..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/producer/TransactionCheckListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * 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.client.producer;
-
-import com.alibaba.rocketmq.common.message.MessageExt;
-
-
-/**
- * @author shijia.wxr
- */
-public interface TransactionCheckListener {
- LocalTransactionState checkLocalTransactionState(final MessageExt msg);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/producer/TransactionMQProducer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/producer/TransactionMQProducer.java b/client/src/main/java/com/alibaba/rocketmq/client/producer/TransactionMQProducer.java
deleted file mode 100644
index 08dd4ab..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/producer/TransactionMQProducer.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * 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.client.producer;
-
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.remoting.RPCHook;
-
-
-/**
- * @author shijia.wxr
- */
-public class TransactionMQProducer extends DefaultMQProducer {
- private TransactionCheckListener transactionCheckListener;
- private int checkThreadPoolMinSize = 1;
- private int checkThreadPoolMaxSize = 1;
- private int checkRequestHoldMax = 2000;
-
-
- public TransactionMQProducer() {
- }
-
-
- public TransactionMQProducer(final String producerGroup) {
- super(producerGroup);
- }
-
- public TransactionMQProducer(final String producerGroup, RPCHook rpcHook) {
- super(producerGroup, rpcHook);
- }
-
- @Override
- public void start() throws MQClientException {
- this.defaultMQProducerImpl.initTransactionEnv();
- super.start();
- }
-
-
- @Override
- public void shutdown() {
- super.shutdown();
- this.defaultMQProducerImpl.destroyTransactionEnv();
- }
-
-
- @Override
- public TransactionSendResult sendMessageInTransaction(final Message msg,
- final LocalTransactionExecuter tranExecuter, final Object arg) throws MQClientException {
- if (null == this.transactionCheckListener) {
- throw new MQClientException("localTransactionBranchCheckListener is null", null);
- }
-
- return this.defaultMQProducerImpl.sendMessageInTransaction(msg, tranExecuter, arg);
- }
-
-
- public TransactionCheckListener getTransactionCheckListener() {
- return transactionCheckListener;
- }
-
-
- public void setTransactionCheckListener(TransactionCheckListener transactionCheckListener) {
- this.transactionCheckListener = transactionCheckListener;
- }
-
-
- public int getCheckThreadPoolMinSize() {
- return checkThreadPoolMinSize;
- }
-
-
- public void setCheckThreadPoolMinSize(int checkThreadPoolMinSize) {
- this.checkThreadPoolMinSize = checkThreadPoolMinSize;
- }
-
-
- public int getCheckThreadPoolMaxSize() {
- return checkThreadPoolMaxSize;
- }
-
-
- public void setCheckThreadPoolMaxSize(int checkThreadPoolMaxSize) {
- this.checkThreadPoolMaxSize = checkThreadPoolMaxSize;
- }
-
-
- public int getCheckRequestHoldMax() {
- return checkRequestHoldMax;
- }
-
-
- public void setCheckRequestHoldMax(int checkRequestHoldMax) {
- this.checkRequestHoldMax = checkRequestHoldMax;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/producer/TransactionSendResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/producer/TransactionSendResult.java b/client/src/main/java/com/alibaba/rocketmq/client/producer/TransactionSendResult.java
deleted file mode 100644
index e7dcd0e..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/producer/TransactionSendResult.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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.client.producer;
-
-/**
- * @author shijia.wxr
- */
-public class TransactionSendResult extends SendResult {
- private LocalTransactionState localTransactionState;
-
-
- public TransactionSendResult() {
- }
-
-
- public LocalTransactionState getLocalTransactionState() {
- return localTransactionState;
- }
-
-
- public void setLocalTransactionState(LocalTransactionState localTransactionState) {
- this.localTransactionState = localTransactionState;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/producer/selector/SelectMessageQueueByHash.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/producer/selector/SelectMessageQueueByHash.java b/client/src/main/java/com/alibaba/rocketmq/client/producer/selector/SelectMessageQueueByHash.java
deleted file mode 100644
index 648356b..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/producer/selector/SelectMessageQueueByHash.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.client.producer.selector;
-
-import com.alibaba.rocketmq.client.producer.MessageQueueSelector;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public class SelectMessageQueueByHash implements MessageQueueSelector {
-
- @Override
- public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
- int value = arg.hashCode();
- if (value < 0) {
- value = Math.abs(value);
- }
-
- value = value % mqs.size();
- return mqs.get(value);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java b/client/src/main/java/com/alibaba/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java
deleted file mode 100644
index a213391..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * 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.client.producer.selector;
-
-import com.alibaba.rocketmq.client.producer.MessageQueueSelector;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-import java.util.List;
-import java.util.Set;
-
-
-/**
- * @author shijia.wxr
- */
-public class SelectMessageQueueByMachineRoom implements MessageQueueSelector {
- private Set<String> consumeridcs;
-
-
- @Override
- public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
- return null;
- }
-
-
- public Set<String> getConsumeridcs() {
- return consumeridcs;
- }
-
-
- public void setConsumeridcs(Set<String> consumeridcs) {
- this.consumeridcs = consumeridcs;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java b/client/src/main/java/com/alibaba/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java
deleted file mode 100644
index 3f381e4..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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.client.producer.selector;
-
-import com.alibaba.rocketmq.client.producer.MessageQueueSelector;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-import java.util.List;
-import java.util.Random;
-
-
-/**
- * @author shijia.wxr
- */
-public class SelectMessageQueueByRandoom implements MessageQueueSelector {
- private Random random = new Random(System.currentTimeMillis());
-
-
- @Override
- public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
- int value = random.nextInt();
- if (value < 0) {
- value = Math.abs(value);
- }
-
- value = value % mqs.size();
- return mqs.get(value);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/stat/ConsumerStatsManager.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/stat/ConsumerStatsManager.java b/client/src/main/java/com/alibaba/rocketmq/client/stat/ConsumerStatsManager.java
deleted file mode 100644
index e07e233..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/stat/ConsumerStatsManager.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/**
- * 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.client.stat;
-
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.protocol.body.ConsumeStatus;
-import com.alibaba.rocketmq.common.stats.StatsItemSet;
-import com.alibaba.rocketmq.common.stats.StatsSnapshot;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.ScheduledExecutorService;
-
-
-public class ConsumerStatsManager {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.CLIENT_LOGGER_NAME);
-
- private static final String TOPIC_AND_GROUP_CONSUME_OK_TPS = "CONSUME_OK_TPS";
- private static final String TOPIC_AND_GROUP_CONSUME_FAILED_TPS = "CONSUME_FAILED_TPS";
- private static final String TOPIC_AND_GROUP_CONSUME_RT = "CONSUME_RT";
- private static final String TOPIC_AND_GROUP_PULL_TPS = "PULL_TPS";
- private static final String TOPIC_AND_GROUP_PULL_RT = "PULL_RT";
-
- private final StatsItemSet topicAndGroupConsumeOKTPS;
- private final StatsItemSet topicAndGroupConsumeRT;
- private final StatsItemSet topicAndGroupConsumeFailedTPS;
- private final StatsItemSet topicAndGroupPullTPS;
- private final StatsItemSet topicAndGroupPullRT;
-
-
- public ConsumerStatsManager(final ScheduledExecutorService scheduledExecutorService) {
- this.topicAndGroupConsumeOKTPS =
- new StatsItemSet(TOPIC_AND_GROUP_CONSUME_OK_TPS, scheduledExecutorService, log);
-
- this.topicAndGroupConsumeRT =
- new StatsItemSet(TOPIC_AND_GROUP_CONSUME_RT, scheduledExecutorService, log);
-
- this.topicAndGroupConsumeFailedTPS =
- new StatsItemSet(TOPIC_AND_GROUP_CONSUME_FAILED_TPS, scheduledExecutorService, log);
-
- this.topicAndGroupPullTPS = new StatsItemSet(TOPIC_AND_GROUP_PULL_TPS, scheduledExecutorService, log);
-
- this.topicAndGroupPullRT = new StatsItemSet(TOPIC_AND_GROUP_PULL_RT, scheduledExecutorService, log);
- }
-
-
- public void start() {
- }
-
-
- public void shutdown() {
- }
-
-
- public void incPullRT(final String group, final String topic, final long rt) {
- this.topicAndGroupPullRT.addValue(topic + "@" + group, (int) rt, 1);
- }
-
-
- public void incPullTPS(final String group, final String topic, final long msgs) {
- this.topicAndGroupPullTPS.addValue(topic + "@" + group, (int) msgs, 1);
- }
-
-
- public void incConsumeRT(final String group, final String topic, final long rt) {
- this.topicAndGroupConsumeRT.addValue(topic + "@" + group, (int) rt, 1);
- }
-
-
- public void incConsumeOKTPS(final String group, final String topic, final long msgs) {
- this.topicAndGroupConsumeOKTPS.addValue(topic + "@" + group, (int) msgs, 1);
- }
-
-
- public void incConsumeFailedTPS(final String group, final String topic, final long msgs) {
- this.topicAndGroupConsumeFailedTPS.addValue(topic + "@" + group, (int) msgs, 1);
- }
-
- public ConsumeStatus consumeStatus(final String group, final String topic) {
- ConsumeStatus cs = new ConsumeStatus();
- {
- StatsSnapshot ss = this.getPullRT(group, topic);
- if (ss != null) {
- cs.setPullRT(ss.getAvgpt());
- }
- }
-
- {
- StatsSnapshot ss = this.getPullTPS(group, topic);
- if (ss != null) {
- cs.setPullTPS(ss.getTps());
- }
- }
-
- {
- StatsSnapshot ss = this.getConsumeRT(group, topic);
- if (ss != null) {
- cs.setConsumeRT(ss.getAvgpt());
- }
- }
-
- {
- StatsSnapshot ss = this.getConsumeOKTPS(group, topic);
- if (ss != null) {
- cs.setConsumeOKTPS(ss.getTps());
- }
- }
-
- {
- StatsSnapshot ss = this.getConsumeFailedTPS(group, topic);
- if (ss != null) {
- cs.setConsumeFailedTPS(ss.getTps());
- }
- }
-
- {
- StatsSnapshot ss = this.topicAndGroupConsumeFailedTPS.getStatsDataInHour(topic + "@" + group);
- if (ss != null) {
- cs.setConsumeFailedMsgs(ss.getSum());
- }
- }
-
- return cs;
- }
-
- private StatsSnapshot getPullRT(final String group, final String topic) {
- return this.topicAndGroupPullRT.getStatsDataInMinute(topic + "@" + group);
- }
-
- private StatsSnapshot getPullTPS(final String group, final String topic) {
- return this.topicAndGroupPullTPS.getStatsDataInMinute(topic + "@" + group);
- }
-
- private StatsSnapshot getConsumeRT(final String group, final String topic) {
- StatsSnapshot statsData = this.topicAndGroupConsumeRT.getStatsDataInMinute(topic + "@" + group);
- if (0 == statsData.getSum()) {
- statsData = this.topicAndGroupConsumeRT.getStatsDataInHour(topic + "@" + group);
- }
-
- return statsData;
- }
-
- private StatsSnapshot getConsumeOKTPS(final String group, final String topic) {
- return this.topicAndGroupConsumeOKTPS.getStatsDataInMinute(topic + "@" + group);
- }
-
- private StatsSnapshot getConsumeFailedTPS(final String group, final String topic) {
- return this.topicAndGroupConsumeFailedTPS.getStatsDataInMinute(topic + "@" + group);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/ClientConfig.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
new file mode 100644
index 0000000..8d15108
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java
@@ -0,0 +1,202 @@
+/**
+ * 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.common.MixAll;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.remoting.common.RemotingUtil;
+
+
+/**
+ * Client Common configuration
+ *
+ * @author shijia.wxr
+ * @author vongosling
+ */
+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 String instanceName = System.getProperty("rocketmq.client.name", "DEFAULT");
+ private int clientCallbackExecutorThreads = Runtime.getRuntime().availableProcessors();
+ /**
+ * Pulling topic information interval from the named server
+ */
+ private int pollNameServerInteval = 1000 * 30;
+ /**
+ * Heartbeat interval in microseconds with message broker
+ */
+ private int heartbeatBrokerInterval = 1000 * 30;
+ /**
+ * Offset persistent interval for consumer
+ */
+ private int persistConsumerOffsetInterval = 1000 * 5;
+ private boolean unitMode = false;
+ private String unitName;
+ private boolean vipChannelEnabled = Boolean.parseBoolean(System.getProperty(SEND_MESSAGE_WITH_VIP_CHANNEL_PROPERTY, "true"));
+
+ public String buildMQClientId() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(this.getClientIP());
+
+ sb.append("@");
+ sb.append(this.getInstanceName());
+ if (!UtilAll.isBlank(this.unitName)) {
+ sb.append("@");
+ sb.append(this.unitName);
+ }
+
+ return sb.toString();
+ }
+
+ public String getClientIP() {
+ return clientIP;
+ }
+
+ public void setClientIP(String clientIP) {
+ this.clientIP = clientIP;
+ }
+
+ public String getInstanceName() {
+ return instanceName;
+ }
+
+ public void setInstanceName(String instanceName) {
+ this.instanceName = instanceName;
+ }
+
+ public void changeInstanceNameToPID() {
+ if (this.instanceName.equals("DEFAULT")) {
+ this.instanceName = String.valueOf(UtilAll.getPid());
+ }
+ }
+
+ public void resetClientConfig(final ClientConfig cc) {
+ this.namesrvAddr = cc.namesrvAddr;
+ this.clientIP = cc.clientIP;
+ this.instanceName = cc.instanceName;
+ this.clientCallbackExecutorThreads = cc.clientCallbackExecutorThreads;
+ this.pollNameServerInteval = cc.pollNameServerInteval;
+ this.heartbeatBrokerInterval = cc.heartbeatBrokerInterval;
+ this.persistConsumerOffsetInterval = cc.persistConsumerOffsetInterval;
+ this.unitMode = cc.unitMode;
+ this.unitName = cc.unitName;
+ this.vipChannelEnabled = cc.vipChannelEnabled;
+ }
+
+ public ClientConfig cloneClientConfig() {
+ ClientConfig cc = new ClientConfig();
+ cc.namesrvAddr = namesrvAddr;
+ cc.clientIP = clientIP;
+ cc.instanceName = instanceName;
+ cc.clientCallbackExecutorThreads = clientCallbackExecutorThreads;
+ cc.pollNameServerInteval = pollNameServerInteval;
+ cc.heartbeatBrokerInterval = heartbeatBrokerInterval;
+ cc.persistConsumerOffsetInterval = persistConsumerOffsetInterval;
+ cc.unitMode = unitMode;
+ cc.unitName = unitName;
+ cc.vipChannelEnabled = vipChannelEnabled;
+ return cc;
+ }
+
+ public String getNamesrvAddr() {
+ return namesrvAddr;
+ }
+
+ public void setNamesrvAddr(String namesrvAddr) {
+ this.namesrvAddr = namesrvAddr;
+ }
+
+ public int getClientCallbackExecutorThreads() {
+ return clientCallbackExecutorThreads;
+ }
+
+
+ public void setClientCallbackExecutorThreads(int clientCallbackExecutorThreads) {
+ this.clientCallbackExecutorThreads = clientCallbackExecutorThreads;
+ }
+
+
+ public int getPollNameServerInteval() {
+ return pollNameServerInteval;
+ }
+
+
+ public void setPollNameServerInteval(int pollNameServerInteval) {
+ this.pollNameServerInteval = pollNameServerInteval;
+ }
+
+
+ public int getHeartbeatBrokerInterval() {
+ return heartbeatBrokerInterval;
+ }
+
+
+ public void setHeartbeatBrokerInterval(int heartbeatBrokerInterval) {
+ this.heartbeatBrokerInterval = heartbeatBrokerInterval;
+ }
+
+
+ public int getPersistConsumerOffsetInterval() {
+ return persistConsumerOffsetInterval;
+ }
+
+
+ public void setPersistConsumerOffsetInterval(int persistConsumerOffsetInterval) {
+ this.persistConsumerOffsetInterval = persistConsumerOffsetInterval;
+ }
+
+
+ public String getUnitName() {
+ return unitName;
+ }
+
+
+ public void setUnitName(String unitName) {
+ this.unitName = unitName;
+ }
+
+
+ public boolean isUnitMode() {
+ return unitMode;
+ }
+
+
+ public void setUnitMode(boolean unitMode) {
+ this.unitMode = unitMode;
+ }
+
+
+ public boolean isVipChannelEnabled() {
+ return vipChannelEnabled;
+ }
+
+
+ public void setVipChannelEnabled(final boolean vipChannelEnabled) {
+ this.vipChannelEnabled = vipChannelEnabled;
+ }
+
+
+ @Override
+ public String toString() {
+ return "ClientConfig [namesrvAddr=" + namesrvAddr + ", clientIP=" + clientIP + ", instanceName=" + instanceName
+ + ", clientCallbackExecutorThreads=" + clientCallbackExecutorThreads + ", pollNameServerInteval=" + pollNameServerInteval
+ + ", heartbeatBrokerInterval=" + heartbeatBrokerInterval + ", persistConsumerOffsetInterval="
+ + persistConsumerOffsetInterval + ", unitMode=" + unitMode + ", unitName=" + unitName + ", vipChannelEnabled="
+ + vipChannelEnabled + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java b/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
new file mode 100644
index 0000000..9e85283
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
@@ -0,0 +1,173 @@
+/**
+ * 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.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+
+
+/**
+ * Base interface for MQ management
+ *
+ * @author shijia.wxr
+ */
+public interface MQAdmin {
+ /**
+ * Creates an topic
+ *
+ * @param key
+ * accesskey
+ * @param newTopic
+ * topic name
+ * @param queueNum
+ * topic's queue number
+ *
+ * @throws MQClientException
+ */
+ void createTopic(final String key, final String newTopic, final int queueNum)
+ throws MQClientException;
+
+
+ /**
+ * Creates an topic
+ *
+ * @param key
+ * accesskey
+ * @param newTopic
+ * topic name
+ * @param queueNum
+ * topic's queue number
+ * @param topicSysFlag
+ * topic system flag
+ *
+ * @throws MQClientException
+ */
+ void createTopic(String key, String newTopic, int queueNum, int topicSysFlag)
+ throws MQClientException;
+
+
+ /**
+ * Gets the message queue offset according to some time in milliseconds<br>
+ * be cautious to call because of more IO overhead
+ *
+ * @param mq
+ * Instance of MessageQueue
+ * @param timestamp
+ * from when in milliseconds.
+ *
+ * @return offset
+ *
+ * @throws MQClientException
+ */
+ long searchOffset(final MessageQueue mq, final long timestamp) throws MQClientException;
+
+
+ /**
+ * Gets the max offset
+ *
+ * @param mq
+ * Instance of MessageQueue
+ *
+ * @return the max offset
+ *
+ * @throws MQClientException
+ */
+ long maxOffset(final MessageQueue mq) throws MQClientException;
+
+
+ /**
+ * Gets the minimum offset
+ *
+ * @param mq
+ * Instance of MessageQueue
+ *
+ * @return the minimum offset
+ *
+ * @throws MQClientException
+ */
+ long minOffset(final MessageQueue mq) throws MQClientException;
+
+
+ /**
+ * Gets the earliest stored message time
+ *
+ * @param mq
+ * Instance of MessageQueue
+ *
+ * @return the time in microseconds
+ *
+ * @throws MQClientException
+ */
+ long earliestMsgStoreTime(final MessageQueue mq) throws MQClientException;
+
+
+ /**
+ * Query message according tto message id
+ *
+ * @param offsetMsgId
+ * message id
+ *
+ * @return message
+ *
+ * @throws InterruptedException
+ * @throws MQBrokerException
+ * @throws RemotingException
+ * @throws MQClientException
+ */
+ MessageExt viewMessage(final String offsetMsgId) throws RemotingException, MQBrokerException,
+ InterruptedException, MQClientException;
+
+
+ /**
+ * Query messages
+ *
+ * @param topic
+ * message topic
+ * @param key
+ * message key index word
+ * @param maxNum
+ * max message number
+ * @param begin
+ * from when
+ * @param end
+ * to when
+ *
+ * @return Instance of QueryResult
+ *
+ * @throws MQClientException
+ * @throws InterruptedException
+ */
+ QueryResult queryMessage(final String topic, final String key, final int maxNum, final long begin,
+ final long end) throws MQClientException, InterruptedException;
+
+ /**
+
+ * @param topic
+ * @param msgId
+ * @return The {@code MessageExt} of given msgId
+ * @throws RemotingException
+ * @throws MQBrokerException
+ * @throws InterruptedException
+ * @throws MQClientException
+ */
+ MessageExt viewMessage(String topic, String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/MQHelper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/MQHelper.java b/client/src/main/java/org/apache/rocketmq/client/MQHelper.java
new file mode 100644
index 0000000..41009c5
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/MQHelper.java
@@ -0,0 +1,94 @@
+/**
+ * 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.DefaultMQPullConsumer;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+import org.slf4j.Logger;
+
+import java.util.Set;
+import java.util.TreeSet;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class MQHelper {
+ public static void resetOffsetByTimestamp(
+ final MessageModel messageModel,
+ final String consumerGroup,
+ final String topic,
+ final long timestamp) throws Exception {
+ resetOffsetByTimestamp(messageModel, "DEFAULT", consumerGroup, topic, timestamp);
+ }
+
+ /**
+ * Reset consumer topic offset according to time
+ *
+ * @param messageModel
+ * which model
+ * @param instanceName
+ * which instance
+ * @param consumerGroup
+ * consumer group
+ * @param topic
+ * topic
+ * @param timestamp
+ * time
+ *
+ * @throws Exception
+ */
+ public static void resetOffsetByTimestamp(
+ final MessageModel messageModel,
+ final String instanceName,
+ final String consumerGroup,
+ final String topic,
+ final long timestamp) throws Exception {
+ final Logger log = ClientLogger.getLog();
+
+ DefaultMQPullConsumer consumer = new DefaultMQPullConsumer(consumerGroup);
+ consumer.setInstanceName(instanceName);
+ consumer.setMessageModel(messageModel);
+ consumer.start();
+
+ Set<MessageQueue> mqs = null;
+ try {
+ mqs = consumer.fetchSubscribeMessageQueues(topic);
+ if (mqs != null && !mqs.isEmpty()) {
+ TreeSet<MessageQueue> mqsNew = new TreeSet<MessageQueue>(mqs);
+ for (MessageQueue mq : mqsNew) {
+ long offset = consumer.searchOffset(mq, timestamp);
+ if (offset >= 0) {
+ consumer.updateConsumeOffset(mq, offset);
+ log.info("resetOffsetByTimestamp updateConsumeOffset success, {} {} {}",
+ consumerGroup, offset, mq);
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.warn("resetOffsetByTimestamp Exception", e);
+ throw e;
+ } finally {
+ if (mqs != null) {
+ consumer.getDefaultMQPullConsumerImpl().getOffsetStore().persistAll(mqs);
+ }
+ consumer.shutdown();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/QueryResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/QueryResult.java b/client/src/main/java/org/apache/rocketmq/client/QueryResult.java
new file mode 100644
index 0000000..cdbf1e7
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/QueryResult.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 org.apache.rocketmq.client;
+
+import org.apache.rocketmq.common.message.MessageExt;
+
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class QueryResult {
+ private final long indexLastUpdateTimestamp;
+ private final List<MessageExt> messageList;
+
+
+ public QueryResult(long indexLastUpdateTimestamp, List<MessageExt> messageList) {
+ this.indexLastUpdateTimestamp = indexLastUpdateTimestamp;
+ this.messageList = messageList;
+ }
+
+
+ public long getIndexLastUpdateTimestamp() {
+ return indexLastUpdateTimestamp;
+ }
+
+
+ public List<MessageExt> getMessageList() {
+ return messageList;
+ }
+
+
+ @Override
+ public String toString() {
+ return "QueryResult [indexLastUpdateTimestamp=" + indexLastUpdateTimestamp + ", messageList="
+ + messageList + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/Validators.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/Validators.java b/client/src/main/java/org/apache/rocketmq/client/Validators.java
new file mode 100644
index 0000000..e977d44
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/Validators.java
@@ -0,0 +1,150 @@
+/**
+ * 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.exception.MQClientException;
+import org.apache.rocketmq.client.producer.DefaultMQProducer;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.protocol.ResponseCode;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+/**
+ * Common Validator
+ *
+ * @author manhong.yqd
+ */
+public class Validators {
+ public static final String VALID_PATTERN_STR = "^[%|a-zA-Z0-9_-]+$";
+ public static final Pattern PATTERN = Pattern.compile(VALID_PATTERN_STR);
+ public static final int CHARACTER_MAX_LENGTH = 255;
+
+ /**
+ * @param origin
+ * @param patternStr
+ *
+ * @return The resulting {@code String}
+ */
+ public static String getGroupWithRegularExpression(String origin, String patternStr) {
+ Pattern pattern = Pattern.compile(patternStr);
+ Matcher matcher = pattern.matcher(origin);
+ while (matcher.find()) {
+ return matcher.group(0);
+ }
+ return null;
+ }
+
+ /**
+ * Validate group
+ *
+ * @param group
+ *
+ * @throws MQClientException
+ */
+ public static void checkGroup(String group) throws MQClientException {
+ if (UtilAll.isBlank(group)) {
+ throw new MQClientException("the specified group is blank", null);
+ }
+ if (!regularExpressionMatcher(group, PATTERN)) {
+ throw new MQClientException(String.format(
+ "the specified group[%s] contains illegal characters, allowing only %s", group,
+ VALID_PATTERN_STR), null);
+ }
+ if (group.length() > CHARACTER_MAX_LENGTH) {
+ throw new MQClientException("the specified group is longer than group max length 255.", null);
+ }
+ }
+
+ /**
+ * @param origin
+ * @param pattern
+ *
+ * @return <tt>true</tt> if, and only if, the entire origin sequence
+ * matches this matcher's pattern
+ */
+ public static boolean regularExpressionMatcher(String origin, Pattern pattern) {
+ if (pattern == null) {
+ return true;
+ }
+ Matcher matcher = pattern.matcher(origin);
+ return matcher.matches();
+ }
+
+ /**
+ * Validate message
+ *
+ * @param msg
+ * @param defaultMQProducer
+ *
+ * @throws MQClientException
+ */
+ public static void checkMessage(Message msg, DefaultMQProducer defaultMQProducer)
+ throws MQClientException {
+ if (null == msg) {
+ throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, "the message is null");
+ }
+ // topic
+ Validators.checkTopic(msg.getTopic());
+ // body
+ if (null == msg.getBody()) {
+ throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, "the message body is null");
+ }
+
+ if (0 == msg.getBody().length) {
+ throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, "the message body length is zero");
+ }
+
+ if (msg.getBody().length > defaultMQProducer.getMaxMessageSize()) {
+ throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL,
+ "the message body size over max value, MAX: " + defaultMQProducer.getMaxMessageSize());
+ }
+ }
+
+ /**
+ * Validate topic
+ *
+ * @param topic
+ *
+ * @throws MQClientException
+ */
+ public static void checkTopic(String topic) throws MQClientException {
+ if (UtilAll.isBlank(topic)) {
+ throw new MQClientException("the specified topic is blank", null);
+ }
+
+ if (!regularExpressionMatcher(topic, PATTERN)) {
+ throw new MQClientException(String.format(
+ "the specified topic[%s] contains illegal characters, allowing only %s", topic,
+ VALID_PATTERN_STR), null);
+ }
+
+ if (topic.length() > CHARACTER_MAX_LENGTH) {
+ throw new MQClientException("the specified topic is longer than topic max length 255.", null);
+ }
+
+ //whether the same with system reserved keyword
+ if (topic.equals(MixAll.DEFAULT_TOPIC)) {
+ throw new MQClientException(
+ String.format("the topic[%s] is conflict with default topic.", topic), null);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java b/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java
new file mode 100644
index 0000000..cfff17e
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java
@@ -0,0 +1,24 @@
+/**
+ * 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.admin;
+
+/**
+ * @author shijia.wxr
+ */
+public interface MQAdminExtInner {
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/common/ClientErrorCode.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/common/ClientErrorCode.java b/client/src/main/java/org/apache/rocketmq/client/common/ClientErrorCode.java
new file mode 100644
index 0000000..6184379
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/common/ClientErrorCode.java
@@ -0,0 +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 org.apache.rocketmq.client.common;
+
+public class ClientErrorCode {
+ public static final int CONNECT_BROKER_EXCEPTION = 10001;
+ public static final int ACCESS_BROKER_TIMEOUT = 10002;
+ public static final int BROKER_NOT_EXIST_EXCEPTION = 10003;
+ public static final int NO_NAME_SERVER_EXCEPTION = 10004;
+ public static final int NOT_FOUND_TOPIC_EXCEPTION = 10005;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/common/ThreadLocalIndex.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/common/ThreadLocalIndex.java b/client/src/main/java/org/apache/rocketmq/client/common/ThreadLocalIndex.java
new file mode 100644
index 0000000..360cfdf
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/common/ThreadLocalIndex.java
@@ -0,0 +1,51 @@
+/**
+ * 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.common;
+
+import java.util.Random;
+
+public class ThreadLocalIndex {
+ private final ThreadLocal<Integer> threadLocalIndex = new ThreadLocal<Integer>();
+ private final Random random = new Random();
+ public ThreadLocalIndex(int value) {
+
+ }
+
+ public int getAndIncrement() {
+ Integer index = this.threadLocalIndex.get();
+ if (null == index) {
+ index = Math.abs(random.nextInt());
+ if (index < 0) index = 0;
+ this.threadLocalIndex.set(index);
+ }
+
+ index = Math.abs(index + 1);
+ if (index < 0)
+ index = 0;
+
+ this.threadLocalIndex.set(index);
+ return index;
+ }
+
+ @Override
+ public String toString() {
+ return "ThreadLocalIndex{" +
+ "threadLocalIndex=" + threadLocalIndex.get() +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java b/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java
new file mode 100644
index 0000000..cb98b62
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java
@@ -0,0 +1,60 @@
+/**
+ * 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.consumer;
+
+import org.apache.rocketmq.common.message.MessageQueue;
+
+import java.util.List;
+
+
+/**
+ * Strategy Algorithm for message allocating between consumers
+ *
+ * @author shijia.wxr
+ * @author vongosling
+ */
+public interface AllocateMessageQueueStrategy {
+
+ /**
+ * Allocating by consumer id
+ *
+ * @param consumerGroup
+ * current consumer group
+ * @param currentCID
+ * current consumer id
+ * @param mqAll
+ * message queue set in current topic
+ * @param cidAll
+ * consumer set in current consumer group
+ *
+ * @return The allocate result of given strategy
+ */
+ List<MessageQueue> allocate(
+ final String consumerGroup,
+ final String currentCID,
+ final List<MessageQueue> mqAll,
+ final List<String> cidAll
+ );
+
+
+ /**
+ * Algorithm name
+ *
+ * @return The strategy name
+ */
+ String getName();
+}
[03/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/simple/RandomAsyncCommit.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/RandomAsyncCommit.java b/example/src/main/java/org/apache/rocketmq/example/simple/RandomAsyncCommit.java
new file mode 100644
index 0000000..cda7952
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/RandomAsyncCommit.java
@@ -0,0 +1,60 @@
+/**
+ * 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.example.simple;
+
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
+
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+public class RandomAsyncCommit {
+ private final ConcurrentHashMap<MessageQueue, CachedQueue> mqCachedTable =
+ new ConcurrentHashMap<MessageQueue, CachedQueue>();
+
+
+ public void putMessages(final MessageQueue mq, final List<MessageExt> msgs) {
+ CachedQueue cachedQueue = this.mqCachedTable.get(mq);
+ if (null == cachedQueue) {
+ cachedQueue = new CachedQueue();
+ this.mqCachedTable.put(mq, cachedQueue);
+ }
+ for (MessageExt msg : msgs) {
+ cachedQueue.getMsgCachedTable().put(msg.getQueueOffset(), msg);
+ }
+ }
+
+
+ public void removeMessage(final MessageQueue mq, long offset) {
+ CachedQueue cachedQueue = this.mqCachedTable.get(mq);
+ if (null != cachedQueue) {
+ cachedQueue.getMsgCachedTable().remove(offset);
+ }
+ }
+
+
+ public long commitableOffset(final MessageQueue mq) {
+ CachedQueue cachedQueue = this.mqCachedTable.get(mq);
+ if (null != cachedQueue) {
+ return cachedQueue.getMsgCachedTable().firstKey();
+ }
+
+ return -1;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/simple/TestProducer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/TestProducer.java b/example/src/main/java/org/apache/rocketmq/example/simple/TestProducer.java
new file mode 100644
index 0000000..0304a63
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/TestProducer.java
@@ -0,0 +1,54 @@
+/**
+ * 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.example.simple;
+
+import org.apache.rocketmq.client.QueryResult;
+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.message.Message;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+
+public class TestProducer {
+ public static void main(String[] args) throws MQClientException, InterruptedException {
+ DefaultMQProducer producer = new DefaultMQProducer("ProducerGroupName");
+ producer.start();
+
+ for (int i = 0; i < 1; i++)
+ try {
+ {
+ Message msg = new Message("TopicTest1",
+ "TagA",
+ "key113",
+ "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
+ SendResult sendResult = producer.send(msg);
+ System.out.printf("%s%n", sendResult);
+
+ QueryResult queryMessage =
+ producer.queryMessage("TopicTest1", "key113", 10, 0, System.currentTimeMillis());
+ for (MessageExt m : queryMessage.getMessageList()) {
+ System.out.printf("%s%n", m);
+ }
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ producer.shutdown();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionCheckListenerImpl.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionCheckListenerImpl.java b/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionCheckListenerImpl.java
new file mode 100644
index 0000000..fea93a8
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionCheckListenerImpl.java
@@ -0,0 +1,45 @@
+/**
+ * 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.example.transaction;
+
+import org.apache.rocketmq.client.producer.LocalTransactionState;
+import org.apache.rocketmq.client.producer.TransactionCheckListener;
+import org.apache.rocketmq.common.message.MessageExt;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+
+public class TransactionCheckListenerImpl implements TransactionCheckListener {
+ private AtomicInteger transactionIndex = new AtomicInteger(0);
+
+
+ @Override
+ public LocalTransactionState checkLocalTransactionState(MessageExt msg) {
+ System.out.printf("server checking TrMsg " + msg.toString() + "%n");
+
+ int value = transactionIndex.getAndIncrement();
+ if ((value % 6) == 0) {
+ throw new RuntimeException("Could not find db");
+ } else if ((value % 5) == 0) {
+ return LocalTransactionState.ROLLBACK_MESSAGE;
+ } else if ((value % 4) == 0) {
+ return LocalTransactionState.COMMIT_MESSAGE;
+ }
+
+ return LocalTransactionState.UNKNOW;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionExecuterImpl.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionExecuterImpl.java b/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionExecuterImpl.java
new file mode 100644
index 0000000..eb787fd
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionExecuterImpl.java
@@ -0,0 +1,43 @@
+/**
+ * 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.example.transaction;
+
+import org.apache.rocketmq.client.producer.LocalTransactionExecuter;
+import org.apache.rocketmq.client.producer.LocalTransactionState;
+import org.apache.rocketmq.common.message.Message;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class TransactionExecuterImpl implements LocalTransactionExecuter {
+ private AtomicInteger transactionIndex = new AtomicInteger(1);
+
+
+ @Override
+ public LocalTransactionState executeLocalTransactionBranch(final Message msg, final Object arg) {
+ int value = transactionIndex.getAndIncrement();
+
+ if (value == 0) {
+ throw new RuntimeException("Could not find db");
+ } else if ((value % 5) == 0) {
+ return LocalTransactionState.ROLLBACK_MESSAGE;
+ } else if ((value % 4) == 0) {
+ return LocalTransactionState.COMMIT_MESSAGE;
+ }
+
+ return LocalTransactionState.UNKNOW;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionProducer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionProducer.java b/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionProducer.java
new file mode 100644
index 0000000..5a868c6
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionProducer.java
@@ -0,0 +1,61 @@
+/**
+ * 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.example.transaction;
+
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.producer.SendResult;
+import org.apache.rocketmq.client.producer.TransactionCheckListener;
+import org.apache.rocketmq.client.producer.TransactionMQProducer;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+
+import java.io.UnsupportedEncodingException;
+
+public class TransactionProducer {
+ public static void main(String[] args) throws MQClientException, InterruptedException {
+ TransactionCheckListener transactionCheckListener = new TransactionCheckListenerImpl();
+ TransactionMQProducer producer = new TransactionMQProducer("please_rename_unique_group_name");
+ producer.setCheckThreadPoolMinSize(2);
+ producer.setCheckThreadPoolMaxSize(2);
+ producer.setCheckRequestHoldMax(2000);
+ producer.setTransactionCheckListener(transactionCheckListener);
+ producer.start();
+
+ String[] tags = new String[]{"TagA", "TagB", "TagC", "TagD", "TagE"};
+ TransactionExecuterImpl tranExecuter = new TransactionExecuterImpl();
+ for (int i = 0; i < 100; i++) {
+ try {
+ Message msg =
+ new Message("TopicTest", tags[i % tags.length], "KEY" + i,
+ ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET));
+ SendResult sendResult = producer.sendMessageInTransaction(msg, tranExecuter, null);
+ System.out.printf("%s%n", sendResult);
+
+ Thread.sleep(10);
+ } catch (MQClientException e) {
+ e.printStackTrace();
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ }
+
+ for (int i = 0; i < 100000; i++) {
+ Thread.sleep(1000);
+ }
+ producer.shutdown();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/example/src/main/resources/MessageFilterImpl.java
----------------------------------------------------------------------
diff --git a/example/src/main/resources/MessageFilterImpl.java b/example/src/main/resources/MessageFilterImpl.java
index 2894a55..3ff3f48 100644
--- a/example/src/main/resources/MessageFilterImpl.java
+++ b/example/src/main/resources/MessageFilterImpl.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package com.alibaba.rocketmq.example.filter;
+package org.apache.rocketmq.example.filter;
-import com.alibaba.rocketmq.common.filter.MessageFilter;
-import com.alibaba.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.filter.MessageFilter;
+import org.apache.rocketmq.common.message.MessageExt;
public class MessageFilterImpl implements MessageFilter {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/pom.xml
----------------------------------------------------------------------
diff --git a/filtersrv/pom.xml b/filtersrv/pom.xml
index 28c360b..bebd10a 100644
--- a/filtersrv/pom.xml
+++ b/filtersrv/pom.xml
@@ -18,7 +18,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.rocketmq</groupId>
+ <groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-all</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/FilterServerOuterAPI.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/FilterServerOuterAPI.java b/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/FilterServerOuterAPI.java
deleted file mode 100644
index b469b3f..0000000
--- a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/FilterServerOuterAPI.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * 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.filtersrv;
-
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.common.protocol.RequestCode;
-import com.alibaba.rocketmq.common.protocol.ResponseCode;
-import com.alibaba.rocketmq.common.protocol.header.filtersrv.RegisterFilterServerRequestHeader;
-import com.alibaba.rocketmq.common.protocol.header.filtersrv.RegisterFilterServerResponseHeader;
-import com.alibaba.rocketmq.remoting.RemotingClient;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-import com.alibaba.rocketmq.remoting.exception.RemotingConnectException;
-import com.alibaba.rocketmq.remoting.exception.RemotingSendRequestException;
-import com.alibaba.rocketmq.remoting.exception.RemotingTimeoutException;
-import com.alibaba.rocketmq.remoting.netty.NettyClientConfig;
-import com.alibaba.rocketmq.remoting.netty.NettyRemotingClient;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-
-
-/**
- * @author shijia.wxr
- */
-public class FilterServerOuterAPI {
- private final RemotingClient remotingClient;
-
-
- public FilterServerOuterAPI() {
- this.remotingClient = new NettyRemotingClient(new NettyClientConfig());
- }
-
-
- public void start() {
- this.remotingClient.start();
- }
-
-
- public void shutdown() {
- this.remotingClient.shutdown();
- }
-
-
- public RegisterFilterServerResponseHeader registerFilterServerToBroker(
- final String brokerAddr,
- final String filterServerAddr
- ) throws RemotingCommandException, RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, InterruptedException, MQBrokerException {
- RegisterFilterServerRequestHeader requestHeader = new RegisterFilterServerRequestHeader();
- requestHeader.setFilterServerAddr(filterServerAddr);
- RemotingCommand request =
- RemotingCommand.createRequestCommand(RequestCode.REGISTER_FILTER_SERVER, requestHeader);
-
- RemotingCommand response = this.remotingClient.invokeSync(brokerAddr, request, 3000);
- assert response != null;
- switch (response.getCode()) {
- case ResponseCode.SUCCESS: {
- RegisterFilterServerResponseHeader responseHeader =
- (RegisterFilterServerResponseHeader) response
- .decodeCommandCustomHeader(RegisterFilterServerResponseHeader.class);
-
- return responseHeader;
- }
- default:
- break;
- }
-
- throw new MQBrokerException(response.getCode(), response.getRemark());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/FiltersrvConfig.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/FiltersrvConfig.java b/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/FiltersrvConfig.java
deleted file mode 100644
index fac620f..0000000
--- a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/FiltersrvConfig.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * 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.filtersrv;
-
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.annotation.ImportantField;
-import com.alibaba.rocketmq.remoting.common.RemotingUtil;
-
-
-public class FiltersrvConfig {
- private String rocketmqHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY,
- System.getenv(MixAll.ROCKETMQ_HOME_ENV));
-
- @ImportantField
- private String namesrvAddr = System.getProperty(MixAll.NAMESRV_ADDR_PROPERTY,
- System.getenv(MixAll.NAMESRV_ADDR_ENV));
-
- private String connectWhichBroker = "127.0.0.1:10911";
- private String filterServerIP = RemotingUtil.getLocalAddress();
-
- private int compressMsgBodyOverHowmuch = 1024 * 8;
- private int zipCompressLevel = 5;
-
-
- private boolean clientUploadFilterClassEnable = true;
-
-
- private String filterClassRepertoryUrl = "http://fsrep.tbsite.net/filterclass";
-
- private int fsServerAsyncSemaphoreValue = 2048;
- private int fsServerCallbackExecutorThreads = 64;
- private int fsServerWorkerThreads = 64;
-
-
- public String getRocketmqHome() {
- return rocketmqHome;
- }
-
-
- public void setRocketmqHome(String rocketmqHome) {
- this.rocketmqHome = rocketmqHome;
- }
-
-
- public String getNamesrvAddr() {
- return namesrvAddr;
- }
-
-
- public void setNamesrvAddr(String namesrvAddr) {
- this.namesrvAddr = namesrvAddr;
- }
-
-
- public String getConnectWhichBroker() {
- return connectWhichBroker;
- }
-
-
- public void setConnectWhichBroker(String connectWhichBroker) {
- this.connectWhichBroker = connectWhichBroker;
- }
-
-
- public String getFilterServerIP() {
- return filterServerIP;
- }
-
-
- public void setFilterServerIP(String filterServerIP) {
- this.filterServerIP = filterServerIP;
- }
-
-
- public int getCompressMsgBodyOverHowmuch() {
- return compressMsgBodyOverHowmuch;
- }
-
-
- public void setCompressMsgBodyOverHowmuch(int compressMsgBodyOverHowmuch) {
- this.compressMsgBodyOverHowmuch = compressMsgBodyOverHowmuch;
- }
-
-
- public int getZipCompressLevel() {
- return zipCompressLevel;
- }
-
-
- public void setZipCompressLevel(int zipCompressLevel) {
- this.zipCompressLevel = zipCompressLevel;
- }
-
-
- public boolean isClientUploadFilterClassEnable() {
- return clientUploadFilterClassEnable;
- }
-
-
- public void setClientUploadFilterClassEnable(boolean clientUploadFilterClassEnable) {
- this.clientUploadFilterClassEnable = clientUploadFilterClassEnable;
- }
-
-
- public String getFilterClassRepertoryUrl() {
- return filterClassRepertoryUrl;
- }
-
-
- public void setFilterClassRepertoryUrl(String filterClassRepertoryUrl) {
- this.filterClassRepertoryUrl = filterClassRepertoryUrl;
- }
-
-
- public int getFsServerAsyncSemaphoreValue() {
- return fsServerAsyncSemaphoreValue;
- }
-
-
- public void setFsServerAsyncSemaphoreValue(int fsServerAsyncSemaphoreValue) {
- this.fsServerAsyncSemaphoreValue = fsServerAsyncSemaphoreValue;
- }
-
-
- public int getFsServerCallbackExecutorThreads() {
- return fsServerCallbackExecutorThreads;
- }
-
-
- public void setFsServerCallbackExecutorThreads(int fsServerCallbackExecutorThreads) {
- this.fsServerCallbackExecutorThreads = fsServerCallbackExecutorThreads;
- }
-
-
- public int getFsServerWorkerThreads() {
- return fsServerWorkerThreads;
- }
-
-
- public void setFsServerWorkerThreads(int fsServerWorkerThreads) {
- this.fsServerWorkerThreads = fsServerWorkerThreads;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/FiltersrvController.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/FiltersrvController.java b/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/FiltersrvController.java
deleted file mode 100644
index 0e3f696..0000000
--- a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/FiltersrvController.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/**
- * 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.filtersrv;
-
-import com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.ThreadFactoryImpl;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.protocol.header.filtersrv.RegisterFilterServerResponseHeader;
-import com.alibaba.rocketmq.filtersrv.filter.FilterClassManager;
-import com.alibaba.rocketmq.filtersrv.processor.DefaultRequestProcessor;
-import com.alibaba.rocketmq.filtersrv.stats.FilterServerStatsManager;
-import com.alibaba.rocketmq.remoting.RemotingServer;
-import com.alibaba.rocketmq.remoting.netty.NettyRemotingServer;
-import com.alibaba.rocketmq.remoting.netty.NettyServerConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-
-/**
- * @author shijia.wxr
- */
-public class FiltersrvController {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
-
- private final FiltersrvConfig filtersrvConfig;
-
- private final NettyServerConfig nettyServerConfig;
- private final FilterClassManager filterClassManager;
-
- private final FilterServerOuterAPI filterServerOuterAPI = new FilterServerOuterAPI();
- private final DefaultMQPullConsumer defaultMQPullConsumer = new DefaultMQPullConsumer(
- MixAll.FILTERSRV_CONSUMER_GROUP);
-
- private final ScheduledExecutorService scheduledExecutorService = Executors
- .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("FSScheduledThread"));
- private final FilterServerStatsManager filterServerStatsManager = new FilterServerStatsManager();
-
- private RemotingServer remotingServer;
-
- private ExecutorService remotingExecutor;
- private volatile String brokerName = null;
-
-
- public FiltersrvController(FiltersrvConfig filtersrvConfig, NettyServerConfig nettyServerConfig) {
- this.filtersrvConfig = filtersrvConfig;
- this.nettyServerConfig = nettyServerConfig;
- this.filterClassManager = new FilterClassManager(this);
- }
-
-
- public boolean initialize() {
-
- MixAll.printObjectProperties(log, this.filtersrvConfig);
-
-
- this.remotingServer = new NettyRemotingServer(this.nettyServerConfig);
-
-
- this.remotingExecutor =
- Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(),
- new ThreadFactoryImpl("RemotingExecutorThread_"));
-
- this.registerProcessor();
-
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
-
- @Override
- public void run() {
- FiltersrvController.this.registerFilterServerToBroker();
- }
- }, 3, 10, TimeUnit.SECONDS);
-
- this.defaultMQPullConsumer.setBrokerSuspendMaxTimeMillis(this.defaultMQPullConsumer
- .getBrokerSuspendMaxTimeMillis() - 1000);
- this.defaultMQPullConsumer.setConsumerTimeoutMillisWhenSuspend(this.defaultMQPullConsumer
- .getConsumerTimeoutMillisWhenSuspend() - 1000);
-
- this.defaultMQPullConsumer.setNamesrvAddr(this.filtersrvConfig.getNamesrvAddr());
- this.defaultMQPullConsumer.setInstanceName(String.valueOf(UtilAll.getPid()));
-
- return true;
- }
-
- private void registerProcessor() {
- this.remotingServer
- .registerDefaultProcessor(new DefaultRequestProcessor(this), this.remotingExecutor);
- }
-
- public void registerFilterServerToBroker() {
- try {
- RegisterFilterServerResponseHeader responseHeader =
- this.filterServerOuterAPI.registerFilterServerToBroker(
- this.filtersrvConfig.getConnectWhichBroker(), this.localAddr());
- this.defaultMQPullConsumer.getDefaultMQPullConsumerImpl().getPullAPIWrapper()
- .setDefaultBrokerId(responseHeader.getBrokerId());
-
- if (null == this.brokerName) {
- this.brokerName = responseHeader.getBrokerName();
- }
-
- log.info("register filter server<{}> to broker<{}> OK, Return: {} {}",
- this.localAddr(),
- this.filtersrvConfig.getConnectWhichBroker(),
- responseHeader.getBrokerName(),
- responseHeader.getBrokerId());
- } catch (Exception e) {
- log.warn("register filter server Exception", e);
-
- log.warn("access broker failed, kill oneself");
- System.exit(-1);
- }
- }
-
- public String localAddr() {
- return String.format("%s:%d", this.filtersrvConfig.getFilterServerIP(),
- this.remotingServer.localListenPort());
- }
-
- public void start() throws Exception {
- this.defaultMQPullConsumer.start();
- this.remotingServer.start();
- this.filterServerOuterAPI.start();
- this.defaultMQPullConsumer.getDefaultMQPullConsumerImpl().getPullAPIWrapper()
- .setConnectBrokerByUser(true);
- this.filterClassManager.start();
- this.filterServerStatsManager.start();
- }
-
-
- public void shutdown() {
- this.remotingServer.shutdown();
- this.remotingExecutor.shutdown();
- this.scheduledExecutorService.shutdown();
- this.defaultMQPullConsumer.shutdown();
- this.filterServerOuterAPI.shutdown();
- this.filterClassManager.shutdown();
- this.filterServerStatsManager.shutdown();
- }
-
-
- public RemotingServer getRemotingServer() {
- return remotingServer;
- }
-
-
- public void setRemotingServer(RemotingServer remotingServer) {
- this.remotingServer = remotingServer;
- }
-
-
- public ExecutorService getRemotingExecutor() {
- return remotingExecutor;
- }
-
-
- public void setRemotingExecutor(ExecutorService remotingExecutor) {
- this.remotingExecutor = remotingExecutor;
- }
-
-
- public FiltersrvConfig getFiltersrvConfig() {
- return filtersrvConfig;
- }
-
-
- public NettyServerConfig getNettyServerConfig() {
- return nettyServerConfig;
- }
-
-
- public ScheduledExecutorService getScheduledExecutorService() {
- return scheduledExecutorService;
- }
-
-
- public FilterServerOuterAPI getFilterServerOuterAPI() {
- return filterServerOuterAPI;
- }
-
-
- public FilterClassManager getFilterClassManager() {
- return filterClassManager;
- }
-
-
- public DefaultMQPullConsumer getDefaultMQPullConsumer() {
- return defaultMQPullConsumer;
- }
-
-
- public String getBrokerName() {
- return brokerName;
- }
-
-
- public void setBrokerName(String brokerName) {
- this.brokerName = brokerName;
- }
-
-
- public FilterServerStatsManager getFilterServerStatsManager() {
- return filterServerStatsManager;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/FiltersrvStartup.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/FiltersrvStartup.java b/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/FiltersrvStartup.java
deleted file mode 100644
index 3fe6b22..0000000
--- a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/FiltersrvStartup.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/**
- * 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.filtersrv;
-
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.joran.JoranConfigurator;
-import com.alibaba.rocketmq.common.MQVersion;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.remoting.netty.NettyServerConfig;
-import com.alibaba.rocketmq.remoting.netty.NettySystemConfig;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import com.alibaba.rocketmq.srvutil.ServerUtil;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.PosixParser;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicInteger;
-
-
-/**
- * @author shijia.wxr
- */
-public class FiltersrvStartup {
- public static Logger log;
-
- public static void main(String[] args) {
- start(createController(args));
- }
-
- public static FiltersrvController start(FiltersrvController controller) {
-
- try {
- controller.start();
- } catch (Exception e) {
- e.printStackTrace();
- System.exit(-1);
- }
-
- String tip = "The Filter Server boot success, " + controller.localAddr();
- log.info(tip);
- System.out.printf("%s%n", tip);
-
- return controller;
- }
-
- public static FiltersrvController createController(String[] args) {
- System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));
-
-
- if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE)) {
- NettySystemConfig.socketSndbufSize = 65535;
- }
-
-
- if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE)) {
- NettySystemConfig.socketRcvbufSize = 1024;
- }
-
- try {
- Options options = ServerUtil.buildCommandlineOptions(new Options());
- final CommandLine commandLine =
- ServerUtil.parseCmdLine("mqfiltersrv", args, buildCommandlineOptions(options),
- new PosixParser());
- if (null == commandLine) {
- System.exit(-1);
- return null;
- }
-
- final FiltersrvConfig filtersrvConfig = new FiltersrvConfig();
- final NettyServerConfig nettyServerConfig = new NettyServerConfig();
-
- if (commandLine.hasOption('c')) {
- String file = commandLine.getOptionValue('c');
- if (file != null) {
- InputStream in = new BufferedInputStream(new FileInputStream(file));
- Properties properties = new Properties();
- properties.load(in);
- MixAll.properties2Object(properties, filtersrvConfig);
- System.out.printf("load config properties file OK, " + file + "%n");
- in.close();
-
- String port = properties.getProperty("listenPort");
- if (port != null) {
- filtersrvConfig.setConnectWhichBroker(String.format("127.0.0.1:%s", port));
- }
- }
- }
-
- nettyServerConfig.setListenPort(0);
- nettyServerConfig.setServerAsyncSemaphoreValue(filtersrvConfig.getFsServerAsyncSemaphoreValue());
- nettyServerConfig.setServerCallbackExecutorThreads(filtersrvConfig
- .getFsServerCallbackExecutorThreads());
- nettyServerConfig.setServerWorkerThreads(filtersrvConfig.getFsServerWorkerThreads());
-
- if (commandLine.hasOption('p')) {
- MixAll.printObjectProperties(null, filtersrvConfig);
- MixAll.printObjectProperties(null, nettyServerConfig);
- System.exit(0);
- }
-
- MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), filtersrvConfig);
- if (null == filtersrvConfig.getRocketmqHome()) {
- System.out.printf("Please set the " + MixAll.ROCKETMQ_HOME_ENV
- + " variable in your environment to match the location of the RocketMQ installation%n");
- System.exit(-2);
- }
-
- LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
- JoranConfigurator configurator = new JoranConfigurator();
- configurator.setContext(lc);
- lc.reset();
- configurator.doConfigure(filtersrvConfig.getRocketmqHome() + "/conf/logback_filtersrv.xml");
- log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
-
- final FiltersrvController controller =
- new FiltersrvController(filtersrvConfig, nettyServerConfig);
- boolean initResult = controller.initialize();
- if (!initResult) {
- controller.shutdown();
- System.exit(-3);
- }
-
- Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
- private volatile boolean hasShutdown = false;
- private AtomicInteger shutdownTimes = new AtomicInteger(0);
-
- @Override
- public void run() {
- synchronized (this) {
- log.info("shutdown hook was invoked, " + this.shutdownTimes.incrementAndGet());
- if (!this.hasShutdown) {
- this.hasShutdown = true;
- long begineTime = System.currentTimeMillis();
- controller.shutdown();
- long consumingTimeTotal = System.currentTimeMillis() - begineTime;
- log.info("shutdown hook over, consuming time total(ms): " + consumingTimeTotal);
- }
- }
- }
- }, "ShutdownHook"));
-
- return controller;
- } catch (Throwable e) {
- e.printStackTrace();
- System.exit(-1);
- }
- return null;
- }
-
- public static Options buildCommandlineOptions(final Options options) {
- Option opt = new Option("c", "configFile", true, "Filter server config properties file");
- opt.setRequired(false);
- options.addOption(opt);
-
- opt = new Option("p", "printConfigItem", false, "Print all config item");
- opt.setRequired(false);
- options.addOption(opt);
-
- return options;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/DynaCode.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/DynaCode.java b/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/DynaCode.java
deleted file mode 100644
index e17e5d2..0000000
--- a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/DynaCode.java
+++ /dev/null
@@ -1,393 +0,0 @@
-/**
- * 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.filtersrv.filter;
-
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.filter.FilterAPI;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.tools.JavaCompiler;
-import javax.tools.ToolProvider;
-import java.io.*;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.URLDecoder;
-import java.util.*;
-
-
-public class DynaCode {
- private static final Logger LOGGER = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
-
- private static final String FILE_SP = System.getProperty("file.separator");
-
- private static final String LINE_SP = System.getProperty("line.separator");
-
- private String sourcePath = System.getProperty("user.home") + FILE_SP + "rocketmq_filter_class" + FILE_SP
- + UtilAll.getPid();
-
- private String outPutClassPath = sourcePath;
-
-
- private ClassLoader parentClassLoader;
-
-
- private List<String> codeStrs;
-
-
- private Map<String/* fullClassName */, Class<?>/* class */> loadClass;
-
-
- private String classpath;
-
-
- private String bootclasspath;
-
-
- private String extdirs;
-
-
- private String encoding = "UTF-8";
-
-
- private String target;
-
-
- @SuppressWarnings("unchecked")
- public DynaCode(String code) {
- this(Thread.currentThread().getContextClassLoader(), Arrays.asList(code));
- }
-
-
- public DynaCode(ClassLoader parentClassLoader, List<String> codeStrs) {
- this(extractClasspath(parentClassLoader), parentClassLoader, codeStrs);
- }
-
-
- public DynaCode(String classpath, ClassLoader parentClassLoader, List<String> codeStrs) {
- this.classpath = classpath;
- this.parentClassLoader = parentClassLoader;
- this.codeStrs = codeStrs;
- this.loadClass = new HashMap<String, Class<?>>(codeStrs.size());
- }
-
-
- private static String extractClasspath(ClassLoader cl) {
- StringBuffer buf = new StringBuffer();
- while (cl != null) {
- if (cl instanceof URLClassLoader) {
- URL urls[] = ((URLClassLoader) cl).getURLs();
- for (int i = 0; i < urls.length; i++) {
- if (buf.length() > 0) {
- buf.append(File.pathSeparatorChar);
- }
- String s = urls[i].getFile();
- try {
- s = URLDecoder.decode(s, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- continue;
- }
- File f = new File(s);
- buf.append(f.getAbsolutePath());
- }
- }
- cl = cl.getParent();
- }
- return buf.toString();
- }
-
-
- public DynaCode(List<String> codeStrs) {
- this(Thread.currentThread().getContextClassLoader(), codeStrs);
- }
-
- public static Class<?> compileAndLoadClass(final String className, final String javaSource)
- throws Exception {
- String classSimpleName = FilterAPI.simpleClassName(className);
- String javaCode = javaSource;
-
- final String newClassSimpleName = classSimpleName + System.currentTimeMillis();
- String newJavaCode = javaCode.replaceAll(classSimpleName, newClassSimpleName);
-
- List<String> codes = new ArrayList<String>();
- codes.add(newJavaCode);
- DynaCode dc = new DynaCode(codes);
- dc.compileAndLoadClass();
- Map<String, Class<?>> map = dc.getLoadClass();
-
- Class<?> clazz = map.get(getQualifiedName(newJavaCode));
- return clazz;
- }
-
- public void compileAndLoadClass() throws Exception {
- String[] sourceFiles = this.uploadSrcFile();
- this.compile(sourceFiles);
- this.loadClass(this.loadClass.keySet());
- }
-
- public Map<String, Class<?>> getLoadClass() {
- return loadClass;
- }
-
- public static String getQualifiedName(String code) {
- StringBuilder sb = new StringBuilder();
- String className = getClassName(code);
- if (StringUtils.isNotBlank(className)) {
-
- String packageName = getPackageName(code);
- if (StringUtils.isNotBlank(packageName)) {
- sb.append(packageName).append(".");
- }
- sb.append(className);
- }
- return sb.toString();
- }
-
- private String[] uploadSrcFile() throws Exception {
- List<String> srcFileAbsolutePaths = new ArrayList<String>(codeStrs.size());
- for (String code : codeStrs) {
- if (StringUtils.isNotBlank(code)) {
- String packageName = getPackageName(code);
- String className = getClassName(code);
- if (StringUtils.isNotBlank(className)) {
- File srcFile = null;
- BufferedWriter bufferWriter = null;
- try {
- if (StringUtils.isBlank(packageName)) {
- File pathFile = new File(sourcePath);
-
- if (!pathFile.exists()) {
- if (!pathFile.mkdirs()) {
- throw new RuntimeException("create PathFile Error!");
- }
- }
- srcFile = new File(sourcePath + FILE_SP + className + ".java");
- } else {
- String srcPath = StringUtils.replace(packageName, ".", FILE_SP);
- File pathFile = new File(sourcePath + FILE_SP + srcPath);
-
- if (!pathFile.exists()) {
- if (!pathFile.mkdirs()) {
- throw new RuntimeException("create PathFile Error!");
- }
- }
- srcFile = new File(pathFile.getAbsolutePath() + FILE_SP + className + ".java");
- }
- synchronized (loadClass) {
- loadClass.put(getFullClassName(code), null);
- }
- if (null != srcFile) {
- LOGGER.warn("Dyna Create Java Source File:---->" + srcFile.getAbsolutePath());
- srcFileAbsolutePaths.add(srcFile.getAbsolutePath());
- srcFile.deleteOnExit();
- }
- OutputStreamWriter outputStreamWriter =
- new OutputStreamWriter(new FileOutputStream(srcFile), encoding);
- bufferWriter = new BufferedWriter(outputStreamWriter);
- for (String lineCode : code.split(LINE_SP)) {
- bufferWriter.write(lineCode);
- bufferWriter.newLine();
- }
- bufferWriter.flush();
- } finally {
- if (null != bufferWriter) {
- bufferWriter.close();
- }
- }
- }
- }
- }
- return srcFileAbsolutePaths.toArray(new String[srcFileAbsolutePaths.size()]);
- }
-
- private void compile(String[] srcFiles) throws Exception {
- String args[] = this.buildCompileJavacArgs(srcFiles);
- ByteArrayOutputStream err = new ByteArrayOutputStream();
- JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- if (compiler == null) {
- throw new NullPointerException(
- "ToolProvider.getSystemJavaCompiler() return null,please use JDK replace JRE!");
- }
- int resultCode = compiler.run(null, null, err, args);
- if (resultCode != 0) {
- throw new Exception(err.toString(RemotingHelper.DEFAULT_CHARSET));
- }
- }
-
- private void loadClass(Set<String> classFullNames) throws ClassNotFoundException, MalformedURLException {
- synchronized (loadClass) {
- ClassLoader classLoader =
- new URLClassLoader(new URL[]{new File(outPutClassPath).toURI().toURL()},
- parentClassLoader);
- for (String key : classFullNames) {
- Class<?> classz = classLoader.loadClass(key);
- if (null != classz) {
- loadClass.put(key, classz);
- LOGGER.info("Dyna Load Java Class File OK:----> className: " + key);
- } else {
- LOGGER.error("Dyna Load Java Class File Fail:----> className: " + key);
- }
- }
- }
- }
-
- public static String getClassName(String code) {
- String className = StringUtils.substringBefore(code, "{");
- if (StringUtils.isBlank(className)) {
- return className;
- }
- if (StringUtils.contains(code, " class ")) {
- className = StringUtils.substringAfter(className, " class ");
- if (StringUtils.contains(className, " extends ")) {
- className = StringUtils.substringBefore(className, " extends ").trim();
- } else if (StringUtils.contains(className, " implements ")) {
- className = StringUtils.trim(StringUtils.substringBefore(className, " implements "));
- } else {
- className = StringUtils.trim(className);
- }
- } else if (StringUtils.contains(code, " interface ")) {
- className = StringUtils.substringAfter(className, " interface ");
- if (StringUtils.contains(className, " extends ")) {
- className = StringUtils.substringBefore(className, " extends ").trim();
- } else {
- className = StringUtils.trim(className);
- }
- } else if (StringUtils.contains(code, " enum ")) {
- className = StringUtils.trim(StringUtils.substringAfter(className, " enum "));
- } else {
- return StringUtils.EMPTY;
- }
- return className;
- }
-
- public static String getPackageName(String code) {
- String packageName =
- StringUtils.substringBefore(StringUtils.substringAfter(code, "package "), ";").trim();
- return packageName;
- }
-
- public static String getFullClassName(String code) {
- String packageName = getPackageName(code);
- String className = getClassName(code);
- return StringUtils.isBlank(packageName) ? className : packageName + "." + className;
- }
-
- private String[] buildCompileJavacArgs(String srcFiles[]) {
- ArrayList<String> args = new ArrayList<String>();
- if (StringUtils.isNotBlank(classpath)) {
- args.add("-classpath");
- args.add(classpath);
- }
- if (StringUtils.isNotBlank(outPutClassPath)) {
- args.add("-d");
- args.add(outPutClassPath);
- }
- if (StringUtils.isNotBlank(sourcePath)) {
- args.add("-sourcepath");
- args.add(sourcePath);
- }
- if (StringUtils.isNotBlank(bootclasspath)) {
- args.add("-bootclasspath");
- args.add(bootclasspath);
- }
- if (StringUtils.isNotBlank(extdirs)) {
- args.add("-extdirs");
- args.add(extdirs);
- }
- if (StringUtils.isNotBlank(encoding)) {
- args.add("-encoding");
- args.add(encoding);
- }
- if (StringUtils.isNotBlank(target)) {
- args.add("-target");
- args.add(target);
- }
- for (int i = 0; i < srcFiles.length; i++) {
- args.add(srcFiles[i]);
- }
- return args.toArray(new String[args.size()]);
- }
-
- public String getOutPutClassPath() {
- return outPutClassPath;
- }
-
- public void setOutPutClassPath(String outPutClassPath) {
- this.outPutClassPath = outPutClassPath;
- }
-
- public String getSourcePath() {
- return sourcePath;
- }
-
- public void setSourcePath(String sourcePath) {
- this.sourcePath = sourcePath;
- }
-
- public ClassLoader getParentClassLoader() {
- return parentClassLoader;
- }
-
- public void setParentClassLoader(ClassLoader parentClassLoader) {
- this.parentClassLoader = parentClassLoader;
- }
-
- public String getClasspath() {
- return classpath;
- }
-
- public void setClasspath(String classpath) {
- this.classpath = classpath;
- }
-
- public String getBootclasspath() {
- return bootclasspath;
- }
-
- public void setBootclasspath(String bootclasspath) {
- this.bootclasspath = bootclasspath;
- }
-
- public String getExtdirs() {
- return extdirs;
- }
-
- public void setExtdirs(String extdirs) {
- this.extdirs = extdirs;
- }
-
- public String getEncoding() {
- return encoding;
- }
-
- public void setEncoding(String encoding) {
- this.encoding = encoding;
- }
-
- public String getTarget() {
- return target;
- }
-
- public void setTarget(String target) {
- this.target = target;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/FilterClassFetchMethod.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/FilterClassFetchMethod.java b/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/FilterClassFetchMethod.java
deleted file mode 100644
index 27b19ce..0000000
--- a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/FilterClassFetchMethod.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * 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.filtersrv.filter;
-
-public interface FilterClassFetchMethod {
- public String fetch(final String topic, final String consumerGroup, final String className);
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/FilterClassInfo.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/FilterClassInfo.java b/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/FilterClassInfo.java
deleted file mode 100644
index f3e747e..0000000
--- a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/FilterClassInfo.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * 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.filtersrv.filter;
-
-import com.alibaba.rocketmq.common.filter.MessageFilter;
-
-
-public class FilterClassInfo {
- private String className;
- private int classCRC;
- private MessageFilter messageFilter;
-
-
- public int getClassCRC() {
- return classCRC;
- }
-
-
- public void setClassCRC(int classCRC) {
- this.classCRC = classCRC;
- }
-
-
- public MessageFilter getMessageFilter() {
- return messageFilter;
- }
-
-
- public void setMessageFilter(MessageFilter messageFilter) {
- this.messageFilter = messageFilter;
- }
-
-
- public String getClassName() {
- return className;
- }
-
-
- public void setClassName(String className) {
- this.className = className;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/FilterClassLoader.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/FilterClassLoader.java b/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/FilterClassLoader.java
deleted file mode 100644
index 8966ca2..0000000
--- a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/FilterClassLoader.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * 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.filtersrv.filter;
-
-public class FilterClassLoader extends ClassLoader {
- public final Class<?> createNewClass(String name, byte[] b, int off, int len) throws ClassFormatError {
- return this.defineClass(name, b, off, len);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/FilterClassManager.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/FilterClassManager.java b/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/FilterClassManager.java
deleted file mode 100644
index 618db8e..0000000
--- a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/FilterClassManager.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/**
- * 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.filtersrv.filter;
-
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.ThreadFactoryImpl;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.filter.MessageFilter;
-import com.alibaba.rocketmq.filtersrv.FiltersrvController;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-
-public class FilterClassManager {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
-
- private final Object compileLock = new Object();
- private final FiltersrvController filtersrvController;
-
- private final ScheduledExecutorService scheduledExecutorService = Executors
- .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("FSGetClassScheduledThread"));
- private ConcurrentHashMap<String/* topic@consumerGroup */, FilterClassInfo> filterClassTable =
- new ConcurrentHashMap<String, FilterClassInfo>(128);
- private FilterClassFetchMethod filterClassFetchMethod;
-
-
- public FilterClassManager(FiltersrvController filtersrvController) {
- this.filtersrvController = filtersrvController;
- this.filterClassFetchMethod =
- new HttpFilterClassFetchMethod(this.filtersrvController.getFiltersrvConfig()
- .getFilterClassRepertoryUrl());
- }
-
-
- public void start() {
- if (!this.filtersrvController.getFiltersrvConfig().isClientUploadFilterClassEnable()) {
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
-
- @Override
- public void run() {
- fetchClassFromRemoteHost();
- }
- }, 1, 1, TimeUnit.MINUTES);
- }
- }
-
- private void fetchClassFromRemoteHost() {
- Iterator<Entry<String, FilterClassInfo>> it = this.filterClassTable.entrySet().iterator();
- while (it.hasNext()) {
- try {
- Entry<String, FilterClassInfo> next = it.next();
- FilterClassInfo filterClassInfo = next.getValue();
- String[] topicAndGroup = next.getKey().split("@");
- String responseStr =
- this.filterClassFetchMethod.fetch(topicAndGroup[0], topicAndGroup[1],
- filterClassInfo.getClassName());
- byte[] filterSourceBinary = responseStr.getBytes("UTF-8");
- int classCRC = UtilAll.crc32(responseStr.getBytes("UTF-8"));
- if (classCRC != filterClassInfo.getClassCRC()) {
- String javaSource = new String(filterSourceBinary, MixAll.DEFAULT_CHARSET);
- Class<?> newClass =
- DynaCode.compileAndLoadClass(filterClassInfo.getClassName(), javaSource);
- Object newInstance = newClass.newInstance();
- filterClassInfo.setMessageFilter((MessageFilter) newInstance);
- filterClassInfo.setClassCRC(classCRC);
-
- log.info("fetch Remote class File OK, {} {}", next.getKey(),
- filterClassInfo.getClassName());
- }
- } catch (Exception e) {
- log.error("fetchClassFromRemoteHost Exception", e);
- }
- }
- }
-
- public void shutdown() {
- this.scheduledExecutorService.shutdown();
- }
-
- public boolean registerFilterClass(final String consumerGroup, final String topic,
- final String className, final int classCRC, final byte[] filterSourceBinary) {
- final String key = buildKey(consumerGroup, topic);
-
-
- boolean registerNew = false;
- FilterClassInfo filterClassInfoPrev = this.filterClassTable.get(key);
- if (null == filterClassInfoPrev) {
- registerNew = true;
- } else {
- if (this.filtersrvController.getFiltersrvConfig().isClientUploadFilterClassEnable()) {
- if (filterClassInfoPrev.getClassCRC() != classCRC && classCRC != 0) {
- registerNew = true;
- }
- }
- }
-
- if (registerNew) {
- synchronized (this.compileLock) {
- filterClassInfoPrev = this.filterClassTable.get(key);
- if (null != filterClassInfoPrev && filterClassInfoPrev.getClassCRC() == classCRC) {
- return true;
- }
-
- try {
-
- FilterClassInfo filterClassInfoNew = new FilterClassInfo();
- filterClassInfoNew.setClassName(className);
- filterClassInfoNew.setClassCRC(0);
- filterClassInfoNew.setMessageFilter(null);
-
- if (this.filtersrvController.getFiltersrvConfig().isClientUploadFilterClassEnable()) {
- String javaSource = new String(filterSourceBinary, MixAll.DEFAULT_CHARSET);
- Class<?> newClass = DynaCode.compileAndLoadClass(className, javaSource);
- Object newInstance = newClass.newInstance();
- filterClassInfoNew.setMessageFilter((MessageFilter) newInstance);
- filterClassInfoNew.setClassCRC(classCRC);
- }
-
- this.filterClassTable.put(key, filterClassInfoNew);
- } catch (Throwable e) {
- String info =
- String
- .format(
- "FilterServer, registerFilterClass Exception, consumerGroup: %s topic: %s className: %s",
- consumerGroup, topic, className);
- log.error(info, e);
- return false;
- }
- }
- }
-
- return true;
- }
-
- private static String buildKey(final String consumerGroup, final String topic) {
- return topic + "@" + consumerGroup;
- }
-
- public FilterClassInfo findFilterClass(final String consumerGroup, final String topic) {
- return this.filterClassTable.get(buildKey(consumerGroup, topic));
- }
-
-
- public FilterClassFetchMethod getFilterClassFetchMethod() {
- return filterClassFetchMethod;
- }
-
-
- public void setFilterClassFetchMethod(FilterClassFetchMethod filterClassFetchMethod) {
- this.filterClassFetchMethod = filterClassFetchMethod;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/HttpFilterClassFetchMethod.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/HttpFilterClassFetchMethod.java b/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/HttpFilterClassFetchMethod.java
deleted file mode 100644
index 88cb572..0000000
--- a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/filter/HttpFilterClassFetchMethod.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * 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.filtersrv.filter;
-
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.utils.HttpTinyClient;
-import com.alibaba.rocketmq.common.utils.HttpTinyClient.HttpResult;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class HttpFilterClassFetchMethod implements FilterClassFetchMethod {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
- private final String url;
-
-
- public HttpFilterClassFetchMethod(String url) {
- this.url = url;
- }
-
-
- @Override
- public String fetch(String topic, String consumerGroup, String className) {
- String thisUrl = String.format("%s/%s.java", this.url, className);
-
- try {
- HttpResult result = HttpTinyClient.httpGet(thisUrl, null, null, "UTF-8", 5000);
- if (200 == result.code) {
- return result.content;
- }
- } catch (Exception e) {
- log.error(
- String.format("call <%s> exception, Topic: %s Group: %s", thisUrl, topic, consumerGroup), e);
- }
-
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/processor/DefaultRequestProcessor.java b/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
deleted file mode 100644
index 105cfff..0000000
--- a/filtersrv/src/main/java/com/alibaba/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/**
- * 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.filtersrv.processor;
-
-import com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer;
-import com.alibaba.rocketmq.client.consumer.PullCallback;
-import com.alibaba.rocketmq.client.consumer.PullResult;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.filter.FilterContext;
-import com.alibaba.rocketmq.common.message.MessageDecoder;
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.RequestCode;
-import com.alibaba.rocketmq.common.protocol.ResponseCode;
-import com.alibaba.rocketmq.common.protocol.header.PullMessageRequestHeader;
-import com.alibaba.rocketmq.common.protocol.header.PullMessageResponseHeader;
-import com.alibaba.rocketmq.common.protocol.header.filtersrv.RegisterMessageFilterClassRequestHeader;
-import com.alibaba.rocketmq.common.sysflag.MessageSysFlag;
-import com.alibaba.rocketmq.filtersrv.FiltersrvController;
-import com.alibaba.rocketmq.filtersrv.filter.FilterClassInfo;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-import com.alibaba.rocketmq.remoting.netty.NettyRequestProcessor;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import com.alibaba.rocketmq.store.CommitLog;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelFutureListener;
-import io.netty.channel.ChannelHandlerContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public class DefaultRequestProcessor implements NettyRequestProcessor {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
-
- private final FiltersrvController filtersrvController;
-
-
- public DefaultRequestProcessor(FiltersrvController filtersrvController) {
- this.filtersrvController = filtersrvController;
- }
-
-
- @Override
- public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws Exception {
- if (log.isDebugEnabled()) {
- log.debug("receive request, {} {} {}",
- request.getCode(),
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
- request);
- }
-
- switch (request.getCode()) {
- case RequestCode.REGISTER_MESSAGE_FILTER_CLASS:
- return registerMessageFilterClass(ctx, request);
- case RequestCode.PULL_MESSAGE:
- return pullMessageForward(ctx, request);
- }
-
- return null;
- }
-
- @Override
- public boolean rejectRequest() {
- return false;
- }
-
- private RemotingCommand registerMessageFilterClass(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- final RegisterMessageFilterClassRequestHeader requestHeader =
- (RegisterMessageFilterClassRequestHeader) request.decodeCommandCustomHeader(RegisterMessageFilterClassRequestHeader.class);
-
- try {
- boolean ok = this.filtersrvController.getFilterClassManager().registerFilterClass(requestHeader.getConsumerGroup(),
- requestHeader.getTopic(),
- requestHeader.getClassName(),
- requestHeader.getClassCRC(),
- request.getBody());
- if (!ok) {
- throw new Exception("registerFilterClass error");
- }
- } catch (Exception e) {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark(RemotingHelper.exceptionSimpleDesc(e));
- return response;
- }
-
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand pullMessageForward(final ChannelHandlerContext ctx, final RemotingCommand request) throws Exception {
- final RemotingCommand response = RemotingCommand.createResponseCommand(PullMessageResponseHeader.class);
- final PullMessageResponseHeader responseHeader = (PullMessageResponseHeader) response.readCustomHeader();
- final PullMessageRequestHeader requestHeader =
- (PullMessageRequestHeader) request.decodeCommandCustomHeader(PullMessageRequestHeader.class);
-
- final FilterContext filterContext = new FilterContext();
- filterContext.setConsumerGroup(requestHeader.getConsumerGroup());
-
-
- response.setOpaque(request.getOpaque());
-
- DefaultMQPullConsumer pullConsumer = this.filtersrvController.getDefaultMQPullConsumer();
- final FilterClassInfo findFilterClass =
- this.filtersrvController.getFilterClassManager()
- .findFilterClass(requestHeader.getConsumerGroup(), requestHeader.getTopic());
- if (null == findFilterClass) {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("Find Filter class failed, not registered");
- return response;
- }
-
- if (null == findFilterClass.getMessageFilter()) {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("Find Filter class failed, registered but no class");
- return response;
- }
-
- responseHeader.setSuggestWhichBrokerId(MixAll.MASTER_ID);
-
-
- MessageQueue mq = new MessageQueue();
- mq.setTopic(requestHeader.getTopic());
- mq.setQueueId(requestHeader.getQueueId());
- mq.setBrokerName(this.filtersrvController.getBrokerName());
- long offset = requestHeader.getQueueOffset();
- int maxNums = requestHeader.getMaxMsgNums();
-
- final PullCallback pullCallback = new PullCallback() {
-
- @Override
- public void onSuccess(PullResult pullResult) {
- responseHeader.setMaxOffset(pullResult.getMaxOffset());
- responseHeader.setMinOffset(pullResult.getMinOffset());
- responseHeader.setNextBeginOffset(pullResult.getNextBeginOffset());
- response.setRemark(null);
-
- switch (pullResult.getPullStatus()) {
- case FOUND:
- response.setCode(ResponseCode.SUCCESS);
-
- List<MessageExt> msgListOK = new ArrayList<MessageExt>();
- try {
- for (MessageExt msg : pullResult.getMsgFoundList()) {
- boolean match = findFilterClass.getMessageFilter().match(msg, filterContext);
- if (match) {
- msgListOK.add(msg);
- }
- }
-
-
- if (!msgListOK.isEmpty()) {
- returnResponse(requestHeader.getConsumerGroup(), requestHeader.getTopic(), ctx, response, msgListOK);
- return;
- } else {
- response.setCode(ResponseCode.PULL_RETRY_IMMEDIATELY);
- }
- } catch (Throwable e) {
- final String error =
- String.format("do Message Filter Exception, ConsumerGroup: %s Topic: %s ",
- requestHeader.getConsumerGroup(), requestHeader.getTopic());
- log.error(error, e);
-
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark(error + RemotingHelper.exceptionSimpleDesc(e));
- returnResponse(requestHeader.getConsumerGroup(), requestHeader.getTopic(), ctx, response, null);
- return;
- }
-
- break;
- case NO_MATCHED_MSG:
- response.setCode(ResponseCode.PULL_RETRY_IMMEDIATELY);
- break;
- case NO_NEW_MSG:
- response.setCode(ResponseCode.PULL_NOT_FOUND);
- break;
- case OFFSET_ILLEGAL:
- response.setCode(ResponseCode.PULL_OFFSET_MOVED);
- break;
- default:
- break;
- }
-
- returnResponse(requestHeader.getConsumerGroup(), requestHeader.getTopic(), ctx, response, null);
- }
-
-
- @Override
- public void onException(Throwable e) {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("Pull Callback Exception, " + RemotingHelper.exceptionSimpleDesc(e));
- returnResponse(requestHeader.getConsumerGroup(), requestHeader.getTopic(), ctx, response, null);
- return;
- }
- };
-
- pullConsumer.pullBlockIfNotFound(mq, null, offset, maxNums, pullCallback);
-
- return null;
- }
-
- private void returnResponse(final String group, final String topic, ChannelHandlerContext ctx, final RemotingCommand response,
- final List<MessageExt> msgList) {
- if (null != msgList) {
- ByteBuffer[] msgBufferList = new ByteBuffer[msgList.size()];
- int bodyTotalSize = 0;
- for (int i = 0; i < msgList.size(); i++) {
- try {
- msgBufferList[i] = messageToByteBuffer(msgList.get(i));
- bodyTotalSize += msgBufferList[i].capacity();
- } catch (Exception e) {
- log.error("messageToByteBuffer UnsupportedEncodingException", e);
- }
- }
-
- ByteBuffer body = ByteBuffer.allocate(bodyTotalSize);
- for (ByteBuffer bb : msgBufferList) {
- bb.flip();
- body.put(bb);
- }
-
- response.setBody(body.array());
-
-
- this.filtersrvController.getFilterServerStatsManager().incGroupGetNums(group, topic, msgList.size());
-
- this.filtersrvController.getFilterServerStatsManager().incGroupGetSize(group, topic, bodyTotalSize);
- }
-
- try {
- ctx.writeAndFlush(response).addListener(new ChannelFutureListener() {
- @Override
- public void operationComplete(ChannelFuture future) throws Exception {
- if (!future.isSuccess()) {
- log.error("FilterServer response to " + future.channel().remoteAddress() + " failed", future.cause());
- log.error(response.toString());
- }
- }
- });
- } catch (Throwable e) {
- log.error("FilterServer process request over, but response failed", e);
- log.error(response.toString());
- }
- }
-
- private ByteBuffer messageToByteBuffer(final MessageExt msg) throws IOException {
- int sysFlag = MessageSysFlag.clearCompressedFlag(msg.getSysFlag());
- if (msg.getBody() != null) {
- if (msg.getBody().length >= this.filtersrvController.getFiltersrvConfig().getCompressMsgBodyOverHowmuch()) {
- byte[] data = UtilAll.compress(msg.getBody(), this.filtersrvController.getFiltersrvConfig().getZipCompressLevel());
- if (data != null) {
- msg.setBody(data);
- sysFlag |= MessageSysFlag.COMPRESSED_FLAG;
- }
- }
- }
-
- final int bodyLength = msg.getBody() != null ? msg.getBody().length : 0;
- byte[] topicData = msg.getTopic().getBytes(MixAll.DEFAULT_CHARSET);
- final int topicLength = topicData.length;
- String properties = MessageDecoder.messageProperties2String(msg.getProperties());
- byte[] propertiesData = properties.getBytes(MixAll.DEFAULT_CHARSET);
- final int propertiesLength = propertiesData.length;
- final int msgLen = 4 // 1 TOTALSIZE
- + 4 // 2 MAGICCODE
- + 4 // 3 BODYCRC
- + 4 // 4 QUEUEID
- + 4 // 5 FLAG
- + 8 // 6 QUEUEOFFSET
- + 8 // 7 PHYSICALOFFSET
- + 4 // 8 SYSFLAG
- + 8 // 9 BORNTIMESTAMP
- + 8 // 10 BORNHOST
- + 8 // 11 STORETIMESTAMP
- + 8 // 12 STOREHOSTADDRESS
- + 4 // 13 RECONSUMETIMES
- + 8 // 14 Prepared Transaction Offset
- + 4 + bodyLength // 14 BODY
- + 1 + topicLength // 15 TOPIC
- + 2 + propertiesLength // 16 propertiesLength
- + 0;
-
- ByteBuffer msgStoreItemMemory = ByteBuffer.allocate(msgLen);
-
- final MessageExt msgInner = msg;
-
- // 1 TOTALSIZE
- msgStoreItemMemory.putInt(msgLen);
- // 2 MAGICCODE
- msgStoreItemMemory.putInt(CommitLog.MESSAGE_MAGIC_CODE);
- // 3 BODYCRC
- msgStoreItemMemory.putInt(UtilAll.crc32(msgInner.getBody()));
- // 4 QUEUEID
- msgStoreItemMemory.putInt(msgInner.getQueueId());
- // 5 FLAG
- msgStoreItemMemory.putInt(msgInner.getFlag());
- // 6 QUEUEOFFSET
- msgStoreItemMemory.putLong(msgInner.getQueueOffset());
- // 7 PHYSICALOFFSET
- msgStoreItemMemory.putLong(msgInner.getCommitLogOffset());
- // 8 SYSFLAG
- msgStoreItemMemory.putInt(sysFlag);
- // 9 BORNTIMESTAMP
- msgStoreItemMemory.putLong(msgInner.getBornTimestamp());
- // 10 BORNHOST
- msgStoreItemMemory.put(msgInner.getBornHostBytes());
- // 11 STORETIMESTAMP
- msgStoreItemMemory.putLong(msgInner.getStoreTimestamp());
- // 12 STOREHOSTADDRESS
- msgStoreItemMemory.put(msgInner.getStoreHostBytes());
- // 13 RECONSUMETIMES
- msgStoreItemMemory.putInt(msgInner.getReconsumeTimes());
- // 14 Prepared Transaction Offset
- msgStoreItemMemory.putLong(msgInner.getPreparedTransactionOffset());
- // 15 BODY
- msgStoreItemMemory.putInt(bodyLength);
- if (bodyLength > 0)
- msgStoreItemMemory.put(msgInner.getBody());
- // 16 TOPIC
- msgStoreItemMemory.put((byte) topicLength);
- msgStoreItemMemory.put(topicData);
- // 17 PROPERTIES
- msgStoreItemMemory.putShort((short) propertiesLength);
- if (propertiesLength > 0)
- msgStoreItemMemory.put(propertiesData);
-
- return msgStoreItemMemory;
- }
-}
[69/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/store/src/test/resources/logback-test.xml b/store/src/test/resources/logback-test.xml
index 25fc615..752ad59 100644
--- a/store/src/test/resources/logback-test.xml
+++ b/store/src/test/resources/logback-test.xml
@@ -17,19 +17,19 @@
-->
<configuration>
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
- <charset class="java.nio.charset.Charset">UTF-8</charset>
- </encoder>
- </appender>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
+ <charset class="java.nio.charset.Charset">UTF-8</charset>
+ </encoder>
+ </appender>
- <logger name="org.apache.rocketmq.store" level="WARN" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
+ <logger name="org.apache.rocketmq.store" level="WARN" additivity="false">
+ <appender-ref ref="STDOUT"/>
+ </logger>
- <root level="ERROR">
- <appender-ref ref="STDOUT" />
- </root>
+ <root level="ERROR">
+ <appender-ref ref="STDOUT"/>
+ </root>
</configuration>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/style/copyright/Apache.xml
----------------------------------------------------------------------
diff --git a/style/copyright/Apache.xml b/style/copyright/Apache.xml
index f728d8a..d54449b 100644
--- a/style/copyright/Apache.xml
+++ b/style/copyright/Apache.xml
@@ -1,6 +1,7 @@
<component name="CopyrightManager">
- <copyright>
- <option name="myName" value="Apache" />
- <option name="notice" value="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." />
- </copyright>
+ <copyright>
+ <option name="myName" value="Apache"/>
+ <option name="notice"
+ value="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."/>
+ </copyright>
</component>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/style/copyright/profiles_settings.xml
----------------------------------------------------------------------
diff --git a/style/copyright/profiles_settings.xml b/style/copyright/profiles_settings.xml
index 0cba723..d75ac23 100644
--- a/style/copyright/profiles_settings.xml
+++ b/style/copyright/profiles_settings.xml
@@ -1,44 +1,44 @@
<component name="CopyrightManager">
- <settings default="Apache">
- <module2copyright>
- <element module="All" copyright="Apache" />
- </module2copyright>
- <LanguageOptions name="GSP">
- <option name="fileTypeOverride" value="3" />
- <option name="prefixLines" value="false" />
- </LanguageOptions>
- <LanguageOptions name="HTML">
- <option name="fileTypeOverride" value="3" />
- <option name="prefixLines" value="false" />
- </LanguageOptions>
- <LanguageOptions name="JAVA" />
- <LanguageOptions name="JSP">
- <option name="fileTypeOverride" value="3" />
- <option name="prefixLines" value="false" />
- </LanguageOptions>
- <LanguageOptions name="JSPX">
- <option name="fileTypeOverride" value="3" />
- <option name="prefixLines" value="false" />
- </LanguageOptions>
- <LanguageOptions name="MXML">
- <option name="fileTypeOverride" value="3" />
- <option name="prefixLines" value="false" />
- </LanguageOptions>
- <LanguageOptions name="Properties">
- <option name="fileTypeOverride" value="3" />
- <option name="block" value="false" />
- </LanguageOptions>
- <LanguageOptions name="SPI">
- <option name="fileTypeOverride" value="3" />
- <option name="block" value="false" />
- </LanguageOptions>
- <LanguageOptions name="XML">
- <option name="fileTypeOverride" value="3" />
- <option name="prefixLines" value="false" />
- </LanguageOptions>
- <LanguageOptions name="__TEMPLATE__">
- <option name="separateBefore" value="true" />
- <option name="lenBefore" value="1" />
- </LanguageOptions>
- </settings>
+ <settings default="Apache">
+ <module2copyright>
+ <element module="All" copyright="Apache"/>
+ </module2copyright>
+ <LanguageOptions name="GSP">
+ <option name="fileTypeOverride" value="3"/>
+ <option name="prefixLines" value="false"/>
+ </LanguageOptions>
+ <LanguageOptions name="HTML">
+ <option name="fileTypeOverride" value="3"/>
+ <option name="prefixLines" value="false"/>
+ </LanguageOptions>
+ <LanguageOptions name="JAVA"/>
+ <LanguageOptions name="JSP">
+ <option name="fileTypeOverride" value="3"/>
+ <option name="prefixLines" value="false"/>
+ </LanguageOptions>
+ <LanguageOptions name="JSPX">
+ <option name="fileTypeOverride" value="3"/>
+ <option name="prefixLines" value="false"/>
+ </LanguageOptions>
+ <LanguageOptions name="MXML">
+ <option name="fileTypeOverride" value="3"/>
+ <option name="prefixLines" value="false"/>
+ </LanguageOptions>
+ <LanguageOptions name="Properties">
+ <option name="fileTypeOverride" value="3"/>
+ <option name="block" value="false"/>
+ </LanguageOptions>
+ <LanguageOptions name="SPI">
+ <option name="fileTypeOverride" value="3"/>
+ <option name="block" value="false"/>
+ </LanguageOptions>
+ <LanguageOptions name="XML">
+ <option name="fileTypeOverride" value="3"/>
+ <option name="prefixLines" value="false"/>
+ </LanguageOptions>
+ <LanguageOptions name="__TEMPLATE__">
+ <option name="separateBefore" value="true"/>
+ <option name="lenBefore" value="1"/>
+ </LanguageOptions>
+ </settings>
</component>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/style/rmq_codeStyle.xml
----------------------------------------------------------------------
diff --git a/style/rmq_codeStyle.xml b/style/rmq_codeStyle.xml
index e6a9b7d..a2872f0 100644
--- a/style/rmq_codeStyle.xml
+++ b/style/rmq_codeStyle.xml
@@ -1,140 +1,140 @@
<code_scheme name="rocketmq">
- <option name="USE_SAME_INDENTS" value="true" />
- <option name="IGNORE_SAME_INDENTS_FOR_LANGUAGES" value="true" />
+ <option name="USE_SAME_INDENTS" value="true"/>
+ <option name="IGNORE_SAME_INDENTS_FOR_LANGUAGES" value="true"/>
<option name="OTHER_INDENT_OPTIONS">
<value>
- <option name="INDENT_SIZE" value="4" />
- <option name="CONTINUATION_INDENT_SIZE" value="4" />
- <option name="TAB_SIZE" value="4" />
- <option name="USE_TAB_CHARACTER" value="false" />
- <option name="SMART_TABS" value="false" />
- <option name="LABEL_INDENT_SIZE" value="0" />
- <option name="LABEL_INDENT_ABSOLUTE" value="false" />
- <option name="USE_RELATIVE_INDENTS" value="false" />
+ <option name="INDENT_SIZE" value="4"/>
+ <option name="CONTINUATION_INDENT_SIZE" value="4"/>
+ <option name="TAB_SIZE" value="4"/>
+ <option name="USE_TAB_CHARACTER" value="false"/>
+ <option name="SMART_TABS" value="false"/>
+ <option name="LABEL_INDENT_SIZE" value="0"/>
+ <option name="LABEL_INDENT_ABSOLUTE" value="false"/>
+ <option name="USE_RELATIVE_INDENTS" value="false"/>
</value>
</option>
- <option name="PREFER_LONGER_NAMES" value="false" />
- <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="1000" />
- <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="1000" />
+ <option name="PREFER_LONGER_NAMES" value="false"/>
+ <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="1000"/>
+ <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="1000"/>
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
- <value />
+ <value/>
</option>
<option name="IMPORT_LAYOUT_TABLE">
<value>
- <package name="" withSubpackages="true" static="false" />
- <emptyLine />
- <package name="" withSubpackages="true" static="true" />
+ <package name="" withSubpackages="true" static="false"/>
+ <emptyLine/>
+ <package name="" withSubpackages="true" static="true"/>
</value>
</option>
- <option name="JD_ALIGN_PARAM_COMMENTS" value="false" />
- <option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false" />
- <option name="JD_P_AT_EMPTY_LINES" value="false" />
- <option name="JD_KEEP_INVALID_TAGS" value="false" />
- <option name="JD_DO_NOT_WRAP_ONE_LINE_COMMENTS" value="true" />
- <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
- <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
- <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
- <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
- <option name="ELSE_ON_NEW_LINE" value="true" />
- <option name="WHILE_ON_NEW_LINE" value="true" />
- <option name="CATCH_ON_NEW_LINE" value="true" />
- <option name="FINALLY_ON_NEW_LINE" value="true" />
- <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
- <option name="ALIGN_MULTILINE_FOR" value="false" />
- <option name="SPACE_AFTER_TYPE_CAST" value="false" />
- <option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" />
- <option name="METHOD_PARAMETERS_WRAP" value="1" />
- <option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
- <option name="LABELED_STATEMENT_WRAP" value="1" />
- <option name="WRAP_COMMENTS" value="true" />
- <option name="METHOD_ANNOTATION_WRAP" value="1" />
- <option name="CLASS_ANNOTATION_WRAP" value="1" />
- <option name="FIELD_ANNOTATION_WRAP" value="1" />
+ <option name="JD_ALIGN_PARAM_COMMENTS" value="false"/>
+ <option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false"/>
+ <option name="JD_P_AT_EMPTY_LINES" value="false"/>
+ <option name="JD_KEEP_INVALID_TAGS" value="false"/>
+ <option name="JD_DO_NOT_WRAP_ONE_LINE_COMMENTS" value="true"/>
+ <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false"/>
+ <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1"/>
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1"/>
+ <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1"/>
+ <option name="ELSE_ON_NEW_LINE" value="true"/>
+ <option name="WHILE_ON_NEW_LINE" value="true"/>
+ <option name="CATCH_ON_NEW_LINE" value="true"/>
+ <option name="FINALLY_ON_NEW_LINE" value="true"/>
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false"/>
+ <option name="ALIGN_MULTILINE_FOR" value="false"/>
+ <option name="SPACE_AFTER_TYPE_CAST" value="false"/>
+ <option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true"/>
+ <option name="METHOD_PARAMETERS_WRAP" value="1"/>
+ <option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true"/>
+ <option name="LABELED_STATEMENT_WRAP" value="1"/>
+ <option name="WRAP_COMMENTS" value="true"/>
+ <option name="METHOD_ANNOTATION_WRAP" value="1"/>
+ <option name="CLASS_ANNOTATION_WRAP" value="1"/>
+ <option name="FIELD_ANNOTATION_WRAP" value="1"/>
<JavaCodeStyleSettings>
- <option name="CLASS_NAMES_IN_JAVADOC" value="3" />
+ <option name="CLASS_NAMES_IN_JAVADOC" value="3"/>
</JavaCodeStyleSettings>
<XML>
- <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
+ <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true"/>
</XML>
<ADDITIONAL_INDENT_OPTIONS fileType="haml">
- <option name="INDENT_SIZE" value="2" />
+ <option name="INDENT_SIZE" value="2"/>
</ADDITIONAL_INDENT_OPTIONS>
<codeStyleSettings language="Groovy">
- <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
- <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
- <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
- <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
- <option name="ELSE_ON_NEW_LINE" value="true" />
- <option name="CATCH_ON_NEW_LINE" value="true" />
- <option name="FINALLY_ON_NEW_LINE" value="true" />
- <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
- <option name="ALIGN_MULTILINE_FOR" value="false" />
- <option name="SPACE_AFTER_TYPE_CAST" value="false" />
- <option name="METHOD_PARAMETERS_WRAP" value="1" />
- <option name="METHOD_ANNOTATION_WRAP" value="1" />
- <option name="CLASS_ANNOTATION_WRAP" value="1" />
- <option name="FIELD_ANNOTATION_WRAP" value="1" />
- <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false"/>
+ <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1"/>
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1"/>
+ <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1"/>
+ <option name="ELSE_ON_NEW_LINE" value="true"/>
+ <option name="CATCH_ON_NEW_LINE" value="true"/>
+ <option name="FINALLY_ON_NEW_LINE" value="true"/>
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false"/>
+ <option name="ALIGN_MULTILINE_FOR" value="false"/>
+ <option name="SPACE_AFTER_TYPE_CAST" value="false"/>
+ <option name="METHOD_PARAMETERS_WRAP" value="1"/>
+ <option name="METHOD_ANNOTATION_WRAP" value="1"/>
+ <option name="CLASS_ANNOTATION_WRAP" value="1"/>
+ <option name="FIELD_ANNOTATION_WRAP" value="1"/>
+ <option name="PARENT_SETTINGS_INSTALLED" value="true"/>
<indentOptions>
- <option name="CONTINUATION_INDENT_SIZE" value="4" />
+ <option name="CONTINUATION_INDENT_SIZE" value="4"/>
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="HOCON">
- <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
- <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1"/>
+ <option name="PARENT_SETTINGS_INSTALLED" value="true"/>
</codeStyleSettings>
<codeStyleSettings language="JAVA">
- <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
- <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
- <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
- <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
- <option name="ELSE_ON_NEW_LINE" value="true" />
- <option name="WHILE_ON_NEW_LINE" value="true" />
- <option name="CATCH_ON_NEW_LINE" value="true" />
- <option name="FINALLY_ON_NEW_LINE" value="true" />
- <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
- <option name="ALIGN_MULTILINE_FOR" value="false" />
- <option name="SPACE_AFTER_TYPE_CAST" value="false" />
- <option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" />
- <option name="METHOD_PARAMETERS_WRAP" value="1" />
- <option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
- <option name="LABELED_STATEMENT_WRAP" value="1" />
- <option name="METHOD_ANNOTATION_WRAP" value="1" />
- <option name="CLASS_ANNOTATION_WRAP" value="1" />
- <option name="FIELD_ANNOTATION_WRAP" value="1" />
- <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false"/>
+ <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1"/>
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1"/>
+ <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1"/>
+ <option name="ELSE_ON_NEW_LINE" value="true"/>
+ <option name="WHILE_ON_NEW_LINE" value="true"/>
+ <option name="CATCH_ON_NEW_LINE" value="true"/>
+ <option name="FINALLY_ON_NEW_LINE" value="true"/>
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false"/>
+ <option name="ALIGN_MULTILINE_FOR" value="false"/>
+ <option name="SPACE_AFTER_TYPE_CAST" value="false"/>
+ <option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true"/>
+ <option name="METHOD_PARAMETERS_WRAP" value="1"/>
+ <option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true"/>
+ <option name="LABELED_STATEMENT_WRAP" value="1"/>
+ <option name="METHOD_ANNOTATION_WRAP" value="1"/>
+ <option name="CLASS_ANNOTATION_WRAP" value="1"/>
+ <option name="FIELD_ANNOTATION_WRAP" value="1"/>
+ <option name="PARENT_SETTINGS_INSTALLED" value="true"/>
<indentOptions>
- <option name="CONTINUATION_INDENT_SIZE" value="4" />
+ <option name="CONTINUATION_INDENT_SIZE" value="4"/>
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="JSON">
- <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
- <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1"/>
+ <option name="PARENT_SETTINGS_INSTALLED" value="true"/>
</codeStyleSettings>
<codeStyleSettings language="Scala">
- <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
- <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
- <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
- <option name="ELSE_ON_NEW_LINE" value="true" />
- <option name="WHILE_ON_NEW_LINE" value="true" />
- <option name="CATCH_ON_NEW_LINE" value="true" />
- <option name="FINALLY_ON_NEW_LINE" value="true" />
- <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
- <option name="ALIGN_MULTILINE_FOR" value="false" />
- <option name="METHOD_PARAMETERS_WRAP" value="1" />
- <option name="METHOD_ANNOTATION_WRAP" value="1" />
- <option name="CLASS_ANNOTATION_WRAP" value="1" />
- <option name="FIELD_ANNOTATION_WRAP" value="1" />
- <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+ <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1"/>
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1"/>
+ <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1"/>
+ <option name="ELSE_ON_NEW_LINE" value="true"/>
+ <option name="WHILE_ON_NEW_LINE" value="true"/>
+ <option name="CATCH_ON_NEW_LINE" value="true"/>
+ <option name="FINALLY_ON_NEW_LINE" value="true"/>
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false"/>
+ <option name="ALIGN_MULTILINE_FOR" value="false"/>
+ <option name="METHOD_PARAMETERS_WRAP" value="1"/>
+ <option name="METHOD_ANNOTATION_WRAP" value="1"/>
+ <option name="CLASS_ANNOTATION_WRAP" value="1"/>
+ <option name="FIELD_ANNOTATION_WRAP" value="1"/>
+ <option name="PARENT_SETTINGS_INSTALLED" value="true"/>
<indentOptions>
- <option name="INDENT_SIZE" value="4" />
- <option name="CONTINUATION_INDENT_SIZE" value="4" />
- <option name="TAB_SIZE" value="4" />
+ <option name="INDENT_SIZE" value="4"/>
+ <option name="CONTINUATION_INDENT_SIZE" value="4"/>
+ <option name="TAB_SIZE" value="4"/>
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="XML">
<indentOptions>
- <option name="CONTINUATION_INDENT_SIZE" value="4" />
+ <option name="CONTINUATION_INDENT_SIZE" value="4"/>
</indentOptions>
</codeStyleSettings>
</code_scheme>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/pom.xml
----------------------------------------------------------------------
diff --git a/tools/pom.xml b/tools/pom.xml
index aa05fea..d80beae 100644
--- a/tools/pom.xml
+++ b/tools/pom.xml
@@ -15,7 +15,7 @@
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.rocketmq</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java
index c6a80b0..e8751bd 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java
@@ -16,6 +16,11 @@
*/
package org.apache.rocketmq.tools.admin;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
import org.apache.rocketmq.client.ClientConfig;
import org.apache.rocketmq.client.QueryResult;
import org.apache.rocketmq.client.exception.MQBrokerException;
@@ -27,19 +32,28 @@ import org.apache.rocketmq.common.admin.RollbackStats;
import org.apache.rocketmq.common.admin.TopicStatsTable;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.message.MessageQueue;
-import org.apache.rocketmq.common.protocol.body.*;
+import org.apache.rocketmq.common.protocol.body.BrokerStatsData;
+import org.apache.rocketmq.common.protocol.body.ClusterInfo;
+import org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
+import org.apache.rocketmq.common.protocol.body.ConsumeStatsList;
+import org.apache.rocketmq.common.protocol.body.ConsumerConnection;
+import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
+import org.apache.rocketmq.common.protocol.body.GroupList;
+import org.apache.rocketmq.common.protocol.body.KVTable;
+import org.apache.rocketmq.common.protocol.body.ProducerConnection;
+import org.apache.rocketmq.common.protocol.body.QueueTimeSpan;
+import org.apache.rocketmq.common.protocol.body.SubscriptionGroupWrapper;
+import org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper;
+import org.apache.rocketmq.common.protocol.body.TopicList;
import org.apache.rocketmq.common.protocol.route.TopicRouteData;
import org.apache.rocketmq.common.subscription.SubscriptionGroupConfig;
import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.exception.RemotingConnectException;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
+import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
import org.apache.rocketmq.tools.admin.api.MessageTrack;
-import org.apache.rocketmq.remoting.exception.*;
-
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
private final DefaultMQAdminExtImpl defaultMQAdminExtImpl;
@@ -93,7 +107,6 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
return defaultMQAdminExtImpl.maxOffset(mq);
}
-
@Override
public long minOffset(MessageQueue mq) throws MQClientException {
return defaultMQAdminExtImpl.minOffset(mq);
@@ -111,7 +124,7 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
@Override
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end) throws MQClientException,
- InterruptedException {
+ InterruptedException {
return defaultMQAdminExtImpl.queryMessage(topic, key, maxNum, begin, end);
}
@@ -127,25 +140,25 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
@Override
public void updateBrokerConfig(String brokerAddr, Properties properties) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, UnsupportedEncodingException, InterruptedException, MQBrokerException {
+ RemotingTimeoutException, UnsupportedEncodingException, InterruptedException, MQBrokerException {
defaultMQAdminExtImpl.updateBrokerConfig(brokerAddr, properties);
}
@Override
public Properties getBrokerConfig(final String brokerAddr) throws RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException, UnsupportedEncodingException, InterruptedException, MQBrokerException {
+ RemotingSendRequestException, RemotingTimeoutException, UnsupportedEncodingException, InterruptedException, MQBrokerException {
return defaultMQAdminExtImpl.getBrokerConfig(brokerAddr);
}
@Override
public void createAndUpdateTopicConfig(String addr, TopicConfig config) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException {
+ InterruptedException, MQClientException {
defaultMQAdminExtImpl.createAndUpdateTopicConfig(addr, config);
}
@Override
public void createAndUpdateSubscriptionGroupConfig(String addr, SubscriptionGroupConfig config) throws RemotingException,
- MQBrokerException, InterruptedException, MQClientException {
+ MQBrokerException, InterruptedException, MQClientException {
defaultMQAdminExtImpl.createAndUpdateSubscriptionGroupConfig(addr, config);
}
@@ -161,7 +174,7 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
@Override
public TopicStatsTable examineTopicStats(String topic) throws RemotingException, MQClientException, InterruptedException,
- MQBrokerException {
+ MQBrokerException {
return defaultMQAdminExtImpl.examineTopicStats(topic);
}
@@ -177,25 +190,25 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
@Override
public KVTable fetchBrokerRuntimeStats(final String brokerAddr) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, InterruptedException, MQBrokerException {
+ RemotingTimeoutException, InterruptedException, MQBrokerException {
return this.defaultMQAdminExtImpl.fetchBrokerRuntimeStats(brokerAddr);
}
@Override
public ConsumeStats examineConsumeStats(String consumerGroup) throws RemotingException, MQClientException, InterruptedException,
- MQBrokerException {
+ MQBrokerException {
return examineConsumeStats(consumerGroup, null);
}
@Override
public ConsumeStats examineConsumeStats(String consumerGroup, String topic) throws RemotingException, MQClientException,
- InterruptedException, MQBrokerException {
+ InterruptedException, MQBrokerException {
return defaultMQAdminExtImpl.examineConsumeStats(consumerGroup, topic);
}
@Override
public ClusterInfo examineBrokerClusterInfo() throws InterruptedException, RemotingConnectException, RemotingTimeoutException,
- RemotingSendRequestException, MQBrokerException {
+ RemotingSendRequestException, MQBrokerException {
return defaultMQAdminExtImpl.examineBrokerClusterInfo();
}
@@ -206,13 +219,13 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
@Override
public ConsumerConnection examineConsumerConnectionInfo(String consumerGroup) throws InterruptedException, MQBrokerException,
- RemotingException, MQClientException {
+ RemotingException, MQClientException {
return defaultMQAdminExtImpl.examineConsumerConnectionInfo(consumerGroup);
}
@Override
public ProducerConnection examineProducerConnectionInfo(String producerGroup, final String topic) throws RemotingException,
- MQClientException, InterruptedException, MQBrokerException {
+ MQClientException, InterruptedException, MQBrokerException {
return defaultMQAdminExtImpl.examineProducerConnectionInfo(producerGroup, topic);
}
@@ -223,7 +236,7 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
@Override
public int wipeWritePermOfBroker(final String namesrvAddr, String brokerName) throws RemotingCommandException,
- RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQClientException {
+ RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQClientException {
return defaultMQAdminExtImpl.wipeWritePermOfBroker(namesrvAddr, brokerName);
}
@@ -244,148 +257,150 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
@Override
public void deleteTopicInBroker(Set<String> addrs, String topic) throws RemotingException, MQBrokerException, InterruptedException,
- MQClientException {
+ MQClientException {
defaultMQAdminExtImpl.deleteTopicInBroker(addrs, topic);
}
@Override
public void deleteTopicInNameServer(Set<String> addrs, String topic) throws RemotingException, MQBrokerException, InterruptedException,
- MQClientException {
+ MQClientException {
defaultMQAdminExtImpl.deleteTopicInNameServer(addrs, topic);
}
@Override
public void deleteSubscriptionGroup(String addr, String groupName) throws RemotingException, MQBrokerException, InterruptedException,
- MQClientException {
+ MQClientException {
defaultMQAdminExtImpl.deleteSubscriptionGroup(addr, groupName);
}
@Override
public void createAndUpdateKvConfig(String namespace, String key, String value) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException {
+ InterruptedException, MQClientException {
defaultMQAdminExtImpl.createAndUpdateKvConfig(namespace, key, value);
}
@Override
public void deleteKvConfig(String namespace, String key) throws RemotingException, MQBrokerException, InterruptedException,
- MQClientException {
+ MQClientException {
defaultMQAdminExtImpl.deleteKvConfig(namespace, key);
}
public List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp, boolean force)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
return defaultMQAdminExtImpl.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, force);
}
@Override
public Map<MessageQueue, Long> resetOffsetByTimestamp(String topic, String group, long timestamp, boolean isForce)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
return resetOffsetByTimestamp(topic, group, timestamp, isForce, false);
}
public Map<MessageQueue, Long> resetOffsetByTimestamp(String topic, String group, long timestamp, boolean isForce, boolean isC)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
return defaultMQAdminExtImpl.resetOffsetByTimestamp(topic, group, timestamp, isForce, isC);
}
@Override
public void resetOffsetNew(String consumerGroup, String topic, long timestamp) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException {
+ InterruptedException, MQClientException {
this.defaultMQAdminExtImpl.resetOffsetNew(consumerGroup, topic, timestamp);
}
@Override
public Map<String, Map<MessageQueue, Long>> getConsumeStatus(String topic, String group, String clientAddr) throws RemotingException,
- MQBrokerException, InterruptedException, MQClientException {
+ MQBrokerException, InterruptedException, MQClientException {
return defaultMQAdminExtImpl.getConsumeStatus(topic, group, clientAddr);
}
@Override
public void createOrUpdateOrderConf(String key, String value, boolean isCluster) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException {
+ InterruptedException, MQClientException {
defaultMQAdminExtImpl.createOrUpdateOrderConf(key, value, isCluster);
}
@Override
public GroupList queryTopicConsumeByWho(String topic) throws InterruptedException, MQBrokerException, RemotingException,
- MQClientException {
+ MQClientException {
return this.defaultMQAdminExtImpl.queryTopicConsumeByWho(topic);
}
@Override
public List<QueueTimeSpan> queryConsumeTimeSpan(final String topic, final String group) throws InterruptedException, MQBrokerException,
- RemotingException, MQClientException {
+ RemotingException, MQClientException {
return this.defaultMQAdminExtImpl.queryConsumeTimeSpan(topic, group);
}
@Override
public boolean cleanExpiredConsumerQueue(String cluster) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, MQClientException, InterruptedException {
+ RemotingTimeoutException, MQClientException, InterruptedException {
return defaultMQAdminExtImpl.cleanExpiredConsumerQueue(cluster);
}
@Override
public boolean cleanExpiredConsumerQueueByAddr(String addr) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, MQClientException, InterruptedException {
+ RemotingTimeoutException, MQClientException, InterruptedException {
return defaultMQAdminExtImpl.cleanExpiredConsumerQueueByAddr(addr);
}
@Override
public boolean cleanUnusedTopic(String cluster) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, MQClientException, InterruptedException {
+ RemotingTimeoutException, MQClientException, InterruptedException {
return defaultMQAdminExtImpl.cleanUnusedTopicByAddr(cluster);
}
@Override
public boolean cleanUnusedTopicByAddr(String addr) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, MQClientException, InterruptedException {
+ RemotingTimeoutException, MQClientException, InterruptedException {
return defaultMQAdminExtImpl.cleanUnusedTopicByAddr(addr);
}
@Override
public ConsumerRunningInfo getConsumerRunningInfo(String consumerGroup, String clientId, boolean jstack) throws RemotingException,
- MQClientException, InterruptedException {
+ MQClientException, InterruptedException {
return defaultMQAdminExtImpl.getConsumerRunningInfo(consumerGroup, clientId, jstack);
}
@Override
public ConsumeMessageDirectlyResult consumeMessageDirectly(String consumerGroup, String clientId, String msgId)
- throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
+ throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
return defaultMQAdminExtImpl.consumeMessageDirectly(consumerGroup, clientId, msgId);
}
@Override
- public ConsumeMessageDirectlyResult consumeMessageDirectly(final String consumerGroup, final String clientId, final String topic, final String msgId) throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
+ public ConsumeMessageDirectlyResult consumeMessageDirectly(final String consumerGroup, final String clientId, final String topic,
+ final String msgId) throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
return defaultMQAdminExtImpl.consumeMessageDirectly(consumerGroup, clientId, topic, msgId);
}
@Override
public List<MessageTrack> messageTrackDetail(MessageExt msg) throws RemotingException, MQClientException, InterruptedException,
- MQBrokerException {
+ MQBrokerException {
return this.defaultMQAdminExtImpl.messageTrackDetail(msg);
}
@Override
public void cloneGroupOffset(String srcGroup, String destGroup, String topic, boolean isOffline) throws RemotingException,
- MQClientException, InterruptedException, MQBrokerException {
+ MQClientException, InterruptedException, MQBrokerException {
this.defaultMQAdminExtImpl.cloneGroupOffset(srcGroup, destGroup, topic, isOffline);
}
@Override
public BrokerStatsData viewBrokerStatsData(String brokerAddr, String statsName, String statsKey) throws RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException, MQClientException, InterruptedException {
+ RemotingSendRequestException, RemotingTimeoutException, MQClientException, InterruptedException {
return this.defaultMQAdminExtImpl.viewBrokerStatsData(brokerAddr, statsName, statsKey);
}
@Override
public Set<String> getClusterList(String topic) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, MQClientException, InterruptedException {
+ RemotingTimeoutException, MQClientException, InterruptedException {
return this.defaultMQAdminExtImpl.getClusterList(topic);
}
@Override
- public ConsumeStatsList fetchConsumeStatsInBroker(final String brokerAddr, boolean isOrder, long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, MQClientException, InterruptedException {
+ public ConsumeStatsList fetchConsumeStatsInBroker(final String brokerAddr, boolean isOrder,
+ long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException,
+ RemotingTimeoutException, MQClientException, InterruptedException {
return this.defaultMQAdminExtImpl.fetchConsumeStatsInBroker(brokerAddr, isOrder, timeoutMillis);
}
@@ -395,24 +410,25 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
}
@Override
- public SubscriptionGroupWrapper getAllSubscriptionGroup(final String brokerAddr, long timeoutMillis) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException,
- RemotingConnectException, MQBrokerException {
+ public SubscriptionGroupWrapper getAllSubscriptionGroup(final String brokerAddr,
+ long timeoutMillis) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException,
+ RemotingConnectException, MQBrokerException {
return this.defaultMQAdminExtImpl.getAllSubscriptionGroup(brokerAddr, timeoutMillis);
}
@Override
- public TopicConfigSerializeWrapper getAllTopicGroup(final String brokerAddr, long timeoutMillis) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException,
- RemotingConnectException, MQBrokerException {
+ public TopicConfigSerializeWrapper getAllTopicGroup(final String brokerAddr,
+ long timeoutMillis) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException,
+ RemotingConnectException, MQBrokerException {
return this.defaultMQAdminExtImpl.getAllTopicGroup(brokerAddr, timeoutMillis);
}
-
/* (non-Javadoc)
* @see org.apache.rocketmq.client.MQAdmin#queryMessageByUniqKey(java.lang.String, java.lang.String)
*/
@Override
public MessageExt viewMessage(String topic, String msgId)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
return this.defaultMQAdminExtImpl.viewMessage(topic, msgId);
}
@@ -433,23 +449,24 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
}
@Override
- public void updateConsumeOffset(String brokerAddr, String consumeGroup, MessageQueue mq, long offset) throws RemotingException, InterruptedException, MQBrokerException {
+ public void updateConsumeOffset(String brokerAddr, String consumeGroup, MessageQueue mq,
+ long offset) throws RemotingException, InterruptedException, MQBrokerException {
this.defaultMQAdminExtImpl.updateConsumeOffset(brokerAddr, consumeGroup, mq, offset);
}
@Override
public void updateNameServerConfig(final Properties properties, final List<String> nameServers)
- throws InterruptedException, RemotingConnectException,
- UnsupportedEncodingException, MQBrokerException, RemotingTimeoutException,
- MQClientException, RemotingSendRequestException {
+ throws InterruptedException, RemotingConnectException,
+ UnsupportedEncodingException, MQBrokerException, RemotingTimeoutException,
+ MQClientException, RemotingSendRequestException {
this.defaultMQAdminExtImpl.updateNameServerConfig(properties, nameServers);
}
@Override
public Map<String, Properties> getNameServerConfig(final List<String> nameServers)
- throws InterruptedException, RemotingTimeoutException,
- RemotingSendRequestException, RemotingConnectException, MQClientException,
- UnsupportedEncodingException {
+ throws InterruptedException, RemotingTimeoutException,
+ RemotingSendRequestException, RemotingConnectException, MQClientException,
+ UnsupportedEncodingException {
return this.defaultMQAdminExtImpl.getNameServerConfig(nameServers);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
index a0117a8..847a2c0 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
@@ -16,6 +16,20 @@
*/
package org.apache.rocketmq.tools.admin;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.Random;
+import java.util.Set;
+import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.client.QueryResult;
import org.apache.rocketmq.client.admin.MQAdminExtInner;
import org.apache.rocketmq.client.exception.MQBrokerException;
@@ -27,12 +41,32 @@ import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.ServiceState;
import org.apache.rocketmq.common.TopicConfig;
import org.apache.rocketmq.common.UtilAll;
-import org.apache.rocketmq.common.admin.*;
+import org.apache.rocketmq.common.admin.ConsumeStats;
+import org.apache.rocketmq.common.admin.OffsetWrapper;
+import org.apache.rocketmq.common.admin.RollbackStats;
+import org.apache.rocketmq.common.admin.TopicOffset;
+import org.apache.rocketmq.common.admin.TopicStatsTable;
import org.apache.rocketmq.common.help.FAQUrl;
-import org.apache.rocketmq.common.message.*;
+import org.apache.rocketmq.common.message.MessageClientExt;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageDecoder;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.namesrv.NamesrvUtil;
import org.apache.rocketmq.common.protocol.ResponseCode;
-import org.apache.rocketmq.common.protocol.body.*;
+import org.apache.rocketmq.common.protocol.body.BrokerStatsData;
+import org.apache.rocketmq.common.protocol.body.ClusterInfo;
+import org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
+import org.apache.rocketmq.common.protocol.body.ConsumeStatsList;
+import org.apache.rocketmq.common.protocol.body.ConsumerConnection;
+import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
+import org.apache.rocketmq.common.protocol.body.GroupList;
+import org.apache.rocketmq.common.protocol.body.KVTable;
+import org.apache.rocketmq.common.protocol.body.ProducerConnection;
+import org.apache.rocketmq.common.protocol.body.QueueTimeSpan;
+import org.apache.rocketmq.common.protocol.body.SubscriptionGroupWrapper;
+import org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper;
+import org.apache.rocketmq.common.protocol.body.TopicList;
import org.apache.rocketmq.common.protocol.header.UpdateConsumerOffsetRequestHeader;
import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
import org.apache.rocketmq.common.protocol.route.BrokerData;
@@ -42,17 +76,15 @@ import org.apache.rocketmq.common.subscription.SubscriptionGroupConfig;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.apache.rocketmq.remoting.common.RemotingUtil;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.exception.RemotingConnectException;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
+import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
import org.apache.rocketmq.tools.admin.api.MessageTrack;
import org.apache.rocketmq.tools.admin.api.TrackType;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.rocketmq.remoting.exception.*;
import org.slf4j.Logger;
-import java.io.UnsupportedEncodingException;
-import java.util.*;
-import java.util.Map.Entry;
-
-
public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
private final Logger log = ClientLogger.getLog();
private final DefaultMQAdminExt defaultMQAdminExt;
@@ -62,19 +94,16 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
private long timeoutMillis = 20000;
private Random random = new Random();
-
public DefaultMQAdminExtImpl(DefaultMQAdminExt defaultMQAdminExt, long timeoutMillis) {
this(defaultMQAdminExt, null, timeoutMillis);
}
-
public DefaultMQAdminExtImpl(DefaultMQAdminExt defaultMQAdminExt, RPCHook rpcHook, long timeoutMillis) {
this.defaultMQAdminExt = defaultMQAdminExt;
this.rpcHook = rpcHook;
this.timeoutMillis = timeoutMillis;
}
-
@Override
public void start() throws MQClientException {
switch (this.serviceState) {
@@ -89,8 +118,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
if (!registerOK) {
this.serviceState = ServiceState.CREATE_JUST;
throw new MQClientException("The adminExt group[" + this.defaultMQAdminExt.getAdminExtGroup()
- + "] has created already, specifed another name please."//
- + FAQUrl.suggestTodo(FAQUrl.GROUP_NAME_DUPLICATE_URL), null);
+ + "] has created already, specifed another name please."//
+ + FAQUrl.suggestTodo(FAQUrl.GROUP_NAME_DUPLICATE_URL), null);
}
mqClientInstance.start();
@@ -103,14 +132,13 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
case START_FAILED:
case SHUTDOWN_ALREADY:
throw new MQClientException("The AdminExt service state not OK, maybe started once, "//
- + this.serviceState//
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK), null);
+ + this.serviceState//
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK), null);
default:
break;
}
}
-
@Override
public void shutdown() {
switch (this.serviceState) {
@@ -132,25 +160,25 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public void updateBrokerConfig(String brokerAddr, Properties properties) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, UnsupportedEncodingException, InterruptedException, MQBrokerException {
+ RemotingTimeoutException, UnsupportedEncodingException, InterruptedException, MQBrokerException {
this.mqClientInstance.getMQClientAPIImpl().updateBrokerConfig(brokerAddr, properties, timeoutMillis);
}
@Override
public Properties getBrokerConfig(final String brokerAddr) throws RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException, UnsupportedEncodingException, InterruptedException, MQBrokerException {
+ RemotingSendRequestException, RemotingTimeoutException, UnsupportedEncodingException, InterruptedException, MQBrokerException {
return this.mqClientInstance.getMQClientAPIImpl().getBrokerConfig(brokerAddr, timeoutMillis);
}
@Override
public void createAndUpdateTopicConfig(String addr, TopicConfig config) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException {
+ InterruptedException, MQClientException {
this.mqClientInstance.getMQClientAPIImpl().createTopic(addr, this.defaultMQAdminExt.getCreateTopicKey(), config, timeoutMillis);
}
@Override
public void createAndUpdateSubscriptionGroupConfig(String addr, SubscriptionGroupConfig config) throws RemotingException,
- MQBrokerException, InterruptedException, MQClientException {
+ MQBrokerException, InterruptedException, MQClientException {
this.mqClientInstance.getMQClientAPIImpl().createSubscriptionGroup(addr, config, timeoutMillis);
}
@@ -168,7 +196,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public TopicStatsTable examineTopicStats(String topic) throws RemotingException, MQClientException, InterruptedException,
- MQBrokerException {
+ MQBrokerException {
TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
TopicStatsTable topicStatsTable = new TopicStatsTable();
@@ -199,19 +227,19 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public KVTable fetchBrokerRuntimeStats(final String brokerAddr) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, InterruptedException, MQBrokerException {
+ RemotingTimeoutException, InterruptedException, MQBrokerException {
return this.mqClientInstance.getMQClientAPIImpl().getBrokerRuntimeInfo(brokerAddr, timeoutMillis);
}
@Override
public ConsumeStats examineConsumeStats(String consumerGroup) throws RemotingException, MQClientException, InterruptedException,
- MQBrokerException {
+ MQBrokerException {
return examineConsumeStats(consumerGroup, null);
}
@Override
public ConsumeStats examineConsumeStats(String consumerGroup, String topic) throws RemotingException, MQClientException,
- InterruptedException, MQBrokerException {
+ InterruptedException, MQBrokerException {
String retryTopic = MixAll.getRetryTopic(consumerGroup);
TopicRouteData topicRouteData = this.examineTopicRouteInfo(retryTopic);
ConsumeStats result = new ConsumeStats();
@@ -220,7 +248,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
String addr = bd.selectBrokerAddr();
if (addr != null) {
ConsumeStats consumeStats =
- this.mqClientInstance.getMQClientAPIImpl().getConsumeStats(addr, consumerGroup, topic, timeoutMillis * 3);
+ this.mqClientInstance.getMQClientAPIImpl().getConsumeStats(addr, consumerGroup, topic, timeoutMillis * 3);
result.getOffsetTable().putAll(consumeStats.getOffsetTable());
double value = result.getConsumeTps() + consumeStats.getConsumeTps();
result.setConsumeTps(value);
@@ -229,7 +257,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
if (result.getOffsetTable().isEmpty()) {
throw new MQClientException(ResponseCode.CONSUMER_NOT_ONLINE,
- "Not found the consumer group consume stats, because return offset table is empty, maybe the consumer not consume any message");
+ "Not found the consumer group consume stats, because return offset table is empty, maybe the consumer not consume any message");
}
return result;
@@ -237,7 +265,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public ClusterInfo examineBrokerClusterInfo() throws InterruptedException, MQBrokerException, RemotingTimeoutException,
- RemotingSendRequestException, RemotingConnectException {
+ RemotingSendRequestException, RemotingConnectException {
return this.mqClientInstance.getMQClientAPIImpl().getBrokerClusterInfo(timeoutMillis);
}
@@ -246,7 +274,6 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
return this.mqClientInstance.getMQClientAPIImpl().getTopicRouteInfoFromNameServer(topic, timeoutMillis);
}
-
@Override
public MessageExt viewMessage(String topic, String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
try {
@@ -260,7 +287,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public ConsumerConnection examineConsumerConnectionInfo(String consumerGroup) throws InterruptedException, MQBrokerException,
- RemotingException, MQClientException {
+ RemotingException, MQClientException {
ConsumerConnection result = new ConsumerConnection();
String topic = MixAll.getRetryTopic(consumerGroup);
List<BrokerData> brokers = this.examineTopicRouteInfo(topic).getBrokerDatas();
@@ -283,7 +310,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public ProducerConnection examineProducerConnectionInfo(String producerGroup, final String topic) throws RemotingException,
- MQClientException, InterruptedException, MQBrokerException {
+ MQClientException, InterruptedException, MQBrokerException {
ProducerConnection result = new ProducerConnection();
List<BrokerData> brokers = this.examineTopicRouteInfo(topic).getBrokerDatas();
BrokerData brokerData = brokers.get(random.nextInt(brokers.size()));
@@ -310,7 +337,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public int wipeWritePermOfBroker(final String namesrvAddr, String brokerName) throws RemotingCommandException,
- RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQClientException {
+ RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQClientException {
return this.mqClientInstance.getMQClientAPIImpl().wipeWritePermOfBroker(namesrvAddr, brokerName, timeoutMillis);
}
@@ -332,7 +359,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public void deleteTopicInBroker(Set<String> addrs, String topic) throws RemotingException, MQBrokerException, InterruptedException,
- MQClientException {
+ MQClientException {
for (String addr : addrs) {
this.mqClientInstance.getMQClientAPIImpl().deleteTopicInBroker(addr, topic, timeoutMillis);
}
@@ -340,7 +367,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public void deleteTopicInNameServer(Set<String> addrs, String topic) throws RemotingException, MQBrokerException, InterruptedException,
- MQClientException {
+ MQClientException {
if (addrs == null) {
String ns = this.mqClientInstance.getMQClientAPIImpl().fetchNameServerAddr();
addrs = new HashSet(Arrays.asList(ns.split(";")));
@@ -352,25 +379,25 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public void deleteSubscriptionGroup(String addr, String groupName) throws RemotingException, MQBrokerException, InterruptedException,
- MQClientException {
+ MQClientException {
this.mqClientInstance.getMQClientAPIImpl().deleteSubscriptionGroup(addr, groupName, timeoutMillis);
}
@Override
public void createAndUpdateKvConfig(String namespace, String key, String value) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException {
+ InterruptedException, MQClientException {
this.mqClientInstance.getMQClientAPIImpl().putKVConfigValue(namespace, key, value, timeoutMillis);
}
@Override
public void deleteKvConfig(String namespace, String key) throws RemotingException, MQBrokerException, InterruptedException,
- MQClientException {
+ MQClientException {
this.mqClientInstance.getMQClientAPIImpl().deleteKVConfigValue(namespace, key, timeoutMillis);
}
@Override
public List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp, boolean force)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
List<RollbackStats> rollbackStatsList = new ArrayList<RollbackStats>();
Map<String, Integer> topicRouteMap = new HashMap<String, Integer>();
@@ -397,7 +424,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
if (!hasConsumed) {
HashMap<MessageQueue, TopicOffset> topicStatus =
- this.mqClientInstance.getMQClientAPIImpl().getTopicStatsInfo(addr, topic, timeoutMillis).getOffsetTable();
+ this.mqClientInstance.getMQClientAPIImpl().getTopicStatsInfo(addr, topic, timeoutMillis).getOffsetTable();
for (int i = 0; i < topicRouteMap.get(addr); i++) {
MessageQueue queue = new MessageQueue(topic, bd.getBrokerName(), i);
OffsetWrapper offsetWrapper = new OffsetWrapper();
@@ -415,13 +442,13 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public Map<MessageQueue, Long> resetOffsetByTimestamp(String topic, String group, long timestamp, boolean isForce)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
return resetOffsetByTimestamp(topic, group, timestamp, isForce, false);
}
@Override
public void resetOffsetNew(String consumerGroup, String topic, long timestamp) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException {
+ InterruptedException, MQClientException {
try {
this.resetOffsetByTimestamp(topic, consumerGroup, timestamp, true);
} catch (MQClientException e) {
@@ -434,7 +461,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
public Map<MessageQueue, Long> resetOffsetByTimestamp(String topic, String group, long timestamp, boolean isForce, boolean isC)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
List<BrokerData> brokerDatas = topicRouteData.getBrokerDatas();
Map<MessageQueue, Long> allOffsetTable = new HashMap<MessageQueue, Long>();
@@ -443,8 +470,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
String addr = brokerData.selectBrokerAddr();
if (addr != null) {
Map<MessageQueue, Long> offsetTable =
- this.mqClientInstance.getMQClientAPIImpl().invokeBrokerToResetOffset(addr, topic, group, timestamp, isForce,
- timeoutMillis, isC);
+ this.mqClientInstance.getMQClientAPIImpl().invokeBrokerToResetOffset(addr, topic, group, timestamp, isForce,
+ timeoutMillis, isC);
if (offsetTable != null) {
allOffsetTable.putAll(offsetTable);
}
@@ -455,18 +482,17 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
private RollbackStats resetOffsetConsumeOffset(String brokerAddr, String consumeGroup, MessageQueue queue, OffsetWrapper offsetWrapper,
- long timestamp, boolean force) throws RemotingException, InterruptedException, MQBrokerException {
+ long timestamp, boolean force) throws RemotingException, InterruptedException, MQBrokerException {
long resetOffset;
if (timestamp == -1) {
resetOffset = this.mqClientInstance.getMQClientAPIImpl().getMaxOffset(brokerAddr, queue.getTopic(), queue.getQueueId(), timeoutMillis);
} else {
resetOffset =
- this.mqClientInstance.getMQClientAPIImpl().searchOffset(brokerAddr, queue.getTopic(), queue.getQueueId(), timestamp,
- timeoutMillis);
+ this.mqClientInstance.getMQClientAPIImpl().searchOffset(brokerAddr, queue.getTopic(), queue.getQueueId(), timestamp,
+ timeoutMillis);
}
-
RollbackStats rollbackStats = new RollbackStats();
rollbackStats.setBrokerName(queue.getBrokerName());
rollbackStats.setQueueId(queue.getQueueId());
@@ -489,31 +515,31 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public Map<String, Map<MessageQueue, Long>> getConsumeStatus(String topic, String group, String clientAddr) throws RemotingException,
- MQBrokerException, InterruptedException, MQClientException {
+ MQBrokerException, InterruptedException, MQClientException {
TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
List<BrokerData> brokerDatas = topicRouteData.getBrokerDatas();
if (brokerDatas != null && brokerDatas.size() > 0) {
String addr = brokerDatas.get(0).selectBrokerAddr();
if (addr != null) {
return this.mqClientInstance.getMQClientAPIImpl().invokeBrokerToGetConsumerStatus(addr, topic, group, clientAddr,
- timeoutMillis);
+ timeoutMillis);
}
}
return Collections.EMPTY_MAP;
}
public void createOrUpdateOrderConf(String key, String value, boolean isCluster) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException {
+ InterruptedException, MQClientException {
if (isCluster) {
this.mqClientInstance.getMQClientAPIImpl()
- .putKVConfigValue(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, key, value, timeoutMillis);
+ .putKVConfigValue(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, key, value, timeoutMillis);
} else {
String oldOrderConfs = null;
try {
oldOrderConfs =
- this.mqClientInstance.getMQClientAPIImpl().getKVConfigValue(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, key,
- timeoutMillis);
+ this.mqClientInstance.getMQClientAPIImpl().getKVConfigValue(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, key,
+ timeoutMillis);
} catch (Exception e) {
e.printStackTrace();
}
@@ -536,13 +562,13 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
splitor = ";";
}
this.mqClientInstance.getMQClientAPIImpl().putKVConfigValue(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, key,
- newOrderConf.toString(), timeoutMillis);
+ newOrderConf.toString(), timeoutMillis);
}
}
@Override
public GroupList queryTopicConsumeByWho(String topic) throws InterruptedException, MQBrokerException, RemotingException,
- MQClientException {
+ MQClientException {
TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
for (BrokerData bd : topicRouteData.getBrokerDatas()) {
@@ -559,7 +585,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public List<QueueTimeSpan> queryConsumeTimeSpan(final String topic, final String group) throws InterruptedException, MQBrokerException,
- RemotingException, MQClientException {
+ RemotingException, MQClientException {
List<QueueTimeSpan> spanSet = new ArrayList<QueueTimeSpan>();
TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
for (BrokerData bd : topicRouteData.getBrokerDatas()) {
@@ -573,7 +599,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public boolean cleanExpiredConsumerQueue(String cluster) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, MQClientException, InterruptedException {
+ RemotingTimeoutException, MQClientException, InterruptedException {
boolean result = false;
try {
ClusterInfo clusterInfo = examineBrokerClusterInfo();
@@ -592,7 +618,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
public boolean cleanExpiredConsumerQueueByCluster(ClusterInfo clusterInfo, String cluster) throws RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException, MQClientException, InterruptedException {
+ RemotingSendRequestException, RemotingTimeoutException, MQClientException, InterruptedException {
boolean result = false;
String[] addrs = clusterInfo.retrieveAllAddrByCluster(cluster);
for (String addr : addrs) {
@@ -603,7 +629,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public boolean cleanExpiredConsumerQueueByAddr(String addr) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, MQClientException, InterruptedException {
+ RemotingTimeoutException, MQClientException, InterruptedException {
boolean result = mqClientInstance.getMQClientAPIImpl().cleanExpiredConsumeQueue(addr, timeoutMillis);
log.warn("clean expired ConsumeQueue on target " + addr + " broker " + result);
return result;
@@ -611,7 +637,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public boolean cleanUnusedTopic(String cluster) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, MQClientException, InterruptedException {
+ RemotingTimeoutException, MQClientException, InterruptedException {
boolean result = false;
try {
ClusterInfo clusterInfo = examineBrokerClusterInfo();
@@ -630,7 +656,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
public boolean cleanUnusedTopicByCluster(ClusterInfo clusterInfo, String cluster) throws RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException, MQClientException, InterruptedException {
+ RemotingSendRequestException, RemotingTimeoutException, MQClientException, InterruptedException {
boolean result = false;
String[] addrs = clusterInfo.retrieveAllAddrByCluster(cluster);
for (String addr : addrs) {
@@ -641,7 +667,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public boolean cleanUnusedTopicByAddr(String addr) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, MQClientException, InterruptedException {
+ RemotingTimeoutException, MQClientException, InterruptedException {
boolean result = mqClientInstance.getMQClientAPIImpl().cleanUnusedTopicByAddr(addr, timeoutMillis);
log.warn("clean expired ConsumeQueue on target " + addr + " broker " + result);
return result;
@@ -649,7 +675,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public ConsumerRunningInfo getConsumerRunningInfo(String consumerGroup, String clientId, boolean jstack) throws RemotingException,
- MQClientException, InterruptedException {
+ MQClientException, InterruptedException {
String topic = MixAll.RETRY_GROUP_TOPIC_PREFIX + consumerGroup;
TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic);
List<BrokerData> brokerDatas = topicRouteData.getBrokerDatas();
@@ -658,7 +684,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
String addr = brokerData.selectBrokerAddr();
if (addr != null) {
return this.mqClientInstance.getMQClientAPIImpl().getConsumerRunningInfo(addr, consumerGroup, clientId, jstack,
- timeoutMillis * 3);
+ timeoutMillis * 3);
}
}
}
@@ -667,29 +693,30 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public ConsumeMessageDirectlyResult consumeMessageDirectly(String consumerGroup, String clientId, String msgId)
- throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
+ throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
MessageExt msg = this.viewMessage(msgId);
return this.mqClientInstance.getMQClientAPIImpl().consumeMessageDirectly(RemotingUtil.socketAddress2String(msg.getStoreHost()),
- consumerGroup, clientId, msgId, timeoutMillis * 3);
+ consumerGroup, clientId, msgId, timeoutMillis * 3);
}
@Override
- public ConsumeMessageDirectlyResult consumeMessageDirectly(final String consumerGroup, final String clientId, final String topic, final String msgId) throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
+ public ConsumeMessageDirectlyResult consumeMessageDirectly(final String consumerGroup, final String clientId, final String topic,
+ final String msgId) throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
MessageExt msg = this.viewMessage(topic, msgId);
if (msg.getProperty(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX) == null) {
return this.mqClientInstance.getMQClientAPIImpl().consumeMessageDirectly(RemotingUtil.socketAddress2String(msg.getStoreHost()),
- consumerGroup, clientId, msgId, timeoutMillis * 3);
+ consumerGroup, clientId, msgId, timeoutMillis * 3);
} else {
- MessageClientExt msgClient = (MessageClientExt) msg;
+ MessageClientExt msgClient = (MessageClientExt)msg;
return this.mqClientInstance.getMQClientAPIImpl().consumeMessageDirectly(RemotingUtil.socketAddress2String(msg.getStoreHost()),
- consumerGroup, clientId, msgClient.getOffsetMsgId(), timeoutMillis * 3);
+ consumerGroup, clientId, msgClient.getOffsetMsgId(), timeoutMillis * 3);
}
}
@Override
public List<MessageTrack> messageTrackDetail(MessageExt msg) throws RemotingException, MQClientException, InterruptedException,
- MQBrokerException {
+ MQBrokerException {
List<MessageTrack> result = new ArrayList<MessageTrack>();
GroupList groupList = this.queryTopicConsumeByWho(msg.getTopic());
@@ -750,8 +777,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
Entry<String, SubscriptionData> next = it.next();
if (next.getKey().equals(msg.getTopic())) {
if (next.getValue().getTagsSet().contains(msg.getTags())
- || next.getValue().getTagsSet().contains("*")
- || next.getValue().getTagsSet().isEmpty()) {
+ || next.getValue().getTagsSet().contains("*")
+ || next.getValue().getTagsSet().isEmpty()) {
} else {
mt.setTrackType(TrackType.CONSUMED_BUT_FILTERED);
}
@@ -771,7 +798,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
public boolean consumed(final MessageExt msg, final String group) throws RemotingException, MQClientException, InterruptedException,
- MQBrokerException {
+ MQBrokerException {
ConsumeStats cstats = this.examineConsumeStats(group);
@@ -799,7 +826,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public void cloneGroupOffset(String srcGroup, String destGroup, String topic, boolean isOffline) throws RemotingException,
- MQClientException, InterruptedException, MQBrokerException {
+ MQClientException, InterruptedException, MQBrokerException {
String retryTopic = MixAll.getRetryTopic(srcGroup);
TopicRouteData topicRouteData = this.examineTopicRouteInfo(retryTopic);
@@ -813,26 +840,26 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public BrokerStatsData viewBrokerStatsData(String brokerAddr, String statsName, String statsKey) throws RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException, MQClientException, InterruptedException {
+ RemotingSendRequestException, RemotingTimeoutException, MQClientException, InterruptedException {
return this.mqClientInstance.getMQClientAPIImpl().viewBrokerStatsData(brokerAddr, statsName, statsKey, timeoutMillis);
}
@Override
public Set<String> getClusterList(String topic) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, MQClientException, InterruptedException {
+ RemotingTimeoutException, MQClientException, InterruptedException {
return this.mqClientInstance.getMQClientAPIImpl().getClusterList(topic, timeoutMillis);
}
@Override
public ConsumeStatsList fetchConsumeStatsInBroker(final String brokerAddr, boolean isOrder, long timeoutMillis)
- throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, MQClientException,
- InterruptedException {
+ throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, MQClientException,
+ InterruptedException {
return this.mqClientInstance.getMQClientAPIImpl().fetchConsumeStatsInBroker(brokerAddr, isOrder, timeoutMillis);
}
@Override
public Set<String> getTopicClusterList(final String topic) throws InterruptedException, MQBrokerException, MQClientException,
- RemotingException {
+ RemotingException {
Set<String> clusterSet = new HashSet<String>();
ClusterInfo clusterInfo = examineBrokerClusterInfo();
TopicRouteData topicRouteData = examineTopicRouteInfo(topic);
@@ -850,13 +877,13 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public SubscriptionGroupWrapper getAllSubscriptionGroup(final String brokerAddr, long timeoutMillis) throws InterruptedException,
- RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
+ RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
return this.mqClientInstance.getMQClientAPIImpl().getAllSubscriptionGroup(brokerAddr, timeoutMillis);
}
@Override
public TopicConfigSerializeWrapper getAllTopicGroup(final String brokerAddr, long timeoutMillis) throws InterruptedException,
- RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
+ RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQBrokerException {
return this.mqClientInstance.getMQClientAPIImpl().getAllTopicConfig(brokerAddr, timeoutMillis);
}
@@ -897,12 +924,13 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end) throws MQClientException,
- InterruptedException {
+ InterruptedException {
return this.mqClientInstance.getMQAdminImpl().queryMessage(topic, key, maxNum, begin, end);
}
@Override
- public void updateConsumeOffset(String brokerAddr, String consumeGroup, MessageQueue mq, long offset) throws RemotingException, InterruptedException, MQBrokerException {
+ public void updateConsumeOffset(String brokerAddr, String consumeGroup, MessageQueue mq,
+ long offset) throws RemotingException, InterruptedException, MQBrokerException {
UpdateConsumerOffsetRequestHeader requestHeader = new UpdateConsumerOffsetRequestHeader();
requestHeader.setConsumerGroup(consumeGroup);
requestHeader.setTopic(mq.getTopic());
@@ -913,17 +941,17 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
public void updateNameServerConfig(final Properties properties, final List<String> nameServers)
- throws InterruptedException, RemotingConnectException,
- UnsupportedEncodingException, RemotingSendRequestException, RemotingTimeoutException,
- MQClientException, MQBrokerException {
+ throws InterruptedException, RemotingConnectException,
+ UnsupportedEncodingException, RemotingSendRequestException, RemotingTimeoutException,
+ MQClientException, MQBrokerException {
this.mqClientInstance.getMQClientAPIImpl().updateNameServerConfig(properties, nameServers, timeoutMillis);
}
@Override
public Map<String, Properties> getNameServerConfig(final List<String> nameServers)
- throws InterruptedException, RemotingTimeoutException,
- RemotingSendRequestException, RemotingConnectException, MQClientException,
- UnsupportedEncodingException {
+ throws InterruptedException, RemotingTimeoutException,
+ RemotingSendRequestException, RemotingConnectException, MQClientException,
+ UnsupportedEncodingException {
return this.mqClientInstance.getMQClientAPIImpl().getNameServerConfig(nameServers, timeoutMillis);
}
[58/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Remove bad
practices in client.
Posted by yu...@apache.org.
ROCKETMQ-18 Remove bad practices in client.
Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/commit/c8ee3289
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/tree/c8ee3289
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/diff/c8ee3289
Branch: refs/heads/master
Commit: c8ee3289b7518674bb077773e8b6bab699392984
Parents: 9165667
Author: yukon <yu...@apache.org>
Authored: Wed Dec 28 10:43:30 2016 +0800
Committer: yukon <yu...@apache.org>
Committed: Wed Dec 28 10:43:30 2016 +0800
----------------------------------------------------------------------
.../rocketmq/client/consumer/DefaultMQPullConsumer.java | 1 +
.../rocketmq/client/consumer/DefaultMQPushConsumer.java | 1 +
.../org/apache/rocketmq/client/consumer/PullCallback.java | 4 ++--
.../apache/rocketmq/client/consumer/PullTaskCallback.java | 2 +-
.../rocketmq/client/consumer/listener/ConsumeReturnType.java | 3 ---
.../rebalance/AllocateMessageQueueByMachineRoom.java | 8 ++++----
.../client/consumer/store/RemoteBrokerOffsetStore.java | 2 +-
.../org/apache/rocketmq/client/hook/CheckForbiddenHook.java | 4 ++--
.../org/apache/rocketmq/client/hook/FilterMessageHook.java | 4 ++--
9 files changed, 14 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/c8ee3289/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
index a8dd766..aac4207 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
@@ -335,6 +335,7 @@ public class DefaultMQPullConsumer extends ClientConfig implements MQPullConsume
MessageDecoder.decodeMessageId(uniqKey);
return this.viewMessage(uniqKey);
} catch (Exception e) {
+ // Ignore
}
return this.defaultMQPullConsumerImpl.queryMessageByUniqKey(topic, uniqKey);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/c8ee3289/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
index 38c4649..2575827 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
@@ -210,6 +210,7 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume
MessageDecoder.decodeMessageId(msgId);
return this.viewMessage(msgId);
} catch (Exception e) {
+ // Ignore
}
return this.defaultMQPushConsumerImpl.queryMessageByUniqKey(topic, msgId);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/c8ee3289/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
index fd2be0e..508050d 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
@@ -22,7 +22,7 @@ package org.apache.rocketmq.client.consumer;
* @author vintagewang@apache.org
*/
public interface PullCallback {
- public void onSuccess(final PullResult pullResult);
+ void onSuccess(final PullResult pullResult);
- public void onException(final Throwable e);
+ void onException(final Throwable e);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/c8ee3289/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskCallback.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskCallback.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskCallback.java
index f0e9b25..dc74bca 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskCallback.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskCallback.java
@@ -20,5 +20,5 @@ import org.apache.rocketmq.common.message.MessageQueue;
public interface PullTaskCallback {
- public void doPullTask(final MessageQueue mq, final PullTaskContext context);
+ void doPullTask(final MessageQueue mq, final PullTaskContext context);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/c8ee3289/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeReturnType.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeReturnType.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeReturnType.java
index 82570ab..99083b4 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeReturnType.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeReturnType.java
@@ -17,9 +17,6 @@
package org.apache.rocketmq.client.consumer.listener;
-/**
- * Created by alvin on 16-11-30.
- */
public enum ConsumeReturnType {
/**
* consume return success
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/c8ee3289/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByMachineRoom.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByMachineRoom.java b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByMachineRoom.java
index d3448c9..adfc124 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByMachineRoom.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByMachineRoom.java
@@ -45,12 +45,12 @@ public class AllocateMessageQueueByMachineRoom implements AllocateMessageQueueSt
premqAll.add(mq);
}
}
- // Todo cid
+
int mod = premqAll.size() / cidAll.size();
int rem = premqAll.size() % cidAll.size();
- int startindex = mod * currentIndex;
- int endindex = startindex + mod;
- for (int i = startindex; i < endindex; i++) {
+ int startIndex = mod * currentIndex;
+ int endIndex = startIndex + mod;
+ for (int i = startIndex; i < endIndex; i++) {
result.add(mqAll.get(i));
}
if (rem > currentIndex) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/c8ee3289/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
index 4fd6911..de9d0dd 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
@@ -125,7 +125,7 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
return;
final HashSet<MessageQueue> unusedMQ = new HashSet<MessageQueue>();
- if (mqs != null && !mqs.isEmpty()) {
+ if (!mqs.isEmpty()) {
for (Map.Entry<MessageQueue, AtomicLong> entry : this.offsetTable.entrySet()) {
MessageQueue mq = entry.getKey();
AtomicLong offset = entry.getValue();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/c8ee3289/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java b/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java
index 41ed088..90f164b 100644
--- a/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java
@@ -24,8 +24,8 @@ import org.apache.rocketmq.client.exception.MQClientException;
* @author manhong.yqd
*/
public interface CheckForbiddenHook {
- public String hookName();
+ String hookName();
- public void checkForbidden(final CheckForbiddenContext context) throws MQClientException;
+ void checkForbidden(final CheckForbiddenContext context) throws MQClientException;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/c8ee3289/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java b/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java
index 016ff56..28956ee 100644
--- a/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java
@@ -20,8 +20,8 @@ package org.apache.rocketmq.client.hook;
* @author manhong.yqd
*/
public interface FilterMessageHook {
- public String hookName();
+ String hookName();
- public void filterMessage(final FilterMessageContext context);
+ void filterMessage(final FilterMessageContext context);
}
[45/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/subscription/SubscriptionGroupManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/subscription/SubscriptionGroupManager.java b/broker/src/main/java/com/alibaba/rocketmq/broker/subscription/SubscriptionGroupManager.java
deleted file mode 100644
index d954a46..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/subscription/SubscriptionGroupManager.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/**
- * 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.subscription;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import com.alibaba.rocketmq.broker.BrokerPathConfigHelper;
-import com.alibaba.rocketmq.common.ConfigManager;
-import com.alibaba.rocketmq.common.DataVersion;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.subscription.SubscriptionGroupConfig;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-
-
-/**
- * @author shijia.wxr
- */
-public class SubscriptionGroupManager extends ConfigManager {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
-
- private final ConcurrentHashMap<String, SubscriptionGroupConfig> subscriptionGroupTable =
- new ConcurrentHashMap<String, SubscriptionGroupConfig>(1024);
- private final DataVersion dataVersion = new DataVersion();
- private transient BrokerController brokerController;
-
-
- public SubscriptionGroupManager() {
- this.init();
- }
-
- private void init() {
- {
- SubscriptionGroupConfig subscriptionGroupConfig = new SubscriptionGroupConfig();
- subscriptionGroupConfig.setGroupName(MixAll.TOOLS_CONSUMER_GROUP);
- this.subscriptionGroupTable.put(MixAll.TOOLS_CONSUMER_GROUP, subscriptionGroupConfig);
- }
-
- {
- SubscriptionGroupConfig subscriptionGroupConfig = new SubscriptionGroupConfig();
- subscriptionGroupConfig.setGroupName(MixAll.FILTERSRV_CONSUMER_GROUP);
- this.subscriptionGroupTable.put(MixAll.FILTERSRV_CONSUMER_GROUP, subscriptionGroupConfig);
- }
-
- {
- SubscriptionGroupConfig subscriptionGroupConfig = new SubscriptionGroupConfig();
- subscriptionGroupConfig.setGroupName(MixAll.SELF_TEST_CONSUMER_GROUP);
- this.subscriptionGroupTable.put(MixAll.SELF_TEST_CONSUMER_GROUP, subscriptionGroupConfig);
- }
-
- {
- SubscriptionGroupConfig subscriptionGroupConfig = new SubscriptionGroupConfig();
- subscriptionGroupConfig.setGroupName(MixAll.ONS_HTTP_PROXY_GROUP);
- subscriptionGroupConfig.setConsumeBroadcastEnable(true);
- this.subscriptionGroupTable.put(MixAll.ONS_HTTP_PROXY_GROUP, subscriptionGroupConfig);
- }
-
- {
- SubscriptionGroupConfig subscriptionGroupConfig = new SubscriptionGroupConfig();
- subscriptionGroupConfig.setGroupName(MixAll.CID_ONSAPI_PULL_GROUP);
- subscriptionGroupConfig.setConsumeBroadcastEnable(true);
- this.subscriptionGroupTable.put(MixAll.CID_ONSAPI_PULL_GROUP, subscriptionGroupConfig);
- }
-
- {
- SubscriptionGroupConfig subscriptionGroupConfig = new SubscriptionGroupConfig();
- subscriptionGroupConfig.setGroupName(MixAll.CID_ONSAPI_PERMISSION_GROUP);
- subscriptionGroupConfig.setConsumeBroadcastEnable(true);
- this.subscriptionGroupTable.put(MixAll.CID_ONSAPI_PERMISSION_GROUP, subscriptionGroupConfig);
- }
-
- {
- SubscriptionGroupConfig subscriptionGroupConfig = new SubscriptionGroupConfig();
- subscriptionGroupConfig.setGroupName(MixAll.CID_ONSAPI_OWNER_GROUP);
- subscriptionGroupConfig.setConsumeBroadcastEnable(true);
- this.subscriptionGroupTable.put(MixAll.CID_ONSAPI_OWNER_GROUP, subscriptionGroupConfig);
- }
- }
-
-
- public SubscriptionGroupManager(BrokerController brokerController) {
- this.brokerController = brokerController;
- this.init();
- }
-
-
- public void updateSubscriptionGroupConfig(final SubscriptionGroupConfig config) {
- SubscriptionGroupConfig old = this.subscriptionGroupTable.put(config.getGroupName(), config);
- if (old != null) {
- log.info("update subscription group config, old: " + old + " new: " + config);
- } else {
- log.info("create new subscription group, " + config);
- }
-
- this.dataVersion.nextVersion();
-
- this.persist();
- }
-
- public void disableConsume(final String groupName) {
- SubscriptionGroupConfig old = this.subscriptionGroupTable.get(groupName);
- if (old != null) {
- old.setConsumeEnable(false);
- this.dataVersion.nextVersion();
- }
- }
-
-
- public SubscriptionGroupConfig findSubscriptionGroupConfig(final String group) {
- SubscriptionGroupConfig subscriptionGroupConfig = this.subscriptionGroupTable.get(group);
- if (null == subscriptionGroupConfig) {
- if (brokerController.getBrokerConfig().isAutoCreateSubscriptionGroup() || MixAll.isSysConsumerGroup(group)) {
- subscriptionGroupConfig = new SubscriptionGroupConfig();
- subscriptionGroupConfig.setGroupName(group);
- SubscriptionGroupConfig preConfig = this.subscriptionGroupTable.putIfAbsent(group, subscriptionGroupConfig);
- if (null == preConfig) {
- log.info("auto create a subscription group, {}", subscriptionGroupConfig.toString());
- }
- this.dataVersion.nextVersion();
- this.persist();
- }
- }
-
- return subscriptionGroupConfig;
- }
-
-
- @Override
- public String encode() {
- return this.encode(false);
- }
-
- @Override
- public String configFilePath() {
- //return BrokerPathConfigHelper.getSubscriptionGroupPath(this.brokerController.getMessageStoreConfig().getStorePathRootDir());
- return BrokerPathConfigHelper.getSubscriptionGroupPath(System.getProperty("user.home") + File.separator + "store");
- }
-
- @Override
- public void decode(String jsonString) {
- if (jsonString != null) {
- SubscriptionGroupManager obj = RemotingSerializable.fromJson(jsonString, SubscriptionGroupManager.class);
- if (obj != null) {
- this.subscriptionGroupTable.putAll(obj.subscriptionGroupTable);
- this.dataVersion.assignNewOne(obj.dataVersion);
- this.printLoadDataWhenFirstBoot(obj);
- }
- }
- }
-
- public String encode(final boolean prettyFormat) {
- return RemotingSerializable.toJson(this, prettyFormat);
- }
-
- private void printLoadDataWhenFirstBoot(final SubscriptionGroupManager sgm) {
- Iterator<Entry<String, SubscriptionGroupConfig>> it = sgm.getSubscriptionGroupTable().entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, SubscriptionGroupConfig> next = it.next();
- log.info("load exist subscription group, {}", next.getValue().toString());
- }
- }
-
- public ConcurrentHashMap<String, SubscriptionGroupConfig> getSubscriptionGroupTable() {
- return subscriptionGroupTable;
- }
-
-
- public DataVersion getDataVersion() {
- return dataVersion;
- }
-
-
- public void deleteSubscriptionGroupConfig(final String groupName) {
- SubscriptionGroupConfig old = this.subscriptionGroupTable.remove(groupName);
- if (old != null) {
- log.info("delete subscription group OK, subscription group: " + old);
- this.dataVersion.nextVersion();
- this.persist();
- } else {
- log.warn("delete subscription group failed, subscription group: " + old + " not exist");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/topic/TopicConfigManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/topic/TopicConfigManager.java b/broker/src/main/java/com/alibaba/rocketmq/broker/topic/TopicConfigManager.java
deleted file mode 100644
index 94d7e9f..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/topic/TopicConfigManager.java
+++ /dev/null
@@ -1,440 +0,0 @@
-/**
- * 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.topic;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import com.alibaba.rocketmq.broker.BrokerPathConfigHelper;
-import com.alibaba.rocketmq.common.ConfigManager;
-import com.alibaba.rocketmq.common.DataVersion;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.TopicConfig;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.constant.PermName;
-import com.alibaba.rocketmq.common.protocol.body.KVTable;
-import com.alibaba.rocketmq.common.protocol.body.TopicConfigSerializeWrapper;
-import com.alibaba.rocketmq.common.sysflag.TopicSysFlag;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-
-/**
- * @author shijia.wxr
- */
-public class TopicConfigManager extends ConfigManager {
- private static final Logger LOG = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
- private static final long LOCK_TIMEOUT_MILLIS = 3000;
- private transient final Lock lockTopicConfigTable = new ReentrantLock();
-
- private final ConcurrentHashMap<String, TopicConfig> topicConfigTable =
- new ConcurrentHashMap<String, TopicConfig>(1024);
- private final DataVersion dataVersion = new DataVersion();
- private final Set<String> systemTopicList = new HashSet<String>();
- private transient BrokerController brokerController;
-
-
- public TopicConfigManager() {
- }
-
-
- public TopicConfigManager(BrokerController brokerController) {
- this.brokerController = brokerController;
- {
- // MixAll.SELF_TEST_TOPIC
- String topic = MixAll.SELF_TEST_TOPIC;
- TopicConfig topicConfig = new TopicConfig(topic);
- this.systemTopicList.add(topic);
- topicConfig.setReadQueueNums(1);
- topicConfig.setWriteQueueNums(1);
- this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig);
- }
- {
- // MixAll.DEFAULT_TOPIC
- if (this.brokerController.getBrokerConfig().isAutoCreateTopicEnable()) {
- String topic = MixAll.DEFAULT_TOPIC;
- TopicConfig topicConfig = new TopicConfig(topic);
- this.systemTopicList.add(topic);
- topicConfig.setReadQueueNums(this.brokerController.getBrokerConfig()
- .getDefaultTopicQueueNums());
- topicConfig.setWriteQueueNums(this.brokerController.getBrokerConfig()
- .getDefaultTopicQueueNums());
- int perm = PermName.PERM_INHERIT | PermName.PERM_READ | PermName.PERM_WRITE;
- topicConfig.setPerm(perm);
- this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig);
- }
- }
- {
- // MixAll.BENCHMARK_TOPIC
- String topic = MixAll.BENCHMARK_TOPIC;
- TopicConfig topicConfig = new TopicConfig(topic);
- this.systemTopicList.add(topic);
- topicConfig.setReadQueueNums(1024);
- topicConfig.setWriteQueueNums(1024);
- this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig);
- }
- {
-
- String topic = this.brokerController.getBrokerConfig().getBrokerClusterName();
- TopicConfig topicConfig = new TopicConfig(topic);
- this.systemTopicList.add(topic);
- int perm = PermName.PERM_INHERIT;
- if (this.brokerController.getBrokerConfig().isClusterTopicEnable()) {
- perm |= PermName.PERM_READ | PermName.PERM_WRITE;
- }
- topicConfig.setPerm(perm);
- this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig);
- }
- {
-
- String topic = this.brokerController.getBrokerConfig().getBrokerName();
- TopicConfig topicConfig = new TopicConfig(topic);
- this.systemTopicList.add(topic);
- int perm = PermName.PERM_INHERIT;
- if (this.brokerController.getBrokerConfig().isBrokerTopicEnable()) {
- perm |= PermName.PERM_READ | PermName.PERM_WRITE;
- }
- topicConfig.setReadQueueNums(1);
- topicConfig.setWriteQueueNums(1);
- topicConfig.setPerm(perm);
- this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig);
- }
- {
- // MixAll.OFFSET_MOVED_EVENT
- String topic = MixAll.OFFSET_MOVED_EVENT;
- TopicConfig topicConfig = new TopicConfig(topic);
- this.systemTopicList.add(topic);
- topicConfig.setReadQueueNums(1);
- topicConfig.setWriteQueueNums(1);
- this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig);
- }
- }
-
-
- public boolean isSystemTopic(final String topic) {
- return this.systemTopicList.contains(topic);
- }
-
-
- public Set<String> getSystemTopic() {
- return this.systemTopicList;
- }
-
-
- public boolean isTopicCanSendMessage(final String topic) {
- return !topic.equals(MixAll.DEFAULT_TOPIC);
- }
-
-
- public TopicConfig selectTopicConfig(final String topic) {
- return this.topicConfigTable.get(topic);
- }
-
-
- public TopicConfig createTopicInSendMessageMethod(final String topic, final String defaultTopic,
- final String remoteAddress, final int clientDefaultTopicQueueNums, final int topicSysFlag) {
- TopicConfig topicConfig = null;
- boolean createNew = false;
-
- try {
- if (this.lockTopicConfigTable.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
- try {
- topicConfig = this.topicConfigTable.get(topic);
- if (topicConfig != null)
- return topicConfig;
-
- TopicConfig defaultTopicConfig = this.topicConfigTable.get(defaultTopic);
- if (defaultTopicConfig != null) {
- if (defaultTopic.equals(MixAll.DEFAULT_TOPIC)) {
- if (!this.brokerController.getBrokerConfig().isAutoCreateTopicEnable()) {
- defaultTopicConfig.setPerm(PermName.PERM_READ | PermName.PERM_WRITE);
- }
- }
-
- if (PermName.isInherited(defaultTopicConfig.getPerm())) {
- topicConfig = new TopicConfig(topic);
-
- int queueNums =
- clientDefaultTopicQueueNums > defaultTopicConfig.getWriteQueueNums() ? defaultTopicConfig
- .getWriteQueueNums() : clientDefaultTopicQueueNums;
-
- if (queueNums < 0) {
- queueNums = 0;
- }
-
- topicConfig.setReadQueueNums(queueNums);
- topicConfig.setWriteQueueNums(queueNums);
- int perm = defaultTopicConfig.getPerm();
- perm &= ~PermName.PERM_INHERIT;
- topicConfig.setPerm(perm);
- topicConfig.setTopicSysFlag(topicSysFlag);
- topicConfig.setTopicFilterType(defaultTopicConfig.getTopicFilterType());
- } else {
- LOG.warn("create new topic failed, because the default topic[" + defaultTopic
- + "] no perm, " + defaultTopicConfig.getPerm() + " producer: "
- + remoteAddress);
- }
- } else {
- LOG.warn("create new topic failed, because the default topic[" + defaultTopic
- + "] not exist." + " producer: " + remoteAddress);
- }
-
- if (topicConfig != null) {
- LOG.info("create new topic by default topic[" + defaultTopic + "], " + topicConfig
- + " producer: " + remoteAddress);
-
- this.topicConfigTable.put(topic, topicConfig);
-
- this.dataVersion.nextVersion();
-
- createNew = true;
-
- this.persist();
- }
- } finally {
- this.lockTopicConfigTable.unlock();
- }
- }
- } catch (InterruptedException e) {
- LOG.error("createTopicInSendMessageMethod exception", e);
- }
-
- if (createNew) {
- this.brokerController.registerBrokerAll(false, true);
- }
-
- return topicConfig;
- }
-
- public TopicConfig createTopicInSendMessageBackMethod(
- final String topic,
- final int clientDefaultTopicQueueNums,
- final int perm,
- final int topicSysFlag) {
- TopicConfig topicConfig = this.topicConfigTable.get(topic);
- if (topicConfig != null)
- return topicConfig;
-
- boolean createNew = false;
-
- try {
- if (this.lockTopicConfigTable.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
- try {
- topicConfig = this.topicConfigTable.get(topic);
- if (topicConfig != null)
- return topicConfig;
-
- topicConfig = new TopicConfig(topic);
- topicConfig.setReadQueueNums(clientDefaultTopicQueueNums);
- topicConfig.setWriteQueueNums(clientDefaultTopicQueueNums);
- topicConfig.setPerm(perm);
- topicConfig.setTopicSysFlag(topicSysFlag);
-
- LOG.info("create new topic {}", topicConfig);
- this.topicConfigTable.put(topic, topicConfig);
- createNew = true;
- this.dataVersion.nextVersion();
- this.persist();
- } finally {
- this.lockTopicConfigTable.unlock();
- }
- }
- } catch (InterruptedException e) {
- LOG.error("createTopicInSendMessageBackMethod exception", e);
- }
-
- if (createNew) {
- this.brokerController.registerBrokerAll(false, true);
- }
-
- return topicConfig;
- }
-
- public void updateTopicUnitFlag(final String topic, final boolean unit) {
-
- TopicConfig topicConfig = this.topicConfigTable.get(topic);
- if (topicConfig != null) {
- int oldTopicSysFlag = topicConfig.getTopicSysFlag();
- if (unit) {
- topicConfig.setTopicSysFlag(TopicSysFlag.setUnitFlag(oldTopicSysFlag));
- } else {
- topicConfig.setTopicSysFlag(TopicSysFlag.clearUnitFlag(oldTopicSysFlag));
- }
-
- LOG.info("update topic sys flag. oldTopicSysFlag={}, newTopicSysFlag", oldTopicSysFlag,
- topicConfig.getTopicSysFlag());
-
- this.topicConfigTable.put(topic, topicConfig);
-
- this.dataVersion.nextVersion();
-
- this.persist();
- this.brokerController.registerBrokerAll(false, true);
- }
- }
-
- public void updateTopicUnitSubFlag(final String topic, final boolean hasUnitSub) {
- TopicConfig topicConfig = this.topicConfigTable.get(topic);
- if (topicConfig != null) {
- int oldTopicSysFlag = topicConfig.getTopicSysFlag();
- if (hasUnitSub) {
- topicConfig.setTopicSysFlag(TopicSysFlag.setUnitSubFlag(oldTopicSysFlag));
- }
-
- LOG.info("update topic sys flag. oldTopicSysFlag={}, newTopicSysFlag", oldTopicSysFlag,
- topicConfig.getTopicSysFlag());
-
- this.topicConfigTable.put(topic, topicConfig);
-
- this.dataVersion.nextVersion();
-
- this.persist();
- this.brokerController.registerBrokerAll(false, true);
- }
- }
-
- public void updateTopicConfig(final TopicConfig topicConfig) {
- TopicConfig old = this.topicConfigTable.put(topicConfig.getTopicName(), topicConfig);
- if (old != null) {
- LOG.info("update topic config, old: " + old + " new: " + topicConfig);
- } else {
- LOG.info("create new topic, " + topicConfig);
- }
-
- this.dataVersion.nextVersion();
-
- this.persist();
- }
-
-
- public void updateOrderTopicConfig(final KVTable orderKVTableFromNs) {
-
- if (orderKVTableFromNs != null && orderKVTableFromNs.getTable() != null) {
- boolean isChange = false;
- Set<String> orderTopics = orderKVTableFromNs.getTable().keySet();
- for (String topic : orderTopics) {
- TopicConfig topicConfig = this.topicConfigTable.get(topic);
- if (topicConfig != null && !topicConfig.isOrder()) {
- topicConfig.setOrder(true);
- isChange = true;
- LOG.info("update order topic config, topic={}, order={}", topic, true);
- }
- }
-
- for (Map.Entry<String, TopicConfig> entry : this.topicConfigTable.entrySet()) {
- String topic = entry.getKey();
- if (!orderTopics.contains(topic)) {
- TopicConfig topicConfig = entry.getValue();
- if (topicConfig.isOrder()) {
- topicConfig.setOrder(false);
- isChange = true;
- LOG.info("update order topic config, topic={}, order={}", topic, false);
- }
- }
- }
-
- if (isChange) {
- this.dataVersion.nextVersion();
- this.persist();
- }
- }
- }
-
- public boolean isOrderTopic(final String topic) {
- TopicConfig topicConfig = this.topicConfigTable.get(topic);
- if (topicConfig == null) {
- return false;
- } else {
- return topicConfig.isOrder();
- }
- }
-
- public void deleteTopicConfig(final String topic) {
- TopicConfig old = this.topicConfigTable.remove(topic);
- if (old != null) {
- LOG.info("delete topic config OK, topic: " + old);
- this.dataVersion.nextVersion();
- this.persist();
- } else {
- LOG.warn("delete topic config failed, topic: " + topic + " not exist");
- }
- }
-
- public TopicConfigSerializeWrapper buildTopicConfigSerializeWrapper() {
- TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper();
- topicConfigSerializeWrapper.setTopicConfigTable(this.topicConfigTable);
- topicConfigSerializeWrapper.setDataVersion(this.dataVersion);
- return topicConfigSerializeWrapper;
- }
-
- @Override
- public String encode() {
- return encode(false);
- }
-
- @Override
- public String configFilePath() {
-// return BrokerPathConfigHelper.getTopicConfigPath(this.brokerController.getMessageStoreConfig()
-// .getStorePathRootDir());
- return BrokerPathConfigHelper.getTopicConfigPath(System.getProperty("user.home") + File.separator + "store");
- }
-
- @Override
- public void decode(String jsonString) {
- if (jsonString != null) {
- TopicConfigSerializeWrapper topicConfigSerializeWrapper =
- TopicConfigSerializeWrapper.fromJson(jsonString, TopicConfigSerializeWrapper.class);
- if (topicConfigSerializeWrapper != null) {
- this.topicConfigTable.putAll(topicConfigSerializeWrapper.getTopicConfigTable());
- this.dataVersion.assignNewOne(topicConfigSerializeWrapper.getDataVersion());
- this.printLoadDataWhenFirstBoot(topicConfigSerializeWrapper);
- }
- }
- }
-
- public String encode(final boolean prettyFormat) {
- TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper();
- topicConfigSerializeWrapper.setTopicConfigTable(this.topicConfigTable);
- topicConfigSerializeWrapper.setDataVersion(this.dataVersion);
- return topicConfigSerializeWrapper.toJson(prettyFormat);
- }
-
- private void printLoadDataWhenFirstBoot(final TopicConfigSerializeWrapper tcs) {
- Iterator<Entry<String, TopicConfig>> it = tcs.getTopicConfigTable().entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, TopicConfig> next = it.next();
- LOG.info("load exist local topic, {}", next.getValue().toString());
- }
- }
-
- public DataVersion getDataVersion() {
- return dataVersion;
- }
-
- public ConcurrentHashMap<String, TopicConfig> getTopicConfigTable() {
- return topicConfigTable;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/transaction/TransactionRecord.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/transaction/TransactionRecord.java b/broker/src/main/java/com/alibaba/rocketmq/broker/transaction/TransactionRecord.java
deleted file mode 100644
index 4328cf8..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/transaction/TransactionRecord.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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.transaction;
-
-public class TransactionRecord {
- // Commit Log Offset
- private long offset;
- private String producerGroup;
-
-
- public long getOffset() {
- return offset;
- }
-
-
- public void setOffset(long offset) {
- this.offset = offset;
- }
-
-
- public String getProducerGroup() {
- return producerGroup;
- }
-
-
- public void setProducerGroup(String producerGroup) {
- this.producerGroup = producerGroup;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/transaction/TransactionStore.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/transaction/TransactionStore.java b/broker/src/main/java/com/alibaba/rocketmq/broker/transaction/TransactionStore.java
deleted file mode 100644
index 9d977ab..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/transaction/TransactionStore.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * 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.transaction;
-
-import java.util.List;
-
-
-public interface TransactionStore {
- public boolean open();
-
-
- public void close();
-
-
- public boolean put(final List<TransactionRecord> trs);
-
-
- public void remove(final List<Long> pks);
-
-
- public List<TransactionRecord> traverse(final long pk, final int nums);
-
-
- public long totalRecords();
-
-
- public long minPK();
-
-
- public long maxPK();
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/transaction/jdbc/JDBCTransactionStore.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/transaction/jdbc/JDBCTransactionStore.java b/broker/src/main/java/com/alibaba/rocketmq/broker/transaction/jdbc/JDBCTransactionStore.java
deleted file mode 100644
index 47de33b..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/transaction/jdbc/JDBCTransactionStore.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/**
- * 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.transaction.jdbc;
-
-import com.alibaba.rocketmq.broker.transaction.TransactionRecord;
-import com.alibaba.rocketmq.broker.transaction.TransactionStore;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.URL;
-import java.sql.*;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicLong;
-
-
-public class JDBCTransactionStore implements TransactionStore {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.TRANSACTION_LOGGER_NAME);
- private final JDBCTransactionStoreConfig jdbcTransactionStoreConfig;
- private Connection connection;
- private AtomicLong totalRecordsValue = new AtomicLong(0);
-
- public JDBCTransactionStore(JDBCTransactionStoreConfig jdbcTransactionStoreConfig) {
- this.jdbcTransactionStoreConfig = jdbcTransactionStoreConfig;
- }
-
- @Override
- public boolean open() {
- if (this.loadDriver()) {
- Properties props = new Properties();
- props.put("user", jdbcTransactionStoreConfig.getJdbcUser());
- props.put("password", jdbcTransactionStoreConfig.getJdbcPassword());
-
- try {
- this.connection =
- DriverManager.getConnection(this.jdbcTransactionStoreConfig.getJdbcURL(), props);
-
- this.connection.setAutoCommit(false);
-
-
- if (!this.computeTotalRecords()) {
- return this.createDB();
- }
-
- return true;
- } catch (SQLException e) {
- log.info("Create JDBC Connection Exeption", e);
- }
- }
-
- return false;
- }
-
- private boolean loadDriver() {
- try {
- Class.forName(this.jdbcTransactionStoreConfig.getJdbcDriverClass()).newInstance();
- log.info("Loaded the appropriate driver, {}",
- this.jdbcTransactionStoreConfig.getJdbcDriverClass());
- return true;
- } catch (Exception e) {
- log.info("Loaded the appropriate driver Exception", e);
- }
-
- return false;
- }
-
- private boolean computeTotalRecords() {
- Statement statement = null;
- ResultSet resultSet = null;
- try {
- statement = this.connection.createStatement();
-
- resultSet = statement.executeQuery("select count(offset) as total from t_transaction");
- if (!resultSet.next()) {
- log.warn("computeTotalRecords ResultSet is empty");
- return false;
- }
-
- this.totalRecordsValue.set(resultSet.getLong(1));
- } catch (Exception e) {
- log.warn("computeTotalRecords Exception", e);
- return false;
- } finally {
- if (null != statement) {
- try {
- statement.close();
- } catch (SQLException e) {
- }
- }
-
- if (null != resultSet) {
- try {
- resultSet.close();
- } catch (SQLException e) {
- }
- }
- }
-
- return true;
- }
-
- private boolean createDB() {
- Statement statement = null;
- try {
- statement = this.connection.createStatement();
-
- String sql = this.createTableSql();
- log.info("createDB SQL:\n {}", sql);
- statement.execute(sql);
- this.connection.commit();
- return true;
- } catch (Exception e) {
- log.warn("createDB Exception", e);
- return false;
- } finally {
- if (null != statement) {
- try {
- statement.close();
- } catch (SQLException e) {
- log.warn("Close statement exception", e);
- }
- }
- }
- }
-
- private String createTableSql() {
- URL resource = JDBCTransactionStore.class.getClassLoader().getResource("transaction.sql");
- String fileContent = MixAll.file2String(resource);
- return fileContent;
- }
-
- @Override
- public void close() {
- try {
- if (this.connection != null) {
- this.connection.close();
- }
- } catch (SQLException e) {
- }
- }
-
- @Override
- public boolean put(List<TransactionRecord> trs) {
- PreparedStatement statement = null;
- try {
- this.connection.setAutoCommit(false);
- statement = this.connection.prepareStatement("insert into t_transaction values (?, ?)");
- for (TransactionRecord tr : trs) {
- statement.setLong(1, tr.getOffset());
- statement.setString(2, tr.getProducerGroup());
- statement.addBatch();
- }
- int[] executeBatch = statement.executeBatch();
- this.connection.commit();
- this.totalRecordsValue.addAndGet(updatedRows(executeBatch));
- return true;
- } catch (Exception e) {
- log.warn("createDB Exception", e);
- return false;
- } finally {
- if (null != statement) {
- try {
- statement.close();
- } catch (SQLException e) {
- log.warn("Close statement exception", e);
- }
- }
- }
- }
-
- private long updatedRows(int[] rows) {
- long res = 0;
- for (int i : rows) {
- res += i;
- }
-
- return res;
- }
-
- @Override
- public void remove(List<Long> pks) {
- PreparedStatement statement = null;
- try {
- this.connection.setAutoCommit(false);
- statement = this.connection.prepareStatement("DELETE FROM t_transaction WHERE offset = ?");
- for (long pk : pks) {
- statement.setLong(1, pk);
- statement.addBatch();
- }
- int[] executeBatch = statement.executeBatch();
- this.connection.commit();
- } catch (Exception e) {
- log.warn("createDB Exception", e);
- } finally {
- if (null != statement) {
- try {
- statement.close();
- } catch (SQLException e) {
- }
- }
- }
- }
-
- @Override
- public List<TransactionRecord> traverse(long pk, int nums) {
- return null;
- }
-
- @Override
- public long totalRecords() {
- return this.totalRecordsValue.get();
- }
-
- @Override
- public long minPK() {
- return 0;
- }
-
- @Override
- public long maxPK() {
- return 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/transaction/jdbc/JDBCTransactionStoreConfig.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/transaction/jdbc/JDBCTransactionStoreConfig.java b/broker/src/main/java/com/alibaba/rocketmq/broker/transaction/jdbc/JDBCTransactionStoreConfig.java
deleted file mode 100644
index 1244cfc..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/transaction/jdbc/JDBCTransactionStoreConfig.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * 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.transaction.jdbc;
-
-public class JDBCTransactionStoreConfig {
- private String jdbcDriverClass = "com.mysql.jdbc.Driver";
- private String jdbcURL = "jdbc:mysql://xxx.xxx.xxx.xxx:1000/xxx?useUnicode=true&characterEncoding=UTF-8";
- private String jdbcUser = "xxx";
- private String jdbcPassword = "xxx";
-
-
- public String getJdbcDriverClass() {
- return jdbcDriverClass;
- }
-
-
- public void setJdbcDriverClass(String jdbcDriverClass) {
- this.jdbcDriverClass = jdbcDriverClass;
- }
-
-
- public String getJdbcURL() {
- return jdbcURL;
- }
-
-
- public void setJdbcURL(String jdbcURL) {
- this.jdbcURL = jdbcURL;
- }
-
-
- public String getJdbcUser() {
- return jdbcUser;
- }
-
-
- public void setJdbcUser(String jdbcUser) {
- this.jdbcUser = jdbcUser;
- }
-
-
- public String getJdbcPassword() {
- return jdbcPassword;
- }
-
-
- public void setJdbcPassword(String jdbcPassword) {
- this.jdbcPassword = jdbcPassword;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
new file mode 100644
index 0000000..c5c05f4
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
@@ -0,0 +1,773 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.broker;
+
+import org.apache.rocketmq.broker.client.*;
+import org.apache.rocketmq.broker.client.net.Broker2Client;
+import org.apache.rocketmq.broker.client.rebalance.RebalanceLockManager;
+import org.apache.rocketmq.broker.filtersrv.FilterServerManager;
+import org.apache.rocketmq.broker.latency.BrokerFastFailure;
+import org.apache.rocketmq.broker.latency.BrokerFixedThreadPoolExecutor;
+import org.apache.rocketmq.broker.longpolling.NotifyMessageArrivingListener;
+import org.apache.rocketmq.broker.longpolling.PullRequestHoldService;
+import org.apache.rocketmq.broker.mqtrace.ConsumeMessageHook;
+import org.apache.rocketmq.broker.mqtrace.SendMessageHook;
+import org.apache.rocketmq.broker.offset.ConsumerOffsetManager;
+import org.apache.rocketmq.broker.out.BrokerOuterAPI;
+import org.apache.rocketmq.broker.plugin.MessageStoreFactory;
+import org.apache.rocketmq.broker.plugin.MessageStorePluginContext;
+import org.apache.rocketmq.broker.processor.*;
+import org.apache.rocketmq.broker.slave.SlaveSynchronize;
+import org.apache.rocketmq.broker.subscription.SubscriptionGroupManager;
+import org.apache.rocketmq.broker.topic.TopicConfigManager;
+import org.apache.rocketmq.common.*;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.constant.PermName;
+import org.apache.rocketmq.common.namesrv.RegisterBrokerResult;
+import org.apache.rocketmq.common.protocol.RequestCode;
+import org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper;
+import org.apache.rocketmq.common.stats.MomentStatsItem;
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.remoting.RemotingServer;
+import org.apache.rocketmq.remoting.netty.*;
+import org.apache.rocketmq.store.DefaultMessageStore;
+import org.apache.rocketmq.store.MessageArrivingListener;
+import org.apache.rocketmq.store.MessageStore;
+import org.apache.rocketmq.store.config.BrokerRole;
+import org.apache.rocketmq.store.config.MessageStoreConfig;
+import org.apache.rocketmq.store.stats.BrokerStats;
+import org.apache.rocketmq.store.stats.BrokerStatsManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.*;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class BrokerController {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+ private static final Logger LOG_PROTECTION = LoggerFactory.getLogger(LoggerName.PROTECTION_LOGGER_NAME);
+ private static final Logger LOG_WATER_MARK = LoggerFactory.getLogger(LoggerName.WATER_MARK_LOGGER_NAME);
+ private final BrokerConfig brokerConfig;
+ private final NettyServerConfig nettyServerConfig;
+ private final NettyClientConfig nettyClientConfig;
+ private final MessageStoreConfig messageStoreConfig;
+ private final ConsumerOffsetManager consumerOffsetManager;
+ private final ConsumerManager consumerManager;
+ private final ProducerManager producerManager;
+ private final ClientHousekeepingService clientHousekeepingService;
+ private final PullMessageProcessor pullMessageProcessor;
+ private final PullRequestHoldService pullRequestHoldService;
+ private final MessageArrivingListener messageArrivingListener;
+ private final Broker2Client broker2Client;
+ private final SubscriptionGroupManager subscriptionGroupManager;
+ private final ConsumerIdsChangeListener consumerIdsChangeListener;
+ private final RebalanceLockManager rebalanceLockManager = new RebalanceLockManager();
+ private final BrokerOuterAPI brokerOuterAPI;
+ private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl(
+ "BrokerControllerScheduledThread"));
+ private final SlaveSynchronize slaveSynchronize;
+ private final BlockingQueue<Runnable> sendThreadPoolQueue;
+ private final BlockingQueue<Runnable> pullThreadPoolQueue;
+ private final BlockingQueue<Runnable> clientManagerThreadPoolQueue;
+ private final BlockingQueue<Runnable> consumerManagerThreadPoolQueue;
+ private final FilterServerManager filterServerManager;
+ private final BrokerStatsManager brokerStatsManager;
+ private final List<SendMessageHook> sendMessageHookList = new ArrayList<SendMessageHook>();
+ private final List<ConsumeMessageHook> consumeMessageHookList = new ArrayList<ConsumeMessageHook>();
+ private MessageStore messageStore;
+ private RemotingServer remotingServer;
+ private RemotingServer fastRemotingServer;
+ private TopicConfigManager topicConfigManager;
+ private ExecutorService sendMessageExecutor;
+ private ExecutorService pullMessageExecutor;
+ private ExecutorService adminBrokerExecutor;
+ private ExecutorService clientManageExecutor;
+ private ExecutorService consumerManageExecutor;
+ private boolean updateMasterHAServerAddrPeriodically = false;
+ private BrokerStats brokerStats;
+ private InetSocketAddress storeHost;
+ private BrokerFastFailure brokerFastFailure;
+ private Configuration configuration;
+
+ public BrokerController(//
+ final BrokerConfig brokerConfig, //
+ final NettyServerConfig nettyServerConfig, //
+ final NettyClientConfig nettyClientConfig, //
+ final MessageStoreConfig messageStoreConfig //
+ ) {
+ this.brokerConfig = brokerConfig;
+ this.nettyServerConfig = nettyServerConfig;
+ this.nettyClientConfig = nettyClientConfig;
+ this.messageStoreConfig = messageStoreConfig;
+ this.consumerOffsetManager = new ConsumerOffsetManager(this);
+ this.topicConfigManager = new TopicConfigManager(this);
+ this.pullMessageProcessor = new PullMessageProcessor(this);
+ this.pullRequestHoldService = new PullRequestHoldService(this);
+ this.messageArrivingListener = new NotifyMessageArrivingListener(this.pullRequestHoldService);
+ this.consumerIdsChangeListener = new DefaultConsumerIdsChangeListener(this);
+ this.consumerManager = new ConsumerManager(this.consumerIdsChangeListener);
+ this.producerManager = new ProducerManager();
+ this.clientHousekeepingService = new ClientHousekeepingService(this);
+ this.broker2Client = new Broker2Client(this);
+ this.subscriptionGroupManager = new SubscriptionGroupManager(this);
+ this.brokerOuterAPI = new BrokerOuterAPI(nettyClientConfig);
+ this.filterServerManager = new FilterServerManager(this);
+
+ if (this.brokerConfig.getNamesrvAddr() != null) {
+ this.brokerOuterAPI.updateNameServerAddressList(this.brokerConfig.getNamesrvAddr());
+ log.info("user specfied name server address: {}", this.brokerConfig.getNamesrvAddr());
+ }
+
+ this.slaveSynchronize = new SlaveSynchronize(this);
+
+ this.sendThreadPoolQueue = new LinkedBlockingQueue<Runnable>(this.brokerConfig.getSendThreadPoolQueueCapacity());
+
+ this.pullThreadPoolQueue = new LinkedBlockingQueue<Runnable>(this.brokerConfig.getPullThreadPoolQueueCapacity());
+ this.clientManagerThreadPoolQueue = new LinkedBlockingQueue<Runnable>(this.brokerConfig.getClientManagerThreadPoolQueueCapacity());
+ this.consumerManagerThreadPoolQueue = new LinkedBlockingQueue<Runnable>(this.brokerConfig.getConsumerManagerThreadPoolQueueCapacity());
+
+ this.brokerStatsManager = new BrokerStatsManager(this.brokerConfig.getBrokerClusterName());
+ this.setStoreHost(new InetSocketAddress(this.getBrokerConfig().getBrokerIP1(), this.getNettyServerConfig().getListenPort()));
+
+ this.brokerFastFailure = new BrokerFastFailure(this);
+ this.configuration = new Configuration(
+ log,
+ BrokerPathConfigHelper.getBrokerConfigPath(),
+ this.brokerConfig, this.nettyServerConfig, this.nettyClientConfig, this.messageStoreConfig
+ );
+ }
+
+ public BrokerConfig getBrokerConfig() {
+ return brokerConfig;
+ }
+
+ public NettyServerConfig getNettyServerConfig() {
+ return nettyServerConfig;
+ }
+
+ public BlockingQueue<Runnable> getPullThreadPoolQueue() {
+ return pullThreadPoolQueue;
+ }
+
+ public boolean initialize() throws CloneNotSupportedException {
+ boolean result = true;
+
+ result = result && this.topicConfigManager.load();
+
+ result = result && this.consumerOffsetManager.load();
+ result = result && this.subscriptionGroupManager.load();
+
+ if (result) {
+ try {
+ this.messageStore =
+ new DefaultMessageStore(this.messageStoreConfig, this.brokerStatsManager, this.messageArrivingListener,
+ this.brokerConfig);
+ this.brokerStats = new BrokerStats((DefaultMessageStore) this.messageStore);
+ //load plugin
+ MessageStorePluginContext context = new MessageStorePluginContext(messageStoreConfig, brokerStatsManager, messageArrivingListener, brokerConfig);
+ this.messageStore = MessageStoreFactory.build(context, this.messageStore);
+ } catch (IOException e) {
+ result = false;
+ e.printStackTrace();
+ }
+ }
+
+ result = result && this.messageStore.load();
+
+ if (result) {
+ this.remotingServer = new NettyRemotingServer(this.nettyServerConfig, this.clientHousekeepingService);
+ NettyServerConfig fastConfig = (NettyServerConfig) this.nettyServerConfig.clone();
+ fastConfig.setListenPort(nettyServerConfig.getListenPort() - 2);
+ this.fastRemotingServer = new NettyRemotingServer(fastConfig, this.clientHousekeepingService);
+ this.sendMessageExecutor = new BrokerFixedThreadPoolExecutor(
+ this.brokerConfig.getSendMessageThreadPoolNums(),
+ this.brokerConfig.getSendMessageThreadPoolNums(),
+ 1000 * 60,
+ TimeUnit.MILLISECONDS,
+ this.sendThreadPoolQueue,
+ new ThreadFactoryImpl("SendMessageThread_"));
+
+ this.pullMessageExecutor = new BrokerFixedThreadPoolExecutor(
+ this.brokerConfig.getPullMessageThreadPoolNums(),
+ this.brokerConfig.getPullMessageThreadPoolNums(),
+ 1000 * 60,
+ TimeUnit.MILLISECONDS,
+ this.pullThreadPoolQueue,
+ new ThreadFactoryImpl("PullMessageThread_"));
+
+ this.adminBrokerExecutor =
+ Executors.newFixedThreadPool(this.brokerConfig.getAdminBrokerThreadPoolNums(), new ThreadFactoryImpl(
+ "AdminBrokerThread_"));
+
+ this.clientManageExecutor = new ThreadPoolExecutor(
+ this.brokerConfig.getClientManageThreadPoolNums(),
+ this.brokerConfig.getClientManageThreadPoolNums(),
+ 1000 * 60,
+ TimeUnit.MILLISECONDS,
+ this.clientManagerThreadPoolQueue,
+ new ThreadFactoryImpl("ClientManageThread_"));
+
+ this.consumerManageExecutor =
+ Executors.newFixedThreadPool(this.brokerConfig.getConsumerManageThreadPoolNums(), new ThreadFactoryImpl(
+ "ConsumerManageThread_"));
+
+ this.registerProcessor();
+
+
+ // TODO remove in future
+ final long initialDelay = UtilAll.computNextMorningTimeMillis() - System.currentTimeMillis();
+ final long period = 1000 * 60 * 60 * 24;
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ BrokerController.this.getBrokerStats().record();
+ } catch (Throwable e) {
+ log.error("schedule record error.", e);
+ }
+ }
+ }, initialDelay, period, TimeUnit.MILLISECONDS);
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ BrokerController.this.consumerOffsetManager.persist();
+ } catch (Throwable e) {
+ log.error("schedule persist consumerOffset error.", e);
+ }
+ }
+ }, 1000 * 10, this.brokerConfig.getFlushConsumerOffsetInterval(), TimeUnit.MILLISECONDS);
+
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ BrokerController.this.protectBroker();
+ } catch (Exception e) {
+ log.error("protectBroker error.", e);
+ }
+ }
+ }, 3, 3, TimeUnit.MINUTES);
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ BrokerController.this.printWaterMark();
+ } catch (Exception e) {
+ log.error("printWaterMark error.", e);
+ }
+ }
+ }, 10, 1, TimeUnit.SECONDS);
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ log.info("dispatch behind commit log {} bytes", BrokerController.this.getMessageStore().dispatchBehindBytes());
+ } catch (Throwable e) {
+ log.error("schedule dispatchBehindBytes error.", e);
+ }
+ }
+ }, 1000 * 10, 1000 * 60, TimeUnit.MILLISECONDS);
+
+ if (this.brokerConfig.getNamesrvAddr() != null) {
+ this.brokerOuterAPI.updateNameServerAddressList(this.brokerConfig.getNamesrvAddr());
+ } else if (this.brokerConfig.isFetchNamesrvAddrByAddressServer()) {
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ BrokerController.this.brokerOuterAPI.fetchNameServerAddr();
+ } catch (Throwable e) {
+ log.error("ScheduledTask fetchNameServerAddr exception", e);
+ }
+ }
+ }, 1000 * 10, 1000 * 60 * 2, TimeUnit.MILLISECONDS);
+ }
+
+ if (BrokerRole.SLAVE == this.messageStoreConfig.getBrokerRole()) {
+ if (this.messageStoreConfig.getHaMasterAddress() != null && this.messageStoreConfig.getHaMasterAddress().length() >= 6) {
+ this.messageStore.updateHaMasterAddress(this.messageStoreConfig.getHaMasterAddress());
+ this.updateMasterHAServerAddrPeriodically = false;
+ } else {
+ this.updateMasterHAServerAddrPeriodically = true;
+ }
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ BrokerController.this.slaveSynchronize.syncAll();
+ } catch (Throwable e) {
+ log.error("ScheduledTask syncAll slave exception", e);
+ }
+ }
+ }, 1000 * 10, 1000 * 60, TimeUnit.MILLISECONDS);
+ } else {
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ BrokerController.this.printMasterAndSlaveDiff();
+ } catch (Throwable e) {
+ log.error("schedule printMasterAndSlaveDiff error.", e);
+ }
+ }
+ }, 1000 * 10, 1000 * 60, TimeUnit.MILLISECONDS);
+ }
+ }
+
+ return result;
+ }
+
+ public void registerProcessor() {
+ /**
+ * SendMessageProcessor
+ */
+ SendMessageProcessor sendProcessor = new SendMessageProcessor(this);
+ sendProcessor.registerSendMessageHook(sendMessageHookList);
+ sendProcessor.registerConsumeMessageHook(consumeMessageHookList);
+
+ this.remotingServer.registerProcessor(RequestCode.SEND_MESSAGE, sendProcessor, this.sendMessageExecutor);
+ this.remotingServer.registerProcessor(RequestCode.SEND_MESSAGE_V2, sendProcessor, this.sendMessageExecutor);
+ this.remotingServer.registerProcessor(RequestCode.CONSUMER_SEND_MSG_BACK, sendProcessor, this.sendMessageExecutor);
+ this.fastRemotingServer.registerProcessor(RequestCode.SEND_MESSAGE, sendProcessor, this.sendMessageExecutor);
+ this.fastRemotingServer.registerProcessor(RequestCode.SEND_MESSAGE_V2, sendProcessor, this.sendMessageExecutor);
+ this.fastRemotingServer.registerProcessor(RequestCode.CONSUMER_SEND_MSG_BACK, sendProcessor, this.sendMessageExecutor);
+ /**
+ * PullMessageProcessor
+ */
+ this.remotingServer.registerProcessor(RequestCode.PULL_MESSAGE, this.pullMessageProcessor, this.pullMessageExecutor);
+ this.pullMessageProcessor.registerConsumeMessageHook(consumeMessageHookList);
+
+ /**
+ * QueryMessageProcessor
+ */
+ NettyRequestProcessor queryProcessor = new QueryMessageProcessor(this);
+ this.remotingServer.registerProcessor(RequestCode.QUERY_MESSAGE, queryProcessor, this.pullMessageExecutor);
+ this.remotingServer.registerProcessor(RequestCode.VIEW_MESSAGE_BY_ID, queryProcessor, this.pullMessageExecutor);
+
+ this.fastRemotingServer.registerProcessor(RequestCode.QUERY_MESSAGE, queryProcessor, this.pullMessageExecutor);
+ this.fastRemotingServer.registerProcessor(RequestCode.VIEW_MESSAGE_BY_ID, queryProcessor, this.pullMessageExecutor);
+
+ /**
+ * ClientManageProcessor
+ */
+ ClientManageProcessor clientProcessor = new ClientManageProcessor(this);
+ this.remotingServer.registerProcessor(RequestCode.HEART_BEAT, clientProcessor, this.clientManageExecutor);
+ this.remotingServer.registerProcessor(RequestCode.UNREGISTER_CLIENT, clientProcessor, this.clientManageExecutor);
+
+ this.fastRemotingServer.registerProcessor(RequestCode.HEART_BEAT, clientProcessor, this.clientManageExecutor);
+ this.fastRemotingServer.registerProcessor(RequestCode.UNREGISTER_CLIENT, clientProcessor, this.clientManageExecutor);
+
+ /**
+ * ConsumerManageProcessor
+ */
+ ConsumerManageProcessor consumerManageProcessor = new ConsumerManageProcessor(this);
+ this.remotingServer.registerProcessor(RequestCode.GET_CONSUMER_LIST_BY_GROUP, consumerManageProcessor, this.consumerManageExecutor);
+ this.remotingServer.registerProcessor(RequestCode.UPDATE_CONSUMER_OFFSET, consumerManageProcessor, this.consumerManageExecutor);
+ this.remotingServer.registerProcessor(RequestCode.QUERY_CONSUMER_OFFSET, consumerManageProcessor, this.consumerManageExecutor);
+
+ this.fastRemotingServer.registerProcessor(RequestCode.GET_CONSUMER_LIST_BY_GROUP, consumerManageProcessor, this.consumerManageExecutor);
+ this.fastRemotingServer.registerProcessor(RequestCode.UPDATE_CONSUMER_OFFSET, consumerManageProcessor, this.consumerManageExecutor);
+ this.fastRemotingServer.registerProcessor(RequestCode.QUERY_CONSUMER_OFFSET, consumerManageProcessor, this.consumerManageExecutor);
+
+
+ /**
+ * EndTransactionProcessor
+ */
+ this.remotingServer.registerProcessor(RequestCode.END_TRANSACTION, new EndTransactionProcessor(this), this.sendMessageExecutor);
+ this.fastRemotingServer.registerProcessor(RequestCode.END_TRANSACTION, new EndTransactionProcessor(this), this.sendMessageExecutor);
+
+ /**
+ * Default
+ */
+ AdminBrokerProcessor adminProcessor = new AdminBrokerProcessor(this);
+ this.remotingServer.registerDefaultProcessor(adminProcessor, this.adminBrokerExecutor);
+ this.fastRemotingServer.registerDefaultProcessor(adminProcessor, this.adminBrokerExecutor);
+ }
+
+ public BrokerStats getBrokerStats() {
+ return brokerStats;
+ }
+
+ public void setBrokerStats(BrokerStats brokerStats) {
+ this.brokerStats = brokerStats;
+ }
+
+ public void protectBroker() {
+ if (this.brokerConfig.isDisableConsumeIfConsumerReadSlowly()) {
+ final Iterator<Map.Entry<String, MomentStatsItem>> it = this.brokerStatsManager.getMomentStatsItemSetFallSize().getStatsItemTable().entrySet().iterator();
+ while (it.hasNext()) {
+ final Map.Entry<String, MomentStatsItem> next = it.next();
+ final long fallBehindBytes = next.getValue().getValue().get();
+ if (fallBehindBytes > this.brokerConfig.getConsumerFallbehindThreshold()) {
+ final String[] split = next.getValue().getStatsKey().split("@");
+ final String group = split[2];
+ LOG_PROTECTION.info("[PROTECT_BROKER] the consumer[{}] consume slowly, {} bytes, disable it", group, fallBehindBytes);
+ this.subscriptionGroupManager.disableConsume(group);
+ }
+ }
+ }
+ }
+
+ public long headSlowTimeMills(BlockingQueue<Runnable> q) {
+ long slowTimeMills = 0;
+ final Runnable peek = q.peek();
+ if (peek != null) {
+ RequestTask rt = BrokerFastFailure.castRunnable(peek);
+ slowTimeMills = this.messageStore.now() - rt.getCreateTimestamp();
+ }
+
+ if (slowTimeMills < 0) slowTimeMills = 0;
+
+ return slowTimeMills;
+ }
+
+ public long headSlowTimeMills4SendThreadPoolQueue() {
+ return this.headSlowTimeMills(this.sendThreadPoolQueue);
+ }
+
+ public long headSlowTimeMills4PullThreadPoolQueue() {
+ return this.headSlowTimeMills(this.pullThreadPoolQueue);
+ }
+
+ public void printWaterMark() {
+ LOG_WATER_MARK.info("[WATERMARK] Send Queue Size: {} SlowTimeMills: {}", this.sendThreadPoolQueue.size(), headSlowTimeMills4SendThreadPoolQueue());
+ LOG_WATER_MARK.info("[WATERMARK] Pull Queue Size: {} SlowTimeMills: {}", this.pullThreadPoolQueue.size(), headSlowTimeMills4PullThreadPoolQueue());
+ }
+
+ public MessageStore getMessageStore() {
+ return messageStore;
+ }
+
+ public void setMessageStore(MessageStore messageStore) {
+ this.messageStore = messageStore;
+ }
+
+ private void printMasterAndSlaveDiff() {
+ long diff = this.messageStore.slaveFallBehindMuch();
+
+ // XXX: warn and notify me
+ log.info("slave fall behind master, how much, {} bytes", diff);
+ }
+
+ public Broker2Client getBroker2Client() {
+ return broker2Client;
+ }
+
+ public ConsumerManager getConsumerManager() {
+ return consumerManager;
+ }
+
+ public ConsumerOffsetManager getConsumerOffsetManager() {
+ return consumerOffsetManager;
+ }
+
+ public MessageStoreConfig getMessageStoreConfig() {
+ return messageStoreConfig;
+ }
+
+ public ProducerManager getProducerManager() {
+ return producerManager;
+ }
+
+ public void setFastRemotingServer(RemotingServer fastRemotingServer) {
+ this.fastRemotingServer = fastRemotingServer;
+ }
+
+ public PullMessageProcessor getPullMessageProcessor() {
+ return pullMessageProcessor;
+ }
+
+ public PullRequestHoldService getPullRequestHoldService() {
+ return pullRequestHoldService;
+ }
+
+ public SubscriptionGroupManager getSubscriptionGroupManager() {
+ return subscriptionGroupManager;
+ }
+
+ public void shutdown() {
+ if (this.brokerStatsManager != null) {
+ this.brokerStatsManager.shutdown();
+ }
+
+ if (this.clientHousekeepingService != null) {
+ this.clientHousekeepingService.shutdown();
+ }
+
+ if (this.pullRequestHoldService != null) {
+ this.pullRequestHoldService.shutdown();
+ }
+
+ if (this.remotingServer != null) {
+ this.remotingServer.shutdown();
+ }
+
+ if (this.fastRemotingServer != null) {
+ this.fastRemotingServer.shutdown();
+ }
+
+ if (this.messageStore != null) {
+ this.messageStore.shutdown();
+ }
+
+ this.scheduledExecutorService.shutdown();
+ try {
+ this.scheduledExecutorService.awaitTermination(5000, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ }
+
+ this.unregisterBrokerAll();
+
+ if (this.sendMessageExecutor != null) {
+ this.sendMessageExecutor.shutdown();
+ }
+
+ if (this.pullMessageExecutor != null) {
+ this.pullMessageExecutor.shutdown();
+ }
+
+ if (this.adminBrokerExecutor != null) {
+ this.adminBrokerExecutor.shutdown();
+ }
+
+ if (this.brokerOuterAPI != null) {
+ this.brokerOuterAPI.shutdown();
+ }
+
+ this.consumerOffsetManager.persist();
+
+ if (this.filterServerManager != null) {
+ this.filterServerManager.shutdown();
+ }
+
+ if (this.brokerFastFailure != null) {
+ this.brokerFastFailure.shutdown();
+ }
+ }
+
+ private void unregisterBrokerAll() {
+ this.brokerOuterAPI.unregisterBrokerAll(
+ this.brokerConfig.getBrokerClusterName(),
+ this.getBrokerAddr(),
+ this.brokerConfig.getBrokerName(),
+ this.brokerConfig.getBrokerId());
+ }
+
+ public String getBrokerAddr() {
+ return this.brokerConfig.getBrokerIP1() + ":" + this.nettyServerConfig.getListenPort();
+ }
+
+ public void start() throws Exception {
+ if (this.messageStore != null) {
+ this.messageStore.start();
+ }
+
+ if (this.remotingServer != null) {
+ this.remotingServer.start();
+ }
+
+ if (this.fastRemotingServer != null) {
+ this.fastRemotingServer.start();
+ }
+
+ if (this.brokerOuterAPI != null) {
+ this.brokerOuterAPI.start();
+ }
+
+ if (this.pullRequestHoldService != null) {
+ this.pullRequestHoldService.start();
+ }
+
+ if (this.clientHousekeepingService != null) {
+ this.clientHousekeepingService.start();
+ }
+
+ if (this.filterServerManager != null) {
+ this.filterServerManager.start();
+ }
+
+ this.registerBrokerAll(true, false);
+
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ BrokerController.this.registerBrokerAll(true, false);
+ } catch (Throwable e) {
+ log.error("registerBrokerAll Exception", e);
+ }
+ }
+ }, 1000 * 10, 1000 * 30, TimeUnit.MILLISECONDS);
+
+ if (this.brokerStatsManager != null) {
+ this.brokerStatsManager.start();
+ }
+
+ if (this.brokerFastFailure != null) {
+ this.brokerFastFailure.start();
+ }
+ }
+
+ public synchronized void registerBrokerAll(final boolean checkOrderConfig, boolean oneway) {
+ TopicConfigSerializeWrapper topicConfigWrapper = this.getTopicConfigManager().buildTopicConfigSerializeWrapper();
+
+ if (!PermName.isWriteable(this.getBrokerConfig().getBrokerPermission())
+ || !PermName.isReadable(this.getBrokerConfig().getBrokerPermission())) {
+ ConcurrentHashMap<String, TopicConfig> topicConfigTable = new ConcurrentHashMap<String, TopicConfig>();
+ for (TopicConfig topicConfig : topicConfigWrapper.getTopicConfigTable().values()) {
+ TopicConfig tmp =
+ new TopicConfig(topicConfig.getTopicName(), topicConfig.getReadQueueNums(), topicConfig.getWriteQueueNums(),
+ this.brokerConfig.getBrokerPermission());
+ topicConfigTable.put(topicConfig.getTopicName(), tmp);
+ }
+ topicConfigWrapper.setTopicConfigTable(topicConfigTable);
+ }
+
+ RegisterBrokerResult registerBrokerResult = this.brokerOuterAPI.registerBrokerAll(
+ this.brokerConfig.getBrokerClusterName(),
+ this.getBrokerAddr(),
+ this.brokerConfig.getBrokerName(),
+ this.brokerConfig.getBrokerId(),
+ this.getHAServerAddr(),
+ topicConfigWrapper,
+ this.filterServerManager.buildNewFilterServerList(),
+ oneway,
+ this.brokerConfig.getRegisterBrokerTimeoutMills());
+
+ if (registerBrokerResult != null) {
+ if (this.updateMasterHAServerAddrPeriodically && registerBrokerResult.getHaServerAddr() != null) {
+ this.messageStore.updateHaMasterAddress(registerBrokerResult.getHaServerAddr());
+ }
+
+ this.slaveSynchronize.setMasterAddr(registerBrokerResult.getMasterAddr());
+
+ if (checkOrderConfig) {
+ this.getTopicConfigManager().updateOrderTopicConfig(registerBrokerResult.getKvTable());
+ }
+ }
+ }
+
+ public TopicConfigManager getTopicConfigManager() {
+ return topicConfigManager;
+ }
+
+ public void setTopicConfigManager(TopicConfigManager topicConfigManager) {
+ this.topicConfigManager = topicConfigManager;
+ }
+
+ public String getHAServerAddr() {
+ return this.brokerConfig.getBrokerIP2() + ":" + this.messageStoreConfig.getHaListenPort();
+ }
+
+ public RebalanceLockManager getRebalanceLockManager() {
+ return rebalanceLockManager;
+ }
+
+ public SlaveSynchronize getSlaveSynchronize() {
+ return slaveSynchronize;
+ }
+
+ public ExecutorService getPullMessageExecutor() {
+ return pullMessageExecutor;
+ }
+
+ public void setPullMessageExecutor(ExecutorService pullMessageExecutor) {
+ this.pullMessageExecutor = pullMessageExecutor;
+ }
+
+ public BlockingQueue<Runnable> getSendThreadPoolQueue() {
+ return sendThreadPoolQueue;
+ }
+
+ public FilterServerManager getFilterServerManager() {
+ return filterServerManager;
+ }
+
+ public BrokerStatsManager getBrokerStatsManager() {
+ return brokerStatsManager;
+ }
+
+ public List<SendMessageHook> getSendMessageHookList() {
+ return sendMessageHookList;
+ }
+
+ public void registerSendMessageHook(final SendMessageHook hook) {
+ this.sendMessageHookList.add(hook);
+ log.info("register SendMessageHook Hook, {}", hook.hookName());
+ }
+
+ public List<ConsumeMessageHook> getConsumeMessageHookList() {
+ return consumeMessageHookList;
+ }
+
+ public void registerConsumeMessageHook(final ConsumeMessageHook hook) {
+ this.consumeMessageHookList.add(hook);
+ log.info("register ConsumeMessageHook Hook, {}", hook.hookName());
+ }
+
+ public void registerServerRPCHook(RPCHook rpcHook) {
+ getRemotingServer().registerRPCHook(rpcHook);
+ }
+
+ public RemotingServer getRemotingServer() {
+ return remotingServer;
+ }
+
+ public void setRemotingServer(RemotingServer remotingServer) {
+ this.remotingServer = remotingServer;
+ }
+
+ public void registerClientRPCHook(RPCHook rpcHook) {
+ this.getBrokerOuterAPI().registerRPCHook(rpcHook);
+ }
+
+ public BrokerOuterAPI getBrokerOuterAPI() {
+ return brokerOuterAPI;
+ }
+
+ public InetSocketAddress getStoreHost() {
+ return storeHost;
+ }
+
+ public void setStoreHost(InetSocketAddress storeHost) {
+ this.storeHost = storeHost;
+ }
+
+ public Configuration getConfiguration() {
+ return this.configuration;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/BrokerPathConfigHelper.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerPathConfigHelper.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerPathConfigHelper.java
new file mode 100644
index 0000000..dbcd304
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerPathConfigHelper.java
@@ -0,0 +1,52 @@
+/**
+ * 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.broker;
+
+import java.io.File;
+
+
+public class BrokerPathConfigHelper {
+ private static String brokerConfigPath = System.getProperty("user.home") + File.separator + "store"
+ + File.separator + "config" + File.separator + "broker.properties";
+
+
+ public static String getBrokerConfigPath() {
+ return brokerConfigPath;
+ }
+
+
+ public static void setBrokerConfigPath(String path) {
+ brokerConfigPath = path;
+ }
+
+
+ public static String getTopicConfigPath(final String rootDir) {
+ return rootDir + File.separator + "config" + File.separator + "topics.json";
+ }
+
+
+ public static String getConsumerOffsetPath(final String rootDir) {
+ return rootDir + File.separator + "config" + File.separator + "consumerOffset.json";
+ }
+
+
+ public static String getSubscriptionGroupPath(final String rootDir) {
+ return rootDir + File.separator + "config" + File.separator + "subscriptionGroup.json";
+ }
+
+}
[63/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Remove
author annotation.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
index 2d8c2a6..334f0a1 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
@@ -28,7 +28,6 @@ import java.util.Set;
/**
* Offset store interface
*
- * @author vintagewang@apache.org
*/
public interface OffsetStore {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
index de9d0dd..4adc18c 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
@@ -40,7 +40,6 @@ import java.util.concurrent.atomic.AtomicLong;
/**
* Remote storage implementation
*
- * @author vintagewang@apache.org
*/
public class RemoteBrokerOffsetStore implements OffsetStore {
private final static Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java b/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java
index 1765fd6..ce4bedb 100644
--- a/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java
+++ b/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java
@@ -20,9 +20,6 @@ import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.help.FAQUrl;
-/**
- * @author vintagewang@apache.org
- */
public class MQBrokerException extends Exception {
private static final long serialVersionUID = 5975020272601250368L;
private final int responseCode;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java b/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java
index 5000ac5..7ffab0d 100644
--- a/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java
+++ b/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java
@@ -20,9 +20,6 @@ import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.help.FAQUrl;
-/**
- * @author vintagewang@apache.org
- */
public class MQClientException extends Exception {
private static final long serialVersionUID = -5758410930844185841L;
private int responseCode;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenContext.java b/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenContext.java
index 8cb4ca9..e84beff 100644
--- a/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenContext.java
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenContext.java
@@ -22,9 +22,6 @@ import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageQueue;
-/**
- * @author manhong.yqd
- */
public class CheckForbiddenContext {
private String nameSrvAddr;
private String group;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java b/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java
index 90f164b..d6f75bb 100644
--- a/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java
@@ -20,9 +20,6 @@ package org.apache.rocketmq.client.hook;
import org.apache.rocketmq.client.exception.MQClientException;
-/**
- * @author manhong.yqd
- */
public interface CheckForbiddenHook {
String hookName();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageContext.java b/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageContext.java
index 942fd71..23340d3 100644
--- a/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageContext.java
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageContext.java
@@ -22,9 +22,6 @@ import org.apache.rocketmq.common.message.MessageQueue;
import java.util.List;
-/**
- * @author manhong.yqd
- */
public class FilterMessageContext {
private String consumerGroup;
private List<MessageExt> msgList;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java b/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java
index 28956ee..48fd513 100644
--- a/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.client.hook;
-/**
- * @author manhong.yqd
- */
public interface FilterMessageHook {
String hookName();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java b/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
index c751c44..bb008bf 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
@@ -43,9 +43,6 @@ import java.util.HashMap;
import java.util.Map;
-/**
- * @author vintagewang@apache.org
- */
public class ClientRemotingProcessor implements NettyRequestProcessor {
private final Logger log = ClientLogger.getLog();
private final MQClientInstance mqClientFactory;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java b/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java
index db9f6fb..9af6794 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.client.impl;
-/**
- * @author vintagewang@apache.org
- */
public enum CommunicationMode {
SYNC,
ASYNC,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java b/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java
index 4e2b058..8773f26 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.client.impl;
-/**
- * @author vintagewang@apache.org
- */
public class FindBrokerResult {
private final String brokerAddr;
private final boolean slave;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
index 6ae4f94..3e6673c 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
@@ -48,9 +48,6 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-/**
- * @author vintagewang@apache.org
- */
public class MQAdminImpl {
private final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
index e45d593..84ee7db 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
@@ -66,9 +66,6 @@ import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
-/**
- * @author vintagewang@apache.org
- */
public class MQClientAPIImpl {
private final static Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java
index 585e8c7..3cc2fdf 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientManager.java
@@ -24,9 +24,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
-/**
- * @author vintagewang@apache.org
- */
public class MQClientManager {
private static MQClientManager instance = new MQClientManager();
private AtomicInteger factoryIndexGenerator = new AtomicInteger();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
index e1bfd96..e02bd4f 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
@@ -39,9 +39,6 @@ import java.util.*;
import java.util.concurrent.*;
-/**
- * @author vintagewang@apache.org
- */
public class ConsumeMessageConcurrentlyService implements ConsumeMessageService {
private static final Logger log = ClientLogger.getLog();
private final DefaultMQPushConsumerImpl defaultMQPushConsumerImpl;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
index 7b84cef..f6a1e4d 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
@@ -41,9 +41,6 @@ import java.util.List;
import java.util.concurrent.*;
-/**
- * @author vintagewang@apache.org
- */
public class ConsumeMessageOrderlyService implements ConsumeMessageService {
private static final Logger log = ClientLogger.getLog();
private final static long MAX_TIME_CONSUME_CONTINUOUSLY =
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java
index 7b63eb0..3dc768c 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java
@@ -23,9 +23,6 @@ import org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public interface ConsumeMessageService {
void start();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
index c343b17..f216533 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
@@ -56,9 +56,6 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
-/**
- * @author vintagewang@apache.org
- */
public class DefaultMQPullConsumerImpl implements MQConsumerInner {
private final Logger log = ClientLogger.getLog();
private final DefaultMQPullConsumer defaultMQPullConsumer;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
index 3a7014e..4241c0e 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
@@ -65,9 +65,6 @@ import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
-/**
- * @author vintagewang@apache.org
- */
public class DefaultMQPushConsumerImpl implements MQConsumerInner {
/**
* Delay some time when exception occur
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
index 5aab2ce..b1a2a25 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
@@ -29,7 +29,6 @@ import java.util.Set;
/**
* Consumer inner interface
*
- * @author vintagewang@apache.org
*/
public interface MQConsumerInner {
String groupName();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
index 2d553cb..1e573c3 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
@@ -24,7 +24,6 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* Message lock,strictly ensure the single queue only one thread at a time consuming
*
- * @author vintagewang@apache.org
*/
public class MessageQueueLock {
private ConcurrentHashMap<MessageQueue, Object> mqLockTable =
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
index e54d2e3..f361f1f 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
@@ -38,7 +38,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* Queue consumption snapshot
*
- * @author vintagewang@apache.org
*/
public class ProcessQueue {
public final static long REBALANCE_LOCK_MAX_LIVE_TIME =
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
index b5fc4a3..59c9b1c 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
@@ -44,9 +44,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
-/**
- * @author vintagewang@apache.org
- */
public class PullAPIWrapper {
private final Logger log = ClientLogger.getLog();
private final MQClientInstance mQClientFactory;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
index 17610a3..4634c24 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
@@ -24,9 +24,6 @@ import org.slf4j.Logger;
import java.util.concurrent.*;
-/**
- * @author vintagewang@apache.org
- */
public class PullMessageService extends ServiceThread {
private final Logger log = ClientLogger.getLog();
private final LinkedBlockingQueue<PullRequest> pullRequestQueue = new LinkedBlockingQueue<PullRequest>();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
index 211ed21..ccc624b 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
@@ -19,9 +19,6 @@ package org.apache.rocketmq.client.impl.consumer;
import org.apache.rocketmq.common.message.MessageQueue;
-/**
- * @author vintagewang@apache.org
- */
public class PullRequest {
private String consumerGroup;
private MessageQueue messageQueue;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java
index 95ca1aa..d248603 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java
@@ -23,9 +23,6 @@ import org.apache.rocketmq.common.message.MessageExt;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class PullResultExt extends PullResult {
private final long suggestWhichBrokerId;
private byte[] messageBinary;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
index 58a6157..53d775f 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
@@ -37,7 +37,6 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* Base class for rebalance algorithm
*
- * @author vintagewang@apache.org
*/
public abstract class RebalanceImpl {
protected static final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java
index 273b973..d37090d 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java
@@ -27,9 +27,6 @@ import java.util.List;
import java.util.Set;
-/**
- * @author vintagewang@apache.org
- */
public class RebalancePullImpl extends RebalanceImpl {
private final DefaultMQPullConsumerImpl defaultMQPullConsumerImpl;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
index f9eaf41..4d0d47f 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
@@ -33,9 +33,6 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
-/**
- * @author vintagewang@apache.org
- */
public class RebalancePushImpl extends RebalanceImpl {
private final static long UNLOCK_DELAY_TIME_MILLS = Long.parseLong(System.getProperty("rocketmq.client.unlockDelayTimeMills", "20000"));
private final DefaultMQPushConsumerImpl defaultMQPushConsumerImpl;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
index 1745324..5b5ab2a 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
@@ -25,7 +25,6 @@ import org.slf4j.Logger;
/**
* Rebalance Service
*
- * @author vintagewang@apache.org
*/
public class RebalanceService extends ServiceThread {
private static long waitInterval =
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java b/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
index 4a1cef4..6e0e379 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
@@ -58,9 +58,6 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-/**
- * @author vintagewang@apache.org
- */
public class MQClientInstance {
private final static long LOCK_TIMEOUT_MILLIS = 3000;
private final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
index ec0a9db..b53fa19 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
@@ -54,9 +54,6 @@ import java.util.*;
import java.util.concurrent.*;
-/**
- * @author vintagewang@apache.org
- */
public class DefaultMQProducerImpl implements MQProducerInner {
private final Logger log = ClientLogger.getLog();
private final Random random = new Random();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java b/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java
index 894017d..cac77ae 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java
@@ -23,9 +23,6 @@ import org.apache.rocketmq.common.protocol.header.CheckTransactionStateRequestHe
import java.util.Set;
-/**
- * @author vintagewang@apache.org
- */
public interface MQProducerInner {
Set<String> getPublishTopicList();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java b/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
index 1712308..dca20cb 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
@@ -25,9 +25,6 @@ import java.util.ArrayList;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class TopicPublishInfo {
private boolean orderTopic = false;
private boolean haveTopicRouterInfo = false;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultTolerance.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultTolerance.java b/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultTolerance.java
index 2da66f1..7f86d68 100644
--- a/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultTolerance.java
+++ b/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultTolerance.java
@@ -17,9 +17,6 @@
package org.apache.rocketmq.client.latency;
-/**
- * @author vintagewang@apache.org
- */
public interface LatencyFaultTolerance<T> {
void updateFaultItem(final T name, final long currentLatency, final long notAvailableDuration);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java b/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
index 8448128..12dac4b 100644
--- a/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
@@ -25,9 +25,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
-/**
- * @author vintagewang@apache.org
- */
public class LatencyFaultToleranceImpl implements LatencyFaultTolerance<String> {
private final ConcurrentHashMap<String, FaultItem> faultItemTable = new ConcurrentHashMap<String, FaultItem>(16);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java b/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java
index 75a3b0a..cdfd5d1 100644
--- a/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java
+++ b/client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java
@@ -20,9 +20,6 @@ package org.apache.rocketmq.client.latency;
import org.apache.rocketmq.client.impl.producer.TopicPublishInfo;
import org.apache.rocketmq.common.message.MessageQueue;
-/**
- * @author vintagewang@apache.org
- */
public class MQFaultStrategy {
private final LatencyFaultTolerance<String> latencyFaultTolerance = new LatencyFaultToleranceImpl();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java b/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java
index 48595a5..3055119 100644
--- a/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java
+++ b/client/src/main/java/org/apache/rocketmq/client/log/ClientLogger.java
@@ -25,9 +25,6 @@ import java.lang.reflect.Method;
import java.net.URL;
-/**
- * @author vintagewang@apache.org
- */
public class ClientLogger {
private static Logger log;
public static final String CLIENT_LOG_ROOT = "rocketmq.client.logRoot";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java
----------------------------------------------------------------------
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 854623f..340b1ff 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
@@ -29,9 +29,6 @@ import org.apache.rocketmq.common.message.*;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class DefaultMQProducer extends ClientConfig implements MQProducer {
protected final transient DefaultMQProducerImpl defaultMQProducerImpl;
private String producerGroup;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java b/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java
index 50ed48d..a7246e0 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionExecuter.java
@@ -19,9 +19,6 @@ package org.apache.rocketmq.client.producer;
import org.apache.rocketmq.common.message.Message;
-/**
- * @author vintagewang@apache.org
- */
public interface LocalTransactionExecuter {
public LocalTransactionState executeLocalTransactionBranch(final Message msg, final Object arg);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java b/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java
index eeec460..b907f81 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/LocalTransactionState.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.client.producer;
-/**
- * @author vintagewang@apache.org
- */
public enum LocalTransactionState {
COMMIT_MESSAGE,
ROLLBACK_MESSAGE,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java b/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java
index 7fb6561..492604e 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/MQProducer.java
@@ -26,9 +26,6 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public interface MQProducer extends MQAdmin {
void start() throws MQClientException;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java b/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java
index 30d7ba5..47956bb 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/MessageQueueSelector.java
@@ -22,9 +22,6 @@ import org.apache.rocketmq.common.message.MessageQueue;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public interface MessageQueueSelector {
MessageQueue select(final List<MessageQueue> mqs, final Message msg, final Object arg);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java b/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java
index eca9762..f599d83 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/SendCallback.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.client.producer;
-/**
- * @author vintagewang@apache.org
- */
public interface SendCallback {
public void onSuccess(final SendResult sendResult);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java b/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java
index 7c918f0..0fce69e 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/SendResult.java
@@ -20,9 +20,6 @@ import com.alibaba.fastjson.JSON;
import org.apache.rocketmq.common.message.MessageQueue;
-/**
- * @author vintagewang@apache.org
- */
public class SendResult {
private SendStatus sendStatus;
private String msgId;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java b/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java
index 740228f..a12c689 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/SendStatus.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.client.producer;
-/**
- * @author vintagewang@apache.org
- */
public enum SendStatus {
SEND_OK,
FLUSH_DISK_TIMEOUT,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java
index 0616949..6da0737 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionCheckListener.java
@@ -19,9 +19,6 @@ package org.apache.rocketmq.client.producer;
import org.apache.rocketmq.common.message.MessageExt;
-/**
- * @author vintagewang@apache.org
- */
public interface TransactionCheckListener {
LocalTransactionState checkLocalTransactionState(final MessageExt msg);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java
index ab6d782..b404216 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionMQProducer.java
@@ -21,9 +21,6 @@ import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.RPCHook;
-/**
- * @author vintagewang@apache.org
- */
public class TransactionMQProducer extends DefaultMQProducer {
private TransactionCheckListener transactionCheckListener;
private int checkThreadPoolMinSize = 1;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java
index 3ea7efc..ca9e713 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/TransactionSendResult.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.client.producer;
-/**
- * @author vintagewang@apache.org
- */
public class TransactionSendResult extends SendResult {
private LocalTransactionState localTransactionState;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java
index b304d91..15c7e55 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByHash.java
@@ -23,9 +23,6 @@ import org.apache.rocketmq.common.message.MessageQueue;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class SelectMessageQueueByHash implements MessageQueueSelector {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java
index 967b27a..d2bf6f3 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByMachineRoom.java
@@ -24,9 +24,6 @@ import java.util.List;
import java.util.Set;
-/**
- * @author vintagewang@apache.org
- */
public class SelectMessageQueueByMachineRoom implements MessageQueueSelector {
private Set<String> consumeridcs;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java
index d33c725..38d04c1 100644
--- a/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java
+++ b/client/src/main/java/org/apache/rocketmq/client/producer/selector/SelectMessageQueueByRandoom.java
@@ -24,9 +24,6 @@ import java.util.List;
import java.util.Random;
-/**
- * @author vintagewang@apache.org
- */
public class SelectMessageQueueByRandoom implements MessageQueueSelector {
private Random random = new Random(System.currentTimeMillis());
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java b/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java
index 51b4f25..e11122a 100644
--- a/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java
+++ b/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java
@@ -24,9 +24,6 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
-/**
- * @author vintagewang@apache.org
- */
public class BrokerConfig {
private String rocketmqHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV));
@ImportantField
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java b/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java
index 0175cac..1ade521 100644
--- a/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java
+++ b/common/src/main/java/org/apache/rocketmq/common/ConfigManager.java
@@ -23,9 +23,6 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
-/**
- * @author vintagewang@apache.org
- */
public abstract class ConfigManager {
private static final Logger PLOG = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/Configuration.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/Configuration.java b/common/src/main/java/org/apache/rocketmq/common/Configuration.java
index 0ab7c0d..1f81ba6 100644
--- a/common/src/main/java/org/apache/rocketmq/common/Configuration.java
+++ b/common/src/main/java/org/apache/rocketmq/common/Configuration.java
@@ -28,9 +28,6 @@ import java.util.Properties;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-/**
- * @author xigu.lx
- */
public class Configuration {
private final Logger log;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java b/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java
index a1a4061..23c27ac 100644
--- a/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java
+++ b/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java
@@ -23,7 +23,6 @@ import java.util.concurrent.locks.AbstractQueuedSynchronizer;
/**
* Add reset feature for @see java.util.concurrent.CountDownLatch2
*
- * @author yukon@apache.org
*/
public class CountDownLatch2 {
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/DataVersion.java b/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
index 067c028..1bb223f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
+++ b/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
@@ -21,9 +21,6 @@ import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
import java.util.concurrent.atomic.AtomicLong;
-/**
- * @author vintagewang@apache.org
- */
public class DataVersion extends RemotingSerializable {
private long timestatmp = System.currentTimeMillis();
private AtomicLong counter = new AtomicLong(0);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/MQVersion.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/MQVersion.java b/common/src/main/java/org/apache/rocketmq/common/MQVersion.java
index d2c1a45..3543161 100644
--- a/common/src/main/java/org/apache/rocketmq/common/MQVersion.java
+++ b/common/src/main/java/org/apache/rocketmq/common/MQVersion.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.common;
-/**
- * @author vintagewang@apache.org
- */
public class MQVersion {
public static final int CURRENT_VERSION = Version.V4_0_0_SNAPSHOT.ordinal();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/MixAll.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/MixAll.java b/common/src/main/java/org/apache/rocketmq/common/MixAll.java
index 1e8374c..bca55f5 100644
--- a/common/src/main/java/org/apache/rocketmq/common/MixAll.java
+++ b/common/src/main/java/org/apache/rocketmq/common/MixAll.java
@@ -48,9 +48,6 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
-/**
- * @author vintagewang@apache.org
- */
public class MixAll {
public static final String ROCKETMQ_HOME_ENV = "ROCKETMQ_HOME";
public static final String ROCKETMQ_HOME_PROPERTY = "rocketmq.home.dir";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/Pair.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/Pair.java b/common/src/main/java/org/apache/rocketmq/common/Pair.java
index dd8fded..45f6dee 100644
--- a/common/src/main/java/org/apache/rocketmq/common/Pair.java
+++ b/common/src/main/java/org/apache/rocketmq/common/Pair.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.common;
-/**
- * @author vintagewang@apache.org
- */
public class Pair<T1, T2> {
private T1 object1;
private T2 object2;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/ServiceState.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/ServiceState.java b/common/src/main/java/org/apache/rocketmq/common/ServiceState.java
index f211d7b..c8fbfea 100644
--- a/common/src/main/java/org/apache/rocketmq/common/ServiceState.java
+++ b/common/src/main/java/org/apache/rocketmq/common/ServiceState.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.common;
-/**
- * @author vintagewang@apache.org
- */
public enum ServiceState {
/**
* Service just created,not start
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java b/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java
index 8884a96..c0ae430 100644
--- a/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java
+++ b/common/src/main/java/org/apache/rocketmq/common/ServiceThread.java
@@ -23,10 +23,6 @@ import org.slf4j.LoggerFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-/**
- * @author vintagewang@apache.org
- * @author yukon@apache.org
- */
public abstract class ServiceThread implements Runnable {
private static final Logger STLOG = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
private static final long JOIN_TIME = 90 * 1000;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/SystemClock.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/SystemClock.java b/common/src/main/java/org/apache/rocketmq/common/SystemClock.java
index f86a4f5..5abc805 100644
--- a/common/src/main/java/org/apache/rocketmq/common/SystemClock.java
+++ b/common/src/main/java/org/apache/rocketmq/common/SystemClock.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.common;
-/**
- * @author vintage.wang
- */
public class SystemClock {
public long now() {
return System.currentTimeMillis();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java b/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
index 9fa8e94..9eec278 100644
--- a/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
+++ b/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
@@ -19,9 +19,6 @@ package org.apache.rocketmq.common;
import org.apache.rocketmq.common.constant.PermName;
-/**
- * @author vintagewang@apache.org
- */
public class TopicConfig {
private static final String SEPARATOR = " ";
public static int defaultReadQueueNums = 16;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java b/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java
index d98a972..cd3490a 100644
--- a/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java
+++ b/common/src/main/java/org/apache/rocketmq/common/TopicFilterType.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.common;
-/**
- * @author vintagewang@apache.org
- */
public enum TopicFilterType {
SINGLE_TAG,
MULTI_TAG
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
index 5ab75b5..55d9b3f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
+++ b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
@@ -36,9 +36,6 @@ import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;
-/**
- * @author vintagewang@apache.org
- */
public class UtilAll {
public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
public static final String YYYY_MM_DD_HH_MM_SS_SSS = "yyyy-MM-dd#HH:mm:ss:SSS";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java b/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
index 2e9d1bb..efab41b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/ConsumeStats.java
@@ -26,7 +26,6 @@ import java.util.Map.Entry;
/**
*
- * @author vintagewang@apache.org
*
*/
public class ConsumeStats extends RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java b/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
index 218e033..170509a 100644
--- a/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/OffsetWrapper.java
@@ -18,7 +18,6 @@ package org.apache.rocketmq.common.admin;
/**
*
- * @author vintagewang@apache.org
*
*/
public class OffsetWrapper {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/admin/RollbackStats.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/RollbackStats.java b/common/src/main/java/org/apache/rocketmq/common/admin/RollbackStats.java
index 5709327..3af6a0c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/admin/RollbackStats.java
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/RollbackStats.java
@@ -19,7 +19,6 @@ package org.apache.rocketmq.common.admin;
/**
*
- * @author manhong.yqd
*/
public class RollbackStats {
private String brokerName;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java b/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
index fc1e2ce..f64ddcb 100644
--- a/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/TopicOffset.java
@@ -18,7 +18,6 @@ package org.apache.rocketmq.common.admin;
/**
*
- * @author vintagewang@apache.org
*
*/
public class TopicOffset {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java b/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
index db73eb8..a9e9e84 100644
--- a/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
+++ b/common/src/main/java/org/apache/rocketmq/common/admin/TopicStatsTable.java
@@ -24,7 +24,6 @@ import java.util.HashMap;
/**
*
- * @author vintagewang@apache.org
*
*/
public class TopicStatsTable extends RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java b/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java
index e88a57b..2bcfacf 100644
--- a/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java
+++ b/common/src/main/java/org/apache/rocketmq/common/constant/LoggerName.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.common.constant;
-/**
- * @author vintagewang@apache.org
- */
public class LoggerName {
public static final String FILTERSRV_LOGGER_NAME = "RocketmqFiltersrv";
public static final String NAMESRV_LOGGER_NAME = "RocketmqNamesrv";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java b/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java
index d9a524c..e5ab1fc 100644
--- a/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java
+++ b/common/src/main/java/org/apache/rocketmq/common/constant/PermName.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.common.constant;
-/**
- * @author vintagewang@apache.org
- */
public class PermName {
public static final int PERM_PRIORITY = 0x1 << 3;
public static final int PERM_READ = 0x1 << 2;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java b/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java
index fc43a81..2c8e989 100644
--- a/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java
+++ b/common/src/main/java/org/apache/rocketmq/common/consumer/ConsumeFromWhere.java
@@ -18,7 +18,6 @@ package org.apache.rocketmq.common.consumer;
/**
*
- * @author vintagewang@apache.org
*/
public enum ConsumeFromWhere {
CONSUME_FROM_LAST_OFFSET,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.java b/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.java
index 0396023..7f558ef 100644
--- a/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.java
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/FilterAPI.java
@@ -22,7 +22,6 @@ import java.net.URL;
/**
- * @author vintagewang@apache.org
*
*/
public class FilterAPI {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java b/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java
index 0118ff8..d3c5f33 100644
--- a/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java
+++ b/common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.common.help;
-/**
- * @author vintagewang@apache.org
- */
public class FAQUrl {
public static final String APPLY_TOPIC_URL = //
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java b/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java
index a99df6e..10b1097 100644
--- a/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java
+++ b/common/src/main/java/org/apache/rocketmq/common/hook/FilterCheckHook.java
@@ -22,7 +22,6 @@ import java.nio.ByteBuffer;
/**
*
- * @author manhong.yqd
*
*/
public interface FilterCheckHook {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/message/Message.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/Message.java b/common/src/main/java/org/apache/rocketmq/common/message/Message.java
index ac13e36..258104c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/Message.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/Message.java
@@ -24,7 +24,6 @@ import java.util.Map;
/**
*
- * @author vintagewang@apache.org
*
*/
public class Message implements Serializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
index 285e372..375cc47 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
@@ -32,9 +32,6 @@ import java.util.List;
import java.util.Map;
-/**
- * @author vintagewang@apache.org
- */
public class MessageDecoder {
public final static int MSG_ID_LENGTH = 8 + 8;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
index c159ac2..b771666 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
@@ -24,9 +24,6 @@ import java.net.SocketAddress;
import java.nio.ByteBuffer;
-/**
- * @author vintagewang@apache.org
- */
public class MessageExt extends Message {
private static final long serialVersionUID = 5720810158625748049L;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java
index 87ad4e6..04dd01f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageId.java
@@ -19,9 +19,6 @@ package org.apache.rocketmq.common.message;
import java.net.SocketAddress;
-/**
- * @author vintagewang@apache.org
- */
public class MessageId {
private SocketAddress address;
private long offset;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
index 7850cd3..6274d96 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
@@ -19,9 +19,6 @@ package org.apache.rocketmq.common.message;
import java.io.Serializable;
-/**
- * @author vintagewang@apache.org
- */
public class MessageQueue implements Comparable<MessageQueue>, Serializable {
private static final long serialVersionUID = 6191200464116433425L;
private String topic;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java
index 27b5e07..4a8fb6f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java
@@ -20,9 +20,6 @@ package org.apache.rocketmq.common.message;
import java.io.Serializable;
-/**
- * @author lansheng.zj
- */
public class MessageQueueForC implements Comparable<MessageQueueForC>, Serializable {
private static final long serialVersionUID = 5320967846569962104L;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
index 0ba82ac..fe3e8e3 100644
--- a/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
+++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
@@ -30,8 +30,6 @@ import java.io.File;
/**
*
- * @author vintagewang@apache.org
- * @author lansheng.zj
*/
public class NamesrvConfig {
private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java
index 0622d4b..2b0a1ed 100644
--- a/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java
+++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvUtil.java
@@ -17,9 +17,6 @@
package org.apache.rocketmq.common.namesrv;
-/**
- * @author vintagewang@apache.org
- */
public class NamesrvUtil {
public static final String NAMESPACE_ORDER_TOPIC_CONFIG = "ORDER_TOPIC_CONFIG";
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java
index 80b8df0..d74b477 100644
--- a/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java
+++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/RegisterBrokerResult.java
@@ -20,9 +20,6 @@ package org.apache.rocketmq.common.namesrv;
import org.apache.rocketmq.common.protocol.body.KVTable;
-/**
- * @author vintagewang@apache.org
- */
public class RegisterBrokerResult {
private String haServerAddr;
private String masterAddr;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
index d5a4d88..15a2f13 100644
--- a/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
+++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
@@ -31,10 +31,6 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
-/**
- * @author vintagewang@apache.org
- * @author manhong.yqd
- */
public class TopAddressing {
private static final Logger log = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
private String nsAddr;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java b/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java
index 4774aea..0ea12eb 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/MQProtosHelper.java
@@ -25,9 +25,6 @@ import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-/**
- * @author vintagewang@apache.org
- */
public class MQProtosHelper {
public static boolean registerBrokerToNameServer(final String nsaddr, final String brokerAddr,
final long timeoutMillis) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java
index a7b53d7..a88616f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ClusterInfo.java
@@ -26,9 +26,6 @@ import java.util.List;
import java.util.Set;
-/**
- * @author vintagewang@apache.org
- */
public class ClusterInfo extends RemotingSerializable {
private HashMap<String/* brokerName */, BrokerData> brokerAddrTable;
private HashMap<String/* clusterName */, Set<String/* brokerName */>> clusterAddrTable;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java
index f504880..76f0921 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/Connection.java
@@ -20,9 +20,6 @@ package org.apache.rocketmq.common.protocol.body;
import org.apache.rocketmq.remoting.protocol.LanguageCode;
-/**
- * @author vintagewang@apache.org
- */
public class Connection {
private String clientId;
private String clientAddr;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java
index 5e33ef7..8342144 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeByWho.java
@@ -22,7 +22,6 @@ import java.util.HashSet;
/**
- * @author vintagewang@apache.org
*
*/
public class ConsumeByWho extends RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java
index 53b4345..c907555 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumeStatsList.java
@@ -24,9 +24,6 @@ import java.util.List;
import java.util.Map;
-/**
- * @author vintagewang@apache.org
- */
public class ConsumeStatsList extends RemotingSerializable {
private List<Map<String/*subscriptionGroupName*/, List<ConsumeStats>>> consumeStatsList = new ArrayList<Map<String/*subscriptionGroupName*/, List<ConsumeStats>>>();
private String brokerAddr;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java
index c2dc644..bc2acad 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerConnection.java
@@ -27,9 +27,6 @@ import java.util.HashSet;
import java.util.concurrent.ConcurrentHashMap;
-/**
- * @author vintagewang@apache.org
- */
public class ConsumerConnection extends RemotingSerializable {
private HashSet<Connection> connectionSet = new HashSet<Connection>();
private ConcurrentHashMap<String/* Topic */, SubscriptionData> subscriptionTable =
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerOffsetSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerOffsetSerializeWrapper.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerOffsetSerializeWrapper.java
index 5b4c6fb..1ce7cf4 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerOffsetSerializeWrapper.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerOffsetSerializeWrapper.java
@@ -22,9 +22,6 @@ import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
import java.util.concurrent.ConcurrentHashMap;
-/**
- * @author manhong.yqd
- */
public class ConsumerOffsetSerializeWrapper extends RemotingSerializable {
private ConcurrentHashMap<String/* topic@group */, ConcurrentHashMap<Integer, Long>> offsetTable =
new ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>>(512);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/GetConsumerStatusBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/GetConsumerStatusBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/GetConsumerStatusBody.java
index 71d8667..d37116c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/GetConsumerStatusBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/GetConsumerStatusBody.java
@@ -24,9 +24,6 @@ import java.util.HashMap;
import java.util.Map;
-/**
- * @author manhong.yqd
- */
@Deprecated
public class GetConsumerStatusBody extends RemotingSerializable {
private Map<MessageQueue, Long> messageQueueTable = new HashMap<MessageQueue, Long>();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java
index 0bc526b..e67dd8c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/GroupList.java
@@ -22,7 +22,6 @@ import java.util.HashSet;
/**
- * @author vintagewang@apache.org
*
*/
public class GroupList extends RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java
index 8ae3371..18b20a2 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/KVTable.java
@@ -22,7 +22,6 @@ import java.util.HashMap;
/**
- * @author vintagewang@apache.org
*
*/
public class KVTable extends RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java
index 19fdaa9..59768ff 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchRequestBody.java
@@ -25,7 +25,6 @@ import java.util.Set;
/**
- * @author vintagewang@apache.org
*
*/
public class LockBatchRequestBody extends RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java
index 4a7c1a7..e1a5117 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/LockBatchResponseBody.java
@@ -25,7 +25,6 @@ import java.util.Set;
/**
- * @author vintagewang@apache.org
*
*/
public class LockBatchResponseBody extends RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java
index aa4e29b..99ac6ba 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ProducerConnection.java
@@ -22,9 +22,6 @@ import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
import java.util.HashSet;
-/**
- * @author vintagewang@apache.org
- */
public class ProducerConnection extends RemotingSerializable {
private HashSet<Connection> connectionSet = new HashSet<Connection>();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java
index 98279c8..9daff00 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryConsumeTimeSpanBody.java
@@ -23,9 +23,6 @@ import java.util.ArrayList;
import java.util.List;
-/**
- * @author manhong.yqd
- */
public class QueryConsumeTimeSpanBody extends RemotingSerializable {
List<QueueTimeSpan> consumeTimeSpanSet = new ArrayList<QueueTimeSpan>();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java
index efe491d..18b1ff4 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueryCorrectionOffsetBody.java
@@ -22,9 +22,6 @@ import java.util.HashMap;
import java.util.Map;
-/**
- * @author manhong.yqd
- */
public class QueryCorrectionOffsetBody extends RemotingSerializable {
private Map<Integer, Long> correctionOffsets = new HashMap<Integer, Long>();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueueTimeSpan.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueueTimeSpan.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueueTimeSpan.java
index c959c59..df1daf9 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueueTimeSpan.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/QueueTimeSpan.java
@@ -23,9 +23,6 @@ import org.apache.rocketmq.common.message.MessageQueue;
import java.util.Date;
-/**
- * @author manhong.yqd
- */
public class QueueTimeSpan {
private MessageQueue messageQueue;
private long minTimeStamp;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBody.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBody.java
index c311436..cefaa1f 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBody.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ResetOffsetBody.java
@@ -24,7 +24,6 @@ import java.util.Map;
/**
- * @author manhong.yqd
*
*/
public class ResetOffsetBody extends RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/common/src/main/java/org/apache/rocketmq/common/protocol/body/SubscriptionGroupWrapper.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/SubscriptionGroupWrapper.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/SubscriptionGroupWrapper.java
index ba63926..88b863e 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/SubscriptionGroupWrapper.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/SubscriptionGroupWrapper.java
@@ -24,9 +24,6 @@ import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
import java.util.concurrent.ConcurrentHashMap;
-/**
- * @author manhong.yqd
- */
public class SubscriptionGroupWrapper extends RemotingSerializable {
private ConcurrentHashMap<String, SubscriptionGroupConfig> subscriptionGroupTable =
new ConcurrentHashMap<String, SubscriptionGroupConfig>(1024);
[74/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java
index c82cbdf..9cccaaf 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java
@@ -6,20 +6,19 @@
* (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
+ * 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.
+ * 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.remoting.common;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
/**
* Base class for background thread
*
@@ -32,20 +31,16 @@ public abstract class ServiceThread implements Runnable {
protected volatile boolean hasNotified = false;
protected volatile boolean stopped = false;
-
public ServiceThread() {
this.thread = new Thread(this, this.getServiceName());
}
-
public abstract String getServiceName();
-
public void start() {
this.thread.start();
}
-
public void shutdown() {
this.shutdown(false);
}
@@ -69,7 +64,7 @@ public abstract class ServiceThread implements Runnable {
this.thread.join(this.getJointime());
long eclipseTime = System.currentTimeMillis() - beginTime;
STLOG.info("join thread " + this.getServiceName() + " eclipse time(ms) " + eclipseTime + " "
- + this.getJointime());
+ + this.getJointime());
} catch (InterruptedException e) {
e.printStackTrace();
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingCommandException.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingCommandException.java b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingCommandException.java
index 72c5287..62a10a6 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingCommandException.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingCommandException.java
@@ -6,25 +6,23 @@
* (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
+ * 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.
+ * 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.remoting.exception;
public class RemotingCommandException extends RemotingException {
private static final long serialVersionUID = -6061365915274953096L;
-
public RemotingCommandException(String message) {
super(message, null);
}
-
public RemotingCommandException(String message, Throwable cause) {
super(message, cause);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingConnectException.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingConnectException.java b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingConnectException.java
index 2fa4d69..c3e4777 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingConnectException.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingConnectException.java
@@ -6,25 +6,23 @@
* (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
+ * 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.
+ * 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.remoting.exception;
public class RemotingConnectException extends RemotingException {
private static final long serialVersionUID = -5565366231695911316L;
-
public RemotingConnectException(String addr) {
this(addr, null);
}
-
public RemotingConnectException(String addr, Throwable cause) {
super("connect to <" + addr + "> failed", cause);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingException.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingException.java b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingException.java
index f4a79ea..cbc363b 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingException.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingException.java
@@ -6,25 +6,23 @@
* (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
+ * 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.
+ * 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.remoting.exception;
public class RemotingException extends Exception {
private static final long serialVersionUID = -5690687334570505110L;
-
public RemotingException(String message) {
super(message);
}
-
public RemotingException(String message, Throwable cause) {
super(message, cause);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingSendRequestException.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingSendRequestException.java b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingSendRequestException.java
index 720ec1f..4eb1b63 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingSendRequestException.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingSendRequestException.java
@@ -6,25 +6,23 @@
* (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
+ * 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.
+ * 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.remoting.exception;
public class RemotingSendRequestException extends RemotingException {
private static final long serialVersionUID = 5391285827332471674L;
-
public RemotingSendRequestException(String addr) {
this(addr, null);
}
-
public RemotingSendRequestException(String addr, Throwable cause) {
super("send request to <" + addr + "> failed", cause);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTimeoutException.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTimeoutException.java b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTimeoutException.java
index 1190b49..e4cc69e 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTimeoutException.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTimeoutException.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.remoting.exception;
@@ -20,17 +20,14 @@ public class RemotingTimeoutException extends RemotingException {
private static final long serialVersionUID = 4106899185095245979L;
-
public RemotingTimeoutException(String message) {
super(message);
}
-
public RemotingTimeoutException(String addr, long timeoutMillis) {
this(addr, timeoutMillis, null);
}
-
public RemotingTimeoutException(String addr, long timeoutMillis, Throwable cause) {
super("wait response on the channel <" + addr + "> timeout, " + timeoutMillis + "(ms)", cause);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTooMuchRequestException.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTooMuchRequestException.java b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTooMuchRequestException.java
index 80d4418..8ec5cf6 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTooMuchRequestException.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTooMuchRequestException.java
@@ -6,20 +6,19 @@
* (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
+ * 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.
+ * 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.remoting.exception;
public class RemotingTooMuchRequestException extends RemotingException {
private static final long serialVersionUID = 4326919581254519654L;
-
public RemotingTooMuchRequestException(String message) {
super(message);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyClientConfig.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyClientConfig.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyClientConfig.java
index b797272..7c017eb 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyClientConfig.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyClientConfig.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.remoting.netty;
@@ -53,97 +53,78 @@ public class NettyClientConfig {
return clientWorkerThreads;
}
-
public void setClientWorkerThreads(int clientWorkerThreads) {
this.clientWorkerThreads = clientWorkerThreads;
}
-
public int getClientOnewaySemaphoreValue() {
return clientOnewaySemaphoreValue;
}
-
public void setClientOnewaySemaphoreValue(int clientOnewaySemaphoreValue) {
this.clientOnewaySemaphoreValue = clientOnewaySemaphoreValue;
}
-
public int getConnectTimeoutMillis() {
return connectTimeoutMillis;
}
-
public void setConnectTimeoutMillis(int connectTimeoutMillis) {
this.connectTimeoutMillis = connectTimeoutMillis;
}
-
public int getClientCallbackExecutorThreads() {
return clientCallbackExecutorThreads;
}
-
public void setClientCallbackExecutorThreads(int clientCallbackExecutorThreads) {
this.clientCallbackExecutorThreads = clientCallbackExecutorThreads;
}
-
public long getChannelNotActiveInterval() {
return channelNotActiveInterval;
}
-
public void setChannelNotActiveInterval(long channelNotActiveInterval) {
this.channelNotActiveInterval = channelNotActiveInterval;
}
-
public int getClientAsyncSemaphoreValue() {
return clientAsyncSemaphoreValue;
}
-
public void setClientAsyncSemaphoreValue(int clientAsyncSemaphoreValue) {
this.clientAsyncSemaphoreValue = clientAsyncSemaphoreValue;
}
-
public int getClientChannelMaxIdleTimeSeconds() {
return clientChannelMaxIdleTimeSeconds;
}
-
public void setClientChannelMaxIdleTimeSeconds(int clientChannelMaxIdleTimeSeconds) {
this.clientChannelMaxIdleTimeSeconds = clientChannelMaxIdleTimeSeconds;
}
-
public int getClientSocketSndBufSize() {
return clientSocketSndBufSize;
}
-
public void setClientSocketSndBufSize(int clientSocketSndBufSize) {
this.clientSocketSndBufSize = clientSocketSndBufSize;
}
-
public int getClientSocketRcvBufSize() {
return clientSocketRcvBufSize;
}
-
public void setClientSocketRcvBufSize(int clientSocketRcvBufSize) {
this.clientSocketRcvBufSize = clientSocketRcvBufSize;
}
-
public boolean isClientPooledByteBufAllocatorEnable() {
return clientPooledByteBufAllocatorEnable;
}
-
public void setClientPooledByteBufAllocatorEnable(boolean clientPooledByteBufAllocatorEnable) {
this.clientPooledByteBufAllocatorEnable = clientPooledByteBufAllocatorEnable;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
index 0a8ba97..73d7f2b 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
@@ -6,47 +6,43 @@
* (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
+ * 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.
+ * 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.remoting.netty;
-import org.apache.rocketmq.remoting.common.RemotingHelper;
-import org.apache.rocketmq.remoting.common.RemotingUtil;
-import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
+import java.nio.ByteBuffer;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.common.RemotingUtil;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.nio.ByteBuffer;
-
-
/**
*
*/
public class NettyDecoder extends LengthFieldBasedFrameDecoder {
private static final Logger log = LoggerFactory.getLogger(RemotingHelper.ROCKETMQ_REMOTING);
private static final int FRAME_MAX_LENGTH = //
- Integer.parseInt(System.getProperty("com.rocketmq.remoting.frameMaxLength", "16777216"));
-
+ Integer.parseInt(System.getProperty("com.rocketmq.remoting.frameMaxLength", "16777216"));
public NettyDecoder() {
super(FRAME_MAX_LENGTH, 0, 4, 0, 4);
}
-
@Override
public Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
ByteBuf frame = null;
try {
- frame = (ByteBuf) super.decode(ctx, in);
+ frame = (ByteBuf)super.decode(ctx, in);
if (null == frame) {
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEncoder.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEncoder.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEncoder.java
index 35adcf2..fdebcdc 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEncoder.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEncoder.java
@@ -6,28 +6,26 @@
* (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
+ * 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.
+ * 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.remoting.netty;
-import org.apache.rocketmq.remoting.common.RemotingHelper;
-import org.apache.rocketmq.remoting.common.RemotingUtil;
-import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
+import java.nio.ByteBuffer;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.common.RemotingUtil;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.nio.ByteBuffer;
-
-
/**
*
*/
@@ -36,7 +34,7 @@ public class NettyEncoder extends MessageToByteEncoder<RemotingCommand> {
@Override
public void encode(ChannelHandlerContext ctx, RemotingCommand remotingCommand, ByteBuf out)
- throws Exception {
+ throws Exception {
try {
ByteBuffer header = remotingCommand.encodeHeader();
out.writeBytes(header);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEvent.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEvent.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEvent.java
index e086409..825d1da 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEvent.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEvent.java
@@ -6,47 +6,41 @@
* (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
+ * 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.
+ * 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.remoting.netty;
import io.netty.channel.Channel;
-
public class NettyEvent {
private final NettyEventType type;
private final String remoteAddr;
private final Channel channel;
-
public NettyEvent(NettyEventType type, String remoteAddr, Channel channel) {
this.type = type;
this.remoteAddr = remoteAddr;
this.channel = channel;
}
-
public NettyEventType getType() {
return type;
}
-
public String getRemoteAddr() {
return remoteAddr;
}
-
public Channel getChannel() {
return channel;
}
-
@Override
public String toString() {
return "NettyEvent [type=" + type + ", remoteAddr=" + remoteAddr + ", channel=" + channel + "]";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEventType.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEventType.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEventType.java
index ae4b647..b2135da 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEventType.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEventType.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.remoting.netty;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java
index 1034dd8..c0136d3 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java
@@ -16,25 +16,10 @@
*/
package org.apache.rocketmq.remoting.netty;
-import org.apache.rocketmq.remoting.ChannelEventListener;
-import org.apache.rocketmq.remoting.InvokeCallback;
-import org.apache.rocketmq.remoting.RPCHook;
-import org.apache.rocketmq.remoting.common.Pair;
-import org.apache.rocketmq.remoting.common.RemotingHelper;
-import org.apache.rocketmq.remoting.common.SemaphoreReleaseOnlyOnce;
-import org.apache.rocketmq.remoting.common.ServiceThread;
-import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
-import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
-import org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException;
-import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-import org.apache.rocketmq.remoting.protocol.RemotingSysResponseCode;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.net.SocketAddress;
import java.util.HashMap;
import java.util.Iterator;
@@ -47,28 +32,37 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
-
+import org.apache.rocketmq.remoting.ChannelEventListener;
+import org.apache.rocketmq.remoting.InvokeCallback;
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.remoting.common.Pair;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.common.SemaphoreReleaseOnlyOnce;
+import org.apache.rocketmq.remoting.common.ServiceThread;
+import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
+import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
+import org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.apache.rocketmq.remoting.protocol.RemotingSysResponseCode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public abstract class NettyRemotingAbstract {
private static final Logger PLOG = LoggerFactory.getLogger(RemotingHelper.ROCKETMQ_REMOTING);
-
protected final Semaphore semaphoreOneway;
-
protected final Semaphore semaphoreAsync;
-
protected final ConcurrentHashMap<Integer /* opaque */, ResponseFuture> responseTable =
- new ConcurrentHashMap<Integer, ResponseFuture>(256);
+ new ConcurrentHashMap<Integer, ResponseFuture>(256);
protected final HashMap<Integer/* request code */, Pair<NettyRequestProcessor, ExecutorService>> processorTable =
- new HashMap<Integer, Pair<NettyRequestProcessor, ExecutorService>>(64);
+ new HashMap<Integer, Pair<NettyRequestProcessor, ExecutorService>>(64);
protected final NettyEventExecuter nettyEventExecuter = new NettyEventExecuter();
protected Pair<NettyRequestProcessor, ExecutorService> defaultRequestProcessor;
-
public NettyRemotingAbstract(final int permitsOneway, final int permitsAsync) {
this.semaphoreOneway = new Semaphore(permitsOneway, true);
this.semaphoreAsync = new Semaphore(permitsAsync, true);
@@ -133,14 +127,14 @@ public abstract class NettyRemotingAbstract {
}
} catch (Throwable e) {
if (!"com.aliyun.openservices.ons.api.impl.authority.exception.AuthenticationException"
- .equals(e.getClass().getCanonicalName())) {
+ .equals(e.getClass().getCanonicalName())) {
PLOG.error("process request exception", e);
PLOG.error(cmd.toString());
}
if (!cmd.isOnewayRPC()) {
final RemotingCommand response = RemotingCommand.createResponseCommand(RemotingSysResponseCode.SYSTEM_ERROR, //
- RemotingHelper.exceptionSimpleDesc(e));
+ RemotingHelper.exceptionSimpleDesc(e));
response.setOpaque(opaque);
ctx.writeAndFlush(response);
}
@@ -150,7 +144,7 @@ public abstract class NettyRemotingAbstract {
if (pair.getObject1().rejectRequest()) {
final RemotingCommand response = RemotingCommand.createResponseCommand(RemotingSysResponseCode.SYSTEM_BUSY,
- "[REJECTREQUEST]system busy, start flow control for a while");
+ "[REJECTREQUEST]system busy, start flow control for a while");
response.setOpaque(opaque);
ctx.writeAndFlush(response);
return;
@@ -162,14 +156,14 @@ public abstract class NettyRemotingAbstract {
} catch (RejectedExecutionException e) {
if ((System.currentTimeMillis() % 10000) == 0) {
PLOG.warn(RemotingHelper.parseChannelRemoteAddr(ctx.channel()) //
- + ", too many requests and system thread pool busy, RejectedExecutionException " //
- + pair.getObject2().toString() //
- + " request code: " + cmd.getCode());
+ + ", too many requests and system thread pool busy, RejectedExecutionException " //
+ + pair.getObject2().toString() //
+ + " request code: " + cmd.getCode());
}
if (!cmd.isOnewayRPC()) {
final RemotingCommand response = RemotingCommand.createResponseCommand(RemotingSysResponseCode.SYSTEM_BUSY,
- "[OVERLOAD]system busy, start flow control for a while");
+ "[OVERLOAD]system busy, start flow control for a while");
response.setOpaque(opaque);
ctx.writeAndFlush(response);
}
@@ -177,7 +171,7 @@ public abstract class NettyRemotingAbstract {
} else {
String error = " request type " + cmd.getCode() + " not supported";
final RemotingCommand response =
- RemotingCommand.createResponseCommand(RemotingSysResponseCode.REQUEST_CODE_NOT_SUPPORTED, error);
+ RemotingCommand.createResponseCommand(RemotingSysResponseCode.REQUEST_CODE_NOT_SUPPORTED, error);
response.setOpaque(opaque);
ctx.writeAndFlush(response);
PLOG.error(RemotingHelper.parseChannelRemoteAddr(ctx.channel()) + error);
@@ -267,7 +261,7 @@ public abstract class NettyRemotingAbstract {
}
public RemotingCommand invokeSyncImpl(final Channel channel, final RemotingCommand request, final long timeoutMillis)
- throws InterruptedException, RemotingSendRequestException, RemotingTimeoutException {
+ throws InterruptedException, RemotingSendRequestException, RemotingTimeoutException {
final int opaque = request.getOpaque();
try {
@@ -295,7 +289,7 @@ public abstract class NettyRemotingAbstract {
if (null == responseCommand) {
if (responseFuture.isSendRequestOK()) {
throw new RemotingTimeoutException(RemotingHelper.parseSocketAddressAddr(addr), timeoutMillis,
- responseFuture.getCause());
+ responseFuture.getCause());
} else {
throw new RemotingSendRequestException(RemotingHelper.parseSocketAddressAddr(addr), responseFuture.getCause());
}
@@ -308,8 +302,8 @@ public abstract class NettyRemotingAbstract {
}
public void invokeAsyncImpl(final Channel channel, final RemotingCommand request, final long timeoutMillis,
- final InvokeCallback invokeCallback)
- throws InterruptedException, RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
+ final InvokeCallback invokeCallback)
+ throws InterruptedException, RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
final int opaque = request.getOpaque();
boolean acquired = this.semaphoreAsync.tryAcquire(timeoutMillis, TimeUnit.MILLISECONDS);
if (acquired) {
@@ -348,18 +342,18 @@ public abstract class NettyRemotingAbstract {
}
} else {
String info =
- String.format("invokeAsyncImpl tryAcquire semaphore timeout, %dms, waiting thread nums: %d semaphoreAsyncValue: %d", //
- timeoutMillis, //
- this.semaphoreAsync.getQueueLength(), //
- this.semaphoreAsync.availablePermits()//
- );
+ String.format("invokeAsyncImpl tryAcquire semaphore timeout, %dms, waiting thread nums: %d semaphoreAsyncValue: %d", //
+ timeoutMillis, //
+ this.semaphoreAsync.getQueueLength(), //
+ this.semaphoreAsync.availablePermits()//
+ );
PLOG.warn(info);
throw new RemotingTooMuchRequestException(info);
}
}
public void invokeOnewayImpl(final Channel channel, final RemotingCommand request, final long timeoutMillis)
- throws InterruptedException, RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
+ throws InterruptedException, RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
request.markOnewayRPC();
boolean acquired = this.semaphoreOneway.tryAcquire(timeoutMillis, TimeUnit.MILLISECONDS);
if (acquired) {
@@ -384,10 +378,10 @@ public abstract class NettyRemotingAbstract {
throw new RemotingTooMuchRequestException("invokeOnewayImpl invoke too fast");
} else {
String info = String.format(
- "invokeOnewayImpl tryAcquire semaphore timeout, %dms, waiting thread nums: %d semaphoreAsyncValue: %d", //
- timeoutMillis, //
- this.semaphoreOneway.getQueueLength(), //
- this.semaphoreOneway.availablePermits()//
+ "invokeOnewayImpl tryAcquire semaphore timeout, %dms, waiting thread nums: %d semaphoreAsyncValue: %d", //
+ timeoutMillis, //
+ this.semaphoreOneway.getQueueLength(), //
+ this.semaphoreOneway.availablePermits()//
);
PLOG.warn(info);
throw new RemotingTimeoutException(info);
@@ -399,7 +393,6 @@ public abstract class NettyRemotingAbstract {
private final LinkedBlockingQueue<NettyEvent> eventQueue = new LinkedBlockingQueue<NettyEvent>();
private final int maxSize = 10000;
-
public void putNettyEvent(final NettyEvent event) {
if (this.eventQueue.size() <= maxSize) {
this.eventQueue.add(event);
@@ -408,7 +401,6 @@ public abstract class NettyRemotingAbstract {
}
}
-
@Override
public void run() {
PLOG.info(this.getServiceName() + " service started");
@@ -445,7 +437,6 @@ public abstract class NettyRemotingAbstract {
PLOG.info(this.getServiceName() + " service end");
}
-
@Override
public String getServiceName() {
return NettyEventExecuter.class.getSimpleName();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
index 3b7013a..db7815a 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
@@ -16,18 +16,6 @@
*/
package org.apache.rocketmq.remoting.netty;
-import org.apache.rocketmq.remoting.ChannelEventListener;
-import org.apache.rocketmq.remoting.InvokeCallback;
-import org.apache.rocketmq.remoting.RPCHook;
-import org.apache.rocketmq.remoting.RemotingClient;
-import org.apache.rocketmq.remoting.common.Pair;
-import org.apache.rocketmq.remoting.common.RemotingHelper;
-import org.apache.rocketmq.remoting.common.RemotingUtil;
-import org.apache.rocketmq.remoting.exception.RemotingConnectException;
-import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
-import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
-import org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException;
-import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelDuplexHandler;
@@ -45,9 +33,6 @@ import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.util.concurrent.DefaultEventExecutorGroup;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.net.SocketAddress;
import java.util.Collections;
import java.util.List;
@@ -64,7 +49,20 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-
+import org.apache.rocketmq.remoting.ChannelEventListener;
+import org.apache.rocketmq.remoting.InvokeCallback;
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.remoting.RemotingClient;
+import org.apache.rocketmq.remoting.common.Pair;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.common.RemotingUtil;
+import org.apache.rocketmq.remoting.exception.RemotingConnectException;
+import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
+import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
+import org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class NettyRemotingClient extends NettyRemotingAbstract implements RemotingClient {
private static final Logger log = LoggerFactory.getLogger(RemotingHelper.ROCKETMQ_REMOTING);
@@ -94,7 +92,7 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
}
public NettyRemotingClient(final NettyClientConfig nettyClientConfig, //
- final ChannelEventListener channelEventListener) {
+ final ChannelEventListener channelEventListener) {
super(nettyClientConfig.getClientOnewaySemaphoreValue(), nettyClientConfig.getClientAsyncSemaphoreValue());
this.nettyClientConfig = nettyClientConfig;
this.channelEventListener = channelEventListener;
@@ -107,7 +105,6 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
this.publicExecutor = Executors.newFixedThreadPool(publicThreadNums, new ThreadFactory() {
private AtomicInteger threadIndex = new AtomicInteger(0);
-
@Override
public Thread newThread(Runnable r) {
return new Thread(r, "NettyClientPublicExecutor_" + this.threadIndex.incrementAndGet());
@@ -117,7 +114,6 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
this.eventLoopGroupWorker = new NioEventLoopGroup(1, new ThreadFactory() {
private AtomicInteger threadIndex = new AtomicInteger(0);
-
@Override
public Thread newThread(Runnable r) {
return new Thread(r, String.format("NettyClientSelector_%d", this.threadIndex.incrementAndGet()));
@@ -134,36 +130,35 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
@Override
public void start() {
this.defaultEventExecutorGroup = new DefaultEventExecutorGroup(//
- nettyClientConfig.getClientWorkerThreads(), //
- new ThreadFactory() {
+ nettyClientConfig.getClientWorkerThreads(), //
+ new ThreadFactory() {
- private AtomicInteger threadIndex = new AtomicInteger(0);
+ private AtomicInteger threadIndex = new AtomicInteger(0);
-
- @Override
- public Thread newThread(Runnable r) {
- return new Thread(r, "NettyClientWorkerThread_" + this.threadIndex.incrementAndGet());
- }
- });
+ @Override
+ public Thread newThread(Runnable r) {
+ return new Thread(r, "NettyClientWorkerThread_" + this.threadIndex.incrementAndGet());
+ }
+ });
Bootstrap handler = this.bootstrap.group(this.eventLoopGroupWorker).channel(NioSocketChannel.class)//
- .option(ChannelOption.TCP_NODELAY, true)
- .option(ChannelOption.SO_KEEPALIVE, false)
- .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, nettyClientConfig.getConnectTimeoutMillis())
- .option(ChannelOption.SO_SNDBUF, nettyClientConfig.getClientSocketSndBufSize())
- .option(ChannelOption.SO_RCVBUF, nettyClientConfig.getClientSocketRcvBufSize())
- .handler(new ChannelInitializer<SocketChannel>() {
- @Override
- public void initChannel(SocketChannel ch) throws Exception {
- ch.pipeline().addLast(
- defaultEventExecutorGroup,
- new NettyEncoder(),
- new NettyDecoder(),
- new IdleStateHandler(0, 0, nettyClientConfig.getClientChannelMaxIdleTimeSeconds()),
- new NettyConnetManageHandler(),
- new NettyClientHandler());
- }
- });
+ .option(ChannelOption.TCP_NODELAY, true)
+ .option(ChannelOption.SO_KEEPALIVE, false)
+ .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, nettyClientConfig.getConnectTimeoutMillis())
+ .option(ChannelOption.SO_SNDBUF, nettyClientConfig.getClientSocketSndBufSize())
+ .option(ChannelOption.SO_RCVBUF, nettyClientConfig.getClientSocketRcvBufSize())
+ .handler(new ChannelInitializer<SocketChannel>() {
+ @Override
+ public void initChannel(SocketChannel ch) throws Exception {
+ ch.pipeline().addLast(
+ defaultEventExecutorGroup,
+ new NettyEncoder(),
+ new NettyDecoder(),
+ new IdleStateHandler(0, 0, nettyClientConfig.getClientChannelMaxIdleTimeSeconds()),
+ new NettyConnetManageHandler(),
+ new NettyClientHandler());
+ }
+ });
this.timer.scheduleAtFixedRate(new TimerTask() {
@Override
@@ -233,7 +228,7 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
removeItemFromTable = false;
} else if (prevCW.getChannel() != channel) {
log.info("closeChannel: the channel[{}] has been closed before, and has been created again, nothing to do.",
- addrRemote);
+ addrRemote);
removeItemFromTable = false;
}
@@ -338,7 +333,7 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
@Override
public RemotingCommand invokeSync(String addr, final RemotingCommand request, long timeoutMillis)
- throws InterruptedException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException {
+ throws InterruptedException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException {
final Channel channel = this.getAndCreateChannel(addr);
if (channel != null && channel.isActive()) {
try {
@@ -431,7 +426,6 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
return cw.getChannel();
}
-
if (this.lockChannelTables.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
try {
boolean createNewConnection = false;
@@ -476,7 +470,7 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
}
} else {
log.warn("createChannel: connect remote host[{}] timeout {}ms, {}", addr, this.nettyClientConfig.getConnectTimeoutMillis(),
- channelFuture.toString());
+ channelFuture.toString());
}
}
@@ -485,8 +479,8 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
@Override
public void invokeAsync(String addr, RemotingCommand request, long timeoutMillis, InvokeCallback invokeCallback)
- throws InterruptedException, RemotingConnectException, RemotingTooMuchRequestException, RemotingTimeoutException,
- RemotingSendRequestException {
+ throws InterruptedException, RemotingConnectException, RemotingTooMuchRequestException, RemotingTimeoutException,
+ RemotingSendRequestException {
final Channel channel = this.getAndCreateChannel(addr);
if (channel != null && channel.isActive()) {
try {
@@ -507,7 +501,7 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
@Override
public void invokeOneway(String addr, RemotingCommand request, long timeoutMillis) throws InterruptedException,
- RemotingConnectException, RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
+ RemotingConnectException, RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
final Channel channel = this.getAndCreateChannel(addr);
if (channel != null && channel.isActive()) {
try {
@@ -572,27 +566,22 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
static class ChannelWrapper {
private final ChannelFuture channelFuture;
-
public ChannelWrapper(ChannelFuture channelFuture) {
this.channelFuture = channelFuture;
}
-
public boolean isOK() {
return this.channelFuture.channel() != null && this.channelFuture.channel().isActive();
}
-
public boolean isWriteable() {
return this.channelFuture.channel().isWritable();
}
-
private Channel getChannel() {
return this.channelFuture.channel();
}
-
public ChannelFuture getChannelFuture() {
return channelFuture;
}
@@ -610,7 +599,7 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
class NettyConnetManageHandler extends ChannelDuplexHandler {
@Override
public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise)
- throws Exception {
+ throws Exception {
final String local = localAddress == null ? "UNKNOW" : localAddress.toString();
final String remote = remoteAddress == null ? "UNKNOW" : remoteAddress.toString();
log.info("NETTY CLIENT PIPELINE: CONNECT {} => {}", local, remote);
@@ -621,7 +610,6 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
}
}
-
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ctx.channel());
@@ -634,7 +622,6 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
}
}
-
@Override
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ctx.channel());
@@ -650,14 +637,14 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof IdleStateEvent) {
- IdleStateEvent evnet = (IdleStateEvent) evt;
+ IdleStateEvent evnet = (IdleStateEvent)evt;
if (evnet.state().equals(IdleState.ALL_IDLE)) {
final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ctx.channel());
log.warn("NETTY CLIENT PIPELINE: IDLE exception [{}]", remoteAddress);
closeChannel(ctx.channel());
if (NettyRemotingClient.this.channelEventListener != null) {
NettyRemotingClient.this
- .putNettyEvent(new NettyEvent(NettyEventType.IDLE, remoteAddress.toString(), ctx.channel()));
+ .putNettyEvent(new NettyEvent(NettyEventType.IDLE, remoteAddress.toString(), ctx.channel()));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
index c6e2eda..f109086 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java
@@ -6,27 +6,16 @@
* (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
+ * 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.
+ * 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.remoting.netty;
-import org.apache.rocketmq.remoting.ChannelEventListener;
-import org.apache.rocketmq.remoting.InvokeCallback;
-import org.apache.rocketmq.remoting.RPCHook;
-import org.apache.rocketmq.remoting.RemotingServer;
-import org.apache.rocketmq.remoting.common.Pair;
-import org.apache.rocketmq.remoting.common.RemotingHelper;
-import org.apache.rocketmq.remoting.common.RemotingUtil;
-import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
-import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
-import org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException;
-import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.channel.Channel;
@@ -45,9 +34,6 @@ import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.util.concurrent.DefaultEventExecutorGroup;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.net.InetSocketAddress;
import java.util.Timer;
import java.util.TimerTask;
@@ -55,7 +41,19 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
-
+import org.apache.rocketmq.remoting.ChannelEventListener;
+import org.apache.rocketmq.remoting.InvokeCallback;
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.remoting.RemotingServer;
+import org.apache.rocketmq.remoting.common.Pair;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.common.RemotingUtil;
+import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
+import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
+import org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class NettyRemotingServer extends NettyRemotingAbstract implements RemotingServer {
private static final Logger log = LoggerFactory.getLogger(RemotingHelper.ROCKETMQ_REMOTING);
@@ -72,15 +70,12 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
private RPCHook rpcHook;
-
private int port = 0;
-
public NettyRemotingServer(final NettyServerConfig nettyServerConfig) {
this(nettyServerConfig, null);
}
-
public NettyRemotingServer(final NettyServerConfig nettyServerConfig, final ChannelEventListener channelEventListener) {
super(nettyServerConfig.getServerOnewaySemaphoreValue(), nettyServerConfig.getServerAsyncSemaphoreValue());
this.serverBootstrap = new ServerBootstrap();
@@ -95,7 +90,6 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
this.publicExecutor = Executors.newFixedThreadPool(publicThreadNums, new ThreadFactory() {
private AtomicInteger threadIndex = new AtomicInteger(0);
-
@Override
public Thread newThread(Runnable r) {
return new Thread(r, "NettyServerPublicExecutor_" + this.threadIndex.incrementAndGet());
@@ -105,7 +99,6 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
this.eventLoopGroupBoss = new NioEventLoopGroup(1, new ThreadFactory() {
private AtomicInteger threadIndex = new AtomicInteger(0);
-
@Override
public Thread newThread(Runnable r) {
return new Thread(r, String.format("NettyBoss_%d", this.threadIndex.incrementAndGet()));
@@ -113,12 +106,11 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
});
if (RemotingUtil.isLinuxPlatform() //
- && nettyServerConfig.isUseEpollNativeSelector()) {
+ && nettyServerConfig.isUseEpollNativeSelector()) {
this.eventLoopGroupSelector = new EpollEventLoopGroup(nettyServerConfig.getServerSelectorThreads(), new ThreadFactory() {
private AtomicInteger threadIndex = new AtomicInteger(0);
private int threadTotal = nettyServerConfig.getServerSelectorThreads();
-
@Override
public Thread newThread(Runnable r) {
return new Thread(r, String.format("NettyServerEPOLLSelector_%d_%d", threadTotal, this.threadIndex.incrementAndGet()));
@@ -129,7 +121,6 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
private AtomicInteger threadIndex = new AtomicInteger(0);
private int threadTotal = nettyServerConfig.getServerSelectorThreads();
-
@Override
public Thread newThread(Runnable r) {
return new Thread(r, String.format("NettyServerNIOSelector_%d_%d", threadTotal, this.threadIndex.incrementAndGet()));
@@ -138,51 +129,49 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
}
}
-
@Override
public void start() {
this.defaultEventExecutorGroup = new DefaultEventExecutorGroup(//
- nettyServerConfig.getServerWorkerThreads(), //
- new ThreadFactory() {
+ nettyServerConfig.getServerWorkerThreads(), //
+ new ThreadFactory() {
- private AtomicInteger threadIndex = new AtomicInteger(0);
+ private AtomicInteger threadIndex = new AtomicInteger(0);
+ @Override
+ public Thread newThread(Runnable r) {
+ return new Thread(r, "NettyServerCodecThread_" + this.threadIndex.incrementAndGet());
+ }
+ });
+ ServerBootstrap childHandler =
+ this.serverBootstrap.group(this.eventLoopGroupBoss, this.eventLoopGroupSelector).channel(NioServerSocketChannel.class)
+ .option(ChannelOption.SO_BACKLOG, 1024)
+ .option(ChannelOption.SO_REUSEADDR, true)
+ .option(ChannelOption.SO_KEEPALIVE, false)
+ .childOption(ChannelOption.TCP_NODELAY, true)
+ .option(ChannelOption.SO_SNDBUF, nettyServerConfig.getServerSocketSndBufSize())
+ .option(ChannelOption.SO_RCVBUF, nettyServerConfig.getServerSocketRcvBufSize())
+ .localAddress(new InetSocketAddress(this.nettyServerConfig.getListenPort()))
+ .childHandler(new ChannelInitializer<SocketChannel>() {
@Override
- public Thread newThread(Runnable r) {
- return new Thread(r, "NettyServerCodecThread_" + this.threadIndex.incrementAndGet());
+ public void initChannel(SocketChannel ch) throws Exception {
+ ch.pipeline().addLast(
+ defaultEventExecutorGroup,
+ new NettyEncoder(),
+ new NettyDecoder(),
+ new IdleStateHandler(0, 0, nettyServerConfig.getServerChannelMaxIdleTimeSeconds()),
+ new NettyConnetManageHandler(),
+ new NettyServerHandler());
}
});
- ServerBootstrap childHandler =
- this.serverBootstrap.group(this.eventLoopGroupBoss, this.eventLoopGroupSelector).channel(NioServerSocketChannel.class)
- .option(ChannelOption.SO_BACKLOG, 1024)
- .option(ChannelOption.SO_REUSEADDR, true)
- .option(ChannelOption.SO_KEEPALIVE, false)
- .childOption(ChannelOption.TCP_NODELAY, true)
- .option(ChannelOption.SO_SNDBUF, nettyServerConfig.getServerSocketSndBufSize())
- .option(ChannelOption.SO_RCVBUF, nettyServerConfig.getServerSocketRcvBufSize())
- .localAddress(new InetSocketAddress(this.nettyServerConfig.getListenPort()))
- .childHandler(new ChannelInitializer<SocketChannel>() {
- @Override
- public void initChannel(SocketChannel ch) throws Exception {
- ch.pipeline().addLast(
- defaultEventExecutorGroup,
- new NettyEncoder(),
- new NettyDecoder(),
- new IdleStateHandler(0, 0, nettyServerConfig.getServerChannelMaxIdleTimeSeconds()),
- new NettyConnetManageHandler(),
- new NettyServerHandler());
- }
- });
-
if (nettyServerConfig.isServerPooledByteBufAllocatorEnable()) {
childHandler.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
}
try {
ChannelFuture sync = this.serverBootstrap.bind().sync();
- InetSocketAddress addr = (InetSocketAddress) sync.channel().localAddress();
+ InetSocketAddress addr = (InetSocketAddress)sync.channel().localAddress();
this.port = addr.getPort();
} catch (InterruptedException e1) {
throw new RuntimeException("this.serverBootstrap.bind().sync() InterruptedException", e1);
@@ -269,19 +258,19 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
@Override
public RemotingCommand invokeSync(final Channel channel, final RemotingCommand request, final long timeoutMillis)
- throws InterruptedException, RemotingSendRequestException, RemotingTimeoutException {
+ throws InterruptedException, RemotingSendRequestException, RemotingTimeoutException {
return this.invokeSyncImpl(channel, request, timeoutMillis);
}
@Override
public void invokeAsync(Channel channel, RemotingCommand request, long timeoutMillis, InvokeCallback invokeCallback)
- throws InterruptedException, RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
+ throws InterruptedException, RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
this.invokeAsyncImpl(channel, request, timeoutMillis, invokeCallback);
}
@Override
public void invokeOneway(Channel channel, RemotingCommand request, long timeoutMillis) throws InterruptedException,
- RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
+ RemotingTooMuchRequestException, RemotingTimeoutException, RemotingSendRequestException {
this.invokeOnewayImpl(channel, request, timeoutMillis);
}
@@ -316,7 +305,6 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
super.channelRegistered(ctx);
}
-
@Override
public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ctx.channel());
@@ -324,7 +312,6 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
super.channelUnregistered(ctx);
}
-
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ctx.channel());
@@ -336,7 +323,6 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
}
}
-
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ctx.channel());
@@ -348,18 +334,17 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
}
}
-
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof IdleStateEvent) {
- IdleStateEvent evnet = (IdleStateEvent) evt;
+ IdleStateEvent evnet = (IdleStateEvent)evt;
if (evnet.state().equals(IdleState.ALL_IDLE)) {
final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ctx.channel());
log.warn("NETTY SERVER PIPELINE: IDLE exception [{}]", remoteAddress);
RemotingUtil.closeChannel(ctx.channel());
if (NettyRemotingServer.this.channelEventListener != null) {
NettyRemotingServer.this
- .putNettyEvent(new NettyEvent(NettyEventType.IDLE, remoteAddress.toString(), ctx.channel()));
+ .putNettyEvent(new NettyEvent(NettyEventType.IDLE, remoteAddress.toString(), ctx.channel()));
}
}
}
@@ -367,7 +352,6 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
ctx.fireUserEventTriggered(evt);
}
-
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ctx.channel());
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java
index b8d2052..c6251e9 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java
@@ -6,19 +6,18 @@
* (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
+ * 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.
+ * 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.remoting.netty;
-import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import io.netty.channel.ChannelHandlerContext;
-
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
/**
* Common remoting command processor
@@ -27,6 +26,7 @@ import io.netty.channel.ChannelHandlerContext;
*/
public interface NettyRequestProcessor {
RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request)
- throws Exception;
+ throws Exception;
+
boolean rejectRequest();
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
index 0a53240..f69fded 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.remoting.netty;
@@ -43,118 +43,96 @@ public class NettyServerConfig implements Cloneable {
*/
private boolean useEpollNativeSelector = false;
-
public int getListenPort() {
return listenPort;
}
-
public void setListenPort(int listenPort) {
this.listenPort = listenPort;
}
-
public int getServerWorkerThreads() {
return serverWorkerThreads;
}
-
public void setServerWorkerThreads(int serverWorkerThreads) {
this.serverWorkerThreads = serverWorkerThreads;
}
-
public int getServerSelectorThreads() {
return serverSelectorThreads;
}
-
public void setServerSelectorThreads(int serverSelectorThreads) {
this.serverSelectorThreads = serverSelectorThreads;
}
-
public int getServerOnewaySemaphoreValue() {
return serverOnewaySemaphoreValue;
}
-
public void setServerOnewaySemaphoreValue(int serverOnewaySemaphoreValue) {
this.serverOnewaySemaphoreValue = serverOnewaySemaphoreValue;
}
-
public int getServerCallbackExecutorThreads() {
return serverCallbackExecutorThreads;
}
-
public void setServerCallbackExecutorThreads(int serverCallbackExecutorThreads) {
this.serverCallbackExecutorThreads = serverCallbackExecutorThreads;
}
-
public int getServerAsyncSemaphoreValue() {
return serverAsyncSemaphoreValue;
}
-
public void setServerAsyncSemaphoreValue(int serverAsyncSemaphoreValue) {
this.serverAsyncSemaphoreValue = serverAsyncSemaphoreValue;
}
-
public int getServerChannelMaxIdleTimeSeconds() {
return serverChannelMaxIdleTimeSeconds;
}
-
public void setServerChannelMaxIdleTimeSeconds(int serverChannelMaxIdleTimeSeconds) {
this.serverChannelMaxIdleTimeSeconds = serverChannelMaxIdleTimeSeconds;
}
-
public int getServerSocketSndBufSize() {
return serverSocketSndBufSize;
}
-
public void setServerSocketSndBufSize(int serverSocketSndBufSize) {
this.serverSocketSndBufSize = serverSocketSndBufSize;
}
-
public int getServerSocketRcvBufSize() {
return serverSocketRcvBufSize;
}
-
public void setServerSocketRcvBufSize(int serverSocketRcvBufSize) {
this.serverSocketRcvBufSize = serverSocketRcvBufSize;
}
-
public boolean isServerPooledByteBufAllocatorEnable() {
return serverPooledByteBufAllocatorEnable;
}
-
public void setServerPooledByteBufAllocatorEnable(boolean serverPooledByteBufAllocatorEnable) {
this.serverPooledByteBufAllocatorEnable = serverPooledByteBufAllocatorEnable;
}
-
public boolean isUseEpollNativeSelector() {
return useEpollNativeSelector;
}
-
public void setUseEpollNativeSelector(boolean useEpollNativeSelector) {
this.useEpollNativeSelector = useEpollNativeSelector;
}
@Override
public Object clone() throws CloneNotSupportedException {
- return (NettyServerConfig) super.clone();
+ return (NettyServerConfig)super.clone();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettySystemConfig.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettySystemConfig.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettySystemConfig.java
index ca22df1..9409f92 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettySystemConfig.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettySystemConfig.java
@@ -19,24 +19,24 @@ package org.apache.rocketmq.remoting.netty;
public class NettySystemConfig {
public static final String COM_ROCKETMQ_REMOTING_NETTY_POOLED_BYTE_BUF_ALLOCATOR_ENABLE =
- "com.rocketmq.remoting.nettyPooledByteBufAllocatorEnable";
+ "com.rocketmq.remoting.nettyPooledByteBufAllocatorEnable";
public static final String COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE = //
- "com.rocketmq.remoting.socket.sndbuf.size";
+ "com.rocketmq.remoting.socket.sndbuf.size";
public static final String COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE = //
- "com.rocketmq.remoting.socket.rcvbuf.size";
+ "com.rocketmq.remoting.socket.rcvbuf.size";
public static final String COM_ROCKETMQ_REMOTING_CLIENT_ASYNC_SEMAPHORE_VALUE = //
- "com.rocketmq.remoting.clientAsyncSemaphoreValue";
+ "com.rocketmq.remoting.clientAsyncSemaphoreValue";
public static final String COM_ROCKETMQ_REMOTING_CLIENT_ONEWAY_SEMAPHORE_VALUE = //
- "com.rocketmq.remoting.clientOnewaySemaphoreValue";
+ "com.rocketmq.remoting.clientOnewaySemaphoreValue";
public static final boolean NETTY_POOLED_BYTE_BUF_ALLOCATOR_ENABLE = //
- Boolean
- .parseBoolean(System.getProperty(COM_ROCKETMQ_REMOTING_NETTY_POOLED_BYTE_BUF_ALLOCATOR_ENABLE, "false"));
- public static int socketSndbufSize = //
- Integer.parseInt(System.getProperty(COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE, "65535"));
- public static int socketRcvbufSize = //
- Integer.parseInt(System.getProperty(COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE, "65535"));
+ Boolean
+ .parseBoolean(System.getProperty(COM_ROCKETMQ_REMOTING_NETTY_POOLED_BYTE_BUF_ALLOCATOR_ENABLE, "false"));
public static final int CLIENT_ASYNC_SEMAPHORE_VALUE = //
- Integer.parseInt(System.getProperty(COM_ROCKETMQ_REMOTING_CLIENT_ASYNC_SEMAPHORE_VALUE, "65535"));
+ Integer.parseInt(System.getProperty(COM_ROCKETMQ_REMOTING_CLIENT_ASYNC_SEMAPHORE_VALUE, "65535"));
public static final int CLIENT_ONEWAY_SEMAPHORE_VALUE = //
- Integer.parseInt(System.getProperty(COM_ROCKETMQ_REMOTING_CLIENT_ONEWAY_SEMAPHORE_VALUE, "65535"));
+ Integer.parseInt(System.getProperty(COM_ROCKETMQ_REMOTING_CLIENT_ONEWAY_SEMAPHORE_VALUE, "65535"));
+ public static int socketSndbufSize = //
+ Integer.parseInt(System.getProperty(COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE, "65535"));
+ public static int socketRcvbufSize = //
+ Integer.parseInt(System.getProperty(COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE, "65535"));
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/netty/RequestTask.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/RequestTask.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/RequestTask.java
index e1317a0..0443b43 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/RequestTask.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/RequestTask.java
@@ -17,9 +17,8 @@
package org.apache.rocketmq.remoting.netty;
-
-import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import io.netty.channel.Channel;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
public class RequestTask implements Runnable {
private final Runnable runnable;
@@ -37,7 +36,7 @@ public class RequestTask implements Runnable {
@Override
public int hashCode() {
int result = runnable != null ? runnable.hashCode() : 0;
- result = 31 * result + (int) (getCreateTimestamp() ^ (getCreateTimestamp() >>> 32));
+ result = 31 * result + (int)(getCreateTimestamp() ^ (getCreateTimestamp() >>> 32));
result = 31 * result + (channel != null ? channel.hashCode() : 0);
result = 31 * result + (request != null ? request.hashCode() : 0);
result = 31 * result + (isStopRun() ? 1 : 0);
@@ -46,14 +45,19 @@ public class RequestTask implements Runnable {
@Override
public boolean equals(final Object o) {
- if (this == o) return true;
- if (!(o instanceof RequestTask)) return false;
+ if (this == o)
+ return true;
+ if (!(o instanceof RequestTask))
+ return false;
- final RequestTask that = (RequestTask) o;
+ final RequestTask that = (RequestTask)o;
- if (getCreateTimestamp() != that.getCreateTimestamp()) return false;
- if (isStopRun() != that.isStopRun()) return false;
- if (channel != null ? !channel.equals(that.channel) : that.channel != null) return false;
+ if (getCreateTimestamp() != that.getCreateTimestamp())
+ return false;
+ if (isStopRun() != that.isStopRun())
+ return false;
+ if (channel != null ? !channel.equals(that.channel) : that.channel != null)
+ return false;
return request != null ? request.getOpaque() == that.request.getOpaque() : that.request == null;
}
@@ -72,7 +76,8 @@ public class RequestTask implements Runnable {
@Override
public void run() {
- if (!this.stopRun) this.runnable.run();
+ if (!this.stopRun)
+ this.runnable.run();
}
public void returnResponse(int code, String remark) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/remoting/src/main/java/org/apache/rocketmq/remoting/netty/ResponseFuture.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/ResponseFuture.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/ResponseFuture.java
index d564a3a..fa792b2 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/ResponseFuture.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/ResponseFuture.java
@@ -6,24 +6,22 @@
* (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
+ * 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.
+ * 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.remoting.netty;
-import org.apache.rocketmq.remoting.InvokeCallback;
-import org.apache.rocketmq.remoting.common.SemaphoreReleaseOnlyOnce;
-import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-
+import org.apache.rocketmq.remoting.InvokeCallback;
+import org.apache.rocketmq.remoting.common.SemaphoreReleaseOnlyOnce;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
public class ResponseFuture {
private final int opaque;
@@ -39,16 +37,14 @@ public class ResponseFuture {
private volatile boolean sendRequestOK = true;
private volatile Throwable cause;
-
public ResponseFuture(int opaque, long timeoutMillis, InvokeCallback invokeCallback,
- SemaphoreReleaseOnlyOnce once) {
+ SemaphoreReleaseOnlyOnce once) {
this.opaque = opaque;
this.timeoutMillis = timeoutMillis;
this.invokeCallback = invokeCallback;
this.once = once;
}
-
public void executeInvokeCallback() {
if (invokeCallback != null) {
if (this.executeCallbackOnlyOnce.compareAndSet(false, true)) {
@@ -57,87 +53,72 @@ public class ResponseFuture {
}
}
-
public void release() {
if (this.once != null) {
this.once.release();
}
}
-
public boolean isTimeout() {
long diff = System.currentTimeMillis() - this.beginTimestamp;
return diff > this.timeoutMillis;
}
-
public RemotingCommand waitResponse(final long timeoutMillis) throws InterruptedException {
this.countDownLatch.await(timeoutMillis, TimeUnit.MILLISECONDS);
return this.responseCommand;
}
-
public void putResponse(final RemotingCommand responseCommand) {
this.responseCommand = responseCommand;
this.countDownLatch.countDown();
}
-
public long getBeginTimestamp() {
return beginTimestamp;
}
-
public boolean isSendRequestOK() {
return sendRequestOK;
}
-
public void setSendRequestOK(boolean sendRequestOK) {
this.sendRequestOK = sendRequestOK;
}
-
public long getTimeoutMillis() {
return timeoutMillis;
}
-
public InvokeCallback getInvokeCallback() {
return invokeCallback;
}
-
public Throwable getCause() {
return cause;
}
-
public void setCause(Throwable cause) {
this.cause = cause;
}
-
public RemotingCommand getResponseCommand() {
return responseCommand;
}
-
public void setResponseCommand(RemotingCommand responseCommand) {
this.responseCommand = responseCommand;
}
-
public int getOpaque() {
return opaque;
}
-
@Override
public String toString() {
return "ResponseFuture [responseCommand=" + responseCommand + ", sendRequestOK=" + sendRequestOK
- + ", cause=" + cause + ", opaque=" + opaque + ", timeoutMillis=" + timeoutMillis
- + ", invokeCallback=" + invokeCallback + ", beginTimestamp=" + beginTimestamp
- + ", countDownLatch=" + countDownLatch + "]";
+ + ", cause=" + cause + ", opaque=" + opaque + ", timeoutMillis=" + timeoutMillis
+ + ", invokeCallback=" + invokeCallback + ", beginTimestamp=" + beginTimestamp
+ + ", countDownLatch=" + countDownLatch + "]";
}
}
[77/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/sysflag/SubscriptionSysFlag.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/sysflag/SubscriptionSysFlag.java b/common/src/main/java/org/apache/rocketmq/common/sysflag/SubscriptionSysFlag.java
index da6401e..cf7cdcd 100644
--- a/common/src/main/java/org/apache/rocketmq/common/sysflag/SubscriptionSysFlag.java
+++ b/common/src/main/java/org/apache/rocketmq/common/sysflag/SubscriptionSysFlag.java
@@ -20,7 +20,6 @@ public class SubscriptionSysFlag {
private final static int FLAG_UNIT = 0x1 << 0;
-
public static int buildSysFlag(final boolean unit) {
int sysFlag = 0;
@@ -31,22 +30,18 @@ public class SubscriptionSysFlag {
return sysFlag;
}
-
public static int setUnitFlag(final int sysFlag) {
return sysFlag | FLAG_UNIT;
}
-
public static int clearUnitFlag(final int sysFlag) {
return sysFlag & (~FLAG_UNIT);
}
-
public static boolean hasUnitFlag(final int sysFlag) {
return (sysFlag & FLAG_UNIT) == FLAG_UNIT;
}
-
public static void main(String[] args) {
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/sysflag/TopicSysFlag.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/sysflag/TopicSysFlag.java b/common/src/main/java/org/apache/rocketmq/common/sysflag/TopicSysFlag.java
index 1d804db..2c45150 100644
--- a/common/src/main/java/org/apache/rocketmq/common/sysflag/TopicSysFlag.java
+++ b/common/src/main/java/org/apache/rocketmq/common/sysflag/TopicSysFlag.java
@@ -27,7 +27,6 @@ public class TopicSysFlag {
private final static int FLAG_UNIT_SUB = 0x1 << 1;
-
public static int buildSysFlag(final boolean unit, final boolean hasUnitSub) {
int sysFlag = 0;
@@ -42,37 +41,30 @@ public class TopicSysFlag {
return sysFlag;
}
-
public static int setUnitFlag(final int sysFlag) {
return sysFlag | FLAG_UNIT;
}
-
public static int clearUnitFlag(final int sysFlag) {
return sysFlag & (~FLAG_UNIT);
}
-
public static boolean hasUnitFlag(final int sysFlag) {
return (sysFlag & FLAG_UNIT) == FLAG_UNIT;
}
-
public static int setUnitSubFlag(final int sysFlag) {
return sysFlag | FLAG_UNIT_SUB;
}
-
public static int clearUnitSubFlag(final int sysFlag) {
return sysFlag & (~FLAG_UNIT_SUB);
}
-
public static boolean hasUnitSubFlag(final int sysFlag) {
return (sysFlag & FLAG_UNIT_SUB) == FLAG_UNIT_SUB;
}
-
public static void main(String[] args) {
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/utils/ChannelUtil.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/utils/ChannelUtil.java b/common/src/main/java/org/apache/rocketmq/common/utils/ChannelUtil.java
index ab017f2..dcb9187 100644
--- a/common/src/main/java/org/apache/rocketmq/common/utils/ChannelUtil.java
+++ b/common/src/main/java/org/apache/rocketmq/common/utils/ChannelUtil.java
@@ -6,25 +6,24 @@
* (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
+ * 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.
+ * 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.common.utils;
import io.netty.channel.Channel;
-
import java.net.InetAddress;
import java.net.InetSocketAddress;
public class ChannelUtil {
public static String getRemoteIp(Channel channel) {
- InetSocketAddress inetSocketAddress = (InetSocketAddress) channel.remoteAddress();
+ InetSocketAddress inetSocketAddress = (InetSocketAddress)channel.remoteAddress();
if (inetSocketAddress == null) {
return "";
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/utils/HttpTinyClient.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/utils/HttpTinyClient.java b/common/src/main/java/org/apache/rocketmq/common/utils/HttpTinyClient.java
index fcd002c..0cc3463 100755
--- a/common/src/main/java/org/apache/rocketmq/common/utils/HttpTinyClient.java
+++ b/common/src/main/java/org/apache/rocketmq/common/utils/HttpTinyClient.java
@@ -6,20 +6,17 @@
* (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
+ * 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.
+ * 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.common.utils;
-import org.apache.rocketmq.common.MQVersion;
-import org.apache.rocketmq.common.MixAll;
-
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
@@ -27,21 +24,22 @@ import java.net.URL;
import java.net.URLEncoder;
import java.util.Iterator;
import java.util.List;
-
+import org.apache.rocketmq.common.MQVersion;
+import org.apache.rocketmq.common.MixAll;
public class HttpTinyClient {
static public HttpResult httpGet(String url, List<String> headers, List<String> paramValues,
- String encoding, long readTimeoutMs) throws IOException {
+ String encoding, long readTimeoutMs) throws IOException {
String encodedContent = encodingParams(paramValues, encoding);
url += (null == encodedContent) ? "" : ("?" + encodedContent);
HttpURLConnection conn = null;
try {
- conn = (HttpURLConnection) new URL(url).openConnection();
+ conn = (HttpURLConnection)new URL(url).openConnection();
conn.setRequestMethod("GET");
- conn.setConnectTimeout((int) readTimeoutMs);
- conn.setReadTimeout((int) readTimeoutMs);
+ conn.setConnectTimeout((int)readTimeoutMs);
+ conn.setReadTimeout((int)readTimeoutMs);
setHeaders(conn, headers, encoding);
conn.connect();
@@ -62,7 +60,7 @@ public class HttpTinyClient {
}
static private String encodingParams(List<String> paramValues, String encoding)
- throws UnsupportedEncodingException {
+ throws UnsupportedEncodingException {
StringBuilder sb = new StringBuilder();
if (null == paramValues) {
return null;
@@ -87,7 +85,6 @@ public class HttpTinyClient {
conn.addRequestProperty("Client-Version", MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION));
conn.addRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + encoding);
-
String ts = String.valueOf(System.currentTimeMillis());
conn.addRequestProperty("Metaq-Client-RequestTS", ts);
}
@@ -110,15 +107,15 @@ public class HttpTinyClient {
* @throws java.io.IOException
*/
static public HttpResult httpPost(String url, List<String> headers, List<String> paramValues,
- String encoding, long readTimeoutMs) throws IOException {
+ String encoding, long readTimeoutMs) throws IOException {
String encodedContent = encodingParams(paramValues, encoding);
HttpURLConnection conn = null;
try {
- conn = (HttpURLConnection) new URL(url).openConnection();
+ conn = (HttpURLConnection)new URL(url).openConnection();
conn.setRequestMethod("POST");
conn.setConnectTimeout(3000);
- conn.setReadTimeout((int) readTimeoutMs);
+ conn.setReadTimeout((int)readTimeoutMs);
conn.setDoOutput(true);
conn.setDoInput(true);
setHeaders(conn, headers, encoding);
@@ -145,7 +142,6 @@ public class HttpTinyClient {
final public int code;
final public String content;
-
public HttpResult(int code, String content) {
this.code = code;
this.content = content;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java b/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java
index a5152f8..b569c24 100644
--- a/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java
+++ b/common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java
@@ -6,40 +6,46 @@
* (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
+ * 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.
+ * 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.common.utils;
-import org.apache.rocketmq.remoting.common.RemotingHelper;
-
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.CharArrayWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.List;
-
+import org.apache.rocketmq.remoting.common.RemotingHelper;
public class IOTinyUtils {
static public String toString(InputStream input, String encoding) throws IOException {
return (null == encoding) ? toString(new InputStreamReader(input, RemotingHelper.DEFAULT_CHARSET)) : toString(new InputStreamReader(
- input, encoding));
+ input, encoding));
}
-
static public String toString(Reader reader) throws IOException {
CharArrayWriter sw = new CharArrayWriter();
copy(reader, sw);
return sw.toString();
}
-
static public long copy(Reader input, Writer output) throws IOException {
char[] buffer = new char[1 << 12];
long count = 0;
@@ -50,7 +56,6 @@ public class IOTinyUtils {
return count;
}
-
/**
*/
@@ -58,7 +63,7 @@ public class IOTinyUtils {
BufferedReader reader = toBufferedReader(input);
List<String> list = new ArrayList<String>();
String line = null;
- for (;;) {
+ for (; ; ) {
line = reader.readLine();
if (null != line) {
list.add(line);
@@ -69,12 +74,10 @@ public class IOTinyUtils {
return list;
}
-
static private BufferedReader toBufferedReader(Reader reader) {
- return reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader);
+ return reader instanceof BufferedReader ? (BufferedReader)reader : new BufferedReader(reader);
}
-
static public void copyFile(String source, String target) throws IOException {
File sf = new File(source);
if (!sf.exists()) {
@@ -102,7 +105,6 @@ public class IOTinyUtils {
}
}
-
public static void delete(File fileOrDir) throws IOException {
if (fileOrDir == null) {
return;
@@ -115,7 +117,6 @@ public class IOTinyUtils {
fileOrDir.delete();
}
-
/**
*/
@@ -149,7 +150,6 @@ public class IOTinyUtils {
}
}
-
public static void writeStringToFile(File file, String data, String encoding) throws IOException {
OutputStream os = null;
try {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java b/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java
index 0006f74..3205c64 100644
--- a/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java
+++ b/common/src/test/java/org/apache/rocketmq/common/MixAllTest.java
@@ -6,23 +6,21 @@
* (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
+ * 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.
+ * 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.common;
-import junit.framework.Assert;
-import org.junit.Test;
-
import java.net.InetAddress;
import java.util.List;
-
+import junit.framework.Assert;
+import org.junit.Test;
public class MixAllTest {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/test/java/org/apache/rocketmq/common/RemotingUtilTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/rocketmq/common/RemotingUtilTest.java b/common/src/test/java/org/apache/rocketmq/common/RemotingUtilTest.java
index b7509b1..9211d37 100644
--- a/common/src/test/java/org/apache/rocketmq/common/RemotingUtilTest.java
+++ b/common/src/test/java/org/apache/rocketmq/common/RemotingUtilTest.java
@@ -6,20 +6,19 @@
* (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
+ * 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.
+ * 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.common;
import org.apache.rocketmq.remoting.common.RemotingUtil;
import org.junit.Test;
-
public class RemotingUtilTest {
@Test
public void test() throws Exception {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java b/common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java
index decd3d0..b21d65b 100644
--- a/common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java
+++ b/common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java
@@ -6,25 +6,23 @@
* (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
+ * 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.
+ * 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.common;
-import org.junit.Test;
-
import java.net.URL;
import java.util.Properties;
+import org.junit.Test;
import static org.junit.Assert.assertTrue;
-
public class UtilAllTest {
@Test
@@ -32,7 +30,6 @@ public class UtilAllTest {
System.out.println(UtilAll.currentStackTrace());
}
-
@Test
public void test_a() {
URL url = this.getClass().getProtectionDomain().getCodeSource().getLocation();
@@ -40,14 +37,12 @@ public class UtilAllTest {
System.out.println(url.getPath());
}
-
@Test
public void test_resetClassProperties() {
DemoConfig demoConfig = new DemoConfig();
MixAll.properties2Object(new Properties(), demoConfig);
}
-
@Test
public void test_properties2String() {
DemoConfig demoConfig = new DemoConfig();
@@ -55,13 +50,11 @@ public class UtilAllTest {
System.out.println(MixAll.properties2String(properties));
}
-
@Test
public void test_timeMillisToHumanString() {
System.out.println(UtilAll.timeMillisToHumanString());
}
-
@Test
public void test_isPropertiesEqual() {
final Properties p1 = new Properties();
@@ -77,7 +70,6 @@ public class UtilAllTest {
assertTrue(MixAll.isPropertiesEqual(p1, p2));
}
-
@Test
public void test_getpid() {
int pid = UtilAll.getPid();
@@ -86,7 +78,6 @@ public class UtilAllTest {
assertTrue(pid > 0);
}
-
@Test
public void test_isBlank() {
{
@@ -121,42 +112,34 @@ public class UtilAllTest {
private boolean demoOK = false;
private String demoName = "haha";
-
public int getDemoWidth() {
return demoWidth;
}
-
public void setDemoWidth(int demoWidth) {
this.demoWidth = demoWidth;
}
-
public int getDemoLength() {
return demoLength;
}
-
public void setDemoLength(int demoLength) {
this.demoLength = demoLength;
}
-
public boolean isDemoOK() {
return demoOK;
}
-
public void setDemoOK(boolean demoOK) {
this.demoOK = demoOK;
}
-
public String getDemoName() {
return demoName;
}
-
public void setDemoNfieldame(String demoName) {
this.demoName = demoName;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java b/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java
index cf26efd..5a97db9 100644
--- a/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java
+++ b/common/src/test/java/org/apache/rocketmq/common/filter/FilterAPITest.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.filter;
@@ -21,7 +21,6 @@ import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
import org.junit.Test;
-
/**
*
*/
@@ -30,14 +29,14 @@ public class FilterAPITest {
@Test
public void testBuildSubscriptionData() throws Exception {
SubscriptionData subscriptionData =
- FilterAPI.buildSubscriptionData("ConsumerGroup1", "TestTopic", "TAG1 || Tag2 || tag3");
+ FilterAPI.buildSubscriptionData("ConsumerGroup1", "TestTopic", "TAG1 || Tag2 || tag3");
System.out.println(subscriptionData);
}
@Test
public void testSubscriptionData() throws Exception {
SubscriptionData subscriptionData =
- FilterAPI.buildSubscriptionData("ConsumerGroup1", "TestTopic", "TAG1 || Tag2 || tag3");
+ FilterAPI.buildSubscriptionData("ConsumerGroup1", "TestTopic", "TAG1 || Tag2 || tag3");
subscriptionData.setFilterClassSource("java hello");
String json = RemotingSerializable.toJson(subscriptionData, true);
System.out.println(json);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/test/java/org/apache/rocketmq/common/protocol/ConsumeStatusTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/rocketmq/common/protocol/ConsumeStatusTest.java b/common/src/test/java/org/apache/rocketmq/common/protocol/ConsumeStatusTest.java
index 79c6bbf..b511537 100644
--- a/common/src/test/java/org/apache/rocketmq/common/protocol/ConsumeStatusTest.java
+++ b/common/src/test/java/org/apache/rocketmq/common/protocol/ConsumeStatusTest.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol;
@@ -21,7 +21,6 @@ import org.apache.rocketmq.common.protocol.body.ConsumeStatus;
import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
import org.junit.Test;
-
public class ConsumeStatusTest {
@Test
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/conf/2m-2s-async/broker-a-s.properties
----------------------------------------------------------------------
diff --git a/conf/2m-2s-async/broker-a-s.properties b/conf/2m-2s-async/broker-a-s.properties
index a4401f8..60fddf9 100644
--- a/conf/2m-2s-async/broker-a-s.properties
+++ b/conf/2m-2s-async/broker-a-s.properties
@@ -12,7 +12,6 @@
# 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.
-
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=1
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/conf/2m-2s-async/broker-a.properties
----------------------------------------------------------------------
diff --git a/conf/2m-2s-async/broker-a.properties b/conf/2m-2s-async/broker-a.properties
index 6ca12f1..367f974 100644
--- a/conf/2m-2s-async/broker-a.properties
+++ b/conf/2m-2s-async/broker-a.properties
@@ -12,7 +12,6 @@
# 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.
-
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=0
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/conf/2m-2s-async/broker-b-s.properties
----------------------------------------------------------------------
diff --git a/conf/2m-2s-async/broker-b-s.properties b/conf/2m-2s-async/broker-b-s.properties
index 51f8daf..bcd5a16 100644
--- a/conf/2m-2s-async/broker-b-s.properties
+++ b/conf/2m-2s-async/broker-b-s.properties
@@ -12,7 +12,6 @@
# 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.
-
brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=1
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/conf/2m-2s-async/broker-b.properties
----------------------------------------------------------------------
diff --git a/conf/2m-2s-async/broker-b.properties b/conf/2m-2s-async/broker-b.properties
index f7f3791..33b68fe 100644
--- a/conf/2m-2s-async/broker-b.properties
+++ b/conf/2m-2s-async/broker-b.properties
@@ -12,7 +12,6 @@
# 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.
-
brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=0
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/conf/2m-2s-sync/broker-a-s.properties
----------------------------------------------------------------------
diff --git a/conf/2m-2s-sync/broker-a-s.properties b/conf/2m-2s-sync/broker-a-s.properties
index a4401f8..60fddf9 100644
--- a/conf/2m-2s-sync/broker-a-s.properties
+++ b/conf/2m-2s-sync/broker-a-s.properties
@@ -12,7 +12,6 @@
# 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.
-
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=1
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/conf/2m-2s-sync/broker-a.properties
----------------------------------------------------------------------
diff --git a/conf/2m-2s-sync/broker-a.properties b/conf/2m-2s-sync/broker-a.properties
index 135552d..b916f88 100644
--- a/conf/2m-2s-sync/broker-a.properties
+++ b/conf/2m-2s-sync/broker-a.properties
@@ -12,7 +12,6 @@
# 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.
-
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=0
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/conf/2m-2s-sync/broker-b-s.properties
----------------------------------------------------------------------
diff --git a/conf/2m-2s-sync/broker-b-s.properties b/conf/2m-2s-sync/broker-b-s.properties
index 51f8daf..bcd5a16 100644
--- a/conf/2m-2s-sync/broker-b-s.properties
+++ b/conf/2m-2s-sync/broker-b-s.properties
@@ -12,7 +12,6 @@
# 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.
-
brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=1
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/conf/2m-2s-sync/broker-b.properties
----------------------------------------------------------------------
diff --git a/conf/2m-2s-sync/broker-b.properties b/conf/2m-2s-sync/broker-b.properties
index 97162a7..44fcea7 100644
--- a/conf/2m-2s-sync/broker-b.properties
+++ b/conf/2m-2s-sync/broker-b.properties
@@ -12,7 +12,6 @@
# 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.
-
brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=0
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/conf/2m-noslave/broker-a.properties
----------------------------------------------------------------------
diff --git a/conf/2m-noslave/broker-a.properties b/conf/2m-noslave/broker-a.properties
index 6ca12f1..367f974 100644
--- a/conf/2m-noslave/broker-a.properties
+++ b/conf/2m-noslave/broker-a.properties
@@ -12,7 +12,6 @@
# 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.
-
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=0
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/conf/2m-noslave/broker-b.properties
----------------------------------------------------------------------
diff --git a/conf/2m-noslave/broker-b.properties b/conf/2m-noslave/broker-b.properties
index f7f3791..33b68fe 100644
--- a/conf/2m-noslave/broker-b.properties
+++ b/conf/2m-noslave/broker-b.properties
@@ -12,7 +12,6 @@
# 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.
-
brokerClusterName=DefaultCluster
brokerName=broker-b
brokerId=0
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/conf/broker.conf
----------------------------------------------------------------------
diff --git a/conf/broker.conf b/conf/broker.conf
index 6ca12f1..0c0b28b 100644
--- a/conf/broker.conf
+++ b/conf/broker.conf
@@ -13,10 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-brokerClusterName=DefaultCluster
-brokerName=broker-a
-brokerId=0
-deleteWhen=04
-fileReservedTime=48
-brokerRole=ASYNC_MASTER
-flushDiskType=ASYNC_FLUSH
+brokerClusterName = DefaultCluster
+brokerName = broker-a
+brokerId = 0
+deleteWhen = 04
+fileReservedTime = 48
+brokerRole = ASYNC_MASTER
+flushDiskType = ASYNC_FLUSH
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/conf/logback_broker.xml
----------------------------------------------------------------------
diff --git a/conf/logback_broker.xml b/conf/logback_broker.xml
index 49e9d12..7a8f83b 100644
--- a/conf/logback_broker.xml
+++ b/conf/logback_broker.xml
@@ -28,7 +28,7 @@
<maxIndex>10</maxIndex>
</rollingPolicy>
<triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>
<encoder>
@@ -48,7 +48,7 @@
<maxIndex>20</maxIndex>
</rollingPolicy>
<triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>128MB</maxFileSize>
</triggeringPolicy>
<encoder>
@@ -71,7 +71,7 @@
<maxIndex>10</maxIndex>
</rollingPolicy>
<triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>
<encoder>
@@ -94,7 +94,7 @@
<maxIndex>10</maxIndex>
</rollingPolicy>
<triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>
<encoder>
@@ -117,7 +117,7 @@
<maxIndex>10</maxIndex>
</rollingPolicy>
<triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>128MB</maxFileSize>
</triggeringPolicy>
<encoder>
@@ -140,7 +140,7 @@
<maxIndex>10</maxIndex>
</rollingPolicy>
<triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>
<encoder>
@@ -163,7 +163,7 @@
<maxIndex>10</maxIndex>
</rollingPolicy>
<triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>
<encoder>
@@ -187,7 +187,7 @@
<maxIndex>10</maxIndex>
</rollingPolicy>
<triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>
<encoder>
@@ -210,7 +210,7 @@
<maxIndex>5</maxIndex>
</rollingPolicy>
<triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>
<encoder>
@@ -233,7 +233,7 @@
<maxIndex>5</maxIndex>
</rollingPolicy>
<triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>
<encoder>
@@ -253,7 +253,7 @@
<maxIndex>10</maxIndex>
</rollingPolicy>
<triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>500MB</maxFileSize>
</triggeringPolicy>
</appender>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/conf/logback_filtersrv.xml
----------------------------------------------------------------------
diff --git a/conf/logback_filtersrv.xml b/conf/logback_filtersrv.xml
index 8de4e08..9668795 100644
--- a/conf/logback_filtersrv.xml
+++ b/conf/logback_filtersrv.xml
@@ -28,7 +28,7 @@
<maxIndex>5</maxIndex>
</rollingPolicy>
<triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>
<encoder>
@@ -48,7 +48,7 @@
<maxIndex>5</maxIndex>
</rollingPolicy>
<triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>
<encoder>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/conf/logback_namesrv.xml
----------------------------------------------------------------------
diff --git a/conf/logback_namesrv.xml b/conf/logback_namesrv.xml
index 7a60c76..45ccf4f 100644
--- a/conf/logback_namesrv.xml
+++ b/conf/logback_namesrv.xml
@@ -28,7 +28,7 @@
<maxIndex>5</maxIndex>
</rollingPolicy>
<triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>
<encoder>
@@ -48,7 +48,7 @@
<maxIndex>5</maxIndex>
</rollingPolicy>
<triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>
<encoder>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/conf/logback_tools.xml
----------------------------------------------------------------------
diff --git a/conf/logback_tools.xml b/conf/logback_tools.xml
index addf211..35d33a5 100644
--- a/conf/logback_tools.xml
+++ b/conf/logback_tools.xml
@@ -28,7 +28,7 @@
<maxIndex>5</maxIndex>
</rollingPolicy>
<triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>
<encoder>
@@ -48,7 +48,7 @@
<maxIndex>5</maxIndex>
</rollingPolicy>
<triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>
<encoder>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/pom.xml
----------------------------------------------------------------------
diff --git a/example/pom.xml b/example/pom.xml
index 53aa6a6..efb1aa5 100644
--- a/example/pom.xml
+++ b/example/pom.xml
@@ -15,7 +15,7 @@
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.rocketmq</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/benchmark/Consumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/benchmark/Consumer.java b/example/src/main/java/org/apache/rocketmq/example/benchmark/Consumer.java
index 1fbb8a4..f810f5a 100644
--- a/example/src/main/java/org/apache/rocketmq/example/benchmark/Consumer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/benchmark/Consumer.java
@@ -17,6 +17,15 @@
package org.apache.rocketmq.example.benchmark;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.atomic.AtomicLong;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.PosixParser;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
@@ -24,16 +33,6 @@ import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.srvutil.ServerUtil;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.PosixParser;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.atomic.AtomicLong;
public class Consumer {
@@ -77,17 +76,16 @@ public class Consumer {
Long[] end = snapshotList.getLast();
final long consumeTps =
- (long) (((end[1] - begin[1]) / (double) (end[0] - begin[0])) * 1000L);
- final double averageB2CRT = (end[2] - begin[2]) / (double) (end[1] - begin[1]);
- final double averageS2CRT = (end[3] - begin[3]) / (double) (end[1] - begin[1]);
+ (long)(((end[1] - begin[1]) / (double)(end[0] - begin[0])) * 1000L);
+ final double averageB2CRT = (end[2] - begin[2]) / (double)(end[1] - begin[1]);
+ final double averageS2CRT = (end[3] - begin[3]) / (double)(end[1] - begin[1]);
System.out.printf("Consume TPS: %d Average(B2C) RT: %7.3f Average(S2C) RT: %7.3f MAX(B2C) RT: %d MAX(S2C) RT: %d%n",
- consumeTps, averageB2CRT, averageS2CRT, end[4], end[5]
+ consumeTps, averageB2CRT, averageS2CRT, end[4], end[5]
);
}
}
-
@Override
public void run() {
try {
@@ -106,7 +104,7 @@ public class Consumer {
consumer.registerMessageListener(new MessageListenerConcurrently() {
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
- ConsumeConcurrentlyContext context) {
+ ConsumeConcurrentlyContext context) {
MessageExt msg = msgs.get(0);
long now = System.currentTimeMillis();
@@ -140,7 +138,6 @@ public class Consumer {
opt.setRequired(false);
options.addOption(opt);
-
opt = new Option("p", "group prefix enable", true, "Consumer group name, Default: false");
opt.setRequired(false);
options.addOption(opt);
@@ -148,7 +145,6 @@ public class Consumer {
return options;
}
-
public static void compareAndSetMax(final AtomicLong target, final long value) {
long prev = target.get();
while (value > prev) {
@@ -161,7 +157,6 @@ public class Consumer {
}
}
-
class StatsBenchmarkConsumer {
private final AtomicLong receiveMessageTotalCount = new AtomicLong(0L);
@@ -173,41 +168,35 @@ class StatsBenchmarkConsumer {
private final AtomicLong store2ConsumerMaxRT = new AtomicLong(0L);
-
public Long[] createSnapshot() {
- Long[] snap = new Long[]{
- System.currentTimeMillis(),
- this.receiveMessageTotalCount.get(),
- this.born2ConsumerTotalRT.get(),
- this.store2ConsumerTotalRT.get(),
- this.born2ConsumerMaxRT.get(),
- this.store2ConsumerMaxRT.get(),
+ Long[] snap = new Long[] {
+ System.currentTimeMillis(),
+ this.receiveMessageTotalCount.get(),
+ this.born2ConsumerTotalRT.get(),
+ this.store2ConsumerTotalRT.get(),
+ this.born2ConsumerMaxRT.get(),
+ this.store2ConsumerMaxRT.get(),
};
return snap;
}
-
public AtomicLong getReceiveMessageTotalCount() {
return receiveMessageTotalCount;
}
-
public AtomicLong getBorn2ConsumerTotalRT() {
return born2ConsumerTotalRT;
}
-
public AtomicLong getStore2ConsumerTotalRT() {
return store2ConsumerTotalRT;
}
-
public AtomicLong getBorn2ConsumerMaxRT() {
return born2ConsumerMaxRT;
}
-
public AtomicLong getStore2ConsumerMaxRT() {
return store2ConsumerMaxRT;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java b/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java
index 3b13f94..88e9a4f 100644
--- a/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/benchmark/Producer.java
@@ -16,6 +16,17 @@
*/
package org.apache.rocketmq.example.benchmark;
+import java.io.UnsupportedEncodingException;
+import java.util.LinkedList;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicLong;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.PosixParser;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.log.ClientLogger;
@@ -24,20 +35,8 @@ import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.apache.rocketmq.remoting.exception.RemotingException;
import org.apache.rocketmq.srvutil.ServerUtil;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.PosixParser;
import org.slf4j.Logger;
-import java.io.UnsupportedEncodingException;
-import java.util.LinkedList;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.atomic.AtomicLong;
-
public class Producer {
public static void main(String[] args) throws MQClientException, UnsupportedEncodingException {
@@ -82,15 +81,14 @@ public class Producer {
Long[] begin = snapshotList.getFirst();
Long[] end = snapshotList.getLast();
- final long sendTps = (long) (((end[3] - begin[3]) / (double) (end[0] - begin[0])) * 1000L);
- final double averageRT = (end[5] - begin[5]) / (double) (end[3] - begin[3]);
+ final long sendTps = (long)(((end[3] - begin[3]) / (double)(end[0] - begin[0])) * 1000L);
+ final double averageRT = (end[5] - begin[5]) / (double)(end[3] - begin[3]);
System.out.printf("Send TPS: %d Max RT: %d Average RT: %7.3f Send Failed: %d Response Failed: %d%n",
- sendTps, statsBenchmark.getSendMessageMaxRT().get(), averageRT, end[2], end[4]);
+ sendTps, statsBenchmark.getSendMessageMaxRT().get(), averageRT, end[2], end[4]);
}
}
-
@Override
public void run() {
try {
@@ -202,7 +200,6 @@ public class Producer {
}
}
-
class StatsBenchmarkProducer {
private final AtomicLong sendRequestSuccessCount = new AtomicLong(0L);
@@ -216,46 +213,39 @@ class StatsBenchmarkProducer {
private final AtomicLong sendMessageMaxRT = new AtomicLong(0L);
-
public Long[] createSnapshot() {
- Long[] snap = new Long[]{
- System.currentTimeMillis(),
- this.sendRequestSuccessCount.get(),
- this.sendRequestFailedCount.get(),
- this.receiveResponseSuccessCount.get(),
- this.receiveResponseFailedCount.get(),
- this.sendMessageSuccessTimeTotal.get(),
+ Long[] snap = new Long[] {
+ System.currentTimeMillis(),
+ this.sendRequestSuccessCount.get(),
+ this.sendRequestFailedCount.get(),
+ this.receiveResponseSuccessCount.get(),
+ this.receiveResponseFailedCount.get(),
+ this.sendMessageSuccessTimeTotal.get(),
};
return snap;
}
-
public AtomicLong getSendRequestSuccessCount() {
return sendRequestSuccessCount;
}
-
public AtomicLong getSendRequestFailedCount() {
return sendRequestFailedCount;
}
-
public AtomicLong getReceiveResponseSuccessCount() {
return receiveResponseSuccessCount;
}
-
public AtomicLong getReceiveResponseFailedCount() {
return receiveResponseFailedCount;
}
-
public AtomicLong getSendMessageSuccessTimeTotal() {
return sendMessageSuccessTimeTotal;
}
-
public AtomicLong getSendMessageMaxRT() {
return sendMessageMaxRT;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/benchmark/TransactionProducer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/benchmark/TransactionProducer.java b/example/src/main/java/org/apache/rocketmq/example/benchmark/TransactionProducer.java
index 43f159b..ce4b1ab 100644
--- a/example/src/main/java/org/apache/rocketmq/example/benchmark/TransactionProducer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/benchmark/TransactionProducer.java
@@ -17,12 +17,6 @@
package org.apache.rocketmq.example.benchmark;
-import org.apache.rocketmq.client.exception.MQClientException;
-import org.apache.rocketmq.common.message.Message;
-import org.apache.rocketmq.common.message.MessageExt;
-import org.apache.rocketmq.remoting.common.RemotingHelper;
-import org.apache.rocketmq.client.producer.*;
-
import java.io.UnsupportedEncodingException;
import java.util.LinkedList;
import java.util.Timer;
@@ -30,6 +24,15 @@ import java.util.TimerTask;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicLong;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.producer.LocalTransactionExecuter;
+import org.apache.rocketmq.client.producer.LocalTransactionState;
+import org.apache.rocketmq.client.producer.SendResult;
+import org.apache.rocketmq.client.producer.TransactionCheckListener;
+import org.apache.rocketmq.client.producer.TransactionMQProducer;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
public class TransactionProducer {
private static int threadCount;
@@ -37,7 +40,6 @@ public class TransactionProducer {
private static boolean ischeck;
private static boolean ischeckffalse;
-
public static void main(String[] args) throws MQClientException, UnsupportedEncodingException {
threadCount = args.length >= 1 ? Integer.parseInt(args[0]) : 32;
messageSize = args.length >= 2 ? Integer.parseInt(args[1]) : 1024 * 2;
@@ -71,16 +73,15 @@ public class TransactionProducer {
Long[] end = snapshotList.getLast();
final long sendTps =
- (long) (((end[3] - begin[3]) / (double) (end[0] - begin[0])) * 1000L);
- final double averageRT = (end[5] - begin[5]) / (double) (end[3] - begin[3]);
+ (long)(((end[3] - begin[3]) / (double)(end[0] - begin[0])) * 1000L);
+ final double averageRT = (end[5] - begin[5]) / (double)(end[3] - begin[3]);
System.out.printf(
- "Send TPS: %d Max RT: %d Average RT: %7.3f Send Failed: %d Response Failed: %d transaction checkCount: %d %n",
- sendTps, statsBenchmark.getSendMessageMaxRT().get(), averageRT, end[2], end[4], end[6]);
+ "Send TPS: %d Max RT: %d Average RT: %7.3f Send Failed: %d Response Failed: %d transaction checkCount: %d %n",
+ sendTps, statsBenchmark.getSendMessageMaxRT().get(), averageRT, end[2], end[4], end[6]);
}
}
-
@Override
public void run() {
try {
@@ -92,7 +93,7 @@ public class TransactionProducer {
}, 10000, 10000);
final TransactionCheckListener transactionCheckListener =
- new TransactionCheckListenerBImpl(ischeckffalse, statsBenchmark);
+ new TransactionCheckListenerBImpl(ischeckffalse, statsBenchmark);
final TransactionMQProducer producer = new TransactionMQProducer("benchmark_transaction_producer");
producer.setInstanceName(Long.toString(System.currentTimeMillis()));
producer.setTransactionCheckListener(transactionCheckListener);
@@ -110,7 +111,7 @@ public class TransactionProducer {
// Thread.sleep(1000);
final long beginTimestamp = System.currentTimeMillis();
SendResult sendResult =
- producer.sendMessageInTransaction(msg, tranExecuter, null);
+ producer.sendMessageInTransaction(msg, tranExecuter, null);
if (sendResult != null) {
statsBenchmark.getSendRequestSuccessCount().incrementAndGet();
statsBenchmark.getReceiveResponseSuccessCount().incrementAndGet();
@@ -121,8 +122,8 @@ public class TransactionProducer {
long prevMaxRT = statsBenchmark.getSendMessageMaxRT().get();
while (currentRT > prevMaxRT) {
boolean updated =
- statsBenchmark.getSendMessageMaxRT().compareAndSet(prevMaxRT,
- currentRT);
+ statsBenchmark.getSendMessageMaxRT().compareAndSet(prevMaxRT,
+ currentRT);
if (updated)
break;
@@ -137,7 +138,6 @@ public class TransactionProducer {
}
}
-
private static Message buildMessage(final int messageSize) throws UnsupportedEncodingException {
Message msg = new Message();
msg.setTopic("BenchmarkTest");
@@ -153,17 +153,14 @@ public class TransactionProducer {
}
}
-
class TransactionExecuterBImpl implements LocalTransactionExecuter {
private boolean ischeck;
-
public TransactionExecuterBImpl(boolean ischeck) {
this.ischeck = ischeck;
}
-
@Override
public LocalTransactionState executeLocalTransactionBranch(final Message msg, final Object arg) {
if (ischeck) {
@@ -173,19 +170,16 @@ class TransactionExecuterBImpl implements LocalTransactionExecuter {
}
}
-
class TransactionCheckListenerBImpl implements TransactionCheckListener {
private boolean ischeckffalse;
private StatsBenchmarkTProducer statsBenchmarkTProducer;
-
public TransactionCheckListenerBImpl(boolean ischeckffalse,
- StatsBenchmarkTProducer statsBenchmarkTProducer) {
+ StatsBenchmarkTProducer statsBenchmarkTProducer) {
this.ischeckffalse = ischeckffalse;
this.statsBenchmarkTProducer = statsBenchmarkTProducer;
}
-
@Override
public LocalTransactionState checkLocalTransactionState(MessageExt msg) {
statsBenchmarkTProducer.getCheckRequestSuccessCount().incrementAndGet();
@@ -198,7 +192,6 @@ class TransactionCheckListenerBImpl implements TransactionCheckListener {
}
}
-
class StatsBenchmarkTProducer {
private final AtomicLong sendRequestSuccessCount = new AtomicLong(0L);
@@ -214,51 +207,43 @@ class StatsBenchmarkTProducer {
private final AtomicLong checkRequestSuccessCount = new AtomicLong(0L);
-
public Long[] createSnapshot() {
- Long[] snap = new Long[]{
- System.currentTimeMillis(),
- this.sendRequestSuccessCount.get(),
- this.sendRequestFailedCount.get(),
- this.receiveResponseSuccessCount.get(),
- this.receiveResponseFailedCount.get(),
- this.sendMessageSuccessTimeTotal.get(),
- this.checkRequestSuccessCount.get()};
+ Long[] snap = new Long[] {
+ System.currentTimeMillis(),
+ this.sendRequestSuccessCount.get(),
+ this.sendRequestFailedCount.get(),
+ this.receiveResponseSuccessCount.get(),
+ this.receiveResponseFailedCount.get(),
+ this.sendMessageSuccessTimeTotal.get(),
+ this.checkRequestSuccessCount.get()};
return snap;
}
-
public AtomicLong getSendRequestSuccessCount() {
return sendRequestSuccessCount;
}
-
public AtomicLong getSendRequestFailedCount() {
return sendRequestFailedCount;
}
-
public AtomicLong getReceiveResponseSuccessCount() {
return receiveResponseSuccessCount;
}
-
public AtomicLong getReceiveResponseFailedCount() {
return receiveResponseFailedCount;
}
-
public AtomicLong getSendMessageSuccessTimeTotal() {
return sendMessageSuccessTimeTotal;
}
-
public AtomicLong getSendMessageMaxRT() {
return sendMessageMaxRT;
}
-
public AtomicLong getCheckRequestSuccessCount() {
return checkRequestSuccessCount;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/broadcast/PushConsumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/broadcast/PushConsumer.java b/example/src/main/java/org/apache/rocketmq/example/broadcast/PushConsumer.java
index aa62a1e..6301b3b 100644
--- a/example/src/main/java/org/apache/rocketmq/example/broadcast/PushConsumer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/broadcast/PushConsumer.java
@@ -16,6 +16,7 @@
*/
package org.apache.rocketmq.example.broadcast;
+import java.util.List;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
@@ -25,8 +26,6 @@ import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
-import java.util.List;
-
public class PushConsumer {
public static void main(String[] args) throws InterruptedException, MQClientException {
@@ -42,7 +41,7 @@ public class PushConsumer {
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
- ConsumeConcurrentlyContext context) {
+ ConsumeConcurrentlyContext context) {
System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n");
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/filter/Consumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/filter/Consumer.java b/example/src/main/java/org/apache/rocketmq/example/filter/Consumer.java
index d0a41f1..8d0fbe4 100644
--- a/example/src/main/java/org/apache/rocketmq/example/filter/Consumer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/filter/Consumer.java
@@ -16,6 +16,7 @@
*/
package org.apache.rocketmq.example.filter;
+import java.util.List;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
@@ -24,9 +25,6 @@ import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.message.MessageExt;
-import java.util.List;
-
-
public class Consumer {
public static void main(String[] args) throws InterruptedException, MQClientException {
@@ -34,13 +32,13 @@ public class Consumer {
String filterCode = MixAll.file2String("/home/admin/MessageFilterImpl.java");
consumer.subscribe("TopicFilter7", "org.apache.rocketmq.example.filter.MessageFilterImpl",
- filterCode);
+ filterCode);
consumer.registerMessageListener(new MessageListenerConcurrently() {
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
- ConsumeConcurrentlyContext context) {
+ ConsumeConcurrentlyContext context) {
System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n");
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/filter/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/filter/Producer.java b/example/src/main/java/org/apache/rocketmq/example/filter/Producer.java
index d58c28d..a2dba6c 100644
--- a/example/src/main/java/org/apache/rocketmq/example/filter/Producer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/filter/Producer.java
@@ -30,9 +30,9 @@ public class Producer {
try {
for (int i = 0; i < 6000000; i++) {
Message msg = new Message("TopicFilter7",
- "TagA",
- "OrderID001",
- "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
+ "TagA",
+ "OrderID001",
+ "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
msg.putUserProperty("SequenceId", String.valueOf(i));
SendResult sendResult = producer.send(msg);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/operation/Consumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/operation/Consumer.java b/example/src/main/java/org/apache/rocketmq/example/operation/Consumer.java
index a6a3aca..ec7d6ef 100644
--- a/example/src/main/java/org/apache/rocketmq/example/operation/Consumer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/operation/Consumer.java
@@ -16,22 +16,20 @@
*/
package org.apache.rocketmq.example.operation;
-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.common.message.MessageExt;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
-
-import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
-
+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.common.message.MessageExt;
public class Consumer {
@@ -51,10 +49,9 @@ public class Consumer {
consumer.registerMessageListener(new MessageListenerConcurrently() {
AtomicLong consumeTimes = new AtomicLong(0);
-
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
- ConsumeConcurrentlyContext context) {
+ ConsumeConcurrentlyContext context) {
long currentTimes = this.consumeTimes.incrementAndGet();
System.out.printf("%-8d %s%n", currentTimes, msgs);
if (Boolean.parseBoolean(returnFailedHalf)) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/operation/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/operation/Producer.java b/example/src/main/java/org/apache/rocketmq/example/operation/Producer.java
index 54e256b..663acd0 100644
--- a/example/src/main/java/org/apache/rocketmq/example/operation/Producer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/operation/Producer.java
@@ -6,22 +6,27 @@
* (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
+ * 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.
+ * 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.example.operation;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.PosixParser;
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.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;
-import org.apache.commons.cli.*;
public class Producer {
@@ -42,10 +47,10 @@ public class Producer {
for (int i = 0; i < Integer.parseInt(msgCount); i++) {
try {
Message msg = new Message(
- topic,
- tags,
- keys,
- ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET));
+ topic,
+ tags,
+ keys,
+ ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET));
SendResult sendResult = producer.send(msg);
System.out.printf("%-8d %s%n", i, sendResult);
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/ordermessage/Consumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/ordermessage/Consumer.java b/example/src/main/java/org/apache/rocketmq/example/ordermessage/Consumer.java
index 7ddfbf7..0a25402 100644
--- a/example/src/main/java/org/apache/rocketmq/example/ordermessage/Consumer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/ordermessage/Consumer.java
@@ -16,6 +16,8 @@
*/
package org.apache.rocketmq.example.ordermessage;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyContext;
import org.apache.rocketmq.client.consumer.listener.ConsumeOrderlyStatus;
@@ -24,10 +26,6 @@ import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import org.apache.rocketmq.common.message.MessageExt;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
-
-
public class Consumer {
public static void main(String[] args) throws MQClientException {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/ordermessage/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/ordermessage/Producer.java b/example/src/main/java/org/apache/rocketmq/example/ordermessage/Producer.java
index 84c1da4..7abbb5a 100644
--- a/example/src/main/java/org/apache/rocketmq/example/ordermessage/Producer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/ordermessage/Producer.java
@@ -16,6 +16,8 @@
*/
package org.apache.rocketmq.example.ordermessage;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
@@ -27,25 +29,22 @@ import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.apache.rocketmq.remoting.exception.RemotingException;
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-
public class Producer {
public static void main(String[] args) throws UnsupportedEncodingException {
try {
MQProducer producer = new DefaultMQProducer("please_rename_unique_group_name");
producer.start();
- String[] tags = new String[]{"TagA", "TagB", "TagC", "TagD", "TagE"};
+ String[] tags = new String[] {"TagA", "TagB", "TagC", "TagD", "TagE"};
for (int i = 0; i < 100; i++) {
int orderId = i % 10;
Message msg =
- new Message("TopicTestjjj", tags[i % tags.length], "KEY" + i,
- ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET));
+ new Message("TopicTestjjj", tags[i % tags.length], "KEY" + i,
+ ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET));
SendResult sendResult = producer.send(msg, new MessageQueueSelector() {
@Override
public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
- Integer id = (Integer) arg;
+ Integer id = (Integer)arg;
int index = id % mqs.size();
return mqs.get(index);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/quickstart/Consumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/quickstart/Consumer.java b/example/src/main/java/org/apache/rocketmq/example/quickstart/Consumer.java
index 43566f0..513c269 100644
--- a/example/src/main/java/org/apache/rocketmq/example/quickstart/Consumer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/quickstart/Consumer.java
@@ -16,6 +16,7 @@
*/
package org.apache.rocketmq.example.quickstart;
+import java.util.List;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
@@ -24,8 +25,6 @@ import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import org.apache.rocketmq.common.message.MessageExt;
-import java.util.List;
-
public class Consumer {
public static void main(String[] args) throws InterruptedException, MQClientException {
@@ -39,7 +38,7 @@ public class Consumer {
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
- ConsumeConcurrentlyContext context) {
+ ConsumeConcurrentlyContext context) {
System.out.printf(Thread.currentThread().getName() + " Receive New Messages: " + msgs + "%n");
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/quickstart/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/quickstart/Producer.java b/example/src/main/java/org/apache/rocketmq/example/quickstart/Producer.java
index f6bd5df..a74d9df 100644
--- a/example/src/main/java/org/apache/rocketmq/example/quickstart/Producer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/quickstart/Producer.java
@@ -32,8 +32,8 @@ public class Producer {
for (int i = 0; i < 1000; i++) {
try {
Message msg = new Message("TopicTest",
- "TagA",
- ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET)
+ "TagA",
+ ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET)
);
SendResult sendResult = producer.send(msg);
LocalTransactionExecuter tranExecuter = new LocalTransactionExecuter() {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/simple/AsyncProducer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/AsyncProducer.java b/example/src/main/java/org/apache/rocketmq/example/simple/AsyncProducer.java
index 68dbb67..d4d9975 100644
--- a/example/src/main/java/org/apache/rocketmq/example/simple/AsyncProducer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/AsyncProducer.java
@@ -16,6 +16,7 @@
*/
package org.apache.rocketmq.example.simple;
+import java.io.UnsupportedEncodingException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendCallback;
@@ -23,9 +24,6 @@ import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;
-import java.io.UnsupportedEncodingException;
-
-
public class AsyncProducer {
public static void main(String[] args) throws MQClientException, InterruptedException, UnsupportedEncodingException {
@@ -37,9 +35,9 @@ public class AsyncProducer {
try {
final int index = i;
Message msg = new Message("Jodie_topic_1023",
- "TagA",
- "OrderID188",
- "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
+ "TagA",
+ "OrderID188",
+ "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
producer.send(msg, new SendCallback() {
@Override
public void onSuccess(SendResult sendResult) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/simple/CachedQueue.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/CachedQueue.java b/example/src/main/java/org/apache/rocketmq/example/simple/CachedQueue.java
index 2b4ce23..54bf54f 100644
--- a/example/src/main/java/org/apache/rocketmq/example/simple/CachedQueue.java
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/CachedQueue.java
@@ -6,26 +6,23 @@
* (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
+ * 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.
+ * 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.example.simple;
-import org.apache.rocketmq.common.message.MessageExt;
-
import java.util.TreeMap;
-
+import org.apache.rocketmq.common.message.MessageExt;
public class CachedQueue {
private final TreeMap<Long, MessageExt> msgCachedTable = new TreeMap<Long, MessageExt>();
-
public TreeMap<Long, MessageExt> getMsgCachedTable() {
return msgCachedTable;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/simple/Producer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/Producer.java b/example/src/main/java/org/apache/rocketmq/example/simple/Producer.java
index b035d57..590bcee 100644
--- a/example/src/main/java/org/apache/rocketmq/example/simple/Producer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/Producer.java
@@ -22,7 +22,6 @@ import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;
-
public class Producer {
public static void main(String[] args) throws MQClientException, InterruptedException {
@@ -34,9 +33,9 @@ public class Producer {
try {
{
Message msg = new Message("TopicTest",
- "TagA",
- "OrderID188",
- "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
+ "TagA",
+ "OrderID188",
+ "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
SendResult sendResult = producer.send(msg);
System.out.printf("%s%n", sendResult);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/simple/PullConsumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/PullConsumer.java b/example/src/main/java/org/apache/rocketmq/example/simple/PullConsumer.java
index 8c9ba15..c468f3a 100644
--- a/example/src/main/java/org/apache/rocketmq/example/simple/PullConsumer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/PullConsumer.java
@@ -16,19 +16,17 @@
*/
package org.apache.rocketmq.example.simple;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
import org.apache.rocketmq.client.consumer.DefaultMQPullConsumer;
import org.apache.rocketmq.client.consumer.PullResult;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.message.MessageQueue;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
public class PullConsumer {
private static final Map<MessageQueue, Long> OFFSE_TABLE = new HashMap<MessageQueue, Long>();
-
public static void main(String[] args) throws MQClientException {
DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("please_rename_unique_group_name_5");
@@ -41,7 +39,7 @@ public class PullConsumer {
while (true) {
try {
PullResult pullResult =
- consumer.pullBlockIfNotFound(mq, null, getMessageQueueOffset(mq), 32);
+ consumer.pullBlockIfNotFound(mq, null, getMessageQueueOffset(mq), 32);
System.out.printf("%s%n", pullResult);
putMessageQueueOffset(mq, pullResult.getNextBeginOffset());
switch (pullResult.getPullStatus()) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/simple/PullScheduleService.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/PullScheduleService.java b/example/src/main/java/org/apache/rocketmq/example/simple/PullScheduleService.java
index d38d679..b6bc8d2 100644
--- a/example/src/main/java/org/apache/rocketmq/example/simple/PullScheduleService.java
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/PullScheduleService.java
@@ -26,7 +26,6 @@ import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
-
public class PullScheduleService {
public static void main(String[] args) throws MQClientException {
@@ -59,7 +58,6 @@ public class PullScheduleService {
}
consumer.updateConsumeOffset(mq, pullResult.getNextBeginOffset());
-
context.setPullNextDelayTimeMillis(100);
} catch (Exception e) {
e.printStackTrace();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/simple/PushConsumer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/PushConsumer.java b/example/src/main/java/org/apache/rocketmq/example/simple/PushConsumer.java
index 5929aff..78bb922 100644
--- a/example/src/main/java/org/apache/rocketmq/example/simple/PushConsumer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/PushConsumer.java
@@ -16,6 +16,7 @@
*/
package org.apache.rocketmq.example.simple;
+import java.util.List;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
@@ -24,9 +25,6 @@ import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import org.apache.rocketmq.common.message.MessageExt;
-import java.util.List;
-
-
public class PushConsumer {
public static void main(String[] args) throws InterruptedException, MQClientException {
[98/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Fix the
conflicts between code and check style.
Posted by yu...@apache.org.
ROCKETMQ-18 Fix the conflicts between code and check style.
Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/commit/853b167b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/tree/853b167b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/diff/853b167b
Branch: refs/heads/master
Commit: 853b167bda89c58dc1bdffceb95ee4698e5d9e53
Parents: 388ba7a
Author: yukon <yu...@apache.org>
Authored: Wed Dec 28 16:11:32 2016 +0800
Committer: yukon <yu...@apache.org>
Committed: Wed Dec 28 16:11:32 2016 +0800
----------------------------------------------------------------------
.../rocketmq/broker/BrokerController.java | 4 +-
.../apache/rocketmq/broker/BrokerStartup.java | 2 +-
.../broker/client/ClientChannelInfo.java | 4 +-
.../broker/latency/BrokerFastFailure.java | 4 +-
.../broker/longpolling/ManyPullRequest.java | 2 +-
.../rocketmq/broker/out/BrokerOuterAPI.java | 2 +-
.../broker/plugin/MessageStoreFactory.java | 2 +-
.../processor/AbstractSendMessageProcessor.java | 6 +-
.../broker/processor/AdminBrokerProcessor.java | 62 ++++-----
.../broker/processor/ClientManageProcessor.java | 2 +-
.../processor/ConsumerManageProcessor.java | 8 +-
.../processor/EndTransactionProcessor.java | 2 +-
.../broker/processor/PullMessageProcessor.java | 6 +-
.../broker/processor/QueryMessageProcessor.java | 6 +-
.../broker/processor/SendMessageProcessor.java | 8 +-
.../rocketmq/broker/BrokerTestHarness.java | 2 +
.../rocketmq/broker/api/SendMessageTest.java | 2 +
.../offset/ConsumerOffsetManagerTest.java | 2 +
.../broker/topic/TopicConfigManagerTest.java | 2 +
checkstyle/checkstyle.xml | 128 -------------------
.../apache/rocketmq/client/ClientConfig.java | 1 -
.../org/apache/rocketmq/client/MQAdmin.java | 70 +++-------
.../org/apache/rocketmq/client/Validators.java | 9 +-
.../client/consumer/DefaultMQPullConsumer.java | 1 -
.../rocketmq/client/consumer/MQConsumer.java | 8 +-
.../client/consumer/MQPullConsumer.java | 33 +----
.../client/consumer/MQPushConsumer.java | 20 +--
.../client/consumer/MessageQueueListener.java | 10 +-
.../rocketmq/client/consumer/PullCallback.java | 1 -
.../listener/ConsumeOrderlyContext.java | 1 -
.../consumer/listener/MessageListener.java | 1 -
.../listener/MessageListenerConcurrently.java | 6 +-
.../listener/MessageListenerOrderly.java | 6 +-
.../consumer/store/OffsetSerializeWrapper.java | 1 -
.../client/consumer/store/OffsetStore.java | 4 -
.../client/impl/ClientRemotingProcessor.java | 12 +-
.../rocketmq/client/impl/MQAdminImpl.java | 2 +-
.../rocketmq/client/impl/MQClientAPIImpl.java | 18 +--
.../consumer/DefaultMQPushConsumerImpl.java | 8 +-
.../client/impl/consumer/MQConsumerInner.java | 1 -
.../client/impl/consumer/MessageQueueLock.java | 1 -
.../client/impl/consumer/ProcessQueue.java | 3 -
.../client/impl/consumer/PullAPIWrapper.java | 2 +-
.../impl/consumer/PullMessageService.java | 2 +-
.../client/impl/consumer/PullRequest.java | 2 +-
.../client/impl/consumer/RebalanceService.java | 1 -
.../client/impl/factory/MQClientInstance.java | 10 +-
.../impl/producer/DefaultMQProducerImpl.java | 6 +-
.../latency/LatencyFaultToleranceImpl.java | 6 +-
.../client/stat/ConsumerStatsManager.java | 10 +-
.../apache/rocketmq/common/Configuration.java | 3 +-
.../apache/rocketmq/common/CountDownLatch2.java | 2 +-
.../org/apache/rocketmq/common/DataVersion.java | 4 +-
.../java/org/apache/rocketmq/common/MixAll.java | 4 +-
.../org/apache/rocketmq/common/TopicConfig.java | 2 +-
.../org/apache/rocketmq/common/UtilAll.java | 40 +++---
.../rocketmq/common/filter/impl/PolishExpr.java | 17 +--
.../common/message/MessageClientIDSetter.java | 12 +-
.../rocketmq/common/message/MessageDecoder.java | 14 +-
.../rocketmq/common/message/MessageExt.java | 6 +-
.../rocketmq/common/message/MessageQueue.java | 2 +-
.../common/message/MessageQueueForC.java | 2 +-
.../rocketmq/common/namesrv/NamesrvConfig.java | 2 +
.../rocketmq/common/namesrv/TopAddressing.java | 2 +
.../protocol/body/ConsumerRunningInfo.java | 4 +-
.../CheckTransactionStateRequestHeader.java | 2 +
.../CheckTransactionStateResponseHeader.java | 2 +
.../header/CloneGroupOffsetRequestHeader.java | 2 +
.../header/CreateTopicRequestHeader.java | 2 +
.../header/DeleteTopicRequestHeader.java | 2 +
.../header/EndTransactionRequestHeader.java | 2 +
.../header/EndTransactionResponseHeader.java | 2 +
.../header/GetAllTopicConfigResponseHeader.java | 2 +
.../header/GetBrokerConfigResponseHeader.java | 2 +
.../GetEarliestMsgStoretimeRequestHeader.java | 2 +
.../GetEarliestMsgStoretimeResponseHeader.java | 2 +
.../header/GetMaxOffsetRequestHeader.java | 2 +
.../header/GetMaxOffsetResponseHeader.java | 2 +
.../header/GetMinOffsetRequestHeader.java | 2 +
.../header/GetMinOffsetResponseHeader.java | 2 +
.../header/PullMessageRequestHeader.java | 2 +
.../header/PullMessageResponseHeader.java | 2 +
.../QueryConsumerOffsetRequestHeader.java | 2 +
.../QueryConsumerOffsetResponseHeader.java | 2 +
.../header/QueryCorrectionOffsetHeader.java | 2 +
.../header/QueryMessageRequestHeader.java | 2 +
.../header/QueryMessageResponseHeader.java | 2 +
.../QueryTopicConsumeByWhoRequestHeader.java | 2 +
.../header/SearchOffsetRequestHeader.java | 2 +
.../header/SearchOffsetResponseHeader.java | 2 +
.../header/SendMessageRequestHeader.java | 2 +
.../header/SendMessageResponseHeader.java | 2 +
.../UpdateConsumerOffsetRequestHeader.java | 2 +
.../UpdateConsumerOffsetResponseHeader.java | 2 +
.../header/ViewMessageRequestHeader.java | 2 +
.../header/ViewMessageResponseHeader.java | 2 +
.../namesrv/GetRouteInfoRequestHeader.java | 2 +
.../namesrv/GetRouteInfoResponseHeader.java | 2 +
.../namesrv/RegisterBrokerRequestHeader.java | 2 +
.../RegisterOrderTopicRequestHeader.java | 2 +
.../namesrv/UnRegisterBrokerRequestHeader.java | 2 +
.../common/protocol/heartbeat/ConsumeType.java | 2 +
.../common/protocol/heartbeat/ConsumerData.java | 2 +
.../protocol/heartbeat/HeartbeatData.java | 2 +
.../common/protocol/heartbeat/MessageModel.java | 2 +
.../common/protocol/heartbeat/ProducerData.java | 2 +
.../protocol/heartbeat/SubscriptionData.java | 4 +-
.../common/protocol/route/BrokerData.java | 4 +-
.../common/protocol/route/QueueData.java | 4 +-
.../common/protocol/route/TopicRouteData.java | 4 +-
.../common/queue/ConcurrentTreeMap.java | 1 -
.../rocketmq/common/queue/RoundQueue.java | 1 -
.../subscription/SubscriptionGroupConfig.java | 6 +-
.../rocketmq/common/utils/ChannelUtil.java | 2 +-
.../rocketmq/common/utils/HttpTinyClient.java | 18 +--
.../rocketmq/common/utils/IOTinyUtils.java | 9 +-
.../rocketmq/example/benchmark/Consumer.java | 6 +-
.../rocketmq/example/benchmark/Producer.java | 4 +-
.../example/benchmark/TransactionProducer.java | 4 +-
.../rocketmq/example/ordermessage/Producer.java | 2 +-
.../filtersrv/FilterServerOuterAPI.java | 2 +-
.../rocketmq/filtersrv/FiltersrvStartup.java | 2 +-
.../rocketmq/filtersrv/filter/DynaCode.java | 2 +-
.../filtersrv/filter/FilterClassManager.java | 4 +-
.../processor/DefaultRequestProcessor.java | 10 +-
.../apache/rocketmq/namesrv/NamesrvStartup.java | 2 +-
.../processor/ClusterTestRequestProcessor.java | 2 +-
.../processor/DefaultRequestProcessor.java | 30 ++---
.../namesrv/routeinfo/RouteInfoManager.java | 2 +-
pom.xml | 4 +-
.../remoting/common/RemotingHelper.java | 6 +-
.../rocketmq/remoting/common/RemotingUtil.java | 4 +-
.../rocketmq/remoting/common/ServiceThread.java | 2 -
.../rocketmq/remoting/netty/NettyDecoder.java | 2 +-
.../remoting/netty/NettyRemotingClient.java | 2 +-
.../remoting/netty/NettyRemotingServer.java | 4 +-
.../remoting/netty/NettyRequestProcessor.java | 2 -
.../remoting/netty/NettyServerConfig.java | 2 +-
.../rocketmq/remoting/netty/RequestTask.java | 4 +-
.../remoting/protocol/LanguageCode.java | 18 +--
.../remoting/protocol/RemotingCommand.java | 8 +-
.../remoting/protocol/RocketMQSerializable.java | 6 +-
.../remoting/protocol/SerializeType.java | 4 +-
.../org/apache/rocketmq/remoting/MixTest.java | 2 +
.../apache/rocketmq/remoting/NettyRPCTest.java | 65 ++++------
.../store/AllocateMappedFileService.java | 2 +-
.../rocketmq/store/AppendMessageCallback.java | 3 -
.../rocketmq/store/AppendMessageResult.java | 1 -
.../rocketmq/store/AppendMessageStatus.java | 2 -
.../org/apache/rocketmq/store/CommitLog.java | 10 +-
.../org/apache/rocketmq/store/ConsumeQueue.java | 6 +-
.../rocketmq/store/DefaultMessageStore.java | 48 +++----
.../apache/rocketmq/store/GetMessageResult.java | 2 +-
.../org/apache/rocketmq/store/MappedFile.java | 8 +-
.../apache/rocketmq/store/MappedFileQueue.java | 20 +--
.../org/apache/rocketmq/store/StoreUtil.java | 2 +-
.../rocketmq/store/TransientStorePool.java | 4 +-
.../store/config/MessageStoreConfig.java | 21 +--
.../org/apache/rocketmq/store/ha/HAService.java | 2 +-
.../apache/rocketmq/store/index/IndexFile.java | 17 +--
.../rocketmq/store/index/IndexService.java | 2 +-
.../store/schedule/ScheduleMessageService.java | 2 -
.../org/apache/rocketmq/store/util/LibC.java | 2 +-
.../rocketmq/store/MappedFileQueueTest.java | 2 +
.../apache/rocketmq/store/MappedFileTest.java | 2 +
.../rocketmq/store/StoreCheckpointTest.java | 2 +
.../rocketmq/store/index/IndexFileTest.java | 2 +
.../store/schedule/ScheduleMessageTest.java | 2 +
style/rmq_checkstyle.xml | 126 ++++++++++++++++++
.../tools/admin/DefaultMQAdminExtImpl.java | 2 +-
.../rocketmq/tools/command/MQAdminStartup.java | 2 +-
.../cluster/CLusterSendMsgRTCommand.java | 2 +-
.../consumer/ConsumerProgressSubCommand.java | 4 +-
.../command/message/CheckMsgSendRTCommand.java | 4 +-
.../message/PrintMessageByQueueCommand.java | 2 +-
.../command/message/QueryMsgByIdSubCommand.java | 2 +-
176 files changed, 619 insertions(+), 659 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
index 501c1c5..f2fea43 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
@@ -205,7 +205,7 @@ public class BrokerController {
this.messageStore =
new DefaultMessageStore(this.messageStoreConfig, this.brokerStatsManager, this.messageArrivingListener,
this.brokerConfig);
- this.brokerStats = new BrokerStats((DefaultMessageStore)this.messageStore);
+ this.brokerStats = new BrokerStats((DefaultMessageStore) this.messageStore);
//load plugin
MessageStorePluginContext context = new MessageStorePluginContext(messageStoreConfig, brokerStatsManager, messageArrivingListener, brokerConfig);
this.messageStore = MessageStoreFactory.build(context, this.messageStore);
@@ -219,7 +219,7 @@ public class BrokerController {
if (result) {
this.remotingServer = new NettyRemotingServer(this.nettyServerConfig, this.clientHousekeepingService);
- NettyServerConfig fastConfig = (NettyServerConfig)this.nettyServerConfig.clone();
+ NettyServerConfig fastConfig = (NettyServerConfig) this.nettyServerConfig.clone();
fastConfig.setListenPort(nettyServerConfig.getListenPort() - 2);
this.fastRemotingServer = new NettyRemotingServer(fastConfig, this.clientHousekeepingService);
this.sendMessageExecutor = new BrokerFixedThreadPoolExecutor(
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java b/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
index dfa97c1..4c23eb0 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
@@ -178,7 +178,7 @@ public class BrokerStartup {
}
messageStoreConfig.setHaListenPort(nettyServerConfig.getListenPort() + 1);
- LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory();
+ LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
index 24cddb9..b37fce5 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/client/ClientChannelInfo.java
@@ -68,7 +68,7 @@ public class ClientChannelInfo {
result = prime * result + ((channel == null) ? 0 : channel.hashCode());
result = prime * result + ((clientId == null) ? 0 : clientId.hashCode());
result = prime * result + ((language == null) ? 0 : language.hashCode());
- result = prime * result + (int)(lastUpdateTimestamp ^ (lastUpdateTimestamp >>> 32));
+ result = prime * result + (int) (lastUpdateTimestamp ^ (lastUpdateTimestamp >>> 32));
result = prime * result + version;
return result;
}
@@ -81,7 +81,7 @@ public class ClientChannelInfo {
return false;
if (getClass() != obj.getClass())
return false;
- ClientChannelInfo other = (ClientChannelInfo)obj;
+ ClientChannelInfo other = (ClientChannelInfo) obj;
if (channel == null) {
if (other.channel != null)
return false;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
index f616e33..f885b71 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
@@ -39,8 +39,8 @@ public class BrokerFastFailure {
public static RequestTask castRunnable(final Runnable runnable) {
try {
- FutureTaskExt object = (FutureTaskExt)runnable;
- return (RequestTask)object.getRunnable();
+ FutureTaskExt object = (FutureTaskExt) runnable;
+ return (RequestTask) object.getRunnable();
} catch (Throwable e) {
log.error(String.format("castRunnable exception, %s", runnable.getClass().getName()), e);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
index 0ee02ad..30edf34 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
@@ -32,7 +32,7 @@ public class ManyPullRequest {
public synchronized List<PullRequest> cloneListAndClear() {
if (!this.pullRequestList.isEmpty()) {
- List<PullRequest> result = (ArrayList<PullRequest>)this.pullRequestList.clone();
+ List<PullRequest> result = (ArrayList<PullRequest>) this.pullRequestList.clone();
this.pullRequestList.clear();
return result;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java b/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
index 25b333a..1866628 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
@@ -169,7 +169,7 @@ public class BrokerOuterAPI {
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
RegisterBrokerResponseHeader responseHeader =
- (RegisterBrokerResponseHeader)response.decodeCommandCustomHeader(RegisterBrokerResponseHeader.class);
+ (RegisterBrokerResponseHeader) response.decodeCommandCustomHeader(RegisterBrokerResponseHeader.class);
RegisterBrokerResult result = new RegisterBrokerResult();
result.setMasterAddr(responseHeader.getMasterAddr());
result.setHaServerAddr(responseHeader.getHaServerAddr());
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java b/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java
index 294bf8c..ac7f949 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java
@@ -34,7 +34,7 @@ public final class MessageStoreFactory {
String pluginClass = pluginClasses[i];
try {
@SuppressWarnings("unchecked")
- Class<AbstractPluginMessageStore> clazz = (Class<AbstractPluginMessageStore>)Class.forName(pluginClass);
+ Class<AbstractPluginMessageStore> clazz = (Class<AbstractPluginMessageStore>) Class.forName(pluginClass);
Constructor<AbstractPluginMessageStore> construct = clazz.getConstructor(MessageStorePluginContext.class, MessageStore.class);
messageStore = construct.newInstance(context, messageStore);
} catch (Throwable e) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
index 75e5766..06e546b 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
@@ -283,12 +283,12 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
switch (request.getCode()) {
case RequestCode.SEND_MESSAGE_V2:
requestHeaderV2 =
- (SendMessageRequestHeaderV2)request
+ (SendMessageRequestHeaderV2) request
.decodeCommandCustomHeader(SendMessageRequestHeaderV2.class);
case RequestCode.SEND_MESSAGE:
if (null == requestHeaderV2) {
requestHeader =
- (SendMessageRequestHeader)request
+ (SendMessageRequestHeader) request
.decodeCommandCustomHeader(SendMessageRequestHeader.class);
} else {
requestHeader = SendMessageRequestHeaderV2.createSendMessageRequestHeaderV1(requestHeaderV2);
@@ -305,7 +305,7 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
try {
if (response != null) {
final SendMessageResponseHeader responseHeader =
- (SendMessageResponseHeader)response.readCustomHeader();
+ (SendMessageResponseHeader) response.readCustomHeader();
context.setMsgId(responseHeader.getMsgId());
context.setQueueId(responseHeader.getQueueId());
context.setQueueOffset(responseHeader.getQueueOffset());
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
index 722bec2..1398057 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
@@ -202,7 +202,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand updateAndCreateTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final CreateTopicRequestHeader requestHeader =
- (CreateTopicRequestHeader)request.decodeCommandCustomHeader(CreateTopicRequestHeader.class);
+ (CreateTopicRequestHeader) request.decodeCommandCustomHeader(CreateTopicRequestHeader.class);
log.info("updateAndCreateTopic called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
if (requestHeader.getTopic().equals(this.brokerController.getBrokerConfig().getBrokerClusterName())) {
@@ -237,7 +237,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand deleteTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
DeleteTopicRequestHeader requestHeader =
- (DeleteTopicRequestHeader)request.decodeCommandCustomHeader(DeleteTopicRequestHeader.class);
+ (DeleteTopicRequestHeader) request.decodeCommandCustomHeader(DeleteTopicRequestHeader.class);
log.info("deleteTopic called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
@@ -318,7 +318,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand getBrokerConfig(ChannelHandlerContext ctx, RemotingCommand request) {
final RemotingCommand response = RemotingCommand.createResponseCommand(GetBrokerConfigResponseHeader.class);
- final GetBrokerConfigResponseHeader responseHeader = (GetBrokerConfigResponseHeader)response.readCustomHeader();
+ final GetBrokerConfigResponseHeader responseHeader = (GetBrokerConfigResponseHeader) response.readCustomHeader();
String content = this.brokerController.getConfiguration().getAllConfigsFormatString();
if (content != null && content.length() > 0) {
@@ -342,9 +342,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand searchOffsetByTimestamp(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(SearchOffsetResponseHeader.class);
- final SearchOffsetResponseHeader responseHeader = (SearchOffsetResponseHeader)response.readCustomHeader();
+ final SearchOffsetResponseHeader responseHeader = (SearchOffsetResponseHeader) response.readCustomHeader();
final SearchOffsetRequestHeader requestHeader =
- (SearchOffsetRequestHeader)request.decodeCommandCustomHeader(SearchOffsetRequestHeader.class);
+ (SearchOffsetRequestHeader) request.decodeCommandCustomHeader(SearchOffsetRequestHeader.class);
long offset = this.brokerController.getMessageStore().getOffsetInQueueByTime(requestHeader.getTopic(), requestHeader.getQueueId(),
requestHeader.getTimestamp());
@@ -358,9 +358,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand getMaxOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(GetMaxOffsetResponseHeader.class);
- final GetMaxOffsetResponseHeader responseHeader = (GetMaxOffsetResponseHeader)response.readCustomHeader();
+ final GetMaxOffsetResponseHeader responseHeader = (GetMaxOffsetResponseHeader) response.readCustomHeader();
final GetMaxOffsetRequestHeader requestHeader =
- (GetMaxOffsetRequestHeader)request.decodeCommandCustomHeader(GetMaxOffsetRequestHeader.class);
+ (GetMaxOffsetRequestHeader) request.decodeCommandCustomHeader(GetMaxOffsetRequestHeader.class);
long offset = this.brokerController.getMessageStore().getMaxOffsetInQuque(requestHeader.getTopic(), requestHeader.getQueueId());
@@ -373,9 +373,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand getMinOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(GetMinOffsetResponseHeader.class);
- final GetMinOffsetResponseHeader responseHeader = (GetMinOffsetResponseHeader)response.readCustomHeader();
+ final GetMinOffsetResponseHeader responseHeader = (GetMinOffsetResponseHeader) response.readCustomHeader();
final GetMinOffsetRequestHeader requestHeader =
- (GetMinOffsetRequestHeader)request.decodeCommandCustomHeader(GetMinOffsetRequestHeader.class);
+ (GetMinOffsetRequestHeader) request.decodeCommandCustomHeader(GetMinOffsetRequestHeader.class);
long offset = this.brokerController.getMessageStore().getMinOffsetInQuque(requestHeader.getTopic(), requestHeader.getQueueId());
@@ -387,9 +387,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand getEarliestMsgStoretime(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(GetEarliestMsgStoretimeResponseHeader.class);
- final GetEarliestMsgStoretimeResponseHeader responseHeader = (GetEarliestMsgStoretimeResponseHeader)response.readCustomHeader();
+ final GetEarliestMsgStoretimeResponseHeader responseHeader = (GetEarliestMsgStoretimeResponseHeader) response.readCustomHeader();
final GetEarliestMsgStoretimeRequestHeader requestHeader =
- (GetEarliestMsgStoretimeRequestHeader)request.decodeCommandCustomHeader(GetEarliestMsgStoretimeRequestHeader.class);
+ (GetEarliestMsgStoretimeRequestHeader) request.decodeCommandCustomHeader(GetEarliestMsgStoretimeRequestHeader.class);
long timestamp =
this.brokerController.getMessageStore().getEarliestMessageTime(requestHeader.getTopic(), requestHeader.getQueueId());
@@ -491,7 +491,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand deleteSubscriptionGroup(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
DeleteSubscriptionGroupRequestHeader requestHeader =
- (DeleteSubscriptionGroupRequestHeader)request.decodeCommandCustomHeader(DeleteSubscriptionGroupRequestHeader.class);
+ (DeleteSubscriptionGroupRequestHeader) request.decodeCommandCustomHeader(DeleteSubscriptionGroupRequestHeader.class);
log.info("deleteSubscriptionGroup called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
@@ -505,7 +505,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand getTopicStatsInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetTopicStatsInfoRequestHeader requestHeader =
- (GetTopicStatsInfoRequestHeader)request.decodeCommandCustomHeader(GetTopicStatsInfoRequestHeader.class);
+ (GetTopicStatsInfoRequestHeader) request.decodeCommandCustomHeader(GetTopicStatsInfoRequestHeader.class);
final String topic = requestHeader.getTopic();
TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
@@ -553,7 +553,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand getConsumerConnectionList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetConsumerConnectionListRequestHeader requestHeader =
- (GetConsumerConnectionListRequestHeader)request.decodeCommandCustomHeader(GetConsumerConnectionListRequestHeader.class);
+ (GetConsumerConnectionListRequestHeader) request.decodeCommandCustomHeader(GetConsumerConnectionListRequestHeader.class);
ConsumerGroupInfo consumerGroupInfo =
this.brokerController.getConsumerManager().getConsumerGroupInfo(requestHeader.getConsumerGroup());
@@ -592,7 +592,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand getProducerConnectionList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetProducerConnectionListRequestHeader requestHeader =
- (GetProducerConnectionListRequestHeader)request.decodeCommandCustomHeader(GetProducerConnectionListRequestHeader.class);
+ (GetProducerConnectionListRequestHeader) request.decodeCommandCustomHeader(GetProducerConnectionListRequestHeader.class);
ProducerConnection bodydata = new ProducerConnection();
HashMap<Channel, ClientChannelInfo> channelInfoHashMap =
@@ -625,7 +625,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand getConsumeStats(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetConsumeStatsRequestHeader requestHeader =
- (GetConsumeStatsRequestHeader)request.decodeCommandCustomHeader(GetConsumeStatsRequestHeader.class);
+ (GetConsumeStatsRequestHeader) request.decodeCommandCustomHeader(GetConsumeStatsRequestHeader.class);
ConsumeStats consumeStats = new ConsumeStats();
@@ -733,7 +733,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand getAllDelayOffset(ChannelHandlerContext ctx, RemotingCommand request) {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- String content = ((DefaultMessageStore)this.brokerController.getMessageStore()).getScheduleMessageService().encode();
+ String content = ((DefaultMessageStore) this.brokerController.getMessageStore()).getScheduleMessageService().encode();
if (content != null && content.length() > 0) {
try {
response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
@@ -759,7 +759,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
public RemotingCommand resetOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final ResetOffsetRequestHeader requestHeader =
- (ResetOffsetRequestHeader)request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
+ (ResetOffsetRequestHeader) request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
log.info("[reset-offset] reset offset started by {}. topic={}, group={}, timestamp={}, isForce={}",
RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
requestHeader.getTimestamp(), requestHeader.isForce());
@@ -776,7 +776,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
public RemotingCommand getConsumerStatus(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final GetConsumerStatusRequestHeader requestHeader =
- (GetConsumerStatusRequestHeader)request.decodeCommandCustomHeader(GetConsumerStatusRequestHeader.class);
+ (GetConsumerStatusRequestHeader) request.decodeCommandCustomHeader(GetConsumerStatusRequestHeader.class);
log.info("[get-consumer-status] get consumer status by {}. topic={}, group={}",
RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup());
@@ -788,7 +788,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand queryTopicConsumeByWho(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
QueryTopicConsumeByWhoRequestHeader requestHeader =
- (QueryTopicConsumeByWhoRequestHeader)request.decodeCommandCustomHeader(QueryTopicConsumeByWhoRequestHeader.class);
+ (QueryTopicConsumeByWhoRequestHeader) request.decodeCommandCustomHeader(QueryTopicConsumeByWhoRequestHeader.class);
HashSet<String> groups = this.brokerController.getConsumerManager().queryTopicConsumeByWho(requestHeader.getTopic());
@@ -809,9 +809,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand registerFilterServer(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterFilterServerResponseHeader.class);
- final RegisterFilterServerResponseHeader responseHeader = (RegisterFilterServerResponseHeader)response.readCustomHeader();
+ final RegisterFilterServerResponseHeader responseHeader = (RegisterFilterServerResponseHeader) response.readCustomHeader();
final RegisterFilterServerRequestHeader requestHeader =
- (RegisterFilterServerRequestHeader)request.decodeCommandCustomHeader(RegisterFilterServerRequestHeader.class);
+ (RegisterFilterServerRequestHeader) request.decodeCommandCustomHeader(RegisterFilterServerRequestHeader.class);
this.brokerController.getFilterServerManager().registerFilterServer(ctx.channel(), requestHeader.getFilterServerAddr());
@@ -826,7 +826,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand queryConsumeTimeSpan(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
QueryConsumeTimeSpanRequestHeader requestHeader =
- (QueryConsumeTimeSpanRequestHeader)request.decodeCommandCustomHeader(QueryConsumeTimeSpanRequestHeader.class);
+ (QueryConsumeTimeSpanRequestHeader) request.decodeCommandCustomHeader(QueryConsumeTimeSpanRequestHeader.class);
final String topic = requestHeader.getTopic();
TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
@@ -916,7 +916,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
*/
private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final GetConsumerRunningInfoRequestHeader requestHeader =
- (GetConsumerRunningInfoRequestHeader)request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);
+ (GetConsumerRunningInfoRequestHeader) request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);
return this.callConsumer(RequestCode.GET_CONSUMER_RUNNING_INFO, request, requestHeader.getConsumerGroup(),
requestHeader.getClientId());
@@ -925,7 +925,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand queryCorrectionOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
QueryCorrectionOffsetHeader requestHeader =
- (QueryCorrectionOffsetHeader)request.decodeCommandCustomHeader(QueryCorrectionOffsetHeader.class);
+ (QueryCorrectionOffsetHeader) request.decodeCommandCustomHeader(QueryCorrectionOffsetHeader.class);
Map<Integer, Long> correctionOffset = this.brokerController.getConsumerOffsetManager()
.queryMinOffsetInAllGroup(requestHeader.getTopic(), requestHeader.getFilterGroups());
@@ -950,7 +950,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
}
private RemotingCommand consumeMessageDirectly(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final ConsumeMessageDirectlyResultRequestHeader requestHeader = (ConsumeMessageDirectlyResultRequestHeader)request
+ final ConsumeMessageDirectlyResultRequestHeader requestHeader = (ConsumeMessageDirectlyResultRequestHeader) request
.decodeCommandCustomHeader(ConsumeMessageDirectlyResultRequestHeader.class);
request.getExtFields().put("brokerName", this.brokerController.getBrokerConfig().getBrokerName());
@@ -976,7 +976,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand cloneGroupOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
CloneGroupOffsetRequestHeader requestHeader =
- (CloneGroupOffsetRequestHeader)request.decodeCommandCustomHeader(CloneGroupOffsetRequestHeader.class);
+ (CloneGroupOffsetRequestHeader) request.decodeCommandCustomHeader(CloneGroupOffsetRequestHeader.class);
Set<String> topics;
if (UtilAll.isBlank(requestHeader.getTopic())) {
@@ -1018,9 +1018,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
private RemotingCommand ViewBrokerStatsData(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final ViewBrokerStatsDataRequestHeader requestHeader =
- (ViewBrokerStatsDataRequestHeader)request.decodeCommandCustomHeader(ViewBrokerStatsDataRequestHeader.class);
+ (ViewBrokerStatsDataRequestHeader) request.decodeCommandCustomHeader(ViewBrokerStatsDataRequestHeader.class);
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- DefaultMessageStore messageStore = (DefaultMessageStore)this.brokerController.getMessageStore();
+ DefaultMessageStore messageStore = (DefaultMessageStore) this.brokerController.getMessageStore();
StatsItem statsItem = messageStore.getBrokerStatsManager().getStatsItem(requestHeader.getStatsName(), requestHeader.getStatsKey());
if (null == statsItem) {
@@ -1068,7 +1068,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
GetConsumeStatsInBrokerHeader requestHeader =
- (GetConsumeStatsInBrokerHeader)request.decodeCommandCustomHeader(GetConsumeStatsInBrokerHeader.class);
+ (GetConsumeStatsInBrokerHeader) request.decodeCommandCustomHeader(GetConsumeStatsInBrokerHeader.class);
boolean isOrder = requestHeader.isOrder();
ConcurrentHashMap<String, SubscriptionGroupConfig> subscriptionGroups =
brokerController.getSubscriptionGroupManager().getSubscriptionGroupTable();
@@ -1185,7 +1185,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
runtimeInfo.put("earliestMessageTimeStamp", String.valueOf(this.brokerController.getMessageStore().getEarliestMessageTime()));
runtimeInfo.put("startAcceptSendRequestTimeStamp", String.valueOf(this.brokerController.getBrokerConfig().getStartAcceptSendRequestTimeStamp()));
if (this.brokerController.getMessageStore() instanceof DefaultMessageStore) {
- DefaultMessageStore defaultMessageStore = (DefaultMessageStore)this.brokerController.getMessageStore();
+ DefaultMessageStore defaultMessageStore = (DefaultMessageStore) this.brokerController.getMessageStore();
runtimeInfo.put("remainTransientStoreBufferNumbs", String.valueOf(defaultMessageStore.remainTransientStoreBufferNumbs()));
if (defaultMessageStore.getMessageStoreConfig().isTransientStorePoolEnable()) {
runtimeInfo.put("remainHowManyDataToCommit", MixAll.humanReadableByteCount(defaultMessageStore.getCommitLog().remainHowManyDataToCommit(), false));
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
index 717afaf..74046a6 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/ClientManageProcessor.java
@@ -125,7 +125,7 @@ public class ClientManageProcessor implements NettyRequestProcessor {
final RemotingCommand response =
RemotingCommand.createResponseCommand(UnregisterClientResponseHeader.class);
final UnregisterClientRequestHeader requestHeader =
- (UnregisterClientRequestHeader)request
+ (UnregisterClientRequestHeader) request
.decodeCommandCustomHeader(UnregisterClientRequestHeader.class);
ClientChannelInfo clientChannelInfo = new ClientChannelInfo(
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
index d2e6d7d..b732326 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/ConsumerManageProcessor.java
@@ -72,7 +72,7 @@ public class ConsumerManageProcessor implements NettyRequestProcessor {
final RemotingCommand response =
RemotingCommand.createResponseCommand(GetConsumerListByGroupResponseHeader.class);
final GetConsumerListByGroupRequestHeader requestHeader =
- (GetConsumerListByGroupRequestHeader)request
+ (GetConsumerListByGroupRequestHeader) request
.decodeCommandCustomHeader(GetConsumerListByGroupRequestHeader.class);
ConsumerGroupInfo consumerGroupInfo =
@@ -106,7 +106,7 @@ public class ConsumerManageProcessor implements NettyRequestProcessor {
final RemotingCommand response =
RemotingCommand.createResponseCommand(UpdateConsumerOffsetResponseHeader.class);
final UpdateConsumerOffsetRequestHeader requestHeader =
- (UpdateConsumerOffsetRequestHeader)request
+ (UpdateConsumerOffsetRequestHeader) request
.decodeCommandCustomHeader(UpdateConsumerOffsetRequestHeader.class);
this.brokerController.getConsumerOffsetManager().commitOffset(RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getConsumerGroup(),
requestHeader.getTopic(), requestHeader.getQueueId(), requestHeader.getCommitOffset());
@@ -120,9 +120,9 @@ public class ConsumerManageProcessor implements NettyRequestProcessor {
final RemotingCommand response =
RemotingCommand.createResponseCommand(QueryConsumerOffsetResponseHeader.class);
final QueryConsumerOffsetResponseHeader responseHeader =
- (QueryConsumerOffsetResponseHeader)response.readCustomHeader();
+ (QueryConsumerOffsetResponseHeader) response.readCustomHeader();
final QueryConsumerOffsetRequestHeader requestHeader =
- (QueryConsumerOffsetRequestHeader)request
+ (QueryConsumerOffsetRequestHeader) request
.decodeCommandCustomHeader(QueryConsumerOffsetRequestHeader.class);
long offset =
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
index 6a34a69..5bf512f 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/EndTransactionProcessor.java
@@ -49,7 +49,7 @@ public class EndTransactionProcessor implements NettyRequestProcessor {
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final EndTransactionRequestHeader requestHeader =
- (EndTransactionRequestHeader)request.decodeCommandCustomHeader(EndTransactionRequestHeader.class);
+ (EndTransactionRequestHeader) request.decodeCommandCustomHeader(EndTransactionRequestHeader.class);
if (requestHeader.getFromTransactionCheck()) {
switch (requestHeader.getCommitOrRollback()) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
index 7169b9c..54e56cd 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
@@ -81,9 +81,9 @@ public class PullMessageProcessor implements NettyRequestProcessor {
private RemotingCommand processRequest(final Channel channel, RemotingCommand request, boolean brokerAllowSuspend)
throws RemotingCommandException {
RemotingCommand response = RemotingCommand.createResponseCommand(PullMessageResponseHeader.class);
- final PullMessageResponseHeader responseHeader = (PullMessageResponseHeader)response.readCustomHeader();
+ final PullMessageResponseHeader responseHeader = (PullMessageResponseHeader) response.readCustomHeader();
final PullMessageRequestHeader requestHeader =
- (PullMessageRequestHeader)request.decodeCommandCustomHeader(PullMessageRequestHeader.class);
+ (PullMessageRequestHeader) request.decodeCommandCustomHeader(PullMessageRequestHeader.class);
response.setOpaque(request.getOpaque());
@@ -335,7 +335,7 @@ public class PullMessageProcessor implements NettyRequestProcessor {
final byte[] r = this.readGetMessageResult(getMessageResult, requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueId());
this.brokerController.getBrokerStatsManager().incGroupGetLatency(requestHeader.getConsumerGroup(),
requestHeader.getTopic(), requestHeader.getQueueId(),
- (int)(this.brokerController.getMessageStore().now() - beginTimeMills));
+ (int) (this.brokerController.getMessageStore().now() - beginTimeMills));
response.setBody(r);
} else {
try {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
index 04f206f..9df5a01 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/QueryMessageProcessor.java
@@ -72,9 +72,9 @@ public class QueryMessageProcessor implements NettyRequestProcessor {
final RemotingCommand response =
RemotingCommand.createResponseCommand(QueryMessageResponseHeader.class);
final QueryMessageResponseHeader responseHeader =
- (QueryMessageResponseHeader)response.readCustomHeader();
+ (QueryMessageResponseHeader) response.readCustomHeader();
final QueryMessageRequestHeader requestHeader =
- (QueryMessageRequestHeader)request
+ (QueryMessageRequestHeader) request
.decodeCommandCustomHeader(QueryMessageRequestHeader.class);
response.setOpaque(request.getOpaque());
@@ -127,7 +127,7 @@ public class QueryMessageProcessor implements NettyRequestProcessor {
throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final ViewMessageRequestHeader requestHeader =
- (ViewMessageRequestHeader)request.decodeCommandCustomHeader(ViewMessageRequestHeader.class);
+ (ViewMessageRequestHeader) request.decodeCommandCustomHeader(ViewMessageRequestHeader.class);
response.setOpaque(request.getOpaque());
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
index 1b95205..ea8c44b 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
@@ -89,7 +89,7 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final ConsumerSendMsgBackRequestHeader requestHeader =
- (ConsumerSendMsgBackRequestHeader)request.decodeCommandCustomHeader(ConsumerSendMsgBackRequestHeader.class);
+ (ConsumerSendMsgBackRequestHeader) request.decodeCommandCustomHeader(ConsumerSendMsgBackRequestHeader.class);
if (this.hasConsumeMessageHook() && !UtilAll.isBlank(requestHeader.getOriginMsgId())) {
@@ -244,7 +244,7 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
final SendMessageRequestHeader requestHeader) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(SendMessageResponseHeader.class);
- final SendMessageResponseHeader responseHeader = (SendMessageResponseHeader)response.readCustomHeader();
+ final SendMessageResponseHeader responseHeader = (SendMessageResponseHeader) response.readCustomHeader();
response.setOpaque(request.getOpaque());
@@ -415,7 +415,7 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
int commercialBaseCount = brokerController.getBrokerConfig().getCommercialBaseCount();
int wroteSize = putMessageResult.getAppendMessageResult().getWroteBytes();
- int incValue = (int)Math.ceil(wroteSize / BrokerStatsManager.SIZE_PER_COUNT) * commercialBaseCount;
+ int incValue = (int) Math.ceil(wroteSize / BrokerStatsManager.SIZE_PER_COUNT) * commercialBaseCount;
sendMessageContext.setCommercialSendStats(BrokerStatsManager.StatsType.SEND_SUCCESS);
sendMessageContext.setCommercialSendTimes(incValue);
@@ -426,7 +426,7 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
} else {
if (hasSendMessageHook()) {
int wroteSize = request.getBody().length;
- int incValue = (int)Math.ceil(wroteSize / BrokerStatsManager.SIZE_PER_COUNT);
+ int incValue = (int) Math.ceil(wroteSize / BrokerStatsManager.SIZE_PER_COUNT);
sendMessageContext.setCommercialSendStats(BrokerStatsManager.StatsType.SEND_FAILURE);
sendMessageContext.setCommercialSendTimes(incValue);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java b/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
index 5e944d8..1eefb25 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: SendMessageTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
+ *
+ * $Id: SendMessageTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java b/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
index 38d885e..1ab0093 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: SendMessageTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
+ *
+ * $Id: SendMessageTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java b/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
index 89813fc..a4eb659 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: ConsumerOffsetManagerTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
+ *
+ * $Id: ConsumerOffsetManagerTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java b/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
index 2f85dbc..6897967 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: TopicConfigManagerTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
+ *
+ * $Id: TopicConfigManagerTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/checkstyle/checkstyle.xml
----------------------------------------------------------------------
diff --git a/checkstyle/checkstyle.xml b/checkstyle/checkstyle.xml
deleted file mode 100644
index 0d22d7d..0000000
--- a/checkstyle/checkstyle.xml
+++ /dev/null
@@ -1,128 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE module PUBLIC
- "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
- "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
-<!--
- 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.
- -->
-<!--Refer http://checkstyle.sourceforge.net/reports/google-java-style.html#s2.2-file-encoding -->
-<module name="Checker">
-
- <property name="localeLanguage" value="en"/>
-
- <!--To configure the check to report on the first instance in each file-->
- <module name="FileTabCharacter"/>
-
- <!-- header -->
- <module name="RegexpHeader">
- <property name="header" value="/\*\*\nLicensed to the Apache Software Foundation*"/>
- </module>
-
- <module name="RegexpSingleline">
- <property name="format" value="System\.out\.println"/>
- <property name="message" value="Prohibit invoking System.out.println in source code !"/>
- </module>
-
- <module name="RegexpSingleline">
- <property name="format" value="//FIXME"/>
- <property name="message" value="Recommended fix FIXME task !"/>
- </module>
-
- <module name="RegexpSingleline">
- <property name="format" value="//TODO"/>
- <property name="message" value="Recommended fix TODO task !"/>
- </module>
-
- <module name="RegexpSingleline">
- <property name="format" value="@alibaba"/>
- <property name="message" value="Recommended remove @alibaba keyword!"/>
- </module>
-
- <module name="RegexpSingleline">
- <property name="format"
- value=".*[\u3400-\u4DB5\u4E00-\u9FA5\u9FA6-\u9FBB\uF900-\uFA2D\uFA30-\uFA6A\uFA70-\uFAD9\uFF00-\uFFEF\u2E80-\u2EFF\u3000-\u303F\u31C0-\u31EF]+.*"/>
- <property name="message" value="Not allow chinese character !"/>
- </module>
-
- <module name="FileLength">
- <property name="max" value="2000"/>
- </module>
-
- <module name="TreeWalker">
-
- <module name="UnusedImports">
- <property name="processJavadoc" value="true"/>
- </module>
- <module name="RedundantImport"/>
-
- <!--<module name="IllegalImport" />-->
-
- <!--Checks that classes that override equals() also override hashCode()-->
- <module name="EqualsHashCode"/>
- <!--Checks for over-complicated boolean expressions. Currently finds code like if (topic == true), topic || true, !false, etc.-->
- <module name="SimplifyBooleanExpression"/>
- <module name="OneStatementPerLine"/>
- <module name="UnnecessaryParentheses"/>
- <!--Checks for over-complicated boolean return statements. For example the following code-->
- <module name="SimplifyBooleanReturn"/>
-
- <!--Check that the default is after all the cases in producerGroup switch statement-->
- <module name="DefaultComesLast"/>
- <!--Detects empty statements (standalone ";" semicolon)-->
- <module name="EmptyStatement"/>
- <!--Checks that long constants are defined with an upper ell-->
- <module name="UpperEll"/>
- <module name="ConstantName">
- <property name="format" value="(^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)|(^log$)"/>
- </module>
- <!--Checks that local, non-final variable names conform to producerGroup format specified by the format property-->
- <module name="LocalVariableName"/>
- <!--Validates identifiers for local, final variables, including catch parameters-->
- <module name="LocalFinalVariableName"/>
- <!--Validates identifiers for non-static fields-->
- <module name="MemberName"/>
- <!--Validates identifiers for class type parameters-->
- <module name="ClassTypeParameterName">
- <property name="format" value="^[A-Z0-9]*$"/>
- </module>
- <!--Validates identifiers for method type parameters-->
- <module name="MethodTypeParameterName">
- <property name="format" value="^[A-Z0-9]*$"/>
- </module>
- <module name="PackageName"/>
- <module name="ParameterName"/>
- <module name="StaticVariableName"/>
- <module name="TypeName"/>
- <!--Checks that there are no import statements that use the * notation-->
- <!--
- <module name="AvoidStarImport"/>
- -->
-
- <!--whitespace-->
- <module name="GenericWhitespace"/>
- <module name="NoWhitespaceBefore"/>
- <module name="WhitespaceAfter"/>
- <module name="NoWhitespaceAfter"/>
- <module name="WhitespaceAround">
- <property name="allowEmptyConstructors" value="true"/>
- <property name="allowEmptyMethods" value="true"/>
- </module>
- <module name="Indentation"/>
- <module name="MethodParamPad"/>
- <module name="ParenPad"/>
- <module name="TypecastParenPad"/>
- </module>
-</module>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/ClientConfig.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 9c7a0cd..1c80a2b 100644
--- a/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java
+++ b/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java
@@ -22,7 +22,6 @@ import org.apache.rocketmq.remoting.common.RemotingUtil;
/**
* Client Common configuration
- *
*/
public class ClientConfig {
public static final String SEND_MESSAGE_WITH_VIP_CHANNEL_PROPERTY = "com.rocketmq.sendMessageWithVIPChannel";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java b/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
index 7697520..b8d5b23 100644
--- a/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
+++ b/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
@@ -24,19 +24,14 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
/**
* Base interface for MQ management
- *
*/
public interface MQAdmin {
/**
* Creates an topic
*
- * @param key
- * accesskey
- * @param newTopic
- * topic name
- * @param queueNum
- * topic's queue number
- *
+ * @param key accesskey
+ * @param newTopic topic name
+ * @param queueNum topic's queue number
* @throws MQClientException
*/
void createTopic(final String key, final String newTopic, final int queueNum)
@@ -45,15 +40,10 @@ public interface MQAdmin {
/**
* Creates an topic
*
- * @param key
- * accesskey
- * @param newTopic
- * topic name
- * @param queueNum
- * topic's queue number
- * @param topicSysFlag
- * topic system flag
- *
+ * @param key accesskey
+ * @param newTopic topic name
+ * @param queueNum topic's queue number
+ * @param topicSysFlag topic system flag
* @throws MQClientException
*/
void createTopic(String key, String newTopic, int queueNum, int topicSysFlag)
@@ -63,13 +53,9 @@ public interface MQAdmin {
* Gets the message queue offset according to some time in milliseconds<br>
* be cautious to call because of more IO overhead
*
- * @param mq
- * Instance of MessageQueue
- * @param timestamp
- * from when in milliseconds.
- *
+ * @param mq Instance of MessageQueue
+ * @param timestamp from when in milliseconds.
* @return offset
- *
* @throws MQClientException
*/
long searchOffset(final MessageQueue mq, final long timestamp) throws MQClientException;
@@ -77,11 +63,8 @@ public interface MQAdmin {
/**
* Gets the max offset
*
- * @param mq
- * Instance of MessageQueue
- *
+ * @param mq Instance of MessageQueue
* @return the max offset
- *
* @throws MQClientException
*/
long maxOffset(final MessageQueue mq) throws MQClientException;
@@ -89,11 +72,8 @@ public interface MQAdmin {
/**
* Gets the minimum offset
*
- * @param mq
- * Instance of MessageQueue
- *
+ * @param mq Instance of MessageQueue
* @return the minimum offset
- *
* @throws MQClientException
*/
long minOffset(final MessageQueue mq) throws MQClientException;
@@ -101,11 +81,8 @@ public interface MQAdmin {
/**
* Gets the earliest stored message time
*
- * @param mq
- * Instance of MessageQueue
- *
+ * @param mq Instance of MessageQueue
* @return the time in microseconds
- *
* @throws MQClientException
*/
long earliestMsgStoreTime(final MessageQueue mq) throws MQClientException;
@@ -113,11 +90,8 @@ public interface MQAdmin {
/**
* Query message according tto message id
*
- * @param offsetMsgId
- * message id
- *
+ * @param offsetMsgId message id
* @return message
- *
* @throws InterruptedException
* @throws MQBrokerException
* @throws RemotingException
@@ -129,19 +103,12 @@ public interface MQAdmin {
/**
* Query messages
*
- * @param topic
- * message topic
- * @param key
- * message key index word
- * @param maxNum
- * max message number
- * @param begin
- * from when
- * @param end
- * to when
- *
+ * @param topic message topic
+ * @param key message key index word
+ * @param maxNum max message number
+ * @param begin from when
+ * @param end to when
* @return Instance of QueryResult
- *
* @throws MQClientException
* @throws InterruptedException
*/
@@ -149,7 +116,6 @@ public interface MQAdmin {
final long end) throws MQClientException, InterruptedException;
/**
-
* @param topic
* @param msgId
* @return The {@code MessageExt} of given msgId
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/Validators.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/Validators.java b/client/src/main/java/org/apache/rocketmq/client/Validators.java
index fa9e4e6..845886a 100644
--- a/client/src/main/java/org/apache/rocketmq/client/Validators.java
+++ b/client/src/main/java/org/apache/rocketmq/client/Validators.java
@@ -28,7 +28,6 @@ import org.apache.rocketmq.common.protocol.ResponseCode;
/**
* Common Validator
- *
*/
public class Validators {
public static final String VALID_PATTERN_STR = "^[%|a-zA-Z0-9_-]+$";
@@ -38,7 +37,6 @@ public class Validators {
/**
* @param origin
* @param patternStr
- *
* @return The resulting {@code String}
*/
public static String getGroupWithRegularExpression(String origin, String patternStr) {
@@ -54,7 +52,6 @@ public class Validators {
* Validate group
*
* @param group
- *
* @throws MQClientException
*/
public static void checkGroup(String group) throws MQClientException {
@@ -74,9 +71,7 @@ public class Validators {
/**
* @param origin
* @param pattern
- *
- * @return <tt>true</tt> if, and only if, the entire origin sequence
- * matches this matcher's pattern
+ * @return <tt>true</tt> if, and only if, the entire origin sequence matches this matcher's pattern
*/
public static boolean regularExpressionMatcher(String origin, Pattern pattern) {
if (pattern == null) {
@@ -91,7 +86,6 @@ public class Validators {
*
* @param msg
* @param defaultMQProducer
- *
* @throws MQClientException
*/
public static void checkMessage(Message msg, DefaultMQProducer defaultMQProducer)
@@ -120,7 +114,6 @@ public class Validators {
* Validate topic
*
* @param topic
- *
* @throws MQClientException
*/
public static void checkTopic(String topic) throws MQClientException {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
index 8eb1258..e438b61 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
@@ -35,7 +35,6 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
/**
* Default pulling consumer
- *
*/
public class DefaultMQPullConsumer extends ClientConfig implements MQPullConsumer {
protected final transient DefaultMQPullConsumerImpl defaultMQPullConsumerImpl;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
index 343a0a2..ee145e7 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
@@ -26,7 +26,6 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
/**
* Message queue consumer interface
- *
*/
public interface MQConsumer extends MQAdmin {
/**
@@ -34,7 +33,6 @@ public interface MQConsumer extends MQAdmin {
*
* @param msg
* @param delayLevel
- *
* @throws InterruptedException
* @throws MQBrokerException
* @throws RemotingException
@@ -50,7 +48,6 @@ public interface MQConsumer extends MQAdmin {
* @param msg
* @param delayLevel
* @param brokerName
- *
* @throws RemotingException
* @throws MQBrokerException
* @throws InterruptedException
@@ -62,11 +59,8 @@ public interface MQConsumer extends MQAdmin {
/**
* Fetch message queues from consumer cache according to the topic
*
- * @param topic
- * message topic
- *
+ * @param topic message topic
* @return queue set
- *
* @throws MQClientException
*/
Set<MessageQueue> fetchSubscribeMessageQueues(final String topic) throws MQClientException;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
index d199f8a..1bca536 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
@@ -25,7 +25,6 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
/**
* Pulling consumer interface
- *
*/
public interface MQPullConsumer extends MQConsumer {
/**
@@ -51,18 +50,12 @@ public interface MQPullConsumer extends MQConsumer {
/**
* Pulling the messages,not blocking
*
- * @param mq
- * from which message queue
- * @param subExpression
- * subscription expression.it only support or operation such as "tag1 || tag2 || tag3" <br>
- * if null or * expression,meaning subscribe all
- * @param offset
- * from where to pull
- * @param maxNums
- * max pulling numbers
- *
+ * @param mq from which message queue
+ * @param subExpression subscription expression.it only support or operation such as "tag1 || tag2 || tag3" <br> if null or * expression,meaning subscribe
+ * all
+ * @param offset from where to pull
+ * @param maxNums max pulling numbers
* @return The resulting {@code PullRequest}
- *
* @throws MQClientException
* @throws InterruptedException
* @throws MQBrokerException
@@ -80,9 +73,7 @@ public interface MQPullConsumer extends MQConsumer {
* @param offset
* @param maxNums
* @param timeout
- *
* @return The resulting {@code PullRequest}
- *
* @throws MQClientException
* @throws RemotingException
* @throws MQBrokerException
@@ -100,7 +91,6 @@ public interface MQPullConsumer extends MQConsumer {
* @param offset
* @param maxNums
* @param pullCallback
- *
* @throws MQClientException
* @throws RemotingException
* @throws InterruptedException
@@ -118,7 +108,6 @@ public interface MQPullConsumer extends MQConsumer {
* @param maxNums
* @param pullCallback
* @param timeout
- *
* @throws MQClientException
* @throws RemotingException
* @throws InterruptedException
@@ -134,9 +123,7 @@ public interface MQPullConsumer extends MQConsumer {
* @param subExpression
* @param offset
* @param maxNums
- *
* @return The resulting {@code PullRequest}
- *
* @throws MQClientException
* @throws RemotingException
* @throws MQBrokerException
@@ -154,7 +141,6 @@ public interface MQPullConsumer extends MQConsumer {
* @param offset
* @param maxNums
* @param pullCallback
- *
* @throws MQClientException
* @throws RemotingException
* @throws InterruptedException
@@ -168,7 +154,6 @@ public interface MQPullConsumer extends MQConsumer {
*
* @param mq
* @param offset
- *
* @throws MQClientException
*/
void updateConsumeOffset(final MessageQueue mq, final long offset) throws MQClientException;
@@ -178,9 +163,7 @@ public interface MQPullConsumer extends MQConsumer {
*
* @param mq
* @param fromStore
- *
* @return The fetched offset of given queue
- *
* @throws MQClientException
*/
long fetchConsumeOffset(final MessageQueue mq, final boolean fromStore) throws MQClientException;
@@ -188,11 +171,8 @@ public interface MQPullConsumer extends MQConsumer {
/**
* Fetch the message queues according to the topic
*
- * @param topic
- * message topic
- *
+ * @param topic message topic
* @return message queue set
- *
* @throws MQClientException
*/
Set<MessageQueue> fetchMessageQueuesInBalance(final String topic) throws MQClientException;
@@ -205,7 +185,6 @@ public interface MQPullConsumer extends MQConsumer {
* @param delayLevel
* @param brokerName
* @param consumerGroup
- *
* @throws RemotingException
* @throws MQBrokerException
* @throws InterruptedException
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
index 1b969bd..cef8507 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
@@ -23,7 +23,6 @@ import org.apache.rocketmq.client.exception.MQClientException;
/**
* Push consumer
- *
*/
public interface MQPushConsumer extends MQConsumer {
/**
@@ -54,11 +53,8 @@ public interface MQPushConsumer extends MQConsumer {
* Subscribe some topic
*
* @param topic
- * @param subExpression
- * subscription expression.it only support or operation such as
- * "tag1 || tag2 || tag3" <br>
- * if null or * expression,meaning subscribe all
- *
+ * @param subExpression subscription expression.it only support or operation such as "tag1 || tag2 || tag3" <br> if null or * expression,meaning subscribe
+ * all
* @throws MQClientException
*/
void subscribe(final String topic, final String subExpression) throws MQClientException;
@@ -67,13 +63,8 @@ public interface MQPushConsumer extends MQConsumer {
* Subscribe some topic
*
* @param topic
- * @param fullClassName
- * full class name,must extend
- * org.apache.rocketmq.common.filter. MessageFilter
- * @param filterClassSource
- * class source code,used UTF-8 file encoding,must be responsible
- * for your code safety
- *
+ * @param fullClassName full class name,must extend org.apache.rocketmq.common.filter. MessageFilter
+ * @param filterClassSource class source code,used UTF-8 file encoding,must be responsible for your code safety
* @throws MQClientException
*/
void subscribe(final String topic, final String fullClassName, final String filterClassSource) throws MQClientException;
@@ -81,8 +72,7 @@ public interface MQPushConsumer extends MQConsumer {
/**
* Unsubscribe consumption some topic
*
- * @param topic
- * message topic
+ * @param topic message topic
*/
void unsubscribe(final String topic);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
index 0cc2dc4..66e8757 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
@@ -21,16 +21,12 @@ import org.apache.rocketmq.common.message.MessageQueue;
/**
* A MessageQueueListener is implemented by the application and may be specified when a message queue changed
- *
*/
public interface MessageQueueListener {
/**
- * @param topic
- * message topic
- * @param mqAll
- * all queues in this message topic
- * @param mqDivided
- * collection of queues,assigned to the current consumer
+ * @param topic message topic
+ * @param mqAll all queues in this message topic
+ * @param mqDivided collection of queues,assigned to the current consumer
*/
void messageQueueChanged(final String topic, final Set<MessageQueue> mqAll,
final Set<MessageQueue> mqDivided);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
index 06e47d9..cfbc83e 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
@@ -18,7 +18,6 @@ package org.apache.rocketmq.client.consumer;
/**
* Async message pulling interface
- *
*/
public interface PullCallback {
void onSuccess(final PullResult pullResult);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
index 405781b..7280ff4 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
@@ -20,7 +20,6 @@ import org.apache.rocketmq.common.message.MessageQueue;
/**
* Consumer Orderly consumption context
- *
*/
public class ConsumeOrderlyContext {
private final MessageQueue messageQueue;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
index 2a9e5c9..338c156 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
@@ -18,7 +18,6 @@ package org.apache.rocketmq.client.consumer.listener;
/**
* A MessageListener object is used to receive asynchronously delivered messages.
- *
*/
public interface MessageListener {
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
index c083157..fcf0e74 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
@@ -21,17 +21,13 @@ import org.apache.rocketmq.common.message.MessageExt;
/**
* A MessageListenerConcurrently object is used to receive asynchronously delivered messages concurrently
- *
*/
public interface MessageListenerConcurrently extends MessageListener {
/**
* It is not recommend to throw exception,rather than returning ConsumeConcurrentlyStatus.RECONSUME_LATER if consumption failure
*
- * @param msgs
- * msgs.size() >= 1<br>
- * DefaultMQPushConsumer.consumeMessageBatchMaxSize=1,you can modify here
+ * @param msgs msgs.size() >= 1<br> DefaultMQPushConsumer.consumeMessageBatchMaxSize=1,you can modify here
* @param context
- *
* @return The consume status
*/
ConsumeConcurrentlyStatus consumeMessage(final List<MessageExt> msgs,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
index 57a553a..5db8462 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
@@ -21,17 +21,13 @@ import org.apache.rocketmq.common.message.MessageExt;
/**
* A MessageListenerConcurrently object is used to receive asynchronously delivered messages orderly.one queue,one thread
- *
*/
public interface MessageListenerOrderly extends MessageListener {
/**
* It is not recommend to throw exception,rather than returning ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT if consumption failure
*
- * @param msgs
- * msgs.size() >= 1<br>
- * DefaultMQPushConsumer.consumeMessageBatchMaxSize=1,you can modify here
+ * @param msgs msgs.size() >= 1<br> DefaultMQPushConsumer.consumeMessageBatchMaxSize=1,you can modify here
* @param context
- *
* @return The consume status
*/
ConsumeOrderlyStatus consumeMessage(final List<MessageExt> msgs,
[85/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
index 4241c0e..c22c515 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
@@ -16,6 +16,17 @@
*/
package org.apache.rocketmq.client.impl.consumer;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.rocketmq.client.QueryResult;
import org.apache.rocketmq.client.Validators;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
@@ -44,7 +55,11 @@ import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import org.apache.rocketmq.common.filter.FilterAPI;
import org.apache.rocketmq.common.help.FAQUrl;
-import org.apache.rocketmq.common.message.*;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageAccessor;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.body.ConsumeStatus;
import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
import org.apache.rocketmq.common.protocol.body.ProcessQueueInfo;
@@ -60,11 +75,6 @@ import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.apache.rocketmq.remoting.exception.RemotingException;
import org.slf4j.Logger;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-
-
public class DefaultMQPushConsumerImpl implements MQConsumerInner {
/**
* Delay some time when exception occur
@@ -98,7 +108,6 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
private long flowControlTimes1 = 0;
private long flowControlTimes2 = 0;
-
public DefaultMQPushConsumerImpl(DefaultMQPushConsumer defaultMQPushConsumer, RPCHook rpcHook) {
this.defaultMQPushConsumer = defaultMQPushConsumer;
this.rpcHook = rpcHook;
@@ -214,8 +223,8 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
this.executePullRequestLater(pullRequest, PULL_TIME_DELAY_MILLS_WHEN_FLOW_CONTROL);
if ((flowControlTimes1++ % 1000) == 0) {
log.warn(
- "the consumer message buffer is full, so do flow control, minOffset={}, maxOffset={}, size={}, pullRequest={}, flowControlTimes={}",
- processQueue.getMsgTreeMap().firstKey(), processQueue.getMsgTreeMap().lastKey(), size, pullRequest, flowControlTimes1);
+ "the consumer message buffer is full, so do flow control, minOffset={}, maxOffset={}, size={}, pullRequest={}, flowControlTimes={}",
+ processQueue.getMsgTreeMap().firstKey(), processQueue.getMsgTreeMap().lastKey(), size, pullRequest, flowControlTimes1);
}
return;
}
@@ -225,9 +234,9 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
this.executePullRequestLater(pullRequest, PULL_TIME_DELAY_MILLS_WHEN_FLOW_CONTROL);
if ((flowControlTimes2++ % 1000) == 0) {
log.warn(
- "the queue's messages, span too long, so do flow control, minOffset={}, maxOffset={}, maxSpan={}, pullRequest={}, flowControlTimes={}",
- processQueue.getMsgTreeMap().firstKey(), processQueue.getMsgTreeMap().lastKey(), processQueue.getMaxSpan(),
- pullRequest, flowControlTimes2);
+ "the queue's messages, span too long, so do flow control, minOffset={}, maxOffset={}, maxSpan={}, pullRequest={}, flowControlTimes={}",
+ processQueue.getMsgTreeMap().firstKey(), processQueue.getMsgTreeMap().lastKey(), processQueue.getMaxSpan(),
+ pullRequest, flowControlTimes2);
}
return;
}
@@ -237,10 +246,10 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
final long offset = this.rebalanceImpl.computePullFromWhere(pullRequest.getMessageQueue());
boolean brokerBusy = offset < pullRequest.getNextOffset();
log.info("the first time to pull message, so fix offset from broker. pullRequest: {} NewOffset: {} brokerBusy: {}",
- pullRequest, offset, brokerBusy);
+ pullRequest, offset, brokerBusy);
if (brokerBusy) {
log.info("[NOTIFYME]the first time to pull message, but pull request offset larger than broker consume offset. pullRequest: {} NewOffset: {}",
- pullRequest, offset);
+ pullRequest, offset);
}
pullRequest.setLockedFirst(true);
@@ -267,7 +276,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
public void onSuccess(PullResult pullResult) {
if (pullResult != null) {
pullResult = DefaultMQPushConsumerImpl.this.pullAPIWrapper.processPullResult(pullRequest.getMessageQueue(), pullResult,
- subscriptionData);
+ subscriptionData);
switch (pullResult.getPullStatus()) {
case FOUND:
@@ -275,7 +284,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
pullRequest.setNextOffset(pullResult.getNextBeginOffset());
long pullRT = System.currentTimeMillis() - beginTimestamp;
DefaultMQPushConsumerImpl.this.getConsumerStatsManager().incPullRT(pullRequest.getConsumerGroup(),
- pullRequest.getMessageQueue().getTopic(), pullRT);
+ pullRequest.getMessageQueue().getTopic(), pullRT);
long firstMsgOffset = Long.MAX_VALUE;
if (pullResult.getMsgFoundList() == null || pullResult.getMsgFoundList().isEmpty()) {
@@ -284,30 +293,30 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
firstMsgOffset = pullResult.getMsgFoundList().get(0).getQueueOffset();
DefaultMQPushConsumerImpl.this.getConsumerStatsManager().incPullTPS(pullRequest.getConsumerGroup(),
- pullRequest.getMessageQueue().getTopic(), pullResult.getMsgFoundList().size());
+ pullRequest.getMessageQueue().getTopic(), pullResult.getMsgFoundList().size());
boolean dispathToConsume = processQueue.putMessage(pullResult.getMsgFoundList());
DefaultMQPushConsumerImpl.this.consumeMessageService.submitConsumeRequest(//
- pullResult.getMsgFoundList(), //
- processQueue, //
- pullRequest.getMessageQueue(), //
- dispathToConsume);
+ pullResult.getMsgFoundList(), //
+ processQueue, //
+ pullRequest.getMessageQueue(), //
+ dispathToConsume);
if (DefaultMQPushConsumerImpl.this.defaultMQPushConsumer.getPullInterval() > 0) {
DefaultMQPushConsumerImpl.this.executePullRequestLater(pullRequest,
- DefaultMQPushConsumerImpl.this.defaultMQPushConsumer.getPullInterval());
+ DefaultMQPushConsumerImpl.this.defaultMQPushConsumer.getPullInterval());
} else {
DefaultMQPushConsumerImpl.this.executePullRequestImmediately(pullRequest);
}
}
if (pullResult.getNextBeginOffset() < prevRequestOffset//
- || firstMsgOffset < prevRequestOffset) {
+ || firstMsgOffset < prevRequestOffset) {
log.warn(
- "[BUG] pull message result maybe data wrong, nextBeginOffset: {} firstMsgOffset: {} prevRequestOffset: {}", //
- pullResult.getNextBeginOffset(), //
- firstMsgOffset, //
- prevRequestOffset);
+ "[BUG] pull message result maybe data wrong, nextBeginOffset: {} firstMsgOffset: {} prevRequestOffset: {}", //
+ pullResult.getNextBeginOffset(), //
+ firstMsgOffset, //
+ prevRequestOffset);
}
break;
@@ -327,7 +336,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
break;
case OFFSET_ILLEGAL:
log.warn("the pull request offset illegal, {} {}", //
- pullRequest.toString(), pullResult.toString());
+ pullRequest.toString(), pullResult.toString());
pullRequest.setNextOffset(pullResult.getNextBeginOffset());
pullRequest.getProcessQueue().setDropped(true);
@@ -337,7 +346,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
public void run() {
try {
DefaultMQPushConsumerImpl.this.offsetStore.updateOffset(pullRequest.getMessageQueue(),
- pullRequest.getNextOffset(), false);
+ pullRequest.getNextOffset(), false);
DefaultMQPushConsumerImpl.this.offsetStore.persist(pullRequest.getMessageQueue());
@@ -356,7 +365,6 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
}
}
-
@Override
public void onException(Throwable e) {
if (!pullRequest.getMessageQueue().getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
@@ -388,24 +396,24 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
}
int sysFlag = PullSysFlag.buildSysFlag(//
- commitOffsetEnable, // commitOffset
- true, // suspend
- subExpression != null, // subscription
- classFilter // class filter
+ commitOffsetEnable, // commitOffset
+ true, // suspend
+ subExpression != null, // subscription
+ classFilter // class filter
);
try {
this.pullAPIWrapper.pullKernelImpl(//
- pullRequest.getMessageQueue(), // 1
- subExpression, // 2
- subscriptionData.getSubVersion(), // 3
- pullRequest.getNextOffset(), // 4
- this.defaultMQPushConsumer.getPullBatchSize(), // 5
- sysFlag, // 6
- commitOffsetValue, // 7
- BROKER_SUSPEND_MAX_TIME_MILLIS, // 8
- CONSUMER_TIMEOUT_MILLIS_WHEN_SUSPEND, // 9
- CommunicationMode.ASYNC, // 10
- pullCallback// 11
+ pullRequest.getMessageQueue(), // 1
+ subExpression, // 2
+ subscriptionData.getSubVersion(), // 3
+ pullRequest.getNextOffset(), // 4
+ this.defaultMQPushConsumer.getPullBatchSize(), // 5
+ sysFlag, // 6
+ commitOffsetValue, // 7
+ BROKER_SUSPEND_MAX_TIME_MILLIS, // 8
+ CONSUMER_TIMEOUT_MILLIS_WHEN_SUSPEND, // 9
+ CommunicationMode.ASYNC, // 10
+ pullCallback// 11
);
} catch (Exception e) {
log.error("pullKernelImpl exception", e);
@@ -416,9 +424,9 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
private void makeSureStateOK() throws MQClientException {
if (this.serviceState != ServiceState.RUNNING) {
throw new MQClientException("The consumer service state not OK, "//
- + this.serviceState//
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
- null);
+ + this.serviceState//
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
+ null);
}
}
@@ -453,16 +461,15 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
}
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
- throws MQClientException, InterruptedException {
+ throws MQClientException, InterruptedException {
return this.mQClientFactory.getMQAdminImpl().queryMessage(topic, key, maxNum, begin, end);
}
public MessageExt queryMessageByUniqKey(String topic, String uniqKey) throws MQClientException,
- InterruptedException {
+ InterruptedException {
return this.mQClientFactory.getMQAdminImpl().queryMessageByUniqKey(topic, uniqKey);
}
-
public void registerMessageListener(MessageListener messageListener) {
this.messageListenerInner = messageListener;
}
@@ -474,12 +481,12 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
}
public void sendMessageBack(MessageExt msg, int delayLevel, final String brokerName)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
try {
String brokerAddr = (null != brokerName) ? this.mQClientFactory.findBrokerAddressInPublish(brokerName)
- : RemotingHelper.parseSocketAddressAddr(msg.getStoreHost());
+ : RemotingHelper.parseSocketAddressAddr(msg.getStoreHost());
this.mQClientFactory.getMQClientAPIImpl().consumerSendMessageBack(brokerAddr, msg,
- this.defaultMQPushConsumer.getConsumerGroup(), delayLevel, 5000, getMaxReconsumeTimes());
+ this.defaultMQPushConsumer.getConsumerGroup(), delayLevel, 5000, getMaxReconsumeTimes());
} catch (Exception e) {
log.error("sendMessageBack Exception, " + this.defaultMQPushConsumer.getConsumerGroup(), e);
@@ -532,7 +539,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
switch (this.serviceState) {
case CREATE_JUST:
log.info("the consumer [{}] start beginning. messageModel={}, isUnitMode={}", this.defaultMQPushConsumer.getConsumerGroup(),
- this.defaultMQPushConsumer.getMessageModel(), this.defaultMQPushConsumer.isUnitMode());
+ this.defaultMQPushConsumer.getMessageModel(), this.defaultMQPushConsumer.isUnitMode());
this.serviceState = ServiceState.START_FAILED;
this.checkConfig();
@@ -551,8 +558,8 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
this.rebalanceImpl.setmQClientFactory(this.mQClientFactory);
this.pullAPIWrapper = new PullAPIWrapper(
- mQClientFactory,
- this.defaultMQPushConsumer.getConsumerGroup(), isUnitMode());
+ mQClientFactory,
+ this.defaultMQPushConsumer.getConsumerGroup(), isUnitMode());
this.pullAPIWrapper.registerFilterMessageHook(filterMessageHookList);
if (this.defaultMQPushConsumer.getOffsetStore() != null) {
@@ -574,11 +581,11 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
if (this.getMessageListenerInner() instanceof MessageListenerOrderly) {
this.consumeOrderly = true;
this.consumeMessageService =
- new ConsumeMessageOrderlyService(this, (MessageListenerOrderly) this.getMessageListenerInner());
+ new ConsumeMessageOrderlyService(this, (MessageListenerOrderly)this.getMessageListenerInner());
} else if (this.getMessageListenerInner() instanceof MessageListenerConcurrently) {
this.consumeOrderly = false;
this.consumeMessageService =
- new ConsumeMessageConcurrentlyService(this, (MessageListenerConcurrently) this.getMessageListenerInner());
+ new ConsumeMessageConcurrentlyService(this, (MessageListenerConcurrently)this.getMessageListenerInner());
}
this.consumeMessageService.start();
@@ -588,8 +595,8 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
this.serviceState = ServiceState.CREATE_JUST;
this.consumeMessageService.shutdown();
throw new MQClientException("The consumer group[" + this.defaultMQPushConsumer.getConsumerGroup()
- + "] has been created before, specify another name please." + FAQUrl.suggestTodo(FAQUrl.GROUP_NAME_DUPLICATE_URL),
- null);
+ + "] has been created before, specify another name please." + FAQUrl.suggestTodo(FAQUrl.GROUP_NAME_DUPLICATE_URL),
+ null);
}
mQClientFactory.start();
@@ -600,9 +607,9 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
case START_FAILED:
case SHUTDOWN_ALREADY:
throw new MQClientException("The PushConsumer service state not OK, maybe started once, "//
- + this.serviceState//
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
- null);
+ + this.serviceState//
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
+ null);
default:
break;
}
@@ -619,133 +626,133 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
if (null == this.defaultMQPushConsumer.getConsumerGroup()) {
throw new MQClientException(
- "consumerGroup is null"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
+ "consumerGroup is null"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
}
if (this.defaultMQPushConsumer.getConsumerGroup().equals(MixAll.DEFAULT_CONSUMER_GROUP)) {
throw new MQClientException(
- "consumerGroup can not equal "
- + MixAll.DEFAULT_CONSUMER_GROUP
- + ", please specify another one."
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
+ "consumerGroup can not equal "
+ + MixAll.DEFAULT_CONSUMER_GROUP
+ + ", please specify another one."
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
}
if (null == this.defaultMQPushConsumer.getMessageModel()) {
throw new MQClientException(
- "messageModel is null"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
+ "messageModel is null"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
}
if (null == this.defaultMQPushConsumer.getConsumeFromWhere()) {
throw new MQClientException(
- "consumeFromWhere is null"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
+ "consumeFromWhere is null"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
}
Date dt = UtilAll.parseDate(this.defaultMQPushConsumer.getConsumeTimestamp(), UtilAll.YYYY_MMDD_HHMMSS);
if (null == dt) {
throw new MQClientException(
- "consumeTimestamp is invalid, YYYY_MMDD_HHMMSS"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
+ "consumeTimestamp is invalid, YYYY_MMDD_HHMMSS"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
}
// allocateMessageQueueStrategy
if (null == this.defaultMQPushConsumer.getAllocateMessageQueueStrategy()) {
throw new MQClientException(
- "allocateMessageQueueStrategy is null"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
+ "allocateMessageQueueStrategy is null"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
}
// subscription
if (null == this.defaultMQPushConsumer.getSubscription()) {
throw new MQClientException(
- "subscription is null"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
+ "subscription is null"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
}
// messageListener
if (null == this.defaultMQPushConsumer.getMessageListener()) {
throw new MQClientException(
- "messageListener is null"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
+ "messageListener is null"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
}
boolean orderly = this.defaultMQPushConsumer.getMessageListener() instanceof MessageListenerOrderly;
boolean concurrently = this.defaultMQPushConsumer.getMessageListener() instanceof MessageListenerConcurrently;
if (!orderly && !concurrently) {
throw new MQClientException(
- "messageListener must be instanceof MessageListenerOrderly or MessageListenerConcurrently"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
+ "messageListener must be instanceof MessageListenerOrderly or MessageListenerConcurrently"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
}
// consumeThreadMin
if (this.defaultMQPushConsumer.getConsumeThreadMin() < 1
- || this.defaultMQPushConsumer.getConsumeThreadMin() > 1000
- || this.defaultMQPushConsumer.getConsumeThreadMin() > this.defaultMQPushConsumer.getConsumeThreadMax()) {
+ || this.defaultMQPushConsumer.getConsumeThreadMin() > 1000
+ || this.defaultMQPushConsumer.getConsumeThreadMin() > this.defaultMQPushConsumer.getConsumeThreadMax()) {
throw new MQClientException(
- "consumeThreadMin Out of range [1, 1000]"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
+ "consumeThreadMin Out of range [1, 1000]"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
}
// consumeThreadMax
if (this.defaultMQPushConsumer.getConsumeThreadMax() < 1 || this.defaultMQPushConsumer.getConsumeThreadMax() > 1000) {
throw new MQClientException(
- "consumeThreadMax Out of range [1, 1000]"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
+ "consumeThreadMax Out of range [1, 1000]"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
}
// consumeConcurrentlyMaxSpan
if (this.defaultMQPushConsumer.getConsumeConcurrentlyMaxSpan() < 1
- || this.defaultMQPushConsumer.getConsumeConcurrentlyMaxSpan() > 65535) {
+ || this.defaultMQPushConsumer.getConsumeConcurrentlyMaxSpan() > 65535) {
throw new MQClientException(
- "consumeConcurrentlyMaxSpan Out of range [1, 65535]"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
+ "consumeConcurrentlyMaxSpan Out of range [1, 65535]"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
}
// pullThresholdForQueue
if (this.defaultMQPushConsumer.getPullThresholdForQueue() < 1 || this.defaultMQPushConsumer.getPullThresholdForQueue() > 65535) {
throw new MQClientException(
- "pullThresholdForQueue Out of range [1, 65535]"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
+ "pullThresholdForQueue Out of range [1, 65535]"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
}
// pullInterval
if (this.defaultMQPushConsumer.getPullInterval() < 0 || this.defaultMQPushConsumer.getPullInterval() > 65535) {
throw new MQClientException(
- "pullInterval Out of range [0, 65535]"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
+ "pullInterval Out of range [0, 65535]"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
}
// consumeMessageBatchMaxSize
if (this.defaultMQPushConsumer.getConsumeMessageBatchMaxSize() < 1
- || this.defaultMQPushConsumer.getConsumeMessageBatchMaxSize() > 1024) {
+ || this.defaultMQPushConsumer.getConsumeMessageBatchMaxSize() > 1024) {
throw new MQClientException(
- "consumeMessageBatchMaxSize Out of range [1, 1024]"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
+ "consumeMessageBatchMaxSize Out of range [1, 1024]"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
}
// pullBatchSize
if (this.defaultMQPushConsumer.getPullBatchSize() < 1 || this.defaultMQPushConsumer.getPullBatchSize() > 1024) {
throw new MQClientException(
- "pullBatchSize Out of range [1, 1024]"
- + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
- null);
+ "pullBatchSize Out of range [1, 1024]"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
}
}
@@ -757,7 +764,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
final String topic = entry.getKey();
final String subString = entry.getValue();
SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPushConsumer.getConsumerGroup(), //
- topic, subString);
+ topic, subString);
this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData);
}
}
@@ -772,7 +779,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
case CLUSTERING:
final String retryTopic = MixAll.getRetryTopic(this.defaultMQPushConsumer.getConsumerGroup());
SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPushConsumer.getConsumerGroup(), //
- retryTopic, SubscriptionData.SUB_ALL);
+ retryTopic, SubscriptionData.SUB_ALL);
this.rebalanceImpl.getSubscriptionInner().put(retryTopic, subscriptionData);
break;
default:
@@ -804,7 +811,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
public void subscribe(String topic, String subExpression) throws MQClientException {
try {
SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPushConsumer.getConsumerGroup(), //
- topic, subExpression);
+ topic, subExpression);
this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData);
if (this.mQClientFactory != null) {
this.mQClientFactory.sendHeartbeatToAllBrokerWithLock();
@@ -817,7 +824,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
public void subscribe(String topic, String fullClassName, String filterClassSource) throws MQClientException {
try {
SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPushConsumer.getConsumerGroup(), //
- topic, "*");
+ topic, "*");
subscriptionData.setSubString(fullClassName);
subscriptionData.setClassFilterMode(true);
subscriptionData.setFilterClassSource(filterClassSource);
@@ -865,7 +872,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
}
public void resetOffsetByTimeStamp(long timeStamp)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
for (String topic : rebalanceImpl.getSubscriptionInner().keySet()) {
Set<MessageQueue> mqs = rebalanceImpl.getTopicSubscribeInfoTable().get(topic);
Map<MessageQueue, Long> offsetTable = new HashMap<MessageQueue, Long>();
@@ -1017,9 +1024,9 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
long computeAccTotal = this.computeAccumulationTotal();
long adjustThreadPoolNumsThreshold = this.defaultMQPushConsumer.getAdjustThreadPoolNumsThreshold();
- long incThreshold = (long) (adjustThreadPoolNumsThreshold * 1.0);
+ long incThreshold = (long)(adjustThreadPoolNumsThreshold * 1.0);
- long decThreshold = (long) (adjustThreadPoolNumsThreshold * 0.8);
+ long decThreshold = (long)(adjustThreadPoolNumsThreshold * 0.8);
if (computeAccTotal >= incThreshold) {
this.consumeMessageService.incCorePoolSize();
@@ -1044,7 +1051,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
}
public List<QueueTimeSpan> queryConsumeTimeSpan(final String topic)
- throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
+ throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
List<QueueTimeSpan> queueTimeSpan = new ArrayList<QueueTimeSpan>();
TopicRouteData routeData = this.mQClientFactory.getMQClientAPIImpl().getTopicRouteInfoFromNameServer(topic, 3000);
for (BrokerData brokerData : routeData.getBrokerDatas()) {
@@ -1055,12 +1062,10 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
return queueTimeSpan;
}
-
public ConsumeMessageService getConsumeMessageService() {
return consumeMessageService;
}
-
public void setConsumeMessageService(ConsumeMessageService consumeMessageService) {
this.consumeMessageService = consumeMessageService;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
index b1a2a25..ce4f2b9 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
@@ -6,16 +6,17 @@
* (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
+ * 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.
+ * 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.impl.consumer;
+import java.util.Set;
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
@@ -23,9 +24,6 @@ import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
-import java.util.Set;
-
-
/**
* Consumer inner interface
*
@@ -33,33 +31,23 @@ import java.util.Set;
public interface MQConsumerInner {
String groupName();
-
MessageModel messageModel();
-
ConsumeType consumeType();
-
ConsumeFromWhere consumeFromWhere();
-
Set<SubscriptionData> subscriptions();
-
void doRebalance();
-
void persistConsumerOffset();
-
void updateTopicSubscribeInfo(final String topic, final Set<MessageQueue> info);
-
boolean isSubscribeTopicNeedUpdate(final String topic);
-
boolean isUnitMode();
-
ConsumerRunningInfo consumerRunningInfo();
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
index 1e573c3..47ae2b0 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
@@ -6,20 +6,18 @@
* (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
+ * 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.
+ * 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.impl.consumer;
-import org.apache.rocketmq.common.message.MessageQueue;
-
import java.util.concurrent.ConcurrentHashMap;
-
+import org.apache.rocketmq.common.message.MessageQueue;
/**
* Message lock,strictly ensure the single queue only one thread at a time consuming
@@ -27,8 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class MessageQueueLock {
private ConcurrentHashMap<MessageQueue, Object> mqLockTable =
- new ConcurrentHashMap<MessageQueue, Object>();
-
+ new ConcurrentHashMap<MessageQueue, Object>();
public Object fetchLockObject(final MessageQueue mq) {
Object objLock = this.mqLockTable.get(mq);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
index f361f1f..2d17703 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
@@ -6,24 +6,16 @@
* (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
+ * 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.
+ * 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.impl.consumer;
-import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
-import org.apache.rocketmq.client.log.ClientLogger;
-import org.apache.rocketmq.common.message.MessageAccessor;
-import org.apache.rocketmq.common.message.MessageConst;
-import org.apache.rocketmq.common.message.MessageExt;
-import org.apache.rocketmq.common.protocol.body.ProcessQueueInfo;
-import org.slf4j.Logger;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -33,7 +25,13 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-
+import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.message.MessageAccessor;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.protocol.body.ProcessQueueInfo;
+import org.slf4j.Logger;
/**
* Queue consumption snapshot
@@ -41,7 +39,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
*/
public class ProcessQueue {
public final static long REBALANCE_LOCK_MAX_LIVE_TIME =
- Long.parseLong(System.getProperty("rocketmq.client.rebalance.lockMaxLiveTime", "30000"));
+ Long.parseLong(System.getProperty("rocketmq.client.rebalance.lockMaxLiveTime", "30000"));
public final static long REBALANCE_LOCK_INTERVAL = Long.parseLong(System.getProperty("rocketmq.client.rebalance.lockInterval", "20000"));
private final static long PULL_MAX_IDLE_TIME = Long.parseLong(System.getProperty("rocketmq.client.pull.pullMaxIdleTime", "120000"));
private final Logger log = ClientLogger.getLog();
@@ -65,7 +63,6 @@ public class ProcessQueue {
return result;
}
-
public boolean isPullExpired() {
boolean result = (System.currentTimeMillis() - this.lastPullTimestamp) > PULL_MAX_IDLE_TIME;
return result;
@@ -80,7 +77,7 @@ public class ProcessQueue {
if (pushConsumer.getDefaultMQPushConsumerImpl().isConsumeOrderly()) {
return;
}
-
+
int loop = msgTreeMap.size() < 16 ? msgTreeMap.size() : 16;
for (int i = 0; i < loop; i++) {
MessageExt msg = null;
@@ -126,7 +123,6 @@ public class ProcessQueue {
}
}
-
public boolean putMessage(final List<MessageExt> msgs) {
boolean dispatchToConsume = false;
try {
@@ -167,7 +163,6 @@ public class ProcessQueue {
return dispatchToConsume;
}
-
public long getMaxSpan() {
try {
this.lockTreeMap.readLock().lockInterruptibly();
@@ -185,7 +180,6 @@ public class ProcessQueue {
return 0;
}
-
public long removeMessage(final List<MessageExt> msgs) {
long result = -1;
final long now = System.currentTimeMillis();
@@ -218,22 +212,18 @@ public class ProcessQueue {
return result;
}
-
public TreeMap<Long, MessageExt> getMsgTreeMap() {
return msgTreeMap;
}
-
public AtomicLong getMsgCount() {
return msgCount;
}
-
public boolean isDropped() {
return dropped;
}
-
public void setDropped(boolean dropped) {
this.dropped = dropped;
}
@@ -260,7 +250,6 @@ public class ProcessQueue {
}
}
-
public long commit() {
try {
this.lockTreeMap.writeLock().lockInterruptibly();
@@ -281,7 +270,6 @@ public class ProcessQueue {
return -1;
}
-
public void makeMessageToCosumeAgain(List<MessageExt> msgs) {
try {
this.lockTreeMap.writeLock().lockInterruptibly();
@@ -298,7 +286,6 @@ public class ProcessQueue {
}
}
-
public List<MessageExt> takeMessags(final int batchSize) {
List<MessageExt> result = new ArrayList<MessageExt>(batchSize);
final long now = System.currentTimeMillis();
@@ -331,7 +318,6 @@ public class ProcessQueue {
return result;
}
-
public boolean hasTempMessage() {
try {
this.lockTreeMap.readLock().lockInterruptibly();
@@ -346,7 +332,6 @@ public class ProcessQueue {
return true;
}
-
public void clear() {
try {
this.lockTreeMap.writeLock().lockInterruptibly();
@@ -363,52 +348,42 @@ public class ProcessQueue {
}
}
-
public long getLastLockTimestamp() {
return lastLockTimestamp;
}
-
public void setLastLockTimestamp(long lastLockTimestamp) {
this.lastLockTimestamp = lastLockTimestamp;
}
-
public Lock getLockConsume() {
return lockConsume;
}
-
public long getLastPullTimestamp() {
return lastPullTimestamp;
}
-
public void setLastPullTimestamp(long lastPullTimestamp) {
this.lastPullTimestamp = lastPullTimestamp;
}
-
public long getMsgAccCnt() {
return msgAccCnt;
}
-
public void setMsgAccCnt(long msgAccCnt) {
this.msgAccCnt = msgAccCnt;
}
-
public long getTryUnlockTimes() {
return this.tryUnlockTimes.get();
}
-
public void incTryUnlockTimes() {
this.tryUnlockTimes.incrementAndGet();
}
-
public void fillProcessQueueInfo(final ProcessQueueInfo info) {
try {
this.lockTreeMap.readLock().lockInterruptibly();
@@ -438,12 +413,10 @@ public class ProcessQueue {
}
}
-
public long getLastConsumeTimestamp() {
return lastConsumeTimestamp;
}
-
public void setLastConsumeTimestamp(long lastConsumeTimestamp) {
this.lastConsumeTimestamp = lastConsumeTimestamp;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
index 59c9b1c..d358175 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
@@ -16,6 +16,12 @@
*/
package org.apache.rocketmq.client.impl.consumer;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicLong;
import org.apache.rocketmq.client.consumer.PullCallback;
import org.apache.rocketmq.client.consumer.PullResult;
import org.apache.rocketmq.client.consumer.PullStatus;
@@ -28,7 +34,11 @@ import org.apache.rocketmq.client.impl.FindBrokerResult;
import org.apache.rocketmq.client.impl.factory.MQClientInstance;
import org.apache.rocketmq.client.log.ClientLogger;
import org.apache.rocketmq.common.MixAll;
-import org.apache.rocketmq.common.message.*;
+import org.apache.rocketmq.common.message.MessageAccessor;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageDecoder;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.header.PullMessageRequestHeader;
import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
import org.apache.rocketmq.common.protocol.route.TopicRouteData;
@@ -36,21 +46,13 @@ import org.apache.rocketmq.common.sysflag.PullSysFlag;
import org.apache.rocketmq.remoting.exception.RemotingException;
import org.slf4j.Logger;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
-
-
public class PullAPIWrapper {
private final Logger log = ClientLogger.getLog();
private final MQClientInstance mQClientFactory;
private final String consumerGroup;
private final boolean unitMode;
private ConcurrentHashMap<MessageQueue, AtomicLong/* brokerId */> pullFromWhichNodeTable =
- new ConcurrentHashMap<MessageQueue, AtomicLong>(32);
+ new ConcurrentHashMap<MessageQueue, AtomicLong>(32);
private volatile boolean connectBrokerByUser = false;
private volatile long defaultBrokerId = MixAll.MASTER_ID;
private Random random = new Random(System.currentTimeMillis());
@@ -63,8 +65,8 @@ public class PullAPIWrapper {
}
public PullResult processPullResult(final MessageQueue mq, final PullResult pullResult,
- final SubscriptionData subscriptionData) {
- PullResultExt pullResultExt = (PullResultExt) pullResult;
+ final SubscriptionData subscriptionData) {
+ PullResultExt pullResultExt = (PullResultExt)pullResult;
this.updatePullFromWhichNode(mq, pullResultExt.getSuggestWhichBrokerId());
if (PullStatus.FOUND == pullResult.getPullStatus()) {
@@ -92,9 +94,9 @@ public class PullAPIWrapper {
for (MessageExt msg : msgListFilterAgain) {
MessageAccessor.putProperty(msg, MessageConst.PROPERTY_MIN_OFFSET,
- Long.toString(pullResult.getMinOffset()));
+ Long.toString(pullResult.getMinOffset()));
MessageAccessor.putProperty(msg, MessageConst.PROPERTY_MAX_OFFSET,
- Long.toString(pullResult.getMaxOffset()));
+ Long.toString(pullResult.getMaxOffset()));
}
pullResultExt.setMsgFoundList(msgListFilterAgain);
@@ -131,26 +133,26 @@ public class PullAPIWrapper {
}
public PullResult pullKernelImpl(
- final MessageQueue mq,
- final String subExpression,
- final long subVersion,
- final long offset,
- final int maxNums,
- final int sysFlag,
- final long commitOffset,
- final long brokerSuspendMaxTimeMillis,
- final long timeoutMillis,
- final CommunicationMode communicationMode,
- final PullCallback pullCallback
+ final MessageQueue mq,
+ final String subExpression,
+ final long subVersion,
+ final long offset,
+ final int maxNums,
+ final int sysFlag,
+ final long commitOffset,
+ final long brokerSuspendMaxTimeMillis,
+ final long timeoutMillis,
+ final CommunicationMode communicationMode,
+ final PullCallback pullCallback
) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
FindBrokerResult findBrokerResult =
- this.mQClientFactory.findBrokerAddressInSubscribe(mq.getBrokerName(),
- this.recalculatePullFromWhichNode(mq), false);
+ this.mQClientFactory.findBrokerAddressInSubscribe(mq.getBrokerName(),
+ this.recalculatePullFromWhichNode(mq), false);
if (null == findBrokerResult) {
this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
findBrokerResult =
- this.mQClientFactory.findBrokerAddressInSubscribe(mq.getBrokerName(),
- this.recalculatePullFromWhichNode(mq), false);
+ this.mQClientFactory.findBrokerAddressInSubscribe(mq.getBrokerName(),
+ this.recalculatePullFromWhichNode(mq), false);
}
if (findBrokerResult != null) {
@@ -178,11 +180,11 @@ public class PullAPIWrapper {
}
PullResult pullResult = this.mQClientFactory.getMQClientAPIImpl().pullMessage(
- brokerAddr,
- requestHeader,
- timeoutMillis,
- communicationMode,
- pullCallback);
+ brokerAddr,
+ requestHeader,
+ timeoutMillis,
+ communicationMode,
+ pullCallback);
return pullResult;
}
@@ -204,7 +206,7 @@ public class PullAPIWrapper {
}
private String computPullFromWhichFilterServer(final String topic, final String brokerAddr)
- throws MQClientException {
+ throws MQClientException {
ConcurrentHashMap<String, TopicRouteData> topicRouteTable = this.mQClientFactory.getTopicRouteTable();
if (topicRouteTable != null) {
TopicRouteData topicRouteData = topicRouteTable.get(topic);
@@ -216,13 +218,18 @@ public class PullAPIWrapper {
}
throw new MQClientException("Find Filter Server Failed, Broker Addr: " + brokerAddr + " topic: "
- + topic, null);
+ + topic, null);
}
public boolean isConnectBrokerByUser() {
return connectBrokerByUser;
}
+ public void setConnectBrokerByUser(boolean connectBrokerByUser) {
+ this.connectBrokerByUser = connectBrokerByUser;
+
+ }
+
public int randomNum() {
int value = random.nextInt();
if (value < 0) {
@@ -233,11 +240,6 @@ public class PullAPIWrapper {
return value;
}
- public void setConnectBrokerByUser(boolean connectBrokerByUser) {
- this.connectBrokerByUser = connectBrokerByUser;
-
- }
-
public void registerFilterMessageHook(ArrayList<FilterMessageHook> filterMessageHookList) {
this.filterMessageHookList = filterMessageHookList;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
index 4634c24..55e3d59 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
@@ -6,35 +6,37 @@
* (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
+ * 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.
+ * 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.impl.consumer;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
import org.apache.rocketmq.client.impl.factory.MQClientInstance;
import org.apache.rocketmq.client.log.ClientLogger;
import org.apache.rocketmq.common.ServiceThread;
import org.slf4j.Logger;
-import java.util.concurrent.*;
-
-
public class PullMessageService extends ServiceThread {
private final Logger log = ClientLogger.getLog();
private final LinkedBlockingQueue<PullRequest> pullRequestQueue = new LinkedBlockingQueue<PullRequest>();
private final MQClientInstance mQClientFactory;
private final ScheduledExecutorService scheduledExecutorService = Executors
- .newSingleThreadScheduledExecutor(new ThreadFactory() {
- @Override
- public Thread newThread(Runnable r) {
- return new Thread(r, "PullMessageServiceScheduledThread");
- }
- });
+ .newSingleThreadScheduledExecutor(new ThreadFactory() {
+ @Override
+ public Thread newThread(Runnable r) {
+ return new Thread(r, "PullMessageServiceScheduledThread");
+ }
+ });
public PullMessageService(MQClientInstance mQClientFactory) {
this.mQClientFactory = mQClientFactory;
@@ -69,14 +71,13 @@ public class PullMessageService extends ServiceThread {
private void pullMessage(final PullRequest pullRequest) {
final MQConsumerInner consumer = this.mQClientFactory.selectConsumer(pullRequest.getConsumerGroup());
if (consumer != null) {
- DefaultMQPushConsumerImpl impl = (DefaultMQPushConsumerImpl) consumer;
+ DefaultMQPushConsumerImpl impl = (DefaultMQPushConsumerImpl)consumer;
impl.pullMessage(pullRequest);
} else {
log.warn("No matched consumer for the PullRequest {}, drop it", pullRequest);
}
}
-
@Override
public void run() {
log.info(this.getServiceName() + " service started");
@@ -96,11 +97,9 @@ public class PullMessageService extends ServiceThread {
log.info(this.getServiceName() + " service end");
}
-
@Override
public String getServiceName() {
return PullMessageService.class.getSimpleName();
}
-
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
index ccc624b..4850313 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
@@ -6,19 +6,18 @@
* (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
+ * 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.
+ * 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.impl.consumer;
import org.apache.rocketmq.common.message.MessageQueue;
-
public class PullRequest {
private String consumerGroup;
private MessageQueue messageQueue;
@@ -38,27 +37,22 @@ public class PullRequest {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public MessageQueue getMessageQueue() {
return messageQueue;
}
-
public void setMessageQueue(MessageQueue messageQueue) {
this.messageQueue = messageQueue;
}
-
public long getNextOffset() {
return nextOffset;
}
-
public void setNextOffset(long nextOffset) {
this.nextOffset = nextOffset;
}
@@ -80,7 +74,7 @@ public class PullRequest {
return false;
if (getClass() != obj.getClass())
return false;
- PullRequest other = (PullRequest) obj;
+ PullRequest other = (PullRequest)obj;
if (consumerGroup == null) {
if (other.consumerGroup != null)
return false;
@@ -97,14 +91,13 @@ public class PullRequest {
@Override
public String toString() {
return "PullRequest [consumerGroup=" + consumerGroup + ", messageQueue=" + messageQueue
- + ", nextOffset=" + nextOffset + "]";
+ + ", nextOffset=" + nextOffset + "]";
}
public ProcessQueue getProcessQueue() {
return processQueue;
}
-
public void setProcessQueue(ProcessQueue processQueue) {
this.processQueue = processQueue;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java
index d248603..c43c9a9 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullResultExt.java
@@ -6,46 +6,40 @@
* (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
+ * 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.
+ * 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.impl.consumer;
+import java.util.List;
import org.apache.rocketmq.client.consumer.PullResult;
import org.apache.rocketmq.client.consumer.PullStatus;
import org.apache.rocketmq.common.message.MessageExt;
-import java.util.List;
-
-
public class PullResultExt extends PullResult {
private final long suggestWhichBrokerId;
private byte[] messageBinary;
-
public PullResultExt(PullStatus pullStatus, long nextBeginOffset, long minOffset, long maxOffset,
- List<MessageExt> msgFoundList, final long suggestWhichBrokerId, final byte[] messageBinary) {
+ List<MessageExt> msgFoundList, final long suggestWhichBrokerId, final byte[] messageBinary) {
super(pullStatus, nextBeginOffset, minOffset, maxOffset, msgFoundList);
this.suggestWhichBrokerId = suggestWhichBrokerId;
this.messageBinary = messageBinary;
}
-
public byte[] getMessageBinary() {
return messageBinary;
}
-
public void setMessageBinary(byte[] messageBinary) {
this.messageBinary = messageBinary;
}
-
public long getSuggestWhichBrokerId() {
return suggestWhichBrokerId;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
index 53d775f..91bfd1a 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
@@ -16,6 +16,16 @@
*/
package org.apache.rocketmq.client.impl.consumer;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.rocketmq.client.consumer.AllocateMessageQueueStrategy;
import org.apache.rocketmq.client.impl.FindBrokerResult;
import org.apache.rocketmq.client.impl.factory.MQClientInstance;
@@ -29,30 +39,23 @@ import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
import org.slf4j.Logger;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-
-
/**
* Base class for rebalance algorithm
- *
*/
public abstract class RebalanceImpl {
protected static final Logger log = ClientLogger.getLog();
protected final ConcurrentHashMap<MessageQueue, ProcessQueue> processQueueTable = new ConcurrentHashMap<MessageQueue, ProcessQueue>(64);
protected final ConcurrentHashMap<String/* topic */, Set<MessageQueue>> topicSubscribeInfoTable =
- new ConcurrentHashMap<String, Set<MessageQueue>>();
+ new ConcurrentHashMap<String, Set<MessageQueue>>();
protected final ConcurrentHashMap<String /* topic */, SubscriptionData> subscriptionInner =
- new ConcurrentHashMap<String, SubscriptionData>();
+ new ConcurrentHashMap<String, SubscriptionData>();
protected String consumerGroup;
protected MessageModel messageModel;
protected AllocateMessageQueueStrategy allocateMessageQueueStrategy;
protected MQClientInstance mQClientFactory;
-
public RebalanceImpl(String consumerGroup, MessageModel messageModel, AllocateMessageQueueStrategy allocateMessageQueueStrategy,
- MQClientInstance mQClientFactory) {
+ MQClientInstance mQClientFactory) {
this.consumerGroup = consumerGroup;
this.messageModel = messageModel;
this.allocateMessageQueueStrategy = allocateMessageQueueStrategy;
@@ -70,9 +73,9 @@ public abstract class RebalanceImpl {
try {
this.mQClientFactory.getMQClientAPIImpl().unlockBatchMQ(findBrokerResult.getBrokerAddr(), requestBody, 1000, oneway);
log.warn("unlock messageQueue. group:{}, clientId:{}, mq:{}", //
- this.consumerGroup, //
- this.mQClientFactory.getClientId(), //
- mq);
+ this.consumerGroup, //
+ this.mQClientFactory.getClientId(), //
+ mq);
} catch (Exception e) {
log.error("unlockBatchMQ exception, " + mq, e);
}
@@ -138,7 +141,7 @@ public abstract class RebalanceImpl {
try {
Set<MessageQueue> lockedMq =
- this.mQClientFactory.getMQClientAPIImpl().lockBatchMQ(findBrokerResult.getBrokerAddr(), requestBody, 1000);
+ this.mQClientFactory.getMQClientAPIImpl().lockBatchMQ(findBrokerResult.getBrokerAddr(), requestBody, 1000);
for (MessageQueue mmqq : lockedMq) {
ProcessQueue processQueue = this.processQueueTable.get(mmqq);
if (processQueue != null) {
@@ -149,9 +152,9 @@ public abstract class RebalanceImpl {
boolean lockOK = lockedMq.contains(mq);
log.info("the message queue lock {}, {} {}",
- lockOK ? "OK" : "Failed",
- this.consumerGroup,
- mq);
+ lockOK ? "OK" : "Failed",
+ this.consumerGroup,
+ mq);
return lockOK;
} catch (Exception e) {
log.error("lockBatchMQ exception, " + mq, e);
@@ -182,7 +185,7 @@ public abstract class RebalanceImpl {
try {
Set<MessageQueue> lockOKMQSet =
- this.mQClientFactory.getMQClientAPIImpl().lockBatchMQ(findBrokerResult.getBrokerAddr(), requestBody, 1000);
+ this.mQClientFactory.getMQClientAPIImpl().lockBatchMQ(findBrokerResult.getBrokerAddr(), requestBody, 1000);
for (MessageQueue mq : lockOKMQSet) {
ProcessQueue processQueue = this.processQueueTable.get(mq);
@@ -242,10 +245,10 @@ public abstract class RebalanceImpl {
if (changed) {
this.messageQueueChanged(topic, mqSet, mqSet);
log.info("messageQueueChanged {} {} {} {}", //
- consumerGroup, //
- topic, //
- mqSet, //
- mqSet);
+ consumerGroup, //
+ topic, //
+ mqSet, //
+ mqSet);
}
} else {
log.warn("doRebalance, {}, but the topic[{}] not exist.", consumerGroup, topic);
@@ -277,13 +280,13 @@ public abstract class RebalanceImpl {
List<MessageQueue> allocateResult = null;
try {
allocateResult = strategy.allocate(//
- this.consumerGroup, //
- this.mQClientFactory.getClientId(), //
- mqAll, //
- cidAll);
+ this.consumerGroup, //
+ this.mQClientFactory.getClientId(), //
+ mqAll, //
+ cidAll);
} catch (Throwable e) {
log.error("AllocateMessageQueueStrategy.allocate Exception. allocateMessageQueueStrategyName={}", strategy.getName(),
- e);
+ e);
return;
}
@@ -295,9 +298,9 @@ public abstract class RebalanceImpl {
boolean changed = this.updateProcessQueueTableInRebalance(topic, allocateResultSet, isOrder);
if (changed) {
log.info(
- "rebalanced result changed. allocateMessageQueueStrategyName={}, group={}, topic={}, clientId={}, mqAllSize={}, cidAllSize={}, rebalanceResultSize={}, rebalanceResultSet={}",
- strategy.getName(), consumerGroup, topic, this.mQClientFactory.getClientId(), mqSet.size(), cidAll.size(),
- allocateResultSet.size(), allocateResultSet);
+ "rebalanced result changed. allocateMessageQueueStrategyName={}, group={}, topic={}, clientId={}, mqAllSize={}, cidAllSize={}, rebalanceResultSize={}, rebalanceResultSet={}",
+ strategy.getName(), consumerGroup, topic, this.mQClientFactory.getClientId(), mqSet.size(), cidAll.size(),
+ allocateResultSet.size(), allocateResultSet);
this.messageQueueChanged(topic, mqSet, allocateResultSet);
}
}
@@ -350,7 +353,7 @@ public abstract class RebalanceImpl {
it.remove();
changed = true;
log.error("[BUG]doRebalance, {}, remove unnecessary mq, {}, because pull is pause, so try to fixed it",
- consumerGroup, mq);
+ consumerGroup, mq);
}
break;
default:
@@ -422,52 +425,42 @@ public abstract class RebalanceImpl {
return processQueueTable;
}
-
public ConcurrentHashMap<String, Set<MessageQueue>> getTopicSubscribeInfoTable() {
return topicSubscribeInfoTable;
}
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public MessageModel getMessageModel() {
return messageModel;
}
-
public void setMessageModel(MessageModel messageModel) {
this.messageModel = messageModel;
}
-
public AllocateMessageQueueStrategy getAllocateMessageQueueStrategy() {
return allocateMessageQueueStrategy;
}
-
public void setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy allocateMessageQueueStrategy) {
this.allocateMessageQueueStrategy = allocateMessageQueueStrategy;
}
-
public MQClientInstance getmQClientFactory() {
return mQClientFactory;
}
-
public void setmQClientFactory(MQClientInstance mQClientFactory) {
this.mQClientFactory = mQClientFactory;
}
-
public void destroy() {
Iterator<Entry<MessageQueue, ProcessQueue>> it = this.processQueueTable.entrySet().iterator();
while (it.hasNext()) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java
index d37090d..1130943 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePullImpl.java
@@ -6,16 +6,18 @@
* (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
+ * 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.
+ * 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.impl.consumer;
+import java.util.List;
+import java.util.Set;
import org.apache.rocketmq.client.consumer.AllocateMessageQueueStrategy;
import org.apache.rocketmq.client.consumer.MessageQueueListener;
import org.apache.rocketmq.client.impl.factory.MQClientInstance;
@@ -23,21 +25,15 @@ import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
-import java.util.List;
-import java.util.Set;
-
-
public class RebalancePullImpl extends RebalanceImpl {
private final DefaultMQPullConsumerImpl defaultMQPullConsumerImpl;
-
public RebalancePullImpl(DefaultMQPullConsumerImpl defaultMQPullConsumerImpl) {
this(null, null, null, null, defaultMQPullConsumerImpl);
}
-
public RebalancePullImpl(String consumerGroup, MessageModel messageModel, AllocateMessageQueueStrategy allocateMessageQueueStrategy,
- MQClientInstance mQClientFactory, DefaultMQPullConsumerImpl defaultMQPullConsumerImpl) {
+ MQClientInstance mQClientFactory, DefaultMQPullConsumerImpl defaultMQPullConsumerImpl) {
super(consumerGroup, messageModel, allocateMessageQueueStrategy, mQClientFactory);
this.defaultMQPullConsumerImpl = defaultMQPullConsumerImpl;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
index 4d0d47f..707b9a1 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
@@ -6,16 +6,19 @@
* (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
+ * 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.
+ * 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.impl.consumer;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
import org.apache.rocketmq.client.consumer.AllocateMessageQueueStrategy;
import org.apache.rocketmq.client.consumer.store.OffsetStore;
import org.apache.rocketmq.client.consumer.store.ReadOffsetType;
@@ -28,23 +31,16 @@ import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-
public class RebalancePushImpl extends RebalanceImpl {
private final static long UNLOCK_DELAY_TIME_MILLS = Long.parseLong(System.getProperty("rocketmq.client.unlockDelayTimeMills", "20000"));
private final DefaultMQPushConsumerImpl defaultMQPushConsumerImpl;
-
public RebalancePushImpl(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl) {
this(null, null, null, null, defaultMQPushConsumerImpl);
}
-
public RebalancePushImpl(String consumerGroup, MessageModel messageModel, AllocateMessageQueueStrategy allocateMessageQueueStrategy,
- MQClientInstance mQClientFactory, DefaultMQPushConsumerImpl defaultMQPushConsumerImpl) {
+ MQClientInstance mQClientFactory, DefaultMQPushConsumerImpl defaultMQPushConsumerImpl) {
super(consumerGroup, messageModel, allocateMessageQueueStrategy, mQClientFactory);
this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
}
@@ -58,7 +54,7 @@ public class RebalancePushImpl extends RebalanceImpl {
this.defaultMQPushConsumerImpl.getOffsetStore().persist(mq);
this.defaultMQPushConsumerImpl.getOffsetStore().removeOffset(mq);
if (this.defaultMQPushConsumerImpl.isConsumeOrderly()
- && MessageModel.CLUSTERING.equals(this.defaultMQPushConsumerImpl.messageModel())) {
+ && MessageModel.CLUSTERING.equals(this.defaultMQPushConsumerImpl.messageModel())) {
try {
if (pq.getLockConsume().tryLock(1000, TimeUnit.MILLISECONDS)) {
try {
@@ -68,8 +64,8 @@ public class RebalancePushImpl extends RebalanceImpl {
}
} else {
log.warn("[WRONG]mq is consuming, so can not unlock it, {}. maybe hanged for a while, {}", //
- mq, //
- pq.getTryUnlockTimes());
+ mq, //
+ pq.getTryUnlockTimes());
pq.incTryUnlockTimes();
}
@@ -164,7 +160,7 @@ public class RebalancePushImpl extends RebalanceImpl {
} else {
try {
long timestamp = UtilAll.parseDate(this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer().getConsumeTimestamp(),
- UtilAll.YYYY_MMDD_HHMMSS).getTime();
+ UtilAll.YYYY_MMDD_HHMMSS).getTime();
result = this.mQClientFactory.getMQAdminImpl().searchOffset(mq, timestamp);
} catch (MQClientException e) {
result = -1;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
index 5b5ab2a..985129e 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.impl.consumer;
@@ -21,15 +21,14 @@ import org.apache.rocketmq.client.log.ClientLogger;
import org.apache.rocketmq.common.ServiceThread;
import org.slf4j.Logger;
-
/**
* Rebalance Service
*
*/
public class RebalanceService extends ServiceThread {
private static long waitInterval =
- Long.parseLong(System.getProperty(
- "rocketmq.client.rebalance.waitInterval", "20000"));
+ Long.parseLong(System.getProperty(
+ "rocketmq.client.rebalance.waitInterval", "20000"));
private final Logger log = ClientLogger.getLog();
private final MQClientInstance mqClientFactory;
@@ -49,7 +48,6 @@ public class RebalanceService extends ServiceThread {
log.info(this.getServiceName() + " service end");
}
-
@Override
public String getServiceName() {
return RebalanceService.class.getSimpleName();
[39/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/test/java/com/alibaba/rocketmq/broker/topic/TopicConfigManagerTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/com/alibaba/rocketmq/broker/topic/TopicConfigManagerTest.java b/broker/src/test/java/com/alibaba/rocketmq/broker/topic/TopicConfigManagerTest.java
deleted file mode 100644
index 1c93b02..0000000
--- a/broker/src/test/java/com/alibaba/rocketmq/broker/topic/TopicConfigManagerTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: TopicConfigManagerTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
- */
-package com.alibaba.rocketmq.broker.topic;
-
-import com.alibaba.rocketmq.broker.BrokerTestHarness;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.TopicConfig;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-
-/**
- * @author zander
- */
-public class TopicConfigManagerTest extends BrokerTestHarness {
- @Test
- public void testFlushTopicConfig() throws Exception {
- TopicConfigManager topicConfigManager = new TopicConfigManager(brokerController);
-
- for (int i = 0; i < 10; i++) {
- String topic = "UNITTEST-" + i;
- TopicConfig topicConfig = topicConfigManager.createTopicInSendMessageMethod(topic, MixAll.DEFAULT_TOPIC, null, 4, 0);
- assertNotNull(topicConfig);
- }
- topicConfigManager.persist();
-
- topicConfigManager.getTopicConfigTable().clear();
-
- for (int i = 0; i < 10; i++) {
- String topic = "UNITTEST-" + i;
- TopicConfig topicConfig = topicConfigManager.selectTopicConfig(topic);
- assertNull(topicConfig);
- }
- topicConfigManager.load();
- for (int i = 0; i < 10; i++) {
- String topic = "UNITTEST-" + i;
- TopicConfig topicConfig = topicConfigManager.selectTopicConfig(topic);
- assertNotNull(topicConfig);
- assertEquals(topicConfig.getTopicSysFlag(), 0);
- assertEquals(topicConfig.getReadQueueNums(), 4);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java b/broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java
new file mode 100644
index 0000000..79f82a6
--- /dev/null
+++ b/broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java
@@ -0,0 +1,61 @@
+/**
+ * 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.broker;
+
+import org.apache.rocketmq.common.BrokerConfig;
+import org.apache.rocketmq.remoting.netty.NettyClientConfig;
+import org.apache.rocketmq.remoting.netty.NettyServerConfig;
+import org.apache.rocketmq.store.config.MessageStoreConfig;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author shtykh_roman
+ */
+public class BrokerControllerTest {
+ protected Logger logger = LoggerFactory.getLogger(BrokerControllerTest.class);
+
+ 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();
+ Assert.assertTrue(initResult);
+ logger.info("Broker is initialized " + initResult);
+ brokerController.start();
+ logger.info("Broker is started");
+
+ brokerController.shutdown();
+ logger.info("Broker is stopped");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java b/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
new file mode 100644
index 0000000..4b4fd95
--- /dev/null
+++ b/broker/src/test/java/org/apache/rocketmq/broker/BrokerTestHarness.java
@@ -0,0 +1,74 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: SendMessageTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
+ */
+package org.apache.rocketmq.broker;
+
+import org.apache.rocketmq.common.BrokerConfig;
+import org.apache.rocketmq.remoting.netty.NettyClientConfig;
+import org.apache.rocketmq.remoting.netty.NettyServerConfig;
+import org.apache.rocketmq.store.config.MessageStoreConfig;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.Random;
+
+/**
+ * @author zander
+ */
+public class BrokerTestHarness {
+
+ protected BrokerController brokerController = null;
+
+ protected Random random = new Random();
+ public final String BROKER_NAME = "TestBrokerName";
+ protected String brokerAddr = "";
+ protected Logger logger = LoggerFactory.getLogger(BrokerTestHarness.class);
+ protected BrokerConfig brokerConfig = new BrokerConfig();
+ protected NettyServerConfig nettyServerConfig = new NettyServerConfig();
+ protected NettyClientConfig nettyClientConfig = new NettyClientConfig();
+ protected MessageStoreConfig storeConfig = new MessageStoreConfig();
+
+ @Before
+ public void startup() throws Exception {
+ brokerConfig.setBrokerName(BROKER_NAME);
+ brokerConfig.setBrokerIP1("127.0.0.1");
+ storeConfig.setStorePathRootDir(System.getProperty("user.home") + File.separator + "unitteststore");
+ storeConfig.setStorePathCommitLog(System.getProperty("user.home") + File.separator + "unitteststore" + File.separator + "commitlog");
+ nettyServerConfig.setListenPort(10000 + random.nextInt(1000));
+ brokerAddr = brokerConfig.getBrokerIP1() + ":" + nettyServerConfig.getListenPort();
+ brokerController = new BrokerController(brokerConfig, nettyServerConfig, nettyClientConfig, storeConfig);
+ boolean initResult = brokerController.initialize();
+ Assert.assertTrue(initResult);
+ logger.info("Broker Start name:{} addr:{}", brokerConfig.getBrokerName(), brokerController.getBrokerAddr());
+ brokerController.start();
+ }
+
+ @After
+ public void shutdown() throws Exception {
+ if (brokerController != null) {
+ brokerController.shutdown();
+ }
+ //maybe need to clean the file store. But we do not suggest deleting anything.
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java b/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
new file mode 100644
index 0000000..9988a7c
--- /dev/null
+++ b/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
@@ -0,0 +1,83 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: SendMessageTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
+ */
+package org.apache.rocketmq.broker.api;
+
+import org.apache.rocketmq.broker.BrokerTestHarness;
+import org.apache.rocketmq.client.ClientConfig;
+import org.apache.rocketmq.client.hook.SendMessageContext;
+import org.apache.rocketmq.client.impl.CommunicationMode;
+import org.apache.rocketmq.client.impl.MQClientAPIImpl;
+import org.apache.rocketmq.client.producer.SendResult;
+import org.apache.rocketmq.client.producer.SendStatus;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageDecoder;
+import org.apache.rocketmq.common.protocol.header.SendMessageRequestHeader;
+import org.apache.rocketmq.remoting.netty.NettyClientConfig;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * @author zander
+ */
+public class SendMessageTest extends BrokerTestHarness{
+
+ MQClientAPIImpl client = new MQClientAPIImpl(new NettyClientConfig(), null, null, new ClientConfig());
+ String topic = "UnitTestTopic";
+
+ @Before
+ @Override
+ public void startup() throws Exception {
+ super.startup();
+ client.start();
+
+ }
+
+ @After
+ @Override
+ public void shutdown() throws Exception {
+ client.shutdown();
+ super.shutdown();
+ }
+
+ @Test
+ public void testSendSingle() throws Exception{
+ Message msg = new Message(topic, "TAG1 TAG2", "100200300", "body".getBytes());
+ SendMessageRequestHeader requestHeader = new SendMessageRequestHeader();
+ requestHeader.setProducerGroup("abc");
+ requestHeader.setTopic(msg.getTopic());
+ requestHeader.setDefaultTopic(MixAll.DEFAULT_TOPIC);
+ requestHeader.setDefaultTopicQueueNums(4);
+ requestHeader.setQueueId(0);
+ requestHeader.setSysFlag(0);
+ requestHeader.setBornTimestamp(System.currentTimeMillis());
+ requestHeader.setFlag(msg.getFlag());
+ requestHeader.setProperties(MessageDecoder.messageProperties2String(msg.getProperties()));
+
+ SendResult result = client.sendMessage(brokerAddr, BROKER_NAME, msg, requestHeader, 1000 * 5,
+ CommunicationMode.SYNC, new SendMessageContext(), null);
+ assertEquals(result.getSendStatus(), SendStatus.SEND_OK);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java b/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
new file mode 100644
index 0000000..cdbddf9
--- /dev/null
+++ b/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
@@ -0,0 +1,65 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: ConsumerOffsetManagerTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
+ */
+package org.apache.rocketmq.broker.offset;
+
+import org.apache.rocketmq.broker.BrokerTestHarness;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+
+/**
+ * @author zander
+ */
+public class ConsumerOffsetManagerTest extends BrokerTestHarness {
+
+ @Test
+ public void testFlushConsumerOffset() throws Exception {
+ ConsumerOffsetManager consumerOffsetManager = new ConsumerOffsetManager(brokerController);
+ for (int i = 0; i < 10; i++) {
+ String group = "UNIT_TEST_GROUP_" + i;
+ for (int id = 0; id < 10; id++) {
+ consumerOffsetManager.commitOffset(null, group, "TOPIC_A", id, id + 100);
+ consumerOffsetManager.commitOffset(null, group, "TOPIC_B", id, id + 100);
+ consumerOffsetManager.commitOffset(null, group, "TOPIC_C", id, id + 100);
+ }
+ }
+ consumerOffsetManager.persist();
+ consumerOffsetManager.getOffsetTable().clear();
+ for (int i = 0; i < 10; i++) {
+ String group = "UNIT_TEST_GROUP_" + i;
+ for (int id = 0; id < 10; id++) {
+ assertEquals(consumerOffsetManager.queryOffset(group, "TOPIC_A", id), -1);
+ assertEquals(consumerOffsetManager.queryOffset(group, "TOPIC_B", id), -1);
+ assertEquals(consumerOffsetManager.queryOffset(group, "TOPIC_B", id), -1);
+ }
+ }
+ consumerOffsetManager.load();
+ for (int i = 0; i < 10; i++) {
+ String group = "UNIT_TEST_GROUP_" + i;
+ for (int id = 0; id < 10; id++) {
+ assertEquals(consumerOffsetManager.queryOffset(group, "TOPIC_A", id), id + 100);
+ assertEquals(consumerOffsetManager.queryOffset(group, "TOPIC_B", id), id + 100);
+ assertEquals(consumerOffsetManager.queryOffset(group, "TOPIC_B", id), id + 100);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java b/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
new file mode 100644
index 0000000..1de17e6
--- /dev/null
+++ b/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
@@ -0,0 +1,62 @@
+/**
+ * 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.
+ */
+
+/**
+ * $Id: TopicConfigManagerTest.java 1831 2013-05-16 01:39:51Z shijia.wxr $
+ */
+package org.apache.rocketmq.broker.topic;
+
+import org.apache.rocketmq.broker.BrokerTestHarness;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.TopicConfig;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * @author zander
+ */
+public class TopicConfigManagerTest extends BrokerTestHarness {
+ @Test
+ public void testFlushTopicConfig() throws Exception {
+ TopicConfigManager topicConfigManager = new TopicConfigManager(brokerController);
+
+ for (int i = 0; i < 10; i++) {
+ String topic = "UNITTEST-" + i;
+ TopicConfig topicConfig = topicConfigManager.createTopicInSendMessageMethod(topic, MixAll.DEFAULT_TOPIC, null, 4, 0);
+ assertNotNull(topicConfig);
+ }
+ topicConfigManager.persist();
+
+ topicConfigManager.getTopicConfigTable().clear();
+
+ for (int i = 0; i < 10; i++) {
+ String topic = "UNITTEST-" + i;
+ TopicConfig topicConfig = topicConfigManager.selectTopicConfig(topic);
+ assertNull(topicConfig);
+ }
+ topicConfigManager.load();
+ for (int i = 0; i < 10; i++) {
+ String topic = "UNITTEST-" + i;
+ TopicConfig topicConfig = topicConfigManager.selectTopicConfig(topic);
+ assertNotNull(topicConfig);
+ assertEquals(topicConfig.getTopicSysFlag(), 0);
+ assertEquals(topicConfig.getReadQueueNums(), 4);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index 63a6114..86d38cf 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -18,7 +18,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.rocketmq</groupId>
+ <groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-all</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>
@@ -56,19 +56,19 @@
<includes>
<include>com.alibaba:fastjson</include>
<include>io.netty:netty-all</include>
- <include>com.alibaba.rocketmq:rocketmq-client</include>
- <include>com.alibaba.rocketmq:rocketmq-common</include>
- <include>com.alibaba.rocketmq:rocketmq-remoting</include>
+ <include>org.apache.rocketmq:rocketmq-client</include>
+ <include>org.apache.rocketmq:rocketmq-common</include>
+ <include>org.apache.rocketmq:rocketmq-remoting</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>io.netty</pattern>
- <shadedPattern>com.alibaba.rocketmq.shade.io.netty</shadedPattern>
+ <shadedPattern>org.apache.rocketmq.shade.io.netty</shadedPattern>
</relocation>
<relocation>
<pattern>com.alibaba.fastjson</pattern>
- <shadedPattern>com.alibaba.rocketmq.shade.com.alibaba.fastjson</shadedPattern>
+ <shadedPattern>org.apache.rocketmq.shade.com.alibaba.fastjson</shadedPattern>
</relocation>
</relocations>
</configuration>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/ClientConfig.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/ClientConfig.java b/client/src/main/java/com/alibaba/rocketmq/client/ClientConfig.java
deleted file mode 100644
index 4d80564..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/ClientConfig.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/**
- * 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.client;
-
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.remoting.common.RemotingUtil;
-
-
-/**
- * Client Common configuration
- *
- * @author shijia.wxr
- * @author vongosling
- */
-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 String instanceName = System.getProperty("rocketmq.client.name", "DEFAULT");
- private int clientCallbackExecutorThreads = Runtime.getRuntime().availableProcessors();
- /**
- * Pulling topic information interval from the named server
- */
- private int pollNameServerInteval = 1000 * 30;
- /**
- * Heartbeat interval in microseconds with message broker
- */
- private int heartbeatBrokerInterval = 1000 * 30;
- /**
- * Offset persistent interval for consumer
- */
- private int persistConsumerOffsetInterval = 1000 * 5;
- private boolean unitMode = false;
- private String unitName;
- private boolean vipChannelEnabled = Boolean.parseBoolean(System.getProperty(SEND_MESSAGE_WITH_VIP_CHANNEL_PROPERTY, "true"));
-
- public String buildMQClientId() {
- StringBuilder sb = new StringBuilder();
- sb.append(this.getClientIP());
-
- sb.append("@");
- sb.append(this.getInstanceName());
- if (!UtilAll.isBlank(this.unitName)) {
- sb.append("@");
- sb.append(this.unitName);
- }
-
- return sb.toString();
- }
-
- public String getClientIP() {
- return clientIP;
- }
-
- public void setClientIP(String clientIP) {
- this.clientIP = clientIP;
- }
-
- public String getInstanceName() {
- return instanceName;
- }
-
- public void setInstanceName(String instanceName) {
- this.instanceName = instanceName;
- }
-
- public void changeInstanceNameToPID() {
- if (this.instanceName.equals("DEFAULT")) {
- this.instanceName = String.valueOf(UtilAll.getPid());
- }
- }
-
- public void resetClientConfig(final ClientConfig cc) {
- this.namesrvAddr = cc.namesrvAddr;
- this.clientIP = cc.clientIP;
- this.instanceName = cc.instanceName;
- this.clientCallbackExecutorThreads = cc.clientCallbackExecutorThreads;
- this.pollNameServerInteval = cc.pollNameServerInteval;
- this.heartbeatBrokerInterval = cc.heartbeatBrokerInterval;
- this.persistConsumerOffsetInterval = cc.persistConsumerOffsetInterval;
- this.unitMode = cc.unitMode;
- this.unitName = cc.unitName;
- this.vipChannelEnabled = cc.vipChannelEnabled;
- }
-
- public ClientConfig cloneClientConfig() {
- ClientConfig cc = new ClientConfig();
- cc.namesrvAddr = namesrvAddr;
- cc.clientIP = clientIP;
- cc.instanceName = instanceName;
- cc.clientCallbackExecutorThreads = clientCallbackExecutorThreads;
- cc.pollNameServerInteval = pollNameServerInteval;
- cc.heartbeatBrokerInterval = heartbeatBrokerInterval;
- cc.persistConsumerOffsetInterval = persistConsumerOffsetInterval;
- cc.unitMode = unitMode;
- cc.unitName = unitName;
- cc.vipChannelEnabled = vipChannelEnabled;
- return cc;
- }
-
- public String getNamesrvAddr() {
- return namesrvAddr;
- }
-
- public void setNamesrvAddr(String namesrvAddr) {
- this.namesrvAddr = namesrvAddr;
- }
-
- public int getClientCallbackExecutorThreads() {
- return clientCallbackExecutorThreads;
- }
-
-
- public void setClientCallbackExecutorThreads(int clientCallbackExecutorThreads) {
- this.clientCallbackExecutorThreads = clientCallbackExecutorThreads;
- }
-
-
- public int getPollNameServerInteval() {
- return pollNameServerInteval;
- }
-
-
- public void setPollNameServerInteval(int pollNameServerInteval) {
- this.pollNameServerInteval = pollNameServerInteval;
- }
-
-
- public int getHeartbeatBrokerInterval() {
- return heartbeatBrokerInterval;
- }
-
-
- public void setHeartbeatBrokerInterval(int heartbeatBrokerInterval) {
- this.heartbeatBrokerInterval = heartbeatBrokerInterval;
- }
-
-
- public int getPersistConsumerOffsetInterval() {
- return persistConsumerOffsetInterval;
- }
-
-
- public void setPersistConsumerOffsetInterval(int persistConsumerOffsetInterval) {
- this.persistConsumerOffsetInterval = persistConsumerOffsetInterval;
- }
-
-
- public String getUnitName() {
- return unitName;
- }
-
-
- public void setUnitName(String unitName) {
- this.unitName = unitName;
- }
-
-
- public boolean isUnitMode() {
- return unitMode;
- }
-
-
- public void setUnitMode(boolean unitMode) {
- this.unitMode = unitMode;
- }
-
-
- public boolean isVipChannelEnabled() {
- return vipChannelEnabled;
- }
-
-
- public void setVipChannelEnabled(final boolean vipChannelEnabled) {
- this.vipChannelEnabled = vipChannelEnabled;
- }
-
-
- @Override
- public String toString() {
- return "ClientConfig [namesrvAddr=" + namesrvAddr + ", clientIP=" + clientIP + ", instanceName=" + instanceName
- + ", clientCallbackExecutorThreads=" + clientCallbackExecutorThreads + ", pollNameServerInteval=" + pollNameServerInteval
- + ", heartbeatBrokerInterval=" + heartbeatBrokerInterval + ", persistConsumerOffsetInterval="
- + persistConsumerOffsetInterval + ", unitMode=" + unitMode + ", unitName=" + unitName + ", vipChannelEnabled="
- + vipChannelEnabled + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/MQAdmin.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/MQAdmin.java b/client/src/main/java/com/alibaba/rocketmq/client/MQAdmin.java
deleted file mode 100644
index 4e202e9..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/MQAdmin.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
- * 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.client;
-
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.remoting.exception.RemotingException;
-
-
-/**
- * Base interface for MQ management
- *
- * @author shijia.wxr
- */
-public interface MQAdmin {
- /**
- * Creates an topic
- *
- * @param key
- * accesskey
- * @param newTopic
- * topic name
- * @param queueNum
- * topic's queue number
- *
- * @throws MQClientException
- */
- void createTopic(final String key, final String newTopic, final int queueNum)
- throws MQClientException;
-
-
- /**
- * Creates an topic
- *
- * @param key
- * accesskey
- * @param newTopic
- * topic name
- * @param queueNum
- * topic's queue number
- * @param topicSysFlag
- * topic system flag
- *
- * @throws MQClientException
- */
- void createTopic(String key, String newTopic, int queueNum, int topicSysFlag)
- throws MQClientException;
-
-
- /**
- * Gets the message queue offset according to some time in milliseconds<br>
- * be cautious to call because of more IO overhead
- *
- * @param mq
- * Instance of MessageQueue
- * @param timestamp
- * from when in milliseconds.
- *
- * @return offset
- *
- * @throws MQClientException
- */
- long searchOffset(final MessageQueue mq, final long timestamp) throws MQClientException;
-
-
- /**
- * Gets the max offset
- *
- * @param mq
- * Instance of MessageQueue
- *
- * @return the max offset
- *
- * @throws MQClientException
- */
- long maxOffset(final MessageQueue mq) throws MQClientException;
-
-
- /**
- * Gets the minimum offset
- *
- * @param mq
- * Instance of MessageQueue
- *
- * @return the minimum offset
- *
- * @throws MQClientException
- */
- long minOffset(final MessageQueue mq) throws MQClientException;
-
-
- /**
- * Gets the earliest stored message time
- *
- * @param mq
- * Instance of MessageQueue
- *
- * @return the time in microseconds
- *
- * @throws MQClientException
- */
- long earliestMsgStoreTime(final MessageQueue mq) throws MQClientException;
-
-
- /**
- * Query message according tto message id
- *
- * @param offsetMsgId
- * message id
- *
- * @return message
- *
- * @throws InterruptedException
- * @throws MQBrokerException
- * @throws RemotingException
- * @throws MQClientException
- */
- MessageExt viewMessage(final String offsetMsgId) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException;
-
-
- /**
- * Query messages
- *
- * @param topic
- * message topic
- * @param key
- * message key index word
- * @param maxNum
- * max message number
- * @param begin
- * from when
- * @param end
- * to when
- *
- * @return Instance of QueryResult
- *
- * @throws MQClientException
- * @throws InterruptedException
- */
- QueryResult queryMessage(final String topic, final String key, final int maxNum, final long begin,
- final long end) throws MQClientException, InterruptedException;
-
- /**
-
- * @param topic
- * @param msgId
- * @return The {@code MessageExt} of given msgId
- * @throws RemotingException
- * @throws MQBrokerException
- * @throws InterruptedException
- * @throws MQClientException
- */
- MessageExt viewMessage(String topic, String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/MQHelper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/MQHelper.java b/client/src/main/java/com/alibaba/rocketmq/client/MQHelper.java
deleted file mode 100644
index 5934b49..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/MQHelper.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * 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.client;
-
-import com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.heartbeat.MessageModel;
-import org.slf4j.Logger;
-
-import java.util.Set;
-import java.util.TreeSet;
-
-
-/**
- * @author shijia.wxr
- */
-public class MQHelper {
- public static void resetOffsetByTimestamp(
- final MessageModel messageModel,
- final String consumerGroup,
- final String topic,
- final long timestamp) throws Exception {
- resetOffsetByTimestamp(messageModel, "DEFAULT", consumerGroup, topic, timestamp);
- }
-
- /**
- * Reset consumer topic offset according to time
- *
- * @param messageModel
- * which model
- * @param instanceName
- * which instance
- * @param consumerGroup
- * consumer group
- * @param topic
- * topic
- * @param timestamp
- * time
- *
- * @throws Exception
- */
- public static void resetOffsetByTimestamp(
- final MessageModel messageModel,
- final String instanceName,
- final String consumerGroup,
- final String topic,
- final long timestamp) throws Exception {
- final Logger log = ClientLogger.getLog();
-
- DefaultMQPullConsumer consumer = new DefaultMQPullConsumer(consumerGroup);
- consumer.setInstanceName(instanceName);
- consumer.setMessageModel(messageModel);
- consumer.start();
-
- Set<MessageQueue> mqs = null;
- try {
- mqs = consumer.fetchSubscribeMessageQueues(topic);
- if (mqs != null && !mqs.isEmpty()) {
- TreeSet<MessageQueue> mqsNew = new TreeSet<MessageQueue>(mqs);
- for (MessageQueue mq : mqsNew) {
- long offset = consumer.searchOffset(mq, timestamp);
- if (offset >= 0) {
- consumer.updateConsumeOffset(mq, offset);
- log.info("resetOffsetByTimestamp updateConsumeOffset success, {} {} {}",
- consumerGroup, offset, mq);
- }
- }
- }
- } catch (Exception e) {
- log.warn("resetOffsetByTimestamp Exception", e);
- throw e;
- } finally {
- if (mqs != null) {
- consumer.getDefaultMQPullConsumerImpl().getOffsetStore().persistAll(mqs);
- }
- consumer.shutdown();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/QueryResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/QueryResult.java b/client/src/main/java/com/alibaba/rocketmq/client/QueryResult.java
deleted file mode 100644
index 43c8106..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/QueryResult.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * 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.client;
-
-import com.alibaba.rocketmq.common.message.MessageExt;
-
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public class QueryResult {
- private final long indexLastUpdateTimestamp;
- private final List<MessageExt> messageList;
-
-
- public QueryResult(long indexLastUpdateTimestamp, List<MessageExt> messageList) {
- this.indexLastUpdateTimestamp = indexLastUpdateTimestamp;
- this.messageList = messageList;
- }
-
-
- public long getIndexLastUpdateTimestamp() {
- return indexLastUpdateTimestamp;
- }
-
-
- public List<MessageExt> getMessageList() {
- return messageList;
- }
-
-
- @Override
- public String toString() {
- return "QueryResult [indexLastUpdateTimestamp=" + indexLastUpdateTimestamp + ", messageList="
- + messageList + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/Validators.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/Validators.java b/client/src/main/java/com/alibaba/rocketmq/client/Validators.java
deleted file mode 100644
index 203aae0..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/Validators.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/**
- * 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.client;
-
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.message.Message;
-import com.alibaba.rocketmq.common.protocol.ResponseCode;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-
-/**
- * Common Validator
- *
- * @author manhong.yqd
- */
-public class Validators {
- public static final String VALID_PATTERN_STR = "^[%|a-zA-Z0-9_-]+$";
- public static final Pattern PATTERN = Pattern.compile(VALID_PATTERN_STR);
- public static final int CHARACTER_MAX_LENGTH = 255;
-
- /**
- * @param origin
- * @param patternStr
- *
- * @return The resulting {@code String}
- */
- public static String getGroupWithRegularExpression(String origin, String patternStr) {
- Pattern pattern = Pattern.compile(patternStr);
- Matcher matcher = pattern.matcher(origin);
- while (matcher.find()) {
- return matcher.group(0);
- }
- return null;
- }
-
- /**
- * Validate group
- *
- * @param group
- *
- * @throws com.alibaba.rocketmq.client.exception.MQClientException
- */
- public static void checkGroup(String group) throws MQClientException {
- if (UtilAll.isBlank(group)) {
- throw new MQClientException("the specified group is blank", null);
- }
- if (!regularExpressionMatcher(group, PATTERN)) {
- throw new MQClientException(String.format(
- "the specified group[%s] contains illegal characters, allowing only %s", group,
- VALID_PATTERN_STR), null);
- }
- if (group.length() > CHARACTER_MAX_LENGTH) {
- throw new MQClientException("the specified group is longer than group max length 255.", null);
- }
- }
-
- /**
- * @param origin
- * @param pattern
- *
- * @return <tt>true</tt> if, and only if, the entire origin sequence
- * matches this matcher's pattern
- */
- public static boolean regularExpressionMatcher(String origin, Pattern pattern) {
- if (pattern == null) {
- return true;
- }
- Matcher matcher = pattern.matcher(origin);
- return matcher.matches();
- }
-
- /**
- * Validate message
- *
- * @param msg
- * @param defaultMQProducer
- *
- * @throws com.alibaba.rocketmq.client.exception.MQClientException
- */
- public static void checkMessage(Message msg, DefaultMQProducer defaultMQProducer)
- throws MQClientException {
- if (null == msg) {
- throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, "the message is null");
- }
- // topic
- Validators.checkTopic(msg.getTopic());
- // body
- if (null == msg.getBody()) {
- throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, "the message body is null");
- }
-
- if (0 == msg.getBody().length) {
- throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, "the message body length is zero");
- }
-
- if (msg.getBody().length > defaultMQProducer.getMaxMessageSize()) {
- throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL,
- "the message body size over max value, MAX: " + defaultMQProducer.getMaxMessageSize());
- }
- }
-
- /**
- * Validate topic
- *
- * @param topic
- *
- * @throws com.alibaba.rocketmq.client.exception.MQClientException
- */
- public static void checkTopic(String topic) throws MQClientException {
- if (UtilAll.isBlank(topic)) {
- throw new MQClientException("the specified topic is blank", null);
- }
-
- if (!regularExpressionMatcher(topic, PATTERN)) {
- throw new MQClientException(String.format(
- "the specified topic[%s] contains illegal characters, allowing only %s", topic,
- VALID_PATTERN_STR), null);
- }
-
- if (topic.length() > CHARACTER_MAX_LENGTH) {
- throw new MQClientException("the specified topic is longer than topic max length 255.", null);
- }
-
- //whether the same with system reserved keyword
- if (topic.equals(MixAll.DEFAULT_TOPIC)) {
- throw new MQClientException(
- String.format("the topic[%s] is conflict with default topic.", topic), null);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/admin/MQAdminExtInner.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/admin/MQAdminExtInner.java b/client/src/main/java/com/alibaba/rocketmq/client/admin/MQAdminExtInner.java
deleted file mode 100644
index 071a872..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/admin/MQAdminExtInner.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * 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.client.admin;
-
-/**
- * @author shijia.wxr
- */
-public interface MQAdminExtInner {
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/common/ClientErrorCode.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/common/ClientErrorCode.java b/client/src/main/java/com/alibaba/rocketmq/client/common/ClientErrorCode.java
deleted file mode 100644
index 88d0eea..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/common/ClientErrorCode.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * 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.client.common;
-
-public class ClientErrorCode {
- public static final int CONNECT_BROKER_EXCEPTION = 10001;
- public static final int ACCESS_BROKER_TIMEOUT = 10002;
- public static final int BROKER_NOT_EXIST_EXCEPTION = 10003;
- public static final int NO_NAME_SERVER_EXCEPTION = 10004;
- public static final int NOT_FOUND_TOPIC_EXCEPTION = 10005;
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/common/ThreadLocalIndex.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/common/ThreadLocalIndex.java b/client/src/main/java/com/alibaba/rocketmq/client/common/ThreadLocalIndex.java
deleted file mode 100644
index 63fda5d..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/common/ThreadLocalIndex.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * 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.client.common;
-
-import java.util.Random;
-
-public class ThreadLocalIndex {
- private final ThreadLocal<Integer> threadLocalIndex = new ThreadLocal<Integer>();
- private final Random random = new Random();
- public ThreadLocalIndex(int value) {
-
- }
-
- public int getAndIncrement() {
- Integer index = this.threadLocalIndex.get();
- if (null == index) {
- index = Math.abs(random.nextInt());
- if (index < 0) index = 0;
- this.threadLocalIndex.set(index);
- }
-
- index = Math.abs(index + 1);
- if (index < 0)
- index = 0;
-
- this.threadLocalIndex.set(index);
- return index;
- }
-
- @Override
- public String toString() {
- return "ThreadLocalIndex{" +
- "threadLocalIndex=" + threadLocalIndex.get() +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/AllocateMessageQueueStrategy.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/AllocateMessageQueueStrategy.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/AllocateMessageQueueStrategy.java
deleted file mode 100644
index 4d70167..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/AllocateMessageQueueStrategy.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * 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.client.consumer;
-
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-import java.util.List;
-
-
-/**
- * Strategy Algorithm for message allocating between consumers
- *
- * @author shijia.wxr
- * @author vongosling
- */
-public interface AllocateMessageQueueStrategy {
-
- /**
- * Allocating by consumer id
- *
- * @param consumerGroup
- * current consumer group
- * @param currentCID
- * current consumer id
- * @param mqAll
- * message queue set in current topic
- * @param cidAll
- * consumer set in current consumer group
- *
- * @return The allocate result of given strategy
- */
- List<MessageQueue> allocate(
- final String consumerGroup,
- final String currentCID,
- final List<MessageQueue> mqAll,
- final List<String> cidAll
- );
-
-
- /**
- * Algorithm name
- *
- * @return The strategy name
- */
- String getName();
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/DefaultMQPullConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/DefaultMQPullConsumer.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/DefaultMQPullConsumer.java
deleted file mode 100644
index 96040ae..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/DefaultMQPullConsumer.java
+++ /dev/null
@@ -1,381 +0,0 @@
-/**
- * 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.client.consumer;
-
-import com.alibaba.rocketmq.client.ClientConfig;
-import com.alibaba.rocketmq.client.QueryResult;
-import com.alibaba.rocketmq.client.consumer.rebalance.AllocateMessageQueueAveragely;
-import com.alibaba.rocketmq.client.consumer.store.OffsetStore;
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.impl.consumer.DefaultMQPullConsumerImpl;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.message.MessageDecoder;
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.heartbeat.MessageModel;
-import com.alibaba.rocketmq.remoting.RPCHook;
-import com.alibaba.rocketmq.remoting.exception.RemotingException;
-
-import java.util.HashSet;
-import java.util.Set;
-
-
-/**
- * Default pulling consumer
- *
- * @author shijia.wxr
- */
-public class DefaultMQPullConsumer extends ClientConfig implements MQPullConsumer {
- protected final transient DefaultMQPullConsumerImpl defaultMQPullConsumerImpl;
-
- /**
- * Do the same thing for the same Group, the application must be set,and
- * guarantee Globally unique
- */
- private String consumerGroup;
- /**
- * Long polling mode, the Consumer connection max suspend time, it is not
- * recommended to modify
- */
- private long brokerSuspendMaxTimeMillis = 1000 * 20;
- /**
- * Long polling mode, the Consumer connection timeout(must greater than
- * brokerSuspendMaxTimeMillis), it is not recommended to modify
- */
- private long consumerTimeoutMillisWhenSuspend = 1000 * 30;
- /**
- * The socket timeout in milliseconds
- */
- private long consumerPullTimeoutMillis = 1000 * 10;
- /**
- * Consumption pattern,default is clustering
- */
- private MessageModel messageModel = MessageModel.CLUSTERING;
- /**
- * Message queue listener
- */
- private MessageQueueListener messageQueueListener;
- /**
- * Offset Storage
- */
- private OffsetStore offsetStore;
- /**
- * Topic set you want to register
- */
- private Set<String> registerTopics = new HashSet<String>();
- /**
- * Queue allocation algorithm
- */
- private AllocateMessageQueueStrategy allocateMessageQueueStrategy = new AllocateMessageQueueAveragely();
- /**
- * Whether the unit of subscription group
- */
- private boolean unitMode = false;
-
- private int maxReconsumeTimes = 16;
-
-
- public DefaultMQPullConsumer() {
- this(MixAll.DEFAULT_CONSUMER_GROUP, null);
- }
-
-
- public DefaultMQPullConsumer(final String consumerGroup, RPCHook rpcHook) {
- this.consumerGroup = consumerGroup;
- defaultMQPullConsumerImpl = new DefaultMQPullConsumerImpl(this, rpcHook);
- }
-
-
- public DefaultMQPullConsumer(final String consumerGroup) {
- this(consumerGroup, null);
- }
-
-
- public DefaultMQPullConsumer(RPCHook rpcHook) {
- this(MixAll.DEFAULT_CONSUMER_GROUP, rpcHook);
- }
-
- @Override
- public void createTopic(String key, String newTopic, int queueNum) throws MQClientException {
- createTopic(key, newTopic, queueNum, 0);
- }
-
-
- @Override
- public void createTopic(String key, String newTopic, int queueNum, int topicSysFlag) throws MQClientException {
- this.defaultMQPullConsumerImpl.createTopic(key, newTopic, queueNum, topicSysFlag);
- }
-
-
- @Override
- public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
- return this.defaultMQPullConsumerImpl.searchOffset(mq, timestamp);
- }
-
-
- @Override
- public long maxOffset(MessageQueue mq) throws MQClientException {
- return this.defaultMQPullConsumerImpl.maxOffset(mq);
- }
-
-
- @Override
- public long minOffset(MessageQueue mq) throws MQClientException {
- return this.defaultMQPullConsumerImpl.minOffset(mq);
- }
-
-
- @Override
- public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
- return this.defaultMQPullConsumerImpl.earliestMsgStoreTime(mq);
- }
-
-
- @Override
- public MessageExt viewMessage(String offsetMsgId) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException {
- return this.defaultMQPullConsumerImpl.viewMessage(offsetMsgId);
- }
-
-
- @Override
- public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
- throws MQClientException, InterruptedException {
- return this.defaultMQPullConsumerImpl.queryMessage(topic, key, maxNum, begin, end);
- }
-
-
- public AllocateMessageQueueStrategy getAllocateMessageQueueStrategy() {
- return allocateMessageQueueStrategy;
- }
-
-
- public void setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy allocateMessageQueueStrategy) {
- this.allocateMessageQueueStrategy = allocateMessageQueueStrategy;
- }
-
-
- public long getBrokerSuspendMaxTimeMillis() {
- return brokerSuspendMaxTimeMillis;
- }
-
-
- public void setBrokerSuspendMaxTimeMillis(long brokerSuspendMaxTimeMillis) {
- this.brokerSuspendMaxTimeMillis = brokerSuspendMaxTimeMillis;
- }
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
-
- public long getConsumerPullTimeoutMillis() {
- return consumerPullTimeoutMillis;
- }
-
-
- public void setConsumerPullTimeoutMillis(long consumerPullTimeoutMillis) {
- this.consumerPullTimeoutMillis = consumerPullTimeoutMillis;
- }
-
-
- public long getConsumerTimeoutMillisWhenSuspend() {
- return consumerTimeoutMillisWhenSuspend;
- }
-
-
- public void setConsumerTimeoutMillisWhenSuspend(long consumerTimeoutMillisWhenSuspend) {
- this.consumerTimeoutMillisWhenSuspend = consumerTimeoutMillisWhenSuspend;
- }
-
-
- public MessageModel getMessageModel() {
- return messageModel;
- }
-
-
- public void setMessageModel(MessageModel messageModel) {
- this.messageModel = messageModel;
- }
-
-
- public MessageQueueListener getMessageQueueListener() {
- return messageQueueListener;
- }
-
-
- public void setMessageQueueListener(MessageQueueListener messageQueueListener) {
- this.messageQueueListener = messageQueueListener;
- }
-
-
- public Set<String> getRegisterTopics() {
- return registerTopics;
- }
-
-
- public void setRegisterTopics(Set<String> registerTopics) {
- this.registerTopics = registerTopics;
- }
-
-
- @Override
- public void sendMessageBack(MessageExt msg, int delayLevel)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- this.defaultMQPullConsumerImpl.sendMessageBack(msg, delayLevel, null);
- }
-
-
- @Override
- public void sendMessageBack(MessageExt msg, int delayLevel, String brokerName)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- this.defaultMQPullConsumerImpl.sendMessageBack(msg, delayLevel, brokerName);
- }
-
- @Override
- public Set<MessageQueue> fetchSubscribeMessageQueues(String topic) throws MQClientException {
- return this.defaultMQPullConsumerImpl.fetchSubscribeMessageQueues(topic);
- }
-
- @Override
- public void start() throws MQClientException {
- this.defaultMQPullConsumerImpl.start();
- }
-
- @Override
- public void shutdown() {
- this.defaultMQPullConsumerImpl.shutdown();
- }
-
- @Override
- public void registerMessageQueueListener(String topic, MessageQueueListener listener) {
- synchronized (this.registerTopics) {
- this.registerTopics.add(topic);
- if (listener != null) {
- this.messageQueueListener = listener;
- }
- }
- }
-
- @Override
- public PullResult pull(MessageQueue mq, String subExpression, long offset, int maxNums)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- return this.defaultMQPullConsumerImpl.pull(mq, subExpression, offset, maxNums);
- }
-
- @Override
- public PullResult pull(MessageQueue mq, String subExpression, long offset, int maxNums, long timeout)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- return this.defaultMQPullConsumerImpl.pull(mq, subExpression, offset, maxNums, timeout);
- }
-
- @Override
- public void pull(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback)
- throws MQClientException, RemotingException, InterruptedException {
- this.defaultMQPullConsumerImpl.pull(mq, subExpression, offset, maxNums, pullCallback);
- }
-
- @Override
- public void pull(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback, long timeout)
- throws MQClientException, RemotingException, InterruptedException {
- this.defaultMQPullConsumerImpl.pull(mq, subExpression, offset, maxNums, pullCallback, timeout);
- }
-
- @Override
- public PullResult pullBlockIfNotFound(MessageQueue mq, String subExpression, long offset, int maxNums)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
- return this.defaultMQPullConsumerImpl.pullBlockIfNotFound(mq, subExpression, offset, maxNums);
- }
-
- @Override
- public void pullBlockIfNotFound(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback)
- throws MQClientException, RemotingException, InterruptedException {
- this.defaultMQPullConsumerImpl.pullBlockIfNotFound(mq, subExpression, offset, maxNums, pullCallback);
- }
-
- @Override
- public void updateConsumeOffset(MessageQueue mq, long offset) throws MQClientException {
- this.defaultMQPullConsumerImpl.updateConsumeOffset(mq, offset);
- }
-
- @Override
- public long fetchConsumeOffset(MessageQueue mq, boolean fromStore) throws MQClientException {
- return this.defaultMQPullConsumerImpl.fetchConsumeOffset(mq, fromStore);
- }
-
- @Override
- public Set<MessageQueue> fetchMessageQueuesInBalance(String topic) throws MQClientException {
- return this.defaultMQPullConsumerImpl.fetchMessageQueuesInBalance(topic);
- }
-
- @Override
- public MessageExt viewMessage(String topic, String uniqKey) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- try {
- MessageDecoder.decodeMessageId(uniqKey);
- return this.viewMessage(uniqKey);
- } catch (Exception e) {
- }
- return this.defaultMQPullConsumerImpl.queryMessageByUniqKey(topic, uniqKey);
- }
-
- @Override
- public void sendMessageBack(MessageExt msg, int delayLevel, String brokerName, String consumerGroup)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- this.defaultMQPullConsumerImpl.sendMessageBack(msg, delayLevel, brokerName, consumerGroup);
- }
-
- public OffsetStore getOffsetStore() {
- return offsetStore;
- }
-
-
- public void setOffsetStore(OffsetStore offsetStore) {
- this.offsetStore = offsetStore;
- }
-
-
- public DefaultMQPullConsumerImpl getDefaultMQPullConsumerImpl() {
- return defaultMQPullConsumerImpl;
- }
-
-
- public boolean isUnitMode() {
- return unitMode;
- }
-
-
- public void setUnitMode(boolean isUnitMode) {
- this.unitMode = isUnitMode;
- }
-
-
- public int getMaxReconsumeTimes() {
- return maxReconsumeTimes;
- }
-
-
- public void setMaxReconsumeTimes(final int maxReconsumeTimes) {
- this.maxReconsumeTimes = maxReconsumeTimes;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/DefaultMQPushConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/DefaultMQPushConsumer.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/DefaultMQPushConsumer.java
deleted file mode 100644
index f37e982..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/DefaultMQPushConsumer.java
+++ /dev/null
@@ -1,519 +0,0 @@
-/**
- * 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.client.consumer;
-
-import com.alibaba.rocketmq.client.ClientConfig;
-import com.alibaba.rocketmq.client.QueryResult;
-import com.alibaba.rocketmq.client.consumer.listener.MessageListener;
-import com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
-import com.alibaba.rocketmq.client.consumer.listener.MessageListenerOrderly;
-import com.alibaba.rocketmq.client.consumer.rebalance.AllocateMessageQueueAveragely;
-import com.alibaba.rocketmq.client.consumer.store.OffsetStore;
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.consumer.ConsumeFromWhere;
-import com.alibaba.rocketmq.common.message.MessageDecoder;
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.heartbeat.MessageModel;
-import com.alibaba.rocketmq.remoting.RPCHook;
-import com.alibaba.rocketmq.remoting.exception.RemotingException;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-
-/**
- * Wrapped push consumer.in fact,it works as remarkable as the pull consumer
- *
- * @author shijia.wxr
- */
-public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsumer {
- protected final transient DefaultMQPushConsumerImpl defaultMQPushConsumerImpl;
- /**
- * Do the same thing for the same Group, the application must be set,and
- * guarantee Globally unique
- */
- private String consumerGroup;
- /**
- * Consumption pattern,default is clustering
- */
- private MessageModel messageModel = MessageModel.CLUSTERING;
- /**
- * Consumption offset
- */
- private ConsumeFromWhere consumeFromWhere = ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET;
- /**
- * Backtracking consumption time with second precision.time format is
- * 20131223171201<br>
- * Implying Seventeen twelve and 01 seconds on December 23, 2013 year<br>
- * Default backtracking consumption time Half an hour ago
- */
- private String consumeTimestamp = UtilAll.timeMillisToHumanString3(System.currentTimeMillis() - (1000 * 60 * 30));
- /**
- * Queue allocation algorithm
- */
- private AllocateMessageQueueStrategy allocateMessageQueueStrategy;
-
- /**
- * Subscription relationship
- */
- private Map<String /* topic */, String /* sub expression */> subscription = new HashMap<String, String>();
- /**
- * Message listener
- */
- private MessageListener messageListener;
- /**
- * Offset Storage
- */
- private OffsetStore offsetStore;
- /**
- * Minimum consumer thread number
- */
- private int consumeThreadMin = 20;
- /**
- * Max consumer thread number
- */
- private int consumeThreadMax = 64;
-
- /**
- * Threshold for dynamic adjustment of the number of thread pool
- */
- private long adjustThreadPoolNumsThreshold = 100000;
-
- /**
- * Concurrently max span offset.it has no effect on sequential consumption
- */
- private int consumeConcurrentlyMaxSpan = 2000;
- /**
- * Flow control threshold
- */
- private int pullThresholdForQueue = 1000;
- /**
- * Message pull Interval
- */
- private long pullInterval = 0;
- /**
- * Batch consumption size
- */
- private int consumeMessageBatchMaxSize = 1;
- /**
- * Batch pull size
- */
- private int pullBatchSize = 32;
-
- /**
- * Whether update subscription relationship when every pull
- */
- private boolean postSubscriptionWhenPull = false;
-
- /**
- * Whether the unit of subscription group
- */
- private boolean unitMode = false;
-
- private int maxReconsumeTimes = -1;
- private long suspendCurrentQueueTimeMillis = 1000;
- private long consumeTimeout = 15;
-
-
- public DefaultMQPushConsumer() {
- this(MixAll.DEFAULT_CONSUMER_GROUP, null, new AllocateMessageQueueAveragely());
- }
-
-
- public DefaultMQPushConsumer(final String consumerGroup, RPCHook rpcHook, AllocateMessageQueueStrategy allocateMessageQueueStrategy) {
- this.consumerGroup = consumerGroup;
- this.allocateMessageQueueStrategy = allocateMessageQueueStrategy;
- defaultMQPushConsumerImpl = new DefaultMQPushConsumerImpl(this, rpcHook);
- }
-
-
- public DefaultMQPushConsumer(RPCHook rpcHook) {
- this(MixAll.DEFAULT_CONSUMER_GROUP, rpcHook, new AllocateMessageQueueAveragely());
- }
-
-
- public DefaultMQPushConsumer(final String consumerGroup) {
- this(consumerGroup, null, new AllocateMessageQueueAveragely());
- }
-
- @Override
- public void createTopic(String key, String newTopic, int queueNum) throws MQClientException {
- createTopic(key, newTopic, queueNum, 0);
- }
-
-
- @Override
- public void createTopic(String key, String newTopic, int queueNum, int topicSysFlag) throws MQClientException {
- this.defaultMQPushConsumerImpl.createTopic(key, newTopic, queueNum, topicSysFlag);
- }
-
-
- @Override
- public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
- return this.defaultMQPushConsumerImpl.searchOffset(mq, timestamp);
- }
-
-
- @Override
- public long maxOffset(MessageQueue mq) throws MQClientException {
- return this.defaultMQPushConsumerImpl.maxOffset(mq);
- }
-
-
- @Override
- public long minOffset(MessageQueue mq) throws MQClientException {
- return this.defaultMQPushConsumerImpl.minOffset(mq);
- }
-
-
- @Override
- public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
- return this.defaultMQPushConsumerImpl.earliestMsgStoreTime(mq);
- }
-
-
- @Override
- public MessageExt viewMessage(String offsetMsgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- return this.defaultMQPushConsumerImpl.viewMessage(offsetMsgId);
- }
-
-
- @Override
- public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
- throws MQClientException, InterruptedException {
- return this.defaultMQPushConsumerImpl.queryMessage(topic, key, maxNum, begin, end);
- }
-
- @Override
- public MessageExt viewMessage(String topic, String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- try {
- MessageDecoder.decodeMessageId(msgId);
- return this.viewMessage(msgId);
- } catch (Exception e) {
- }
- return this.defaultMQPushConsumerImpl.queryMessageByUniqKey(topic, msgId);
- }
-
- public AllocateMessageQueueStrategy getAllocateMessageQueueStrategy() {
- return allocateMessageQueueStrategy;
- }
-
-
- public void setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy allocateMessageQueueStrategy) {
- this.allocateMessageQueueStrategy = allocateMessageQueueStrategy;
- }
-
-
- public int getConsumeConcurrentlyMaxSpan() {
- return consumeConcurrentlyMaxSpan;
- }
-
-
- public void setConsumeConcurrentlyMaxSpan(int consumeConcurrentlyMaxSpan) {
- this.consumeConcurrentlyMaxSpan = consumeConcurrentlyMaxSpan;
- }
-
-
- public ConsumeFromWhere getConsumeFromWhere() {
- return consumeFromWhere;
- }
-
-
- public void setConsumeFromWhere(ConsumeFromWhere consumeFromWhere) {
- this.consumeFromWhere = consumeFromWhere;
- }
-
-
- public int getConsumeMessageBatchMaxSize() {
- return consumeMessageBatchMaxSize;
- }
-
-
- public void setConsumeMessageBatchMaxSize(int consumeMessageBatchMaxSize) {
- this.consumeMessageBatchMaxSize = consumeMessageBatchMaxSize;
- }
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
-
- public int getConsumeThreadMax() {
- return consumeThreadMax;
- }
-
-
- public void setConsumeThreadMax(int consumeThreadMax) {
- this.consumeThreadMax = consumeThreadMax;
- }
-
-
- public int getConsumeThreadMin() {
- return consumeThreadMin;
- }
-
-
- public void setConsumeThreadMin(int consumeThreadMin) {
- this.consumeThreadMin = consumeThreadMin;
- }
-
-
- public DefaultMQPushConsumerImpl getDefaultMQPushConsumerImpl() {
- return defaultMQPushConsumerImpl;
- }
-
-
- public MessageListener getMessageListener() {
- return messageListener;
- }
-
-
- public void setMessageListener(MessageListener messageListener) {
- this.messageListener = messageListener;
- }
-
-
- public MessageModel getMessageModel() {
- return messageModel;
- }
-
-
- public void setMessageModel(MessageModel messageModel) {
- this.messageModel = messageModel;
- }
-
-
- public int getPullBatchSize() {
- return pullBatchSize;
- }
-
-
- public void setPullBatchSize(int pullBatchSize) {
- this.pullBatchSize = pullBatchSize;
- }
-
-
- public long getPullInterval() {
- return pullInterval;
- }
-
-
- public void setPullInterval(long pullInterval) {
- this.pullInterval = pullInterval;
- }
-
-
- public int getPullThresholdForQueue() {
- return pullThresholdForQueue;
- }
-
-
- public void setPullThresholdForQueue(int pullThresholdForQueue) {
- this.pullThresholdForQueue = pullThresholdForQueue;
- }
-
-
- public Map<String, String> getSubscription() {
- return subscription;
- }
-
-
- public void setSubscription(Map<String, String> subscription) {
- this.subscription = subscription;
- }
-
-
- @Override
- public void sendMessageBack(MessageExt msg, int delayLevel)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- this.defaultMQPushConsumerImpl.sendMessageBack(msg, delayLevel, null);
- }
-
-
- @Override
- public void sendMessageBack(MessageExt msg, int delayLevel, String brokerName)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- this.defaultMQPushConsumerImpl.sendMessageBack(msg, delayLevel, brokerName);
- }
-
-
- @Override
- public Set<MessageQueue> fetchSubscribeMessageQueues(String topic) throws MQClientException {
- return this.defaultMQPushConsumerImpl.fetchSubscribeMessageQueues(topic);
- }
-
-
- @Override
- public void start() throws MQClientException {
- this.defaultMQPushConsumerImpl.start();
- }
-
-
- @Override
- public void shutdown() {
- this.defaultMQPushConsumerImpl.shutdown();
- }
-
-
- @Override
- @Deprecated
- public void registerMessageListener(MessageListener messageListener) {
- this.messageListener = messageListener;
- this.defaultMQPushConsumerImpl.registerMessageListener(messageListener);
- }
-
-
- @Override
- public void registerMessageListener(MessageListenerConcurrently messageListener) {
- this.messageListener = messageListener;
- this.defaultMQPushConsumerImpl.registerMessageListener(messageListener);
- }
-
-
- @Override
- public void registerMessageListener(MessageListenerOrderly messageListener) {
- this.messageListener = messageListener;
- this.defaultMQPushConsumerImpl.registerMessageListener(messageListener);
- }
-
-
- @Override
- public void subscribe(String topic, String subExpression) throws MQClientException {
- this.defaultMQPushConsumerImpl.subscribe(topic, subExpression);
- }
-
-
- @Override
- public void subscribe(String topic, String fullClassName, String filterClassSource) throws MQClientException {
- this.defaultMQPushConsumerImpl.subscribe(topic, fullClassName, filterClassSource);
- }
-
-
- @Override
- public void unsubscribe(String topic) {
- this.defaultMQPushConsumerImpl.unsubscribe(topic);
- }
-
-
- @Override
- public void updateCorePoolSize(int corePoolSize) {
- this.defaultMQPushConsumerImpl.updateCorePoolSize(corePoolSize);
- }
-
-
- @Override
- public void suspend() {
- this.defaultMQPushConsumerImpl.suspend();
- }
-
-
- @Override
- public void resume() {
- this.defaultMQPushConsumerImpl.resume();
- }
-
-
- public OffsetStore getOffsetStore() {
- return offsetStore;
- }
-
-
- public void setOffsetStore(OffsetStore offsetStore) {
- this.offsetStore = offsetStore;
- }
-
-
- public String getConsumeTimestamp() {
- return consumeTimestamp;
- }
-
-
- public void setConsumeTimestamp(String consumeTimestamp) {
- this.consumeTimestamp = consumeTimestamp;
- }
-
-
- public boolean isPostSubscriptionWhenPull() {
- return postSubscriptionWhenPull;
- }
-
-
- public void setPostSubscriptionWhenPull(boolean postSubscriptionWhenPull) {
- this.postSubscriptionWhenPull = postSubscriptionWhenPull;
- }
-
-
- public boolean isUnitMode() {
- return unitMode;
- }
-
-
- public void setUnitMode(boolean isUnitMode) {
- this.unitMode = isUnitMode;
- }
-
-
- public long getAdjustThreadPoolNumsThreshold() {
- return adjustThreadPoolNumsThreshold;
- }
-
-
- public void setAdjustThreadPoolNumsThreshold(long adjustThreadPoolNumsThreshold) {
- this.adjustThreadPoolNumsThreshold = adjustThreadPoolNumsThreshold;
- }
-
-
- public int getMaxReconsumeTimes() {
- return maxReconsumeTimes;
- }
-
-
- public void setMaxReconsumeTimes(final int maxReconsumeTimes) {
- this.maxReconsumeTimes = maxReconsumeTimes;
- }
-
-
- public long getSuspendCurrentQueueTimeMillis() {
- return suspendCurrentQueueTimeMillis;
- }
-
-
- public void setSuspendCurrentQueueTimeMillis(final long suspendCurrentQueueTimeMillis) {
- this.suspendCurrentQueueTimeMillis = suspendCurrentQueueTimeMillis;
- }
-
-
- public long getConsumeTimeout() {
- return consumeTimeout;
- }
-
- public void setConsumeTimeout(final long consumeTimeout) {
- this.consumeTimeout = consumeTimeout;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/consumer/MQConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/consumer/MQConsumer.java b/client/src/main/java/com/alibaba/rocketmq/client/consumer/MQConsumer.java
deleted file mode 100644
index 2a46b65..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/consumer/MQConsumer.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * 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.client.consumer;
-
-import com.alibaba.rocketmq.client.MQAdmin;
-import com.alibaba.rocketmq.client.exception.MQBrokerException;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.common.message.MessageExt;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.remoting.exception.RemotingException;
-
-import java.util.Set;
-
-
-/**
- * Message queue consumer interface
- *
- * @author shijia.wxr
- */
-public interface MQConsumer extends MQAdmin {
- /**
- * If consuming failure,message will be send back to the brokers,and delay consuming some time
- *
- * @param msg
- * @param delayLevel
- *
- * @throws InterruptedException
- * @throws MQBrokerException
- * @throws RemotingException
- * @throws MQClientException
- */
- @Deprecated
- void sendMessageBack(final MessageExt msg, final int delayLevel) throws RemotingException,
- MQBrokerException, InterruptedException, MQClientException;
-
-
- /**
- * If consuming failure,message will be send back to the broker,and delay consuming some time
- *
- * @param msg
- * @param delayLevel
- * @param brokerName
- *
- * @throws RemotingException
- * @throws MQBrokerException
- * @throws InterruptedException
- * @throws MQClientException
- */
- void sendMessageBack(final MessageExt msg, final int delayLevel, final String brokerName)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
-
-
- /**
- * Fetch message queues from consumer cache according to the topic
- *
- * @param topic
- * message topic
- *
- * @return queue set
- *
- * @throws MQClientException
- */
- Set<MessageQueue> fetchSubscribeMessageQueues(final String topic) throws MQClientException;
-}
[29/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
new file mode 100644
index 0000000..c4e91a3
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
@@ -0,0 +1,381 @@
+/**
+ * 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.consumer;
+
+import org.apache.rocketmq.client.ClientConfig;
+import org.apache.rocketmq.client.QueryResult;
+import org.apache.rocketmq.client.consumer.rebalance.AllocateMessageQueueAveragely;
+import org.apache.rocketmq.client.consumer.store.OffsetStore;
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.impl.consumer.DefaultMQPullConsumerImpl;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.message.MessageDecoder;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+
+import java.util.HashSet;
+import java.util.Set;
+
+
+/**
+ * Default pulling consumer
+ *
+ * @author shijia.wxr
+ */
+public class DefaultMQPullConsumer extends ClientConfig implements MQPullConsumer {
+ protected final transient DefaultMQPullConsumerImpl defaultMQPullConsumerImpl;
+
+ /**
+ * Do the same thing for the same Group, the application must be set,and
+ * guarantee Globally unique
+ */
+ private String consumerGroup;
+ /**
+ * Long polling mode, the Consumer connection max suspend time, it is not
+ * recommended to modify
+ */
+ private long brokerSuspendMaxTimeMillis = 1000 * 20;
+ /**
+ * Long polling mode, the Consumer connection timeout(must greater than
+ * brokerSuspendMaxTimeMillis), it is not recommended to modify
+ */
+ private long consumerTimeoutMillisWhenSuspend = 1000 * 30;
+ /**
+ * The socket timeout in milliseconds
+ */
+ private long consumerPullTimeoutMillis = 1000 * 10;
+ /**
+ * Consumption pattern,default is clustering
+ */
+ private MessageModel messageModel = MessageModel.CLUSTERING;
+ /**
+ * Message queue listener
+ */
+ private MessageQueueListener messageQueueListener;
+ /**
+ * Offset Storage
+ */
+ private OffsetStore offsetStore;
+ /**
+ * Topic set you want to register
+ */
+ private Set<String> registerTopics = new HashSet<String>();
+ /**
+ * Queue allocation algorithm
+ */
+ private AllocateMessageQueueStrategy allocateMessageQueueStrategy = new AllocateMessageQueueAveragely();
+ /**
+ * Whether the unit of subscription group
+ */
+ private boolean unitMode = false;
+
+ private int maxReconsumeTimes = 16;
+
+
+ public DefaultMQPullConsumer() {
+ this(MixAll.DEFAULT_CONSUMER_GROUP, null);
+ }
+
+
+ public DefaultMQPullConsumer(final String consumerGroup, RPCHook rpcHook) {
+ this.consumerGroup = consumerGroup;
+ defaultMQPullConsumerImpl = new DefaultMQPullConsumerImpl(this, rpcHook);
+ }
+
+
+ public DefaultMQPullConsumer(final String consumerGroup) {
+ this(consumerGroup, null);
+ }
+
+
+ public DefaultMQPullConsumer(RPCHook rpcHook) {
+ this(MixAll.DEFAULT_CONSUMER_GROUP, rpcHook);
+ }
+
+ @Override
+ public void createTopic(String key, String newTopic, int queueNum) throws MQClientException {
+ createTopic(key, newTopic, queueNum, 0);
+ }
+
+
+ @Override
+ public void createTopic(String key, String newTopic, int queueNum, int topicSysFlag) throws MQClientException {
+ this.defaultMQPullConsumerImpl.createTopic(key, newTopic, queueNum, topicSysFlag);
+ }
+
+
+ @Override
+ public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
+ return this.defaultMQPullConsumerImpl.searchOffset(mq, timestamp);
+ }
+
+
+ @Override
+ public long maxOffset(MessageQueue mq) throws MQClientException {
+ return this.defaultMQPullConsumerImpl.maxOffset(mq);
+ }
+
+
+ @Override
+ public long minOffset(MessageQueue mq) throws MQClientException {
+ return this.defaultMQPullConsumerImpl.minOffset(mq);
+ }
+
+
+ @Override
+ public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
+ return this.defaultMQPullConsumerImpl.earliestMsgStoreTime(mq);
+ }
+
+
+ @Override
+ public MessageExt viewMessage(String offsetMsgId) throws RemotingException, MQBrokerException,
+ InterruptedException, MQClientException {
+ return this.defaultMQPullConsumerImpl.viewMessage(offsetMsgId);
+ }
+
+
+ @Override
+ public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
+ throws MQClientException, InterruptedException {
+ return this.defaultMQPullConsumerImpl.queryMessage(topic, key, maxNum, begin, end);
+ }
+
+
+ public AllocateMessageQueueStrategy getAllocateMessageQueueStrategy() {
+ return allocateMessageQueueStrategy;
+ }
+
+
+ public void setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy allocateMessageQueueStrategy) {
+ this.allocateMessageQueueStrategy = allocateMessageQueueStrategy;
+ }
+
+
+ public long getBrokerSuspendMaxTimeMillis() {
+ return brokerSuspendMaxTimeMillis;
+ }
+
+
+ public void setBrokerSuspendMaxTimeMillis(long brokerSuspendMaxTimeMillis) {
+ this.brokerSuspendMaxTimeMillis = brokerSuspendMaxTimeMillis;
+ }
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+
+ public long getConsumerPullTimeoutMillis() {
+ return consumerPullTimeoutMillis;
+ }
+
+
+ public void setConsumerPullTimeoutMillis(long consumerPullTimeoutMillis) {
+ this.consumerPullTimeoutMillis = consumerPullTimeoutMillis;
+ }
+
+
+ public long getConsumerTimeoutMillisWhenSuspend() {
+ return consumerTimeoutMillisWhenSuspend;
+ }
+
+
+ public void setConsumerTimeoutMillisWhenSuspend(long consumerTimeoutMillisWhenSuspend) {
+ this.consumerTimeoutMillisWhenSuspend = consumerTimeoutMillisWhenSuspend;
+ }
+
+
+ public MessageModel getMessageModel() {
+ return messageModel;
+ }
+
+
+ public void setMessageModel(MessageModel messageModel) {
+ this.messageModel = messageModel;
+ }
+
+
+ public MessageQueueListener getMessageQueueListener() {
+ return messageQueueListener;
+ }
+
+
+ public void setMessageQueueListener(MessageQueueListener messageQueueListener) {
+ this.messageQueueListener = messageQueueListener;
+ }
+
+
+ public Set<String> getRegisterTopics() {
+ return registerTopics;
+ }
+
+
+ public void setRegisterTopics(Set<String> registerTopics) {
+ this.registerTopics = registerTopics;
+ }
+
+
+ @Override
+ public void sendMessageBack(MessageExt msg, int delayLevel)
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ this.defaultMQPullConsumerImpl.sendMessageBack(msg, delayLevel, null);
+ }
+
+
+ @Override
+ public void sendMessageBack(MessageExt msg, int delayLevel, String brokerName)
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ this.defaultMQPullConsumerImpl.sendMessageBack(msg, delayLevel, brokerName);
+ }
+
+ @Override
+ public Set<MessageQueue> fetchSubscribeMessageQueues(String topic) throws MQClientException {
+ return this.defaultMQPullConsumerImpl.fetchSubscribeMessageQueues(topic);
+ }
+
+ @Override
+ public void start() throws MQClientException {
+ this.defaultMQPullConsumerImpl.start();
+ }
+
+ @Override
+ public void shutdown() {
+ this.defaultMQPullConsumerImpl.shutdown();
+ }
+
+ @Override
+ public void registerMessageQueueListener(String topic, MessageQueueListener listener) {
+ synchronized (this.registerTopics) {
+ this.registerTopics.add(topic);
+ if (listener != null) {
+ this.messageQueueListener = listener;
+ }
+ }
+ }
+
+ @Override
+ public PullResult pull(MessageQueue mq, String subExpression, long offset, int maxNums)
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ return this.defaultMQPullConsumerImpl.pull(mq, subExpression, offset, maxNums);
+ }
+
+ @Override
+ public PullResult pull(MessageQueue mq, String subExpression, long offset, int maxNums, long timeout)
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ return this.defaultMQPullConsumerImpl.pull(mq, subExpression, offset, maxNums, timeout);
+ }
+
+ @Override
+ public void pull(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback)
+ throws MQClientException, RemotingException, InterruptedException {
+ this.defaultMQPullConsumerImpl.pull(mq, subExpression, offset, maxNums, pullCallback);
+ }
+
+ @Override
+ public void pull(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback, long timeout)
+ throws MQClientException, RemotingException, InterruptedException {
+ this.defaultMQPullConsumerImpl.pull(mq, subExpression, offset, maxNums, pullCallback, timeout);
+ }
+
+ @Override
+ public PullResult pullBlockIfNotFound(MessageQueue mq, String subExpression, long offset, int maxNums)
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ return this.defaultMQPullConsumerImpl.pullBlockIfNotFound(mq, subExpression, offset, maxNums);
+ }
+
+ @Override
+ public void pullBlockIfNotFound(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback)
+ throws MQClientException, RemotingException, InterruptedException {
+ this.defaultMQPullConsumerImpl.pullBlockIfNotFound(mq, subExpression, offset, maxNums, pullCallback);
+ }
+
+ @Override
+ public void updateConsumeOffset(MessageQueue mq, long offset) throws MQClientException {
+ this.defaultMQPullConsumerImpl.updateConsumeOffset(mq, offset);
+ }
+
+ @Override
+ public long fetchConsumeOffset(MessageQueue mq, boolean fromStore) throws MQClientException {
+ return this.defaultMQPullConsumerImpl.fetchConsumeOffset(mq, fromStore);
+ }
+
+ @Override
+ public Set<MessageQueue> fetchMessageQueuesInBalance(String topic) throws MQClientException {
+ return this.defaultMQPullConsumerImpl.fetchMessageQueuesInBalance(topic);
+ }
+
+ @Override
+ public MessageExt viewMessage(String topic, String uniqKey) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ try {
+ MessageDecoder.decodeMessageId(uniqKey);
+ return this.viewMessage(uniqKey);
+ } catch (Exception e) {
+ }
+ return this.defaultMQPullConsumerImpl.queryMessageByUniqKey(topic, uniqKey);
+ }
+
+ @Override
+ public void sendMessageBack(MessageExt msg, int delayLevel, String brokerName, String consumerGroup)
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ this.defaultMQPullConsumerImpl.sendMessageBack(msg, delayLevel, brokerName, consumerGroup);
+ }
+
+ public OffsetStore getOffsetStore() {
+ return offsetStore;
+ }
+
+
+ public void setOffsetStore(OffsetStore offsetStore) {
+ this.offsetStore = offsetStore;
+ }
+
+
+ public DefaultMQPullConsumerImpl getDefaultMQPullConsumerImpl() {
+ return defaultMQPullConsumerImpl;
+ }
+
+
+ public boolean isUnitMode() {
+ return unitMode;
+ }
+
+
+ public void setUnitMode(boolean isUnitMode) {
+ this.unitMode = isUnitMode;
+ }
+
+
+ public int getMaxReconsumeTimes() {
+ return maxReconsumeTimes;
+ }
+
+
+ public void setMaxReconsumeTimes(final int maxReconsumeTimes) {
+ this.maxReconsumeTimes = maxReconsumeTimes;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
new file mode 100644
index 0000000..cbed53b
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
@@ -0,0 +1,519 @@
+/**
+ * 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.consumer;
+
+import org.apache.rocketmq.client.ClientConfig;
+import org.apache.rocketmq.client.QueryResult;
+import org.apache.rocketmq.client.consumer.listener.MessageListener;
+import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
+import org.apache.rocketmq.client.consumer.listener.MessageListenerOrderly;
+import org.apache.rocketmq.client.consumer.rebalance.AllocateMessageQueueAveragely;
+import org.apache.rocketmq.client.consumer.store.OffsetStore;
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
+import org.apache.rocketmq.common.message.MessageDecoder;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+
+/**
+ * Wrapped push consumer.in fact,it works as remarkable as the pull consumer
+ *
+ * @author shijia.wxr
+ */
+public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsumer {
+ protected final transient DefaultMQPushConsumerImpl defaultMQPushConsumerImpl;
+ /**
+ * Do the same thing for the same Group, the application must be set,and
+ * guarantee Globally unique
+ */
+ private String consumerGroup;
+ /**
+ * Consumption pattern,default is clustering
+ */
+ private MessageModel messageModel = MessageModel.CLUSTERING;
+ /**
+ * Consumption offset
+ */
+ private ConsumeFromWhere consumeFromWhere = ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET;
+ /**
+ * Backtracking consumption time with second precision.time format is
+ * 20131223171201<br>
+ * Implying Seventeen twelve and 01 seconds on December 23, 2013 year<br>
+ * Default backtracking consumption time Half an hour ago
+ */
+ private String consumeTimestamp = UtilAll.timeMillisToHumanString3(System.currentTimeMillis() - (1000 * 60 * 30));
+ /**
+ * Queue allocation algorithm
+ */
+ private AllocateMessageQueueStrategy allocateMessageQueueStrategy;
+
+ /**
+ * Subscription relationship
+ */
+ private Map<String /* topic */, String /* sub expression */> subscription = new HashMap<String, String>();
+ /**
+ * Message listener
+ */
+ private MessageListener messageListener;
+ /**
+ * Offset Storage
+ */
+ private OffsetStore offsetStore;
+ /**
+ * Minimum consumer thread number
+ */
+ private int consumeThreadMin = 20;
+ /**
+ * Max consumer thread number
+ */
+ private int consumeThreadMax = 64;
+
+ /**
+ * Threshold for dynamic adjustment of the number of thread pool
+ */
+ private long adjustThreadPoolNumsThreshold = 100000;
+
+ /**
+ * Concurrently max span offset.it has no effect on sequential consumption
+ */
+ private int consumeConcurrentlyMaxSpan = 2000;
+ /**
+ * Flow control threshold
+ */
+ private int pullThresholdForQueue = 1000;
+ /**
+ * Message pull Interval
+ */
+ private long pullInterval = 0;
+ /**
+ * Batch consumption size
+ */
+ private int consumeMessageBatchMaxSize = 1;
+ /**
+ * Batch pull size
+ */
+ private int pullBatchSize = 32;
+
+ /**
+ * Whether update subscription relationship when every pull
+ */
+ private boolean postSubscriptionWhenPull = false;
+
+ /**
+ * Whether the unit of subscription group
+ */
+ private boolean unitMode = false;
+
+ private int maxReconsumeTimes = -1;
+ private long suspendCurrentQueueTimeMillis = 1000;
+ private long consumeTimeout = 15;
+
+
+ public DefaultMQPushConsumer() {
+ this(MixAll.DEFAULT_CONSUMER_GROUP, null, new AllocateMessageQueueAveragely());
+ }
+
+
+ public DefaultMQPushConsumer(final String consumerGroup, RPCHook rpcHook, AllocateMessageQueueStrategy allocateMessageQueueStrategy) {
+ this.consumerGroup = consumerGroup;
+ this.allocateMessageQueueStrategy = allocateMessageQueueStrategy;
+ defaultMQPushConsumerImpl = new DefaultMQPushConsumerImpl(this, rpcHook);
+ }
+
+
+ public DefaultMQPushConsumer(RPCHook rpcHook) {
+ this(MixAll.DEFAULT_CONSUMER_GROUP, rpcHook, new AllocateMessageQueueAveragely());
+ }
+
+
+ public DefaultMQPushConsumer(final String consumerGroup) {
+ this(consumerGroup, null, new AllocateMessageQueueAveragely());
+ }
+
+ @Override
+ public void createTopic(String key, String newTopic, int queueNum) throws MQClientException {
+ createTopic(key, newTopic, queueNum, 0);
+ }
+
+
+ @Override
+ public void createTopic(String key, String newTopic, int queueNum, int topicSysFlag) throws MQClientException {
+ this.defaultMQPushConsumerImpl.createTopic(key, newTopic, queueNum, topicSysFlag);
+ }
+
+
+ @Override
+ public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
+ return this.defaultMQPushConsumerImpl.searchOffset(mq, timestamp);
+ }
+
+
+ @Override
+ public long maxOffset(MessageQueue mq) throws MQClientException {
+ return this.defaultMQPushConsumerImpl.maxOffset(mq);
+ }
+
+
+ @Override
+ public long minOffset(MessageQueue mq) throws MQClientException {
+ return this.defaultMQPushConsumerImpl.minOffset(mq);
+ }
+
+
+ @Override
+ public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
+ return this.defaultMQPushConsumerImpl.earliestMsgStoreTime(mq);
+ }
+
+
+ @Override
+ public MessageExt viewMessage(String offsetMsgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ return this.defaultMQPushConsumerImpl.viewMessage(offsetMsgId);
+ }
+
+
+ @Override
+ public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
+ throws MQClientException, InterruptedException {
+ return this.defaultMQPushConsumerImpl.queryMessage(topic, key, maxNum, begin, end);
+ }
+
+ @Override
+ public MessageExt viewMessage(String topic, String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ try {
+ MessageDecoder.decodeMessageId(msgId);
+ return this.viewMessage(msgId);
+ } catch (Exception e) {
+ }
+ return this.defaultMQPushConsumerImpl.queryMessageByUniqKey(topic, msgId);
+ }
+
+ public AllocateMessageQueueStrategy getAllocateMessageQueueStrategy() {
+ return allocateMessageQueueStrategy;
+ }
+
+
+ public void setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy allocateMessageQueueStrategy) {
+ this.allocateMessageQueueStrategy = allocateMessageQueueStrategy;
+ }
+
+
+ public int getConsumeConcurrentlyMaxSpan() {
+ return consumeConcurrentlyMaxSpan;
+ }
+
+
+ public void setConsumeConcurrentlyMaxSpan(int consumeConcurrentlyMaxSpan) {
+ this.consumeConcurrentlyMaxSpan = consumeConcurrentlyMaxSpan;
+ }
+
+
+ public ConsumeFromWhere getConsumeFromWhere() {
+ return consumeFromWhere;
+ }
+
+
+ public void setConsumeFromWhere(ConsumeFromWhere consumeFromWhere) {
+ this.consumeFromWhere = consumeFromWhere;
+ }
+
+
+ public int getConsumeMessageBatchMaxSize() {
+ return consumeMessageBatchMaxSize;
+ }
+
+
+ public void setConsumeMessageBatchMaxSize(int consumeMessageBatchMaxSize) {
+ this.consumeMessageBatchMaxSize = consumeMessageBatchMaxSize;
+ }
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+
+ public int getConsumeThreadMax() {
+ return consumeThreadMax;
+ }
+
+
+ public void setConsumeThreadMax(int consumeThreadMax) {
+ this.consumeThreadMax = consumeThreadMax;
+ }
+
+
+ public int getConsumeThreadMin() {
+ return consumeThreadMin;
+ }
+
+
+ public void setConsumeThreadMin(int consumeThreadMin) {
+ this.consumeThreadMin = consumeThreadMin;
+ }
+
+
+ public DefaultMQPushConsumerImpl getDefaultMQPushConsumerImpl() {
+ return defaultMQPushConsumerImpl;
+ }
+
+
+ public MessageListener getMessageListener() {
+ return messageListener;
+ }
+
+
+ public void setMessageListener(MessageListener messageListener) {
+ this.messageListener = messageListener;
+ }
+
+
+ public MessageModel getMessageModel() {
+ return messageModel;
+ }
+
+
+ public void setMessageModel(MessageModel messageModel) {
+ this.messageModel = messageModel;
+ }
+
+
+ public int getPullBatchSize() {
+ return pullBatchSize;
+ }
+
+
+ public void setPullBatchSize(int pullBatchSize) {
+ this.pullBatchSize = pullBatchSize;
+ }
+
+
+ public long getPullInterval() {
+ return pullInterval;
+ }
+
+
+ public void setPullInterval(long pullInterval) {
+ this.pullInterval = pullInterval;
+ }
+
+
+ public int getPullThresholdForQueue() {
+ return pullThresholdForQueue;
+ }
+
+
+ public void setPullThresholdForQueue(int pullThresholdForQueue) {
+ this.pullThresholdForQueue = pullThresholdForQueue;
+ }
+
+
+ public Map<String, String> getSubscription() {
+ return subscription;
+ }
+
+
+ public void setSubscription(Map<String, String> subscription) {
+ this.subscription = subscription;
+ }
+
+
+ @Override
+ public void sendMessageBack(MessageExt msg, int delayLevel)
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ this.defaultMQPushConsumerImpl.sendMessageBack(msg, delayLevel, null);
+ }
+
+
+ @Override
+ public void sendMessageBack(MessageExt msg, int delayLevel, String brokerName)
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ this.defaultMQPushConsumerImpl.sendMessageBack(msg, delayLevel, brokerName);
+ }
+
+
+ @Override
+ public Set<MessageQueue> fetchSubscribeMessageQueues(String topic) throws MQClientException {
+ return this.defaultMQPushConsumerImpl.fetchSubscribeMessageQueues(topic);
+ }
+
+
+ @Override
+ public void start() throws MQClientException {
+ this.defaultMQPushConsumerImpl.start();
+ }
+
+
+ @Override
+ public void shutdown() {
+ this.defaultMQPushConsumerImpl.shutdown();
+ }
+
+
+ @Override
+ @Deprecated
+ public void registerMessageListener(MessageListener messageListener) {
+ this.messageListener = messageListener;
+ this.defaultMQPushConsumerImpl.registerMessageListener(messageListener);
+ }
+
+
+ @Override
+ public void registerMessageListener(MessageListenerConcurrently messageListener) {
+ this.messageListener = messageListener;
+ this.defaultMQPushConsumerImpl.registerMessageListener(messageListener);
+ }
+
+
+ @Override
+ public void registerMessageListener(MessageListenerOrderly messageListener) {
+ this.messageListener = messageListener;
+ this.defaultMQPushConsumerImpl.registerMessageListener(messageListener);
+ }
+
+
+ @Override
+ public void subscribe(String topic, String subExpression) throws MQClientException {
+ this.defaultMQPushConsumerImpl.subscribe(topic, subExpression);
+ }
+
+
+ @Override
+ public void subscribe(String topic, String fullClassName, String filterClassSource) throws MQClientException {
+ this.defaultMQPushConsumerImpl.subscribe(topic, fullClassName, filterClassSource);
+ }
+
+
+ @Override
+ public void unsubscribe(String topic) {
+ this.defaultMQPushConsumerImpl.unsubscribe(topic);
+ }
+
+
+ @Override
+ public void updateCorePoolSize(int corePoolSize) {
+ this.defaultMQPushConsumerImpl.updateCorePoolSize(corePoolSize);
+ }
+
+
+ @Override
+ public void suspend() {
+ this.defaultMQPushConsumerImpl.suspend();
+ }
+
+
+ @Override
+ public void resume() {
+ this.defaultMQPushConsumerImpl.resume();
+ }
+
+
+ public OffsetStore getOffsetStore() {
+ return offsetStore;
+ }
+
+
+ public void setOffsetStore(OffsetStore offsetStore) {
+ this.offsetStore = offsetStore;
+ }
+
+
+ public String getConsumeTimestamp() {
+ return consumeTimestamp;
+ }
+
+
+ public void setConsumeTimestamp(String consumeTimestamp) {
+ this.consumeTimestamp = consumeTimestamp;
+ }
+
+
+ public boolean isPostSubscriptionWhenPull() {
+ return postSubscriptionWhenPull;
+ }
+
+
+ public void setPostSubscriptionWhenPull(boolean postSubscriptionWhenPull) {
+ this.postSubscriptionWhenPull = postSubscriptionWhenPull;
+ }
+
+
+ public boolean isUnitMode() {
+ return unitMode;
+ }
+
+
+ public void setUnitMode(boolean isUnitMode) {
+ this.unitMode = isUnitMode;
+ }
+
+
+ public long getAdjustThreadPoolNumsThreshold() {
+ return adjustThreadPoolNumsThreshold;
+ }
+
+
+ public void setAdjustThreadPoolNumsThreshold(long adjustThreadPoolNumsThreshold) {
+ this.adjustThreadPoolNumsThreshold = adjustThreadPoolNumsThreshold;
+ }
+
+
+ public int getMaxReconsumeTimes() {
+ return maxReconsumeTimes;
+ }
+
+
+ public void setMaxReconsumeTimes(final int maxReconsumeTimes) {
+ this.maxReconsumeTimes = maxReconsumeTimes;
+ }
+
+
+ public long getSuspendCurrentQueueTimeMillis() {
+ return suspendCurrentQueueTimeMillis;
+ }
+
+
+ public void setSuspendCurrentQueueTimeMillis(final long suspendCurrentQueueTimeMillis) {
+ this.suspendCurrentQueueTimeMillis = suspendCurrentQueueTimeMillis;
+ }
+
+
+ public long getConsumeTimeout() {
+ return consumeTimeout;
+ }
+
+ public void setConsumeTimeout(final long consumeTimeout) {
+ this.consumeTimeout = consumeTimeout;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
new file mode 100644
index 0000000..3e26ed6
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
@@ -0,0 +1,78 @@
+/**
+ * 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.consumer;
+
+import org.apache.rocketmq.client.MQAdmin;
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+
+import java.util.Set;
+
+
+/**
+ * Message queue consumer interface
+ *
+ * @author shijia.wxr
+ */
+public interface MQConsumer extends MQAdmin {
+ /**
+ * If consuming failure,message will be send back to the brokers,and delay consuming some time
+ *
+ * @param msg
+ * @param delayLevel
+ *
+ * @throws InterruptedException
+ * @throws MQBrokerException
+ * @throws RemotingException
+ * @throws MQClientException
+ */
+ @Deprecated
+ void sendMessageBack(final MessageExt msg, final int delayLevel) throws RemotingException,
+ MQBrokerException, InterruptedException, MQClientException;
+
+
+ /**
+ * If consuming failure,message will be send back to the broker,and delay consuming some time
+ *
+ * @param msg
+ * @param delayLevel
+ * @param brokerName
+ *
+ * @throws RemotingException
+ * @throws MQBrokerException
+ * @throws InterruptedException
+ * @throws MQClientException
+ */
+ void sendMessageBack(final MessageExt msg, final int delayLevel, final String brokerName)
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
+
+
+ /**
+ * Fetch message queues from consumer cache according to the topic
+ *
+ * @param topic
+ * message topic
+ *
+ * @return queue set
+ *
+ * @throws MQClientException
+ */
+ Set<MessageQueue> fetchSubscribeMessageQueues(final String topic) throws MQClientException;
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
new file mode 100644
index 0000000..d651562
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
@@ -0,0 +1,229 @@
+/**
+ * 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.consumer;
+
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+
+import java.util.Set;
+
+
+/**
+ * Pulling consumer interface
+ *
+ * @author shijia.wxr
+ */
+public interface MQPullConsumer extends MQConsumer {
+ /**
+ * Start the consumer
+ *
+ * @throws MQClientException
+ */
+ void start() throws MQClientException;
+
+
+ /**
+ * Shutdown the consumer
+ */
+ void shutdown();
+
+
+ /**
+ * Register the message queue listener
+ *
+ * @param topic
+ * @param listener
+ */
+ void registerMessageQueueListener(final String topic, final MessageQueueListener listener);
+
+
+ /**
+ * Pulling the messages,not blocking
+ *
+ * @param mq
+ * from which message queue
+ * @param subExpression
+ * subscription expression.it only support or operation such as "tag1 || tag2 || tag3" <br>
+ * if null or * expression,meaning subscribe all
+ * @param offset
+ * from where to pull
+ * @param maxNums
+ * max pulling numbers
+ *
+ * @return The resulting {@code PullRequest}
+ *
+ * @throws MQClientException
+ * @throws InterruptedException
+ * @throws MQBrokerException
+ * @throws RemotingException
+ */
+ PullResult pull(final MessageQueue mq, final String subExpression, final long offset,
+ final int maxNums) throws MQClientException, RemotingException, MQBrokerException,
+ InterruptedException;
+
+
+ /**
+ * Pulling the messages in the specified timeout
+ *
+ * @param mq
+ * @param subExpression
+ * @param offset
+ * @param maxNums
+ * @param timeout
+ *
+ * @return The resulting {@code PullRequest}
+ *
+ * @throws MQClientException
+ * @throws RemotingException
+ * @throws MQBrokerException
+ * @throws InterruptedException
+ */
+ PullResult pull(final MessageQueue mq, final String subExpression, final long offset,
+ final int maxNums, final long timeout) throws MQClientException, RemotingException,
+ MQBrokerException, InterruptedException;
+
+
+ /**
+ * Pulling the messages in a async. way
+ *
+ * @param mq
+ * @param subExpression
+ * @param offset
+ * @param maxNums
+ * @param pullCallback
+ *
+ * @throws MQClientException
+ * @throws RemotingException
+ * @throws InterruptedException
+ */
+ void pull(final MessageQueue mq, final String subExpression, final long offset, final int maxNums,
+ final PullCallback pullCallback) throws MQClientException, RemotingException,
+ InterruptedException;
+
+ /**
+ * Pulling the messages in a async. way
+ *
+ * @param mq
+ * @param subExpression
+ * @param offset
+ * @param maxNums
+ * @param pullCallback
+ * @param timeout
+ *
+ * @throws MQClientException
+ * @throws RemotingException
+ * @throws InterruptedException
+ */
+ void pull(final MessageQueue mq, final String subExpression, final long offset, final int maxNums,
+ final PullCallback pullCallback, long timeout) throws MQClientException, RemotingException,
+ InterruptedException;
+
+
+ /**
+ * Pulling the messages,if no message arrival,blocking some time
+ *
+ * @param mq
+ * @param subExpression
+ * @param offset
+ * @param maxNums
+ *
+ * @return The resulting {@code PullRequest}
+ *
+ * @throws MQClientException
+ * @throws RemotingException
+ * @throws MQBrokerException
+ * @throws InterruptedException
+ */
+ PullResult pullBlockIfNotFound(final MessageQueue mq, final String subExpression,
+ final long offset, final int maxNums) throws MQClientException, RemotingException,
+ MQBrokerException, InterruptedException;
+
+
+ /**
+ * Pulling the messages through callback function,if no message arrival,blocking.
+ *
+ * @param mq
+ * @param subExpression
+ * @param offset
+ * @param maxNums
+ * @param pullCallback
+ *
+ * @throws MQClientException
+ * @throws RemotingException
+ * @throws InterruptedException
+ */
+ void pullBlockIfNotFound(final MessageQueue mq, final String subExpression, final long offset,
+ final int maxNums, final PullCallback pullCallback) throws MQClientException, RemotingException,
+ InterruptedException;
+
+
+ /**
+ * Update the offset
+ *
+ * @param mq
+ * @param offset
+ *
+ * @throws MQClientException
+ */
+ void updateConsumeOffset(final MessageQueue mq, final long offset) throws MQClientException;
+
+
+ /**
+ * Fetch the offset
+ *
+ * @param mq
+ * @param fromStore
+ *
+ * @return The fetched offset of given queue
+ *
+ * @throws MQClientException
+ */
+ long fetchConsumeOffset(final MessageQueue mq, final boolean fromStore) throws MQClientException;
+
+
+ /**
+ * Fetch the message queues according to the topic
+ *
+ * @param topic
+ * message topic
+ *
+ * @return message queue set
+ *
+ * @throws MQClientException
+ */
+ Set<MessageQueue> fetchMessageQueuesInBalance(final String topic) throws MQClientException;
+
+ /**
+ * If consuming failure,message will be send back to the broker,and delay consuming in some time later.<br>
+ * Mind! message can only be consumed in the same group.
+ *
+ * @param msg
+ * @param delayLevel
+ * @param brokerName
+ * @param consumerGroup
+ *
+ * @throws RemotingException
+ * @throws MQBrokerException
+ * @throws InterruptedException
+ * @throws MQClientException
+ */
+ void sendMessageBack(MessageExt msg, int delayLevel, String brokerName, String consumerGroup)
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java
new file mode 100644
index 0000000..33cc1c9
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java
@@ -0,0 +1,212 @@
+/**
+ * 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.consumer;
+
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.ThreadFactoryImpl;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+import org.slf4j.Logger;
+
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+
+/**
+ * Schedule service for pull consumer
+ *
+ * @author shijia.wxr
+ */
+public class MQPullConsumerScheduleService {
+ private final Logger log = ClientLogger.getLog();
+ private final MessageQueueListener messageQueueListener = new MessageQueueListenerImpl();
+ private final ConcurrentHashMap<MessageQueue, PullTaskImpl> taskTable =
+ new ConcurrentHashMap<MessageQueue, PullTaskImpl>();
+ private DefaultMQPullConsumer defaultMQPullConsumer;
+ private int pullThreadNums = 20;
+ private ConcurrentHashMap<String /* topic */, PullTaskCallback> callbackTable =
+ new ConcurrentHashMap<String, PullTaskCallback>();
+ private ScheduledThreadPoolExecutor scheduledThreadPoolExecutor;
+
+ public MQPullConsumerScheduleService(final String consumerGroup) {
+ this.defaultMQPullConsumer = new DefaultMQPullConsumer(consumerGroup);
+ this.defaultMQPullConsumer.setMessageModel(MessageModel.CLUSTERING);
+ }
+
+ public void putTask(String topic, Set<MessageQueue> mqNewSet) {
+ Iterator<Entry<MessageQueue, PullTaskImpl>> it = this.taskTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<MessageQueue, PullTaskImpl> next = it.next();
+ if (next.getKey().getTopic().equals(topic)) {
+ if (!mqNewSet.contains(next.getKey())) {
+ next.getValue().setCancelled(true);
+ it.remove();
+ }
+ }
+ }
+
+ for (MessageQueue mq : mqNewSet) {
+ if (!this.taskTable.containsKey(mq)) {
+ PullTaskImpl command = new PullTaskImpl(mq);
+ this.taskTable.put(mq, command);
+ this.scheduledThreadPoolExecutor.schedule(command, 0, TimeUnit.MILLISECONDS);
+
+ }
+ }
+ }
+
+ public void start() throws MQClientException {
+ final String group = this.defaultMQPullConsumer.getConsumerGroup();
+ this.scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(
+ this.pullThreadNums,
+ new ThreadFactoryImpl("PullMsgThread-" + group)
+ );
+
+ this.defaultMQPullConsumer.setMessageQueueListener(this.messageQueueListener);
+
+ this.defaultMQPullConsumer.start();
+
+ log.info("MQPullConsumerScheduleService start OK, {} {}",
+ this.defaultMQPullConsumer.getConsumerGroup(), this.callbackTable);
+ }
+
+ public void registerPullTaskCallback(final String topic, final PullTaskCallback callback) {
+ this.callbackTable.put(topic, callback);
+ this.defaultMQPullConsumer.registerMessageQueueListener(topic, null);
+ }
+
+ public void shutdown() {
+ if (this.scheduledThreadPoolExecutor != null) {
+ this.scheduledThreadPoolExecutor.shutdown();
+ }
+
+ if (this.defaultMQPullConsumer != null) {
+ this.defaultMQPullConsumer.shutdown();
+ }
+ }
+
+ public ConcurrentHashMap<String, PullTaskCallback> getCallbackTable() {
+ return callbackTable;
+ }
+
+ public void setCallbackTable(ConcurrentHashMap<String, PullTaskCallback> callbackTable) {
+ this.callbackTable = callbackTable;
+ }
+
+ public int getPullThreadNums() {
+ return pullThreadNums;
+ }
+
+ public void setPullThreadNums(int pullThreadNums) {
+ this.pullThreadNums = pullThreadNums;
+ }
+
+ public DefaultMQPullConsumer getDefaultMQPullConsumer() {
+ return defaultMQPullConsumer;
+ }
+
+ public void setDefaultMQPullConsumer(DefaultMQPullConsumer defaultMQPullConsumer) {
+ this.defaultMQPullConsumer = defaultMQPullConsumer;
+ }
+
+ public MessageModel getMessageModel() {
+ return this.defaultMQPullConsumer.getMessageModel();
+ }
+
+ public void setMessageModel(MessageModel messageModel) {
+ this.defaultMQPullConsumer.setMessageModel(messageModel);
+ }
+
+ class MessageQueueListenerImpl implements MessageQueueListener {
+ @Override
+ public void messageQueueChanged(String topic, Set<MessageQueue> mqAll, Set<MessageQueue> mqDivided) {
+ MessageModel messageModel =
+ MQPullConsumerScheduleService.this.defaultMQPullConsumer.getMessageModel();
+ switch (messageModel) {
+ case BROADCASTING:
+ MQPullConsumerScheduleService.this.putTask(topic, mqAll);
+ break;
+ case CLUSTERING:
+ MQPullConsumerScheduleService.this.putTask(topic, mqDivided);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ class PullTaskImpl implements Runnable {
+ private final MessageQueue messageQueue;
+ private volatile boolean cancelled = false;
+
+
+ public PullTaskImpl(final MessageQueue messageQueue) {
+ this.messageQueue = messageQueue;
+ }
+
+
+ @Override
+ public void run() {
+ String topic = this.messageQueue.getTopic();
+ if (!this.isCancelled()) {
+ PullTaskCallback pullTaskCallback =
+ MQPullConsumerScheduleService.this.callbackTable.get(topic);
+ if (pullTaskCallback != null) {
+ final PullTaskContext context = new PullTaskContext();
+ context.setPullConsumer(MQPullConsumerScheduleService.this.defaultMQPullConsumer);
+ try {
+ pullTaskCallback.doPullTask(this.messageQueue, context);
+ } catch (Throwable e) {
+ context.setPullNextDelayTimeMillis(1000);
+ log.error("doPullTask Exception", e);
+ }
+
+ if (!this.isCancelled()) {
+ MQPullConsumerScheduleService.this.scheduledThreadPoolExecutor.schedule(this,
+ context.getPullNextDelayTimeMillis(), TimeUnit.MILLISECONDS);
+ } else {
+ log.warn("The Pull Task is cancelled after doPullTask, {}", messageQueue);
+ }
+ } else {
+ log.warn("Pull Task Callback not exist , {}", topic);
+ }
+ } else {
+ log.warn("The Pull Task is cancelled, {}", messageQueue);
+ }
+ }
+
+
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+
+ public void setCancelled(boolean cancelled) {
+ this.cancelled = cancelled;
+ }
+
+
+ public MessageQueue getMessageQueue() {
+ return messageQueue;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
new file mode 100644
index 0000000..982c839
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
@@ -0,0 +1,117 @@
+/**
+ * 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.consumer;
+
+import org.apache.rocketmq.client.consumer.listener.MessageListener;
+import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
+import org.apache.rocketmq.client.consumer.listener.MessageListenerOrderly;
+import org.apache.rocketmq.client.exception.MQClientException;
+
+
+/**
+ * Push consumer
+ *
+ * @author shijia.wxr
+ */
+public interface MQPushConsumer extends MQConsumer {
+ /**
+ * Start the consumer
+ *
+ * @throws MQClientException
+ */
+ void start() throws MQClientException;
+
+
+ /**
+ * Shutdown the consumer
+ */
+ void shutdown();
+
+
+ /**
+ * Register the message listener
+ *
+ * @param messageListener
+ */
+ @Deprecated
+ void registerMessageListener(MessageListener messageListener);
+
+
+ void registerMessageListener(final MessageListenerConcurrently messageListener);
+
+
+ void registerMessageListener(final MessageListenerOrderly messageListener);
+
+
+ /**
+ * Subscribe some topic
+ *
+ * @param topic
+ * @param subExpression
+ * subscription expression.it only support or operation such as
+ * "tag1 || tag2 || tag3" <br>
+ * if null or * expression,meaning subscribe all
+ *
+ * @throws MQClientException
+ */
+ void subscribe(final String topic, final String subExpression) throws MQClientException;
+
+
+ /**
+ * Subscribe some topic
+ *
+ * @param topic
+ * @param fullClassName
+ * full class name,must extend
+ * org.apache.rocketmq.common.filter. MessageFilter
+ * @param filterClassSource
+ * class source code,used UTF-8 file encoding,must be responsible
+ * for your code safety
+ *
+ * @throws MQClientException
+ */
+ void subscribe(final String topic, final String fullClassName, final String filterClassSource) throws MQClientException;
+
+
+ /**
+ * Unsubscribe consumption some topic
+ *
+ * @param topic
+ * message topic
+ */
+ void unsubscribe(final String topic);
+
+
+ /**
+ * Update the consumer thread pool size Dynamically
+ *
+ * @param corePoolSize
+ */
+ void updateCorePoolSize(int corePoolSize);
+
+
+ /**
+ * Suspend the consumption
+ */
+ void suspend();
+
+
+ /**
+ * Resume the consumption
+ */
+ void resume();
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
new file mode 100644
index 0000000..e59a3ce
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
@@ -0,0 +1,41 @@
+/**
+ * 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.consumer;
+
+import org.apache.rocketmq.common.message.MessageQueue;
+
+import java.util.Set;
+
+
+/**
+ * A MessageQueueListener is implemented by the application and may be specified when a message queue changed
+ *
+ * @author shijia.wxr
+ * @author vongosling
+ */
+public interface MessageQueueListener {
+ /**
+ * @param topic
+ * message topic
+ * @param mqAll
+ * all queues in this message topic
+ * @param mqDivided
+ * collection of queues,assigned to the current consumer
+ */
+ void messageQueueChanged(final String topic, final Set<MessageQueue> mqAll,
+ final Set<MessageQueue> mqDivided);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
new file mode 100644
index 0000000..2429d5a
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
@@ -0,0 +1,28 @@
+/**
+ * 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.consumer;
+
+/**
+ * Async message pulling interface
+ *
+ * @author shijia.wxr
+ */
+public interface PullCallback {
+ public void onSuccess(final PullResult pullResult);
+
+ public void onException(final Throwable e);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java
new file mode 100644
index 0000000..81dd497
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java
@@ -0,0 +1,82 @@
+/**
+ * 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.consumer;
+
+import org.apache.rocketmq.common.message.MessageExt;
+
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class PullResult {
+ private final PullStatus pullStatus;
+ private final long nextBeginOffset;
+ private final long minOffset;
+ private final long maxOffset;
+ private List<MessageExt> msgFoundList;
+
+
+ public PullResult(PullStatus pullStatus, long nextBeginOffset, long minOffset, long maxOffset,
+ List<MessageExt> msgFoundList) {
+ super();
+ this.pullStatus = pullStatus;
+ this.nextBeginOffset = nextBeginOffset;
+ this.minOffset = minOffset;
+ this.maxOffset = maxOffset;
+ this.msgFoundList = msgFoundList;
+ }
+
+
+ public PullStatus getPullStatus() {
+ return pullStatus;
+ }
+
+
+ public long getNextBeginOffset() {
+ return nextBeginOffset;
+ }
+
+
+ public long getMinOffset() {
+ return minOffset;
+ }
+
+
+ public long getMaxOffset() {
+ return maxOffset;
+ }
+
+
+ public List<MessageExt> getMsgFoundList() {
+ return msgFoundList;
+ }
+
+
+ public void setMsgFoundList(List<MessageExt> msgFoundList) {
+ this.msgFoundList = msgFoundList;
+ }
+
+
+ @Override
+ public String toString() {
+ return "PullResult [pullStatus=" + pullStatus + ", nextBeginOffset=" + nextBeginOffset
+ + ", minOffset=" + minOffset + ", maxOffset=" + maxOffset + ", msgFoundList="
+ + (msgFoundList == null ? 0 : msgFoundList.size()) + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java
new file mode 100644
index 0000000..b63a4c4
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java
@@ -0,0 +1,39 @@
+/**
+ * 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.consumer;
+
+/**
+ * @author shijia.wxr
+ */
+public enum PullStatus {
+ /**
+ * Founded
+ */
+ FOUND,
+ /**
+ * No new message can be pull
+ */
+ NO_NEW_MSG,
+ /**
+ * Filtering results can not match
+ */
+ NO_MATCHED_MSG,
+ /**
+ * Illegal offset,may be too big or too small
+ */
+ OFFSET_ILLEGAL
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskCallback.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskCallback.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskCallback.java
new file mode 100644
index 0000000..f0e9b25
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskCallback.java
@@ -0,0 +1,24 @@
+/**
+ * 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.consumer;
+
+import org.apache.rocketmq.common.message.MessageQueue;
+
+
+public interface PullTaskCallback {
+ public void doPullTask(final MessageQueue mq, final PullTaskContext context);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskContext.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskContext.java
new file mode 100644
index 0000000..ba66a1f
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskContext.java
@@ -0,0 +1,44 @@
+/**
+ * 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.consumer;
+
+public class PullTaskContext {
+
+ private int pullNextDelayTimeMillis = 200;
+
+ private MQPullConsumer pullConsumer;
+
+
+ public int getPullNextDelayTimeMillis() {
+ return pullNextDelayTimeMillis;
+ }
+
+
+ public void setPullNextDelayTimeMillis(int pullNextDelayTimeMillis) {
+ this.pullNextDelayTimeMillis = pullNextDelayTimeMillis;
+ }
+
+
+ public MQPullConsumer getPullConsumer() {
+ return pullConsumer;
+ }
+
+
+ public void setPullConsumer(MQPullConsumer pullConsumer) {
+ this.pullConsumer = pullConsumer;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java
new file mode 100644
index 0000000..03223ba
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java
@@ -0,0 +1,66 @@
+/**
+ * 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.consumer.listener;
+
+import org.apache.rocketmq.common.message.MessageQueue;
+
+
+/**
+ * Consumer concurrent consumption context
+ *
+ * @author shijia.wxr
+ */
+public class ConsumeConcurrentlyContext {
+ private final MessageQueue messageQueue;
+ /**
+ * Message consume retry strategy<br>
+ * -1,no retry,put into DLQ directly<br>
+ * 0,broker control retry frequency<br>
+ * >0,client control retry frequency
+ */
+ private int delayLevelWhenNextConsume = 0;
+ private int ackIndex = Integer.MAX_VALUE;
+
+ public ConsumeConcurrentlyContext(MessageQueue messageQueue) {
+ this.messageQueue = messageQueue;
+ }
+
+
+ public int getDelayLevelWhenNextConsume() {
+ return delayLevelWhenNextConsume;
+ }
+
+
+ public void setDelayLevelWhenNextConsume(int delayLevelWhenNextConsume) {
+ this.delayLevelWhenNextConsume = delayLevelWhenNextConsume;
+ }
+
+
+ public MessageQueue getMessageQueue() {
+ return messageQueue;
+ }
+
+
+ public int getAckIndex() {
+ return ackIndex;
+ }
+
+
+ public void setAckIndex(int ackIndex) {
+ this.ackIndex = ackIndex;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java
new file mode 100644
index 0000000..433ce36
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java
@@ -0,0 +1,31 @@
+/**
+ * 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.consumer.listener;
+
+/**
+ * @author shijia.wxr
+ */
+public enum ConsumeConcurrentlyStatus {
+ /**
+ * Success consumption
+ */
+ CONSUME_SUCCESS,
+ /**
+ * Failure consumption,later try to consume
+ */
+ RECONSUME_LATER;
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
new file mode 100644
index 0000000..2adeb29
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
@@ -0,0 +1,61 @@
+/**
+ * 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.consumer.listener;
+
+import org.apache.rocketmq.common.message.MessageQueue;
+
+
+/**
+ * Consumer Orderly consumption context
+ *
+ * @author shijia.wxr
+ */
+public class ConsumeOrderlyContext {
+ private final MessageQueue messageQueue;
+ private boolean autoCommit = true;
+ private long suspendCurrentQueueTimeMillis = -1;
+
+
+ public ConsumeOrderlyContext(MessageQueue messageQueue) {
+ this.messageQueue = messageQueue;
+ }
+
+
+ public boolean isAutoCommit() {
+ return autoCommit;
+ }
+
+
+ public void setAutoCommit(boolean autoCommit) {
+ this.autoCommit = autoCommit;
+ }
+
+
+ public MessageQueue getMessageQueue() {
+ return messageQueue;
+ }
+
+
+ public long getSuspendCurrentQueueTimeMillis() {
+ return suspendCurrentQueueTimeMillis;
+ }
+
+
+ public void setSuspendCurrentQueueTimeMillis(long suspendCurrentQueueTimeMillis) {
+ this.suspendCurrentQueueTimeMillis = suspendCurrentQueueTimeMillis;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java
new file mode 100644
index 0000000..7da0b1f
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java
@@ -0,0 +1,41 @@
+/**
+ * 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.consumer.listener;
+
+/**
+ * @author shijia.wxr
+ */
+public enum ConsumeOrderlyStatus {
+ /**
+ * Success consumption
+ */
+ SUCCESS,
+ /**
+ * Rollback consumption(only for binlog consumption)
+ */
+ @Deprecated
+ ROLLBACK,
+ /**
+ * Commit offset(only for binlog consumption)
+ */
+ @Deprecated
+ COMMIT,
+ /**
+ * Suspend current queue a moment
+ */
+ SUSPEND_CURRENT_QUEUE_A_MOMENT;
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeReturnType.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeReturnType.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeReturnType.java
new file mode 100644
index 0000000..82570ab
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeReturnType.java
@@ -0,0 +1,44 @@
+/**
+ * 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.consumer.listener;
+
+/**
+ * Created by alvin on 16-11-30.
+ */
+public enum ConsumeReturnType {
+ /**
+ * consume return success
+ */
+ SUCCESS,
+ /**
+ * consume timeout ,even if success
+ */
+ TIME_OUT,
+ /**
+ * consume throw exception
+ */
+ EXCEPTION,
+ /**
+ * consume return null
+ */
+ RETURNNULL,
+ /**
+ * consume return failed
+ */
+ FAILED
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
new file mode 100644
index 0000000..adc2651
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
@@ -0,0 +1,25 @@
+/**
+ * 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.consumer.listener;
+
+/**
+ * A MessageListener object is used to receive asynchronously delivered messages.
+ *
+ * @author shijia.wxr
+ */
+public interface MessageListener {
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
new file mode 100644
index 0000000..3df6cc2
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
@@ -0,0 +1,42 @@
+/**
+ * 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.consumer.listener;
+
+import org.apache.rocketmq.common.message.MessageExt;
+
+import java.util.List;
+
+
+/**
+ * A MessageListenerConcurrently object is used to receive asynchronously delivered messages concurrently
+ *
+ * @author shijia.wxr
+ */
+public interface MessageListenerConcurrently extends MessageListener {
+ /**
+ * It is not recommend to throw exception,rather than returning ConsumeConcurrentlyStatus.RECONSUME_LATER if consumption failure
+ *
+ * @param msgs
+ * msgs.size() >= 1<br>
+ * DefaultMQPushConsumer.consumeMessageBatchMaxSize=1,you can modify here
+ * @param context
+ *
+ * @return The consume status
+ */
+ ConsumeConcurrentlyStatus consumeMessage(final List<MessageExt> msgs,
+ final ConsumeConcurrentlyContext context);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
new file mode 100644
index 0000000..d1b6c79
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
@@ -0,0 +1,42 @@
+/**
+ * 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.consumer.listener;
+
+import org.apache.rocketmq.common.message.MessageExt;
+
+import java.util.List;
+
+
+/**
+ * A MessageListenerConcurrently object is used to receive asynchronously delivered messages orderly.one queue,one thread
+ *
+ * @author shijia.wxr
+ */
+public interface MessageListenerOrderly extends MessageListener {
+ /**
+ * It is not recommend to throw exception,rather than returning ConsumeOrderlyStatus.SUSPEND_CURRENT_QUEUE_A_MOMENT if consumption failure
+ *
+ * @param msgs
+ * msgs.size() >= 1<br>
+ * DefaultMQPushConsumer.consumeMessageBatchMaxSize=1,you can modify here
+ * @param context
+ *
+ * @return The consume status
+ */
+ ConsumeOrderlyStatus consumeMessage(final List<MessageExt> msgs,
+ final ConsumeOrderlyContext context);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragely.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragely.java b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragely.java
new file mode 100644
index 0000000..747df83
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragely.java
@@ -0,0 +1,75 @@
+/**
+ * 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.consumer.rebalance;
+
+import org.apache.rocketmq.client.consumer.AllocateMessageQueueStrategy;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.slf4j.Logger;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Average Hashing queue algorithm
+ *
+ * @author manhong.yqd
+ */
+public class AllocateMessageQueueAveragely implements AllocateMessageQueueStrategy {
+ private final Logger log = ClientLogger.getLog();
+
+ @Override
+ public List<MessageQueue> allocate(String consumerGroup, String currentCID, List<MessageQueue> mqAll,
+ List<String> cidAll) {
+ if (currentCID == null || currentCID.length() < 1) {
+ throw new IllegalArgumentException("currentCID is empty");
+ }
+ if (mqAll == null || mqAll.isEmpty()) {
+ throw new IllegalArgumentException("mqAll is null or mqAll empty");
+ }
+ if (cidAll == null || cidAll.isEmpty()) {
+ throw new IllegalArgumentException("cidAll is null or cidAll empty");
+ }
+
+ List<MessageQueue> result = new ArrayList<MessageQueue>();
+ if (!cidAll.contains(currentCID)) {
+ log.info("[BUG] ConsumerGroup: {} The consumerId: {} not in cidAll: {}",
+ consumerGroup,
+ currentCID,
+ cidAll);
+ return result;
+ }
+
+ int index = cidAll.indexOf(currentCID);
+ int mod = mqAll.size() % cidAll.size();
+ int averageSize =
+ mqAll.size() <= cidAll.size() ? 1 : (mod > 0 && index < mod ? mqAll.size() / cidAll.size()
+ + 1 : mqAll.size() / cidAll.size());
+ int startIndex = (mod > 0 && index < mod) ? index * averageSize : index * averageSize + mod;
+ int range = Math.min(averageSize, mqAll.size() - startIndex);
+ for (int i = 0; i < range; i++) {
+ result.add(mqAll.get((startIndex + i) % mqAll.size()));
+ }
+ return result;
+ }
+
+ @Override
+ public String getName() {
+ return "AVG";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragelyByCircle.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragelyByCircle.java b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragelyByCircle.java
new file mode 100644
index 0000000..d6ab041
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragelyByCircle.java
@@ -0,0 +1,71 @@
+/**
+ * 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.consumer.rebalance;
+
+import org.apache.rocketmq.client.consumer.AllocateMessageQueueStrategy;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.slf4j.Logger;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Cycle average Hashing queue algorithm
+ *
+ * @author manhong.yqd
+ */
+public class AllocateMessageQueueAveragelyByCircle implements AllocateMessageQueueStrategy {
+ private final Logger log = ClientLogger.getLog();
+
+ @Override
+ public List<MessageQueue> allocate(String consumerGroup, String currentCID, List<MessageQueue> mqAll,
+ List<String> cidAll) {
+ if (currentCID == null || currentCID.length() < 1) {
+ throw new IllegalArgumentException("currentCID is empty");
+ }
+ if (mqAll == null || mqAll.isEmpty()) {
+ throw new IllegalArgumentException("mqAll is null or mqAll empty");
+ }
+ if (cidAll == null || cidAll.isEmpty()) {
+ throw new IllegalArgumentException("cidAll is null or cidAll empty");
+ }
+
+ List<MessageQueue> result = new ArrayList<MessageQueue>();
+ if (!cidAll.contains(currentCID)) {
+ log.info("[BUG] ConsumerGroup: {} The consumerId: {} not in cidAll: {}",
+ consumerGroup,
+ currentCID,
+ cidAll);
+ return result;
+ }
+
+ int index = cidAll.indexOf(currentCID);
+ for (int i = index; i < mqAll.size(); i++) {
+ if (i % cidAll.size() == index) {
+ result.add(mqAll.get(i));
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public String getName() {
+ return "AVG_BY_CIRCLE";
+ }
+}
[61/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Remove
author annotation.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/CommandCustomHeader.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/CommandCustomHeader.java b/remoting/src/main/java/org/apache/rocketmq/remoting/CommandCustomHeader.java
index 1cd1c66..de7d3b0 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/CommandCustomHeader.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/CommandCustomHeader.java
@@ -19,9 +19,6 @@ package org.apache.rocketmq.remoting;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-/**
- * @author vintagewang@apache.org
- */
public interface CommandCustomHeader {
void checkFields() throws RemotingCommandException;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/InvokeCallback.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/InvokeCallback.java b/remoting/src/main/java/org/apache/rocketmq/remoting/InvokeCallback.java
index 24835b9..3db5f69 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/InvokeCallback.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/InvokeCallback.java
@@ -20,7 +20,6 @@ import org.apache.rocketmq.remoting.netty.ResponseFuture;
/**
- * @author vintagewang@apache.org
*
*/
public interface InvokeCallback {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClient.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClient.java b/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClient.java
index c0bc679..5f96a34 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClient.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClient.java
@@ -28,7 +28,6 @@ import java.util.concurrent.ExecutorService;
/**
- * @author vintagewang@apache.org
*
*/
public interface RemotingClient extends RemotingService {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServer.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServer.java b/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServer.java
index 8579d75..98270ec 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServer.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServer.java
@@ -28,7 +28,6 @@ import java.util.concurrent.ExecutorService;
/**
- * @author vintagewang@apache.org
*
*/
public interface RemotingServer extends RemotingService {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNotNull.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNotNull.java b/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNotNull.java
index 1486465..5c53541 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNotNull.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNotNull.java
@@ -22,9 +22,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-/**
- * @author vintagewang@apache.org
- */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE})
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNullable.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNullable.java b/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNullable.java
index caa2a39..b552057 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNullable.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/annotation/CFNullable.java
@@ -22,9 +22,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-/**
- * @author vintagewang@apache.org
- */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE})
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/common/Pair.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/Pair.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/Pair.java
index b670368..180348c 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/Pair.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/Pair.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.remoting.common;
-/**
- * @author vintagewang@apache.org
- */
public class Pair<T1, T2> {
private T1 object1;
private T2 object2;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java
index ec594ec..4300537 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java
@@ -29,9 +29,6 @@ import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
-/**
- * @author vintagewang@apache.org
- */
public class RemotingHelper {
public static final String ROCKETMQ_REMOTING = "RocketmqRemoting";
public static final String DEFAULT_CHARSET = "UTF-8";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingUtil.java
----------------------------------------------------------------------
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 c26da10..005471e 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
@@ -38,9 +38,6 @@ import java.util.ArrayList;
import java.util.Enumeration;
-/**
- * @author vintagewang@apache.org
- */
public class RemotingUtil {
public static final String OS_NAME = System.getProperty("os.name");
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnce.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnce.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnce.java
index 2f3b8b9..7734f86 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnce.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/SemaphoreReleaseOnlyOnce.java
@@ -20,9 +20,6 @@ import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicBoolean;
-/**
- * @author vintagewang@apache.org
- */
public class SemaphoreReleaseOnlyOnce {
private final AtomicBoolean released = new AtomicBoolean(false);
private final Semaphore semaphore;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java
index 7912609..c82cbdf 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/ServiceThread.java
@@ -23,7 +23,6 @@ import org.slf4j.LoggerFactory;
/**
* Base class for background thread
*
- * @author vintagewang@apache.org
*
*/
public abstract class ServiceThread implements Runnable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingCommandException.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingCommandException.java b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingCommandException.java
index 450f660..72c5287 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingCommandException.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingCommandException.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.remoting.exception;
-/**
- * @author vintagewang@apache.org
- */
public class RemotingCommandException extends RemotingException {
private static final long serialVersionUID = -6061365915274953096L;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingConnectException.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingConnectException.java b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingConnectException.java
index 6f47c22..2fa4d69 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingConnectException.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingConnectException.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.remoting.exception;
-/**
- * @author vintagewang@apache.org
- */
public class RemotingConnectException extends RemotingException {
private static final long serialVersionUID = -5565366231695911316L;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingException.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingException.java b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingException.java
index b1380f9..f4a79ea 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingException.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingException.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.remoting.exception;
-/**
- * @author vintagewang@apache.org
- */
public class RemotingException extends Exception {
private static final long serialVersionUID = -5690687334570505110L;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingSendRequestException.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingSendRequestException.java b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingSendRequestException.java
index d542c2b..720ec1f 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingSendRequestException.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingSendRequestException.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.remoting.exception;
-/**
- * @author vintagewang@apache.org
- */
public class RemotingSendRequestException extends RemotingException {
private static final long serialVersionUID = 5391285827332471674L;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTimeoutException.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTimeoutException.java b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTimeoutException.java
index 4e07e9a..1190b49 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTimeoutException.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTimeoutException.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.remoting.exception;
-/**
- * @author vintagewang@apache.org
- */
public class RemotingTimeoutException extends RemotingException {
private static final long serialVersionUID = 4106899185095245979L;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTooMuchRequestException.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTooMuchRequestException.java b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTooMuchRequestException.java
index 59ce786..80d4418 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTooMuchRequestException.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/exception/RemotingTooMuchRequestException.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.remoting.exception;
-/**
- * @author vintagewang@apache.org
- */
public class RemotingTooMuchRequestException extends RemotingException {
private static final long serialVersionUID = 4326919581254519654L;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyClientConfig.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyClientConfig.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyClientConfig.java
index e558b76..b797272 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyClientConfig.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyClientConfig.java
@@ -17,7 +17,6 @@
package org.apache.rocketmq.remoting.netty;
/**
- * @author vintagewang@apache.org
*
*/
public class NettyClientConfig {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
index b4883ee..0a8ba97 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
@@ -29,7 +29,6 @@ import java.nio.ByteBuffer;
/**
- * @author vintagewang@apache.org
*
*/
public class NettyDecoder extends LengthFieldBasedFrameDecoder {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEncoder.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEncoder.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEncoder.java
index 832e3cd..35adcf2 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEncoder.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEncoder.java
@@ -29,7 +29,6 @@ import java.nio.ByteBuffer;
/**
- * @author vintagewang@apache.org
*
*/
public class NettyEncoder extends MessageToByteEncoder<RemotingCommand> {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEvent.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEvent.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEvent.java
index 38fbb86..e086409 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEvent.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEvent.java
@@ -19,9 +19,6 @@ package org.apache.rocketmq.remoting.netty;
import io.netty.channel.Channel;
-/**
- * @author vintagewang@apache.org
- */
public class NettyEvent {
private final NettyEventType type;
private final String remoteAddr;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEventType.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEventType.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEventType.java
index e6ec3cd..ae4b647 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEventType.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyEventType.java
@@ -17,7 +17,6 @@
package org.apache.rocketmq.remoting.netty;
/**
- * @author vintagewang@apache.org
*
*/
public enum NettyEventType {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java
index bc8ee73..1034dd8 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java
@@ -49,9 +49,6 @@ import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
-/**
- * @author vintagewang@apache.org
- */
public abstract class NettyRemotingAbstract {
private static final Logger PLOG = LoggerFactory.getLogger(RemotingHelper.ROCKETMQ_REMOTING);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
index fd5aeac..3b7013a 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
@@ -66,9 +66,6 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-/**
- * @author vintagewang@apache.org
- */
public class NettyRemotingClient extends NettyRemotingAbstract implements RemotingClient {
private static final Logger log = LoggerFactory.getLogger(RemotingHelper.ROCKETMQ_REMOTING);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java
index 3ce364e..b8d2052 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java
@@ -23,7 +23,6 @@ import io.netty.channel.ChannelHandlerContext;
/**
* Common remoting command processor
*
- * @author vintagewang@apache.org
*
*/
public interface NettyRequestProcessor {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
index b441962..0a53240 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
@@ -19,7 +19,6 @@ package org.apache.rocketmq.remoting.netty;
/**
*
- * @author vintagewang@apache.org
*
*/
public class NettyServerConfig implements Cloneable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/netty/ResponseFuture.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/ResponseFuture.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/ResponseFuture.java
index 58cc1e4..d564a3a 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/ResponseFuture.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/ResponseFuture.java
@@ -25,9 +25,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-/**
- * @author vintagewang@apache.org
- */
public class ResponseFuture {
private final int opaque;
private final long timeoutMillis;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
index bf8eb0e..60dd498 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
@@ -33,9 +33,6 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
-/**
- * @author vintagewang@apache.org
- */
public class RemotingCommand {
public static final String SERIALIZE_TYPE_PROPERTY = "rocketmq.serialize.type";
public static final String SERIALIZE_TYPE_ENV = "ROCKETMQ_SERIALIZE_TYPE";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommandType.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommandType.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommandType.java
index fa4035b..3adf06f 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommandType.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommandType.java
@@ -17,7 +17,6 @@
package org.apache.rocketmq.remoting.protocol;
/**
- * @author vintagewang@apache.org
*
*/
public enum RemotingCommandType {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java
index 93b968c..e543ce1 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java
@@ -22,7 +22,6 @@ import java.nio.charset.Charset;
/**
- * @author vintagewang@apache.org
*
*/
public abstract class RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java
----------------------------------------------------------------------
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java
index 65b7d3d..6b0d825 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java
@@ -24,7 +24,6 @@ import java.util.Map;
/**
- * @author manhong.yqd
*
*/
public class RocketMQSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
index b11ed44..3b73e46 100644
--- a/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
+++ b/remoting/src/test/java/org/apache/rocketmq/remoting/MixTest.java
@@ -23,9 +23,6 @@ package org.apache.rocketmq.remoting;
import org.junit.Test;
-/**
- * @author vintagewang@apache.org
- */
public class MixTest {
@Test
public void test_extFieldsValue() {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
index 42ae4fb..15330bc 100644
--- a/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
+++ b/remoting/src/test/java/org/apache/rocketmq/remoting/NettyRPCTest.java
@@ -32,9 +32,6 @@ import java.util.concurrent.Executors;
import static org.junit.Assert.assertTrue;
-/**
- * @author vintagewang@apache.org
- */
public class NettyRPCTest {
@Test
public void test_RPC_Sync() throws InterruptedException, RemotingConnectException,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java
----------------------------------------------------------------------
diff --git a/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java b/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java
index 8f9132c..3c27697 100644
--- a/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java
+++ b/remoting/src/test/java/org/apache/rocketmq/subclass/TestSubClassAuto.java
@@ -23,9 +23,6 @@ package org.apache.rocketmq.subclass;
import org.junit.Test;
-/**
- * @author vintagewang@apache.org
- */
public class TestSubClassAuto {
@Test
public void test_sub() {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java b/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
index 471418f..94362ea 100644
--- a/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/AllocateMappedFileService.java
@@ -35,7 +35,6 @@ import java.util.concurrent.TimeUnit;
/**
* Create MappedFile in advance
*
- * @author vintagewang@apache.org
*/
public class AllocateMappedFileService extends ServiceThread {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java b/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java
index 786f16d..0e8678c 100644
--- a/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java
+++ b/store/src/main/java/org/apache/rocketmq/store/AppendMessageCallback.java
@@ -22,7 +22,6 @@ import java.nio.ByteBuffer;
/**
* Write messages callback interface
*
- * @author vintagewang@apache.org
*
*/
public interface AppendMessageCallback {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java b/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java
index 53a7c98..8541208 100644
--- a/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/AppendMessageResult.java
@@ -19,7 +19,6 @@ package org.apache.rocketmq.store;
/**
* When write a message to the commit log, returns results
*
- * @author vintagewang@apache.org
*/
public class AppendMessageResult {
// Return code
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java b/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java
index 2a6b329..34f70b1 100644
--- a/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java
+++ b/store/src/main/java/org/apache/rocketmq/store/AppendMessageStatus.java
@@ -19,7 +19,6 @@ package org.apache.rocketmq.store;
/**
* When write a message to the commit log, returns code
*
- * @author vintagewang@apache.org
*
*/
public enum AppendMessageStatus {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/CommitLog.java b/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
index 5bb82ef..ddd6be3 100644
--- a/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
+++ b/store/src/main/java/org/apache/rocketmq/store/CommitLog.java
@@ -45,7 +45,6 @@ import java.util.concurrent.locks.ReentrantLock;
/**
* Store all metadata downtime for recovery, data protection reliability
*
- * @author vintagewang@apache.org
*/
public class CommitLog {
// Message's MAGIC CODE daa320a7
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java b/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
index b89db8a..6326d4b 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ConsumeQueue.java
@@ -25,9 +25,6 @@ import java.nio.ByteBuffer;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class ConsumeQueue {
public static final int CQ_STORE_UNIT_SIZE = 20;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/DefaultMessageFilter.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageFilter.java b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageFilter.java
index 4ba7e60..ac149f4 100644
--- a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageFilter.java
+++ b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageFilter.java
@@ -19,9 +19,6 @@ package org.apache.rocketmq.store;
import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
-/**
- * @author vintagewang@apache.org
- */
public class DefaultMessageFilter implements MessageFilter {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
index 60a0188..8714055 100644
--- a/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
+++ b/store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
@@ -49,9 +49,6 @@ import java.util.concurrent.atomic.AtomicLong;
import static org.apache.rocketmq.store.config.BrokerRole.SLAVE;
-/**
- * @author vintagewang@apache.org
- */
public class DefaultMessageStore implements MessageStore {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/DispatchRequest.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/DispatchRequest.java b/store/src/main/java/org/apache/rocketmq/store/DispatchRequest.java
index 2b099a6..d0855ab 100644
--- a/store/src/main/java/org/apache/rocketmq/store/DispatchRequest.java
+++ b/store/src/main/java/org/apache/rocketmq/store/DispatchRequest.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.store;
-/**
- * @author vintagewang@apache.org
- */
public class DispatchRequest {
private final String topic;
private final int queueId;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java b/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java
index edd0020..0f1ba8c 100644
--- a/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/GetMessageResult.java
@@ -23,9 +23,6 @@ import java.util.ArrayList;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class GetMessageResult {
private final List<SelectMappedBufferResult> messageMapedList =
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/GetMessageStatus.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/GetMessageStatus.java b/store/src/main/java/org/apache/rocketmq/store/GetMessageStatus.java
index c3ae337..003d1d4 100644
--- a/store/src/main/java/org/apache/rocketmq/store/GetMessageStatus.java
+++ b/store/src/main/java/org/apache/rocketmq/store/GetMessageStatus.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.store;
-/**
- * @author vintagewang@apache.org
- */
public enum GetMessageStatus {
FOUND,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/MappedFile.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/MappedFile.java b/store/src/main/java/org/apache/rocketmq/store/MappedFile.java
index d06960b..ce5f570 100644
--- a/store/src/main/java/org/apache/rocketmq/store/MappedFile.java
+++ b/store/src/main/java/org/apache/rocketmq/store/MappedFile.java
@@ -41,9 +41,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
-/**
- * @author vintagewang@apache.org
- */
public class MappedFile extends ReferenceResource {
public static final int OS_PAGE_SIZE = 1024 * 4;
protected static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java b/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
index 21b682e..a208a07 100644
--- a/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
+++ b/store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
@@ -27,9 +27,6 @@ import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
-/**
- * @author vintagewang@apache.org
- */
public class MappedFileQueue {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
private static final Logger LOG_ERROR = LoggerFactory.getLogger(LoggerName.STORE_ERROR_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/MessageExtBrokerInner.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/MessageExtBrokerInner.java b/store/src/main/java/org/apache/rocketmq/store/MessageExtBrokerInner.java
index ecdd28b..dabb418 100644
--- a/store/src/main/java/org/apache/rocketmq/store/MessageExtBrokerInner.java
+++ b/store/src/main/java/org/apache/rocketmq/store/MessageExtBrokerInner.java
@@ -20,9 +20,6 @@ import org.apache.rocketmq.common.TopicFilterType;
import org.apache.rocketmq.common.message.MessageExt;
-/**
- * @author vintagewang@apache.org
- */
public class MessageExtBrokerInner extends MessageExt {
private static final long serialVersionUID = 7256001576878700634L;
private String propertiesString;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/MessageFilter.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/MessageFilter.java b/store/src/main/java/org/apache/rocketmq/store/MessageFilter.java
index cc4657f..cb7304e 100644
--- a/store/src/main/java/org/apache/rocketmq/store/MessageFilter.java
+++ b/store/src/main/java/org/apache/rocketmq/store/MessageFilter.java
@@ -19,9 +19,6 @@ package org.apache.rocketmq.store;
import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
-/**
- * @author vintagewang@apache.org
- */
public interface MessageFilter {
boolean isMessageMatched(final SubscriptionData subscriptionData, final Long tagsCode);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/MessageStore.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/MessageStore.java b/store/src/main/java/org/apache/rocketmq/store/MessageStore.java
index c9a8ddc..328a700 100644
--- a/store/src/main/java/org/apache/rocketmq/store/MessageStore.java
+++ b/store/src/main/java/org/apache/rocketmq/store/MessageStore.java
@@ -23,9 +23,6 @@ import java.util.HashMap;
import java.util.Set;
-/**
- * @author vintagewang@apache.org
- */
public interface MessageStore {
boolean load();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/PutMessageResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/PutMessageResult.java b/store/src/main/java/org/apache/rocketmq/store/PutMessageResult.java
index 8aaee98..d36e7ee 100644
--- a/store/src/main/java/org/apache/rocketmq/store/PutMessageResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/PutMessageResult.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.store;
-/**
- * @author vintagewang@apache.org
- */
public class PutMessageResult {
private PutMessageStatus putMessageStatus;
private AppendMessageResult appendMessageResult;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/PutMessageStatus.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/PutMessageStatus.java b/store/src/main/java/org/apache/rocketmq/store/PutMessageStatus.java
index a37b94e..1b6ec9a 100644
--- a/store/src/main/java/org/apache/rocketmq/store/PutMessageStatus.java
+++ b/store/src/main/java/org/apache/rocketmq/store/PutMessageStatus.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.store;
-/**
- * @author vintagewang@apache.org
- */
public enum PutMessageStatus {
PUT_OK,
FLUSH_DISK_TIMEOUT,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/QueryMessageResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/QueryMessageResult.java b/store/src/main/java/org/apache/rocketmq/store/QueryMessageResult.java
index fa57ed2..1f300a2 100644
--- a/store/src/main/java/org/apache/rocketmq/store/QueryMessageResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/QueryMessageResult.java
@@ -21,9 +21,6 @@ import java.util.ArrayList;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class QueryMessageResult {
private final List<SelectMappedBufferResult> messageMapedList =
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/ReferenceResource.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/ReferenceResource.java b/store/src/main/java/org/apache/rocketmq/store/ReferenceResource.java
index b322e04..6563232 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ReferenceResource.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ReferenceResource.java
@@ -19,9 +19,6 @@ package org.apache.rocketmq.store;
import java.util.concurrent.atomic.AtomicLong;
-/**
- * @author vintagewang@apache.org
- */
public abstract class ReferenceResource {
protected final AtomicLong refCount = new AtomicLong(1);
protected volatile boolean available = true;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/RunningFlags.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/RunningFlags.java b/store/src/main/java/org/apache/rocketmq/store/RunningFlags.java
index c103984..8e7f29f 100644
--- a/store/src/main/java/org/apache/rocketmq/store/RunningFlags.java
+++ b/store/src/main/java/org/apache/rocketmq/store/RunningFlags.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.store;
-/**
- * @author vintagewang@apache.org
- */
public class RunningFlags {
private static final int NOT_READABLE_BIT = 1;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/SelectMappedBufferResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/SelectMappedBufferResult.java b/store/src/main/java/org/apache/rocketmq/store/SelectMappedBufferResult.java
index 14fcce3..218f809 100644
--- a/store/src/main/java/org/apache/rocketmq/store/SelectMappedBufferResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/SelectMappedBufferResult.java
@@ -19,9 +19,6 @@ package org.apache.rocketmq.store;
import java.nio.ByteBuffer;
-/**
- * @author vintagewang@apache.org
- */
public class SelectMappedBufferResult {
private final long startOffset;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/StoreCheckpoint.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/StoreCheckpoint.java b/store/src/main/java/org/apache/rocketmq/store/StoreCheckpoint.java
index d795077..7fb5158 100644
--- a/store/src/main/java/org/apache/rocketmq/store/StoreCheckpoint.java
+++ b/store/src/main/java/org/apache/rocketmq/store/StoreCheckpoint.java
@@ -29,9 +29,6 @@ import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel.MapMode;
-/**
- * @author vintagewang@apache.org
- */
public class StoreCheckpoint {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
private final RandomAccessFile randomAccessFile;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java b/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java
index 4ecc1cc..91b70fb 100644
--- a/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java
@@ -30,9 +30,6 @@ import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantLock;
-/**
- * @author vintagewang@apache.org
- */
public class StoreStatsService extends ServiceThread {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java b/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java
index 6fe0790..d44720c 100644
--- a/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java
+++ b/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java
@@ -21,7 +21,6 @@ import java.lang.management.OperatingSystemMXBean;
/**
- * @author vintagewang@apache.org
*
*/
public class StoreUtil {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java b/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java
index 9e7bcc4..bd5b629 100644
--- a/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java
+++ b/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java
@@ -29,9 +29,6 @@ import java.nio.ByteBuffer;
import java.util.Deque;
import java.util.concurrent.ConcurrentLinkedDeque;
-/**
- * @author yukon@apache.org
- */
public class TransientStorePool {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/config/BrokerRole.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/config/BrokerRole.java b/store/src/main/java/org/apache/rocketmq/store/config/BrokerRole.java
index 0d3c639..6ebb723 100644
--- a/store/src/main/java/org/apache/rocketmq/store/config/BrokerRole.java
+++ b/store/src/main/java/org/apache/rocketmq/store/config/BrokerRole.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.store.config;
-/**
- * @author vintagewang@apache.org
- */
public enum BrokerRole {
ASYNC_MASTER,
SYNC_MASTER,
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/config/FlushDiskType.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/config/FlushDiskType.java b/store/src/main/java/org/apache/rocketmq/store/config/FlushDiskType.java
index 5696429..02b0ced 100644
--- a/store/src/main/java/org/apache/rocketmq/store/config/FlushDiskType.java
+++ b/store/src/main/java/org/apache/rocketmq/store/config/FlushDiskType.java
@@ -16,9 +16,6 @@
*/
package org.apache.rocketmq.store.config;
-/**
- * @author vintagewang@apache.org
- */
public enum FlushDiskType {
SYNC_FLUSH,
ASYNC_FLUSH
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java b/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java
index 9230fa4..205adec 100644
--- a/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java
+++ b/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java
@@ -22,10 +22,6 @@ import org.apache.rocketmq.store.ConsumeQueue;
import java.io.File;
-/**
- * @author vongosling@apache.org
- * @author vintagewang@apache.org
- */
public class MessageStoreConfig {
//The root directory in which the log data is kept
@ImportantField
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/ha/HAConnection.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/ha/HAConnection.java b/store/src/main/java/org/apache/rocketmq/store/ha/HAConnection.java
index d1f8219..e8965d3 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ha/HAConnection.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ha/HAConnection.java
@@ -30,9 +30,6 @@ import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
-/**
- * @author vintagewang@apache.org
- */
public class HAConnection {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
private final HAService haService;
@@ -91,7 +88,6 @@ public class HAConnection {
/**
*
- * @author vintagewang@apache.org
*/
class ReadSocketService extends ServiceThread {
private static final int READ_MAX_BUFFER_SIZE = 1024 * 1024;
@@ -215,7 +211,6 @@ public class HAConnection {
/**
*
- * @author vintagewang@apache.org
*/
class WriteSocketService extends ServiceThread {
private final Selector selector;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java b/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
index 7a17108..84a3af6 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
@@ -38,9 +38,6 @@ import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
-/**
- * @author vintagewang@apache.org
- */
public class HAService {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/ha/WaitNotifyObject.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/ha/WaitNotifyObject.java b/store/src/main/java/org/apache/rocketmq/store/ha/WaitNotifyObject.java
index 9da9fbf..c059e10 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ha/WaitNotifyObject.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ha/WaitNotifyObject.java
@@ -19,9 +19,6 @@ package org.apache.rocketmq.store.ha;
import java.util.HashMap;
-/**
- * @author vintagewang@apache.org
- */
public class WaitNotifyObject {
protected final HashMap<Long/* thread id */, Boolean/* notified */> waitingThreadTable =
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java b/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
index f2861fb..d6a223d 100644
--- a/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
+++ b/store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
@@ -29,9 +29,6 @@ import java.nio.channels.FileLock;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class IndexFile {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
private static int hashSlotSize = 4;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/index/IndexHeader.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/index/IndexHeader.java b/store/src/main/java/org/apache/rocketmq/store/index/IndexHeader.java
index ec6199d..130f08e 100644
--- a/store/src/main/java/org/apache/rocketmq/store/index/IndexHeader.java
+++ b/store/src/main/java/org/apache/rocketmq/store/index/IndexHeader.java
@@ -24,7 +24,6 @@ import java.util.concurrent.atomic.AtomicLong;
/**
*
- * @author vintagewang@apache.org
*
*/
public class IndexHeader {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java b/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java
index eab83cd..939ba2d 100644
--- a/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/index/IndexService.java
@@ -35,9 +35,6 @@ import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-/**
- * @author vintagewang@apache.org
- */
public class IndexService {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
private final DefaultMessageStore defaultMessageStore;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/index/QueryOffsetResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/index/QueryOffsetResult.java b/store/src/main/java/org/apache/rocketmq/store/index/QueryOffsetResult.java
index 0af9aa0..e126aee 100644
--- a/store/src/main/java/org/apache/rocketmq/store/index/QueryOffsetResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/index/QueryOffsetResult.java
@@ -19,9 +19,6 @@ package org.apache.rocketmq.store.index;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class QueryOffsetResult {
private final List<Long> phyOffsets;
private final long indexLastUpdateTimestamp;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/schedule/DelayOffsetSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/schedule/DelayOffsetSerializeWrapper.java b/store/src/main/java/org/apache/rocketmq/store/schedule/DelayOffsetSerializeWrapper.java
index 5c60a2c..b1520e1 100644
--- a/store/src/main/java/org/apache/rocketmq/store/schedule/DelayOffsetSerializeWrapper.java
+++ b/store/src/main/java/org/apache/rocketmq/store/schedule/DelayOffsetSerializeWrapper.java
@@ -22,7 +22,6 @@ import java.util.concurrent.ConcurrentHashMap;
/**
- * @author vintagewang@apache.org
*
*/
public class DelayOffsetSerializeWrapper extends RemotingSerializable {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java b/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java
index 0b5df95..c03c181 100644
--- a/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java
@@ -35,7 +35,6 @@ import java.util.concurrent.ConcurrentHashMap;
/**
- * @author vintagewang@apache.org
*
*/
public class ScheduleMessageService extends ConfigManager {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStats.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStats.java b/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStats.java
index 4f21ae5..dd4f6df 100644
--- a/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStats.java
+++ b/store/src/main/java/org/apache/rocketmq/store/stats/BrokerStats.java
@@ -22,9 +22,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- * @author vintagewang@apache.org
- */
public class BrokerStats {
private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final DefaultMessageStore defaultMessageStore;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java
----------------------------------------------------------------------
diff --git a/store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java b/store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java
index abad9c7..bfcb33e 100644
--- a/store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java
+++ b/store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java
@@ -34,9 +34,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import static org.junit.Assert.assertTrue;
-/**
- * @author vintagewang@apache.org
- */
public class DefaultMessageStoreTest {
private static final Logger logger = LoggerFactory.getLogger(DefaultMessageStoreTest.class);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java
index 688fd5e..c6a80b0 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java
@@ -41,9 +41,6 @@ import java.util.Properties;
import java.util.Set;
-/**
- * @author vintagewang@apache.org
- */
public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
private final DefaultMQAdminExtImpl defaultMQAdminExtImpl;
private String adminExtGroup = "admin_ext_group";
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
index 5237219..a0117a8 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
@@ -53,9 +53,6 @@ import java.util.*;
import java.util.Map.Entry;
-/**
- * @author vintagewang@apache.org
- */
public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
private final Logger log = ClientLogger.getLog();
private final DefaultMQAdminExt defaultMQAdminExt;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java b/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
index bb20c94..c675d9a 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
@@ -28,9 +28,6 @@ import org.apache.rocketmq.tools.admin.MQAdminExt;
import java.util.*;
-/**
- * @author vintagewang@apache.org
- */
public class CommandUtil {
public static Map<String/*master addr*/, List<String>/*slave addr*/> fetchMasterAndSlaveDistinguish(
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java b/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java
index 5c4e173..d11dd23 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java
@@ -45,9 +45,6 @@ import java.util.ArrayList;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class MQAdminStartup {
protected static List<SubCommand> subCommandList = new ArrayList<SubCommand>();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/SubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/SubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/SubCommand.java
index 4a96021..744685e 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/SubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/SubCommand.java
@@ -21,9 +21,6 @@ import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
-/**
- * @author vintagewang@apache.org
- */
public interface SubCommand {
public String commandName();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerConsumeStatsSubCommad.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerConsumeStatsSubCommad.java b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerConsumeStatsSubCommad.java
index 6caa3e9..57ca907 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerConsumeStatsSubCommad.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerConsumeStatsSubCommad.java
@@ -31,9 +31,6 @@ import org.apache.commons.cli.Options;
import java.util.*;
-/**
- * @author vintagewang@apache.org
- */
public class BrokerConsumeStatsSubCommad implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerStatusSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerStatusSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerStatusSubCommand.java
index 9d096a9..3f5ff79 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerStatusSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerStatusSubCommand.java
@@ -35,9 +35,6 @@ import java.util.Set;
import java.util.TreeMap;
-/**
- * @author vintagewang@apache.org
- */
public class BrokerStatusSubCommand implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanExpiredCQSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanExpiredCQSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanExpiredCQSubCommand.java
index cbb04bd..71aa78b 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanExpiredCQSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanExpiredCQSubCommand.java
@@ -25,9 +25,6 @@ import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
-/**
- * @author lansheng.zj
- */
public class CleanExpiredCQSubCommand implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanUnusedTopicCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanUnusedTopicCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanUnusedTopicCommand.java
index 26f0cb5..0e4c4b4 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanUnusedTopicCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanUnusedTopicCommand.java
@@ -25,9 +25,6 @@ import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
-/**
- * @author lansheng.zj
- */
public class CleanUnusedTopicCommand implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/broker/GetBrokerConfigCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/GetBrokerConfigCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/GetBrokerConfigCommand.java
index 529c328..2956264 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/GetBrokerConfigCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/GetBrokerConfigCommand.java
@@ -35,9 +35,6 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
-/**
- * @author xigu.lx
- */
public class GetBrokerConfigCommand implements SubCommand {
@Override
public String commandName() {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/broker/SendMsgStatusCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/SendMsgStatusCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/SendMsgStatusCommand.java
index b968aba..d40ba21 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/SendMsgStatusCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/SendMsgStatusCommand.java
@@ -29,9 +29,6 @@ import org.apache.commons.cli.Options;
import java.io.UnsupportedEncodingException;
-/**
- * @author lansheng.zj
- */
public class SendMsgStatusCommand implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/broker/UpdateBrokerConfigSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/UpdateBrokerConfigSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/UpdateBrokerConfigSubCommand.java
index d71ee3f..1de9457 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/UpdateBrokerConfigSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/UpdateBrokerConfigSubCommand.java
@@ -29,9 +29,6 @@ import java.util.Properties;
import java.util.Set;
-/**
- * @author vintagewang@apache.org
- */
public class UpdateBrokerConfigSubCommand implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/CLusterSendMsgRTCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/CLusterSendMsgRTCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/CLusterSendMsgRTCommand.java
index e4fe4a7..a8bd3a8 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/CLusterSendMsgRTCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/CLusterSendMsgRTCommand.java
@@ -32,9 +32,6 @@ import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
-/**
- * @author fengliang.hfl
- */
public class CLusterSendMsgRTCommand implements SubCommand {
public static void main(String args[]) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/ClusterListSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/ClusterListSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/ClusterListSubCommand.java
index 781dc90..b649af1 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/ClusterListSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/ClusterListSubCommand.java
@@ -36,9 +36,6 @@ import java.util.Set;
import java.util.TreeSet;
-/**
- * @author vintagewang@apache.org
- */
public class ClusterListSubCommand implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ConsumerConnectionSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ConsumerConnectionSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ConsumerConnectionSubCommand.java
index c12f459..355e894 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ConsumerConnectionSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ConsumerConnectionSubCommand.java
@@ -31,9 +31,6 @@ import java.util.Iterator;
import java.util.Map.Entry;
-/**
- * @author vintagewang@apache.org
- */
public class ConsumerConnectionSubCommand implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ProducerConnectionSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ProducerConnectionSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ProducerConnectionSubCommand.java
index 17244de..0b5b0ab 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ProducerConnectionSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ProducerConnectionSubCommand.java
@@ -27,9 +27,6 @@ import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
-/**
- * @author vintagewang@apache.org
- */
public class ProducerConnectionSubCommand implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
index d88d4be..56e0853 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
@@ -41,9 +41,6 @@ import java.util.LinkedList;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class ConsumerProgressSubCommand implements SubCommand {
private final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerStatusSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerStatusSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerStatusSubCommand.java
index 87ead28..e15ce1f 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerStatusSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerStatusSubCommand.java
@@ -34,9 +34,6 @@ import java.util.Map.Entry;
import java.util.TreeMap;
-/**
- * @author vintagewang@apache.org
- */
public class ConsumerStatusSubCommand implements SubCommand {
public static void main(String[] args) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerSubCommand.java
index 3dad886..6e7cc27 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerSubCommand.java
@@ -34,9 +34,6 @@ import java.util.Map.Entry;
import java.util.TreeMap;
-/**
- * @author vintagewang@apache.org
- */
public class ConsumerSubCommand implements SubCommand {
public static void main(String[] args) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/DeleteSubscriptionGroupCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/DeleteSubscriptionGroupCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/DeleteSubscriptionGroupCommand.java
index 0149d0e..0cc5879 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/DeleteSubscriptionGroupCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/DeleteSubscriptionGroupCommand.java
@@ -30,9 +30,6 @@ import org.apache.commons.cli.Options;
import java.util.Set;
-/**
- * @author lansheng.zj
- */
public class DeleteSubscriptionGroupCommand implements SubCommand {
@Override
public String commandName() {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/StartMonitoringSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/StartMonitoringSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/StartMonitoringSubCommand.java
index d902210..4d5315b 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/StartMonitoringSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/StartMonitoringSubCommand.java
@@ -27,9 +27,6 @@ import org.apache.commons.cli.Options;
import org.slf4j.Logger;
-/**
- * @author vintagewang@apache.org
- */
public class StartMonitoringSubCommand implements SubCommand {
private final Logger log = ClientLogger.getLog();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/UpdateSubGroupSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/UpdateSubGroupSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/UpdateSubGroupSubCommand.java
index c784a06..93eb8ec 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/UpdateSubGroupSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/UpdateSubGroupSubCommand.java
@@ -29,9 +29,6 @@ import org.apache.commons.cli.Options;
import java.util.Set;
-/**
- * @author vintagewang@apache.org
- */
public class UpdateSubGroupSubCommand implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageSubCommand.java
index 4148387..e8c9368 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageSubCommand.java
@@ -33,9 +33,6 @@ import java.util.List;
import java.util.Set;
-/**
- * @author vintagewang@apache.org
- */
public class PrintMessageSubCommand implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java
index 8006657..fded7b6 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByIdSubCommand.java
@@ -42,9 +42,6 @@ import java.io.IOException;
import java.util.List;
-/**
- * @author vintagewang@apache.org
- */
public class QueryMsgByIdSubCommand implements SubCommand {
@Override
public String commandName() {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java
index e184ac1..ebfc80e 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByKeySubCommand.java
@@ -29,7 +29,6 @@ import org.apache.commons.cli.Options;
/**
*
- * @author vintagewang@apache.org
*
*/
public class QueryMsgByKeySubCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByOffsetSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByOffsetSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByOffsetSubCommand.java
index e82508f..fc5fd56 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByOffsetSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByOffsetSubCommand.java
@@ -28,9 +28,6 @@ import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
-/**
- * @author vintagewang@apache.org
- */
public class QueryMsgByOffsetSubCommand implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/DeleteKvConfigCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/DeleteKvConfigCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/DeleteKvConfigCommand.java
index 1f2a093..0ae8f44 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/DeleteKvConfigCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/DeleteKvConfigCommand.java
@@ -26,7 +26,6 @@ import org.apache.commons.cli.Options;
/**
*
- * @author manhong.yqd
*
*/
public class DeleteKvConfigCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/GetNamesrvConfigCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/GetNamesrvConfigCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/GetNamesrvConfigCommand.java
index 41e5e34..b2c95d3 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/GetNamesrvConfigCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/GetNamesrvConfigCommand.java
@@ -28,9 +28,6 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
-/**
- * @author xigu.lx
- */
public class GetNamesrvConfigCommand implements SubCommand {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateKvConfigCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateKvConfigCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateKvConfigCommand.java
index 9b8e636..a2d4f43 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateKvConfigCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateKvConfigCommand.java
@@ -26,7 +26,6 @@ import org.apache.commons.cli.Options;
/**
*
- * @author manhong.yqd
*
*/
public class UpdateKvConfigCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateNamesrvConfigCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateNamesrvConfigCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateNamesrvConfigCommand.java
index e43e664..c6517d6 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateNamesrvConfigCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/UpdateNamesrvConfigCommand.java
@@ -28,9 +28,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.Properties;
-/**
- * @author xigu.lx
- */
public class UpdateNamesrvConfigCommand implements SubCommand {
@Override
public String commandName() {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeCommand.java
index a73e343..5eb30b5 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeCommand.java
@@ -34,9 +34,6 @@ import java.util.Iterator;
import java.util.Map;
-/**
- * @author manhong.yqd
- */
public class ResetOffsetByTimeCommand implements SubCommand {
public static void main(String[] args) {
ResetOffsetByTimeCommand cmd = new ResetOffsetByTimeCommand();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeOldCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeOldCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeOldCommand.java
index 0025aa9..0f15f69 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeOldCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeOldCommand.java
@@ -35,7 +35,6 @@ import java.util.List;
/**
*
- * @author manhong.yqd
*
*/
public class ResetOffsetByTimeOldCommand implements SubCommand {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/8ca4657e/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java
index 4661c3f..0749e36 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java
@@ -35,7 +35,6 @@ import java.util.Set;
/**
*
- * @author lansheng.zj
*
*/
public class DeleteTopicSubCommand implements SubCommand {
[90/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java b/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
index 0ff589d..38d885e 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/api/SendMessageTest.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: SendMessageTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
@@ -36,10 +38,9 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.*;
-
+import static org.junit.Assert.assertEquals;
-public class SendMessageTest extends BrokerTestHarness{
+public class SendMessageTest extends BrokerTestHarness {
MQClientAPIImpl client = new MQClientAPIImpl(new NettyClientConfig(), null, null, new ClientConfig());
String topic = "UnitTestTopic";
@@ -60,7 +61,7 @@ public class SendMessageTest extends BrokerTestHarness{
}
@Test
- public void testSendSingle() throws Exception{
+ public void testSendSingle() throws Exception {
Message msg = new Message(topic, "TAG1 TAG2", "100200300", "body".getBytes());
SendMessageRequestHeader requestHeader = new SendMessageRequestHeader();
requestHeader.setProducerGroup("abc");
@@ -74,7 +75,7 @@ public class SendMessageTest extends BrokerTestHarness{
requestHeader.setProperties(MessageDecoder.messageProperties2String(msg.getProperties()));
SendResult result = client.sendMessage(brokerAddr, BROKER_NAME, msg, requestHeader, 1000 * 5,
- CommunicationMode.SYNC, new SendMessageContext(), null);
+ CommunicationMode.SYNC, new SendMessageContext(), null);
assertEquals(result.getSendStatus(), SendStatus.SEND_OK);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java b/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
index d6be5fb..89813fc 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManagerTest.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: ConsumerOffsetManagerTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
@@ -25,7 +27,6 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
-
public class ConsumerOffsetManagerTest extends BrokerTestHarness {
@Test
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
----------------------------------------------------------------------
diff --git a/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java b/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
index ab9ab6f..2f85dbc 100644
--- a/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
+++ b/broker/src/test/java/org/apache/rocketmq/broker/topic/TopicConfigManagerTest.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: TopicConfigManagerTest.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
@@ -25,8 +27,9 @@ import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.TopicConfig;
import org.junit.Test;
-import static org.junit.Assert.*;
-
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
public class TopicConfigManagerTest extends BrokerTestHarness {
@Test
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/checkstyle/checkstyle.xml
----------------------------------------------------------------------
diff --git a/checkstyle/checkstyle.xml b/checkstyle/checkstyle.xml
index e4a8c36..0d22d7d 100644
--- a/checkstyle/checkstyle.xml
+++ b/checkstyle/checkstyle.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC
- "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
- "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
+ "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -32,8 +32,8 @@
</module>
<module name="RegexpSingleline">
- <property name="format" value="System\.out\.println" />
- <property name="message" value="Prohibit invoking System.out.println in source code !" />
+ <property name="format" value="System\.out\.println"/>
+ <property name="message" value="Prohibit invoking System.out.println in source code !"/>
</module>
<module name="RegexpSingleline">
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index 86d38cf..9c18ebd 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -15,7 +15,7 @@
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.rocketmq</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/ClientConfig.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 8afca13..9c7a0cd 100644
--- a/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java
+++ b/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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;
@@ -20,7 +20,6 @@ import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.remoting.common.RemotingUtil;
-
/**
* Client Common configuration
*
@@ -123,78 +122,64 @@ public class ClientConfig {
return clientCallbackExecutorThreads;
}
-
public void setClientCallbackExecutorThreads(int clientCallbackExecutorThreads) {
this.clientCallbackExecutorThreads = clientCallbackExecutorThreads;
}
-
public int getPollNameServerInteval() {
return pollNameServerInteval;
}
-
public void setPollNameServerInteval(int pollNameServerInteval) {
this.pollNameServerInteval = pollNameServerInteval;
}
-
public int getHeartbeatBrokerInterval() {
return heartbeatBrokerInterval;
}
-
public void setHeartbeatBrokerInterval(int heartbeatBrokerInterval) {
this.heartbeatBrokerInterval = heartbeatBrokerInterval;
}
-
public int getPersistConsumerOffsetInterval() {
return persistConsumerOffsetInterval;
}
-
public void setPersistConsumerOffsetInterval(int persistConsumerOffsetInterval) {
this.persistConsumerOffsetInterval = persistConsumerOffsetInterval;
}
-
public String getUnitName() {
return unitName;
}
-
public void setUnitName(String unitName) {
this.unitName = unitName;
}
-
public boolean isUnitMode() {
return unitMode;
}
-
public void setUnitMode(boolean unitMode) {
this.unitMode = unitMode;
}
-
public boolean isVipChannelEnabled() {
return vipChannelEnabled;
}
-
public void setVipChannelEnabled(final boolean vipChannelEnabled) {
this.vipChannelEnabled = vipChannelEnabled;
}
-
@Override
public String toString() {
return "ClientConfig [namesrvAddr=" + namesrvAddr + ", clientIP=" + clientIP + ", instanceName=" + instanceName
- + ", clientCallbackExecutorThreads=" + clientCallbackExecutorThreads + ", pollNameServerInteval=" + pollNameServerInteval
- + ", heartbeatBrokerInterval=" + heartbeatBrokerInterval + ", persistConsumerOffsetInterval="
- + persistConsumerOffsetInterval + ", unitMode=" + unitMode + ", unitName=" + unitName + ", vipChannelEnabled="
- + vipChannelEnabled + "]";
+ + ", clientCallbackExecutorThreads=" + clientCallbackExecutorThreads + ", pollNameServerInteval=" + pollNameServerInteval
+ + ", heartbeatBrokerInterval=" + heartbeatBrokerInterval + ", persistConsumerOffsetInterval="
+ + persistConsumerOffsetInterval + ", unitMode=" + unitMode + ", unitName=" + unitName + ", vipChannelEnabled="
+ + vipChannelEnabled + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java b/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
index 6596855..7697520 100644
--- a/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
+++ b/client/src/main/java/org/apache/rocketmq/client/MQAdmin.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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;
@@ -22,7 +22,6 @@ import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.exception.RemotingException;
-
/**
* Base interface for MQ management
*
@@ -41,8 +40,7 @@ public interface MQAdmin {
* @throws MQClientException
*/
void createTopic(final String key, final String newTopic, final int queueNum)
- throws MQClientException;
-
+ throws MQClientException;
/**
* Creates an topic
@@ -59,8 +57,7 @@ public interface MQAdmin {
* @throws MQClientException
*/
void createTopic(String key, String newTopic, int queueNum, int topicSysFlag)
- throws MQClientException;
-
+ throws MQClientException;
/**
* Gets the message queue offset according to some time in milliseconds<br>
@@ -77,7 +74,6 @@ public interface MQAdmin {
*/
long searchOffset(final MessageQueue mq, final long timestamp) throws MQClientException;
-
/**
* Gets the max offset
*
@@ -90,7 +86,6 @@ public interface MQAdmin {
*/
long maxOffset(final MessageQueue mq) throws MQClientException;
-
/**
* Gets the minimum offset
*
@@ -103,7 +98,6 @@ public interface MQAdmin {
*/
long minOffset(final MessageQueue mq) throws MQClientException;
-
/**
* Gets the earliest stored message time
*
@@ -116,7 +110,6 @@ public interface MQAdmin {
*/
long earliestMsgStoreTime(final MessageQueue mq) throws MQClientException;
-
/**
* Query message according tto message id
*
@@ -131,8 +124,7 @@ public interface MQAdmin {
* @throws MQClientException
*/
MessageExt viewMessage(final String offsetMsgId) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException;
-
+ InterruptedException, MQClientException;
/**
* Query messages
@@ -154,8 +146,8 @@ public interface MQAdmin {
* @throws InterruptedException
*/
QueryResult queryMessage(final String topic, final String key, final int maxNum, final long begin,
- final long end) throws MQClientException, InterruptedException;
-
+ final long end) throws MQClientException, InterruptedException;
+
/**
* @param topic
@@ -166,7 +158,6 @@ public interface MQAdmin {
* @throws InterruptedException
* @throws MQClientException
*/
- MessageExt viewMessage(String topic, String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
+ MessageExt viewMessage(String topic, String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/MQHelper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/MQHelper.java b/client/src/main/java/org/apache/rocketmq/client/MQHelper.java
index b4ddb08..937e846 100644
--- a/client/src/main/java/org/apache/rocketmq/client/MQHelper.java
+++ b/client/src/main/java/org/apache/rocketmq/client/MQHelper.java
@@ -16,47 +16,39 @@
*/
package org.apache.rocketmq.client;
+import java.util.Set;
+import java.util.TreeSet;
import org.apache.rocketmq.client.consumer.DefaultMQPullConsumer;
import org.apache.rocketmq.client.log.ClientLogger;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
import org.slf4j.Logger;
-import java.util.Set;
-import java.util.TreeSet;
-
-
public class MQHelper {
public static void resetOffsetByTimestamp(
- final MessageModel messageModel,
- final String consumerGroup,
- final String topic,
- final long timestamp) throws Exception {
+ final MessageModel messageModel,
+ final String consumerGroup,
+ final String topic,
+ final long timestamp) throws Exception {
resetOffsetByTimestamp(messageModel, "DEFAULT", consumerGroup, topic, timestamp);
}
/**
* Reset consumer topic offset according to time
*
- * @param messageModel
- * which model
- * @param instanceName
- * which instance
- * @param consumerGroup
- * consumer group
- * @param topic
- * topic
- * @param timestamp
- * time
- *
+ * @param messageModel which model
+ * @param instanceName which instance
+ * @param consumerGroup consumer group
+ * @param topic topic
+ * @param timestamp time
* @throws Exception
*/
public static void resetOffsetByTimestamp(
- final MessageModel messageModel,
- final String instanceName,
- final String consumerGroup,
- final String topic,
- final long timestamp) throws Exception {
+ final MessageModel messageModel,
+ final String instanceName,
+ final String consumerGroup,
+ final String topic,
+ final long timestamp) throws Exception {
final Logger log = ClientLogger.getLog();
DefaultMQPullConsumer consumer = new DefaultMQPullConsumer(consumerGroup);
@@ -74,7 +66,7 @@ public class MQHelper {
if (offset >= 0) {
consumer.updateConsumeOffset(mq, offset);
log.info("resetOffsetByTimestamp updateConsumeOffset success, {} {} {}",
- consumerGroup, offset, mq);
+ consumerGroup, offset, mq);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/QueryResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/QueryResult.java b/client/src/main/java/org/apache/rocketmq/client/QueryResult.java
index af3649b..7b1cc01 100644
--- a/client/src/main/java/org/apache/rocketmq/client/QueryResult.java
+++ b/client/src/main/java/org/apache/rocketmq/client/QueryResult.java
@@ -6,45 +6,39 @@
* (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
+ * 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.
+ * 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.common.message.MessageExt;
-
import java.util.List;
-
+import org.apache.rocketmq.common.message.MessageExt;
public class QueryResult {
private final long indexLastUpdateTimestamp;
private final List<MessageExt> messageList;
-
public QueryResult(long indexLastUpdateTimestamp, List<MessageExt> messageList) {
this.indexLastUpdateTimestamp = indexLastUpdateTimestamp;
this.messageList = messageList;
}
-
public long getIndexLastUpdateTimestamp() {
return indexLastUpdateTimestamp;
}
-
public List<MessageExt> getMessageList() {
return messageList;
}
-
@Override
public String toString() {
return "QueryResult [indexLastUpdateTimestamp=" + indexLastUpdateTimestamp + ", messageList="
- + messageList + "]";
+ + messageList + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/Validators.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/Validators.java b/client/src/main/java/org/apache/rocketmq/client/Validators.java
index 92fc53b..fa9e4e6 100644
--- a/client/src/main/java/org/apache/rocketmq/client/Validators.java
+++ b/client/src/main/java/org/apache/rocketmq/client/Validators.java
@@ -6,17 +6,19 @@
* (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
+ * 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.
+ * 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 java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.MixAll;
@@ -24,10 +26,6 @@ import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.protocol.ResponseCode;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-
/**
* Common Validator
*
@@ -65,8 +63,8 @@ public class Validators {
}
if (!regularExpressionMatcher(group, PATTERN)) {
throw new MQClientException(String.format(
- "the specified group[%s] contains illegal characters, allowing only %s", group,
- VALID_PATTERN_STR), null);
+ "the specified group[%s] contains illegal characters, allowing only %s", group,
+ VALID_PATTERN_STR), null);
}
if (group.length() > CHARACTER_MAX_LENGTH) {
throw new MQClientException("the specified group is longer than group max length 255.", null);
@@ -97,7 +95,7 @@ public class Validators {
* @throws MQClientException
*/
public static void checkMessage(Message msg, DefaultMQProducer defaultMQProducer)
- throws MQClientException {
+ throws MQClientException {
if (null == msg) {
throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, "the message is null");
}
@@ -114,7 +112,7 @@ public class Validators {
if (msg.getBody().length > defaultMQProducer.getMaxMessageSize()) {
throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL,
- "the message body size over max value, MAX: " + defaultMQProducer.getMaxMessageSize());
+ "the message body size over max value, MAX: " + defaultMQProducer.getMaxMessageSize());
}
}
@@ -132,8 +130,8 @@ public class Validators {
if (!regularExpressionMatcher(topic, PATTERN)) {
throw new MQClientException(String.format(
- "the specified topic[%s] contains illegal characters, allowing only %s", topic,
- VALID_PATTERN_STR), null);
+ "the specified topic[%s] contains illegal characters, allowing only %s", topic,
+ VALID_PATTERN_STR), null);
}
if (topic.length() > CHARACTER_MAX_LENGTH) {
@@ -143,7 +141,7 @@ public class Validators {
//whether the same with system reserved keyword
if (topic.equals(MixAll.DEFAULT_TOPIC)) {
throw new MQClientException(
- String.format("the topic[%s] is conflict with default topic.", topic), null);
+ String.format("the topic[%s] is conflict with default topic.", topic), null);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java b/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java
index bc4ca6c..913d4f2 100644
--- a/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java
+++ b/client/src/main/java/org/apache/rocketmq/client/admin/MQAdminExtInner.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.admin;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/common/ThreadLocalIndex.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/common/ThreadLocalIndex.java b/client/src/main/java/org/apache/rocketmq/client/common/ThreadLocalIndex.java
index 360cfdf..391f1d1 100644
--- a/client/src/main/java/org/apache/rocketmq/client/common/ThreadLocalIndex.java
+++ b/client/src/main/java/org/apache/rocketmq/client/common/ThreadLocalIndex.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common;
@@ -22,6 +22,7 @@ import java.util.Random;
public class ThreadLocalIndex {
private final ThreadLocal<Integer> threadLocalIndex = new ThreadLocal<Integer>();
private final Random random = new Random();
+
public ThreadLocalIndex(int value) {
}
@@ -30,7 +31,8 @@ public class ThreadLocalIndex {
Integer index = this.threadLocalIndex.get();
if (null == index) {
index = Math.abs(random.nextInt());
- if (index < 0) index = 0;
+ if (index < 0)
+ index = 0;
this.threadLocalIndex.set(index);
}
@@ -45,7 +47,7 @@ public class ThreadLocalIndex {
@Override
public String toString() {
return "ThreadLocalIndex{" +
- "threadLocalIndex=" + threadLocalIndex.get() +
- '}';
+ "threadLocalIndex=" + threadLocalIndex.get() +
+ '}';
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java b/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java
index 81a71e4..ca692d3 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/AllocateMessageQueueStrategy.java
@@ -16,39 +16,30 @@
*/
package org.apache.rocketmq.client.consumer;
-import org.apache.rocketmq.common.message.MessageQueue;
-
import java.util.List;
-
+import org.apache.rocketmq.common.message.MessageQueue;
/**
* Strategy Algorithm for message allocating between consumers
- *
*/
public interface AllocateMessageQueueStrategy {
/**
* Allocating by consumer id
*
- * @param consumerGroup
- * current consumer group
- * @param currentCID
- * current consumer id
- * @param mqAll
- * message queue set in current topic
- * @param cidAll
- * consumer set in current consumer group
- *
+ * @param consumerGroup current consumer group
+ * @param currentCID current consumer id
+ * @param mqAll message queue set in current topic
+ * @param cidAll consumer set in current consumer group
* @return The allocate result of given strategy
*/
List<MessageQueue> allocate(
- final String consumerGroup,
- final String currentCID,
- final List<MessageQueue> mqAll,
- final List<String> cidAll
+ final String consumerGroup,
+ final String currentCID,
+ final List<MessageQueue> mqAll,
+ final List<String> cidAll
);
-
/**
* Algorithm name
*
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
index 156b3d0..8eb1258 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumer.java
@@ -6,16 +6,18 @@
* (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
+ * 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.
+ * 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.consumer;
+import java.util.HashSet;
+import java.util.Set;
import org.apache.rocketmq.client.ClientConfig;
import org.apache.rocketmq.client.QueryResult;
import org.apache.rocketmq.client.consumer.rebalance.AllocateMessageQueueAveragely;
@@ -31,10 +33,6 @@ import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.remoting.exception.RemotingException;
-import java.util.HashSet;
-import java.util.Set;
-
-
/**
* Default pulling consumer
*
@@ -88,23 +86,19 @@ public class DefaultMQPullConsumer extends ClientConfig implements MQPullConsume
private int maxReconsumeTimes = 16;
-
public DefaultMQPullConsumer() {
this(MixAll.DEFAULT_CONSUMER_GROUP, null);
}
-
public DefaultMQPullConsumer(final String consumerGroup, RPCHook rpcHook) {
this.consumerGroup = consumerGroup;
defaultMQPullConsumerImpl = new DefaultMQPullConsumerImpl(this, rpcHook);
}
-
public DefaultMQPullConsumer(final String consumerGroup) {
this(consumerGroup, null);
}
-
public DefaultMQPullConsumer(RPCHook rpcHook) {
this(MixAll.DEFAULT_CONSUMER_GROUP, rpcHook);
}
@@ -114,141 +108,116 @@ public class DefaultMQPullConsumer extends ClientConfig implements MQPullConsume
createTopic(key, newTopic, queueNum, 0);
}
-
@Override
public void createTopic(String key, String newTopic, int queueNum, int topicSysFlag) throws MQClientException {
this.defaultMQPullConsumerImpl.createTopic(key, newTopic, queueNum, topicSysFlag);
}
-
@Override
public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
return this.defaultMQPullConsumerImpl.searchOffset(mq, timestamp);
}
-
@Override
public long maxOffset(MessageQueue mq) throws MQClientException {
return this.defaultMQPullConsumerImpl.maxOffset(mq);
}
-
@Override
public long minOffset(MessageQueue mq) throws MQClientException {
return this.defaultMQPullConsumerImpl.minOffset(mq);
}
-
@Override
public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
return this.defaultMQPullConsumerImpl.earliestMsgStoreTime(mq);
}
-
@Override
public MessageExt viewMessage(String offsetMsgId) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException {
+ InterruptedException, MQClientException {
return this.defaultMQPullConsumerImpl.viewMessage(offsetMsgId);
}
-
@Override
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
- throws MQClientException, InterruptedException {
+ throws MQClientException, InterruptedException {
return this.defaultMQPullConsumerImpl.queryMessage(topic, key, maxNum, begin, end);
}
-
public AllocateMessageQueueStrategy getAllocateMessageQueueStrategy() {
return allocateMessageQueueStrategy;
}
-
public void setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy allocateMessageQueueStrategy) {
this.allocateMessageQueueStrategy = allocateMessageQueueStrategy;
}
-
public long getBrokerSuspendMaxTimeMillis() {
return brokerSuspendMaxTimeMillis;
}
-
public void setBrokerSuspendMaxTimeMillis(long brokerSuspendMaxTimeMillis) {
this.brokerSuspendMaxTimeMillis = brokerSuspendMaxTimeMillis;
}
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public long getConsumerPullTimeoutMillis() {
return consumerPullTimeoutMillis;
}
-
public void setConsumerPullTimeoutMillis(long consumerPullTimeoutMillis) {
this.consumerPullTimeoutMillis = consumerPullTimeoutMillis;
}
-
public long getConsumerTimeoutMillisWhenSuspend() {
return consumerTimeoutMillisWhenSuspend;
}
-
public void setConsumerTimeoutMillisWhenSuspend(long consumerTimeoutMillisWhenSuspend) {
this.consumerTimeoutMillisWhenSuspend = consumerTimeoutMillisWhenSuspend;
}
-
public MessageModel getMessageModel() {
return messageModel;
}
-
public void setMessageModel(MessageModel messageModel) {
this.messageModel = messageModel;
}
-
public MessageQueueListener getMessageQueueListener() {
return messageQueueListener;
}
-
public void setMessageQueueListener(MessageQueueListener messageQueueListener) {
this.messageQueueListener = messageQueueListener;
}
-
public Set<String> getRegisterTopics() {
return registerTopics;
}
-
public void setRegisterTopics(Set<String> registerTopics) {
this.registerTopics = registerTopics;
}
-
@Override
public void sendMessageBack(MessageExt msg, int delayLevel)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
this.defaultMQPullConsumerImpl.sendMessageBack(msg, delayLevel, null);
}
-
@Override
public void sendMessageBack(MessageExt msg, int delayLevel, String brokerName)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
this.defaultMQPullConsumerImpl.sendMessageBack(msg, delayLevel, brokerName);
}
@@ -279,37 +248,37 @@ public class DefaultMQPullConsumer extends ClientConfig implements MQPullConsume
@Override
public PullResult pull(MessageQueue mq, String subExpression, long offset, int maxNums)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.defaultMQPullConsumerImpl.pull(mq, subExpression, offset, maxNums);
}
@Override
public PullResult pull(MessageQueue mq, String subExpression, long offset, int maxNums, long timeout)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.defaultMQPullConsumerImpl.pull(mq, subExpression, offset, maxNums, timeout);
}
@Override
public void pull(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback)
- throws MQClientException, RemotingException, InterruptedException {
+ throws MQClientException, RemotingException, InterruptedException {
this.defaultMQPullConsumerImpl.pull(mq, subExpression, offset, maxNums, pullCallback);
}
@Override
public void pull(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback, long timeout)
- throws MQClientException, RemotingException, InterruptedException {
+ throws MQClientException, RemotingException, InterruptedException {
this.defaultMQPullConsumerImpl.pull(mq, subExpression, offset, maxNums, pullCallback, timeout);
}
@Override
public PullResult pullBlockIfNotFound(MessageQueue mq, String subExpression, long offset, int maxNums)
- throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
return this.defaultMQPullConsumerImpl.pullBlockIfNotFound(mq, subExpression, offset, maxNums);
}
@Override
public void pullBlockIfNotFound(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback)
- throws MQClientException, RemotingException, InterruptedException {
+ throws MQClientException, RemotingException, InterruptedException {
this.defaultMQPullConsumerImpl.pullBlockIfNotFound(mq, subExpression, offset, maxNums, pullCallback);
}
@@ -341,7 +310,7 @@ public class DefaultMQPullConsumer extends ClientConfig implements MQPullConsume
@Override
public void sendMessageBack(MessageExt msg, int delayLevel, String brokerName, String consumerGroup)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
this.defaultMQPullConsumerImpl.sendMessageBack(msg, delayLevel, brokerName, consumerGroup);
}
@@ -349,32 +318,26 @@ public class DefaultMQPullConsumer extends ClientConfig implements MQPullConsume
return offsetStore;
}
-
public void setOffsetStore(OffsetStore offsetStore) {
this.offsetStore = offsetStore;
}
-
public DefaultMQPullConsumerImpl getDefaultMQPullConsumerImpl() {
return defaultMQPullConsumerImpl;
}
-
public boolean isUnitMode() {
return unitMode;
}
-
public void setUnitMode(boolean isUnitMode) {
this.unitMode = isUnitMode;
}
-
public int getMaxReconsumeTimes() {
return maxReconsumeTimes;
}
-
public void setMaxReconsumeTimes(final int maxReconsumeTimes) {
this.maxReconsumeTimes = maxReconsumeTimes;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
index 228e075..fcb3e64 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java
@@ -16,6 +16,9 @@
*/
package org.apache.rocketmq.client.consumer;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
import org.apache.rocketmq.client.ClientConfig;
import org.apache.rocketmq.client.QueryResult;
import org.apache.rocketmq.client.consumer.listener.MessageListener;
@@ -36,14 +39,8 @@ import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.remoting.exception.RemotingException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-
/**
* Wrapped push consumer.in fact,it works as remarkable as the pull consumer
- *
*/
public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsumer {
protected final transient DefaultMQPushConsumerImpl defaultMQPushConsumerImpl;
@@ -133,24 +130,20 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume
private long suspendCurrentQueueTimeMillis = 1000;
private long consumeTimeout = 15;
-
public DefaultMQPushConsumer() {
this(MixAll.DEFAULT_CONSUMER_GROUP, null, new AllocateMessageQueueAveragely());
}
-
public DefaultMQPushConsumer(final String consumerGroup, RPCHook rpcHook, AllocateMessageQueueStrategy allocateMessageQueueStrategy) {
this.consumerGroup = consumerGroup;
this.allocateMessageQueueStrategy = allocateMessageQueueStrategy;
defaultMQPushConsumerImpl = new DefaultMQPushConsumerImpl(this, rpcHook);
}
-
public DefaultMQPushConsumer(RPCHook rpcHook) {
this(MixAll.DEFAULT_CONSUMER_GROUP, rpcHook, new AllocateMessageQueueAveragely());
}
-
public DefaultMQPushConsumer(final String consumerGroup) {
this(consumerGroup, null, new AllocateMessageQueueAveragely());
}
@@ -160,46 +153,39 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume
createTopic(key, newTopic, queueNum, 0);
}
-
@Override
public void createTopic(String key, String newTopic, int queueNum, int topicSysFlag) throws MQClientException {
this.defaultMQPushConsumerImpl.createTopic(key, newTopic, queueNum, topicSysFlag);
}
-
@Override
public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
return this.defaultMQPushConsumerImpl.searchOffset(mq, timestamp);
}
-
@Override
public long maxOffset(MessageQueue mq) throws MQClientException {
return this.defaultMQPushConsumerImpl.maxOffset(mq);
}
-
@Override
public long minOffset(MessageQueue mq) throws MQClientException {
return this.defaultMQPushConsumerImpl.minOffset(mq);
}
-
@Override
public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
return this.defaultMQPushConsumerImpl.earliestMsgStoreTime(mq);
}
-
@Override
public MessageExt viewMessage(String offsetMsgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
return this.defaultMQPushConsumerImpl.viewMessage(offsetMsgId);
}
-
@Override
public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
- throws MQClientException, InterruptedException {
+ throws MQClientException, InterruptedException {
return this.defaultMQPushConsumerImpl.queryMessage(topic, key, maxNum, begin, end);
}
@@ -218,169 +204,137 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume
return allocateMessageQueueStrategy;
}
-
public void setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy allocateMessageQueueStrategy) {
this.allocateMessageQueueStrategy = allocateMessageQueueStrategy;
}
-
public int getConsumeConcurrentlyMaxSpan() {
return consumeConcurrentlyMaxSpan;
}
-
public void setConsumeConcurrentlyMaxSpan(int consumeConcurrentlyMaxSpan) {
this.consumeConcurrentlyMaxSpan = consumeConcurrentlyMaxSpan;
}
-
public ConsumeFromWhere getConsumeFromWhere() {
return consumeFromWhere;
}
-
public void setConsumeFromWhere(ConsumeFromWhere consumeFromWhere) {
this.consumeFromWhere = consumeFromWhere;
}
-
public int getConsumeMessageBatchMaxSize() {
return consumeMessageBatchMaxSize;
}
-
public void setConsumeMessageBatchMaxSize(int consumeMessageBatchMaxSize) {
this.consumeMessageBatchMaxSize = consumeMessageBatchMaxSize;
}
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public int getConsumeThreadMax() {
return consumeThreadMax;
}
-
public void setConsumeThreadMax(int consumeThreadMax) {
this.consumeThreadMax = consumeThreadMax;
}
-
public int getConsumeThreadMin() {
return consumeThreadMin;
}
-
public void setConsumeThreadMin(int consumeThreadMin) {
this.consumeThreadMin = consumeThreadMin;
}
-
public DefaultMQPushConsumerImpl getDefaultMQPushConsumerImpl() {
return defaultMQPushConsumerImpl;
}
-
public MessageListener getMessageListener() {
return messageListener;
}
-
public void setMessageListener(MessageListener messageListener) {
this.messageListener = messageListener;
}
-
public MessageModel getMessageModel() {
return messageModel;
}
-
public void setMessageModel(MessageModel messageModel) {
this.messageModel = messageModel;
}
-
public int getPullBatchSize() {
return pullBatchSize;
}
-
public void setPullBatchSize(int pullBatchSize) {
this.pullBatchSize = pullBatchSize;
}
-
public long getPullInterval() {
return pullInterval;
}
-
public void setPullInterval(long pullInterval) {
this.pullInterval = pullInterval;
}
-
public int getPullThresholdForQueue() {
return pullThresholdForQueue;
}
-
public void setPullThresholdForQueue(int pullThresholdForQueue) {
this.pullThresholdForQueue = pullThresholdForQueue;
}
-
public Map<String, String> getSubscription() {
return subscription;
}
-
public void setSubscription(Map<String, String> subscription) {
this.subscription = subscription;
}
-
@Override
public void sendMessageBack(MessageExt msg, int delayLevel)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
this.defaultMQPushConsumerImpl.sendMessageBack(msg, delayLevel, null);
}
-
@Override
public void sendMessageBack(MessageExt msg, int delayLevel, String brokerName)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
this.defaultMQPushConsumerImpl.sendMessageBack(msg, delayLevel, brokerName);
}
-
@Override
public Set<MessageQueue> fetchSubscribeMessageQueues(String topic) throws MQClientException {
return this.defaultMQPushConsumerImpl.fetchSubscribeMessageQueues(topic);
}
-
@Override
public void start() throws MQClientException {
this.defaultMQPushConsumerImpl.start();
}
-
@Override
public void shutdown() {
this.defaultMQPushConsumerImpl.shutdown();
}
-
@Override
@Deprecated
public void registerMessageListener(MessageListener messageListener) {
@@ -388,127 +342,104 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume
this.defaultMQPushConsumerImpl.registerMessageListener(messageListener);
}
-
@Override
public void registerMessageListener(MessageListenerConcurrently messageListener) {
this.messageListener = messageListener;
this.defaultMQPushConsumerImpl.registerMessageListener(messageListener);
}
-
@Override
public void registerMessageListener(MessageListenerOrderly messageListener) {
this.messageListener = messageListener;
this.defaultMQPushConsumerImpl.registerMessageListener(messageListener);
}
-
@Override
public void subscribe(String topic, String subExpression) throws MQClientException {
this.defaultMQPushConsumerImpl.subscribe(topic, subExpression);
}
-
@Override
public void subscribe(String topic, String fullClassName, String filterClassSource) throws MQClientException {
this.defaultMQPushConsumerImpl.subscribe(topic, fullClassName, filterClassSource);
}
-
@Override
public void unsubscribe(String topic) {
this.defaultMQPushConsumerImpl.unsubscribe(topic);
}
-
@Override
public void updateCorePoolSize(int corePoolSize) {
this.defaultMQPushConsumerImpl.updateCorePoolSize(corePoolSize);
}
-
@Override
public void suspend() {
this.defaultMQPushConsumerImpl.suspend();
}
-
@Override
public void resume() {
this.defaultMQPushConsumerImpl.resume();
}
-
public OffsetStore getOffsetStore() {
return offsetStore;
}
-
public void setOffsetStore(OffsetStore offsetStore) {
this.offsetStore = offsetStore;
}
-
public String getConsumeTimestamp() {
return consumeTimestamp;
}
-
public void setConsumeTimestamp(String consumeTimestamp) {
this.consumeTimestamp = consumeTimestamp;
}
-
public boolean isPostSubscriptionWhenPull() {
return postSubscriptionWhenPull;
}
-
public void setPostSubscriptionWhenPull(boolean postSubscriptionWhenPull) {
this.postSubscriptionWhenPull = postSubscriptionWhenPull;
}
-
public boolean isUnitMode() {
return unitMode;
}
-
public void setUnitMode(boolean isUnitMode) {
this.unitMode = isUnitMode;
}
-
public long getAdjustThreadPoolNumsThreshold() {
return adjustThreadPoolNumsThreshold;
}
-
public void setAdjustThreadPoolNumsThreshold(long adjustThreadPoolNumsThreshold) {
this.adjustThreadPoolNumsThreshold = adjustThreadPoolNumsThreshold;
}
-
public int getMaxReconsumeTimes() {
return maxReconsumeTimes;
}
-
public void setMaxReconsumeTimes(final int maxReconsumeTimes) {
this.maxReconsumeTimes = maxReconsumeTimes;
}
-
public long getSuspendCurrentQueueTimeMillis() {
return suspendCurrentQueueTimeMillis;
}
-
public void setSuspendCurrentQueueTimeMillis(final long suspendCurrentQueueTimeMillis) {
this.suspendCurrentQueueTimeMillis = suspendCurrentQueueTimeMillis;
}
-
public long getConsumeTimeout() {
return consumeTimeout;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
index 9d9c72b..343a0a2 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQConsumer.java
@@ -6,16 +6,17 @@
* (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
+ * 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.
+ * 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.consumer;
+import java.util.Set;
import org.apache.rocketmq.client.MQAdmin;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
@@ -23,9 +24,6 @@ import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.exception.RemotingException;
-import java.util.Set;
-
-
/**
* Message queue consumer interface
*
@@ -44,8 +42,7 @@ public interface MQConsumer extends MQAdmin {
*/
@Deprecated
void sendMessageBack(final MessageExt msg, final int delayLevel) throws RemotingException,
- MQBrokerException, InterruptedException, MQClientException;
-
+ MQBrokerException, InterruptedException, MQClientException;
/**
* If consuming failure,message will be send back to the broker,and delay consuming some time
@@ -60,8 +57,7 @@ public interface MQConsumer extends MQAdmin {
* @throws MQClientException
*/
void sendMessageBack(final MessageExt msg, final int delayLevel, final String brokerName)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
-
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
/**
* Fetch message queues from consumer cache according to the topic
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
index 2335e3d..d199f8a 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumer.java
@@ -6,25 +6,23 @@
* (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
+ * 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.
+ * 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.consumer;
+import java.util.Set;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.exception.RemotingException;
-import java.util.Set;
-
-
/**
* Pulling consumer interface
*
@@ -37,13 +35,11 @@ public interface MQPullConsumer extends MQConsumer {
*/
void start() throws MQClientException;
-
/**
* Shutdown the consumer
*/
void shutdown();
-
/**
* Register the message queue listener
*
@@ -52,7 +48,6 @@ public interface MQPullConsumer extends MQConsumer {
*/
void registerMessageQueueListener(final String topic, final MessageQueueListener listener);
-
/**
* Pulling the messages,not blocking
*
@@ -74,9 +69,8 @@ public interface MQPullConsumer extends MQConsumer {
* @throws RemotingException
*/
PullResult pull(final MessageQueue mq, final String subExpression, final long offset,
- final int maxNums) throws MQClientException, RemotingException, MQBrokerException,
- InterruptedException;
-
+ final int maxNums) throws MQClientException, RemotingException, MQBrokerException,
+ InterruptedException;
/**
* Pulling the messages in the specified timeout
@@ -95,9 +89,8 @@ public interface MQPullConsumer extends MQConsumer {
* @throws InterruptedException
*/
PullResult pull(final MessageQueue mq, final String subExpression, final long offset,
- final int maxNums, final long timeout) throws MQClientException, RemotingException,
- MQBrokerException, InterruptedException;
-
+ final int maxNums, final long timeout) throws MQClientException, RemotingException,
+ MQBrokerException, InterruptedException;
/**
* Pulling the messages in a async. way
@@ -113,8 +106,8 @@ public interface MQPullConsumer extends MQConsumer {
* @throws InterruptedException
*/
void pull(final MessageQueue mq, final String subExpression, final long offset, final int maxNums,
- final PullCallback pullCallback) throws MQClientException, RemotingException,
- InterruptedException;
+ final PullCallback pullCallback) throws MQClientException, RemotingException,
+ InterruptedException;
/**
* Pulling the messages in a async. way
@@ -131,9 +124,8 @@ public interface MQPullConsumer extends MQConsumer {
* @throws InterruptedException
*/
void pull(final MessageQueue mq, final String subExpression, final long offset, final int maxNums,
- final PullCallback pullCallback, long timeout) throws MQClientException, RemotingException,
- InterruptedException;
-
+ final PullCallback pullCallback, long timeout) throws MQClientException, RemotingException,
+ InterruptedException;
/**
* Pulling the messages,if no message arrival,blocking some time
@@ -151,9 +143,8 @@ public interface MQPullConsumer extends MQConsumer {
* @throws InterruptedException
*/
PullResult pullBlockIfNotFound(final MessageQueue mq, final String subExpression,
- final long offset, final int maxNums) throws MQClientException, RemotingException,
- MQBrokerException, InterruptedException;
-
+ final long offset, final int maxNums) throws MQClientException, RemotingException,
+ MQBrokerException, InterruptedException;
/**
* Pulling the messages through callback function,if no message arrival,blocking.
@@ -169,9 +160,8 @@ public interface MQPullConsumer extends MQConsumer {
* @throws InterruptedException
*/
void pullBlockIfNotFound(final MessageQueue mq, final String subExpression, final long offset,
- final int maxNums, final PullCallback pullCallback) throws MQClientException, RemotingException,
- InterruptedException;
-
+ final int maxNums, final PullCallback pullCallback) throws MQClientException, RemotingException,
+ InterruptedException;
/**
* Update the offset
@@ -183,7 +173,6 @@ public interface MQPullConsumer extends MQConsumer {
*/
void updateConsumeOffset(final MessageQueue mq, final long offset) throws MQClientException;
-
/**
* Fetch the offset
*
@@ -196,7 +185,6 @@ public interface MQPullConsumer extends MQConsumer {
*/
long fetchConsumeOffset(final MessageQueue mq, final boolean fromStore) throws MQClientException;
-
/**
* Fetch the message queues according to the topic
*
@@ -224,5 +212,5 @@ public interface MQPullConsumer extends MQConsumer {
* @throws MQClientException
*/
void sendMessageBack(MessageExt msg, int delayLevel, String brokerName, String consumerGroup)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java
index da8ffb5..ec747e2 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPullConsumerScheduleService.java
@@ -16,34 +16,31 @@
*/
package org.apache.rocketmq.client.consumer;
-import org.apache.rocketmq.client.exception.MQClientException;
-import org.apache.rocketmq.client.log.ClientLogger;
-import org.apache.rocketmq.common.ThreadFactoryImpl;
-import org.apache.rocketmq.common.message.MessageQueue;
-import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
-import org.slf4j.Logger;
-
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
-
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.ThreadFactoryImpl;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+import org.slf4j.Logger;
/**
* Schedule service for pull consumer
- *
*/
public class MQPullConsumerScheduleService {
private final Logger log = ClientLogger.getLog();
private final MessageQueueListener messageQueueListener = new MessageQueueListenerImpl();
private final ConcurrentHashMap<MessageQueue, PullTaskImpl> taskTable =
- new ConcurrentHashMap<MessageQueue, PullTaskImpl>();
+ new ConcurrentHashMap<MessageQueue, PullTaskImpl>();
private DefaultMQPullConsumer defaultMQPullConsumer;
private int pullThreadNums = 20;
private ConcurrentHashMap<String /* topic */, PullTaskCallback> callbackTable =
- new ConcurrentHashMap<String, PullTaskCallback>();
+ new ConcurrentHashMap<String, PullTaskCallback>();
private ScheduledThreadPoolExecutor scheduledThreadPoolExecutor;
public MQPullConsumerScheduleService(final String consumerGroup) {
@@ -76,8 +73,8 @@ public class MQPullConsumerScheduleService {
public void start() throws MQClientException {
final String group = this.defaultMQPullConsumer.getConsumerGroup();
this.scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(
- this.pullThreadNums,
- new ThreadFactoryImpl("PullMsgThread-" + group)
+ this.pullThreadNums,
+ new ThreadFactoryImpl("PullMsgThread-" + group)
);
this.defaultMQPullConsumer.setMessageQueueListener(this.messageQueueListener);
@@ -85,7 +82,7 @@ public class MQPullConsumerScheduleService {
this.defaultMQPullConsumer.start();
log.info("MQPullConsumerScheduleService start OK, {} {}",
- this.defaultMQPullConsumer.getConsumerGroup(), this.callbackTable);
+ this.defaultMQPullConsumer.getConsumerGroup(), this.callbackTable);
}
public void registerPullTaskCallback(final String topic, final PullTaskCallback callback) {
@@ -139,7 +136,7 @@ public class MQPullConsumerScheduleService {
@Override
public void messageQueueChanged(String topic, Set<MessageQueue> mqAll, Set<MessageQueue> mqDivided) {
MessageModel messageModel =
- MQPullConsumerScheduleService.this.defaultMQPullConsumer.getMessageModel();
+ MQPullConsumerScheduleService.this.defaultMQPullConsumer.getMessageModel();
switch (messageModel) {
case BROADCASTING:
MQPullConsumerScheduleService.this.putTask(topic, mqAll);
@@ -157,18 +154,16 @@ public class MQPullConsumerScheduleService {
private final MessageQueue messageQueue;
private volatile boolean cancelled = false;
-
public PullTaskImpl(final MessageQueue messageQueue) {
this.messageQueue = messageQueue;
}
-
@Override
public void run() {
String topic = this.messageQueue.getTopic();
if (!this.isCancelled()) {
PullTaskCallback pullTaskCallback =
- MQPullConsumerScheduleService.this.callbackTable.get(topic);
+ MQPullConsumerScheduleService.this.callbackTable.get(topic);
if (pullTaskCallback != null) {
final PullTaskContext context = new PullTaskContext();
context.setPullConsumer(MQPullConsumerScheduleService.this.defaultMQPullConsumer);
@@ -181,7 +176,7 @@ public class MQPullConsumerScheduleService {
if (!this.isCancelled()) {
MQPullConsumerScheduleService.this.scheduledThreadPoolExecutor.schedule(this,
- context.getPullNextDelayTimeMillis(), TimeUnit.MILLISECONDS);
+ context.getPullNextDelayTimeMillis(), TimeUnit.MILLISECONDS);
} else {
log.warn("The Pull Task is cancelled after doPullTask, {}", messageQueue);
}
@@ -193,17 +188,14 @@ public class MQPullConsumerScheduleService {
}
}
-
public boolean isCancelled() {
return cancelled;
}
-
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
-
public MessageQueue getMessageQueue() {
return messageQueue;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
index b04956c..1b969bd 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MQPushConsumer.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.consumer;
@@ -21,7 +21,6 @@ import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import org.apache.rocketmq.client.consumer.listener.MessageListenerOrderly;
import org.apache.rocketmq.client.exception.MQClientException;
-
/**
* Push consumer
*
@@ -34,13 +33,11 @@ public interface MQPushConsumer extends MQConsumer {
*/
void start() throws MQClientException;
-
/**
* Shutdown the consumer
*/
void shutdown();
-
/**
* Register the message listener
*
@@ -49,13 +46,10 @@ public interface MQPushConsumer extends MQConsumer {
@Deprecated
void registerMessageListener(MessageListener messageListener);
-
void registerMessageListener(final MessageListenerConcurrently messageListener);
-
void registerMessageListener(final MessageListenerOrderly messageListener);
-
/**
* Subscribe some topic
*
@@ -69,7 +63,6 @@ public interface MQPushConsumer extends MQConsumer {
*/
void subscribe(final String topic, final String subExpression) throws MQClientException;
-
/**
* Subscribe some topic
*
@@ -85,7 +78,6 @@ public interface MQPushConsumer extends MQConsumer {
*/
void subscribe(final String topic, final String fullClassName, final String filterClassSource) throws MQClientException;
-
/**
* Unsubscribe consumption some topic
*
@@ -94,7 +86,6 @@ public interface MQPushConsumer extends MQConsumer {
*/
void unsubscribe(final String topic);
-
/**
* Update the consumer thread pool size Dynamically
*
@@ -102,13 +93,11 @@ public interface MQPushConsumer extends MQConsumer {
*/
void updateCorePoolSize(int corePoolSize);
-
/**
* Suspend the consumption
*/
void suspend();
-
/**
* Resume the consumption
*/
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java b/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
index 7a08348..0cc2dc4 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/MessageQueueListener.java
@@ -6,20 +6,18 @@
* (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
+ * 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.
+ * 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.consumer;
-import org.apache.rocketmq.common.message.MessageQueue;
-
import java.util.Set;
-
+import org.apache.rocketmq.common.message.MessageQueue;
/**
* A MessageQueueListener is implemented by the application and may be specified when a message queue changed
@@ -35,5 +33,5 @@ public interface MessageQueueListener {
* collection of queues,assigned to the current consumer
*/
void messageQueueChanged(final String topic, final Set<MessageQueue> mqAll,
- final Set<MessageQueue> mqDivided);
+ final Set<MessageQueue> mqDivided);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
index cf554c4..06e47d9 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullCallback.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.consumer;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java
index 1cb23ce..e494f74 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullResult.java
@@ -6,20 +6,18 @@
* (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
+ * 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.
+ * 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.consumer;
-import org.apache.rocketmq.common.message.MessageExt;
-
import java.util.List;
-
+import org.apache.rocketmq.common.message.MessageExt;
public class PullResult {
private final PullStatus pullStatus;
@@ -28,9 +26,8 @@ public class PullResult {
private final long maxOffset;
private List<MessageExt> msgFoundList;
-
public PullResult(PullStatus pullStatus, long nextBeginOffset, long minOffset, long maxOffset,
- List<MessageExt> msgFoundList) {
+ List<MessageExt> msgFoundList) {
super();
this.pullStatus = pullStatus;
this.nextBeginOffset = nextBeginOffset;
@@ -39,41 +36,34 @@ public class PullResult {
this.msgFoundList = msgFoundList;
}
-
public PullStatus getPullStatus() {
return pullStatus;
}
-
public long getNextBeginOffset() {
return nextBeginOffset;
}
-
public long getMinOffset() {
return minOffset;
}
-
public long getMaxOffset() {
return maxOffset;
}
-
public List<MessageExt> getMsgFoundList() {
return msgFoundList;
}
-
public void setMsgFoundList(List<MessageExt> msgFoundList) {
this.msgFoundList = msgFoundList;
}
-
@Override
public String toString() {
return "PullResult [pullStatus=" + pullStatus + ", nextBeginOffset=" + nextBeginOffset
- + ", minOffset=" + minOffset + ", maxOffset=" + maxOffset + ", msgFoundList="
- + (msgFoundList == null ? 0 : msgFoundList.size()) + "]";
+ + ", minOffset=" + minOffset + ", maxOffset=" + maxOffset + ", msgFoundList="
+ + (msgFoundList == null ? 0 : msgFoundList.size()) + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java
index b2a3c8c..a400d90 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullStatus.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.consumer;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskCallback.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskCallback.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskCallback.java
index dc74bca..bc9a867 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskCallback.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskCallback.java
@@ -6,19 +6,18 @@
* (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
+ * 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.
+ * 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.consumer;
import org.apache.rocketmq.common.message.MessageQueue;
-
public interface PullTaskCallback {
void doPullTask(final MessageQueue mq, final PullTaskContext context);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskContext.java b/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskContext.java
index ba66a1f..f0114ae 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskContext.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/PullTaskContext.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.consumer;
@@ -22,22 +22,18 @@ public class PullTaskContext {
private MQPullConsumer pullConsumer;
-
public int getPullNextDelayTimeMillis() {
return pullNextDelayTimeMillis;
}
-
public void setPullNextDelayTimeMillis(int pullNextDelayTimeMillis) {
this.pullNextDelayTimeMillis = pullNextDelayTimeMillis;
}
-
public MQPullConsumer getPullConsumer() {
return pullConsumer;
}
-
public void setPullConsumer(MQPullConsumer pullConsumer) {
this.pullConsumer = pullConsumer;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java
index 981ceaf..40ac6c1 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyContext.java
@@ -18,10 +18,8 @@ package org.apache.rocketmq.client.consumer.listener;
import org.apache.rocketmq.common.message.MessageQueue;
-
/**
* Consumer concurrent consumption context
- *
*/
public class ConsumeConcurrentlyContext {
private final MessageQueue messageQueue;
@@ -38,27 +36,22 @@ public class ConsumeConcurrentlyContext {
this.messageQueue = messageQueue;
}
-
public int getDelayLevelWhenNextConsume() {
return delayLevelWhenNextConsume;
}
-
public void setDelayLevelWhenNextConsume(int delayLevelWhenNextConsume) {
this.delayLevelWhenNextConsume = delayLevelWhenNextConsume;
}
-
public MessageQueue getMessageQueue() {
return messageQueue;
}
-
public int getAckIndex() {
return ackIndex;
}
-
public void setAckIndex(int ackIndex) {
this.ackIndex = ackIndex;
}
[89/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java
index cd66699..0830842 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeConcurrentlyStatus.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.consumer.listener;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
index 3c1ef3d..405781b 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyContext.java
@@ -6,19 +6,18 @@
* (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
+ * 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.
+ * 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.consumer.listener;
import org.apache.rocketmq.common.message.MessageQueue;
-
/**
* Consumer Orderly consumption context
*
@@ -28,32 +27,26 @@ public class ConsumeOrderlyContext {
private boolean autoCommit = true;
private long suspendCurrentQueueTimeMillis = -1;
-
public ConsumeOrderlyContext(MessageQueue messageQueue) {
this.messageQueue = messageQueue;
}
-
public boolean isAutoCommit() {
return autoCommit;
}
-
public void setAutoCommit(boolean autoCommit) {
this.autoCommit = autoCommit;
}
-
public MessageQueue getMessageQueue() {
return messageQueue;
}
-
public long getSuspendCurrentQueueTimeMillis() {
return suspendCurrentQueueTimeMillis;
}
-
public void setSuspendCurrentQueueTimeMillis(long suspendCurrentQueueTimeMillis) {
this.suspendCurrentQueueTimeMillis = suspendCurrentQueueTimeMillis;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java
index 2e55d89..0c6c6e6 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeOrderlyStatus.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.consumer.listener;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeReturnType.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeReturnType.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeReturnType.java
index 99083b4..5de4ded 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeReturnType.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/ConsumeReturnType.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.consumer.listener;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
index 5d05452..2a9e5c9 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListener.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.consumer.listener;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
index 1c59ef7..c083157 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerConcurrently.java
@@ -6,20 +6,18 @@
* (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
+ * 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.
+ * 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.consumer.listener;
-import org.apache.rocketmq.common.message.MessageExt;
-
import java.util.List;
-
+import org.apache.rocketmq.common.message.MessageExt;
/**
* A MessageListenerConcurrently object is used to receive asynchronously delivered messages concurrently
@@ -37,5 +35,5 @@ public interface MessageListenerConcurrently extends MessageListener {
* @return The consume status
*/
ConsumeConcurrentlyStatus consumeMessage(final List<MessageExt> msgs,
- final ConsumeConcurrentlyContext context);
+ final ConsumeConcurrentlyContext context);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
index 5de976f..57a553a 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/listener/MessageListenerOrderly.java
@@ -6,20 +6,18 @@
* (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
+ * 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.
+ * 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.consumer.listener;
-import org.apache.rocketmq.common.message.MessageExt;
-
import java.util.List;
-
+import org.apache.rocketmq.common.message.MessageExt;
/**
* A MessageListenerConcurrently object is used to receive asynchronously delivered messages orderly.one queue,one thread
@@ -37,5 +35,5 @@ public interface MessageListenerOrderly extends MessageListener {
* @return The consume status
*/
ConsumeOrderlyStatus consumeMessage(final List<MessageExt> msgs,
- final ConsumeOrderlyContext context);
+ final ConsumeOrderlyContext context);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragely.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragely.java b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragely.java
index 218f659..256c639 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragely.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragely.java
@@ -16,25 +16,22 @@
*/
package org.apache.rocketmq.client.consumer.rebalance;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.rocketmq.client.consumer.AllocateMessageQueueStrategy;
import org.apache.rocketmq.client.log.ClientLogger;
import org.apache.rocketmq.common.message.MessageQueue;
import org.slf4j.Logger;
-import java.util.ArrayList;
-import java.util.List;
-
-
/**
* Average Hashing queue algorithm
- *
*/
public class AllocateMessageQueueAveragely implements AllocateMessageQueueStrategy {
private final Logger log = ClientLogger.getLog();
@Override
public List<MessageQueue> allocate(String consumerGroup, String currentCID, List<MessageQueue> mqAll,
- List<String> cidAll) {
+ List<String> cidAll) {
if (currentCID == null || currentCID.length() < 1) {
throw new IllegalArgumentException("currentCID is empty");
}
@@ -48,17 +45,17 @@ public class AllocateMessageQueueAveragely implements AllocateMessageQueueStrate
List<MessageQueue> result = new ArrayList<MessageQueue>();
if (!cidAll.contains(currentCID)) {
log.info("[BUG] ConsumerGroup: {} The consumerId: {} not in cidAll: {}",
- consumerGroup,
- currentCID,
- cidAll);
+ consumerGroup,
+ currentCID,
+ cidAll);
return result;
}
int index = cidAll.indexOf(currentCID);
int mod = mqAll.size() % cidAll.size();
int averageSize =
- mqAll.size() <= cidAll.size() ? 1 : (mod > 0 && index < mod ? mqAll.size() / cidAll.size()
- + 1 : mqAll.size() / cidAll.size());
+ mqAll.size() <= cidAll.size() ? 1 : (mod > 0 && index < mod ? mqAll.size() / cidAll.size()
+ + 1 : mqAll.size() / cidAll.size());
int startIndex = (mod > 0 && index < mod) ? index * averageSize : index * averageSize + mod;
int range = Math.min(averageSize, mqAll.size() - startIndex);
for (int i = 0; i < range; i++) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragelyByCircle.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragelyByCircle.java b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragelyByCircle.java
index d612d4f..5df5cd2 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragelyByCircle.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueAveragelyByCircle.java
@@ -16,25 +16,22 @@
*/
package org.apache.rocketmq.client.consumer.rebalance;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.rocketmq.client.consumer.AllocateMessageQueueStrategy;
import org.apache.rocketmq.client.log.ClientLogger;
import org.apache.rocketmq.common.message.MessageQueue;
import org.slf4j.Logger;
-import java.util.ArrayList;
-import java.util.List;
-
-
/**
* Cycle average Hashing queue algorithm
- *
*/
public class AllocateMessageQueueAveragelyByCircle implements AllocateMessageQueueStrategy {
private final Logger log = ClientLogger.getLog();
@Override
public List<MessageQueue> allocate(String consumerGroup, String currentCID, List<MessageQueue> mqAll,
- List<String> cidAll) {
+ List<String> cidAll) {
if (currentCID == null || currentCID.length() < 1) {
throw new IllegalArgumentException("currentCID is empty");
}
@@ -48,9 +45,9 @@ public class AllocateMessageQueueAveragelyByCircle implements AllocateMessageQue
List<MessageQueue> result = new ArrayList<MessageQueue>();
if (!cidAll.contains(currentCID)) {
log.info("[BUG] ConsumerGroup: {} The consumerId: {} not in cidAll: {}",
- consumerGroup,
- currentCID,
- cidAll);
+ consumerGroup,
+ currentCID,
+ cidAll);
return result;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java
index c8fe2d1..387822d 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByConfig.java
@@ -6,28 +6,26 @@
* (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
+ * 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.
+ * 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.consumer.rebalance;
+import java.util.List;
import org.apache.rocketmq.client.consumer.AllocateMessageQueueStrategy;
import org.apache.rocketmq.common.message.MessageQueue;
-import java.util.List;
-
-
public class AllocateMessageQueueByConfig implements AllocateMessageQueueStrategy {
private List<MessageQueue> messageQueueList;
@Override
public List<MessageQueue> allocate(String consumerGroup, String currentCID, List<MessageQueue> mqAll,
- List<String> cidAll) {
+ List<String> cidAll) {
return this.messageQueueList;
}
@@ -40,7 +38,6 @@ public class AllocateMessageQueueByConfig implements AllocateMessageQueueStrateg
return messageQueueList;
}
-
public void setMessageQueueList(List<MessageQueue> messageQueueList) {
this.messageQueueList = messageQueueList;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByMachineRoom.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByMachineRoom.java b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByMachineRoom.java
index adfc124..a154f89 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByMachineRoom.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/rebalance/AllocateMessageQueueByMachineRoom.java
@@ -6,23 +6,21 @@
* (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
+ * 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.
+ * 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.consumer.rebalance;
-import org.apache.rocketmq.client.consumer.AllocateMessageQueueStrategy;
-import org.apache.rocketmq.common.message.MessageQueue;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-
+import org.apache.rocketmq.client.consumer.AllocateMessageQueueStrategy;
+import org.apache.rocketmq.common.message.MessageQueue;
/**
* Computer room Hashing queue algorithm, such as Alipay logic room
@@ -32,7 +30,7 @@ public class AllocateMessageQueueByMachineRoom implements AllocateMessageQueueSt
@Override
public List<MessageQueue> allocate(String consumerGroup, String currentCID, List<MessageQueue> mqAll,
- List<String> cidAll) {
+ List<String> cidAll) {
List<MessageQueue> result = new ArrayList<MessageQueue>();
int currentIndex = cidAll.indexOf(currentCID);
if (currentIndex < 0) {
@@ -68,7 +66,6 @@ public class AllocateMessageQueueByMachineRoom implements AllocateMessageQueueSt
return consumeridcs;
}
-
public void setConsumeridcs(Set<String> consumeridcs) {
this.consumeridcs = consumeridcs;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
index bdaeb58..053ade2 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
@@ -16,6 +16,13 @@
*/
package org.apache.rocketmq.client.consumer.store;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicLong;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.impl.factory.MQClientInstance;
@@ -27,41 +34,29 @@ import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.exception.RemotingException;
import org.slf4j.Logger;
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
-
-
/**
* Local storage implementation
- *
*/
public class LocalFileOffsetStore implements OffsetStore {
public final static String LOCAL_OFFSET_STORE_DIR = System.getProperty(
- "rocketmq.client.localOffsetStoreDir",
- System.getProperty("user.home") + File.separator + ".rocketmq_offsets");
+ "rocketmq.client.localOffsetStoreDir",
+ System.getProperty("user.home") + File.separator + ".rocketmq_offsets");
private final static Logger log = ClientLogger.getLog();
private final MQClientInstance mQClientFactory;
private final String groupName;
private final String storePath;
private ConcurrentHashMap<MessageQueue, AtomicLong> offsetTable =
- new ConcurrentHashMap<MessageQueue, AtomicLong>();
-
+ new ConcurrentHashMap<MessageQueue, AtomicLong>();
public LocalFileOffsetStore(MQClientInstance mQClientFactory, String groupName) {
this.mQClientFactory = mQClientFactory;
this.groupName = groupName;
this.storePath = LOCAL_OFFSET_STORE_DIR + File.separator + //
- this.mQClientFactory.getClientId() + File.separator + //
- this.groupName + File.separator + //
- "offsets.json";
+ this.mQClientFactory.getClientId() + File.separator + //
+ this.groupName + File.separator + //
+ "offsets.json";
}
-
@Override
public void load() throws MQClientException {
OffsetSerializeWrapper offsetSerializeWrapper = this.readLocalOffset();
@@ -71,14 +66,13 @@ public class LocalFileOffsetStore implements OffsetStore {
for (MessageQueue mq : offsetSerializeWrapper.getOffsetTable().keySet()) {
AtomicLong offset = offsetSerializeWrapper.getOffsetTable().get(mq);
log.info("load consumer's offset, {} {} {}",
- this.groupName,
- mq,
- offset.get());
+ this.groupName,
+ mq,
+ offset.get());
}
}
}
-
@Override
public void updateOffset(MessageQueue mq, long offset, boolean increaseOnly) {
if (mq != null) {
@@ -97,7 +91,6 @@ public class LocalFileOffsetStore implements OffsetStore {
}
}
-
@Override
public long readOffset(final MessageQueue mq, final ReadOffsetType type) {
if (mq != null) {
@@ -134,7 +127,6 @@ public class LocalFileOffsetStore implements OffsetStore {
return -1;
}
-
@Override
public void persistAll(Set<MessageQueue> mqs) {
if (null == mqs || mqs.isEmpty())
@@ -158,7 +150,6 @@ public class LocalFileOffsetStore implements OffsetStore {
}
}
-
@Override
public void persist(MessageQueue mq) {
}
@@ -170,7 +161,7 @@ public class LocalFileOffsetStore implements OffsetStore {
@Override
public void updateConsumeOffsetToBroker(final MessageQueue mq, final long offset, final boolean isOneway)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
}
@@ -196,7 +187,7 @@ public class LocalFileOffsetStore implements OffsetStore {
OffsetSerializeWrapper offsetSerializeWrapper = null;
try {
offsetSerializeWrapper =
- OffsetSerializeWrapper.fromJson(content, OffsetSerializeWrapper.class);
+ OffsetSerializeWrapper.fromJson(content, OffsetSerializeWrapper.class);
} catch (Exception e) {
log.warn("readLocalOffset Exception, and try to correct", e);
return this.readLocalOffsetBak();
@@ -212,12 +203,12 @@ public class LocalFileOffsetStore implements OffsetStore {
OffsetSerializeWrapper offsetSerializeWrapper = null;
try {
offsetSerializeWrapper =
- OffsetSerializeWrapper.fromJson(content, OffsetSerializeWrapper.class);
+ OffsetSerializeWrapper.fromJson(content, OffsetSerializeWrapper.class);
} catch (Exception e) {
log.warn("readLocalOffset Exception", e);
throw new MQClientException("readLocalOffset Exception, maybe fastjson version too low" //
- + FAQUrl.suggestTodo(FAQUrl.LOAD_JSON_EXCEPTION), //
- e);
+ + FAQUrl.suggestTodo(FAQUrl.LOAD_JSON_EXCEPTION), //
+ e);
}
return offsetSerializeWrapper;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
index a9fadf2..4954f6f 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
@@ -6,22 +6,20 @@
* (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
+ * 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.
+ * 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.consumer.store;
-import org.apache.rocketmq.common.message.MessageQueue;
-import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
-
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
-
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
/**
* Wrapper class for offset serialization
@@ -29,7 +27,7 @@ import java.util.concurrent.atomic.AtomicLong;
*/
public class OffsetSerializeWrapper extends RemotingSerializable {
private ConcurrentHashMap<MessageQueue, AtomicLong> offsetTable =
- new ConcurrentHashMap<MessageQueue, AtomicLong>();
+ new ConcurrentHashMap<MessageQueue, AtomicLong>();
public ConcurrentHashMap<MessageQueue, AtomicLong> getOffsetTable() {
return offsetTable;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
index 334f0a1..592796f 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
@@ -6,25 +6,23 @@
* (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
+ * 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.
+ * 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.consumer.store;
+import java.util.Map;
+import java.util.Set;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.exception.RemotingException;
-import java.util.Map;
-import java.util.Set;
-
-
/**
* Offset store interface
*
@@ -37,7 +35,6 @@ public interface OffsetStore {
*/
void load() throws MQClientException;
-
/**
* Update the offset,store it in memory
*
@@ -91,6 +88,6 @@ public interface OffsetStore {
* @param offset
* @param isOneway
*/
- void updateConsumeOffsetToBroker(MessageQueue mq, long offset, boolean isOneway) throws RemotingException,
- MQBrokerException, InterruptedException, MQClientException;
+ void updateConsumeOffsetToBroker(MessageQueue mq, long offset, boolean isOneway) throws RemotingException,
+ MQBrokerException, InterruptedException, MQClientException;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/store/ReadOffsetType.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/ReadOffsetType.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/ReadOffsetType.java
index c2ee9b7..da16765 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/store/ReadOffsetType.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/ReadOffsetType.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.consumer.store;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
index 4adc18c..32ef877 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
@@ -16,6 +16,12 @@
*/
package org.apache.rocketmq.client.consumer.store;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicLong;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.impl.FindBrokerResult;
@@ -29,37 +35,25 @@ import org.apache.rocketmq.common.protocol.header.UpdateConsumerOffsetRequestHea
import org.apache.rocketmq.remoting.exception.RemotingException;
import org.slf4j.Logger;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
-
-
/**
* Remote storage implementation
- *
*/
public class RemoteBrokerOffsetStore implements OffsetStore {
private final static Logger log = ClientLogger.getLog();
private final MQClientInstance mQClientFactory;
private final String groupName;
private ConcurrentHashMap<MessageQueue, AtomicLong> offsetTable =
- new ConcurrentHashMap<MessageQueue, AtomicLong>();
-
+ new ConcurrentHashMap<MessageQueue, AtomicLong>();
public RemoteBrokerOffsetStore(MQClientInstance mQClientFactory, String groupName) {
this.mQClientFactory = mQClientFactory;
this.groupName = groupName;
}
-
@Override
public void load() {
}
-
@Override
public void updateOffset(MessageQueue mq, long offset, boolean increaseOnly) {
if (mq != null) {
@@ -78,7 +72,6 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
}
}
-
@Override
public long readOffset(final MessageQueue mq, final ReadOffsetType type) {
if (mq != null) {
@@ -117,7 +110,6 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
return -1;
}
-
@Override
public void persistAll(Set<MessageQueue> mqs) {
if (null == mqs || mqs.isEmpty())
@@ -133,10 +125,10 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
try {
this.updateConsumeOffsetToBroker(mq, offset.get());
log.info("[persistAll] Group: {} ClientId: {} updateConsumeOffsetToBroker {} {}",
- this.groupName,
- this.mQClientFactory.getClientId(),
- mq,
- offset.get());
+ this.groupName,
+ this.mQClientFactory.getClientId(),
+ mq,
+ offset.get());
} catch (Exception e) {
log.error("updateConsumeOffsetToBroker exception, " + mq.toString(), e);
}
@@ -155,7 +147,6 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
}
}
-
@Override
public void persist(MessageQueue mq) {
AtomicLong offset = this.offsetTable.get(mq);
@@ -163,10 +154,10 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
try {
this.updateConsumeOffsetToBroker(mq, offset.get());
log.info("[persist] Group: {} ClientId: {} updateConsumeOffsetToBroker {} {}",
- this.groupName,
- this.mQClientFactory.getClientId(),
- mq,
- offset.get());
+ this.groupName,
+ this.mQClientFactory.getClientId(),
+ mq,
+ offset.get());
} catch (Exception e) {
log.error("updateConsumeOffsetToBroker exception, " + mq.toString(), e);
}
@@ -177,7 +168,7 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
if (mq != null) {
this.offsetTable.remove(mq);
log.info("remove unnecessary messageQueue offset. group={}, mq={}, offsetTableSize={}", this.groupName, mq,
- offsetTable.size());
+ offsetTable.size());
}
}
@@ -199,7 +190,7 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
* here need to be optimized.
*/
private void updateConsumeOffsetToBroker(MessageQueue mq, long offset) throws RemotingException,
- MQBrokerException, InterruptedException, MQClientException {
+ MQBrokerException, InterruptedException, MQClientException {
updateConsumeOffsetToBroker(mq, offset, true);
}
@@ -209,7 +200,7 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
*/
@Override
public void updateConsumeOffsetToBroker(MessageQueue mq, long offset, boolean isOneway) throws RemotingException,
- MQBrokerException, InterruptedException, MQClientException {
+ MQBrokerException, InterruptedException, MQClientException {
FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInAdmin(mq.getBrokerName());
if (null == findBrokerResult) {
// TODO Here may be heavily overhead for Name Server,need tuning
@@ -226,10 +217,10 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
if (isOneway) {
this.mQClientFactory.getMQClientAPIImpl().updateConsumerOffsetOneway(
- findBrokerResult.getBrokerAddr(), requestHeader, 1000 * 5);
+ findBrokerResult.getBrokerAddr(), requestHeader, 1000 * 5);
} else {
this.mQClientFactory.getMQClientAPIImpl().updateConsumerOffset(
- findBrokerResult.getBrokerAddr(), requestHeader, 1000 * 5);
+ findBrokerResult.getBrokerAddr(), requestHeader, 1000 * 5);
}
} else {
throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
@@ -237,7 +228,7 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
}
private long fetchConsumeOffsetFromBroker(MessageQueue mq) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException {
+ InterruptedException, MQClientException {
FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInAdmin(mq.getBrokerName());
if (null == findBrokerResult) {
// TODO Here may be heavily overhead for Name Server,need tuning
@@ -252,7 +243,7 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
requestHeader.setQueueId(mq.getQueueId());
return this.mQClientFactory.getMQClientAPIImpl().queryConsumerOffset(
- findBrokerResult.getBrokerAddr(), requestHeader, 1000 * 5);
+ findBrokerResult.getBrokerAddr(), requestHeader, 1000 * 5);
} else {
throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java b/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java
index ce4bedb..7515a30 100644
--- a/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java
+++ b/client/src/main/java/org/apache/rocketmq/client/exception/MQBrokerException.java
@@ -6,39 +6,35 @@
* (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
+ * 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.
+ * 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.exception;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.help.FAQUrl;
-
public class MQBrokerException extends Exception {
private static final long serialVersionUID = 5975020272601250368L;
private final int responseCode;
private final String errorMessage;
-
public MQBrokerException(int responseCode, String errorMessage) {
super(FAQUrl.attachDefaultURL("CODE: " + UtilAll.responseCode2String(responseCode) + " DESC: "
- + errorMessage));
+ + errorMessage));
this.responseCode = responseCode;
this.errorMessage = errorMessage;
}
-
public int getResponseCode() {
return responseCode;
}
-
public String getErrorMessage() {
return errorMessage;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java b/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java
index 7ffab0d..41a2b59 100644
--- a/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java
+++ b/client/src/main/java/org/apache/rocketmq/client/exception/MQClientException.java
@@ -6,36 +6,33 @@
* (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
+ * 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.
+ * 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.exception;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.help.FAQUrl;
-
public class MQClientException extends Exception {
private static final long serialVersionUID = -5758410930844185841L;
private int responseCode;
private String errorMessage;
-
public MQClientException(String errorMessage, Throwable cause) {
super(FAQUrl.attachDefaultURL(errorMessage), cause);
this.responseCode = -1;
this.errorMessage = errorMessage;
}
-
public MQClientException(int responseCode, String errorMessage) {
super(FAQUrl.attachDefaultURL("CODE: " + UtilAll.responseCode2String(responseCode) + " DESC: "
- + errorMessage));
+ + errorMessage));
this.responseCode = responseCode;
this.errorMessage = errorMessage;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenContext.java b/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenContext.java
index e84beff..cf6c157 100644
--- a/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenContext.java
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenContext.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.hook;
@@ -21,7 +21,6 @@ import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageQueue;
-
public class CheckForbiddenContext {
private String nameSrvAddr;
private String group;
@@ -34,112 +33,91 @@ public class CheckForbiddenContext {
private Object arg;
private boolean unitMode = false;
-
public String getGroup() {
return group;
}
-
public void setGroup(String group) {
this.group = group;
}
-
public Message getMessage() {
return message;
}
-
public void setMessage(Message message) {
this.message = message;
}
-
public MessageQueue getMq() {
return mq;
}
-
public void setMq(MessageQueue mq) {
this.mq = mq;
}
-
public String getBrokerAddr() {
return brokerAddr;
}
-
public void setBrokerAddr(String brokerAddr) {
this.brokerAddr = brokerAddr;
}
-
public CommunicationMode getCommunicationMode() {
return communicationMode;
}
-
public void setCommunicationMode(CommunicationMode communicationMode) {
this.communicationMode = communicationMode;
}
-
public SendResult getSendResult() {
return sendResult;
}
-
public void setSendResult(SendResult sendResult) {
this.sendResult = sendResult;
}
-
public Exception getException() {
return exception;
}
-
public void setException(Exception exception) {
this.exception = exception;
}
-
public Object getArg() {
return arg;
}
-
public void setArg(Object arg) {
this.arg = arg;
}
-
public boolean isUnitMode() {
return unitMode;
}
-
public void setUnitMode(boolean isUnitMode) {
this.unitMode = isUnitMode;
}
-
public String getNameSrvAddr() {
return nameSrvAddr;
}
-
public void setNameSrvAddr(String nameSrvAddr) {
this.nameSrvAddr = nameSrvAddr;
}
-
@Override
public String toString() {
return "SendMessageContext [nameSrvAddr=" + nameSrvAddr + ", group=" + group + ", message=" + message
- + ", mq=" + mq + ", brokerAddr=" + brokerAddr + ", communicationMode=" + communicationMode
- + ", sendResult=" + sendResult + ", exception=" + exception + ", unitMode=" + unitMode
- + ", arg=" + arg + "]";
+ + ", mq=" + mq + ", brokerAddr=" + brokerAddr + ", communicationMode=" + communicationMode
+ + ", sendResult=" + sendResult + ", exception=" + exception + ", unitMode=" + unitMode
+ + ", arg=" + arg + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java b/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java
index d6f75bb..7faf14b 100644
--- a/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/CheckForbiddenHook.java
@@ -6,23 +6,21 @@
* (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
+ * 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.
+ * 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.hook;
import org.apache.rocketmq.client.exception.MQClientException;
-
public interface CheckForbiddenHook {
String hookName();
-
void checkForbidden(final CheckForbiddenContext context) throws MQClientException;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageContext.java b/client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageContext.java
index f141fac..5bababa 100644
--- a/client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageContext.java
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageContext.java
@@ -6,22 +6,20 @@
* (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
+ * 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.
+ * 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.hook;
-import org.apache.rocketmq.common.message.MessageExt;
-import org.apache.rocketmq.common.message.MessageQueue;
-
import java.util.List;
import java.util.Map;
-
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
public class ConsumeMessageContext {
private String consumerGroup;
@@ -32,72 +30,58 @@ public class ConsumeMessageContext {
private Object mqTraceContext;
private Map<String, String> props;
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public List<MessageExt> getMsgList() {
return msgList;
}
-
public void setMsgList(List<MessageExt> msgList) {
this.msgList = msgList;
}
-
public MessageQueue getMq() {
return mq;
}
-
public void setMq(MessageQueue mq) {
this.mq = mq;
}
-
public boolean isSuccess() {
return success;
}
-
public void setSuccess(boolean success) {
this.success = success;
}
-
public Object getMqTraceContext() {
return mqTraceContext;
}
-
public void setMqTraceContext(Object mqTraceContext) {
this.mqTraceContext = mqTraceContext;
}
-
public Map<String, String> getProps() {
return props;
}
-
public void setProps(Map<String, String> props) {
this.props = props;
}
-
public String getStatus() {
return status;
}
-
public void setStatus(String status) {
this.status = status;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageHook.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageHook.java b/client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageHook.java
index 8161d2e..95db7b2 100644
--- a/client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageHook.java
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/ConsumeMessageHook.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.hook;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageContext.java b/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageContext.java
index 23340d3..bc22546 100644
--- a/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageContext.java
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageContext.java
@@ -6,22 +6,20 @@
* (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
+ * 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.
+ * 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.hook;
+import java.util.List;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.message.MessageQueue;
-import java.util.List;
-
-
public class FilterMessageContext {
private String consumerGroup;
private List<MessageExt> msgList;
@@ -29,60 +27,49 @@ public class FilterMessageContext {
private Object arg;
private boolean unitMode;
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public List<MessageExt> getMsgList() {
return msgList;
}
-
public void setMsgList(List<MessageExt> msgList) {
this.msgList = msgList;
}
-
public MessageQueue getMq() {
return mq;
}
-
public void setMq(MessageQueue mq) {
this.mq = mq;
}
-
public Object getArg() {
return arg;
}
-
public void setArg(Object arg) {
this.arg = arg;
}
-
public boolean isUnitMode() {
return unitMode;
}
-
public void setUnitMode(boolean isUnitMode) {
this.unitMode = isUnitMode;
}
-
@Override
public String toString() {
return "ConsumeMessageContext [consumerGroup=" + consumerGroup + ", msgList=" + msgList + ", mq="
- + mq + ", arg=" + arg + "]";
+ + mq + ", arg=" + arg + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java b/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java
index 48fd513..095de32 100644
--- a/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/FilterMessageHook.java
@@ -6,19 +6,18 @@
* (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
+ * 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.
+ * 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.hook;
public interface FilterMessageHook {
String hookName();
-
void filterMessage(final FilterMessageContext context);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/hook/SendMessageContext.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/SendMessageContext.java b/client/src/main/java/org/apache/rocketmq/client/hook/SendMessageContext.java
index bfb4a47..34e22a3 100644
--- a/client/src/main/java/org/apache/rocketmq/client/hook/SendMessageContext.java
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/SendMessageContext.java
@@ -6,16 +6,17 @@
* (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
+ * 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.
+ * 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.hook;
+import java.util.Map;
import org.apache.rocketmq.client.impl.CommunicationMode;
import org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl;
import org.apache.rocketmq.client.producer.SendResult;
@@ -23,9 +24,6 @@ import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.message.MessageType;
-import java.util.Map;
-
-
public class SendMessageContext {
private String producerGroup;
private Message message;
@@ -60,97 +58,78 @@ public class SendMessageContext {
return producerGroup;
}
-
public void setProducerGroup(String producerGroup) {
this.producerGroup = producerGroup;
}
-
public Message getMessage() {
return message;
}
-
public void setMessage(Message message) {
this.message = message;
}
-
public MessageQueue getMq() {
return mq;
}
-
public void setMq(MessageQueue mq) {
this.mq = mq;
}
-
public String getBrokerAddr() {
return brokerAddr;
}
-
public void setBrokerAddr(String brokerAddr) {
this.brokerAddr = brokerAddr;
}
-
public CommunicationMode getCommunicationMode() {
return communicationMode;
}
-
public void setCommunicationMode(CommunicationMode communicationMode) {
this.communicationMode = communicationMode;
}
-
public SendResult getSendResult() {
return sendResult;
}
-
public void setSendResult(SendResult sendResult) {
this.sendResult = sendResult;
}
-
public Exception getException() {
return exception;
}
-
public void setException(Exception exception) {
this.exception = exception;
}
-
public Object getMqTraceContext() {
return mqTraceContext;
}
-
public void setMqTraceContext(Object mqTraceContext) {
this.mqTraceContext = mqTraceContext;
}
-
public Map<String, String> getProps() {
return props;
}
-
public void setProps(Map<String, String> props) {
this.props = props;
}
-
public String getBornHost() {
return bornHost;
}
-
public void setBornHost(String bornHost) {
this.bornHost = bornHost;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/hook/SendMessageHook.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/hook/SendMessageHook.java b/client/src/main/java/org/apache/rocketmq/client/hook/SendMessageHook.java
index c040831..16a86a0 100644
--- a/client/src/main/java/org/apache/rocketmq/client/hook/SendMessageHook.java
+++ b/client/src/main/java/org/apache/rocketmq/client/hook/SendMessageHook.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.hook;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java b/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
index bb008bf..46ce08c 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
@@ -6,16 +6,20 @@
* (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
+ * 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.
+ * 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.impl;
+import io.netty.channel.ChannelHandlerContext;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.rocketmq.client.impl.factory.MQClientInstance;
import org.apache.rocketmq.client.impl.producer.MQProducerInner;
import org.apache.rocketmq.client.log.ClientLogger;
@@ -30,29 +34,26 @@ import org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
import org.apache.rocketmq.common.protocol.body.GetConsumerStatusBody;
import org.apache.rocketmq.common.protocol.body.ResetOffsetBody;
+import org.apache.rocketmq.common.protocol.header.CheckTransactionStateRequestHeader;
+import org.apache.rocketmq.common.protocol.header.ConsumeMessageDirectlyResultRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetConsumerRunningInfoRequestHeader;
+import org.apache.rocketmq.common.protocol.header.GetConsumerStatusRequestHeader;
+import org.apache.rocketmq.common.protocol.header.NotifyConsumerIdsChangedRequestHeader;
+import org.apache.rocketmq.common.protocol.header.ResetOffsetRequestHeader;
import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-import io.netty.channel.ChannelHandlerContext;
-import org.apache.rocketmq.common.protocol.header.*;
import org.slf4j.Logger;
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-import java.util.Map;
-
-
public class ClientRemotingProcessor implements NettyRequestProcessor {
private final Logger log = ClientLogger.getLog();
private final MQClientInstance mqClientFactory;
-
public ClientRemotingProcessor(final MQClientInstance mqClientFactory) {
this.mqClientFactory = mqClientFactory;
}
-
@Override
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
switch (request.getCode()) {
@@ -83,7 +84,7 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
public RemotingCommand checkTransactionState(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final CheckTransactionStateRequestHeader requestHeader =
- (CheckTransactionStateRequestHeader) request.decodeCommandCustomHeader(CheckTransactionStateRequestHeader.class);
+ (CheckTransactionStateRequestHeader)request.decodeCommandCustomHeader(CheckTransactionStateRequestHeader.class);
final ByteBuffer byteBuffer = ByteBuffer.wrap(request.getBody());
final MessageExt messageExt = MessageDecoder.decode(byteBuffer);
if (messageExt != null) {
@@ -109,10 +110,10 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
public RemotingCommand notifyConsumerIdsChanged(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
try {
final NotifyConsumerIdsChangedRequestHeader requestHeader =
- (NotifyConsumerIdsChangedRequestHeader) request.decodeCommandCustomHeader(NotifyConsumerIdsChangedRequestHeader.class);
+ (NotifyConsumerIdsChangedRequestHeader)request.decodeCommandCustomHeader(NotifyConsumerIdsChangedRequestHeader.class);
log.info("receive broker's notification[{}], the consumer group: {} changed, rebalance immediately",
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
- requestHeader.getConsumerGroup());
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
+ requestHeader.getConsumerGroup());
this.mqClientFactory.rebalanceImmediately();
} catch (Exception e) {
log.error("notifyConsumerIdsChanged exception", RemotingHelper.exceptionSimpleDesc(e));
@@ -122,10 +123,11 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
public RemotingCommand resetOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final ResetOffsetRequestHeader requestHeader =
- (ResetOffsetRequestHeader) request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
+ (ResetOffsetRequestHeader)request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
log.info("invoke reset offset operation from broker. brokerAddr={}, topic={}, group={}, timestamp={}",
- new Object[]{RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
- requestHeader.getTimestamp()});
+ new Object[] {
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
+ requestHeader.getTimestamp()});
Map<MessageQueue, Long> offsetTable = new HashMap<MessageQueue, Long>();
if (request.getBody() != null) {
ResetOffsetBody body = ResetOffsetBody.decode(request.getBody(), ResetOffsetBody.class);
@@ -139,7 +141,7 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
public RemotingCommand getConsumeStatus(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetConsumerStatusRequestHeader requestHeader =
- (GetConsumerStatusRequestHeader) request.decodeCommandCustomHeader(GetConsumerStatusRequestHeader.class);
+ (GetConsumerStatusRequestHeader)request.decodeCommandCustomHeader(GetConsumerStatusRequestHeader.class);
Map<MessageQueue, Long> offsetTable = this.mqClientFactory.getConsumerStatus(requestHeader.getTopic(), requestHeader.getGroup());
GetConsumerStatusBody body = new GetConsumerStatusBody();
@@ -152,7 +154,7 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetConsumerRunningInfoRequestHeader requestHeader =
- (GetConsumerRunningInfoRequestHeader) request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);
+ (GetConsumerRunningInfoRequestHeader)request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);
ConsumerRunningInfo consumerRunningInfo = this.mqClientFactory.consumerRunningInfo(requestHeader.getConsumerGroup());
if (null != consumerRunningInfo) {
@@ -175,13 +177,13 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
private RemotingCommand consumeMessageDirectly(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final ConsumeMessageDirectlyResultRequestHeader requestHeader =
- (ConsumeMessageDirectlyResultRequestHeader) request
- .decodeCommandCustomHeader(ConsumeMessageDirectlyResultRequestHeader.class);
+ (ConsumeMessageDirectlyResultRequestHeader)request
+ .decodeCommandCustomHeader(ConsumeMessageDirectlyResultRequestHeader.class);
final MessageExt msg = MessageDecoder.decode(ByteBuffer.wrap(request.getBody()));
ConsumeMessageDirectlyResult result =
- this.mqClientFactory.consumeMessageDirectly(msg, requestHeader.getConsumerGroup(), requestHeader.getBrokerName());
+ this.mqClientFactory.consumeMessageDirectly(msg, requestHeader.getConsumerGroup(), requestHeader.getBrokerName());
if (null != result) {
response.setCode(ResponseCode.SUCCESS);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java b/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java
index 9af6794..07b3a36 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/CommunicationMode.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.impl;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java b/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java
index 8773f26..c6405d8 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/FindBrokerResult.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.impl;
@@ -20,18 +20,15 @@ public class FindBrokerResult {
private final String brokerAddr;
private final boolean slave;
-
public FindBrokerResult(String brokerAddr, boolean slave) {
this.brokerAddr = brokerAddr;
this.slave = slave;
}
-
public String getBrokerAddr() {
return brokerAddr;
}
-
public boolean isSlave() {
return slave;
}
[47/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/processor/AdminBrokerProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/processor/AdminBrokerProcessor.java b/broker/src/main/java/com/alibaba/rocketmq/broker/processor/AdminBrokerProcessor.java
deleted file mode 100644
index b45a866..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/processor/AdminBrokerProcessor.java
+++ /dev/null
@@ -1,1212 +0,0 @@
-/**
- * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.processor;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import com.alibaba.rocketmq.broker.client.ClientChannelInfo;
-import com.alibaba.rocketmq.broker.client.ConsumerGroupInfo;
-import com.alibaba.rocketmq.common.MQVersion;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.TopicConfig;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.admin.ConsumeStats;
-import com.alibaba.rocketmq.common.admin.OffsetWrapper;
-import com.alibaba.rocketmq.common.admin.TopicOffset;
-import com.alibaba.rocketmq.common.admin.TopicStatsTable;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.message.MessageDecoder;
-import com.alibaba.rocketmq.common.message.MessageId;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.RequestCode;
-import com.alibaba.rocketmq.common.protocol.ResponseCode;
-import com.alibaba.rocketmq.common.protocol.body.*;
-import com.alibaba.rocketmq.common.protocol.header.*;
-import com.alibaba.rocketmq.common.protocol.header.filtersrv.RegisterFilterServerRequestHeader;
-import com.alibaba.rocketmq.common.protocol.header.filtersrv.RegisterFilterServerResponseHeader;
-import com.alibaba.rocketmq.common.protocol.heartbeat.SubscriptionData;
-import com.alibaba.rocketmq.common.stats.StatsItem;
-import com.alibaba.rocketmq.common.stats.StatsSnapshot;
-import com.alibaba.rocketmq.common.subscription.SubscriptionGroupConfig;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-import com.alibaba.rocketmq.remoting.exception.RemotingTimeoutException;
-import com.alibaba.rocketmq.remoting.netty.NettyRequestProcessor;
-import com.alibaba.rocketmq.remoting.protocol.LanguageCode;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-import com.alibaba.rocketmq.store.DefaultMessageStore;
-import com.alibaba.rocketmq.store.SelectMappedBufferResult;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandlerContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.UnsupportedEncodingException;
-import java.net.UnknownHostException;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-
-
-/**
- * @author shijia.wxr
- * @author manhong.yqd
- */
-public class AdminBrokerProcessor implements NettyRequestProcessor {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
- private final BrokerController brokerController;
-
- public AdminBrokerProcessor(final BrokerController brokerController) {
- this.brokerController = brokerController;
- }
-
- @Override
- public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- switch (request.getCode()) {
- case RequestCode.UPDATE_AND_CREATE_TOPIC:
- return this.updateAndCreateTopic(ctx, request);
- case RequestCode.DELETE_TOPIC_IN_BROKER:
- return this.deleteTopic(ctx, request);
- case RequestCode.GET_ALL_TOPIC_CONFIG:
- return this.getAllTopicConfig(ctx, request);
- case RequestCode.UPDATE_BROKER_CONFIG:
- return this.updateBrokerConfig(ctx, request);
- case RequestCode.GET_BROKER_CONFIG:
- return this.getBrokerConfig(ctx, request);
- case RequestCode.SEARCH_OFFSET_BY_TIMESTAMP:
- return this.searchOffsetByTimestamp(ctx, request);
- case RequestCode.GET_MAX_OFFSET:
- return this.getMaxOffset(ctx, request);
- case RequestCode.GET_MIN_OFFSET:
- return this.getMinOffset(ctx, request);
- case RequestCode.GET_EARLIEST_MSG_STORETIME:
- return this.getEarliestMsgStoretime(ctx, request);
- case RequestCode.GET_BROKER_RUNTIME_INFO:
- return this.getBrokerRuntimeInfo(ctx, request);
- case RequestCode.LOCK_BATCH_MQ:
- return this.lockBatchMQ(ctx, request);
- case RequestCode.UNLOCK_BATCH_MQ:
- return this.unlockBatchMQ(ctx, request);
- case RequestCode.UPDATE_AND_CREATE_SUBSCRIPTIONGROUP:
- return this.updateAndCreateSubscriptionGroup(ctx, request);
- case RequestCode.GET_ALL_SUBSCRIPTIONGROUP_CONFIG:
- return this.getAllSubscriptionGroup(ctx, request);
- case RequestCode.DELETE_SUBSCRIPTIONGROUP:
- return this.deleteSubscriptionGroup(ctx, request);
- case RequestCode.GET_TOPIC_STATS_INFO:
- return this.getTopicStatsInfo(ctx, request);
- case RequestCode.GET_CONSUMER_CONNECTION_LIST:
- return this.getConsumerConnectionList(ctx, request);
- case RequestCode.GET_PRODUCER_CONNECTION_LIST:
- return this.getProducerConnectionList(ctx, request);
- case RequestCode.GET_CONSUME_STATS:
- return this.getConsumeStats(ctx, request);
- case RequestCode.GET_ALL_CONSUMER_OFFSET:
- return this.getAllConsumerOffset(ctx, request);
- case RequestCode.GET_ALL_DELAY_OFFSET:
- return this.getAllDelayOffset(ctx, request);
- case RequestCode.INVOKE_BROKER_TO_RESET_OFFSET:
- return this.resetOffset(ctx, request);
- case RequestCode.INVOKE_BROKER_TO_GET_CONSUMER_STATUS:
- return this.getConsumerStatus(ctx, request);
- case RequestCode.QUERY_TOPIC_CONSUME_BY_WHO:
- return this.queryTopicConsumeByWho(ctx, request);
- case RequestCode.REGISTER_FILTER_SERVER:
- return this.registerFilterServer(ctx, request);
- case RequestCode.QUERY_CONSUME_TIME_SPAN:
- return this.queryConsumeTimeSpan(ctx, request);
- case RequestCode.GET_SYSTEM_TOPIC_LIST_FROM_BROKER:
- return this.getSystemTopicListFromBroker(ctx, request);
- case RequestCode.CLEAN_EXPIRED_CONSUMEQUEUE:
- return this.cleanExpiredConsumeQueue();
- case RequestCode.CLEAN_UNUSED_TOPIC:
- return this.cleanUnusedTopic();
- case RequestCode.GET_CONSUMER_RUNNING_INFO:
- return this.getConsumerRunningInfo(ctx, request);
- case RequestCode.QUERY_CORRECTION_OFFSET:
- return this.queryCorrectionOffset(ctx, request);
- case RequestCode.CONSUME_MESSAGE_DIRECTLY:
- return this.consumeMessageDirectly(ctx, request);
- case RequestCode.CLONE_GROUP_OFFSET:
- return this.cloneGroupOffset(ctx, request);
- case RequestCode.VIEW_BROKER_STATS_DATA:
- return ViewBrokerStatsData(ctx, request);
- case RequestCode.GET_BROKER_CONSUME_STATS:
- return fetchAllConsumeStatsInBroker(ctx, request);
- default:
- break;
- }
-
- return null;
- }
-
- @Override
- public boolean rejectRequest() {
- return false;
- }
-
- private RemotingCommand updateAndCreateTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- final CreateTopicRequestHeader requestHeader =
- (CreateTopicRequestHeader) request.decodeCommandCustomHeader(CreateTopicRequestHeader.class);
- log.info("updateAndCreateTopic called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
-
-
- if (requestHeader.getTopic().equals(this.brokerController.getBrokerConfig().getBrokerClusterName())) {
- String errorMsg = "the topic[" + requestHeader.getTopic() + "] is conflict with system reserved words.";
- log.warn(errorMsg);
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark(errorMsg);
- return response;
- }
-
- try {
- response.setCode(ResponseCode.SUCCESS);
- response.setOpaque(request.getOpaque());
- response.markResponseType();
- response.setRemark(null);
- ctx.writeAndFlush(response);
- } catch (Exception e) {
- }
-
- TopicConfig topicConfig = new TopicConfig(requestHeader.getTopic());
- topicConfig.setReadQueueNums(requestHeader.getReadQueueNums());
- topicConfig.setWriteQueueNums(requestHeader.getWriteQueueNums());
- topicConfig.setTopicFilterType(requestHeader.getTopicFilterTypeEnum());
- topicConfig.setPerm(requestHeader.getPerm());
- topicConfig.setTopicSysFlag(requestHeader.getTopicSysFlag() == null ? 0 : requestHeader.getTopicSysFlag());
-
- this.brokerController.getTopicConfigManager().updateTopicConfig(topicConfig);
- this.brokerController.registerBrokerAll(false, true);
- return null;
- }
-
- private RemotingCommand deleteTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- DeleteTopicRequestHeader requestHeader =
- (DeleteTopicRequestHeader) request.decodeCommandCustomHeader(DeleteTopicRequestHeader.class);
-
- log.info("deleteTopic called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
-
- this.brokerController.getTopicConfigManager().deleteTopicConfig(requestHeader.getTopic());
- this.brokerController.getMessageStore()
- .cleanUnusedTopic(this.brokerController.getTopicConfigManager().getTopicConfigTable().keySet());
-
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand getAllTopicConfig(ChannelHandlerContext ctx, RemotingCommand request) {
- final RemotingCommand response = RemotingCommand.createResponseCommand(GetAllTopicConfigResponseHeader.class);
- // final GetAllTopicConfigResponseHeader responseHeader =
- // (GetAllTopicConfigResponseHeader) response.readCustomHeader();
-
- String content = this.brokerController.getTopicConfigManager().encode();
- if (content != null && content.length() > 0) {
- try {
- response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
- } catch (UnsupportedEncodingException e) {
- log.error("", e);
-
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("UnsupportedEncodingException " + e);
- return response;
- }
- } else {
- log.error("No topic in this broker, client: " + ctx.channel().remoteAddress());
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("No topic in this broker");
- return response;
- }
-
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
-
- return response;
- }
-
- private RemotingCommand updateBrokerConfig(ChannelHandlerContext ctx, RemotingCommand request) {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
-
- log.info("updateBrokerConfig called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
-
- byte[] body = request.getBody();
- if (body != null) {
- try {
- String bodyStr = new String(body, MixAll.DEFAULT_CHARSET);
- Properties properties = MixAll.string2Properties(bodyStr);
- if (properties != null) {
- log.info("updateBrokerConfig, new config: " + properties + " client: " + ctx.channel().remoteAddress());
- this.brokerController.getConfiguration().update(properties);
- if (properties.containsKey("brokerPermission")) {
- this.brokerController.registerBrokerAll(false, false);
- this.brokerController.getTopicConfigManager().getDataVersion().nextVersion();
- }
- } else {
- log.error("string2Properties error");
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("string2Properties error");
- return response;
- }
- } catch (UnsupportedEncodingException e) {
- log.error("", e);
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("UnsupportedEncodingException " + e);
- return response;
- }
- }
-
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand getBrokerConfig(ChannelHandlerContext ctx, RemotingCommand request) {
-
- final RemotingCommand response = RemotingCommand.createResponseCommand(GetBrokerConfigResponseHeader.class);
- final GetBrokerConfigResponseHeader responseHeader = (GetBrokerConfigResponseHeader) response.readCustomHeader();
-
- String content = this.brokerController.getConfiguration().getAllConfigsFormatString();
- if (content != null && content.length() > 0) {
- try {
- response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
- } catch (UnsupportedEncodingException e) {
- log.error("", e);
-
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("UnsupportedEncodingException " + e);
- return response;
- }
- }
-
- responseHeader.setVersion(this.brokerController.getConfiguration().getDataVersionJson());
-
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand searchOffsetByTimestamp(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(SearchOffsetResponseHeader.class);
- final SearchOffsetResponseHeader responseHeader = (SearchOffsetResponseHeader) response.readCustomHeader();
- final SearchOffsetRequestHeader requestHeader =
- (SearchOffsetRequestHeader) request.decodeCommandCustomHeader(SearchOffsetRequestHeader.class);
-
- long offset = this.brokerController.getMessageStore().getOffsetInQueueByTime(requestHeader.getTopic(), requestHeader.getQueueId(),
- requestHeader.getTimestamp());
-
- responseHeader.setOffset(offset);
-
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand getMaxOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(GetMaxOffsetResponseHeader.class);
- final GetMaxOffsetResponseHeader responseHeader = (GetMaxOffsetResponseHeader) response.readCustomHeader();
- final GetMaxOffsetRequestHeader requestHeader =
- (GetMaxOffsetRequestHeader) request.decodeCommandCustomHeader(GetMaxOffsetRequestHeader.class);
-
- long offset = this.brokerController.getMessageStore().getMaxOffsetInQuque(requestHeader.getTopic(), requestHeader.getQueueId());
-
- responseHeader.setOffset(offset);
-
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand getMinOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(GetMinOffsetResponseHeader.class);
- final GetMinOffsetResponseHeader responseHeader = (GetMinOffsetResponseHeader) response.readCustomHeader();
- final GetMinOffsetRequestHeader requestHeader =
- (GetMinOffsetRequestHeader) request.decodeCommandCustomHeader(GetMinOffsetRequestHeader.class);
-
- long offset = this.brokerController.getMessageStore().getMinOffsetInQuque(requestHeader.getTopic(), requestHeader.getQueueId());
-
- responseHeader.setOffset(offset);
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand getEarliestMsgStoretime(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(GetEarliestMsgStoretimeResponseHeader.class);
- final GetEarliestMsgStoretimeResponseHeader responseHeader = (GetEarliestMsgStoretimeResponseHeader) response.readCustomHeader();
- final GetEarliestMsgStoretimeRequestHeader requestHeader =
- (GetEarliestMsgStoretimeRequestHeader) request.decodeCommandCustomHeader(GetEarliestMsgStoretimeRequestHeader.class);
-
- long timestamp =
- this.brokerController.getMessageStore().getEarliestMessageTime(requestHeader.getTopic(), requestHeader.getQueueId());
-
- responseHeader.setTimestamp(timestamp);
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand getBrokerRuntimeInfo(ChannelHandlerContext ctx, RemotingCommand request) {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
-
- HashMap<String, String> runtimeInfo = this.prepareRuntimeInfo();
- KVTable kvTable = new KVTable();
- kvTable.setTable(runtimeInfo);
-
- byte[] body = kvTable.encode();
- response.setBody(body);
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand lockBatchMQ(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- LockBatchRequestBody requestBody = LockBatchRequestBody.decode(request.getBody(), LockBatchRequestBody.class);
-
- Set<MessageQueue> lockOKMQSet = this.brokerController.getRebalanceLockManager().tryLockBatch(//
- requestBody.getConsumerGroup(), //
- requestBody.getMqSet(), //
- requestBody.getClientId());
-
- LockBatchResponseBody responseBody = new LockBatchResponseBody();
- responseBody.setLockOKMQSet(lockOKMQSet);
-
- response.setBody(responseBody.encode());
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand unlockBatchMQ(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- UnlockBatchRequestBody requestBody = UnlockBatchRequestBody.decode(request.getBody(), UnlockBatchRequestBody.class);
-
- this.brokerController.getRebalanceLockManager().unlockBatch(//
- requestBody.getConsumerGroup(), //
- requestBody.getMqSet(), //
- requestBody.getClientId());
-
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand updateAndCreateSubscriptionGroup(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
-
- log.info("updateAndCreateSubscriptionGroup called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
-
- SubscriptionGroupConfig config = RemotingSerializable.decode(request.getBody(), SubscriptionGroupConfig.class);
- if (config != null) {
- this.brokerController.getSubscriptionGroupManager().updateSubscriptionGroupConfig(config);
- }
-
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand getAllSubscriptionGroup(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- String content = this.brokerController.getSubscriptionGroupManager().encode();
- if (content != null && content.length() > 0) {
- try {
- response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
- } catch (UnsupportedEncodingException e) {
- log.error("", e);
-
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("UnsupportedEncodingException " + e);
- return response;
- }
- } else {
- log.error("No subscription group in this broker, client: " + ctx.channel().remoteAddress());
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("No subscription group in this broker");
- return response;
- }
-
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
-
- return response;
- }
-
- private RemotingCommand deleteSubscriptionGroup(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- DeleteSubscriptionGroupRequestHeader requestHeader =
- (DeleteSubscriptionGroupRequestHeader) request.decodeCommandCustomHeader(DeleteSubscriptionGroupRequestHeader.class);
-
- log.info("deleteSubscriptionGroup called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
-
- this.brokerController.getSubscriptionGroupManager().deleteSubscriptionGroupConfig(requestHeader.getGroupName());
-
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand getTopicStatsInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- final GetTopicStatsInfoRequestHeader requestHeader =
- (GetTopicStatsInfoRequestHeader) request.decodeCommandCustomHeader(GetTopicStatsInfoRequestHeader.class);
-
- final String topic = requestHeader.getTopic();
- TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
- if (null == topicConfig) {
- response.setCode(ResponseCode.TOPIC_NOT_EXIST);
- response.setRemark("topic[" + topic + "] not exist");
- return response;
- }
-
- TopicStatsTable topicStatsTable = new TopicStatsTable();
- for (int i = 0; i < topicConfig.getWriteQueueNums(); i++) {
- MessageQueue mq = new MessageQueue();
- mq.setTopic(topic);
- mq.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());
- mq.setQueueId(i);
-
- TopicOffset topicOffset = new TopicOffset();
- long min = this.brokerController.getMessageStore().getMinOffsetInQuque(topic, i);
- if (min < 0)
- min = 0;
-
- long max = this.brokerController.getMessageStore().getMaxOffsetInQuque(topic, i);
- if (max < 0)
- max = 0;
-
- long timestamp = 0;
- if (max > 0) {
- timestamp = this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i, max - 1);
- }
-
- topicOffset.setMinOffset(min);
- topicOffset.setMaxOffset(max);
- topicOffset.setLastUpdateTimestamp(timestamp);
-
- topicStatsTable.getOffsetTable().put(mq, topicOffset);
- }
-
- byte[] body = topicStatsTable.encode();
- response.setBody(body);
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand getConsumerConnectionList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- final GetConsumerConnectionListRequestHeader requestHeader =
- (GetConsumerConnectionListRequestHeader) request.decodeCommandCustomHeader(GetConsumerConnectionListRequestHeader.class);
-
- ConsumerGroupInfo consumerGroupInfo =
- this.brokerController.getConsumerManager().getConsumerGroupInfo(requestHeader.getConsumerGroup());
- if (consumerGroupInfo != null) {
- ConsumerConnection bodydata = new ConsumerConnection();
- bodydata.setConsumeFromWhere(consumerGroupInfo.getConsumeFromWhere());
- bodydata.setConsumeType(consumerGroupInfo.getConsumeType());
- bodydata.setMessageModel(consumerGroupInfo.getMessageModel());
- bodydata.getSubscriptionTable().putAll(consumerGroupInfo.getSubscriptionTable());
-
- Iterator<Map.Entry<Channel, ClientChannelInfo>> it = consumerGroupInfo.getChannelInfoTable().entrySet().iterator();
- while (it.hasNext()) {
- ClientChannelInfo info = it.next().getValue();
- Connection connection = new Connection();
- connection.setClientId(info.getClientId());
- connection.setLanguage(info.getLanguage());
- connection.setVersion(info.getVersion());
- connection.setClientAddr(RemotingHelper.parseChannelRemoteAddr(info.getChannel()));
-
- bodydata.getConnectionSet().add(connection);
- }
-
- byte[] body = bodydata.encode();
- response.setBody(body);
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
-
- return response;
- }
-
- response.setCode(ResponseCode.CONSUMER_NOT_ONLINE);
- response.setRemark("the consumer group[" + requestHeader.getConsumerGroup() + "] not online");
- return response;
- }
-
- private RemotingCommand getProducerConnectionList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- final GetProducerConnectionListRequestHeader requestHeader =
- (GetProducerConnectionListRequestHeader) request.decodeCommandCustomHeader(GetProducerConnectionListRequestHeader.class);
-
- ProducerConnection bodydata = new ProducerConnection();
- HashMap<Channel, ClientChannelInfo> channelInfoHashMap =
- this.brokerController.getProducerManager().getGroupChannelTable().get(requestHeader.getProducerGroup());
- if (channelInfoHashMap != null) {
- Iterator<Map.Entry<Channel, ClientChannelInfo>> it = channelInfoHashMap.entrySet().iterator();
- while (it.hasNext()) {
- ClientChannelInfo info = it.next().getValue();
- Connection connection = new Connection();
- connection.setClientId(info.getClientId());
- connection.setLanguage(info.getLanguage());
- connection.setVersion(info.getVersion());
- connection.setClientAddr(RemotingHelper.parseChannelRemoteAddr(info.getChannel()));
-
- bodydata.getConnectionSet().add(connection);
- }
-
- byte[] body = bodydata.encode();
- response.setBody(body);
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("the producer group[" + requestHeader.getProducerGroup() + "] not exist");
- return response;
- }
-
- private RemotingCommand getConsumeStats(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- final GetConsumeStatsRequestHeader requestHeader =
- (GetConsumeStatsRequestHeader) request.decodeCommandCustomHeader(GetConsumeStatsRequestHeader.class);
-
- ConsumeStats consumeStats = new ConsumeStats();
-
- Set<String> topics = new HashSet<String>();
- if (UtilAll.isBlank(requestHeader.getTopic())) {
- topics = this.brokerController.getConsumerOffsetManager().whichTopicByConsumer(requestHeader.getConsumerGroup());
- } else {
- topics.add(requestHeader.getTopic());
- }
-
- for (String topic : topics) {
- TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
- if (null == topicConfig) {
- log.warn("consumeStats, topic config not exist, {}", topic);
- continue;
- }
-
- /**
-
- */
- {
- SubscriptionData findSubscriptionData =
- this.brokerController.getConsumerManager().findSubscriptionData(requestHeader.getConsumerGroup(), topic);
-
- if (null == findSubscriptionData //
- && this.brokerController.getConsumerManager().findSubscriptionDataCount(requestHeader.getConsumerGroup()) > 0) {
- log.warn("consumeStats, the consumer group[{}], topic[{}] not exist", requestHeader.getConsumerGroup(), topic);
- continue;
- }
- }
-
- for (int i = 0; i < topicConfig.getReadQueueNums(); i++) {
- MessageQueue mq = new MessageQueue();
- mq.setTopic(topic);
- mq.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());
- mq.setQueueId(i);
-
- OffsetWrapper offsetWrapper = new OffsetWrapper();
-
- long brokerOffset = this.brokerController.getMessageStore().getMaxOffsetInQuque(topic, i);
- if (brokerOffset < 0)
- brokerOffset = 0;
-
- long consumerOffset = this.brokerController.getConsumerOffsetManager().queryOffset(//
- requestHeader.getConsumerGroup(), //
- topic, //
- i);
- if (consumerOffset < 0)
- consumerOffset = 0;
-
- offsetWrapper.setBrokerOffset(brokerOffset);
- offsetWrapper.setConsumerOffset(consumerOffset);
-
-
- long timeOffset = consumerOffset - 1;
- if (timeOffset >= 0) {
- long lastTimestamp = this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i, timeOffset);
- if (lastTimestamp > 0) {
- offsetWrapper.setLastTimestamp(lastTimestamp);
- }
- }
-
- consumeStats.getOffsetTable().put(mq, offsetWrapper);
- }
-
- double consumeTps = this.brokerController.getBrokerStatsManager().tpsGroupGetNums(requestHeader.getConsumerGroup(), topic);
-
- consumeTps += consumeStats.getConsumeTps();
- consumeStats.setConsumeTps(consumeTps);
- }
-
- byte[] body = consumeStats.encode();
- response.setBody(body);
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand getAllConsumerOffset(ChannelHandlerContext ctx, RemotingCommand request) {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
-
- String content = this.brokerController.getConsumerOffsetManager().encode();
- if (content != null && content.length() > 0) {
- try {
- response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
- } catch (UnsupportedEncodingException e) {
- log.error("get all consumer offset from master error.", e);
-
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("UnsupportedEncodingException " + e);
- return response;
- }
- } else {
- log.error("No consumer offset in this broker, client: " + ctx.channel().remoteAddress());
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("No consumer offset in this broker");
- return response;
- }
-
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
-
- return response;
- }
-
- private RemotingCommand getAllDelayOffset(ChannelHandlerContext ctx, RemotingCommand request) {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
-
- String content = ((DefaultMessageStore) this.brokerController.getMessageStore()).getScheduleMessageService().encode();
- if (content != null && content.length() > 0) {
- try {
- response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
- } catch (UnsupportedEncodingException e) {
- log.error("get all delay offset from master error.", e);
-
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("UnsupportedEncodingException " + e);
- return response;
- }
- } else {
- log.error("No delay offset in this broker, client: " + ctx.channel().remoteAddress());
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("No delay offset in this broker");
- return response;
- }
-
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
-
- return response;
- }
-
- public RemotingCommand resetOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final ResetOffsetRequestHeader requestHeader =
- (ResetOffsetRequestHeader) request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
- log.info("[reset-offset] reset offset started by {}. topic={}, group={}, timestamp={}, isForce={}",
- new Object[]{RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
- requestHeader.getTimestamp(), requestHeader.isForce()});
- boolean isC = false;
- LanguageCode language = request.getLanguage();
- switch (language) {
- case CPP:
- isC = true;
- break;
- }
- return this.brokerController.getBroker2Client().resetOffset(requestHeader.getTopic(), requestHeader.getGroup(),
- requestHeader.getTimestamp(), requestHeader.isForce(), isC);
- }
-
- public RemotingCommand getConsumerStatus(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final GetConsumerStatusRequestHeader requestHeader =
- (GetConsumerStatusRequestHeader) request.decodeCommandCustomHeader(GetConsumerStatusRequestHeader.class);
-
- log.info("[get-consumer-status] get consumer status by {}. topic={}, group={}",
- new Object[]{RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup()});
-
- return this.brokerController.getBroker2Client().getConsumeStatus(requestHeader.getTopic(), requestHeader.getGroup(),
- requestHeader.getClientAddr());
- }
-
- private RemotingCommand queryTopicConsumeByWho(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- QueryTopicConsumeByWhoRequestHeader requestHeader =
- (QueryTopicConsumeByWhoRequestHeader) request.decodeCommandCustomHeader(QueryTopicConsumeByWhoRequestHeader.class);
-
-
- HashSet<String> groups = this.brokerController.getConsumerManager().queryTopicConsumeByWho(requestHeader.getTopic());
-
- Set<String> groupInOffset = this.brokerController.getConsumerOffsetManager().whichGroupByTopic(requestHeader.getTopic());
- if (groupInOffset != null && !groupInOffset.isEmpty()) {
- groups.addAll(groupInOffset);
- }
-
- GroupList groupList = new GroupList();
- groupList.setGroupList(groups);
- byte[] body = groupList.encode();
-
- response.setBody(body);
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand registerFilterServer(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterFilterServerResponseHeader.class);
- final RegisterFilterServerResponseHeader responseHeader = (RegisterFilterServerResponseHeader) response.readCustomHeader();
- final RegisterFilterServerRequestHeader requestHeader =
- (RegisterFilterServerRequestHeader) request.decodeCommandCustomHeader(RegisterFilterServerRequestHeader.class);
-
- this.brokerController.getFilterServerManager().registerFilterServer(ctx.channel(), requestHeader.getFilterServerAddr());
-
- responseHeader.setBrokerId(this.brokerController.getBrokerConfig().getBrokerId());
- responseHeader.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());
-
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand queryConsumeTimeSpan(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- QueryConsumeTimeSpanRequestHeader requestHeader =
- (QueryConsumeTimeSpanRequestHeader) request.decodeCommandCustomHeader(QueryConsumeTimeSpanRequestHeader.class);
-
- final String topic = requestHeader.getTopic();
- TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
- if (null == topicConfig) {
- response.setCode(ResponseCode.TOPIC_NOT_EXIST);
- response.setRemark("topic[" + topic + "] not exist");
- return response;
- }
-
- List<QueueTimeSpan> timeSpanSet = new ArrayList<QueueTimeSpan>();
- for (int i = 0; i < topicConfig.getWriteQueueNums(); i++) {
- QueueTimeSpan timeSpan = new QueueTimeSpan();
- MessageQueue mq = new MessageQueue();
- mq.setTopic(topic);
- mq.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());
- mq.setQueueId(i);
- timeSpan.setMessageQueue(mq);
-
- long minTime = this.brokerController.getMessageStore().getEarliestMessageTime(topic, i);
- timeSpan.setMinTimeStamp(minTime);
-
- long max = this.brokerController.getMessageStore().getMaxOffsetInQuque(topic, i);
- long maxTime = this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i, max - 1);
- timeSpan.setMaxTimeStamp(maxTime);
-
- long consumeTime;
- long consumerOffset = this.brokerController.getConsumerOffsetManager().queryOffset(
- requestHeader.getGroup(), topic, i);
- if (consumerOffset > 0) {
- consumeTime = this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i, consumerOffset - 1);
- } else {
- consumeTime = minTime;
- }
- timeSpan.setConsumeTimeStamp(consumeTime);
-
- long maxBrokerOffset = this.brokerController.getMessageStore().getMaxOffsetInQuque(requestHeader.getTopic(), i);
- if (consumerOffset < maxBrokerOffset) {
- long nextTime = this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i, consumerOffset);
- timeSpan.setDelayTime(System.currentTimeMillis() - nextTime);
- }
- timeSpanSet.add(timeSpan);
- }
-
- QueryConsumeTimeSpanBody queryConsumeTimeSpanBody = new QueryConsumeTimeSpanBody();
- queryConsumeTimeSpanBody.setConsumeTimeSpanSet(timeSpanSet);
- response.setBody(queryConsumeTimeSpanBody.encode());
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand getSystemTopicListFromBroker(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
-
- Set<String> topics = this.brokerController.getTopicConfigManager().getSystemTopic();
- TopicList topicList = new TopicList();
- topicList.setTopicList(topics);
- response.setBody(topicList.encode());
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- public RemotingCommand cleanExpiredConsumeQueue() {
- log.warn("invoke cleanExpiredConsumeQueue start.");
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- brokerController.getMessageStore().cleanExpiredConsumerQueue();
- log.warn("invoke cleanExpiredConsumeQueue end.");
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- public RemotingCommand cleanUnusedTopic() {
- log.warn("invoke cleanUnusedTopic start.");
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- brokerController.getMessageStore().cleanUnusedTopic(brokerController.getTopicConfigManager().getTopicConfigTable().keySet());
- log.warn("invoke cleanUnusedTopic end.");
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- /**
-
- */
- private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final GetConsumerRunningInfoRequestHeader requestHeader =
- (GetConsumerRunningInfoRequestHeader) request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);
-
- return this.callConsumer(RequestCode.GET_CONSUMER_RUNNING_INFO, request, requestHeader.getConsumerGroup(),
- requestHeader.getClientId());
- }
-
- private RemotingCommand queryCorrectionOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- QueryCorrectionOffsetHeader requestHeader =
- (QueryCorrectionOffsetHeader) request.decodeCommandCustomHeader(QueryCorrectionOffsetHeader.class);
-
- Map<Integer, Long> correctionOffset = this.brokerController.getConsumerOffsetManager()
- .queryMinOffsetInAllGroup(requestHeader.getTopic(), requestHeader.getFilterGroups());
-
- Map<Integer, Long> compareOffset =
- this.brokerController.getConsumerOffsetManager().queryOffset(requestHeader.getTopic(), requestHeader.getCompareGroup());
-
- if (compareOffset != null && !compareOffset.isEmpty()) {
- for (Map.Entry<Integer, Long> entry : compareOffset.entrySet()) {
- Integer queueId = entry.getKey();
- correctionOffset.put(queueId,
- correctionOffset.get(queueId) > entry.getValue() ? Long.MAX_VALUE : correctionOffset.get(queueId));
- }
- }
-
- QueryCorrectionOffsetBody body = new QueryCorrectionOffsetBody();
- body.setCorrectionOffsets(correctionOffset);
- response.setBody(body.encode());
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand consumeMessageDirectly(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final ConsumeMessageDirectlyResultRequestHeader requestHeader = (ConsumeMessageDirectlyResultRequestHeader) request
- .decodeCommandCustomHeader(ConsumeMessageDirectlyResultRequestHeader.class);
-
- request.getExtFields().put("brokerName", this.brokerController.getBrokerConfig().getBrokerName());
- SelectMappedBufferResult selectMappedBufferResult = null;
- try {
- MessageId messageId = MessageDecoder.decodeMessageId(requestHeader.getMsgId());
- selectMappedBufferResult = this.brokerController.getMessageStore().selectOneMessageByOffset(messageId.getOffset());
-
- byte[] body = new byte[selectMappedBufferResult.getSize()];
- selectMappedBufferResult.getByteBuffer().get(body);
- request.setBody(body);
- } catch (UnknownHostException e) {
- } finally {
- if (selectMappedBufferResult != null) {
- selectMappedBufferResult.release();
- }
- }
-
- return this.callConsumer(RequestCode.CONSUME_MESSAGE_DIRECTLY, request, requestHeader.getConsumerGroup(),
- requestHeader.getClientId());
- }
-
- private RemotingCommand cloneGroupOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- CloneGroupOffsetRequestHeader requestHeader =
- (CloneGroupOffsetRequestHeader) request.decodeCommandCustomHeader(CloneGroupOffsetRequestHeader.class);
-
- Set<String> topics;
- if (UtilAll.isBlank(requestHeader.getTopic())) {
- topics = this.brokerController.getConsumerOffsetManager().whichTopicByConsumer(requestHeader.getSrcGroup());
- } else {
- topics = new HashSet<String>();
- topics.add(requestHeader.getTopic());
- }
-
- for (String topic : topics) {
- TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
- if (null == topicConfig) {
- log.warn("[cloneGroupOffset], topic config not exist, {}", topic);
- continue;
- }
-
- /**
-
- */
- if (!requestHeader.isOffline()) {
-
- SubscriptionData findSubscriptionData =
- this.brokerController.getConsumerManager().findSubscriptionData(requestHeader.getSrcGroup(), topic);
- if (this.brokerController.getConsumerManager().findSubscriptionDataCount(requestHeader.getSrcGroup()) > 0
- && findSubscriptionData == null) {
- log.warn("[cloneGroupOffset], the consumer group[{}], topic[{}] not exist", requestHeader.getSrcGroup(), topic);
- continue;
- }
- }
-
- this.brokerController.getConsumerOffsetManager().cloneOffset(requestHeader.getSrcGroup(), requestHeader.getDestGroup(),
- requestHeader.getTopic());
- }
-
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand ViewBrokerStatsData(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
- final ViewBrokerStatsDataRequestHeader requestHeader =
- (ViewBrokerStatsDataRequestHeader) request.decodeCommandCustomHeader(ViewBrokerStatsDataRequestHeader.class);
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- DefaultMessageStore messageStore = (DefaultMessageStore) this.brokerController.getMessageStore();
-
- StatsItem statsItem = messageStore.getBrokerStatsManager().getStatsItem(requestHeader.getStatsName(), requestHeader.getStatsKey());
- if (null == statsItem) {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark(String.format("The stats <%s> <%s> not exist", requestHeader.getStatsName(), requestHeader.getStatsKey()));
- return response;
- }
-
- BrokerStatsData brokerStatsData = new BrokerStatsData();
-
- {
- BrokerStatsItem it = new BrokerStatsItem();
- StatsSnapshot ss = statsItem.getStatsDataInMinute();
- it.setSum(ss.getSum());
- it.setTps(ss.getTps());
- it.setAvgpt(ss.getAvgpt());
- brokerStatsData.setStatsMinute(it);
- }
-
-
- {
- BrokerStatsItem it = new BrokerStatsItem();
- StatsSnapshot ss = statsItem.getStatsDataInHour();
- it.setSum(ss.getSum());
- it.setTps(ss.getTps());
- it.setAvgpt(ss.getAvgpt());
- brokerStatsData.setStatsHour(it);
- }
-
-
- {
- BrokerStatsItem it = new BrokerStatsItem();
- StatsSnapshot ss = statsItem.getStatsDataInDay();
- it.setSum(ss.getSum());
- it.setTps(ss.getTps());
- it.setAvgpt(ss.getAvgpt());
- brokerStatsData.setStatsDay(it);
- }
-
- response.setBody(brokerStatsData.encode());
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private RemotingCommand fetchAllConsumeStatsInBroker(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- GetConsumeStatsInBrokerHeader requestHeader =
- (GetConsumeStatsInBrokerHeader) request.decodeCommandCustomHeader(GetConsumeStatsInBrokerHeader.class);
- boolean isOrder = requestHeader.isOrder();
- ConcurrentHashMap<String, SubscriptionGroupConfig> subscriptionGroups =
- brokerController.getSubscriptionGroupManager().getSubscriptionGroupTable();
-
- List<Map<String/* subscriptionGroupName */, List<ConsumeStats>>> brokerConsumeStatsList =
- new ArrayList<Map<String, List<ConsumeStats>>>();
-
- long totalDiff = 0L;
-
- for (String group : subscriptionGroups.keySet()) {
- Map<String, List<ConsumeStats>> subscripTopicConsumeMap = new HashMap<String, List<ConsumeStats>>();
- Set<String> topics = this.brokerController.getConsumerOffsetManager().whichTopicByConsumer(group);
- List<ConsumeStats> consumeStatsList = new ArrayList<ConsumeStats>();
- for (String topic : topics) {
- ConsumeStats consumeStats = new ConsumeStats();
- TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
- if (null == topicConfig) {
- log.warn("consumeStats, topic config not exist, {}", topic);
- continue;
- }
-
- if (isOrder && !topicConfig.isOrder()) {
- continue;
- }
- /**
-
- */
- {
- SubscriptionData findSubscriptionData = this.brokerController.getConsumerManager().findSubscriptionData(group, topic);
-
- if (null == findSubscriptionData //
- && this.brokerController.getConsumerManager().findSubscriptionDataCount(group) > 0) {
- log.warn("consumeStats, the consumer group[{}], topic[{}] not exist", group, topic);
- continue;
- }
- }
-
- for (int i = 0; i < topicConfig.getWriteQueueNums(); i++) {
- MessageQueue mq = new MessageQueue();
- mq.setTopic(topic);
- mq.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());
- mq.setQueueId(i);
- OffsetWrapper offsetWrapper = new OffsetWrapper();
- long brokerOffset = this.brokerController.getMessageStore().getMaxOffsetInQuque(topic, i);
- if (brokerOffset < 0)
- brokerOffset = 0;
- long consumerOffset = this.brokerController.getConsumerOffsetManager().queryOffset(//
- group, //
- topic, //
- i);
- if (consumerOffset < 0)
- consumerOffset = 0;
-
- offsetWrapper.setBrokerOffset(brokerOffset);
- offsetWrapper.setConsumerOffset(consumerOffset);
-
-
- long timeOffset = consumerOffset - 1;
- if (timeOffset >= 0) {
- long lastTimestamp = this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i, timeOffset);
- if (lastTimestamp > 0) {
- offsetWrapper.setLastTimestamp(lastTimestamp);
- }
- }
- consumeStats.getOffsetTable().put(mq, offsetWrapper);
- }
- double consumeTps = this.brokerController.getBrokerStatsManager().tpsGroupGetNums(group, topic);
- consumeTps += consumeStats.getConsumeTps();
- consumeStats.setConsumeTps(consumeTps);
- totalDiff += consumeStats.computeTotalDiff();
- consumeStatsList.add(consumeStats);
- }
- subscripTopicConsumeMap.put(group, consumeStatsList);
- brokerConsumeStatsList.add(subscripTopicConsumeMap);
- }
- ConsumeStatsList consumeStats = new ConsumeStatsList();
- consumeStats.setBrokerAddr(brokerController.getBrokerAddr());
- consumeStats.setConsumeStatsList(brokerConsumeStatsList);
- consumeStats.setTotalDiff(totalDiff);
- response.setBody(consumeStats.encode());
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- private HashMap<String, String> prepareRuntimeInfo() {
- HashMap<String, String> runtimeInfo = this.brokerController.getMessageStore().getRuntimeInfo();
- runtimeInfo.put("brokerVersionDesc", MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION));
- runtimeInfo.put("brokerVersion", String.valueOf(MQVersion.CURRENT_VERSION));
-
- runtimeInfo.put("msgPutTotalYesterdayMorning",
- String.valueOf(this.brokerController.getBrokerStats().getMsgPutTotalYesterdayMorning()));
- runtimeInfo.put("msgPutTotalTodayMorning", String.valueOf(this.brokerController.getBrokerStats().getMsgPutTotalTodayMorning()));
- runtimeInfo.put("msgPutTotalTodayNow", String.valueOf(this.brokerController.getBrokerStats().getMsgPutTotalTodayNow()));
-
- runtimeInfo.put("msgGetTotalYesterdayMorning",
- String.valueOf(this.brokerController.getBrokerStats().getMsgGetTotalYesterdayMorning()));
- runtimeInfo.put("msgGetTotalTodayMorning", String.valueOf(this.brokerController.getBrokerStats().getMsgGetTotalTodayMorning()));
- runtimeInfo.put("msgGetTotalTodayNow", String.valueOf(this.brokerController.getBrokerStats().getMsgGetTotalTodayNow()));
-
- runtimeInfo.put("sendThreadPoolQueueSize", String.valueOf(this.brokerController.getSendThreadPoolQueue().size()));
-
- runtimeInfo.put("sendThreadPoolQueueCapacity",
- String.valueOf(this.brokerController.getBrokerConfig().getSendThreadPoolQueueCapacity()));
-
- runtimeInfo.put("pullThreadPoolQueueSize", String.valueOf(this.brokerController.getPullThreadPoolQueue().size()));
- runtimeInfo.put("pullThreadPoolQueueCapacity",
- String.valueOf(this.brokerController.getBrokerConfig().getPullThreadPoolQueueCapacity()));
-
- runtimeInfo.put("dispatchBehindBytes", String.valueOf(this.brokerController.getMessageStore().dispatchBehindBytes()));
- runtimeInfo.put("pageCacheLockTimeMills", String.valueOf(this.brokerController.getMessageStore().lockTimeMills()));
-
- runtimeInfo.put("sendThreadPoolQueueHeadWaitTimeMills", String.valueOf(this.brokerController.headSlowTimeMills4SendThreadPoolQueue()));
- runtimeInfo.put("pullThreadPoolQueueHeadWaitTimeMills", String.valueOf(this.brokerController.headSlowTimeMills4PullThreadPoolQueue()));
- runtimeInfo.put("earliestMessageTimeStamp", String.valueOf(this.brokerController.getMessageStore().getEarliestMessageTime()));
- runtimeInfo.put("startAcceptSendRequestTimeStamp", String.valueOf(this.brokerController.getBrokerConfig().getStartAcceptSendRequestTimeStamp()));
- if (this.brokerController.getMessageStore() instanceof DefaultMessageStore) {
- DefaultMessageStore defaultMessageStore = (DefaultMessageStore) this.brokerController.getMessageStore();
- runtimeInfo.put("remainTransientStoreBufferNumbs", String.valueOf(defaultMessageStore.remainTransientStoreBufferNumbs()));
- if (defaultMessageStore.getMessageStoreConfig().isTransientStorePoolEnable()) {
- runtimeInfo.put("remainHowManyDataToCommit", MixAll.humanReadableByteCount(defaultMessageStore.getCommitLog().remainHowManyDataToCommit(), false));
- }
- runtimeInfo.put("remainHowManyDataToFlush", MixAll.humanReadableByteCount(defaultMessageStore.getCommitLog().remainHowManyDataToFlush(), false));
- }
-
- java.io.File commitLogDir = new java.io.File(this.brokerController.getMessageStoreConfig().getStorePathRootDir());
- if (commitLogDir.exists()) {
- runtimeInfo.put("commitLogDirCapacity", String.format("Total : %s, Free : %s.", MixAll.humanReadableByteCount(commitLogDir.getTotalSpace(), false), MixAll.humanReadableByteCount(commitLogDir.getFreeSpace(), false)));
- }
-
- return runtimeInfo;
- }
-
- private RemotingCommand callConsumer(//
- final int requestCode, //
- final RemotingCommand request, //
- final String consumerGroup, //
- final String clientId) throws RemotingCommandException {
- final RemotingCommand response = RemotingCommand.createResponseCommand(null);
- ClientChannelInfo clientChannelInfo = this.brokerController.getConsumerManager().findChannel(consumerGroup, clientId);
-
- if (null == clientChannelInfo) {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark(String.format("The Consumer <%s> <%s> not online", consumerGroup, clientId));
- return response;
- }
-
- if (clientChannelInfo.getVersion() < MQVersion.Version.V3_1_8_SNAPSHOT.ordinal()) {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark(String.format("The Consumer <%s> Version <%s> too low to finish, please upgrade it to V3_1_8_SNAPSHOT", //
- clientId, //
- MQVersion.getVersionDesc(clientChannelInfo.getVersion())));
- return response;
- }
-
- try {
- RemotingCommand newRequest = RemotingCommand.createRequestCommand(requestCode, null);
- newRequest.setExtFields(request.getExtFields());
- newRequest.setBody(request.getBody());
-
- RemotingCommand consumerResponse =
- this.brokerController.getBroker2Client().callClient(clientChannelInfo.getChannel(), newRequest);
- return consumerResponse;
- } catch (RemotingTimeoutException e) {
- response.setCode(ResponseCode.CONSUME_MSG_TIMEOUT);
- response
- .setRemark(String.format("consumer <%s> <%s> Timeout: %s", consumerGroup, clientId, RemotingHelper.exceptionSimpleDesc(e)));
- return response;
- } catch (Exception e) {
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark(
- String.format("invoke consumer <%s> <%s> Exception: %s", consumerGroup, clientId, RemotingHelper.exceptionSimpleDesc(e)));
- return response;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/processor/ClientManageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/processor/ClientManageProcessor.java b/broker/src/main/java/com/alibaba/rocketmq/broker/processor/ClientManageProcessor.java
deleted file mode 100644
index 254e63c..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/processor/ClientManageProcessor.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.processor;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import com.alibaba.rocketmq.broker.client.ClientChannelInfo;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.constant.PermName;
-import com.alibaba.rocketmq.common.protocol.RequestCode;
-import com.alibaba.rocketmq.common.protocol.ResponseCode;
-import com.alibaba.rocketmq.common.protocol.header.UnregisterClientRequestHeader;
-import com.alibaba.rocketmq.common.protocol.header.UnregisterClientResponseHeader;
-import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumerData;
-import com.alibaba.rocketmq.common.protocol.heartbeat.HeartbeatData;
-import com.alibaba.rocketmq.common.protocol.heartbeat.ProducerData;
-import com.alibaba.rocketmq.common.subscription.SubscriptionGroupConfig;
-import com.alibaba.rocketmq.common.sysflag.TopicSysFlag;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-import com.alibaba.rocketmq.remoting.netty.NettyRequestProcessor;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import io.netty.channel.ChannelHandlerContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * @author shijia.wxr
- */
-public class ClientManageProcessor implements NettyRequestProcessor {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
- private final BrokerController brokerController;
-
- public ClientManageProcessor(final BrokerController brokerController) {
- this.brokerController = brokerController;
- }
-
- @Override
- public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
- switch (request.getCode()) {
- case RequestCode.HEART_BEAT:
- return this.heartBeat(ctx, request);
- case RequestCode.UNREGISTER_CLIENT:
- return this.unregisterClient(ctx, request);
- default:
- break;
- }
- return null;
- }
-
- @Override
- public boolean rejectRequest() {
- return false;
- }
-
- public RemotingCommand heartBeat(ChannelHandlerContext ctx, RemotingCommand request) {
- RemotingCommand response = RemotingCommand.createResponseCommand(null);
- HeartbeatData heartbeatData = HeartbeatData.decode(request.getBody(), HeartbeatData.class);
- ClientChannelInfo clientChannelInfo = new ClientChannelInfo(
- ctx.channel(),
- heartbeatData.getClientID(),
- request.getLanguage(),
- request.getVersion()
- );
-
- for (ConsumerData data : heartbeatData.getConsumerDataSet()) {
- SubscriptionGroupConfig subscriptionGroupConfig =
- this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(
- data.getGroupName());
- boolean isNotifyConsumerIdsChangedEnable = true;
- if (null != subscriptionGroupConfig) {
- isNotifyConsumerIdsChangedEnable = subscriptionGroupConfig.isNotifyConsumerIdsChangedEnable();
- int topicSysFlag = 0;
- if (data.isUnitMode()) {
- topicSysFlag = TopicSysFlag.buildSysFlag(false, true);
- }
- String newTopic = MixAll.getRetryTopic(data.getGroupName());
- this.brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(
- newTopic,
- subscriptionGroupConfig.getRetryQueueNums(),
- PermName.PERM_WRITE | PermName.PERM_READ, topicSysFlag);
- }
-
- boolean changed = this.brokerController.getConsumerManager().registerConsumer(
- data.getGroupName(),
- clientChannelInfo,
- data.getConsumeType(),
- data.getMessageModel(),
- data.getConsumeFromWhere(),
- data.getSubscriptionDataSet(),
- isNotifyConsumerIdsChangedEnable
- );
-
- if (changed) {
- log.info("registerConsumer info changed {} {}",
- data.toString(),
- RemotingHelper.parseChannelRemoteAddr(ctx.channel())
- );
- }
- }
-
- for (ProducerData data : heartbeatData.getProducerDataSet()) {
- this.brokerController.getProducerManager().registerProducer(data.getGroupName(),
- clientChannelInfo);
- }
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
- public RemotingCommand unregisterClient(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
- final RemotingCommand response =
- RemotingCommand.createResponseCommand(UnregisterClientResponseHeader.class);
- final UnregisterClientRequestHeader requestHeader =
- (UnregisterClientRequestHeader) request
- .decodeCommandCustomHeader(UnregisterClientRequestHeader.class);
-
- ClientChannelInfo clientChannelInfo = new ClientChannelInfo(
- ctx.channel(),
- requestHeader.getClientID(),
- request.getLanguage(),
- request.getVersion());
- {
- final String group = requestHeader.getProducerGroup();
- if (group != null) {
- this.brokerController.getProducerManager().unregisterProducer(group, clientChannelInfo);
- }
- }
-
- {
- final String group = requestHeader.getConsumerGroup();
- if (group != null) {
- SubscriptionGroupConfig subscriptionGroupConfig =
- this.brokerController.getSubscriptionGroupManager().findSubscriptionGroupConfig(group);
- boolean isNotifyConsumerIdsChangedEnable = true;
- if (null != subscriptionGroupConfig) {
- isNotifyConsumerIdsChangedEnable = subscriptionGroupConfig.isNotifyConsumerIdsChangedEnable();
- }
- this.brokerController.getConsumerManager().unregisterConsumer(group, clientChannelInfo, isNotifyConsumerIdsChangedEnable);
- }
- }
-
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/com/alibaba/rocketmq/broker/processor/ConsumerManageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/com/alibaba/rocketmq/broker/processor/ConsumerManageProcessor.java b/broker/src/main/java/com/alibaba/rocketmq/broker/processor/ConsumerManageProcessor.java
deleted file mode 100644
index d7f9198..0000000
--- a/broker/src/main/java/com/alibaba/rocketmq/broker/processor/ConsumerManageProcessor.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
- * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.processor;
-
-import com.alibaba.rocketmq.broker.BrokerController;
-import com.alibaba.rocketmq.broker.client.ConsumerGroupInfo;
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import com.alibaba.rocketmq.common.protocol.RequestCode;
-import com.alibaba.rocketmq.common.protocol.ResponseCode;
-import com.alibaba.rocketmq.common.protocol.header.*;
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-import com.alibaba.rocketmq.remoting.exception.RemotingCommandException;
-import com.alibaba.rocketmq.remoting.netty.NettyRequestProcessor;
-import com.alibaba.rocketmq.remoting.protocol.RemotingCommand;
-import io.netty.channel.ChannelHandlerContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public class ConsumerManageProcessor implements NettyRequestProcessor {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
-
- private final BrokerController brokerController;
-
-
- public ConsumerManageProcessor(final BrokerController brokerController) {
- this.brokerController = brokerController;
- }
-
- @Override
- public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
- switch (request.getCode()) {
- case RequestCode.GET_CONSUMER_LIST_BY_GROUP:
- return this.getConsumerListByGroup(ctx, request);
- case RequestCode.UPDATE_CONSUMER_OFFSET:
- return this.updateConsumerOffset(ctx, request);
- case RequestCode.QUERY_CONSUMER_OFFSET:
- return this.queryConsumerOffset(ctx, request);
- default:
- break;
- }
- return null;
- }
-
- @Override
- public boolean rejectRequest() {
- return false;
- }
-
-
- public RemotingCommand getConsumerListByGroup(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
- final RemotingCommand response =
- RemotingCommand.createResponseCommand(GetConsumerListByGroupResponseHeader.class);
- final GetConsumerListByGroupRequestHeader requestHeader =
- (GetConsumerListByGroupRequestHeader) request
- .decodeCommandCustomHeader(GetConsumerListByGroupRequestHeader.class);
-
- ConsumerGroupInfo consumerGroupInfo =
- this.brokerController.getConsumerManager().getConsumerGroupInfo(
- requestHeader.getConsumerGroup());
- if (consumerGroupInfo != null) {
- List<String> clientIds = consumerGroupInfo.getAllClientId();
- if (!clientIds.isEmpty()) {
- GetConsumerListByGroupResponseBody body = new GetConsumerListByGroupResponseBody();
- body.setConsumerIdList(clientIds);
- response.setBody(body.encode());
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- } else {
- log.warn("getAllClientId failed, {} {}", requestHeader.getConsumerGroup(),
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
- }
- } else {
- log.warn("getConsumerGroupInfo failed, {} {}", requestHeader.getConsumerGroup(),
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
- }
-
- response.setCode(ResponseCode.SYSTEM_ERROR);
- response.setRemark("no consumer for this group, " + requestHeader.getConsumerGroup());
- return response;
- }
-
- private RemotingCommand updateConsumerOffset(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
- final RemotingCommand response =
- RemotingCommand.createResponseCommand(UpdateConsumerOffsetResponseHeader.class);
- final UpdateConsumerOffsetRequestHeader requestHeader =
- (UpdateConsumerOffsetRequestHeader) request
- .decodeCommandCustomHeader(UpdateConsumerOffsetRequestHeader.class);
- this.brokerController.getConsumerOffsetManager().commitOffset(RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getConsumerGroup(),
- requestHeader.getTopic(), requestHeader.getQueueId(), requestHeader.getCommitOffset());
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- return response;
- }
-
-
- private RemotingCommand queryConsumerOffset(ChannelHandlerContext ctx, RemotingCommand request)
- throws RemotingCommandException {
- final RemotingCommand response =
- RemotingCommand.createResponseCommand(QueryConsumerOffsetResponseHeader.class);
- final QueryConsumerOffsetResponseHeader responseHeader =
- (QueryConsumerOffsetResponseHeader) response.readCustomHeader();
- final QueryConsumerOffsetRequestHeader requestHeader =
- (QueryConsumerOffsetRequestHeader) request
- .decodeCommandCustomHeader(QueryConsumerOffsetRequestHeader.class);
-
- long offset =
- this.brokerController.getConsumerOffsetManager().queryOffset(
- requestHeader.getConsumerGroup(), requestHeader.getTopic(), requestHeader.getQueueId());
-
-
- if (offset >= 0) {
- responseHeader.setOffset(offset);
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- } else {
- long minOffset =
- this.brokerController.getMessageStore().getMinOffsetInQuque(requestHeader.getTopic(),
- requestHeader.getQueueId());
- if (minOffset <= 0
- && !this.brokerController.getMessageStore().checkInDiskByConsumeOffset(
- requestHeader.getTopic(), requestHeader.getQueueId(), 0)) {
- responseHeader.setOffset(0L);
- response.setCode(ResponseCode.SUCCESS);
- response.setRemark(null);
- } else {
- response.setCode(ResponseCode.QUERY_NOT_FOUND);
- response.setRemark("Not found, V3_0_6_SNAPSHOT maybe this group consumer boot first");
- }
- }
-
- return response;
- }
-}
[33/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/PullRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/PullRequest.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/PullRequest.java
deleted file mode 100644
index efc5ab0..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/PullRequest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * 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.client.impl.consumer;
-
-import com.alibaba.rocketmq.common.message.MessageQueue;
-
-
-/**
- * @author shijia.wxr
- */
-public class PullRequest {
- private String consumerGroup;
- private MessageQueue messageQueue;
- private ProcessQueue processQueue;
- private long nextOffset;
- private boolean lockedFirst = false;
-
- public boolean isLockedFirst() {
- return lockedFirst;
- }
-
- public void setLockedFirst(boolean lockedFirst) {
- this.lockedFirst = lockedFirst;
- }
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
-
- public MessageQueue getMessageQueue() {
- return messageQueue;
- }
-
-
- public void setMessageQueue(MessageQueue messageQueue) {
- this.messageQueue = messageQueue;
- }
-
-
- public long getNextOffset() {
- return nextOffset;
- }
-
-
- public void setNextOffset(long nextOffset) {
- this.nextOffset = nextOffset;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((consumerGroup == null) ? 0 : consumerGroup.hashCode());
- result = prime * result + ((messageQueue == null) ? 0 : messageQueue.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- PullRequest other = (PullRequest) obj;
- if (consumerGroup == null) {
- if (other.consumerGroup != null)
- return false;
- } else if (!consumerGroup.equals(other.consumerGroup))
- return false;
- if (messageQueue == null) {
- if (other.messageQueue != null)
- return false;
- } else if (!messageQueue.equals(other.messageQueue))
- return false;
- return true;
- }
-
- @Override
- public String toString() {
- return "PullRequest [consumerGroup=" + consumerGroup + ", messageQueue=" + messageQueue
- + ", nextOffset=" + nextOffset + "]";
- }
-
- public ProcessQueue getProcessQueue() {
- return processQueue;
- }
-
-
- public void setProcessQueue(ProcessQueue processQueue) {
- this.processQueue = processQueue;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/PullResultExt.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/PullResultExt.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/PullResultExt.java
deleted file mode 100644
index e140b6a..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/PullResultExt.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * 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.client.impl.consumer;
-
-import com.alibaba.rocketmq.client.consumer.PullResult;
-import com.alibaba.rocketmq.client.consumer.PullStatus;
-import com.alibaba.rocketmq.common.message.MessageExt;
-
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public class PullResultExt extends PullResult {
- private final long suggestWhichBrokerId;
- private byte[] messageBinary;
-
-
- public PullResultExt(PullStatus pullStatus, long nextBeginOffset, long minOffset, long maxOffset,
- List<MessageExt> msgFoundList, final long suggestWhichBrokerId, final byte[] messageBinary) {
- super(pullStatus, nextBeginOffset, minOffset, maxOffset, msgFoundList);
- this.suggestWhichBrokerId = suggestWhichBrokerId;
- this.messageBinary = messageBinary;
- }
-
-
- public byte[] getMessageBinary() {
- return messageBinary;
- }
-
-
- public void setMessageBinary(byte[] messageBinary) {
- this.messageBinary = messageBinary;
- }
-
-
- public long getSuggestWhichBrokerId() {
- return suggestWhichBrokerId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/RebalanceImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/RebalanceImpl.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/RebalanceImpl.java
deleted file mode 100644
index 641bb75..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/RebalanceImpl.java
+++ /dev/null
@@ -1,481 +0,0 @@
-/**
- * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.client.impl.consumer;
-
-import com.alibaba.rocketmq.client.consumer.AllocateMessageQueueStrategy;
-import com.alibaba.rocketmq.client.impl.FindBrokerResult;
-import com.alibaba.rocketmq.client.impl.factory.MQClientInstance;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.body.LockBatchRequestBody;
-import com.alibaba.rocketmq.common.protocol.body.UnlockBatchRequestBody;
-import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType;
-import com.alibaba.rocketmq.common.protocol.heartbeat.MessageModel;
-import com.alibaba.rocketmq.common.protocol.heartbeat.SubscriptionData;
-import org.slf4j.Logger;
-
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-
-
-/**
- * Base class for rebalance algorithm
- *
- * @author shijia.wxr
- */
-public abstract class RebalanceImpl {
- protected static final Logger log = ClientLogger.getLog();
- protected final ConcurrentHashMap<MessageQueue, ProcessQueue> processQueueTable = new ConcurrentHashMap<MessageQueue, ProcessQueue>(64);
- protected final ConcurrentHashMap<String/* topic */, Set<MessageQueue>> topicSubscribeInfoTable =
- new ConcurrentHashMap<String, Set<MessageQueue>>();
- protected final ConcurrentHashMap<String /* topic */, SubscriptionData> subscriptionInner =
- new ConcurrentHashMap<String, SubscriptionData>();
- protected String consumerGroup;
- protected MessageModel messageModel;
- protected AllocateMessageQueueStrategy allocateMessageQueueStrategy;
- protected MQClientInstance mQClientFactory;
-
-
- public RebalanceImpl(String consumerGroup, MessageModel messageModel, AllocateMessageQueueStrategy allocateMessageQueueStrategy,
- MQClientInstance mQClientFactory) {
- this.consumerGroup = consumerGroup;
- this.messageModel = messageModel;
- this.allocateMessageQueueStrategy = allocateMessageQueueStrategy;
- this.mQClientFactory = mQClientFactory;
- }
-
- public void unlock(final MessageQueue mq, final boolean oneway) {
- FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInSubscribe(mq.getBrokerName(), MixAll.MASTER_ID, true);
- if (findBrokerResult != null) {
- UnlockBatchRequestBody requestBody = new UnlockBatchRequestBody();
- requestBody.setConsumerGroup(this.consumerGroup);
- requestBody.setClientId(this.mQClientFactory.getClientId());
- requestBody.getMqSet().add(mq);
-
- try {
- this.mQClientFactory.getMQClientAPIImpl().unlockBatchMQ(findBrokerResult.getBrokerAddr(), requestBody, 1000, oneway);
- log.warn("unlock messageQueue. group:{}, clientId:{}, mq:{}", //
- this.consumerGroup, //
- this.mQClientFactory.getClientId(), //
- mq);
- } catch (Exception e) {
- log.error("unlockBatchMQ exception, " + mq, e);
- }
- }
- }
-
- public void unlockAll(final boolean oneway) {
- HashMap<String, Set<MessageQueue>> brokerMqs = this.buildProcessQueueTableByBrokerName();
-
- for (final Map.Entry<String, Set<MessageQueue>> entry : brokerMqs.entrySet()) {
- final String brokerName = entry.getKey();
- final Set<MessageQueue> mqs = entry.getValue();
-
- if (mqs.isEmpty())
- continue;
-
- FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInSubscribe(brokerName, MixAll.MASTER_ID, true);
- if (findBrokerResult != null) {
- UnlockBatchRequestBody requestBody = new UnlockBatchRequestBody();
- requestBody.setConsumerGroup(this.consumerGroup);
- requestBody.setClientId(this.mQClientFactory.getClientId());
- requestBody.setMqSet(mqs);
-
- try {
- this.mQClientFactory.getMQClientAPIImpl().unlockBatchMQ(findBrokerResult.getBrokerAddr(), requestBody, 1000, oneway);
-
- for (MessageQueue mq : mqs) {
- ProcessQueue processQueue = this.processQueueTable.get(mq);
- if (processQueue != null) {
- processQueue.setLocked(false);
- log.info("the message queue unlock OK, Group: {} {}", this.consumerGroup, mq);
- }
- }
- } catch (Exception e) {
- log.error("unlockBatchMQ exception, " + mqs, e);
- }
- }
- }
- }
-
- private HashMap<String/* brokerName */, Set<MessageQueue>> buildProcessQueueTableByBrokerName() {
- HashMap<String, Set<MessageQueue>> result = new HashMap<String, Set<MessageQueue>>();
- for (MessageQueue mq : this.processQueueTable.keySet()) {
- Set<MessageQueue> mqs = result.get(mq.getBrokerName());
- if (null == mqs) {
- mqs = new HashSet<MessageQueue>();
- result.put(mq.getBrokerName(), mqs);
- }
-
- mqs.add(mq);
- }
-
- return result;
- }
-
- public boolean lock(final MessageQueue mq) {
- FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInSubscribe(mq.getBrokerName(), MixAll.MASTER_ID, true);
- if (findBrokerResult != null) {
- LockBatchRequestBody requestBody = new LockBatchRequestBody();
- requestBody.setConsumerGroup(this.consumerGroup);
- requestBody.setClientId(this.mQClientFactory.getClientId());
- requestBody.getMqSet().add(mq);
-
- try {
- Set<MessageQueue> lockedMq =
- this.mQClientFactory.getMQClientAPIImpl().lockBatchMQ(findBrokerResult.getBrokerAddr(), requestBody, 1000);
- for (MessageQueue mmqq : lockedMq) {
- ProcessQueue processQueue = this.processQueueTable.get(mmqq);
- if (processQueue != null) {
- processQueue.setLocked(true);
- processQueue.setLastLockTimestamp(System.currentTimeMillis());
- }
- }
-
- boolean lockOK = lockedMq.contains(mq);
- log.info("the message queue lock {}, {} {}",
- lockOK ? "OK" : "Failed",
- this.consumerGroup,
- mq);
- return lockOK;
- } catch (Exception e) {
- log.error("lockBatchMQ exception, " + mq, e);
- }
- }
-
- return false;
- }
-
- public void lockAll() {
- HashMap<String, Set<MessageQueue>> brokerMqs = this.buildProcessQueueTableByBrokerName();
-
- Iterator<Entry<String, Set<MessageQueue>>> it = brokerMqs.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, Set<MessageQueue>> entry = it.next();
- final String brokerName = entry.getKey();
- final Set<MessageQueue> mqs = entry.getValue();
-
- if (mqs.isEmpty())
- continue;
-
- FindBrokerResult findBrokerResult = this.mQClientFactory.findBrokerAddressInSubscribe(brokerName, MixAll.MASTER_ID, true);
- if (findBrokerResult != null) {
- LockBatchRequestBody requestBody = new LockBatchRequestBody();
- requestBody.setConsumerGroup(this.consumerGroup);
- requestBody.setClientId(this.mQClientFactory.getClientId());
- requestBody.setMqSet(mqs);
-
- try {
- Set<MessageQueue> lockOKMQSet =
- this.mQClientFactory.getMQClientAPIImpl().lockBatchMQ(findBrokerResult.getBrokerAddr(), requestBody, 1000);
-
- for (MessageQueue mq : lockOKMQSet) {
- ProcessQueue processQueue = this.processQueueTable.get(mq);
- if (processQueue != null) {
- if (!processQueue.isLocked()) {
- log.info("the message queue locked OK, Group: {} {}", this.consumerGroup, mq);
- }
-
- processQueue.setLocked(true);
- processQueue.setLastLockTimestamp(System.currentTimeMillis());
- }
- }
- for (MessageQueue mq : mqs) {
- if (!lockOKMQSet.contains(mq)) {
- ProcessQueue processQueue = this.processQueueTable.get(mq);
- if (processQueue != null) {
- processQueue.setLocked(false);
- log.warn("the message queue locked Failed, Group: {} {}", this.consumerGroup, mq);
- }
- }
- }
- } catch (Exception e) {
- log.error("lockBatchMQ exception, " + mqs, e);
- }
- }
- }
- }
-
- public void doRebalance(final boolean isOrder) {
- Map<String, SubscriptionData> subTable = this.getSubscriptionInner();
- if (subTable != null) {
- for (final Map.Entry<String, SubscriptionData> entry : subTable.entrySet()) {
- final String topic = entry.getKey();
- try {
- this.rebalanceByTopic(topic, isOrder);
- } catch (Throwable e) {
- if (!topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
- log.warn("rebalanceByTopic Exception", e);
- }
- }
- }
- }
-
- this.truncateMessageQueueNotMyTopic();
- }
-
- public ConcurrentHashMap<String, SubscriptionData> getSubscriptionInner() {
- return subscriptionInner;
- }
-
- private void rebalanceByTopic(final String topic, final boolean isOrder) {
- switch (messageModel) {
- case BROADCASTING: {
- Set<MessageQueue> mqSet = this.topicSubscribeInfoTable.get(topic);
- if (mqSet != null) {
- boolean changed = this.updateProcessQueueTableInRebalance(topic, mqSet, isOrder);
- if (changed) {
- this.messageQueueChanged(topic, mqSet, mqSet);
- log.info("messageQueueChanged {} {} {} {}", //
- consumerGroup, //
- topic, //
- mqSet, //
- mqSet);
- }
- } else {
- log.warn("doRebalance, {}, but the topic[{}] not exist.", consumerGroup, topic);
- }
- break;
- }
- case CLUSTERING: {
- Set<MessageQueue> mqSet = this.topicSubscribeInfoTable.get(topic);
- List<String> cidAll = this.mQClientFactory.findConsumerIdList(topic, consumerGroup);
- if (null == mqSet) {
- if (!topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
- log.warn("doRebalance, {}, but the topic[{}] not exist.", consumerGroup, topic);
- }
- }
-
- if (null == cidAll) {
- log.warn("doRebalance, {} {}, get consumer id list failed", consumerGroup, topic);
- }
-
- if (mqSet != null && cidAll != null) {
- List<MessageQueue> mqAll = new ArrayList<MessageQueue>();
- mqAll.addAll(mqSet);
-
- Collections.sort(mqAll);
- Collections.sort(cidAll);
-
- AllocateMessageQueueStrategy strategy = this.allocateMessageQueueStrategy;
-
- List<MessageQueue> allocateResult = null;
- try {
- allocateResult = strategy.allocate(//
- this.consumerGroup, //
- this.mQClientFactory.getClientId(), //
- mqAll, //
- cidAll);
- } catch (Throwable e) {
- log.error("AllocateMessageQueueStrategy.allocate Exception. allocateMessageQueueStrategyName={}", strategy.getName(),
- e);
- return;
- }
-
- Set<MessageQueue> allocateResultSet = new HashSet<MessageQueue>();
- if (allocateResult != null) {
- allocateResultSet.addAll(allocateResult);
- }
-
- boolean changed = this.updateProcessQueueTableInRebalance(topic, allocateResultSet, isOrder);
- if (changed) {
- log.info(
- "rebalanced result changed. allocateMessageQueueStrategyName={}, group={}, topic={}, clientId={}, mqAllSize={}, cidAllSize={}, rebalanceResultSize={}, rebalanceResultSet={}",
- strategy.getName(), consumerGroup, topic, this.mQClientFactory.getClientId(), mqSet.size(), cidAll.size(),
- allocateResultSet.size(), allocateResultSet);
- this.messageQueueChanged(topic, mqSet, allocateResultSet);
- }
- }
- break;
- }
- default:
- break;
- }
- }
-
- private void truncateMessageQueueNotMyTopic() {
- Map<String, SubscriptionData> subTable = this.getSubscriptionInner();
-
- for (MessageQueue mq : this.processQueueTable.keySet()) {
- if (!subTable.containsKey(mq.getTopic())) {
-
- ProcessQueue pq = this.processQueueTable.remove(mq);
- if (pq != null) {
- pq.setDropped(true);
- log.info("doRebalance, {}, truncateMessageQueueNotMyTopic remove unnecessary mq, {}", consumerGroup, mq);
- }
- }
- }
- }
-
- private boolean updateProcessQueueTableInRebalance(final String topic, final Set<MessageQueue> mqSet, final boolean isOrder) {
- boolean changed = false;
-
- Iterator<Entry<MessageQueue, ProcessQueue>> it = this.processQueueTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<MessageQueue, ProcessQueue> next = it.next();
- MessageQueue mq = next.getKey();
- ProcessQueue pq = next.getValue();
-
- if (mq.getTopic().equals(topic)) {
- if (!mqSet.contains(mq)) {
- pq.setDropped(true);
- if (this.removeUnnecessaryMessageQueue(mq, pq)) {
- it.remove();
- changed = true;
- log.info("doRebalance, {}, remove unnecessary mq, {}", consumerGroup, mq);
- }
- } else if (pq.isPullExpired()) {
- switch (this.consumeType()) {
- case CONSUME_ACTIVELY:
- break;
- case CONSUME_PASSIVELY:
- pq.setDropped(true);
- if (this.removeUnnecessaryMessageQueue(mq, pq)) {
- it.remove();
- changed = true;
- log.error("[BUG]doRebalance, {}, remove unnecessary mq, {}, because pull is pause, so try to fixed it",
- consumerGroup, mq);
- }
- break;
- default:
- break;
- }
- }
- }
- }
-
- List<PullRequest> pullRequestList = new ArrayList<PullRequest>();
- for (MessageQueue mq : mqSet) {
- if (!this.processQueueTable.containsKey(mq)) {
- if (isOrder && !this.lock(mq)) {
- log.warn("doRebalance, {}, add a new mq failed, {}, because lock failed", consumerGroup, mq);
- continue;
- }
-
- this.removeDirtyOffset(mq);
- ProcessQueue pq = new ProcessQueue();
- long nextOffset = this.computePullFromWhere(mq);
- if (nextOffset >= 0) {
- ProcessQueue pre = this.processQueueTable.putIfAbsent(mq, pq);
- if (pre != null) {
- log.info("doRebalance, {}, mq already exists, {}", consumerGroup, mq);
- } else {
- log.info("doRebalance, {}, add a new mq, {}", consumerGroup, mq);
- PullRequest pullRequest = new PullRequest();
- pullRequest.setConsumerGroup(consumerGroup);
- pullRequest.setNextOffset(nextOffset);
- pullRequest.setMessageQueue(mq);
- pullRequest.setProcessQueue(pq);
- pullRequestList.add(pullRequest);
- changed = true;
- }
- } else {
- log.warn("doRebalance, {}, add new mq failed, {}", consumerGroup, mq);
- }
- }
- }
-
- this.dispatchPullRequest(pullRequestList);
-
- return changed;
- }
-
- public abstract void messageQueueChanged(final String topic, final Set<MessageQueue> mqAll, final Set<MessageQueue> mqDivided);
-
- public abstract boolean removeUnnecessaryMessageQueue(final MessageQueue mq, final ProcessQueue pq);
-
- public abstract ConsumeType consumeType();
-
- public abstract void removeDirtyOffset(final MessageQueue mq);
-
- public abstract long computePullFromWhere(final MessageQueue mq);
-
- public abstract void dispatchPullRequest(final List<PullRequest> pullRequestList);
-
- public void removeProcessQueue(final MessageQueue mq) {
- ProcessQueue prev = this.processQueueTable.remove(mq);
- if (prev != null) {
- boolean droped = prev.isDropped();
- prev.setDropped(true);
- this.removeUnnecessaryMessageQueue(mq, prev);
- log.info("Fix Offset, {}, remove unnecessary mq, {} Droped: {}", consumerGroup, mq, droped);
- }
- }
-
- public ConcurrentHashMap<MessageQueue, ProcessQueue> getProcessQueueTable() {
- return processQueueTable;
- }
-
-
- public ConcurrentHashMap<String, Set<MessageQueue>> getTopicSubscribeInfoTable() {
- return topicSubscribeInfoTable;
- }
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
-
- public MessageModel getMessageModel() {
- return messageModel;
- }
-
-
- public void setMessageModel(MessageModel messageModel) {
- this.messageModel = messageModel;
- }
-
-
- public AllocateMessageQueueStrategy getAllocateMessageQueueStrategy() {
- return allocateMessageQueueStrategy;
- }
-
-
- public void setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy allocateMessageQueueStrategy) {
- this.allocateMessageQueueStrategy = allocateMessageQueueStrategy;
- }
-
-
- public MQClientInstance getmQClientFactory() {
- return mQClientFactory;
- }
-
-
- public void setmQClientFactory(MQClientInstance mQClientFactory) {
- this.mQClientFactory = mQClientFactory;
- }
-
-
- public void destroy() {
- Iterator<Entry<MessageQueue, ProcessQueue>> it = this.processQueueTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<MessageQueue, ProcessQueue> next = it.next();
- next.getValue().setDropped(true);
- }
-
- this.processQueueTable.clear();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/RebalancePullImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/RebalancePullImpl.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/RebalancePullImpl.java
deleted file mode 100644
index 8d2b465..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/RebalancePullImpl.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * 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.client.impl.consumer;
-
-import com.alibaba.rocketmq.client.consumer.AllocateMessageQueueStrategy;
-import com.alibaba.rocketmq.client.consumer.MessageQueueListener;
-import com.alibaba.rocketmq.client.impl.factory.MQClientInstance;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType;
-import com.alibaba.rocketmq.common.protocol.heartbeat.MessageModel;
-
-import java.util.List;
-import java.util.Set;
-
-
-/**
- * @author shijia.wxr
- */
-public class RebalancePullImpl extends RebalanceImpl {
- private final DefaultMQPullConsumerImpl defaultMQPullConsumerImpl;
-
-
- public RebalancePullImpl(DefaultMQPullConsumerImpl defaultMQPullConsumerImpl) {
- this(null, null, null, null, defaultMQPullConsumerImpl);
- }
-
-
- public RebalancePullImpl(String consumerGroup, MessageModel messageModel, AllocateMessageQueueStrategy allocateMessageQueueStrategy,
- MQClientInstance mQClientFactory, DefaultMQPullConsumerImpl defaultMQPullConsumerImpl) {
- super(consumerGroup, messageModel, allocateMessageQueueStrategy, mQClientFactory);
- this.defaultMQPullConsumerImpl = defaultMQPullConsumerImpl;
- }
-
- @Override
- public void messageQueueChanged(String topic, Set<MessageQueue> mqAll, Set<MessageQueue> mqDivided) {
- MessageQueueListener messageQueueListener = this.defaultMQPullConsumerImpl.getDefaultMQPullConsumer().getMessageQueueListener();
- if (messageQueueListener != null) {
- try {
- messageQueueListener.messageQueueChanged(topic, mqAll, mqDivided);
- } catch (Throwable e) {
- log.error("messageQueueChanged exception", e);
- }
- }
- }
-
- @Override
- public boolean removeUnnecessaryMessageQueue(MessageQueue mq, ProcessQueue pq) {
- this.defaultMQPullConsumerImpl.getOffsetStore().persist(mq);
- this.defaultMQPullConsumerImpl.getOffsetStore().removeOffset(mq);
- return true;
- }
-
- @Override
- public ConsumeType consumeType() {
- return ConsumeType.CONSUME_ACTIVELY;
- }
-
- @Override
- public void removeDirtyOffset(final MessageQueue mq) {
- this.defaultMQPullConsumerImpl.getOffsetStore().removeOffset(mq);
- }
-
- @Override
- public long computePullFromWhere(MessageQueue mq) {
- return 0;
- }
-
- @Override
- public void dispatchPullRequest(List<PullRequest> pullRequestList) {
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/RebalancePushImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/RebalancePushImpl.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/RebalancePushImpl.java
deleted file mode 100644
index 2377d29..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/RebalancePushImpl.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/**
- * 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.client.impl.consumer;
-
-import com.alibaba.rocketmq.client.consumer.AllocateMessageQueueStrategy;
-import com.alibaba.rocketmq.client.consumer.store.OffsetStore;
-import com.alibaba.rocketmq.client.consumer.store.ReadOffsetType;
-import com.alibaba.rocketmq.client.exception.MQClientException;
-import com.alibaba.rocketmq.client.impl.factory.MQClientInstance;
-import com.alibaba.rocketmq.common.MixAll;
-import com.alibaba.rocketmq.common.UtilAll;
-import com.alibaba.rocketmq.common.consumer.ConsumeFromWhere;
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType;
-import com.alibaba.rocketmq.common.protocol.heartbeat.MessageModel;
-
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-
-/**
- * @author shijia.wxr
- */
-public class RebalancePushImpl extends RebalanceImpl {
- private final static long UNLOCK_DELAY_TIME_MILLS = Long.parseLong(System.getProperty("rocketmq.client.unlockDelayTimeMills", "20000"));
- private final DefaultMQPushConsumerImpl defaultMQPushConsumerImpl;
-
-
- public RebalancePushImpl(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl) {
- this(null, null, null, null, defaultMQPushConsumerImpl);
- }
-
-
- public RebalancePushImpl(String consumerGroup, MessageModel messageModel, AllocateMessageQueueStrategy allocateMessageQueueStrategy,
- MQClientInstance mQClientFactory, DefaultMQPushConsumerImpl defaultMQPushConsumerImpl) {
- super(consumerGroup, messageModel, allocateMessageQueueStrategy, mQClientFactory);
- this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
- }
-
- @Override
- public void messageQueueChanged(String topic, Set<MessageQueue> mqAll, Set<MessageQueue> mqDivided) {
- }
-
- @Override
- public boolean removeUnnecessaryMessageQueue(MessageQueue mq, ProcessQueue pq) {
- this.defaultMQPushConsumerImpl.getOffsetStore().persist(mq);
- this.defaultMQPushConsumerImpl.getOffsetStore().removeOffset(mq);
- if (this.defaultMQPushConsumerImpl.isConsumeOrderly()
- && MessageModel.CLUSTERING.equals(this.defaultMQPushConsumerImpl.messageModel())) {
- try {
- if (pq.getLockConsume().tryLock(1000, TimeUnit.MILLISECONDS)) {
- try {
- return this.unlockDelay(mq, pq);
- } finally {
- pq.getLockConsume().unlock();
- }
- } else {
- log.warn("[WRONG]mq is consuming, so can not unlock it, {}. maybe hanged for a while, {}", //
- mq, //
- pq.getTryUnlockTimes());
-
- pq.incTryUnlockTimes();
- }
- } catch (Exception e) {
- log.error("removeUnnecessaryMessageQueue Exception", e);
- }
-
- return false;
- }
- return true;
- }
-
- private boolean unlockDelay(final MessageQueue mq, final ProcessQueue pq) {
-
- if (pq.hasTempMessage()) {
- log.info("[{}]unlockDelay, begin {} ", mq.hashCode(), mq);
- this.defaultMQPushConsumerImpl.getmQClientFactory().getScheduledExecutorService().schedule(new Runnable() {
- @Override
- public void run() {
- log.info("[{}]unlockDelay, execute at once {}", mq.hashCode(), mq);
- RebalancePushImpl.this.unlock(mq, true);
- }
- }, UNLOCK_DELAY_TIME_MILLS, TimeUnit.MILLISECONDS);
- } else {
- this.unlock(mq, true);
- }
- return true;
- }
-
- @Override
- public ConsumeType consumeType() {
- return ConsumeType.CONSUME_PASSIVELY;
- }
-
- @Override
- public void removeDirtyOffset(final MessageQueue mq) {
- this.defaultMQPushConsumerImpl.getOffsetStore().removeOffset(mq);
- }
-
- @Override
- public long computePullFromWhere(MessageQueue mq) {
- long result = -1;
- final ConsumeFromWhere consumeFromWhere = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer().getConsumeFromWhere();
- final OffsetStore offsetStore = this.defaultMQPushConsumerImpl.getOffsetStore();
- switch (consumeFromWhere) {
- case CONSUME_FROM_LAST_OFFSET_AND_FROM_MIN_WHEN_BOOT_FIRST:
- case CONSUME_FROM_MIN_OFFSET:
- case CONSUME_FROM_MAX_OFFSET:
- case CONSUME_FROM_LAST_OFFSET: {
- long lastOffset = offsetStore.readOffset(mq, ReadOffsetType.READ_FROM_STORE);
- if (lastOffset >= 0) {
- result = lastOffset;
- }
- // First start,no offset
- else if (-1 == lastOffset) {
- if (mq.getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
- result = 0L;
- } else {
- try {
- result = this.mQClientFactory.getMQAdminImpl().maxOffset(mq);
- } catch (MQClientException e) {
- result = -1;
- }
- }
- } else {
- result = -1;
- }
- break;
- }
- case CONSUME_FROM_FIRST_OFFSET: {
- long lastOffset = offsetStore.readOffset(mq, ReadOffsetType.READ_FROM_STORE);
- if (lastOffset >= 0) {
- result = lastOffset;
- } else if (-1 == lastOffset) {
- result = 0L;
- } else {
- result = -1;
- }
- break;
- }
- case CONSUME_FROM_TIMESTAMP: {
- long lastOffset = offsetStore.readOffset(mq, ReadOffsetType.READ_FROM_STORE);
- if (lastOffset >= 0) {
- result = lastOffset;
- } else if (-1 == lastOffset) {
- if (mq.getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
- try {
- result = this.mQClientFactory.getMQAdminImpl().maxOffset(mq);
- } catch (MQClientException e) {
- result = -1;
- }
- } else {
- try {
- long timestamp = UtilAll.parseDate(this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer().getConsumeTimestamp(),
- UtilAll.YYYY_MMDD_HHMMSS).getTime();
- result = this.mQClientFactory.getMQAdminImpl().searchOffset(mq, timestamp);
- } catch (MQClientException e) {
- result = -1;
- }
- }
- } else {
- result = -1;
- }
- break;
- }
-
- default:
- break;
- }
-
- return result;
- }
-
- @Override
- public void dispatchPullRequest(List<PullRequest> pullRequestList) {
- for (PullRequest pullRequest : pullRequestList) {
- this.defaultMQPushConsumerImpl.executePullRequestImmediately(pullRequest);
- log.info("doRebalance, {}, add a new pull request {}", consumerGroup, pullRequest);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/RebalanceService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/RebalanceService.java b/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/RebalanceService.java
deleted file mode 100644
index 47a9da5..0000000
--- a/client/src/main/java/com/alibaba/rocketmq/client/impl/consumer/RebalanceService.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * 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.client.impl.consumer;
-
-import com.alibaba.rocketmq.client.impl.factory.MQClientInstance;
-import com.alibaba.rocketmq.client.log.ClientLogger;
-import com.alibaba.rocketmq.common.ServiceThread;
-import org.slf4j.Logger;
-
-
-/**
- * Rebalance Service
- *
- * @author shijia.wxr
- */
-public class RebalanceService extends ServiceThread {
- private static long waitInterval =
- Long.parseLong(System.getProperty(
- "rocketmq.client.rebalance.waitInterval", "20000"));
- private final Logger log = ClientLogger.getLog();
- private final MQClientInstance mqClientFactory;
-
- public RebalanceService(MQClientInstance mqClientFactory) {
- this.mqClientFactory = mqClientFactory;
- }
-
- @Override
- public void run() {
- log.info(this.getServiceName() + " service started");
-
- while (!this.isStopped()) {
- this.waitForRunning(waitInterval);
- this.mqClientFactory.doRebalance();
- }
-
- log.info(this.getServiceName() + " service end");
- }
-
-
- @Override
- public String getServiceName() {
- return RebalanceService.class.getSimpleName();
- }
-}
[68/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/admin/MQAdminExt.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/admin/MQAdminExt.java b/tools/src/main/java/org/apache/rocketmq/tools/admin/MQAdminExt.java
index df4fe89..5056010 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/admin/MQAdminExt.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/admin/MQAdminExt.java
@@ -16,6 +16,11 @@
*/
package org.apache.rocketmq.tools.admin;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
import org.apache.rocketmq.client.MQAdmin;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
@@ -25,17 +30,27 @@ import org.apache.rocketmq.common.admin.RollbackStats;
import org.apache.rocketmq.common.admin.TopicStatsTable;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.common.message.MessageQueue;
-import org.apache.rocketmq.common.protocol.body.*;
+import org.apache.rocketmq.common.protocol.body.BrokerStatsData;
+import org.apache.rocketmq.common.protocol.body.ClusterInfo;
+import org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult;
+import org.apache.rocketmq.common.protocol.body.ConsumeStatsList;
+import org.apache.rocketmq.common.protocol.body.ConsumerConnection;
+import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
+import org.apache.rocketmq.common.protocol.body.GroupList;
+import org.apache.rocketmq.common.protocol.body.KVTable;
+import org.apache.rocketmq.common.protocol.body.ProducerConnection;
+import org.apache.rocketmq.common.protocol.body.QueueTimeSpan;
+import org.apache.rocketmq.common.protocol.body.SubscriptionGroupWrapper;
+import org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper;
+import org.apache.rocketmq.common.protocol.body.TopicList;
import org.apache.rocketmq.common.protocol.route.TopicRouteData;
import org.apache.rocketmq.common.subscription.SubscriptionGroupConfig;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.exception.RemotingConnectException;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
+import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
import org.apache.rocketmq.tools.admin.api.MessageTrack;
-import org.apache.rocketmq.remoting.exception.*;
-
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
public interface MQAdminExt extends MQAdmin {
void start() throws MQClientException;
@@ -43,53 +58,53 @@ public interface MQAdminExt extends MQAdmin {
void shutdown();
void updateBrokerConfig(final String brokerAddr, final Properties properties) throws RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException, UnsupportedEncodingException, InterruptedException, MQBrokerException;
+ RemotingSendRequestException, RemotingTimeoutException, UnsupportedEncodingException, InterruptedException, MQBrokerException;
Properties getBrokerConfig(final String brokerAddr) throws RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException, UnsupportedEncodingException, InterruptedException, MQBrokerException;
+ RemotingSendRequestException, RemotingTimeoutException, UnsupportedEncodingException, InterruptedException, MQBrokerException;
void createAndUpdateTopicConfig(final String addr, final TopicConfig config) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException;
+ InterruptedException, MQClientException;
void createAndUpdateSubscriptionGroupConfig(final String addr, final SubscriptionGroupConfig config) throws RemotingException,
- MQBrokerException, InterruptedException, MQClientException;
+ MQBrokerException, InterruptedException, MQClientException;
SubscriptionGroupConfig examineSubscriptionGroupConfig(final String addr, final String group);
TopicConfig examineTopicConfig(final String addr, final String topic);
TopicStatsTable examineTopicStats(final String topic) throws RemotingException, MQClientException, InterruptedException,
- MQBrokerException;
+ MQBrokerException;
TopicList fetchAllTopicList() throws RemotingException, MQClientException, InterruptedException;
TopicList fetchTopicsByCLuster(String clusterName) throws RemotingException, MQClientException, InterruptedException;
KVTable fetchBrokerRuntimeStats(final String brokerAddr) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, InterruptedException, MQBrokerException;
+ RemotingTimeoutException, InterruptedException, MQBrokerException;
ConsumeStats examineConsumeStats(final String consumerGroup) throws RemotingException, MQClientException, InterruptedException,
- MQBrokerException;
+ MQBrokerException;
ConsumeStats examineConsumeStats(final String consumerGroup, final String topic) throws RemotingException, MQClientException,
- InterruptedException, MQBrokerException;
+ InterruptedException, MQBrokerException;
ClusterInfo examineBrokerClusterInfo() throws InterruptedException, MQBrokerException, RemotingTimeoutException,
- RemotingSendRequestException, RemotingConnectException;
+ RemotingSendRequestException, RemotingConnectException;
TopicRouteData examineTopicRouteInfo(final String topic) throws RemotingException, MQClientException, InterruptedException;
ConsumerConnection examineConsumerConnectionInfo(final String consumerGroup) throws RemotingConnectException,
- RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException, RemotingException,
- MQClientException;
+ RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException, RemotingException,
+ MQClientException;
ProducerConnection examineProducerConnectionInfo(final String producerGroup, final String topic) throws RemotingException,
- MQClientException, InterruptedException, MQBrokerException;
+ MQClientException, InterruptedException, MQBrokerException;
List<String> getNameServerAddressList();
int wipeWritePermOfBroker(final String namesrvAddr, String brokerName) throws RemotingCommandException,
- RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQClientException;
+ RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQClientException;
void putKVConfig(final String namespace, final String key, final String value);
@@ -98,91 +113,94 @@ public interface MQAdminExt extends MQAdmin {
KVTable getKVListByNamespace(final String namespace) throws RemotingException, MQClientException, InterruptedException;
void deleteTopicInBroker(final Set<String> addrs, final String topic) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException;
+ InterruptedException, MQClientException;
void deleteTopicInNameServer(final Set<String> addrs, final String topic) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException;
+ InterruptedException, MQClientException;
void deleteSubscriptionGroup(final String addr, String groupName) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException;
+ InterruptedException, MQClientException;
void createAndUpdateKvConfig(String namespace, String key, String value) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException;
+ InterruptedException, MQClientException;
void deleteKvConfig(String namespace, String key) throws RemotingException, MQBrokerException, InterruptedException,
- MQClientException;
+ MQClientException;
List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp, boolean force)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
Map<MessageQueue, Long> resetOffsetByTimestamp(String topic, String group, long timestamp, boolean isForce)
- throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
void resetOffsetNew(String consumerGroup, String topic, long timestamp) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException;
+ InterruptedException, MQClientException;
Map<String, Map<MessageQueue, Long>> getConsumeStatus(String topic, String group, String clientAddr) throws RemotingException,
- MQBrokerException, InterruptedException, MQClientException;
+ MQBrokerException, InterruptedException, MQClientException;
void createOrUpdateOrderConf(String key, String value, boolean isCluster) throws RemotingException, MQBrokerException,
- InterruptedException, MQClientException;
+ InterruptedException, MQClientException;
GroupList queryTopicConsumeByWho(final String topic) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, InterruptedException, MQBrokerException, RemotingException, MQClientException;
+ RemotingTimeoutException, InterruptedException, MQBrokerException, RemotingException, MQClientException;
List<QueueTimeSpan> queryConsumeTimeSpan(final String topic, final String group) throws InterruptedException, MQBrokerException,
- RemotingException, MQClientException;
+ RemotingException, MQClientException;
boolean cleanExpiredConsumerQueue(String cluster) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, MQClientException, InterruptedException;
+ RemotingTimeoutException, MQClientException, InterruptedException;
boolean cleanExpiredConsumerQueueByAddr(String addr) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, MQClientException, InterruptedException;
+ RemotingTimeoutException, MQClientException, InterruptedException;
boolean cleanUnusedTopic(String cluster) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, MQClientException, InterruptedException;
-
+ RemotingTimeoutException, MQClientException, InterruptedException;
boolean cleanUnusedTopicByAddr(String addr) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, MQClientException, InterruptedException;
+ RemotingTimeoutException, MQClientException, InterruptedException;
ConsumerRunningInfo getConsumerRunningInfo(final String consumerGroup, final String clientId, final boolean jstack)
- throws RemotingException, MQClientException, InterruptedException;
+ throws RemotingException, MQClientException, InterruptedException;
ConsumeMessageDirectlyResult consumeMessageDirectly(String consumerGroup,
- String clientId,
- String msgId) throws RemotingException, MQClientException, InterruptedException, MQBrokerException;
+ String clientId,
+ String msgId) throws RemotingException, MQClientException, InterruptedException, MQBrokerException;
ConsumeMessageDirectlyResult consumeMessageDirectly(String consumerGroup,
- String clientId,
- String topic,
- String msgId) throws RemotingException, MQClientException, InterruptedException, MQBrokerException;
+ String clientId,
+ String topic,
+ String msgId) throws RemotingException, MQClientException, InterruptedException, MQBrokerException;
List<MessageTrack> messageTrackDetail(MessageExt msg) throws RemotingException, MQClientException, InterruptedException,
- MQBrokerException;
+ MQBrokerException;
void cloneGroupOffset(String srcGroup, String destGroup, String topic, boolean isOffline) throws RemotingException,
- MQClientException, InterruptedException, MQBrokerException;
+ MQClientException, InterruptedException, MQBrokerException;
BrokerStatsData viewBrokerStatsData(final String brokerAddr, final String statsName, final String statsKey)
- throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, MQClientException,
- InterruptedException;
+ throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, MQClientException,
+ InterruptedException;
Set<String> getClusterList(final String topic) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, MQClientException, InterruptedException;
+ RemotingTimeoutException, MQClientException, InterruptedException;
- ConsumeStatsList fetchConsumeStatsInBroker(final String brokerAddr, boolean isOrder, long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, MQClientException, InterruptedException;
+ ConsumeStatsList fetchConsumeStatsInBroker(final String brokerAddr, boolean isOrder,
+ long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException,
+ RemotingTimeoutException, MQClientException, InterruptedException;
Set<String> getTopicClusterList(final String topic) throws InterruptedException, MQBrokerException, MQClientException, RemotingException;
- SubscriptionGroupWrapper getAllSubscriptionGroup(final String brokerAddr, long timeoutMillis) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException,
- RemotingConnectException, MQBrokerException;
+ SubscriptionGroupWrapper getAllSubscriptionGroup(final String brokerAddr,
+ long timeoutMillis) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException,
+ RemotingConnectException, MQBrokerException;
- TopicConfigSerializeWrapper getAllTopicGroup(final String brokerAddr, long timeoutMillis) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException,
- RemotingConnectException, MQBrokerException;
+ TopicConfigSerializeWrapper getAllTopicGroup(final String brokerAddr,
+ long timeoutMillis) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException,
+ RemotingConnectException, MQBrokerException;
- void updateConsumeOffset(String brokerAddr, String consumeGroup, MessageQueue mq, long offset) throws RemotingException, InterruptedException, MQBrokerException;
+ void updateConsumeOffset(String brokerAddr, String consumeGroup, MessageQueue mq,
+ long offset) throws RemotingException, InterruptedException, MQBrokerException;
/**
* Update name server config.
@@ -193,7 +211,6 @@ public interface MQAdminExt extends MQAdmin {
*
* @param properties
* @param nameServers
- *
* @throws InterruptedException
* @throws RemotingConnectException
* @throws UnsupportedEncodingException
@@ -203,8 +220,8 @@ public interface MQAdminExt extends MQAdmin {
* @throws MQBrokerException
*/
void updateNameServerConfig(final Properties properties, final List<String> nameServers) throws InterruptedException, RemotingConnectException,
- UnsupportedEncodingException, RemotingSendRequestException, RemotingTimeoutException,
- MQClientException, MQBrokerException;
+ UnsupportedEncodingException, RemotingSendRequestException, RemotingTimeoutException,
+ MQClientException, MQBrokerException;
/**
* Get name server config.
@@ -213,9 +230,7 @@ public interface MQAdminExt extends MQAdmin {
* <br> If param(nameServers) is null or empty, will use name servers from ns!
*
* @param nameServers
- *
* @return The fetched name server config
- *
* @throws InterruptedException
* @throws RemotingTimeoutException
* @throws RemotingSendRequestException
@@ -224,6 +239,6 @@ public interface MQAdminExt extends MQAdmin {
* @throws UnsupportedEncodingException
*/
Map<String, Properties> getNameServerConfig(final List<String> nameServers) throws InterruptedException,
- RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException,
- MQClientException, UnsupportedEncodingException;
+ RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException,
+ MQClientException, UnsupportedEncodingException;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/admin/api/MessageTrack.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/admin/api/MessageTrack.java b/tools/src/main/java/org/apache/rocketmq/tools/admin/api/MessageTrack.java
index 324b661..4445482 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/admin/api/MessageTrack.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/admin/api/MessageTrack.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.tools.admin.api;
@@ -22,40 +22,33 @@ public class MessageTrack {
private TrackType trackType;
private String exceptionDesc;
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public TrackType getTrackType() {
return trackType;
}
-
public void setTrackType(TrackType trackType) {
this.trackType = trackType;
}
-
public String getExceptionDesc() {
return exceptionDesc;
}
-
public void setExceptionDesc(String exceptionDesc) {
this.exceptionDesc = exceptionDesc;
}
-
@Override
public String toString() {
return "MessageTrack [consumerGroup=" + consumerGroup + ", trackType=" + trackType
- + ", exceptionDesc=" + exceptionDesc + "]";
+ + ", exceptionDesc=" + exceptionDesc + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/admin/api/TrackType.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/admin/api/TrackType.java b/tools/src/main/java/org/apache/rocketmq/tools/admin/api/TrackType.java
index 36345f9..df70523 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/admin/api/TrackType.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/admin/api/TrackType.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.tools.admin.api;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java b/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
index c675d9a..8b86ab8 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
@@ -16,6 +16,14 @@
*/
package org.apache.rocketmq.tools.command;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.protocol.body.ClusterInfo;
@@ -25,16 +33,13 @@ import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
import org.apache.rocketmq.tools.admin.MQAdminExt;
-import java.util.*;
-
-
public class CommandUtil {
public static Map<String/*master addr*/, List<String>/*slave addr*/> fetchMasterAndSlaveDistinguish(
- final MQAdminExt adminExt, final String clusterName)
- throws InterruptedException, RemotingConnectException,
- RemotingTimeoutException, RemotingSendRequestException,
- MQBrokerException {
+ final MQAdminExt adminExt, final String clusterName)
+ throws InterruptedException, RemotingConnectException,
+ RemotingTimeoutException, RemotingSendRequestException,
+ MQBrokerException {
Map<String, List<String>> masterAndSlaveMap = new HashMap<String, List<String>>(4);
ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();
@@ -42,7 +47,7 @@ public class CommandUtil {
if (brokerNameSet == null) {
System.out
- .printf("[error] Make sure the specified clusterName exists or the nameserver which connected is correct.");
+ .printf("[error] Make sure the specified clusterName exists or the nameserver which connected is correct.");
return masterAndSlaveMap;
}
@@ -58,7 +63,7 @@ public class CommandUtil {
for (Long id : brokerData.getBrokerAddrs().keySet()) {
if (brokerData.getBrokerAddrs().get(id) == null
- || id.longValue() == MixAll.MASTER_ID) {
+ || id.longValue() == MixAll.MASTER_ID) {
continue;
}
@@ -70,8 +75,8 @@ public class CommandUtil {
}
public static Set<String> fetchMasterAddrByClusterName(final MQAdminExt adminExt, final String clusterName)
- throws InterruptedException, RemotingConnectException, RemotingTimeoutException,
- RemotingSendRequestException, MQBrokerException {
+ throws InterruptedException, RemotingConnectException, RemotingTimeoutException,
+ RemotingSendRequestException, MQBrokerException {
Set<String> masterSet = new HashSet<String>();
ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();
@@ -91,15 +96,15 @@ public class CommandUtil {
}
} else {
System.out
- .printf("[error] Make sure the specified clusterName exists or the nameserver which connected is correct.");
+ .printf("[error] Make sure the specified clusterName exists or the nameserver which connected is correct.");
}
return masterSet;
}
public static Set<String> fetchMasterAndSlaveAddrByClusterName(final MQAdminExt adminExt, final String clusterName)
- throws InterruptedException, RemotingConnectException, RemotingTimeoutException,
- RemotingSendRequestException, MQBrokerException {
+ throws InterruptedException, RemotingConnectException, RemotingTimeoutException,
+ RemotingSendRequestException, MQBrokerException {
Set<String> masterSet = new HashSet<String>();
ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();
@@ -116,29 +121,27 @@ public class CommandUtil {
}
} else {
System.out
- .printf("[error] Make sure the specified clusterName exists or the nameserver which connected is correct.");
+ .printf("[error] Make sure the specified clusterName exists or the nameserver which connected is correct.");
}
return masterSet;
}
-
public static Set<String> fetchBrokerNameByClusterName(final MQAdminExt adminExt, final String clusterName)
- throws Exception {
+ throws Exception {
ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();
Set<String> brokerNameSet = clusterInfoSerializeWrapper.getClusterAddrTable().get(clusterName);
if (brokerNameSet.isEmpty()) {
throw new Exception(
- "Make sure the specified clusterName exists or the nameserver which connected is correct.");
+ "Make sure the specified clusterName exists or the nameserver which connected is correct.");
}
return brokerNameSet;
}
-
public static String fetchBrokerNameByAddr(final MQAdminExt adminExt, final String addr) throws Exception {
ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();
HashMap<String/* brokerName */, BrokerData> brokerAddrTable =
- clusterInfoSerializeWrapper.getBrokerAddrTable();
+ clusterInfoSerializeWrapper.getBrokerAddrTable();
Iterator<Map.Entry<String, BrokerData>> it = brokerAddrTable.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, BrokerData> entry = it.next();
@@ -147,8 +150,7 @@ public class CommandUtil {
return entry.getKey();
}
throw new Exception(
- "Make sure the specified broker addr exists or the nameserver which connected is correct.");
+ "Make sure the specified broker addr exists or the nameserver which connected is correct.");
}
-
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java b/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java
index d11dd23..a1753c1 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java
@@ -6,45 +6,71 @@
* (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
+ * 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.
+ * 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.tools.command;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.PosixParser;
import org.apache.rocketmq.common.MQVersion;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.apache.rocketmq.srvutil.ServerUtil;
+import org.apache.rocketmq.tools.command.broker.BrokerConsumeStatsSubCommad;
+import org.apache.rocketmq.tools.command.broker.BrokerStatusSubCommand;
+import org.apache.rocketmq.tools.command.broker.CleanExpiredCQSubCommand;
+import org.apache.rocketmq.tools.command.broker.CleanUnusedTopicCommand;
+import org.apache.rocketmq.tools.command.broker.GetBrokerConfigCommand;
+import org.apache.rocketmq.tools.command.broker.SendMsgStatusCommand;
+import org.apache.rocketmq.tools.command.broker.UpdateBrokerConfigSubCommand;
import org.apache.rocketmq.tools.command.cluster.CLusterSendMsgRTCommand;
import org.apache.rocketmq.tools.command.cluster.ClusterListSubCommand;
import org.apache.rocketmq.tools.command.connection.ConsumerConnectionSubCommand;
import org.apache.rocketmq.tools.command.connection.ProducerConnectionSubCommand;
-import org.apache.rocketmq.tools.command.consumer.*;
-import org.apache.rocketmq.tools.command.namesrv.*;
+import org.apache.rocketmq.tools.command.consumer.ConsumerProgressSubCommand;
+import org.apache.rocketmq.tools.command.consumer.ConsumerStatusSubCommand;
+import org.apache.rocketmq.tools.command.consumer.DeleteSubscriptionGroupCommand;
+import org.apache.rocketmq.tools.command.consumer.StartMonitoringSubCommand;
+import org.apache.rocketmq.tools.command.consumer.UpdateSubGroupSubCommand;
+import org.apache.rocketmq.tools.command.message.CheckMsgSendRTCommand;
+import org.apache.rocketmq.tools.command.message.PrintMessageByQueueCommand;
+import org.apache.rocketmq.tools.command.message.PrintMessageSubCommand;
+import org.apache.rocketmq.tools.command.message.QueryMsgByIdSubCommand;
+import org.apache.rocketmq.tools.command.message.QueryMsgByKeySubCommand;
+import org.apache.rocketmq.tools.command.message.QueryMsgByOffsetSubCommand;
+import org.apache.rocketmq.tools.command.message.QueryMsgByUniqueKeySubCommand;
+import org.apache.rocketmq.tools.command.namesrv.DeleteKvConfigCommand;
+import org.apache.rocketmq.tools.command.namesrv.GetNamesrvConfigCommand;
+import org.apache.rocketmq.tools.command.namesrv.UpdateKvConfigCommand;
+import org.apache.rocketmq.tools.command.namesrv.UpdateNamesrvConfigCommand;
+import org.apache.rocketmq.tools.command.namesrv.WipeWritePermSubCommand;
import org.apache.rocketmq.tools.command.offset.CloneGroupOffsetCommand;
import org.apache.rocketmq.tools.command.offset.ResetOffsetByTimeCommand;
import org.apache.rocketmq.tools.command.stats.StatsAllSubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.PosixParser;
-import org.apache.rocketmq.tools.command.broker.*;
-import org.apache.rocketmq.tools.command.message.*;
-import org.apache.rocketmq.tools.command.topic.*;
+import org.apache.rocketmq.tools.command.topic.AllocateMQSubCommand;
+import org.apache.rocketmq.tools.command.topic.DeleteTopicSubCommand;
+import org.apache.rocketmq.tools.command.topic.TopicClusterSubCommand;
+import org.apache.rocketmq.tools.command.topic.TopicListSubCommand;
+import org.apache.rocketmq.tools.command.topic.TopicRouteSubCommand;
+import org.apache.rocketmq.tools.command.topic.TopicStatusSubCommand;
+import org.apache.rocketmq.tools.command.topic.UpdateOrderConfCommand;
+import org.apache.rocketmq.tools.command.topic.UpdateTopicPermSubCommand;
+import org.apache.rocketmq.tools.command.topic.UpdateTopicSubCommand;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.List;
-
-
public class MQAdminStartup {
protected static List<SubCommand> subCommandList = new ArrayList<SubCommand>();
@@ -55,7 +81,6 @@ public class MQAdminStartup {
public static void main0(String[] args, RPCHook rpcHook) {
System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));
-
//PackageConflictDetect.detectFastjson();
initCommand();
@@ -86,11 +111,10 @@ public class MQAdminStartup {
if (cmd != null) {
String[] subargs = parseSubArgs(args);
-
Options options = ServerUtil.buildCommandlineOptions(new Options());
final CommandLine commandLine =
- ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options),
- new PosixParser());
+ ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options),
+ new PosixParser());
if (null == commandLine) {
System.exit(-1);
return;
@@ -124,7 +148,6 @@ public class MQAdminStartup {
initCommand(new TopicStatusSubCommand());
initCommand(new TopicClusterSubCommand());
-
initCommand(new BrokerStatusSubCommand());
initCommand(new QueryMsgByIdSubCommand());
initCommand(new QueryMsgByKeySubCommand());
@@ -136,7 +159,6 @@ public class MQAdminStartup {
initCommand(new SendMsgStatusCommand());
initCommand(new BrokerConsumeStatsSubCommad());
-
initCommand(new ProducerConnectionSubCommand());
initCommand(new ConsumerConnectionSubCommand());
initCommand(new ConsumerProgressSubCommand());
@@ -172,7 +194,7 @@ public class MQAdminStartup {
private static void initLogback() throws JoranException {
String rocketmqHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV));
- LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+ LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/SubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/SubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/SubCommand.java
index 744685e..2035276 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/SubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/SubCommand.java
@@ -6,30 +6,26 @@
* (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
+ * 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.
+ * 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.tools.command;
-import org.apache.rocketmq.remoting.RPCHook;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
-
+import org.apache.rocketmq.remoting.RPCHook;
public interface SubCommand {
public String commandName();
-
public String commandDesc();
-
public Options buildCommandlineOptions(final Options options);
-
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerConsumeStatsSubCommad.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerConsumeStatsSubCommad.java b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerConsumeStatsSubCommad.java
index 57ca907..485b58c 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerConsumeStatsSubCommad.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerConsumeStatsSubCommad.java
@@ -16,6 +16,14 @@
*/
package org.apache.rocketmq.tools.command.broker;
+import java.util.Collections;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.admin.ConsumeStats;
import org.apache.rocketmq.common.admin.OffsetWrapper;
@@ -24,12 +32,6 @@ import org.apache.rocketmq.common.protocol.body.ConsumeStatsList;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.*;
-
public class BrokerConsumeStatsSubCommad implements SubCommand {
@@ -86,14 +88,14 @@ public class BrokerConsumeStatsSubCommad implements SubCommand {
ConsumeStatsList consumeStatsList = defaultMQAdminExt.fetchConsumeStatsInBroker(brokerAddr, isOrder, timeoutMillis);
System.out.printf("%-32s %-32s %-32s %-4s %-20s %-20s %-20s %s%n",
- "#Topic",
- "#Group",
- "#Broker Name",
- "#QID",
- "#Broker Offset",
- "#Consumer Offset",
- "#Diff",
- "#LastTime");
+ "#Topic",
+ "#Group",
+ "#Broker Name",
+ "#QID",
+ "#Broker Offset",
+ "#Consumer Offset",
+ "#Diff",
+ "#LastTime");
for (Map<String, List<ConsumeStats>> map : consumeStatsList.getConsumeStatsList()) {
for (Map.Entry<String, List<ConsumeStats>> entry : map.entrySet()) {
String group = entry.getKey();
@@ -117,14 +119,14 @@ public class BrokerConsumeStatsSubCommad implements SubCommand {
}
if (offsetWrapper.getLastTimestamp() > 0)
System.out.printf("%-32s %-32s %-32s %-4d %-20d %-20d %-20d %s%n",
- UtilAll.frontStringAtLeast(mq.getTopic(), 32),
- group,
- UtilAll.frontStringAtLeast(mq.getBrokerName(), 32),
- mq.getQueueId(),
- offsetWrapper.getBrokerOffset(),
- offsetWrapper.getConsumerOffset(),
- diff,
- lastTime
+ UtilAll.frontStringAtLeast(mq.getTopic(), 32),
+ group,
+ UtilAll.frontStringAtLeast(mq.getBrokerName(), 32),
+ mq.getQueueId(),
+ offsetWrapper.getBrokerOffset(),
+ offsetWrapper.getConsumerOffset(),
+ diff,
+ lastTime
);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerStatusSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerStatusSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerStatusSubCommand.java
index 3f5ff79..2fad2d1 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerStatusSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/BrokerStatusSubCommand.java
@@ -16,6 +16,13 @@
*/
package org.apache.rocketmq.tools.command.broker;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeMap;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.common.protocol.body.KVTable;
import org.apache.rocketmq.remoting.RPCHook;
@@ -25,15 +32,6 @@ import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.CommandUtil;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeMap;
-
public class BrokerStatusSubCommand implements SubCommand {
@@ -42,13 +40,11 @@ public class BrokerStatusSubCommand implements SubCommand {
return "brokerStatus";
}
-
@Override
public String commandDesc() {
return "Fetch broker runtime status data";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("b", "brokerAddr", true, "Broker address");
@@ -77,7 +73,7 @@ public class BrokerStatusSubCommand implements SubCommand {
printBrokerRuntimeStats(defaultMQAdminExt, brokerAddr, false);
} else if (clusterName != null) {
Set<String> masterSet =
- CommandUtil.fetchMasterAndSlaveAddrByClusterName(defaultMQAdminExt, clusterName);
+ CommandUtil.fetchMasterAndSlaveAddrByClusterName(defaultMQAdminExt, clusterName);
for (String ba : masterSet) {
try {
printBrokerRuntimeStats(defaultMQAdminExt, ba, true);
@@ -87,7 +83,6 @@ public class BrokerStatusSubCommand implements SubCommand {
}
}
-
} catch (Exception e) {
e.printStackTrace();
} finally {
@@ -95,7 +90,8 @@ public class BrokerStatusSubCommand implements SubCommand {
}
}
- public void printBrokerRuntimeStats(final DefaultMQAdminExt defaultMQAdminExt, final String brokerAddr, final boolean printBroker) throws InterruptedException, MQBrokerException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException {
+ public void printBrokerRuntimeStats(final DefaultMQAdminExt defaultMQAdminExt, final String brokerAddr,
+ final boolean printBroker) throws InterruptedException, MQBrokerException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException {
KVTable kvTable = defaultMQAdminExt.fetchBrokerRuntimeStats(brokerAddr);
TreeMap<String, String> tmp = new TreeMap<String, String>();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanExpiredCQSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanExpiredCQSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanExpiredCQSubCommand.java
index 71aa78b..d15ad64 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanExpiredCQSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanExpiredCQSubCommand.java
@@ -6,24 +6,23 @@
* (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
+ * 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.
+ * 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.tools.command.broker;
-import org.apache.rocketmq.remoting.RPCHook;
-import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
-import org.apache.rocketmq.tools.command.SubCommand;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
-
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
+import org.apache.rocketmq.tools.command.SubCommand;
public class CleanExpiredCQSubCommand implements SubCommand {
@@ -32,13 +31,11 @@ public class CleanExpiredCQSubCommand implements SubCommand {
return "cleanExpiredCQ";
}
-
@Override
public String commandDesc() {
return "Clean expired ConsumeQueue on broker.";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("b", "brokerAddr", true, "Broker address");
@@ -52,7 +49,6 @@ public class CleanExpiredCQSubCommand implements SubCommand {
return options;
}
-
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanUnusedTopicCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanUnusedTopicCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanUnusedTopicCommand.java
index 0e4c4b4..ca5778b 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanUnusedTopicCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/CleanUnusedTopicCommand.java
@@ -6,24 +6,23 @@
* (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
+ * 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.
+ * 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.tools.command.broker;
-import org.apache.rocketmq.remoting.RPCHook;
-import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
-import org.apache.rocketmq.tools.command.SubCommand;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
-
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
+import org.apache.rocketmq.tools.command.SubCommand;
public class CleanUnusedTopicCommand implements SubCommand {
@@ -32,13 +31,11 @@ public class CleanUnusedTopicCommand implements SubCommand {
return "cleanUnusedTopic";
}
-
@Override
public String commandDesc() {
return "Clean unused topic on broker.";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("b", "brokerAddr", true, "Broker address");
@@ -52,7 +49,6 @@ public class CleanUnusedTopicCommand implements SubCommand {
return options;
}
-
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/broker/GetBrokerConfigCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/GetBrokerConfigCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/GetBrokerConfigCommand.java
index 2956264..d0a271e 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/GetBrokerConfigCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/GetBrokerConfigCommand.java
@@ -17,6 +17,13 @@
package org.apache.rocketmq.tools.command.broker;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.remoting.exception.RemotingConnectException;
@@ -26,14 +33,6 @@ import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.admin.MQAdminExt;
import org.apache.rocketmq.tools.command.CommandUtil;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
public class GetBrokerConfigCommand implements SubCommand {
@Override
@@ -72,29 +71,29 @@ public class GetBrokerConfigCommand implements SubCommand {
defaultMQAdminExt.start();
getAndPrint(defaultMQAdminExt,
- String.format("============%s============\n", brokerAddr),
- brokerAddr);
+ String.format("============%s============\n", brokerAddr),
+ brokerAddr);
} else if (commandLine.hasOption('c')) {
String clusterName = commandLine.getOptionValue('c').trim();
defaultMQAdminExt.start();
Map<String, List<String>> masterAndSlaveMap
- = CommandUtil.fetchMasterAndSlaveDistinguish(defaultMQAdminExt, clusterName);
+ = CommandUtil.fetchMasterAndSlaveDistinguish(defaultMQAdminExt, clusterName);
for (String masterAddr : masterAndSlaveMap.keySet()) {
getAndPrint(
- defaultMQAdminExt,
- String.format("============Master: %s============\n", masterAddr),
- masterAddr
+ defaultMQAdminExt,
+ String.format("============Master: %s============\n", masterAddr),
+ masterAddr
);
for (String slaveAddr : masterAndSlaveMap.get(masterAddr)) {
getAndPrint(
- defaultMQAdminExt,
- String.format("============My Master: %s=====Slave: %s============\n", masterAddr, slaveAddr),
- slaveAddr
+ defaultMQAdminExt,
+ String.format("============My Master: %s=====Slave: %s============\n", masterAddr, slaveAddr),
+ slaveAddr
);
}
}
@@ -108,9 +107,9 @@ public class GetBrokerConfigCommand implements SubCommand {
}
protected void getAndPrint(final MQAdminExt defaultMQAdminExt, final String printPrefix, final String addr)
- throws InterruptedException, RemotingConnectException,
- UnsupportedEncodingException, RemotingTimeoutException,
- MQBrokerException, RemotingSendRequestException {
+ throws InterruptedException, RemotingConnectException,
+ UnsupportedEncodingException, RemotingTimeoutException,
+ MQBrokerException, RemotingSendRequestException {
System.out.print(printPrefix);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/broker/SendMsgStatusCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/SendMsgStatusCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/SendMsgStatusCommand.java
index d40ba21..d770d12 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/SendMsgStatusCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/SendMsgStatusCommand.java
@@ -16,33 +16,41 @@
*/
package org.apache.rocketmq.tools.command.broker;
+import java.io.UnsupportedEncodingException;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import java.io.UnsupportedEncodingException;
+public class SendMsgStatusCommand implements SubCommand {
+ private static Message buildMessage(final String topic, final int messageSize) throws UnsupportedEncodingException {
+ Message msg = new Message();
+ msg.setTopic(topic);
-public class SendMsgStatusCommand implements SubCommand {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < messageSize; i += 11) {
+ sb.append("hello jodie");
+ }
+ msg.setBody(sb.toString().getBytes(MixAll.DEFAULT_CHARSET));
+ return msg;
+ }
@Override
public String commandName() {
return "sendMsgStatus";
}
-
@Override
public String commandDesc() {
return "send msg to broker.";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("b", "brokerName", true, "Broker Name");
@@ -60,7 +68,6 @@ public class SendMsgStatusCommand implements SubCommand {
return options;
}
-
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
final DefaultMQProducer producer = new DefaultMQProducer("PID_SMSC", rpcHook);
@@ -85,17 +92,4 @@ public class SendMsgStatusCommand implements SubCommand {
producer.shutdown();
}
}
-
-
- private static Message buildMessage(final String topic, final int messageSize) throws UnsupportedEncodingException {
- Message msg = new Message();
- msg.setTopic(topic);
-
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < messageSize; i += 11) {
- sb.append("hello jodie");
- }
- msg.setBody(sb.toString().getBytes(MixAll.DEFAULT_CHARSET));
- return msg;
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/broker/UpdateBrokerConfigSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/UpdateBrokerConfigSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/UpdateBrokerConfigSubCommand.java
index 1de9457..8718c9e 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/broker/UpdateBrokerConfigSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/broker/UpdateBrokerConfigSubCommand.java
@@ -6,28 +6,26 @@
* (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
+ * 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.
+ * 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.tools.command.broker;
+import java.util.Properties;
+import java.util.Set;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.srvutil.ServerUtil;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.CommandUtil;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.Properties;
-import java.util.Set;
-
public class UpdateBrokerConfigSubCommand implements SubCommand {
@@ -36,13 +34,11 @@ public class UpdateBrokerConfigSubCommand implements SubCommand {
return "updateBrokerConfig";
}
-
@Override
public String commandDesc() {
return "Update broker's config";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("b", "brokerAddr", true, "update which broker");
@@ -64,7 +60,6 @@ public class UpdateBrokerConfigSubCommand implements SubCommand {
return options;
}
-
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
@@ -92,7 +87,7 @@ public class UpdateBrokerConfigSubCommand implements SubCommand {
defaultMQAdminExt.start();
Set<String> masterSet =
- CommandUtil.fetchMasterAddrByClusterName(defaultMQAdminExt, clusterName);
+ CommandUtil.fetchMasterAddrByClusterName(defaultMQAdminExt, clusterName);
for (String brokerAddr : masterSet) {
try {
defaultMQAdminExt.updateBrokerConfig(brokerAddr, properties);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/CLusterSendMsgRTCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/CLusterSendMsgRTCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/CLusterSendMsgRTCommand.java
index a8bd3a8..1ae6d52 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/CLusterSendMsgRTCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/CLusterSendMsgRTCommand.java
@@ -17,6 +17,16 @@
package org.apache.rocketmq.tools.command.cluster;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.TimeZone;
+import java.util.TreeSet;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.message.Message;
@@ -24,13 +34,6 @@ import org.apache.rocketmq.common.protocol.body.ClusterInfo;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.*;
public class CLusterSendMsgRTCommand implements SubCommand {
@@ -90,24 +93,24 @@ public class CLusterSendMsgRTCommand implements SubCommand {
ClusterInfo clusterInfoSerializeWrapper = defaultMQAdminExt.examineBrokerClusterInfo();
HashMap<String, Set<String>> clusterAddr = clusterInfoSerializeWrapper
- .getClusterAddrTable();
+ .getClusterAddrTable();
Set<String> clusterNames = null;
long amount = !commandLine.hasOption('a') ? 50 : Long.parseLong(commandLine
- .getOptionValue('a').trim());
+ .getOptionValue('a').trim());
long size = !commandLine.hasOption('s') ? 128 : Long.parseLong(commandLine
- .getOptionValue('s').trim());
+ .getOptionValue('s').trim());
long interval = !commandLine.hasOption('i') ? 10 : Long.parseLong(commandLine
- .getOptionValue('i').trim());
+ .getOptionValue('i').trim());
boolean printAsTlog = !commandLine.hasOption('p') ? false : Boolean
- .parseBoolean(commandLine.getOptionValue('p').trim());
+ .parseBoolean(commandLine.getOptionValue('p').trim());
String machineRoom = !commandLine.hasOption('m') ? "noname" : commandLine
- .getOptionValue('m').trim();
+ .getOptionValue('m').trim();
if (commandLine.hasOption('c')) {
clusterNames = new TreeSet<String>();
@@ -118,11 +121,11 @@ public class CLusterSendMsgRTCommand implements SubCommand {
if (!printAsTlog) {
System.out.printf("%-24s %-24s %-4s %-8s %-8s%n",
- "#Cluster Name",
- "#Broker Name",
- "#RT",
- "#successCount",
- "#failCount"
+ "#Cluster Name",
+ "#Broker Name",
+ "#RT",
+ "#successCount",
+ "#failCount"
);
}
@@ -158,19 +161,19 @@ public class CLusterSendMsgRTCommand implements SubCommand {
}
}
- double rt = (double) elapsed / (amount - 1);
+ double rt = (double)elapsed / (amount - 1);
if (!printAsTlog) {
System.out.printf("%-24s %-24s %-8s %-16s %-16s%n",
- clusterName,
- brokerName,
- String.format("%.2f", rt),
- successCount,
- failCount
+ clusterName,
+ brokerName,
+ String.format("%.2f", rt),
+ successCount,
+ failCount
);
} else {
System.out.printf(String.format("%s|%s|%s|%s|%s%n", getCurTime(),
- machineRoom, clusterName, brokerName,
- new BigDecimal(rt).setScale(0, BigDecimal.ROUND_HALF_UP)));
+ machineRoom, clusterName, brokerName,
+ new BigDecimal(rt).setScale(0, BigDecimal.ROUND_HALF_UP)));
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/ClusterListSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/ClusterListSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/ClusterListSubCommand.java
index b649af1..eb250cf 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/ClusterListSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/cluster/ClusterListSubCommand.java
@@ -16,6 +16,13 @@
*/
package org.apache.rocketmq.tools.command.cluster;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.common.protocol.body.ClusterInfo;
import org.apache.rocketmq.common.protocol.body.KVTable;
@@ -26,15 +33,6 @@ import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
public class ClusterListSubCommand implements SubCommand {
@@ -43,13 +41,11 @@ public class ClusterListSubCommand implements SubCommand {
return "clusterList";
}
-
@Override
public String commandDesc() {
return "List all of clusters";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("m", "moreStats", false, "Print more stats");
@@ -89,7 +85,8 @@ public class ClusterListSubCommand implements SubCommand {
} else {
this.printClusterBaseInfo(defaultMQAdminExt);
}
- } while (enableInterval);
+ }
+ while (enableInterval);
} catch (Exception e) {
e.printStackTrace();
} finally {
@@ -98,17 +95,17 @@ public class ClusterListSubCommand implements SubCommand {
}
private void printClusterMoreStats(final DefaultMQAdminExt defaultMQAdminExt) throws RemotingConnectException,
- RemotingTimeoutException, RemotingSendRequestException, InterruptedException, MQBrokerException {
+ RemotingTimeoutException, RemotingSendRequestException, InterruptedException, MQBrokerException {
ClusterInfo clusterInfoSerializeWrapper = defaultMQAdminExt.examineBrokerClusterInfo();
System.out.printf("%-16s %-32s %14s %14s %14s %14s%n",
- "#Cluster Name",
- "#Broker Name",
- "#InTotalYest",
- "#OutTotalYest",
- "#InTotalToday",
- "#OutTotalToday"
+ "#Cluster Name",
+ "#Broker Name",
+ "#InTotalYest",
+ "#OutTotalYest",
+ "#InTotalToday",
+ "#OutTotalToday"
);
Iterator<Map.Entry<String, Set<String>>> itCluster = clusterInfoSerializeWrapper.getClusterAddrTable().entrySet().iterator();
@@ -149,12 +146,12 @@ public class ClusterListSubCommand implements SubCommand {
}
System.out.printf("%-16s %-32s %14d %14d %14d %14d%n",
- clusterName,
- brokerName,
- inTotalYest,
- outTotalYest,
- inTotalToday,
- outTotalToday
+ clusterName,
+ brokerName,
+ inTotalYest,
+ outTotalYest,
+ inTotalToday,
+ outTotalToday
);
}
}
@@ -167,21 +164,21 @@ public class ClusterListSubCommand implements SubCommand {
}
private void printClusterBaseInfo(final DefaultMQAdminExt defaultMQAdminExt) throws RemotingConnectException, RemotingTimeoutException,
- RemotingSendRequestException, InterruptedException, MQBrokerException {
+ RemotingSendRequestException, InterruptedException, MQBrokerException {
ClusterInfo clusterInfoSerializeWrapper = defaultMQAdminExt.examineBrokerClusterInfo();
System.out.printf("%-16s %-22s %-4s %-22s %-16s %19s %19s %10s %5s %6s%n",
- "#Cluster Name",
- "#Broker Name",
- "#BID",
- "#Addr",
- "#Version",
- "#InTPS(LOAD)",
- "#OutTPS(LOAD)",
- "#PCWait(ms)",
- "#Hour",
- "#SPACE"
+ "#Cluster Name",
+ "#Broker Name",
+ "#BID",
+ "#Addr",
+ "#Version",
+ "#InTPS(LOAD)",
+ "#OutTPS(LOAD)",
+ "#PCWait(ms)",
+ "#Hour",
+ "#SPACE"
);
Iterator<Map.Entry<String, Set<String>>> itCluster = clusterInfoSerializeWrapper.getClusterAddrTable().entrySet().iterator();
@@ -254,16 +251,16 @@ public class ClusterListSubCommand implements SubCommand {
}
System.out.printf("%-16s %-22s %-4s %-22s %-16s %19s %19s %10s %5s %6s%n",
- clusterName,
- brokerName,
- next1.getKey().longValue(),
- next1.getValue(),
- version,
- String.format("%9.2f(%s,%sms)", in, sendThreadPoolQueueSize, sendThreadPoolQueueHeadWaitTimeMills),
- String.format("%9.2f(%s,%sms)", out, pullThreadPoolQueueSize, pullThreadPoolQueueHeadWaitTimeMills),
- pageCacheLockTimeMills,
- String.format("%2.2f", hour),
- String.format("%.4f", space)
+ clusterName,
+ brokerName,
+ next1.getKey().longValue(),
+ next1.getValue(),
+ version,
+ String.format("%9.2f(%s,%sms)", in, sendThreadPoolQueueSize, sendThreadPoolQueueHeadWaitTimeMills),
+ String.format("%9.2f(%s,%sms)", out, pullThreadPoolQueueSize, pullThreadPoolQueueHeadWaitTimeMills),
+ pageCacheLockTimeMills,
+ String.format("%2.2f", hour),
+ String.format("%.4f", space)
);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ConsumerConnectionSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ConsumerConnectionSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ConsumerConnectionSubCommand.java
index 355e894..7f7f88d 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ConsumerConnectionSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ConsumerConnectionSubCommand.java
@@ -16,6 +16,11 @@
*/
package org.apache.rocketmq.tools.command.connection;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.common.MQVersion;
import org.apache.rocketmq.common.protocol.body.Connection;
import org.apache.rocketmq.common.protocol.body.ConsumerConnection;
@@ -23,13 +28,6 @@ import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.Iterator;
-import java.util.Map.Entry;
-
public class ConsumerConnectionSubCommand implements SubCommand {
@@ -65,15 +63,14 @@ public class ConsumerConnectionSubCommand implements SubCommand {
ConsumerConnection cc = defaultMQAdminExt.examineConsumerConnectionInfo(group);
-
int i = 1;
for (Connection conn : cc.getConnectionSet()) {
System.out.printf("%03d %-32s %-22s %-8s %s%n",
- i++,
- conn.getClientId(),
- conn.getClientAddr(),
- conn.getLanguage(),
- MQVersion.getVersionDesc(conn.getVersion())
+ i++,
+ conn.getClientId(),
+ conn.getClientAddr(),
+ conn.getLanguage(),
+ MQVersion.getVersionDesc(conn.getVersion())
);
}
@@ -84,9 +81,9 @@ public class ConsumerConnectionSubCommand implements SubCommand {
Entry<String, SubscriptionData> entry = it.next();
SubscriptionData sd = entry.getValue();
System.out.printf("%03d Topic: %-40s SubExpression: %s%n",
- i++,
- sd.getTopic(),
- sd.getSubString()
+ i++,
+ sd.getTopic(),
+ sd.getSubString()
);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ProducerConnectionSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ProducerConnectionSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ProducerConnectionSubCommand.java
index 0b5b0ab..387c9c8 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ProducerConnectionSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/connection/ProducerConnectionSubCommand.java
@@ -16,16 +16,15 @@
*/
package org.apache.rocketmq.tools.command.connection;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.common.MQVersion;
import org.apache.rocketmq.common.protocol.body.Connection;
import org.apache.rocketmq.common.protocol.body.ProducerConnection;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
public class ProducerConnectionSubCommand implements SubCommand {
@@ -69,11 +68,11 @@ public class ProducerConnectionSubCommand implements SubCommand {
int i = 1;
for (Connection conn : pc.getConnectionSet()) {
System.out.printf("%04d %-32s %-22s %-8s %s%n",
- i++,
- conn.getClientId(),
- conn.getClientAddr(),
- conn.getLanguage(),
- MQVersion.getVersionDesc(conn.getVersion())
+ i++,
+ conn.getClientId(),
+ conn.getClientAddr(),
+ conn.getLanguage(),
+ MQVersion.getVersionDesc(conn.getVersion())
);
}
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
index 56e0853..3e70614 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
@@ -16,6 +16,13 @@
*/
package org.apache.rocketmq.tools.command.consumer;
+import java.util.Collections;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.client.log.ClientLogger;
import org.apache.rocketmq.common.MQVersion;
import org.apache.rocketmq.common.MixAll;
@@ -30,17 +37,8 @@ import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
import org.slf4j.Logger;
-import java.util.Collections;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-
-
public class ConsumerProgressSubCommand implements SubCommand {
private final Logger log = ClientLogger.getLog();
@@ -78,13 +76,13 @@ public class ConsumerProgressSubCommand implements SubCommand {
Collections.sort(mqList);
System.out.printf("%-32s %-32s %-4s %-20s %-20s %-20s %s%n",
- "#Topic",
- "#Broker Name",
- "#QID",
- "#Broker Offset",
- "#Consumer Offset",
- "#Diff",
- "#LastTime");
+ "#Topic",
+ "#Broker Name",
+ "#QID",
+ "#Broker Offset",
+ "#Consumer Offset",
+ "#Diff",
+ "#LastTime");
long diffTotal = 0L;
for (MessageQueue mq : mqList) {
@@ -97,13 +95,13 @@ public class ConsumerProgressSubCommand implements SubCommand {
} catch (Exception e) {
}
System.out.printf("%-32s %-32s %-4d %-20d %-20d %-20d %s%n",
- UtilAll.frontStringAtLeast(mq.getTopic(), 32),
- UtilAll.frontStringAtLeast(mq.getBrokerName(), 32),
- mq.getQueueId(),
- offsetWrapper.getBrokerOffset(),
- offsetWrapper.getConsumerOffset(),
- diff,
- lastTime
+ UtilAll.frontStringAtLeast(mq.getTopic(), 32),
+ UtilAll.frontStringAtLeast(mq.getBrokerName(), 32),
+ mq.getQueueId(),
+ offsetWrapper.getBrokerOffset(),
+ offsetWrapper.getConsumerOffset(),
+ diff,
+ lastTime
);
}
@@ -112,13 +110,13 @@ public class ConsumerProgressSubCommand implements SubCommand {
System.out.printf("Diff Total: %d%n", diffTotal);
} else {
System.out.printf("%-32s %-6s %-24s %-5s %-14s %-7s %s%n",
- "#Group",
- "#Count",
- "#Version",
- "#Type",
- "#Model",
- "#TPS",
- "#Diff Total"
+ "#Group",
+ "#Count",
+ "#Version",
+ "#Type",
+ "#Model",
+ "#TPS",
+ "#Diff Total"
);
TopicList topicList = defaultMQAdminExt.fetchAllTopicList();
for (String topic : topicList.getTopicList()) {
@@ -143,7 +141,7 @@ public class ConsumerProgressSubCommand implements SubCommand {
groupConsumeInfo.setGroup(consumerGroup);
if (consumeStats != null) {
- groupConsumeInfo.setConsumeTps((int) consumeStats.getConsumeTps());
+ groupConsumeInfo.setConsumeTps((int)consumeStats.getConsumeTps());
groupConsumeInfo.setDiffTotal(consumeStats.computeTotalDiff());
}
@@ -155,13 +153,13 @@ public class ConsumerProgressSubCommand implements SubCommand {
}
System.out.printf("%-32s %-6d %-24s %-5s %-14s %-7d %d%n",
- UtilAll.frontStringAtLeast(groupConsumeInfo.getGroup(), 32),
- groupConsumeInfo.getCount(),
- groupConsumeInfo.getCount() > 0 ? groupConsumeInfo.versionDesc() : "OFFLINE",
- groupConsumeInfo.consumeTypeDesc(),
- groupConsumeInfo.messageModelDesc(),
- groupConsumeInfo.getConsumeTps(),
- groupConsumeInfo.getDiffTotal()
+ UtilAll.frontStringAtLeast(groupConsumeInfo.getGroup(), 32),
+ groupConsumeInfo.getCount(),
+ groupConsumeInfo.getCount() > 0 ? groupConsumeInfo.versionDesc() : "OFFLINE",
+ groupConsumeInfo.consumeTypeDesc(),
+ groupConsumeInfo.messageModelDesc(),
+ groupConsumeInfo.getConsumeTps(),
+ groupConsumeInfo.getDiffTotal()
);
} catch (Exception e) {
log.warn("examineConsumeStats or examineConsumerConnectionInfo exception, " + consumerGroup, e);
@@ -177,7 +175,6 @@ public class ConsumerProgressSubCommand implements SubCommand {
}
}
-
class GroupConsumeInfo implements Comparable<GroupConsumeInfo> {
private String group;
private int version;
@@ -187,7 +184,6 @@ class GroupConsumeInfo implements Comparable<GroupConsumeInfo> {
private int consumeTps;
private long diffTotal;
-
public String getGroup() {
return group;
}
@@ -245,37 +241,31 @@ class GroupConsumeInfo implements Comparable<GroupConsumeInfo> {
return diffTotal;
}
-
public void setDiffTotal(long diffTotal) {
this.diffTotal = diffTotal;
}
-
@Override
public int compareTo(GroupConsumeInfo o) {
if (this.count != o.count) {
return o.count - this.count;
}
- return (int) (o.diffTotal - diffTotal);
+ return (int)(o.diffTotal - diffTotal);
}
-
public int getConsumeTps() {
return consumeTps;
}
-
public void setConsumeTps(int consumeTps) {
this.consumeTps = consumeTps;
}
-
public int getVersion() {
return version;
}
-
public void setVersion(int version) {
this.version = version;
}
[43/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerUtil.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerUtil.java b/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerUtil.java
new file mode 100644
index 0000000..1c40c0e
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerUtil.java
@@ -0,0 +1,43 @@
+/**
+ * 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.broker.filtersrv;
+
+import org.slf4j.Logger;
+
+
+public class FilterServerUtil {
+ public static void callShell(final String shellString, final Logger log) {
+ Process process = null;
+ try {
+ String[] cmdArray = splitShellString(shellString);
+ process = Runtime.getRuntime().exec(cmdArray);
+ process.waitFor();
+ log.info("callShell: <{}> OK", shellString);
+ } catch (Throwable e) {
+ log.error("callShell: readLine IOException, " + shellString, e);
+ } finally {
+ if (null != process)
+ process.destroy();
+ }
+ }
+
+ private static String[] splitShellString(final String shellString) {
+ String[] split = shellString.split(" ");
+ return split;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
new file mode 100644
index 0000000..57a451f
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFastFailure.java
@@ -0,0 +1,115 @@
+/**
+ * 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.broker.latency;
+
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.common.ThreadFactoryImpl;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.remoting.netty.RequestTask;
+import org.apache.rocketmq.remoting.protocol.RemotingSysResponseCode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class BrokerFastFailure {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+ private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl(
+ "BrokerFastFailureScheduledThread"));
+ private final BrokerController brokerController;
+
+ public BrokerFastFailure(final BrokerController brokerController) {
+ this.brokerController = brokerController;
+ }
+
+ public void start() {
+ this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
+ @Override
+ public void run() {
+ cleanExpiredRequest();
+ }
+ }, 1000, 10, TimeUnit.MILLISECONDS);
+ }
+
+ private void cleanExpiredRequest() {
+ while (this.brokerController.getMessageStore().isOSPageCacheBusy()) {
+ try {
+ if (!this.brokerController.getSendThreadPoolQueue().isEmpty()) {
+ final Runnable runnable = this.brokerController.getSendThreadPoolQueue().poll(0, TimeUnit.SECONDS);
+ if (null == runnable) {
+ break;
+ }
+
+ final RequestTask rt = castRunnable(runnable);
+ rt.returnResponse(RemotingSysResponseCode.SYSTEM_BUSY, String.format("[PCBUSY_CLEAN_QUEUE]broker busy, start flow control for a while, period in queue: %sms, size of queue: %d", System.currentTimeMillis() - rt.getCreateTimestamp(), this.brokerController.getSendThreadPoolQueue().size()));
+ } else {
+ break;
+ }
+ } catch (Throwable e) {
+ }
+ }
+
+ while (true) {
+ try {
+ if (!this.brokerController.getSendThreadPoolQueue().isEmpty()) {
+ final Runnable runnable = this.brokerController.getSendThreadPoolQueue().peek();
+ if (null == runnable) {
+ break;
+ }
+ final RequestTask rt = castRunnable(runnable);
+ if (rt.isStopRun()) {
+ break;
+ }
+
+ final long behind = System.currentTimeMillis() - rt.getCreateTimestamp();
+ if (behind >= this.brokerController.getBrokerConfig().getWaitTimeMillsInSendQueue()) {
+ if (this.brokerController.getSendThreadPoolQueue().remove(runnable)) {
+ rt.setStopRun(true);
+ rt.returnResponse(RemotingSysResponseCode.SYSTEM_BUSY, String.format("[TIMEOUT_CLEAN_QUEUE]broker busy, start flow control for a while, period in queue: %sms, size of queue: %d", behind, this.brokerController.getSendThreadPoolQueue().size()));
+ }
+ } else {
+ break;
+ }
+ } else {
+ break;
+ }
+ } catch (Throwable e) {
+ }
+ }
+ }
+
+ public static RequestTask castRunnable(final Runnable runnable) {
+ try {
+ FutureTaskExt object = (FutureTaskExt) runnable;
+ return (RequestTask) object.getRunnable();
+ } catch (Throwable e) {
+ log.error(String.format("castRunnable exception, %s", runnable.getClass().getName()), e);
+ }
+
+ return null;
+ }
+
+ public void shutdown() {
+ this.scheduledExecutorService.shutdown();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java
new file mode 100644
index 0000000..352543e
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/latency/BrokerFixedThreadPoolExecutor.java
@@ -0,0 +1,46 @@
+/**
+ * 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.broker.latency;
+
+import java.util.concurrent.*;
+
+/**
+ * @author shijia.wxr
+ */
+public class BrokerFixedThreadPoolExecutor extends ThreadPoolExecutor {
+ public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit, final BlockingQueue<Runnable> workQueue) {
+ super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
+ }
+
+ public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit, final BlockingQueue<Runnable> workQueue, final ThreadFactory threadFactory) {
+ super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory);
+ }
+
+ public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit, final BlockingQueue<Runnable> workQueue, final RejectedExecutionHandler handler) {
+ super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, handler);
+ }
+
+ public BrokerFixedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit, final BlockingQueue<Runnable> workQueue, final ThreadFactory threadFactory, final RejectedExecutionHandler handler) {
+ super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler);
+ }
+
+ @Override
+ protected <T> RunnableFuture<T> newTaskFor(final Runnable runnable, final T value) {
+ return new FutureTaskExt<T>(runnable, value);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/latency/FutureTaskExt.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/latency/FutureTaskExt.java b/broker/src/main/java/org/apache/rocketmq/broker/latency/FutureTaskExt.java
new file mode 100644
index 0000000..642cdd9
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/latency/FutureTaskExt.java
@@ -0,0 +1,42 @@
+/**
+ * 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.broker.latency;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.FutureTask;
+
+/**
+ * @author shijia.wxr
+ */
+public class FutureTaskExt<V> extends FutureTask<V> {
+ private final Runnable runnable;
+
+ public FutureTaskExt(final Callable<V> callable) {
+ super(callable);
+ this.runnable = null;
+ }
+
+ public FutureTaskExt(final Runnable runnable, final V result) {
+ super(runnable, result);
+ this.runnable = runnable;
+ }
+
+ public Runnable getRunnable() {
+ return runnable;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
new file mode 100644
index 0000000..7e9e40a
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/ManyPullRequest.java
@@ -0,0 +1,49 @@
+/**
+ * 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.broker.longpolling;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ManyPullRequest {
+ private final ArrayList<PullRequest> pullRequestList = new ArrayList<PullRequest>();
+
+
+ public synchronized void addPullRequest(final PullRequest pullRequest) {
+ this.pullRequestList.add(pullRequest);
+ }
+
+
+ public synchronized void addPullRequest(final List<PullRequest> many) {
+ this.pullRequestList.addAll(many);
+ }
+
+
+ public synchronized List<PullRequest> cloneListAndClear() {
+ if (!this.pullRequestList.isEmpty()) {
+ List<PullRequest> result = (ArrayList<PullRequest>) this.pullRequestList.clone();
+ this.pullRequestList.clear();
+ return result;
+ }
+
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/longpolling/NotifyMessageArrivingListener.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/NotifyMessageArrivingListener.java b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/NotifyMessageArrivingListener.java
new file mode 100644
index 0000000..f953c1e
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/NotifyMessageArrivingListener.java
@@ -0,0 +1,36 @@
+/**
+ * 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.broker.longpolling;
+
+import org.apache.rocketmq.store.MessageArrivingListener;
+
+
+public class NotifyMessageArrivingListener implements MessageArrivingListener {
+ private final PullRequestHoldService pullRequestHoldService;
+
+
+ public NotifyMessageArrivingListener(final PullRequestHoldService pullRequestHoldService) {
+ this.pullRequestHoldService = pullRequestHoldService;
+ }
+
+
+ @Override
+ public void arriving(String topic, int queueId, long logicOffset, long tagsCode) {
+ this.pullRequestHoldService.notifyMessageArriving(topic, queueId, logicOffset, tagsCode);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java
new file mode 100644
index 0000000..cf03b03
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequest.java
@@ -0,0 +1,74 @@
+/**
+ * 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.broker.longpolling;
+
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import io.netty.channel.Channel;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class PullRequest {
+ private final RemotingCommand requestCommand;
+ private final Channel clientChannel;
+ private final long timeoutMillis;
+ private final long suspendTimestamp;
+ private final long pullFromThisOffset;
+ private final SubscriptionData subscriptionData;
+
+
+ public PullRequest(RemotingCommand requestCommand, Channel clientChannel, long timeoutMillis, long suspendTimestamp,
+ long pullFromThisOffset, SubscriptionData subscriptionData) {
+ this.requestCommand = requestCommand;
+ this.clientChannel = clientChannel;
+ this.timeoutMillis = timeoutMillis;
+ this.suspendTimestamp = suspendTimestamp;
+ this.pullFromThisOffset = pullFromThisOffset;
+ this.subscriptionData = subscriptionData;
+ }
+
+
+ public RemotingCommand getRequestCommand() {
+ return requestCommand;
+ }
+
+
+ public Channel getClientChannel() {
+ return clientChannel;
+ }
+
+
+ public long getTimeoutMillis() {
+ return timeoutMillis;
+ }
+
+
+ public long getSuspendTimestamp() {
+ return suspendTimestamp;
+ }
+
+
+ public long getPullFromThisOffset() {
+ return pullFromThisOffset;
+ }
+
+ public SubscriptionData getSubscriptionData() {
+ return subscriptionData;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java
new file mode 100644
index 0000000..19a3f54
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java
@@ -0,0 +1,169 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.broker.longpolling;
+
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.common.ServiceThread;
+import org.apache.rocketmq.common.SystemClock;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.store.DefaultMessageFilter;
+import org.apache.rocketmq.store.MessageFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class PullRequestHoldService extends ServiceThread {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+ private static final String TOPIC_QUEUEID_SEPARATOR = "@";
+ private final BrokerController brokerController;
+ private final SystemClock systemClock = new SystemClock();
+ private final MessageFilter messageFilter = new DefaultMessageFilter();
+ private ConcurrentHashMap<String/* topic@queueId */, ManyPullRequest> pullRequestTable =
+ new ConcurrentHashMap<String, ManyPullRequest>(1024);
+
+
+ public PullRequestHoldService(final BrokerController brokerController) {
+ this.brokerController = brokerController;
+ }
+
+ public void suspendPullRequest(final String topic, final int queueId, final PullRequest pullRequest) {
+ String key = this.buildKey(topic, queueId);
+ ManyPullRequest mpr = this.pullRequestTable.get(key);
+ if (null == mpr) {
+ mpr = new ManyPullRequest();
+ ManyPullRequest prev = this.pullRequestTable.putIfAbsent(key, mpr);
+ if (prev != null) {
+ mpr = prev;
+ }
+ }
+
+ mpr.addPullRequest(pullRequest);
+ }
+
+ private String buildKey(final String topic, final int queueId) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(topic);
+ sb.append(TOPIC_QUEUEID_SEPARATOR);
+ sb.append(queueId);
+ return sb.toString();
+ }
+
+ @Override
+ public void run() {
+ log.info(this.getServiceName() + " service started");
+ while (!this.isStopped()) {
+ try {
+ if (this.brokerController.getBrokerConfig().isLongPollingEnable()) {
+ this.waitForRunning(5 * 1000);
+ } else {
+ this.waitForRunning(this.brokerController.getBrokerConfig().getShortPollingTimeMills());
+ }
+
+ long beginLockTimestamp = this.systemClock.now();
+ this.checkHoldRequest();
+ long costTime = this.systemClock.now() - beginLockTimestamp;
+ if (costTime > 5 * 1000) {
+ log.info("[NOTIFYME] check hold request cost {} ms.", costTime);
+ }
+ } catch (Throwable e) {
+ log.warn(this.getServiceName() + " service has exception. ", e);
+ }
+ }
+
+ log.info(this.getServiceName() + " service end");
+ }
+
+ @Override
+ public String getServiceName() {
+ return PullRequestHoldService.class.getSimpleName();
+ }
+
+ private void checkHoldRequest() {
+ for (String key : this.pullRequestTable.keySet()) {
+ String[] kArray = key.split(TOPIC_QUEUEID_SEPARATOR);
+ if (kArray != null && 2 == kArray.length) {
+ String topic = kArray[0];
+ int queueId = Integer.parseInt(kArray[1]);
+ final long offset = this.brokerController.getMessageStore().getMaxOffsetInQuque(topic, queueId);
+ try {
+ this.notifyMessageArriving(topic, queueId, offset);
+ } catch (Throwable e) {
+ log.error("check hold request failed. topic={}, queueId={}", topic, queueId, e);
+ }
+ }
+ }
+ }
+
+ public void notifyMessageArriving(final String topic, final int queueId, final long maxOffset) {
+ notifyMessageArriving(topic, queueId, maxOffset, null);
+ }
+
+ public void notifyMessageArriving(final String topic, final int queueId, final long maxOffset, final Long tagsCode) {
+ String key = this.buildKey(topic, queueId);
+ ManyPullRequest mpr = this.pullRequestTable.get(key);
+ if (mpr != null) {
+ List<PullRequest> requestList = mpr.cloneListAndClear();
+ if (requestList != null) {
+ List<PullRequest> replayList = new ArrayList<PullRequest>();
+
+ for (PullRequest request : requestList) {
+ long newestOffset = maxOffset;
+ if (newestOffset <= request.getPullFromThisOffset()) {
+ newestOffset = this.brokerController.getMessageStore().getMaxOffsetInQuque(topic, queueId);
+ }
+
+ Long tmp = tagsCode;
+ if (newestOffset > request.getPullFromThisOffset()) {
+ if (this.messageFilter.isMessageMatched(request.getSubscriptionData(), tmp)) {
+ try {
+ this.brokerController.getPullMessageProcessor().excuteRequestWhenWakeup(request.getClientChannel(),
+ request.getRequestCommand());
+ } catch (Throwable e) {
+ log.error("execute request when wakeup failed.", e);
+ }
+ continue;
+ }
+ }
+
+ if (System.currentTimeMillis() >= (request.getSuspendTimestamp() + request.getTimeoutMillis())) {
+ try {
+ this.brokerController.getPullMessageProcessor().excuteRequestWhenWakeup(request.getClientChannel(),
+ request.getRequestCommand());
+ } catch (Throwable e) {
+ log.error("execute request when wakeup failed.", e);
+ }
+ continue;
+ }
+
+
+ replayList.add(request);
+ }
+
+ if (!replayList.isEmpty()) {
+ mpr.addPullRequest(replayList);
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageContext.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageContext.java b/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageContext.java
new file mode 100644
index 0000000..3a167fa
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageContext.java
@@ -0,0 +1,172 @@
+/**
+ * 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.broker.mqtrace;
+
+import org.apache.rocketmq.store.stats.BrokerStatsManager;
+
+import java.util.Map;
+
+
+public class ConsumeMessageContext {
+ private String consumerGroup;
+ private String topic;
+ private Integer queueId;
+ private String clientHost;
+ private String storeHost;
+ private Map<String, Long> messageIds;
+ private int bodyLength;
+ private boolean success;
+ private String status;
+ private Object mqTraceContext;
+
+ private String commercialOwner;
+ private BrokerStatsManager.StatsType commercialRcvStats;
+ private int commercialRcvTimes;
+ private int commercialRcvSize;
+
+
+ public String getConsumerGroup() {
+ return consumerGroup;
+ }
+
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public Integer getQueueId() {
+ return queueId;
+ }
+
+
+ public void setQueueId(Integer queueId) {
+ this.queueId = queueId;
+ }
+
+
+ public String getClientHost() {
+ return clientHost;
+ }
+
+
+ public void setClientHost(String clientHost) {
+ this.clientHost = clientHost;
+ }
+
+
+ public String getStoreHost() {
+ return storeHost;
+ }
+
+
+ public void setStoreHost(String storeHost) {
+ this.storeHost = storeHost;
+ }
+
+
+ public Map<String, Long> getMessageIds() {
+ return messageIds;
+ }
+
+
+ public void setMessageIds(Map<String, Long> messageIds) {
+ this.messageIds = messageIds;
+ }
+
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+
+ public String getStatus() {
+ return status;
+ }
+
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+
+ public Object getMqTraceContext() {
+ return mqTraceContext;
+ }
+
+
+ public void setMqTraceContext(Object mqTraceContext) {
+ this.mqTraceContext = mqTraceContext;
+ }
+
+
+ public int getBodyLength() {
+ return bodyLength;
+ }
+
+
+ public void setBodyLength(int bodyLength) {
+ this.bodyLength = bodyLength;
+ }
+
+ public String getCommercialOwner() {
+ return commercialOwner;
+ }
+
+ public void setCommercialOwner(final String commercialOwner) {
+ this.commercialOwner = commercialOwner;
+ }
+
+ public BrokerStatsManager.StatsType getCommercialRcvStats() {
+ return commercialRcvStats;
+ }
+
+ public void setCommercialRcvStats(final BrokerStatsManager.StatsType commercialRcvStats) {
+ this.commercialRcvStats = commercialRcvStats;
+ }
+
+ public int getCommercialRcvTimes() {
+ return commercialRcvTimes;
+ }
+
+ public void setCommercialRcvTimes(final int commercialRcvTimes) {
+ this.commercialRcvTimes = commercialRcvTimes;
+ }
+
+ public int getCommercialRcvSize() {
+ return commercialRcvSize;
+ }
+
+ public void setCommercialRcvSize(final int commercialRcvSize) {
+ this.commercialRcvSize = commercialRcvSize;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageHook.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageHook.java b/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageHook.java
new file mode 100644
index 0000000..c4b7f36
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/ConsumeMessageHook.java
@@ -0,0 +1,27 @@
+/**
+ * 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.broker.mqtrace;
+
+public interface ConsumeMessageHook {
+ String hookName();
+
+
+ void consumeMessageBefore(final ConsumeMessageContext context);
+
+
+ void consumeMessageAfter(final ConsumeMessageContext context);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageContext.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageContext.java b/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageContext.java
new file mode 100644
index 0000000..ca8121d
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageContext.java
@@ -0,0 +1,261 @@
+/**
+ * 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.broker.mqtrace;
+
+import org.apache.rocketmq.common.message.MessageType;
+import org.apache.rocketmq.store.stats.BrokerStatsManager;
+
+import java.util.Properties;
+
+
+public class SendMessageContext {
+ private String producerGroup;
+ private String topic;
+ private String msgId;
+ private String originMsgId;
+ private Integer queueId;
+ private Long queueOffset;
+ private String brokerAddr;
+ private String bornHost;
+ private int bodyLength;
+ private int code;
+ private String errorMsg;
+ private String msgProps;
+ private Object mqTraceContext;
+ private Properties extProps;
+ private String brokerRegionId;
+ private String msgUniqueKey;
+ private long bornTimeStamp;
+ private MessageType msgType = MessageType.Trans_msg_Commit;
+ private boolean isSuccess = false;
+ //For Commercial
+ private String commercialOwner;
+ private BrokerStatsManager.StatsType commercialSendStats;
+ private int commercialSendSize;
+ private int commercialSendTimes;
+
+ public boolean isSuccess() {
+ return isSuccess;
+ }
+
+ public void setSuccess(final boolean success) {
+ isSuccess = success;
+ }
+
+ public MessageType getMsgType() {
+ return msgType;
+ }
+
+ public void setMsgType(final MessageType msgType) {
+ this.msgType = msgType;
+ }
+
+ public String getMsgUniqueKey() {
+ return msgUniqueKey;
+ }
+
+ public void setMsgUniqueKey(final String msgUniqueKey) {
+ this.msgUniqueKey = msgUniqueKey;
+ }
+
+ public long getBornTimeStamp() {
+ return bornTimeStamp;
+ }
+
+ public void setBornTimeStamp(final long bornTimeStamp) {
+ this.bornTimeStamp = bornTimeStamp;
+ }
+
+ public String getBrokerRegionId() {
+ return brokerRegionId;
+ }
+
+ public void setBrokerRegionId(final String brokerRegionId) {
+ this.brokerRegionId = brokerRegionId;
+ }
+
+ public String getProducerGroup() {
+ return producerGroup;
+ }
+
+
+ public void setProducerGroup(String producerGroup) {
+ this.producerGroup = producerGroup;
+ }
+
+
+ public String getTopic() {
+ return topic;
+ }
+
+
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+
+ public String getMsgId() {
+ return msgId;
+ }
+
+
+ public void setMsgId(String msgId) {
+ this.msgId = msgId;
+ }
+
+
+ public String getOriginMsgId() {
+ return originMsgId;
+ }
+
+
+ public void setOriginMsgId(String originMsgId) {
+ this.originMsgId = originMsgId;
+ }
+
+
+ public Integer getQueueId() {
+ return queueId;
+ }
+
+
+ public void setQueueId(Integer queueId) {
+ this.queueId = queueId;
+ }
+
+
+ public Long getQueueOffset() {
+ return queueOffset;
+ }
+
+
+ public void setQueueOffset(Long queueOffset) {
+ this.queueOffset = queueOffset;
+ }
+
+
+ public String getBrokerAddr() {
+ return brokerAddr;
+ }
+
+
+ public void setBrokerAddr(String brokerAddr) {
+ this.brokerAddr = brokerAddr;
+ }
+
+
+ public String getBornHost() {
+ return bornHost;
+ }
+
+
+ public void setBornHost(String bornHost) {
+ this.bornHost = bornHost;
+ }
+
+
+ public int getBodyLength() {
+ return bodyLength;
+ }
+
+
+ public void setBodyLength(int bodyLength) {
+ this.bodyLength = bodyLength;
+ }
+
+
+ public int getCode() {
+ return code;
+ }
+
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+
+ public String getErrorMsg() {
+ return errorMsg;
+ }
+
+
+ public void setErrorMsg(String errorMsg) {
+ this.errorMsg = errorMsg;
+ }
+
+
+ public String getMsgProps() {
+ return msgProps;
+ }
+
+
+ public void setMsgProps(String msgProps) {
+ this.msgProps = msgProps;
+ }
+
+
+ public Object getMqTraceContext() {
+ return mqTraceContext;
+ }
+
+
+ public void setMqTraceContext(Object mqTraceContext) {
+ this.mqTraceContext = mqTraceContext;
+ }
+
+
+ public Properties getExtProps() {
+ return extProps;
+ }
+
+
+ public void setExtProps(Properties extProps) {
+ this.extProps = extProps;
+ }
+
+ public String getCommercialOwner() {
+ return commercialOwner;
+ }
+
+ public void setCommercialOwner(final String commercialOwner) {
+ this.commercialOwner = commercialOwner;
+ }
+
+ public BrokerStatsManager.StatsType getCommercialSendStats() {
+ return commercialSendStats;
+ }
+
+ public void setCommercialSendStats(final BrokerStatsManager.StatsType commercialSendStats) {
+ this.commercialSendStats = commercialSendStats;
+ }
+
+ public int getCommercialSendSize() {
+ return commercialSendSize;
+ }
+
+ public void setCommercialSendSize(final int commercialSendSize) {
+ this.commercialSendSize = commercialSendSize;
+ }
+
+ public int getCommercialSendTimes() {
+ return commercialSendTimes;
+ }
+
+ public void setCommercialSendTimes(final int commercialSendTimes) {
+ this.commercialSendTimes = commercialSendTimes;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageHook.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageHook.java b/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageHook.java
new file mode 100644
index 0000000..84cbdcb
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/mqtrace/SendMessageHook.java
@@ -0,0 +1,27 @@
+/**
+ * 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.broker.mqtrace;
+
+public interface SendMessageHook {
+ public String hookName();
+
+
+ public void sendMessageBefore(final SendMessageContext context);
+
+
+ public void sendMessageAfter(final SendMessageContext context);
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java b/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
new file mode 100644
index 0000000..8a1773a
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
@@ -0,0 +1,249 @@
+/**
+ * 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.broker.offset;
+
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.broker.BrokerPathConfigHelper;
+import org.apache.rocketmq.common.ConfigManager;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ConsumerOffsetManager extends ConfigManager {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+ private static final String TOPIC_GROUP_SEPARATOR = "@";
+
+ private ConcurrentHashMap<String/* topic@group */, ConcurrentHashMap<Integer, Long>> offsetTable =
+ new ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>>(512);
+
+ private transient BrokerController brokerController;
+
+
+ public ConsumerOffsetManager() {
+ }
+
+
+ public ConsumerOffsetManager(BrokerController brokerController) {
+ this.brokerController = brokerController;
+ }
+
+
+ public void scanUnsubscribedTopic() {
+ Iterator<Entry<String, ConcurrentHashMap<Integer, Long>>> it = this.offsetTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, ConcurrentHashMap<Integer, Long>> next = it.next();
+ String topicAtGroup = next.getKey();
+ String[] arrays = topicAtGroup.split(TOPIC_GROUP_SEPARATOR);
+ if (arrays != null && arrays.length == 2) {
+ String topic = arrays[0];
+ String group = arrays[1];
+
+ if (null == brokerController.getConsumerManager().findSubscriptionData(group, topic)
+ && this.offsetBehindMuchThanData(topic, next.getValue())) {
+ it.remove();
+ log.warn("remove topic offset, {}", topicAtGroup);
+ }
+ }
+ }
+ }
+
+
+ private boolean offsetBehindMuchThanData(final String topic, ConcurrentHashMap<Integer, Long> table) {
+ Iterator<Entry<Integer, Long>> it = table.entrySet().iterator();
+ boolean result = !table.isEmpty();
+
+ while (it.hasNext() && result) {
+ Entry<Integer, Long> next = it.next();
+ long minOffsetInStore = this.brokerController.getMessageStore().getMinOffsetInQuque(topic, next.getKey());
+ long offsetInPersist = next.getValue();
+ if (offsetInPersist > minOffsetInStore) {
+ result = false;
+ } else {
+ result = true;
+ }
+ }
+
+ return result;
+ }
+
+
+ public Set<String> whichTopicByConsumer(final String group) {
+ Set<String> topics = new HashSet<String>();
+
+ Iterator<Entry<String, ConcurrentHashMap<Integer, Long>>> it = this.offsetTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, ConcurrentHashMap<Integer, Long>> next = it.next();
+ String topicAtGroup = next.getKey();
+ String[] arrays = topicAtGroup.split(TOPIC_GROUP_SEPARATOR);
+ if (arrays != null && arrays.length == 2) {
+ if (group.equals(arrays[1])) {
+ topics.add(arrays[0]);
+ }
+ }
+ }
+
+ return topics;
+ }
+
+
+ public Set<String> whichGroupByTopic(final String topic) {
+ Set<String> groups = new HashSet<String>();
+
+ Iterator<Entry<String, ConcurrentHashMap<Integer, Long>>> it = this.offsetTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<String, ConcurrentHashMap<Integer, Long>> next = it.next();
+ String topicAtGroup = next.getKey();
+ String[] arrays = topicAtGroup.split(TOPIC_GROUP_SEPARATOR);
+ if (arrays != null && arrays.length == 2) {
+ if (topic.equals(arrays[0])) {
+ groups.add(arrays[1]);
+ }
+ }
+ }
+
+ return groups;
+ }
+
+
+ public void commitOffset(final String clientHost, final String group, final String topic, final int queueId, final long offset) {
+ // topic@group
+ String key = topic + TOPIC_GROUP_SEPARATOR + group;
+ this.commitOffset(clientHost, key, queueId, offset);
+ }
+
+ private void commitOffset(final String clientHost, final String key, final int queueId, final long offset) {
+ ConcurrentHashMap<Integer, Long> map = this.offsetTable.get(key);
+ if (null == map) {
+ map = new ConcurrentHashMap<Integer, Long>(32);
+ map.put(queueId, offset);
+ this.offsetTable.put(key, map);
+ } else {
+ Long storeOffset = map.put(queueId, offset);
+ if (storeOffset != null && offset < storeOffset) {
+ log.warn("[NOTIFYME]update consumer offset less than store. clientHost={}, key={}, queueId={}, requestOffset={}, storeOffset={}", clientHost, key, queueId, offset, storeOffset);
+ }
+ }
+ }
+
+ public long queryOffset(final String group, final String topic, final int queueId) {
+ // topic@group
+ String key = topic + TOPIC_GROUP_SEPARATOR + group;
+ ConcurrentHashMap<Integer, Long> map = this.offsetTable.get(key);
+ if (null != map) {
+ Long offset = map.get(queueId);
+ if (offset != null)
+ return offset;
+ }
+
+ return -1;
+ }
+
+ public String encode() {
+ return this.encode(false);
+ }
+
+ @Override
+ public String configFilePath() {
+ return BrokerPathConfigHelper.getConsumerOffsetPath(this.brokerController.getMessageStoreConfig().getStorePathRootDir());
+ }
+
+ @Override
+ public void decode(String jsonString) {
+ if (jsonString != null) {
+ ConsumerOffsetManager obj = RemotingSerializable.fromJson(jsonString, ConsumerOffsetManager.class);
+ if (obj != null) {
+ this.offsetTable = obj.offsetTable;
+ }
+ }
+ }
+
+ public String encode(final boolean prettyFormat) {
+ return RemotingSerializable.toJson(this, prettyFormat);
+ }
+
+ public ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>> getOffsetTable() {
+ return offsetTable;
+ }
+
+
+ public void setOffsetTable(ConcurrentHashMap<String, ConcurrentHashMap<Integer, Long>> offsetTable) {
+ this.offsetTable = offsetTable;
+ }
+
+
+ public Map<Integer, Long> queryMinOffsetInAllGroup(final String topic, final String filterGroups) {
+
+ Map<Integer, Long> queueMinOffset = new HashMap<Integer, Long>();
+ Set<String> topicGroups = this.offsetTable.keySet();
+ if (!UtilAll.isBlank(filterGroups)) {
+ for (String group : filterGroups.split(",")) {
+ Iterator<String> it = topicGroups.iterator();
+ while (it.hasNext()) {
+ if (group.equals(it.next().split(TOPIC_GROUP_SEPARATOR)[1])) {
+ it.remove();
+ }
+ }
+ }
+ }
+
+ for (Map.Entry<String, ConcurrentHashMap<Integer, Long>> offSetEntry : this.offsetTable.entrySet()) {
+ String topicGroup = offSetEntry.getKey();
+ String[] topicGroupArr = topicGroup.split(TOPIC_GROUP_SEPARATOR);
+ if (topic.equals(topicGroupArr[0])) {
+ for (Entry<Integer, Long> entry : offSetEntry.getValue().entrySet()) {
+ long minOffset = this.brokerController.getMessageStore().getMinOffsetInQuque(topic, entry.getKey());
+ if (entry.getValue() >= minOffset) {
+ Long offset = queueMinOffset.get(entry.getKey());
+ if (offset == null) {
+ queueMinOffset.put(entry.getKey(), Math.min(Long.MAX_VALUE, entry.getValue()));
+ } else {
+ queueMinOffset.put(entry.getKey(), Math.min(entry.getValue(), offset));
+ }
+ }
+ }
+ }
+
+ }
+ return queueMinOffset;
+ }
+
+
+ public Map<Integer, Long> queryOffset(final String group, final String topic) {
+ // topic@group
+ String key = topic + TOPIC_GROUP_SEPARATOR + group;
+ return this.offsetTable.get(key);
+ }
+
+
+ public void cloneOffset(final String srcGroup, final String destGroup, final String topic) {
+ ConcurrentHashMap<Integer, Long> offsets = this.offsetTable.get(topic + TOPIC_GROUP_SEPARATOR + srcGroup);
+ if (offsets != null) {
+ this.offsetTable.put(topic + TOPIC_GROUP_SEPARATOR + destGroup, new ConcurrentHashMap<Integer, Long>(offsets));
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java b/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
new file mode 100644
index 0000000..2836c4c
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
@@ -0,0 +1,302 @@
+/**
+ * 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.broker.out;
+
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.namesrv.RegisterBrokerResult;
+import org.apache.rocketmq.common.namesrv.TopAddressing;
+import org.apache.rocketmq.common.protocol.RequestCode;
+import org.apache.rocketmq.common.protocol.ResponseCode;
+import org.apache.rocketmq.common.protocol.body.*;
+import org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerRequestHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerResponseHeader;
+import org.apache.rocketmq.common.protocol.header.namesrv.UnRegisterBrokerRequestHeader;
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.remoting.RemotingClient;
+import org.apache.rocketmq.remoting.exception.*;
+import org.apache.rocketmq.remoting.netty.NettyClientConfig;
+import org.apache.rocketmq.remoting.netty.NettyRemotingClient;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ * @author manhong.yqd
+ */
+public class BrokerOuterAPI {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+ private final RemotingClient remotingClient;
+ private final TopAddressing topAddressing = new TopAddressing(MixAll.WS_ADDR);
+ private String nameSrvAddr = null;
+
+ public BrokerOuterAPI(final NettyClientConfig nettyClientConfig) {
+ this(nettyClientConfig, null);
+ }
+
+ public BrokerOuterAPI(final NettyClientConfig nettyClientConfig, RPCHook rpcHook) {
+ this.remotingClient = new NettyRemotingClient(nettyClientConfig);
+ this.remotingClient.registerRPCHook(rpcHook);
+ }
+
+ public void start() {
+ this.remotingClient.start();
+ }
+
+ public void shutdown() {
+ this.remotingClient.shutdown();
+ }
+
+ public String fetchNameServerAddr() {
+ try {
+ String addrs = this.topAddressing.fetchNSAddr();
+ if (addrs != null) {
+ if (!addrs.equals(this.nameSrvAddr)) {
+ log.info("name server address changed, old: " + this.nameSrvAddr + " new: " + addrs);
+ this.updateNameServerAddressList(addrs);
+ this.nameSrvAddr = addrs;
+ return nameSrvAddr;
+ }
+ }
+ } catch (Exception e) {
+ log.error("fetchNameServerAddr Exception", e);
+ }
+ return nameSrvAddr;
+ }
+
+ public void updateNameServerAddressList(final String addrs) {
+ List<String> lst = new ArrayList<String>();
+ String[] addrArray = addrs.split(";");
+ if (addrArray != null) {
+ for (String addr : addrArray) {
+ lst.add(addr);
+ }
+
+ this.remotingClient.updateNameServerAddressList(lst);
+ }
+ }
+
+ public RegisterBrokerResult registerBrokerAll(
+ final String clusterName,
+ final String brokerAddr,
+ final String brokerName,
+ final long brokerId,
+ final String haServerAddr,
+ final TopicConfigSerializeWrapper topicConfigWrapper,
+ final List<String> filterServerList,
+ final boolean oneway,
+ final int timeoutMills) {
+ RegisterBrokerResult registerBrokerResult = null;
+
+ List<String> nameServerAddressList = this.remotingClient.getNameServerAddressList();
+ if (nameServerAddressList != null) {
+ for (String namesrvAddr : nameServerAddressList) {
+ try {
+ RegisterBrokerResult result = this.registerBroker(namesrvAddr, clusterName, brokerAddr, brokerName, brokerId,
+ haServerAddr, topicConfigWrapper, filterServerList, oneway, timeoutMills);
+ if (result != null) {
+ registerBrokerResult = result;
+ }
+
+ log.info("register broker to name server {} OK", namesrvAddr);
+ } catch (Exception e) {
+ log.warn("registerBroker Exception, " + namesrvAddr, e);
+ }
+ }
+ }
+
+ return registerBrokerResult;
+ }
+
+ private RegisterBrokerResult registerBroker(
+ final String namesrvAddr,
+ final String clusterName,
+ final String brokerAddr,
+ final String brokerName,
+ final long brokerId,
+ final String haServerAddr,
+ final TopicConfigSerializeWrapper topicConfigWrapper,
+ final List<String> filterServerList,
+ final boolean oneway,
+ final int timeoutMills
+ ) throws RemotingCommandException, MQBrokerException, RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException,
+ InterruptedException {
+ RegisterBrokerRequestHeader requestHeader = new RegisterBrokerRequestHeader();
+ requestHeader.setBrokerAddr(brokerAddr);
+ requestHeader.setBrokerId(brokerId);
+ requestHeader.setBrokerName(brokerName);
+ requestHeader.setClusterName(clusterName);
+ requestHeader.setHaServerAddr(haServerAddr);
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.REGISTER_BROKER, requestHeader);
+
+ RegisterBrokerBody requestBody = new RegisterBrokerBody();
+ requestBody.setTopicConfigSerializeWrapper(topicConfigWrapper);
+ requestBody.setFilterServerList(filterServerList);
+ request.setBody(requestBody.encode());
+
+ if (oneway) {
+ try {
+ this.remotingClient.invokeOneway(namesrvAddr, request, timeoutMills);
+ } catch (RemotingTooMuchRequestException e) {
+ }
+ return null;
+ }
+
+ RemotingCommand response = this.remotingClient.invokeSync(namesrvAddr, request, timeoutMills);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ RegisterBrokerResponseHeader responseHeader =
+ (RegisterBrokerResponseHeader) response.decodeCommandCustomHeader(RegisterBrokerResponseHeader.class);
+ RegisterBrokerResult result = new RegisterBrokerResult();
+ result.setMasterAddr(responseHeader.getMasterAddr());
+ result.setHaServerAddr(responseHeader.getHaServerAddr());
+ result.setHaServerAddr(responseHeader.getHaServerAddr());
+ if (response.getBody() != null) {
+ result.setKvTable(KVTable.decode(response.getBody(), KVTable.class));
+ }
+ return result;
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+ public void unregisterBrokerAll(
+ final String clusterName,
+ final String brokerAddr,
+ final String brokerName,
+ final long brokerId
+ ) {
+ List<String> nameServerAddressList = this.remotingClient.getNameServerAddressList();
+ if (nameServerAddressList != null) {
+ for (String namesrvAddr : nameServerAddressList) {
+ try {
+ this.unregisterBroker(namesrvAddr, clusterName, brokerAddr, brokerName, brokerId);
+ log.info("unregisterBroker OK, NamesrvAddr: {}", namesrvAddr);
+ } catch (Exception e) {
+ log.warn("unregisterBroker Exception, " + namesrvAddr, e);
+ }
+ }
+ }
+ }
+
+ public void unregisterBroker(
+ final String namesrvAddr,
+ final String clusterName,
+ final String brokerAddr,
+ final String brokerName,
+ final long brokerId
+ ) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException {
+ UnRegisterBrokerRequestHeader requestHeader = new UnRegisterBrokerRequestHeader();
+ requestHeader.setBrokerAddr(brokerAddr);
+ requestHeader.setBrokerId(brokerId);
+ requestHeader.setBrokerName(brokerName);
+ requestHeader.setClusterName(clusterName);
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UNREGISTER_BROKER, requestHeader);
+
+ RemotingCommand response = this.remotingClient.invokeSync(namesrvAddr, request, 3000);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return;
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+ public TopicConfigSerializeWrapper getAllTopicConfig(final String addr) throws RemotingConnectException, RemotingSendRequestException,
+ RemotingTimeoutException, InterruptedException, MQBrokerException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_TOPIC_CONFIG, null);
+
+ RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(true, addr), request, 3000);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return TopicConfigSerializeWrapper.decode(response.getBody(), TopicConfigSerializeWrapper.class);
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+ public ConsumerOffsetSerializeWrapper getAllConsumerOffset(final String addr) throws InterruptedException, RemotingTimeoutException,
+ RemotingSendRequestException, RemotingConnectException, MQBrokerException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_CONSUMER_OFFSET, null);
+ RemotingCommand response = this.remotingClient.invokeSync(addr, request, 3000);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return ConsumerOffsetSerializeWrapper.decode(response.getBody(), ConsumerOffsetSerializeWrapper.class);
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+ public String getAllDelayOffset(final String addr) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException,
+ RemotingConnectException, MQBrokerException, UnsupportedEncodingException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_DELAY_OFFSET, null);
+ RemotingCommand response = this.remotingClient.invokeSync(addr, request, 3000);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return new String(response.getBody(), MixAll.DEFAULT_CHARSET);
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+ public SubscriptionGroupWrapper getAllSubscriptionGroupConfig(final String addr) throws InterruptedException, RemotingTimeoutException,
+ RemotingSendRequestException, RemotingConnectException, MQBrokerException {
+ RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_ALL_SUBSCRIPTIONGROUP_CONFIG, null);
+ RemotingCommand response = this.remotingClient.invokeSync(addr, request, 3000);
+ assert response != null;
+ switch (response.getCode()) {
+ case ResponseCode.SUCCESS: {
+ return SubscriptionGroupWrapper.decode(response.getBody(), SubscriptionGroupWrapper.class);
+ }
+ default:
+ break;
+ }
+
+ throw new MQBrokerException(response.getCode(), response.getRemark());
+ }
+
+ public void registerRPCHook(RPCHook rpcHook) {
+ remotingClient.registerRPCHook(rpcHook);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java
new file mode 100644
index 0000000..d26eab8
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/ManyMessageTransfer.java
@@ -0,0 +1,90 @@
+/**
+ * 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.broker.pagecache;
+
+import org.apache.rocketmq.store.GetMessageResult;
+import io.netty.channel.FileRegion;
+import io.netty.util.AbstractReferenceCounted;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.WritableByteChannel;
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class ManyMessageTransfer extends AbstractReferenceCounted implements FileRegion {
+ private final ByteBuffer byteBufferHeader;
+ private final GetMessageResult getMessageResult;
+ private long transfered; // the bytes which was transfered already
+
+
+ public ManyMessageTransfer(ByteBuffer byteBufferHeader, GetMessageResult getMessageResult) {
+ this.byteBufferHeader = byteBufferHeader;
+ this.getMessageResult = getMessageResult;
+ }
+
+
+ @Override
+ public long position() {
+ int pos = byteBufferHeader.position();
+ List<ByteBuffer> messageBufferList = this.getMessageResult.getMessageBufferList();
+ for (ByteBuffer bb : messageBufferList) {
+ pos += bb.position();
+ }
+ return pos;
+ }
+
+ @Override
+ public long transfered() {
+ return transfered;
+ }
+
+ @Override
+ public long count() {
+ return byteBufferHeader.limit() + this.getMessageResult.getBufferTotalSize();
+ }
+
+ @Override
+ public long transferTo(WritableByteChannel target, long position) throws IOException {
+ if (this.byteBufferHeader.hasRemaining()) {
+ transfered += target.write(this.byteBufferHeader);
+ return transfered;
+ } else {
+ List<ByteBuffer> messageBufferList = this.getMessageResult.getMessageBufferList();
+ for (ByteBuffer bb : messageBufferList) {
+ if (bb.hasRemaining()) {
+ transfered += target.write(bb);
+ return transfered;
+ }
+ }
+ }
+
+ return 0;
+ }
+
+ public void close() {
+ this.deallocate();
+ }
+
+ @Override
+ protected void deallocate() {
+ this.getMessageResult.release();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java
new file mode 100644
index 0000000..97d1faa
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/OneMessageTransfer.java
@@ -0,0 +1,79 @@
+/**
+ * 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.broker.pagecache;
+
+import org.apache.rocketmq.store.SelectMappedBufferResult;
+import io.netty.channel.FileRegion;
+import io.netty.util.AbstractReferenceCounted;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.WritableByteChannel;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class OneMessageTransfer extends AbstractReferenceCounted implements FileRegion {
+ private final ByteBuffer byteBufferHeader;
+ private final SelectMappedBufferResult selectMappedBufferResult;
+ private long transfered; // the bytes which was transfered already
+
+
+ public OneMessageTransfer(ByteBuffer byteBufferHeader, SelectMappedBufferResult selectMappedBufferResult) {
+ this.byteBufferHeader = byteBufferHeader;
+ this.selectMappedBufferResult = selectMappedBufferResult;
+ }
+
+
+ @Override
+ public long position() {
+ return this.byteBufferHeader.position() + this.selectMappedBufferResult.getByteBuffer().position();
+ }
+
+ @Override
+ public long transfered() {
+ return transfered;
+ }
+
+ @Override
+ public long count() {
+ return this.byteBufferHeader.limit() + this.selectMappedBufferResult.getSize();
+ }
+
+ @Override
+ public long transferTo(WritableByteChannel target, long position) throws IOException {
+ if (this.byteBufferHeader.hasRemaining()) {
+ transfered += target.write(this.byteBufferHeader);
+ return transfered;
+ } else if (this.selectMappedBufferResult.getByteBuffer().hasRemaining()) {
+ transfered += target.write(this.selectMappedBufferResult.getByteBuffer());
+ return transfered;
+ }
+
+ return 0;
+ }
+
+ public void close() {
+ this.deallocate();
+ }
+
+ @Override
+ protected void deallocate() {
+ this.selectMappedBufferResult.release();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java
new file mode 100644
index 0000000..2d21c19
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/pagecache/QueryMessageTransfer.java
@@ -0,0 +1,90 @@
+/**
+ * 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.broker.pagecache;
+
+import org.apache.rocketmq.store.QueryMessageResult;
+import io.netty.channel.FileRegion;
+import io.netty.util.AbstractReferenceCounted;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.WritableByteChannel;
+import java.util.List;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class QueryMessageTransfer extends AbstractReferenceCounted implements FileRegion {
+ private final ByteBuffer byteBufferHeader;
+ private final QueryMessageResult queryMessageResult;
+ private long transfered; // the bytes which was transfered already
+
+
+ public QueryMessageTransfer(ByteBuffer byteBufferHeader, QueryMessageResult queryMessageResult) {
+ this.byteBufferHeader = byteBufferHeader;
+ this.queryMessageResult = queryMessageResult;
+ }
+
+
+ @Override
+ public long position() {
+ int pos = byteBufferHeader.position();
+ List<ByteBuffer> messageBufferList = this.queryMessageResult.getMessageBufferList();
+ for (ByteBuffer bb : messageBufferList) {
+ pos += bb.position();
+ }
+ return pos;
+ }
+
+ @Override
+ public long transfered() {
+ return transfered;
+ }
+
+ @Override
+ public long count() {
+ return byteBufferHeader.limit() + this.queryMessageResult.getBufferTotalSize();
+ }
+
+ @Override
+ public long transferTo(WritableByteChannel target, long position) throws IOException {
+ if (this.byteBufferHeader.hasRemaining()) {
+ transfered += target.write(this.byteBufferHeader);
+ return transfered;
+ } else {
+ List<ByteBuffer> messageBufferList = this.queryMessageResult.getMessageBufferList();
+ for (ByteBuffer bb : messageBufferList) {
+ if (bb.hasRemaining()) {
+ transfered += target.write(bb);
+ return transfered;
+ }
+ }
+ }
+
+ return 0;
+ }
+
+ public void close() {
+ this.deallocate();
+ }
+
+ @Override
+ protected void deallocate() {
+ this.queryMessageResult.release();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/plugin/AbstractPluginMessageStore.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/plugin/AbstractPluginMessageStore.java b/broker/src/main/java/org/apache/rocketmq/broker/plugin/AbstractPluginMessageStore.java
new file mode 100644
index 0000000..601e2f3
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/plugin/AbstractPluginMessageStore.java
@@ -0,0 +1,236 @@
+/**
+ * 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.broker.plugin;
+
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
+import org.apache.rocketmq.store.*;
+
+import java.util.HashMap;
+import java.util.Set;
+
+public abstract class AbstractPluginMessageStore implements MessageStore {
+ protected MessageStore next = null;
+ protected MessageStorePluginContext context;
+
+ public AbstractPluginMessageStore(MessageStorePluginContext context, MessageStore next) {
+ this.next = next;
+ this.context = context;
+ }
+
+ @Override
+ public long getEarliestMessageTime() {
+ return next.getEarliestMessageTime();
+ }
+
+ @Override
+ public long lockTimeMills() {
+ return next.lockTimeMills();
+ }
+
+ @Override
+ public boolean isOSPageCacheBusy() {
+ return next.isOSPageCacheBusy();
+ }
+
+ @Override
+ public boolean isTransientStorePoolDeficient() {
+ return next.isTransientStorePoolDeficient();
+ }
+
+ @Override
+ public boolean load() {
+ return next.load();
+ }
+
+ @Override
+ public void start() throws Exception {
+ next.start();
+ }
+
+ @Override
+ public void shutdown() {
+ next.shutdown();
+ }
+
+ @Override
+ public void destroy() {
+ next.destroy();
+ }
+
+ @Override
+ public PutMessageResult putMessage(MessageExtBrokerInner msg) {
+ return next.putMessage(msg);
+ }
+
+ @Override
+ public GetMessageResult getMessage(String group, String topic, int queueId, long offset,
+ int maxMsgNums, SubscriptionData subscriptionData) {
+ return next.getMessage(group, topic, queueId, offset, maxMsgNums, subscriptionData);
+ }
+
+ @Override
+ public long getMaxOffsetInQuque(String topic, int queueId) {
+ return next.getMaxOffsetInQuque(topic, queueId);
+ }
+
+ @Override
+ public long getMinOffsetInQuque(String topic, int queueId) {
+ return next.getMinOffsetInQuque(topic, queueId);
+ }
+
+ @Override
+ public long getCommitLogOffsetInQueue(String topic, int queueId, long cqOffset) {
+ return next.getCommitLogOffsetInQueue(topic, queueId, cqOffset);
+ }
+
+ @Override
+ public long getOffsetInQueueByTime(String topic, int queueId, long timestamp) {
+ return next.getOffsetInQueueByTime(topic, queueId, timestamp);
+ }
+
+ @Override
+ public MessageExt lookMessageByOffset(long commitLogOffset) {
+ return next.lookMessageByOffset(commitLogOffset);
+ }
+
+ @Override
+ public SelectMappedBufferResult selectOneMessageByOffset(long commitLogOffset) {
+ return next.selectOneMessageByOffset(commitLogOffset);
+ }
+
+ @Override
+ public SelectMappedBufferResult selectOneMessageByOffset(long commitLogOffset, int msgSize) {
+ return next.selectOneMessageByOffset(commitLogOffset, msgSize);
+ }
+
+ @Override
+ public String getRunningDataInfo() {
+ return next.getRunningDataInfo();
+ }
+
+ @Override
+ public HashMap<String, String> getRuntimeInfo() {
+ return next.getRuntimeInfo();
+ }
+
+ @Override
+ public long getMaxPhyOffset() {
+ return next.getMaxPhyOffset();
+ }
+
+ @Override
+ public long getMinPhyOffset() {
+ return next.getMinPhyOffset();
+ }
+
+ @Override
+ public long getEarliestMessageTime(String topic, int queueId) {
+ return next.getEarliestMessageTime(topic, queueId);
+ }
+
+ @Override
+ public long getMessageStoreTimeStamp(String topic, int queueId, long offset) {
+ return next.getMessageStoreTimeStamp(topic, queueId, offset);
+ }
+
+ @Override
+ public long getMessageTotalInQueue(String topic, int queueId) {
+ return next.getMessageTotalInQueue(topic, queueId);
+ }
+
+ @Override
+ public SelectMappedBufferResult getCommitLogData(long offset) {
+ return next.getCommitLogData(offset);
+ }
+
+ @Override
+ public boolean appendToCommitLog(long startOffset, byte[] data) {
+ return next.appendToCommitLog(startOffset, data);
+ }
+
+ @Override
+ public void excuteDeleteFilesManualy() {
+ next.excuteDeleteFilesManualy();
+ }
+
+ @Override
+ public QueryMessageResult queryMessage(String topic, String key, int maxNum, long begin,
+ long end) {
+ return next.queryMessage(topic, key, maxNum, begin, end);
+ }
+
+ @Override
+ public void updateHaMasterAddress(String newAddr) {
+ next.updateHaMasterAddress(newAddr);
+ }
+
+ @Override
+ public long slaveFallBehindMuch() {
+ return next.slaveFallBehindMuch();
+ }
+
+ @Override
+ public long now() {
+ return next.now();
+ }
+
+ @Override
+ public int cleanUnusedTopic(Set<String> topics) {
+ return next.cleanUnusedTopic(topics);
+ }
+
+ @Override
+ public void cleanExpiredConsumerQueue() {
+ next.cleanExpiredConsumerQueue();
+ }
+
+ @Override
+ public boolean checkInDiskByConsumeOffset(String topic, int queueId, long consumeOffset) {
+ return next.checkInDiskByConsumeOffset(topic, queueId, consumeOffset);
+ }
+
+ @Override
+ public long dispatchBehindBytes() {
+ return next.dispatchBehindBytes();
+ }
+
+ @Override
+ public long flush() {
+ return next.flush();
+ }
+
+ @Override
+ public boolean resetWriteOffset(long phyOffset) {
+ return next.resetWriteOffset(phyOffset);
+ }
+
+ @Override
+ public long getConfirmOffset() {
+ return next.getConfirmOffset();
+ }
+
+ @Override
+ public void setConfirmOffset(long phyOffset) {
+ next.setConfirmOffset(phyOffset);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java b/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java
new file mode 100644
index 0000000..d27b6aa
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStoreFactory.java
@@ -0,0 +1,50 @@
+/**
+ * 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.broker.plugin;
+
+import org.apache.rocketmq.store.MessageStore;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+
+public final class MessageStoreFactory {
+ public final static MessageStore build(MessageStorePluginContext context, MessageStore messageStore)
+ throws IOException {
+ String plugin = context.getBrokerConfig().getMessageStorePlugIn();
+ if (plugin != null && plugin.trim().length() != 0) {
+ String[] pluginClasses = plugin.split(",");
+ for (int i = pluginClasses.length - 1; i >= 0; --i) {
+ String pluginClass = pluginClasses[i];
+ try {
+ @SuppressWarnings("unchecked")
+ Class<AbstractPluginMessageStore> clazz = (Class<AbstractPluginMessageStore>) Class.forName(pluginClass);
+ Constructor<AbstractPluginMessageStore> construct = clazz.getConstructor(MessageStorePluginContext.class, MessageStore.class);
+ AbstractPluginMessageStore pluginMessageStore = (AbstractPluginMessageStore) construct.newInstance(context, messageStore);
+ messageStore = pluginMessageStore;
+ } catch (Throwable e) {
+ throw new RuntimeException(String.format(
+ "Initialize plugin's class %s not found!", pluginClass), e);
+ }
+ }
+ }
+ return messageStore;
+ }
+}
[71/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/MessageFilter.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/MessageFilter.java b/store/src/main/java/org/apache/rocketmq/store/MessageFilter.java
index cb7304e..4122857 100644
--- a/store/src/main/java/org/apache/rocketmq/store/MessageFilter.java
+++ b/store/src/main/java/org/apache/rocketmq/store/MessageFilter.java
@@ -6,19 +6,18 @@
* (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
+ * 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.
+ * 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.store;
import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
-
public interface MessageFilter {
boolean isMessageMatched(final SubscriptionData subscriptionData, final Long tagsCode);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/MessageStore.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/MessageStore.java b/store/src/main/java/org/apache/rocketmq/store/MessageStore.java
index 328a700..9ed74e6 100644
--- a/store/src/main/java/org/apache/rocketmq/store/MessageStore.java
+++ b/store/src/main/java/org/apache/rocketmq/store/MessageStore.java
@@ -6,114 +6,87 @@
* (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
+ * 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.
+ * 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.store;
-import org.apache.rocketmq.common.message.MessageExt;
-import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
-
import java.util.HashMap;
import java.util.Set;
-
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
public interface MessageStore {
boolean load();
-
void start() throws Exception;
-
void shutdown();
-
void destroy();
PutMessageResult putMessage(final MessageExtBrokerInner msg);
-
GetMessageResult getMessage(final String group, final String topic, final int queueId,
- final long offset, final int maxMsgNums, final SubscriptionData subscriptionData);
-
+ final long offset, final int maxMsgNums, final SubscriptionData subscriptionData);
long getMaxOffsetInQuque(final String topic, final int queueId);
-
long getMinOffsetInQuque(final String topic, final int queueId);
-
long getCommitLogOffsetInQueue(final String topic, final int queueId, final long cqOffset);
-
long getOffsetInQueueByTime(final String topic, final int queueId, final long timestamp);
-
MessageExt lookMessageByOffset(final long commitLogOffset);
-
SelectMappedBufferResult selectOneMessageByOffset(final long commitLogOffset);
-
SelectMappedBufferResult selectOneMessageByOffset(final long commitLogOffset, final int msgSize);
String getRunningDataInfo();
-
HashMap<String, String> getRuntimeInfo();
-
long getMaxPhyOffset();
-
long getMinPhyOffset();
-
long getEarliestMessageTime(final String topic, final int queueId);
- long getEarliestMessageTime();
+ long getEarliestMessageTime();
long getMessageStoreTimeStamp(final String topic, final int queueId, final long offset);
-
long getMessageTotalInQueue(final String topic, final int queueId);
SelectMappedBufferResult getCommitLogData(final long offset);
-
boolean appendToCommitLog(final long startOffset, final byte[] data);
void excuteDeleteFilesManualy();
-
QueryMessageResult queryMessage(final String topic, final String key, final int maxNum,
- final long begin, final long end);
-
+ final long begin, final long end);
void updateHaMasterAddress(final String newAddr);
-
long slaveFallBehindMuch();
-
long now();
-
int cleanUnusedTopic(final Set<String> topics);
-
void cleanExpiredConsumerQueue();
-
boolean checkInDiskByConsumeOffset(final String topic, final int queueId, long consumeOffset);
-
long dispatchBehindBytes();
long flush();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/PutMessageResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/PutMessageResult.java b/store/src/main/java/org/apache/rocketmq/store/PutMessageResult.java
index d36e7ee..b6ede7e 100644
--- a/store/src/main/java/org/apache/rocketmq/store/PutMessageResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/PutMessageResult.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.store;
@@ -20,42 +20,35 @@ public class PutMessageResult {
private PutMessageStatus putMessageStatus;
private AppendMessageResult appendMessageResult;
-
public PutMessageResult(PutMessageStatus putMessageStatus, AppendMessageResult appendMessageResult) {
this.putMessageStatus = putMessageStatus;
this.appendMessageResult = appendMessageResult;
}
-
public boolean isOk() {
return this.appendMessageResult != null && this.appendMessageResult.isOk();
}
-
public AppendMessageResult getAppendMessageResult() {
return appendMessageResult;
}
-
public void setAppendMessageResult(AppendMessageResult appendMessageResult) {
this.appendMessageResult = appendMessageResult;
}
-
public PutMessageStatus getPutMessageStatus() {
return putMessageStatus;
}
-
public void setPutMessageStatus(PutMessageStatus putMessageStatus) {
this.putMessageStatus = putMessageStatus;
}
-
@Override
public String toString() {
return "PutMessageResult [putMessageStatus=" + putMessageStatus + ", appendMessageResult="
- + appendMessageResult + "]";
+ + appendMessageResult + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/PutMessageStatus.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/PutMessageStatus.java b/store/src/main/java/org/apache/rocketmq/store/PutMessageStatus.java
index 1b6ec9a..abab63f 100644
--- a/store/src/main/java/org/apache/rocketmq/store/PutMessageStatus.java
+++ b/store/src/main/java/org/apache/rocketmq/store/PutMessageStatus.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.store;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/QueryMessageResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/QueryMessageResult.java b/store/src/main/java/org/apache/rocketmq/store/QueryMessageResult.java
index 1f300a2..8b45b7c 100644
--- a/store/src/main/java/org/apache/rocketmq/store/QueryMessageResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/QueryMessageResult.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.store;
@@ -20,11 +20,10 @@ import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
-
public class QueryMessageResult {
private final List<SelectMappedBufferResult> messageMapedList =
- new ArrayList<SelectMappedBufferResult>(100);
+ new ArrayList<SelectMappedBufferResult>(100);
private final List<ByteBuffer> messageBufferList = new ArrayList<ByteBuffer>(100);
private long indexLastUpdateTimestamp;
@@ -32,46 +31,38 @@ public class QueryMessageResult {
private int bufferTotalSize = 0;
-
public void addMessage(final SelectMappedBufferResult mapedBuffer) {
this.messageMapedList.add(mapedBuffer);
this.messageBufferList.add(mapedBuffer.getByteBuffer());
this.bufferTotalSize += mapedBuffer.getSize();
}
-
public void release() {
for (SelectMappedBufferResult select : this.messageMapedList) {
select.release();
}
}
-
public long getIndexLastUpdateTimestamp() {
return indexLastUpdateTimestamp;
}
-
public void setIndexLastUpdateTimestamp(long indexLastUpdateTimestamp) {
this.indexLastUpdateTimestamp = indexLastUpdateTimestamp;
}
-
public long getIndexLastUpdatePhyoffset() {
return indexLastUpdatePhyoffset;
}
-
public void setIndexLastUpdatePhyoffset(long indexLastUpdatePhyoffset) {
this.indexLastUpdatePhyoffset = indexLastUpdatePhyoffset;
}
-
public List<ByteBuffer> getMessageBufferList() {
return messageBufferList;
}
-
public int getBufferTotalSize() {
return bufferTotalSize;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/ReferenceResource.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/ReferenceResource.java b/store/src/main/java/org/apache/rocketmq/store/ReferenceResource.java
index 6563232..b8b75da 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ReferenceResource.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ReferenceResource.java
@@ -6,26 +6,24 @@
* (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
+ * 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.
+ * 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.store;
import java.util.concurrent.atomic.AtomicLong;
-
public abstract class ReferenceResource {
protected final AtomicLong refCount = new AtomicLong(1);
protected volatile boolean available = true;
protected volatile boolean cleanupOver = false;
private volatile long firstShutdownTimestamp = 0;
-
public synchronized boolean hold() {
if (this.isAvailable()) {
if (this.refCount.getAndIncrement() > 0) {
@@ -38,21 +36,16 @@ public abstract class ReferenceResource {
return false;
}
-
public boolean isAvailable() {
return this.available;
}
-
-
public void shutdown(final long intervalForcibly) {
if (this.available) {
this.available = false;
this.firstShutdownTimestamp = System.currentTimeMillis();
this.release();
- }
-
- else if (this.getRefCount() > 0) {
+ } else if (this.getRefCount() > 0) {
if ((System.currentTimeMillis() - this.firstShutdownTimestamp) >= intervalForcibly) {
this.refCount.set(-1000 - this.getRefCount());
this.release();
@@ -77,7 +70,6 @@ public abstract class ReferenceResource {
public abstract boolean cleanup(final long currentRef);
-
public boolean isCleanupOver() {
return this.refCount.get() <= 0 && this.cleanupOver;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/RunningFlags.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/RunningFlags.java b/store/src/main/java/org/apache/rocketmq/store/RunningFlags.java
index 8e7f29f..52c269c 100644
--- a/store/src/main/java/org/apache/rocketmq/store/RunningFlags.java
+++ b/store/src/main/java/org/apache/rocketmq/store/RunningFlags.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.store;
@@ -29,16 +29,13 @@ public class RunningFlags {
private static final int DISK_FULL_BIT = 1 << 4;
private volatile int flagBits = 0;
-
public RunningFlags() {
}
-
public int getFlagBits() {
return flagBits;
}
-
public boolean getAndMakeReadable() {
boolean result = this.isReadable();
if (!result) {
@@ -47,7 +44,6 @@ public class RunningFlags {
return result;
}
-
public boolean isReadable() {
if ((this.flagBits & NOT_READABLE_BIT) == 0) {
return true;
@@ -56,7 +52,6 @@ public class RunningFlags {
return false;
}
-
public boolean getAndMakeNotReadable() {
boolean result = this.isReadable();
if (result) {
@@ -65,7 +60,6 @@ public class RunningFlags {
return result;
}
-
public boolean getAndMakeWriteable() {
boolean result = this.isWriteable();
if (!result) {
@@ -74,7 +68,6 @@ public class RunningFlags {
return result;
}
-
public boolean isWriteable() {
if ((this.flagBits & (NOT_WRITEABLE_BIT | WRITE_LOGICS_QUEUE_ERROR_BIT | DISK_FULL_BIT | WRITE_INDEX_FILE_ERROR_BIT)) == 0) {
return true;
@@ -83,7 +76,6 @@ public class RunningFlags {
return false;
}
-
public boolean getAndMakeNotWriteable() {
boolean result = this.isWriteable();
if (result) {
@@ -92,12 +84,10 @@ public class RunningFlags {
return result;
}
-
public void makeLogicsQueueError() {
this.flagBits |= WRITE_LOGICS_QUEUE_ERROR_BIT;
}
-
public boolean isLogicsQueueError() {
if ((this.flagBits & WRITE_LOGICS_QUEUE_ERROR_BIT) == WRITE_LOGICS_QUEUE_ERROR_BIT) {
return true;
@@ -106,12 +96,10 @@ public class RunningFlags {
return false;
}
-
public void makeIndexFileError() {
this.flagBits |= WRITE_INDEX_FILE_ERROR_BIT;
}
-
public boolean isIndexFileError() {
if ((this.flagBits & WRITE_INDEX_FILE_ERROR_BIT) == WRITE_INDEX_FILE_ERROR_BIT) {
return true;
@@ -120,14 +108,12 @@ public class RunningFlags {
return false;
}
-
public boolean getAndMakeDiskFull() {
boolean result = !((this.flagBits & DISK_FULL_BIT) == DISK_FULL_BIT);
this.flagBits |= DISK_FULL_BIT;
return result;
}
-
public boolean getAndMakeDiskOK() {
boolean result = !((this.flagBits & DISK_FULL_BIT) == DISK_FULL_BIT);
this.flagBits &= ~DISK_FULL_BIT;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/SelectMappedBufferResult.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/SelectMappedBufferResult.java b/store/src/main/java/org/apache/rocketmq/store/SelectMappedBufferResult.java
index 218f809..ddd9383 100644
--- a/store/src/main/java/org/apache/rocketmq/store/SelectMappedBufferResult.java
+++ b/store/src/main/java/org/apache/rocketmq/store/SelectMappedBufferResult.java
@@ -6,19 +6,18 @@
* (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
+ * 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.
+ * 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.store;
import java.nio.ByteBuffer;
-
public class SelectMappedBufferResult {
private final long startOffset;
@@ -29,7 +28,6 @@ public class SelectMappedBufferResult {
private MappedFile mappedFile;
-
public SelectMappedBufferResult(long startOffset, ByteBuffer byteBuffer, int size, MappedFile mappedFile) {
this.startOffset = startOffset;
this.byteBuffer = byteBuffer;
@@ -37,28 +35,23 @@ public class SelectMappedBufferResult {
this.mappedFile = mappedFile;
}
-
public ByteBuffer getByteBuffer() {
return byteBuffer;
}
-
public int getSize() {
return size;
}
-
public void setSize(final int s) {
this.size = s;
this.byteBuffer.limit(this.size);
}
-
public MappedFile getMappedFile() {
return mappedFile;
}
-
// @Override
// protected void finalize() {
// if (this.mappedFile != null) {
@@ -66,7 +59,6 @@ public class SelectMappedBufferResult {
// }
// }
-
public synchronized void release() {
if (this.mappedFile != null) {
this.mappedFile.release();
@@ -74,7 +66,6 @@ public class SelectMappedBufferResult {
}
}
-
public long getStartOffset() {
return startOffset;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/StoreCheckpoint.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/StoreCheckpoint.java b/store/src/main/java/org/apache/rocketmq/store/StoreCheckpoint.java
index 7fb5158..49a342e 100644
--- a/store/src/main/java/org/apache/rocketmq/store/StoreCheckpoint.java
+++ b/store/src/main/java/org/apache/rocketmq/store/StoreCheckpoint.java
@@ -6,28 +6,26 @@
* (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
+ * 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.
+ * 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.store;
-import org.apache.rocketmq.common.UtilAll;
-import org.apache.rocketmq.common.constant.LoggerName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel.MapMode;
-
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class StoreCheckpoint {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
@@ -38,7 +36,6 @@ public class StoreCheckpoint {
private volatile long logicsMsgTimestamp = 0;
private volatile long indexMsgTimestamp = 0;
-
public StoreCheckpoint(final String scpPath) throws IOException {
File file = new File(scpPath);
MappedFile.ensureDirOK(file.getParent());
@@ -55,17 +52,16 @@ public class StoreCheckpoint {
this.indexMsgTimestamp = this.mappedByteBuffer.getLong(16);
log.info("store checkpoint file physicMsgTimestamp " + this.physicMsgTimestamp + ", "
- + UtilAll.timeMillisToHumanString(this.physicMsgTimestamp));
+ + UtilAll.timeMillisToHumanString(this.physicMsgTimestamp));
log.info("store checkpoint file logicsMsgTimestamp " + this.logicsMsgTimestamp + ", "
- + UtilAll.timeMillisToHumanString(this.logicsMsgTimestamp));
+ + UtilAll.timeMillisToHumanString(this.logicsMsgTimestamp));
log.info("store checkpoint file indexMsgTimestamp " + this.indexMsgTimestamp + ", "
- + UtilAll.timeMillisToHumanString(this.indexMsgTimestamp));
+ + UtilAll.timeMillisToHumanString(this.indexMsgTimestamp));
} else {
log.info("store checkpoint file not exists, " + scpPath);
}
}
-
public void shutdown() {
this.flush();
@@ -79,7 +75,6 @@ public class StoreCheckpoint {
}
}
-
public void flush() {
this.mappedByteBuffer.putLong(0, this.physicMsgTimestamp);
this.mappedByteBuffer.putLong(8, this.logicsMsgTimestamp);
@@ -87,36 +82,29 @@ public class StoreCheckpoint {
this.mappedByteBuffer.force();
}
-
public long getPhysicMsgTimestamp() {
return physicMsgTimestamp;
}
-
public void setPhysicMsgTimestamp(long physicMsgTimestamp) {
this.physicMsgTimestamp = physicMsgTimestamp;
}
-
public long getLogicsMsgTimestamp() {
return logicsMsgTimestamp;
}
-
public void setLogicsMsgTimestamp(long logicsMsgTimestamp) {
this.logicsMsgTimestamp = logicsMsgTimestamp;
}
-
public long getMinTimestampIndex() {
return Math.min(this.getMinTimestamp(), this.indexMsgTimestamp);
}
-
public long getMinTimestamp() {
long min = Math.min(this.physicMsgTimestamp, this.logicsMsgTimestamp);
-
// fixed https://github.org/apache/rocketmqissues/467
min -= 1000 * 3;
if (min < 0)
@@ -125,12 +113,10 @@ public class StoreCheckpoint {
return min;
}
-
public long getIndexMsgTimestamp() {
return indexMsgTimestamp;
}
-
public void setIndexMsgTimestamp(long indexMsgTimestamp) {
this.indexMsgTimestamp = indexMsgTimestamp;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java b/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java
index 91b70fb..d4ba147 100644
--- a/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java
+++ b/store/src/main/java/org/apache/rocketmq/store/StoreStatsService.java
@@ -16,11 +16,6 @@
*/
package org.apache.rocketmq.store;
-import org.apache.rocketmq.common.ServiceThread;
-import org.apache.rocketmq.common.constant.LoggerName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.LinkedList;
@@ -28,7 +23,10 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantLock;
-
+import org.apache.rocketmq.common.ServiceThread;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class StoreStatsService extends ServiceThread {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
@@ -36,7 +34,7 @@ public class StoreStatsService extends ServiceThread {
private static final int FREQUENCY_OF_SAMPLING = 1000;
private static final int MAX_RECORDS_OF_SAMPLING = 60 * 10;
- private static final String[] PUT_MESSAGE_ENTIRE_TIME_MAX_DESC = new String[]{
+ private static final String[] PUT_MESSAGE_ENTIRE_TIME_MAX_DESC = new String[] {
"[<=0ms]", "[0~10ms]", "[10~50ms]", "[50~100ms]", "[100~200ms]", "[200~500ms]", "[500ms~1s]", "[1~2s]", "[2~3s]", "[3~4s]", "[4~5s]", "[5~10s]", "[10s~]",
};
@@ -45,9 +43,9 @@ public class StoreStatsService extends ServiceThread {
private final AtomicLong putMessageFailedTimes = new AtomicLong(0);
private final Map<String, AtomicLong> putMessageTopicTimesTotal =
- new ConcurrentHashMap<String, AtomicLong>(128);
+ new ConcurrentHashMap<String, AtomicLong>(128);
private final Map<String, AtomicLong> putMessageTopicSizeTotal =
- new ConcurrentHashMap<String, AtomicLong>(128);
+ new ConcurrentHashMap<String, AtomicLong>(128);
private final AtomicLong getMessageTimesTotalFound = new AtomicLong(0);
private final AtomicLong getMessageTransferedMsgCount = new AtomicLong(0);
@@ -71,7 +69,6 @@ public class StoreStatsService extends ServiceThread {
private ReentrantLock lockSampling = new ReentrantLock();
private long lastPrintTimestamp = System.currentTimeMillis();
-
public StoreStatsService() {
this.initPutMessageDistributeTime();
}
@@ -96,7 +93,8 @@ public class StoreStatsService extends ServiceThread {
public void setPutMessageEntireTimeMax(long value) {
final AtomicLong[] times = this.putMessageDistributeTime;
- if (null == times) return;
+ if (null == times)
+ return;
// us
if (value <= 0) {
@@ -140,37 +138,32 @@ public class StoreStatsService extends ServiceThread {
if (value > this.putMessageEntireTimeMax) {
this.lockPut.lock();
this.putMessageEntireTimeMax =
- value > this.putMessageEntireTimeMax ? value : this.putMessageEntireTimeMax;
+ value > this.putMessageEntireTimeMax ? value : this.putMessageEntireTimeMax;
this.lockPut.unlock();
}
}
-
public long getGetMessageEntireTimeMax() {
return getMessageEntireTimeMax;
}
-
public void setGetMessageEntireTimeMax(long value) {
if (value > this.getMessageEntireTimeMax) {
this.lockGet.lock();
this.getMessageEntireTimeMax =
- value > this.getMessageEntireTimeMax ? value : this.getMessageEntireTimeMax;
+ value > this.getMessageEntireTimeMax ? value : this.getMessageEntireTimeMax;
this.lockGet.unlock();
}
}
-
public long getDispatchMaxBuffer() {
return dispatchMaxBuffer;
}
-
public void setDispatchMaxBuffer(long value) {
this.dispatchMaxBuffer = value > this.dispatchMaxBuffer ? value : this.dispatchMaxBuffer;
}
-
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(1024);
@@ -184,9 +177,9 @@ public class StoreStatsService extends ServiceThread {
sb.append("\tputMessageTimesTotal: " + totalTimes + "\r\n");
sb.append("\tputMessageSizeTotal: " + this.getPutMessageSizeTotal() + "\r\n");
sb.append("\tputMessageDistributeTime: " + this.getPutMessageDistributeTimeStringInfo(totalTimes)
- + "\r\n");
+ + "\r\n");
sb.append("\tputMessageAverageSize: " + (this.getPutMessageSizeTotal() / totalTimes.doubleValue())
- + "\r\n");
+ + "\r\n");
sb.append("\tdispatchMaxBuffer: " + this.dispatchMaxBuffer + "\r\n");
sb.append("\tgetMessageEntireTimeMax: " + this.getMessageEntireTimeMax + "\r\n");
sb.append("\tputTps: " + this.getPutTps() + "\r\n");
@@ -218,7 +211,7 @@ public class StoreStatsService extends ServiceThread {
long hours = (time % day) / hour;
long minutes = (time % hour) / minute;
long seconds = (time % minute) / second;
- return messageFormat.format(new Long[]{days, hours, minutes, seconds});
+ return messageFormat.format(new Long[] {days, hours, minutes, seconds});
}
public long getPutMessageSizeTotal() {
@@ -239,11 +232,9 @@ public class StoreStatsService extends ServiceThread {
sb.append(this.getPutTps(10));
sb.append(" ");
-
sb.append(this.getPutTps(60));
sb.append(" ");
-
sb.append(this.getPutTps(600));
return sb.toString();
@@ -255,11 +246,9 @@ public class StoreStatsService extends ServiceThread {
sb.append(this.getGetFoundTps(10));
sb.append(" ");
-
sb.append(this.getGetFoundTps(60));
sb.append(" ");
-
sb.append(this.getGetFoundTps(600));
return sb.toString();
@@ -271,11 +260,9 @@ public class StoreStatsService extends ServiceThread {
sb.append(this.getGetMissTps(10));
sb.append(" ");
-
sb.append(this.getGetMissTps(60));
sb.append(" ");
-
sb.append(this.getGetMissTps(600));
return sb.toString();
@@ -287,11 +274,9 @@ public class StoreStatsService extends ServiceThread {
sb.append(this.getGetTotalTps(10));
sb.append(" ");
-
sb.append(this.getGetTotalTps(60));
sb.append(" ");
-
sb.append(this.getGetTotalTps(600));
return sb.toString();
@@ -303,11 +288,9 @@ public class StoreStatsService extends ServiceThread {
sb.append(this.getGetTransferedTps(10));
sb.append(" ");
-
sb.append(this.getGetTransferedTps(60));
sb.append(" ");
-
sb.append(this.getGetTransferedTps(600));
return sb.toString();
@@ -315,7 +298,8 @@ public class StoreStatsService extends ServiceThread {
private String putMessageDistributeTimeToString() {
final AtomicLong[] times = this.putMessageDistributeTime;
- if (null == times) return null;
+ if (null == times)
+ return null;
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < times.length; i++) {
@@ -352,7 +336,7 @@ public class StoreStatsService extends ServiceThread {
if (this.getTimesFoundList.size() > time) {
CallSnapshot lastBefore =
- this.getTimesFoundList.get(this.getTimesFoundList.size() - (time + 1));
+ this.getTimesFoundList.get(this.getTimesFoundList.size() - (time + 1));
result += CallSnapshot.getTPS(lastBefore, last);
}
} finally {
@@ -370,7 +354,7 @@ public class StoreStatsService extends ServiceThread {
if (this.getTimesMissList.size() > time) {
CallSnapshot lastBefore =
- this.getTimesMissList.get(this.getTimesMissList.size() - (time + 1));
+ this.getTimesMissList.get(this.getTimesMissList.size() - (time + 1));
result += CallSnapshot.getTPS(lastBefore, last);
}
@@ -391,7 +375,7 @@ public class StoreStatsService extends ServiceThread {
if (this.getTimesFoundList.size() > time) {
CallSnapshot lastBefore =
- this.getTimesFoundList.get(this.getTimesFoundList.size() - (time + 1));
+ this.getTimesFoundList.get(this.getTimesFoundList.size() - (time + 1));
found = CallSnapshot.getTPS(lastBefore, last);
}
}
@@ -400,7 +384,7 @@ public class StoreStatsService extends ServiceThread {
if (this.getTimesMissList.size() > time) {
CallSnapshot lastBefore =
- this.getTimesMissList.get(this.getTimesMissList.size() - (time + 1));
+ this.getTimesMissList.get(this.getTimesMissList.size() - (time + 1));
miss = CallSnapshot.getTPS(lastBefore, last);
}
}
@@ -420,7 +404,7 @@ public class StoreStatsService extends ServiceThread {
if (this.transferedMsgCountList.size() > time) {
CallSnapshot lastBefore =
- this.transferedMsgCountList.get(this.transferedMsgCountList.size() - (time + 1));
+ this.transferedMsgCountList.get(this.transferedMsgCountList.size() - (time + 1));
result += CallSnapshot.getTPS(lastBefore, last);
}
@@ -445,9 +429,9 @@ public class StoreStatsService extends ServiceThread {
result.put("putMessageTimesTotal", String.valueOf(totalTimes));
result.put("putMessageSizeTotal", String.valueOf(this.getPutMessageSizeTotal()));
result.put("putMessageDistributeTime",
- String.valueOf(this.getPutMessageDistributeTimeStringInfo(totalTimes)));
+ String.valueOf(this.getPutMessageDistributeTimeStringInfo(totalTimes)));
result.put("putMessageAverageSize",
- String.valueOf(this.getPutMessageSizeTotal() / totalTimes.doubleValue()));
+ String.valueOf(this.getPutMessageSizeTotal() / totalTimes.doubleValue()));
result.put("dispatchMaxBuffer", String.valueOf(this.dispatchMaxBuffer));
result.put("getMessageEntireTimeMax", String.valueOf(this.getMessageEntireTimeMax));
result.put("putTps", String.valueOf(this.getPutTps()));
@@ -491,19 +475,19 @@ public class StoreStatsService extends ServiceThread {
}
this.getTimesFoundList.add(new CallSnapshot(System.currentTimeMillis(),
- this.getMessageTimesTotalFound.get()));
+ this.getMessageTimesTotalFound.get()));
if (this.getTimesFoundList.size() > (MAX_RECORDS_OF_SAMPLING + 1)) {
this.getTimesFoundList.removeFirst();
}
this.getTimesMissList.add(new CallSnapshot(System.currentTimeMillis(),
- this.getMessageTimesTotalMiss.get()));
+ this.getMessageTimesTotalMiss.get()));
if (this.getTimesMissList.size() > (MAX_RECORDS_OF_SAMPLING + 1)) {
this.getTimesMissList.removeFirst();
}
this.transferedMsgCountList.add(new CallSnapshot(System.currentTimeMillis(),
- this.getMessageTransferedMsgCount.get()));
+ this.getMessageTransferedMsgCount.get()));
if (this.transferedMsgCountList.size() > (MAX_RECORDS_OF_SAMPLING + 1)) {
this.transferedMsgCountList.removeFirst();
}
@@ -518,14 +502,15 @@ public class StoreStatsService extends ServiceThread {
this.lastPrintTimestamp = System.currentTimeMillis();
log.info("[STORETPS] put_tps {} get_found_tps {} get_miss_tps {} get_transfered_tps {}",
- this.getPutTps(printTPSInterval),
- this.getGetFoundTps(printTPSInterval),
- this.getGetMissTps(printTPSInterval),
- this.getGetTransferedTps(printTPSInterval)
+ this.getPutTps(printTPSInterval),
+ this.getGetFoundTps(printTPSInterval),
+ this.getGetMissTps(printTPSInterval),
+ this.getGetTransferedTps(printTPSInterval)
);
final AtomicLong[] times = this.initPutMessageDistributeTime();
- if (null == times) return;
+ if (null == times)
+ return;
final StringBuilder sb = new StringBuilder();
long totalPut = 0;
@@ -544,22 +529,18 @@ public class StoreStatsService extends ServiceThread {
return getMessageTimesTotalFound;
}
-
public AtomicLong getGetMessageTimesTotalMiss() {
return getMessageTimesTotalMiss;
}
-
public AtomicLong getGetMessageTransferedMsgCount() {
return getMessageTransferedMsgCount;
}
-
public AtomicLong getPutMessageFailedTimes() {
return putMessageFailedTimes;
}
-
public AtomicLong getSinglePutMessageTopicSizeTotal(String topic) {
AtomicLong rs = putMessageTopicSizeTotal.get(topic);
if (null == rs) {
@@ -569,7 +550,6 @@ public class StoreStatsService extends ServiceThread {
return rs;
}
-
public AtomicLong getSinglePutMessageTopicTimesTotal(String topic) {
AtomicLong rs = putMessageTopicTimesTotal.get(topic);
if (null == rs) {
@@ -579,12 +559,10 @@ public class StoreStatsService extends ServiceThread {
return rs;
}
-
public Map<String, AtomicLong> getPutMessageTopicTimesTotal() {
return putMessageTopicTimesTotal;
}
-
public Map<String, AtomicLong> getPutMessageTopicSizeTotal() {
return putMessageTopicSizeTotal;
}
@@ -593,13 +571,11 @@ public class StoreStatsService extends ServiceThread {
public final long timestamp;
public final long callTimesTotal;
-
public CallSnapshot(long timestamp, long callTimesTotal) {
this.timestamp = timestamp;
this.callTimesTotal = callTimesTotal;
}
-
public static double getTPS(final CallSnapshot begin, final CallSnapshot end) {
long total = end.callTimesTotal - begin.callTimesTotal;
Long time = end.timestamp - begin.timestamp;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java b/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java
index d44720c..9cd7145 100644
--- a/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java
+++ b/store/src/main/java/org/apache/rocketmq/store/StoreUtil.java
@@ -6,33 +6,31 @@
* (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
+ * 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.
+ * 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.store;
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
-
/**
*
*/
public class StoreUtil {
public static final long TOTAL_PHYSICAL_MEMORY_SIZE = getTotalPhysicalMemorySize();
-
@SuppressWarnings("restriction")
public static long getTotalPhysicalMemorySize() {
long physicalTotal = 1024 * 1024 * 1024 * 24;
OperatingSystemMXBean osmxb = ManagementFactory.getOperatingSystemMXBean();
if (osmxb instanceof com.sun.management.OperatingSystemMXBean) {
- physicalTotal = ((com.sun.management.OperatingSystemMXBean) osmxb).getTotalPhysicalMemorySize();
+ physicalTotal = ((com.sun.management.OperatingSystemMXBean)osmxb).getTotalPhysicalMemorySize();
}
return physicalTotal;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java b/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java
index bd5b629..3e332ba 100644
--- a/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java
+++ b/store/src/main/java/org/apache/rocketmq/store/TransientStorePool.java
@@ -16,19 +16,18 @@
*/
package org.apache.rocketmq.store;
+import com.sun.jna.NativeLong;
+import com.sun.jna.Pointer;
+import java.nio.ByteBuffer;
+import java.util.Deque;
+import java.util.concurrent.ConcurrentLinkedDeque;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.store.config.MessageStoreConfig;
import org.apache.rocketmq.store.util.LibC;
-import com.sun.jna.NativeLong;
-import com.sun.jna.Pointer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.nio.ch.DirectBuffer;
-import java.nio.ByteBuffer;
-import java.util.Deque;
-import java.util.concurrent.ConcurrentLinkedDeque;
-
public class TransientStorePool {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
@@ -51,7 +50,7 @@ public class TransientStorePool {
for (int i = 0; i < poolSize; i++) {
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(fileSize);
- final long address = ((DirectBuffer) byteBuffer).address();
+ final long address = ((DirectBuffer)byteBuffer).address();
Pointer pointer = new Pointer(address);
LibC.INSTANCE.mlock(pointer, new NativeLong(fileSize));
@@ -61,7 +60,7 @@ public class TransientStorePool {
public void destroy() {
for (ByteBuffer byteBuffer : availableBuffers) {
- final long address = ((DirectBuffer) byteBuffer).address();
+ final long address = ((DirectBuffer)byteBuffer).address();
Pointer pointer = new Pointer(address);
LibC.INSTANCE.munlock(pointer, new NativeLong(fileSize));
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/config/BrokerRole.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/config/BrokerRole.java b/store/src/main/java/org/apache/rocketmq/store/config/BrokerRole.java
index 6ebb723..bebacc9 100644
--- a/store/src/main/java/org/apache/rocketmq/store/config/BrokerRole.java
+++ b/store/src/main/java/org/apache/rocketmq/store/config/BrokerRole.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.store.config;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/config/FlushDiskType.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/config/FlushDiskType.java b/store/src/main/java/org/apache/rocketmq/store/config/FlushDiskType.java
index 02b0ced..6a52a67 100644
--- a/store/src/main/java/org/apache/rocketmq/store/config/FlushDiskType.java
+++ b/store/src/main/java/org/apache/rocketmq/store/config/FlushDiskType.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.store.config;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java b/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java
index 205adec..d1e2bfe 100644
--- a/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java
+++ b/store/src/main/java/org/apache/rocketmq/store/config/MessageStoreConfig.java
@@ -6,22 +6,20 @@
* (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
+ * 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.
+ * 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.store.config;
+import java.io.File;
import org.apache.rocketmq.common.annotation.ImportantField;
import org.apache.rocketmq.store.ConsumeQueue;
-import java.io.File;
-
-
public class MessageStoreConfig {
//The root directory in which the log data is kept
@ImportantField
@@ -30,7 +28,7 @@ public class MessageStoreConfig {
//The directory in which the commitlog is kept
@ImportantField
private String storePathCommitLog = System.getProperty("user.home") + File.separator + "store"
- + File.separator + "commitlog";
+ + File.separator + "commitlog";
// CommitLog file size,default is 1G
private int mapedFileSizeCommitLog = 1024 * 1024 * 1024;
@@ -133,7 +131,7 @@ public class MessageStoreConfig {
private boolean transientStorePoolEnable = false;
private int transientStorePoolSize = 5;
private boolean fastFailIfNoBufferInStorePool = false;
-
+
public boolean isDebugLockEnable() {
return debugLockEnable;
}
@@ -170,119 +168,96 @@ public class MessageStoreConfig {
return warmMapedFileEnable;
}
-
public void setWarmMapedFileEnable(boolean warmMapedFileEnable) {
this.warmMapedFileEnable = warmMapedFileEnable;
}
-
public int getMapedFileSizeCommitLog() {
return mapedFileSizeCommitLog;
}
-
public void setMapedFileSizeCommitLog(int mapedFileSizeCommitLog) {
this.mapedFileSizeCommitLog = mapedFileSizeCommitLog;
}
-
public int getMapedFileSizeConsumeQueue() {
- int factor = (int) Math.ceil(this.mapedFileSizeConsumeQueue / (ConsumeQueue.CQ_STORE_UNIT_SIZE * 1.0));
- return (int) (factor * ConsumeQueue.CQ_STORE_UNIT_SIZE);
+ int factor = (int)Math.ceil(this.mapedFileSizeConsumeQueue / (ConsumeQueue.CQ_STORE_UNIT_SIZE * 1.0));
+ return (int)(factor * ConsumeQueue.CQ_STORE_UNIT_SIZE);
}
-
public void setMapedFileSizeConsumeQueue(int mapedFileSizeConsumeQueue) {
this.mapedFileSizeConsumeQueue = mapedFileSizeConsumeQueue;
}
-
public int getFlushIntervalCommitLog() {
return flushIntervalCommitLog;
}
-
public void setFlushIntervalCommitLog(int flushIntervalCommitLog) {
this.flushIntervalCommitLog = flushIntervalCommitLog;
}
-
public int getFlushIntervalConsumeQueue() {
return flushIntervalConsumeQueue;
}
-
public void setFlushIntervalConsumeQueue(int flushIntervalConsumeQueue) {
this.flushIntervalConsumeQueue = flushIntervalConsumeQueue;
}
-
public int getPutMsgIndexHightWater() {
return putMsgIndexHightWater;
}
-
public void setPutMsgIndexHightWater(int putMsgIndexHightWater) {
this.putMsgIndexHightWater = putMsgIndexHightWater;
}
-
public int getCleanResourceInterval() {
return cleanResourceInterval;
}
-
public void setCleanResourceInterval(int cleanResourceInterval) {
this.cleanResourceInterval = cleanResourceInterval;
}
-
public int getMaxMessageSize() {
return maxMessageSize;
}
-
public void setMaxMessageSize(int maxMessageSize) {
this.maxMessageSize = maxMessageSize;
}
-
public boolean isCheckCRCOnRecover() {
return checkCRCOnRecover;
}
-
public boolean getCheckCRCOnRecover() {
return checkCRCOnRecover;
}
-
public void setCheckCRCOnRecover(boolean checkCRCOnRecover) {
this.checkCRCOnRecover = checkCRCOnRecover;
}
-
public String getStorePathCommitLog() {
return storePathCommitLog;
}
-
public void setStorePathCommitLog(String storePathCommitLog) {
this.storePathCommitLog = storePathCommitLog;
}
-
public String getDeleteWhen() {
return deleteWhen;
}
-
public void setDeleteWhen(String deleteWhen) {
this.deleteWhen = deleteWhen;
}
-
public int getDiskMaxUsedSpaceRatio() {
if (this.diskMaxUsedSpaceRatio < 10)
return 10;
@@ -293,361 +268,294 @@ public class MessageStoreConfig {
return diskMaxUsedSpaceRatio;
}
-
public void setDiskMaxUsedSpaceRatio(int diskMaxUsedSpaceRatio) {
this.diskMaxUsedSpaceRatio = diskMaxUsedSpaceRatio;
}
-
public int getDeleteCommitLogFilesInterval() {
return deleteCommitLogFilesInterval;
}
-
public void setDeleteCommitLogFilesInterval(int deleteCommitLogFilesInterval) {
this.deleteCommitLogFilesInterval = deleteCommitLogFilesInterval;
}
-
public int getDeleteConsumeQueueFilesInterval() {
return deleteConsumeQueueFilesInterval;
}
-
public void setDeleteConsumeQueueFilesInterval(int deleteConsumeQueueFilesInterval) {
this.deleteConsumeQueueFilesInterval = deleteConsumeQueueFilesInterval;
}
-
public int getMaxTransferBytesOnMessageInMemory() {
return maxTransferBytesOnMessageInMemory;
}
-
public void setMaxTransferBytesOnMessageInMemory(int maxTransferBytesOnMessageInMemory) {
this.maxTransferBytesOnMessageInMemory = maxTransferBytesOnMessageInMemory;
}
-
public int getMaxTransferCountOnMessageInMemory() {
return maxTransferCountOnMessageInMemory;
}
-
public void setMaxTransferCountOnMessageInMemory(int maxTransferCountOnMessageInMemory) {
this.maxTransferCountOnMessageInMemory = maxTransferCountOnMessageInMemory;
}
-
public int getMaxTransferBytesOnMessageInDisk() {
return maxTransferBytesOnMessageInDisk;
}
-
public void setMaxTransferBytesOnMessageInDisk(int maxTransferBytesOnMessageInDisk) {
this.maxTransferBytesOnMessageInDisk = maxTransferBytesOnMessageInDisk;
}
-
public int getMaxTransferCountOnMessageInDisk() {
return maxTransferCountOnMessageInDisk;
}
-
public void setMaxTransferCountOnMessageInDisk(int maxTransferCountOnMessageInDisk) {
this.maxTransferCountOnMessageInDisk = maxTransferCountOnMessageInDisk;
}
-
public int getFlushCommitLogLeastPages() {
return flushCommitLogLeastPages;
}
-
public void setFlushCommitLogLeastPages(int flushCommitLogLeastPages) {
this.flushCommitLogLeastPages = flushCommitLogLeastPages;
}
-
public int getFlushConsumeQueueLeastPages() {
return flushConsumeQueueLeastPages;
}
-
public void setFlushConsumeQueueLeastPages(int flushConsumeQueueLeastPages) {
this.flushConsumeQueueLeastPages = flushConsumeQueueLeastPages;
}
-
public int getFlushCommitLogThoroughInterval() {
return flushCommitLogThoroughInterval;
}
-
public void setFlushCommitLogThoroughInterval(int flushCommitLogThoroughInterval) {
this.flushCommitLogThoroughInterval = flushCommitLogThoroughInterval;
}
-
public int getFlushConsumeQueueThoroughInterval() {
return flushConsumeQueueThoroughInterval;
}
-
public void setFlushConsumeQueueThoroughInterval(int flushConsumeQueueThoroughInterval) {
this.flushConsumeQueueThoroughInterval = flushConsumeQueueThoroughInterval;
}
-
public int getDestroyMapedFileIntervalForcibly() {
return destroyMapedFileIntervalForcibly;
}
-
public void setDestroyMapedFileIntervalForcibly(int destroyMapedFileIntervalForcibly) {
this.destroyMapedFileIntervalForcibly = destroyMapedFileIntervalForcibly;
}
-
public int getFileReservedTime() {
return fileReservedTime;
}
-
public void setFileReservedTime(int fileReservedTime) {
this.fileReservedTime = fileReservedTime;
}
-
public int getRedeleteHangedFileInterval() {
return redeleteHangedFileInterval;
}
-
public void setRedeleteHangedFileInterval(int redeleteHangedFileInterval) {
this.redeleteHangedFileInterval = redeleteHangedFileInterval;
}
-
public int getAccessMessageInMemoryMaxRatio() {
return accessMessageInMemoryMaxRatio;
}
-
public void setAccessMessageInMemoryMaxRatio(int accessMessageInMemoryMaxRatio) {
this.accessMessageInMemoryMaxRatio = accessMessageInMemoryMaxRatio;
}
-
public boolean isMessageIndexEnable() {
return messageIndexEnable;
}
-
public void setMessageIndexEnable(boolean messageIndexEnable) {
this.messageIndexEnable = messageIndexEnable;
}
-
public int getMaxHashSlotNum() {
return maxHashSlotNum;
}
-
public void setMaxHashSlotNum(int maxHashSlotNum) {
this.maxHashSlotNum = maxHashSlotNum;
}
-
public int getMaxIndexNum() {
return maxIndexNum;
}
-
public void setMaxIndexNum(int maxIndexNum) {
this.maxIndexNum = maxIndexNum;
}
-
public int getMaxMsgsNumBatch() {
return maxMsgsNumBatch;
}
-
public void setMaxMsgsNumBatch(int maxMsgsNumBatch) {
this.maxMsgsNumBatch = maxMsgsNumBatch;
}
-
public int getHaListenPort() {
return haListenPort;
}
-
public void setHaListenPort(int haListenPort) {
this.haListenPort = haListenPort;
}
-
public int getHaSendHeartbeatInterval() {
return haSendHeartbeatInterval;
}
-
public void setHaSendHeartbeatInterval(int haSendHeartbeatInterval) {
this.haSendHeartbeatInterval = haSendHeartbeatInterval;
}
-
public int getHaHousekeepingInterval() {
return haHousekeepingInterval;
}
-
public void setHaHousekeepingInterval(int haHousekeepingInterval) {
this.haHousekeepingInterval = haHousekeepingInterval;
}
-
public BrokerRole getBrokerRole() {
return brokerRole;
}
- public void setBrokerRole(BrokerRole brokerRole) {
- this.brokerRole = brokerRole;
- }
-
public void setBrokerRole(String brokerRole) {
this.brokerRole = BrokerRole.valueOf(brokerRole);
}
+ public void setBrokerRole(BrokerRole brokerRole) {
+ this.brokerRole = brokerRole;
+ }
+
public int getHaTransferBatchSize() {
return haTransferBatchSize;
}
-
public void setHaTransferBatchSize(int haTransferBatchSize) {
this.haTransferBatchSize = haTransferBatchSize;
}
-
public int getHaSlaveFallbehindMax() {
return haSlaveFallbehindMax;
}
-
public void setHaSlaveFallbehindMax(int haSlaveFallbehindMax) {
this.haSlaveFallbehindMax = haSlaveFallbehindMax;
}
-
public FlushDiskType getFlushDiskType() {
return flushDiskType;
}
- public void setFlushDiskType(FlushDiskType flushDiskType) {
- this.flushDiskType = flushDiskType;
- }
-
public void setFlushDiskType(String type) {
this.flushDiskType = FlushDiskType.valueOf(type);
}
+ public void setFlushDiskType(FlushDiskType flushDiskType) {
+ this.flushDiskType = flushDiskType;
+ }
+
public int getSyncFlushTimeout() {
return syncFlushTimeout;
}
-
public void setSyncFlushTimeout(int syncFlushTimeout) {
this.syncFlushTimeout = syncFlushTimeout;
}
-
public String getHaMasterAddress() {
return haMasterAddress;
}
-
public void setHaMasterAddress(String haMasterAddress) {
this.haMasterAddress = haMasterAddress;
}
-
public String getMessageDelayLevel() {
return messageDelayLevel;
}
-
public void setMessageDelayLevel(String messageDelayLevel) {
this.messageDelayLevel = messageDelayLevel;
}
-
public long getFlushDelayOffsetInterval() {
return flushDelayOffsetInterval;
}
-
public void setFlushDelayOffsetInterval(long flushDelayOffsetInterval) {
this.flushDelayOffsetInterval = flushDelayOffsetInterval;
}
-
public boolean isCleanFileForciblyEnable() {
return cleanFileForciblyEnable;
}
-
public void setCleanFileForciblyEnable(boolean cleanFileForciblyEnable) {
this.cleanFileForciblyEnable = cleanFileForciblyEnable;
}
-
public boolean isMessageIndexSafe() {
return messageIndexSafe;
}
-
public void setMessageIndexSafe(boolean messageIndexSafe) {
this.messageIndexSafe = messageIndexSafe;
}
-
public boolean isFlushCommitLogTimed() {
return flushCommitLogTimed;
}
-
public void setFlushCommitLogTimed(boolean flushCommitLogTimed) {
this.flushCommitLogTimed = flushCommitLogTimed;
}
-
public String getStorePathRootDir() {
return storePathRootDir;
}
-
public void setStorePathRootDir(String storePathRootDir) {
this.storePathRootDir = storePathRootDir;
}
-
public int getFlushLeastPagesWhenWarmMapedFile() {
return flushLeastPagesWhenWarmMapedFile;
}
-
public void setFlushLeastPagesWhenWarmMapedFile(int flushLeastPagesWhenWarmMapedFile) {
this.flushLeastPagesWhenWarmMapedFile = flushLeastPagesWhenWarmMapedFile;
}
-
public boolean isOffsetCheckInSlave() {
return offsetCheckInSlave;
}
-
public void setOffsetCheckInSlave(boolean offsetCheckInSlave) {
this.offsetCheckInSlave = offsetCheckInSlave;
}
@@ -666,7 +574,7 @@ public class MessageStoreConfig {
*/
public boolean isTransientStorePoolEnable() {
return transientStorePoolEnable && FlushDiskType.ASYNC_FLUSH == getFlushDiskType()
- && BrokerRole.SLAVE != getBrokerRole();
+ && BrokerRole.SLAVE != getBrokerRole();
}
public void setTransientStorePoolEnable(final boolean transientStorePoolEnable) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/config/StorePathConfigHelper.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/config/StorePathConfigHelper.java b/store/src/main/java/org/apache/rocketmq/store/config/StorePathConfigHelper.java
index 8796436..d1cd7de 100644
--- a/store/src/main/java/org/apache/rocketmq/store/config/StorePathConfigHelper.java
+++ b/store/src/main/java/org/apache/rocketmq/store/config/StorePathConfigHelper.java
@@ -6,51 +6,44 @@
* (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
+ * 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.
+ * 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.store.config;
import java.io.File;
-
public class StorePathConfigHelper {
public static String getStorePathConsumeQueue(final String rootDir) {
return rootDir + File.separator + "consumequeue";
}
-
public static String getStorePathIndex(final String rootDir) {
return rootDir + File.separator + "index";
}
-
public static String getStoreCheckpoint(final String rootDir) {
return rootDir + File.separator + "checkpoint";
}
-
public static String getAbortFile(final String rootDir) {
return rootDir + File.separator + "abort";
}
-
public static String getDelayOffsetStorePath(final String rootDir) {
return rootDir + File.separator + "config" + File.separator + "delayOffset.json";
}
-
public static String getTranStateTableStorePath(final String rootDir) {
return rootDir + File.separator + "transaction" + File.separator + "statetable";
}
-
public static String getTranRedoLogStorePath(final String rootDir) {
return rootDir + File.separator + "transaction" + File.separator + "redolog";
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/store/src/main/java/org/apache/rocketmq/store/ha/HAConnection.java
----------------------------------------------------------------------
diff --git a/store/src/main/java/org/apache/rocketmq/store/ha/HAConnection.java b/store/src/main/java/org/apache/rocketmq/store/ha/HAConnection.java
index e8965d3..a601e81 100644
--- a/store/src/main/java/org/apache/rocketmq/store/ha/HAConnection.java
+++ b/store/src/main/java/org/apache/rocketmq/store/ha/HAConnection.java
@@ -6,16 +6,21 @@
* (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
+ * 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.
+ * 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.store.ha;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.SocketChannel;
import org.apache.rocketmq.common.ServiceThread;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.remoting.common.RemotingUtil;
@@ -23,13 +28,6 @@ import org.apache.rocketmq.store.SelectMappedBufferResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.Selector;
-import java.nio.channels.SocketChannel;
-
-
public class HAConnection {
private static final Logger log = LoggerFactory.getLogger(LoggerName.STORE_LOGGER_NAME);
private final HAService haService;
@@ -41,7 +39,6 @@ public class HAConnection {
private volatile long slaveRequestOffset = -1;
private volatile long slaveAckOffset = -1;
-
public HAConnection(final HAService haService, final SocketChannel socketChannel) throws IOException {
this.haService = haService;
this.socketChannel = socketChannel;
@@ -56,20 +53,17 @@ public class HAConnection {
this.haService.getConnectionCount().incrementAndGet();
}
-
public void start() {
this.readSocketService.start();
this.writeSocketService.start();
}
-
public void shutdown() {
this.writeSocketService.shutdown(true);
this.readSocketService.shutdown(true);
this.close();
}
-
public void close() {
if (this.socketChannel != null) {
try {
@@ -80,7 +74,6 @@ public class HAConnection {
}
}
-
public SocketChannel getSocketChannel() {
return socketChannel;
}
@@ -97,7 +90,6 @@ public class HAConnection {
private int processPostion = 0;
private volatile long lastReadTimestamp = System.currentTimeMillis();
-
public ReadSocketService(final SocketChannel socketChannel) throws IOException {
this.selector = RemotingUtil.openSelector();
this.socketChannel = socketChannel;
@@ -105,7 +97,6 @@ public class HAConnection {
this.thread.setDaemon(true);
}
-
@Override
public void run() {
HAConnection.log.info(this.getServiceName() + " service started");
@@ -119,7 +110,6 @@ public class HAConnection {
break;
}
-
long interval = HAConnection.this.haService.getDefaultMessageStore().getSystemClock().now() - this.lastReadTimestamp;
if (interval > HAConnection.this.haService.getDefaultMessageStore().getMessageStoreConfig().getHaHousekeepingInterval()) {
log.warn("ha housekeeping, found this connection[" + HAConnection.this.clientAddr + "] expired, " + interval);
@@ -135,10 +125,8 @@ public class HAConnection {
writeSocketService.makeStop();
-
haService.removeConnection(HAConnection.this);
-
HAConnection.this.haService.getConnectionCount().decrementAndGet();
SelectionKey sk = this.socketChannel.keyFor(this.selector);
@@ -180,14 +168,12 @@ public class HAConnection {
long readOffset = this.byteBufferRead.getLong(pos - 8);
this.processPostion = pos;
-
HAConnection.this.slaveAckOffset = readOffset;
if (HAConnection.this.slaveRequestOffset < 0) {
HAConnection.this.slaveRequestOffset = readOffset;
log.info("slave[" + HAConnection.this.clientAddr + "] request offset " + readOffset);
}
-
HAConnection.this.haService.notifyTransferSome(HAConnection.this.slaveAckOffset);
}
} else if (readSize == 0) {
@@ -223,7 +209,6 @@ public class HAConnection {
private boolean lastWriteOver = true;
private long lastWriteTimestamp = System.currentTimeMillis();
-
public WriteSocketService(final SocketChannel socketChannel) throws IOException {
this.selector = RemotingUtil.openSelector();
this.socketChannel = socketChannel;
@@ -231,7 +216,6 @@ public class HAConnection {
this.thread.setDaemon(true);
}
-
@Override
public void run() {
HAConnection.log.info(this.getServiceName() + " service started");
@@ -245,15 +229,13 @@ public class HAConnection {
continue;
}
-
-
if (-1 == this.nextTransferFromWhere) {
if (0 == HAConnection.this.slaveRequestOffset) {
long masterOffset = HAConnection.this.haService.getDefaultMessageStore().getCommitLog().getMaxOffset();
masterOffset =
- masterOffset
- - (masterOffset % HAConnection.this.haService.getDefaultMessageStore().getMessageStoreConfig()
- .getMapedFileSizeCommitLog());
+ masterOffset
+ - (masterOffset % HAConnection.this.haService.getDefaultMessageStore().getMessageStoreConfig()
+ .getMapedFileSizeCommitLog());
if (masterOffset < 0) {
masterOffset = 0;
@@ -265,16 +247,16 @@ public class HAConnection {
}
log.info("master transfer data from " + this.nextTransferFromWhere + " to slave[" + HAConnection.this.clientAddr
- + "], and slave request " + HAConnection.this.slaveRequestOffset);
+ + "], and slave request " + HAConnection.this.slaveRequestOffset);
}
if (this.lastWriteOver) {
long interval =
- HAConnection.this.haService.getDefaultMessageStore().getSystemClock().now() - this.lastWriteTimestamp;
+ HAConnection.this.haService.getDefaultMessageStore().getSystemClock().now() - this.lastWriteTimestamp;
if (interval > HAConnection.this.haService.getDefaultMessageStore().getMessageStoreConfig()
- .getHaSendHeartbeatInterval()) {
+ .getHaSendHeartbeatInterval()) {
// Build Header
this.byteBufferHeader.position(0);
@@ -287,16 +269,14 @@ public class HAConnection {
if (!this.lastWriteOver)
continue;
}
- }
-
- else {
+ } else {
this.lastWriteOver = this.transferData();
if (!this.lastWriteOver)
continue;
}
SelectMappedBufferResult selectResult =
- HAConnection.this.haService.getDefaultMessageStore().getCommitLogData(this.nextTransferFromWhere);
+ HAConnection.this.haService.getDefaultMessageStore().getCommitLogData(this.nextTransferFromWhere);
if (selectResult != null) {
int size = selectResult.getSize();
if (size > HAConnection.this.haService.getDefaultMessageStore().getMessageStoreConfig().getHaTransferBatchSize()) {
@@ -328,7 +308,6 @@ public class HAConnection {
}
}
-
if (this.selectMappedBufferResult != null) {
this.selectMappedBufferResult.release();
}
@@ -337,7 +316,6 @@ public class HAConnection {
readSocketService.makeStop();
-
haService.removeConnection(HAConnection.this);
SelectionKey sk = this.socketChannel.keyFor(this.selector);
@@ -355,7 +333,6 @@ public class HAConnection {
HAConnection.log.info(this.getServiceName() + " service end");
}
-
/**
*/
@@ -409,13 +386,11 @@ public class HAConnection {
return result;
}
-
@Override
public String getServiceName() {
return WriteSocketService.class.getSimpleName();
}
-
@Override
public void shutdown() {
super.shutdown();
[79/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
index ce09727..eef99e2 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: GetMinOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,34 +26,28 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class GetMinOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
@CFNotNull
private Integer queueId;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public Integer getQueueId() {
return queueId;
}
-
public void setQueueId(Integer queueId) {
this.queueId = queueId;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
index 366b513..67b7a01 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: GetMinOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,22 +26,18 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class GetMinOffsetResponseHeader implements CommandCustomHeader {
@CFNotNull
private Long offset;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public Long getOffset() {
return offset;
}
-
public void setOffset(Long offset) {
this.offset = offset;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java
index d6da4a7..62fe94d 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetProducerConnectionListRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header;
@@ -21,24 +21,20 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class GetProducerConnectionListRequestHeader implements CommandCustomHeader {
@CFNotNull
private String producerGroup;
-
@Override
public void checkFields() throws RemotingCommandException {
// To change body of implemented methods use File | Settings | File
// Templates.
}
-
public String getProducerGroup() {
return producerGroup;
}
-
public void setProducerGroup(String producerGroup) {
this.producerGroup = producerGroup;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java
index f49dee0..3ef4eb3 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicStatsInfoRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header;
@@ -21,7 +21,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
/**
*
*/
@@ -29,17 +28,14 @@ public class GetTopicStatsInfoRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicsByClusterRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicsByClusterRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicsByClusterRequestHeader.java
index 37f5ffa..80ee8f1 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicsByClusterRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicsByClusterRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header;
@@ -21,7 +21,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
/**
*
*/
@@ -29,17 +28,14 @@ public class GetTopicsByClusterRequestHeader implements CommandCustomHeader {
@CFNotNull
private String cluster;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getCluster() {
return cluster;
}
-
public void setCluster(String cluster) {
this.cluster = cluster;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java
index 35ac787..c8bfdb7 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/NotifyConsumerIdsChangedRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header;
@@ -21,22 +21,18 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class NotifyConsumerIdsChangedRequestHeader implements CommandCustomHeader {
@CFNotNull
private String consumerGroup;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
index 7e72ca1..b0e65ad 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: PullMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -25,7 +27,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.annotation.CFNullable;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class PullMessageRequestHeader implements CommandCustomHeader {
@CFNotNull
private String consumerGroup;
@@ -48,107 +49,86 @@ public class PullMessageRequestHeader implements CommandCustomHeader {
@CFNotNull
private Long subVersion;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public Integer getQueueId() {
return queueId;
}
-
public void setQueueId(Integer queueId) {
this.queueId = queueId;
}
-
public Long getQueueOffset() {
return queueOffset;
}
-
public void setQueueOffset(Long queueOffset) {
this.queueOffset = queueOffset;
}
-
public Integer getMaxMsgNums() {
return maxMsgNums;
}
-
public void setMaxMsgNums(Integer maxMsgNums) {
this.maxMsgNums = maxMsgNums;
}
-
public Integer getSysFlag() {
return sysFlag;
}
-
public void setSysFlag(Integer sysFlag) {
this.sysFlag = sysFlag;
}
-
public Long getCommitOffset() {
return commitOffset;
}
-
public void setCommitOffset(Long commitOffset) {
this.commitOffset = commitOffset;
}
-
public Long getSuspendTimeoutMillis() {
return suspendTimeoutMillis;
}
-
public void setSuspendTimeoutMillis(Long suspendTimeoutMillis) {
this.suspendTimeoutMillis = suspendTimeoutMillis;
}
-
public String getSubscription() {
return subscription;
}
-
public void setSubscription(String subscription) {
this.subscription = subscription;
}
-
public Long getSubVersion() {
return subVersion;
}
-
public void setSubVersion(Long subVersion) {
this.subVersion = subVersion;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
index 576a1b4..6907068 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: PullMessageResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,7 +26,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class PullMessageResponseHeader implements CommandCustomHeader {
@CFNotNull
private Long suggestWhichBrokerId;
@@ -35,47 +36,38 @@ public class PullMessageResponseHeader implements CommandCustomHeader {
@CFNotNull
private Long maxOffset;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public Long getNextBeginOffset() {
return nextBeginOffset;
}
-
public void setNextBeginOffset(Long nextBeginOffset) {
this.nextBeginOffset = nextBeginOffset;
}
-
public Long getMinOffset() {
return minOffset;
}
-
public void setMinOffset(Long minOffset) {
this.minOffset = minOffset;
}
-
public Long getMaxOffset() {
return maxOffset;
}
-
public void setMaxOffset(Long maxOffset) {
this.maxOffset = maxOffset;
}
-
public Long getSuggestWhichBrokerId() {
return suggestWhichBrokerId;
}
-
public void setSuggestWhichBrokerId(Long suggestWhichBrokerId) {
this.suggestWhichBrokerId = suggestWhichBrokerId;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumeTimeSpanRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumeTimeSpanRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumeTimeSpanRequestHeader.java
index 2afdbd5..83253a3 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumeTimeSpanRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumeTimeSpanRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header;
@@ -21,7 +21,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
/**
*
*/
@@ -31,27 +30,22 @@ public class QueryConsumeTimeSpanRequestHeader implements CommandCustomHeader {
@CFNotNull
private String group;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public String getGroup() {
return group;
}
-
public void setGroup(String group) {
this.group = group;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
index f38f912..9cbfaa2 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: QueryConsumerOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,7 +26,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class QueryConsumerOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
private String consumerGroup;
@@ -33,37 +34,30 @@ public class QueryConsumerOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
private Integer queueId;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public Integer getQueueId() {
return queueId;
}
-
public void setQueueId(Integer queueId) {
this.queueId = queueId;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
index db13a39..51b50ea 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: QueryConsumerOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,22 +26,18 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class QueryConsumerOffsetResponseHeader implements CommandCustomHeader {
@CFNotNull
private Long offset;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public Long getOffset() {
return offset;
}
-
public void setOffset(Long offset) {
this.offset = offset;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
index da2b200..04926fa 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: GetMinOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,7 +26,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
/**
*
*
@@ -36,38 +37,31 @@ public class QueryCorrectionOffsetHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
-
@Override
public void checkFields() throws RemotingCommandException {
// TODO Auto-generated method stub
}
-
public String getFilterGroups() {
return filterGroups;
}
-
public void setFilterGroups(String filterGroups) {
this.filterGroups = filterGroups;
}
-
public String getCompareGroup() {
return compareGroup;
}
-
public void setCompareGroup(String compareGroup) {
this.compareGroup = compareGroup;
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
index f7ab865..5aed5f3 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: QueryMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,7 +26,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class QueryMessageRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
@@ -37,58 +38,47 @@ public class QueryMessageRequestHeader implements CommandCustomHeader {
@CFNotNull
private Long endTimestamp;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public String getKey() {
return key;
}
-
public void setKey(String key) {
this.key = key;
}
-
public Integer getMaxNum() {
return maxNum;
}
-
public void setMaxNum(Integer maxNum) {
this.maxNum = maxNum;
}
-
public Long getBeginTimestamp() {
return beginTimestamp;
}
-
public void setBeginTimestamp(Long beginTimestamp) {
this.beginTimestamp = beginTimestamp;
}
-
public Long getEndTimestamp() {
return endTimestamp;
}
-
public void setEndTimestamp(Long endTimestamp) {
this.endTimestamp = endTimestamp;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
index 8e34c73..14d4d54 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: QueryMessageResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,34 +26,28 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class QueryMessageResponseHeader implements CommandCustomHeader {
@CFNotNull
private Long indexLastUpdateTimestamp;
@CFNotNull
private Long indexLastUpdatePhyoffset;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public Long getIndexLastUpdateTimestamp() {
return indexLastUpdateTimestamp;
}
-
public void setIndexLastUpdateTimestamp(Long indexLastUpdateTimestamp) {
this.indexLastUpdateTimestamp = indexLastUpdateTimestamp;
}
-
public Long getIndexLastUpdatePhyoffset() {
return indexLastUpdatePhyoffset;
}
-
public void setIndexLastUpdatePhyoffset(Long indexLastUpdatePhyoffset) {
this.indexLastUpdatePhyoffset = indexLastUpdatePhyoffset;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
index 0d3e7f4..a58de58 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: QueryMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,23 +26,19 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class QueryTopicConsumeByWhoRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java
index 678e85f..920760b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ResetOffsetRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header;
@@ -21,7 +21,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
/**
*
*
@@ -36,47 +35,38 @@ public class ResetOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
private boolean isForce;
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public String getGroup() {
return group;
}
-
public void setGroup(String group) {
this.group = group;
}
-
public long getTimestamp() {
return timestamp;
}
-
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
-
public boolean isForce() {
return isForce;
}
-
public void setForce(boolean isForce) {
this.isForce = isForce;
}
-
@Override
public void checkFields() throws RemotingCommandException {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
index b355aec..e686f90 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: SearchOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,7 +26,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class SearchOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
@@ -33,39 +34,32 @@ public class SearchOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
private Long timestamp;
-
@Override
public void checkFields() throws RemotingCommandException {
// TODO Auto-generated method stub
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public Integer getQueueId() {
return queueId;
}
-
public void setQueueId(Integer queueId) {
this.queueId = queueId;
}
-
public Long getTimestamp() {
return timestamp;
}
-
public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
index 9a74180..bbac844 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: SearchOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,22 +26,18 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class SearchOffsetResponseHeader implements CommandCustomHeader {
@CFNotNull
private Long offset;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public Long getOffset() {
return offset;
}
-
public void setOffset(Long offset) {
this.offset = offset;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
index d5af104..937a86e 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: SendMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -25,7 +27,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.annotation.CFNullable;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class SendMessageRequestHeader implements CommandCustomHeader {
@CFNotNull
private String producerGroup;
@@ -51,127 +52,102 @@ public class SendMessageRequestHeader implements CommandCustomHeader {
private boolean unitMode = false;
private Integer maxReconsumeTimes;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getProducerGroup() {
return producerGroup;
}
-
public void setProducerGroup(String producerGroup) {
this.producerGroup = producerGroup;
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public String getDefaultTopic() {
return defaultTopic;
}
-
public void setDefaultTopic(String defaultTopic) {
this.defaultTopic = defaultTopic;
}
-
public Integer getDefaultTopicQueueNums() {
return defaultTopicQueueNums;
}
-
public void setDefaultTopicQueueNums(Integer defaultTopicQueueNums) {
this.defaultTopicQueueNums = defaultTopicQueueNums;
}
-
public Integer getQueueId() {
return queueId;
}
-
public void setQueueId(Integer queueId) {
this.queueId = queueId;
}
-
public Integer getSysFlag() {
return sysFlag;
}
-
public void setSysFlag(Integer sysFlag) {
this.sysFlag = sysFlag;
}
-
public Long getBornTimestamp() {
return bornTimestamp;
}
-
public void setBornTimestamp(Long bornTimestamp) {
this.bornTimestamp = bornTimestamp;
}
-
public Integer getFlag() {
return flag;
}
-
public void setFlag(Integer flag) {
this.flag = flag;
}
-
public String getProperties() {
return properties;
}
-
public void setProperties(String properties) {
this.properties = properties;
}
-
public Integer getReconsumeTimes() {
return reconsumeTimes;
}
-
public void setReconsumeTimes(Integer reconsumeTimes) {
this.reconsumeTimes = reconsumeTimes;
}
-
public boolean isUnitMode() {
return unitMode;
}
-
public void setUnitMode(boolean isUnitMode) {
this.unitMode = isUnitMode;
}
-
public Integer getMaxReconsumeTimes() {
return maxReconsumeTimes;
}
-
public void setMaxReconsumeTimes(final Integer maxReconsumeTimes) {
this.maxReconsumeTimes = maxReconsumeTimes;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
index 8bf956d..fe5a12b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
@@ -22,7 +22,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.annotation.CFNullable;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
/**
* Use short variable name to speed up FastJson deserialization process.
*/
@@ -94,117 +93,94 @@ public class SendMessageRequestHeaderV2 implements CommandCustomHeader {
return a;
}
-
public void setA(String a) {
this.a = a;
}
-
public String getB() {
return b;
}
-
public void setB(String b) {
this.b = b;
}
-
public String getC() {
return c;
}
-
public void setC(String c) {
this.c = c;
}
-
public Integer getD() {
return d;
}
-
public void setD(Integer d) {
this.d = d;
}
-
public Integer getE() {
return e;
}
-
public void setE(Integer e) {
this.e = e;
}
-
public Integer getF() {
return f;
}
-
public void setF(Integer f) {
this.f = f;
}
-
public Long getG() {
return g;
}
-
public void setG(Long g) {
this.g = g;
}
-
public Integer getH() {
return h;
}
-
public void setH(Integer h) {
this.h = h;
}
-
public String getI() {
return i;
}
-
public void setI(String i) {
this.i = i;
}
-
public Integer getJ() {
return j;
}
-
public void setJ(Integer j) {
this.j = j;
}
-
public boolean isK() {
return k;
}
-
public void setK(boolean k) {
this.k = k;
}
-
public Integer getL() {
return l;
}
-
public void setL(final Integer l) {
this.l = l;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
index 3457ea7..b6a8fa5 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: SendMessageResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,7 +26,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class SendMessageResponseHeader implements CommandCustomHeader {
@CFNotNull
private String msgId;
@@ -34,37 +35,30 @@ public class SendMessageResponseHeader implements CommandCustomHeader {
private Long queueOffset;
private String transactionId;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getMsgId() {
return msgId;
}
-
public void setMsgId(String msgId) {
this.msgId = msgId;
}
-
public Integer getQueueId() {
return queueId;
}
-
public void setQueueId(Integer queueId) {
this.queueId = queueId;
}
-
public Long getQueueOffset() {
return queueOffset;
}
-
public void setQueueOffset(Long queueOffset) {
this.queueOffset = queueOffset;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
index 4c5e6f1..106580e 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.
*/
/**
@@ -25,7 +25,6 @@ import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.annotation.CFNullable;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class UnregisterClientRequestHeader implements CommandCustomHeader {
@CFNotNull
private String clientID;
@@ -35,37 +34,30 @@ public class UnregisterClientRequestHeader implements CommandCustomHeader {
@CFNullable
private String consumerGroup;
-
public String getClientID() {
return clientID;
}
-
public void setClientID(String clientID) {
this.clientID = clientID;
}
-
public String getProducerGroup() {
return producerGroup;
}
-
public void setProducerGroup(String producerGroup) {
this.producerGroup = producerGroup;
}
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
@Override
public void checkFields() throws RemotingCommandException {
// TODO Auto-generated method stub
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
index 92758a1..68d1c7b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.
*/
/**
@@ -23,7 +23,6 @@ package org.apache.rocketmq.common.protocol.header;
import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class UnregisterClientResponseHeader implements CommandCustomHeader {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
index 40861c1..5822d8e 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: UpdateConsumerOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,7 +26,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class UpdateConsumerOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
private String consumerGroup;
@@ -35,47 +36,38 @@ public class UpdateConsumerOffsetRequestHeader implements CommandCustomHeader {
@CFNotNull
private Long commitOffset;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public Integer getQueueId() {
return queueId;
}
-
public void setQueueId(Integer queueId) {
this.queueId = queueId;
}
-
public Long getCommitOffset() {
return commitOffset;
}
-
public void setCommitOffset(Long commitOffset) {
this.commitOffset = commitOffset;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
index d24c5ad..c8b6083 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: UpdateConsumerOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -23,7 +25,6 @@ package org.apache.rocketmq.common.protocol.header;
import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class UpdateConsumerOffsetResponseHeader implements CommandCustomHeader {
@Override
public void checkFields() throws RemotingCommandException {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewBrokerStatsDataRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewBrokerStatsDataRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewBrokerStatsDataRequestHeader.java
index 6d11cd8..3fc0ce4 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewBrokerStatsDataRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewBrokerStatsDataRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header;
@@ -21,35 +21,29 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class ViewBrokerStatsDataRequestHeader implements CommandCustomHeader {
@CFNotNull
private String statsName;
@CFNotNull
private String statsKey;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getStatsName() {
return statsName;
}
-
public void setStatsName(String statsName) {
this.statsName = statsName;
}
-
public String getStatsKey() {
return statsKey;
}
-
public void setStatsKey(String statsKey) {
this.statsKey = statsKey;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
index 4e8d402..f1c7622 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: ViewMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -24,22 +26,18 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class ViewMessageRequestHeader implements CommandCustomHeader {
@CFNotNull
private Long offset;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public Long getOffset() {
return offset;
}
-
public void setOffset(Long offset) {
this.offset = offset;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
index 6c92dc0..b2d97d4 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
@@ -6,13 +6,15 @@
* (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
+ * 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.
+ * 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.
+ *
+ * $Id: ViewMessageResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
@@ -23,7 +25,6 @@ package org.apache.rocketmq.common.protocol.header;
import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class ViewMessageResponseHeader implements CommandCustomHeader {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerRequestHeader.java
index 480e528..5a45d29 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header.filtersrv;
@@ -21,22 +21,18 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class RegisterFilterServerRequestHeader implements CommandCustomHeader {
@CFNotNull
private String filterServerAddr;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getFilterServerAddr() {
return filterServerAddr;
}
-
public void setFilterServerAddr(String filterServerAddr) {
this.filterServerAddr = filterServerAddr;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerResponseHeader.java
index a2a52f0..56067ee 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterFilterServerResponseHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header.filtersrv;
@@ -21,34 +21,28 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class RegisterFilterServerResponseHeader implements CommandCustomHeader {
@CFNotNull
private String brokerName;
@CFNotNull
private long brokerId;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public long getBrokerId() {
return brokerId;
}
-
public void setBrokerId(long brokerId) {
this.brokerId = brokerId;
}
-
public String getBrokerName() {
return brokerName;
}
-
public void setBrokerName(String brokerName) {
this.brokerName = brokerName;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterMessageFilterClassRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterMessageFilterClassRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterMessageFilterClassRequestHeader.java
index 1fc94a9..3b1601e 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterMessageFilterClassRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/filtersrv/RegisterMessageFilterClassRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header.filtersrv;
@@ -21,7 +21,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
public class RegisterMessageFilterClassRequestHeader implements CommandCustomHeader {
@CFNotNull
private String consumerGroup;
@@ -32,47 +31,38 @@ public class RegisterMessageFilterClassRequestHeader implements CommandCustomHea
@CFNotNull
private Integer classCRC;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public String getClassName() {
return className;
}
-
public void setClassName(String className) {
this.className = className;
}
-
public Integer getClassCRC() {
return classCRC;
}
-
public void setClassCRC(Integer classCRC) {
this.classCRC = classCRC;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java
index ff19623..f423b11 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteKVConfigRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header.namesrv;
@@ -21,7 +21,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
/**
*
*/
@@ -31,27 +30,22 @@ public class DeleteKVConfigRequestHeader implements CommandCustomHeader {
@CFNotNull
private String key;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getNamespace() {
return namespace;
}
-
public void setNamespace(String namespace) {
this.namespace = namespace;
}
-
public String getKey() {
return key;
}
-
public void setKey(String key) {
this.key = key;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java
index 44e8cb6..3fd9bb3 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/DeleteTopicInNamesrvRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header.namesrv;
@@ -20,7 +20,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
/**
*
*/
@@ -28,17 +27,14 @@ public class DeleteTopicInNamesrvRequestHeader implements CommandCustomHeader {
@CFNotNull
private String topic;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java
index b68976a..e60163b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetKVConfigRequestHeader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.common.protocol.header.namesrv;
@@ -21,7 +21,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader;
import org.apache.rocketmq.remoting.annotation.CFNotNull;
import org.apache.rocketmq.remoting.exception.RemotingCommandException;
-
/**
*
*/
@@ -31,27 +30,22 @@ public class GetKVConfigRequestHeader implements CommandCustomHeader {
@CFNotNull
private String key;
-
@Override
public void checkFields() throws RemotingCommandException {
}
-
public String getNamespace() {
return namespace;
}
-
public void setNamespace(String namespace) {
this.namespace = namespace;
}
-
public String getKey() {
return key;
}
-
public void setKey(String key) {
this.key = key;
}
[66/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/WipeWritePermSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/WipeWritePermSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/WipeWritePermSubCommand.java
index 66f7159..86e7848 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/WipeWritePermSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/namesrv/WipeWritePermSubCommand.java
@@ -6,24 +6,23 @@
* (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
+ * 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.
+ * 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.tools.command.namesrv;
-import org.apache.rocketmq.remoting.RPCHook;
-import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
-import org.apache.rocketmq.tools.command.SubCommand;
+import java.util.List;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
-
-import java.util.List;
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
+import org.apache.rocketmq.tools.command.SubCommand;
public class WipeWritePermSubCommand implements SubCommand {
@@ -32,13 +31,11 @@ public class WipeWritePermSubCommand implements SubCommand {
return "wipeWritePerm";
}
-
@Override
public String commandDesc() {
return "Wipe write perm of broker in all name server";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("b", "brokerName", true, "broker name");
@@ -47,7 +44,6 @@ public class WipeWritePermSubCommand implements SubCommand {
return options;
}
-
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
@@ -63,14 +59,14 @@ public class WipeWritePermSubCommand implements SubCommand {
try {
int wipeTopicCount = defaultMQAdminExt.wipeWritePermOfBroker(namesrvAddr, brokerName);
System.out.printf("wipe write perm of broker[%s] in name server[%s] OK, %d%n",
- brokerName,
- namesrvAddr,
- wipeTopicCount
+ brokerName,
+ namesrvAddr,
+ wipeTopicCount
);
} catch (Exception e) {
System.out.printf("wipe write perm of broker[%s] in name server[%s] Failed%n",
- brokerName,
- namesrvAddr
+ brokerName,
+ namesrvAddr
);
e.printStackTrace();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/offset/CloneGroupOffsetCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/offset/CloneGroupOffsetCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/offset/CloneGroupOffsetCommand.java
index 3cb7e3f..fe239aa 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/offset/CloneGroupOffsetCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/offset/CloneGroupOffsetCommand.java
@@ -6,17 +6,21 @@
* (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
+ * 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.
+ * 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.tools.command.offset;
+import java.util.Set;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.common.admin.ConsumeStats;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.common.protocol.route.BrokerData;
@@ -24,11 +28,6 @@ import org.apache.rocketmq.common.protocol.route.TopicRouteData;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.Set;
public class CloneGroupOffsetCommand implements SubCommand {
@Override
@@ -94,7 +93,7 @@ public class CloneGroupOffsetCommand implements SubCommand {
}
}
System.out.printf("clone group offset success. srcGroup[%s], destGroup=[%s], topic[%s]",
- srcGroup, destGroup, topic);
+ srcGroup, destGroup, topic);
} catch (Exception e) {
e.printStackTrace();
} finally {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/offset/GetConsumerStatusCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/offset/GetConsumerStatusCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/offset/GetConsumerStatusCommand.java
index 1623f52..68b62e1 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/offset/GetConsumerStatusCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/offset/GetConsumerStatusCommand.java
@@ -17,16 +17,15 @@
package org.apache.rocketmq.tools.command.offset;
+import java.util.Map;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.Map;
public class GetConsumerStatusCommand implements SubCommand {
@Override
@@ -70,15 +69,15 @@ public class GetConsumerStatusCommand implements SubCommand {
defaultMQAdminExt.start();
Map<String, Map<MessageQueue, Long>> consumerStatusTable =
- defaultMQAdminExt.getConsumeStatus(topic, group, originClientId);
+ defaultMQAdminExt.getConsumeStatus(topic, group, originClientId);
System.out.printf("get consumer status from client. group=%s, topic=%s, originClientId=%s%n",
- group, topic, originClientId);
+ group, topic, originClientId);
System.out.printf("%-50s %-15s %-15s %-20s%n",
- "#clientId",
- "#brokerName",
- "#queueId",
- "#offset");
+ "#clientId",
+ "#brokerName",
+ "#queueId",
+ "#offset");
for (Map.Entry<String, Map<MessageQueue, Long>> entry : consumerStatusTable.entrySet()) {
String clientId = entry.getKey();
@@ -86,10 +85,10 @@ public class GetConsumerStatusCommand implements SubCommand {
for (Map.Entry<MessageQueue, Long> entry1 : mqTable.entrySet()) {
MessageQueue mq = entry1.getKey();
System.out.printf("%-50s %-15s %-15d %-20d%n",
- UtilAll.frontStringAtLeast(clientId, 50),
- mq.getBrokerName(),
- mq.getQueueId(),
- mqTable.get(mq));
+ UtilAll.frontStringAtLeast(clientId, 50),
+ mq.getBrokerName(),
+ mq.getQueueId(),
+ mqTable.get(mq));
}
}
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeCommand.java
index 5eb30b5..e07a7c8 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeCommand.java
@@ -17,6 +17,12 @@
package org.apache.rocketmq.tools.command.offset;
+import java.util.Iterator;
+import java.util.Map;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.PosixParser;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.message.MessageQueue;
@@ -25,22 +31,14 @@ import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.srvutil.ServerUtil;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.PosixParser;
-
-import java.util.Iterator;
-import java.util.Map;
-
public class ResetOffsetByTimeCommand implements SubCommand {
public static void main(String[] args) {
ResetOffsetByTimeCommand cmd = new ResetOffsetByTimeCommand();
Options options = ServerUtil.buildCommandlineOptions(new Options());
- String[] subargs = new String[]{"-t Jodie_rest_test", "-g CID_Jodie_rest_test", "-s -1", "-f true"};
+ String[] subargs = new String[] {"-t Jodie_rest_test", "-g CID_Jodie_rest_test", "-s -1", "-f true"};
final CommandLine commandLine =
- ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser());
+ ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser());
cmd.execute(commandLine, options, null);
}
@@ -120,20 +118,20 @@ public class ResetOffsetByTimeCommand implements SubCommand {
}
System.out.printf("rollback consumer offset by specified group[%s], topic[%s], force[%s], timestamp(string)[%s], timestamp(long)[%s]%n",
- group, topic, force, timeStampStr, timestamp);
+ group, topic, force, timeStampStr, timestamp);
System.out.printf("%-40s %-40s %-40s%n",
- "#brokerName",
- "#queueId",
- "#offset");
+ "#brokerName",
+ "#queueId",
+ "#offset");
Iterator<Map.Entry<MessageQueue, Long>> iterator = offsetTable.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<MessageQueue, Long> entry = iterator.next();
System.out.printf("%-40s %-40d %-40d%n",
- UtilAll.frontStringAtLeast(entry.getKey().getBrokerName(), 32),
- entry.getKey().getQueueId(),
- entry.getValue());
+ UtilAll.frontStringAtLeast(entry.getKey().getBrokerName(), 32),
+ entry.getKey().getQueueId(),
+ entry.getValue());
}
} catch (Exception e) {
e.printStackTrace();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeOldCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeOldCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeOldCommand.java
index 0f15f69..9b30474 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeOldCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/offset/ResetOffsetByTimeOldCommand.java
@@ -6,17 +6,22 @@
* (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
+ * 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.
+ * 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.tools.command.offset;
+import java.util.Date;
+import java.util.List;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.UtilAll;
@@ -25,19 +30,40 @@ import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.remoting.exception.RemotingException;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.Date;
-import java.util.List;
-
/**
*
*
*/
public class ResetOffsetByTimeOldCommand implements SubCommand {
+ public static void resetOffset(DefaultMQAdminExt defaultMQAdminExt, String consumerGroup, String topic, long timestamp, boolean force,
+ String timeStampStr) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ List<RollbackStats> rollbackStatsList = defaultMQAdminExt.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, force);
+ System.out.printf(
+ "rollback consumer offset by specified consumerGroup[%s], topic[%s], force[%s], timestamp(string)[%s], timestamp(long)[%s]%n",
+ consumerGroup, topic, force, timeStampStr, timestamp);
+
+ System.out.printf("%-20s %-20s %-20s %-20s %-20s %-20s%n",
+ "#brokerName",
+ "#queueId",
+ "#brokerOffset",
+ "#consumerOffset",
+ "#timestampOffset",
+ "#rollbackOffset"
+ );
+
+ for (RollbackStats rollbackStats : rollbackStatsList) {
+ System.out.printf("%-20s %-20d %-20d %-20d %-20d %-20d%n",
+ UtilAll.frontStringAtLeast(rollbackStats.getBrokerName(), 32),
+ rollbackStats.getQueueId(),
+ rollbackStats.getBrokerOffset(),
+ rollbackStats.getConsumerOffset(),
+ rollbackStats.getTimestampOffset(),
+ rollbackStats.getRollbackOffset()
+ );
+ }
+ }
+
@Override
public String commandName() {
return "resetOffsetByTimeOld";
@@ -104,32 +130,4 @@ public class ResetOffsetByTimeOldCommand implements SubCommand {
defaultMQAdminExt.shutdown();
}
}
-
- public static void resetOffset(DefaultMQAdminExt defaultMQAdminExt, String consumerGroup, String topic, long timestamp, boolean force,
- String timeStampStr) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
- List<RollbackStats> rollbackStatsList = defaultMQAdminExt.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, force);
- System.out.printf(
- "rollback consumer offset by specified consumerGroup[%s], topic[%s], force[%s], timestamp(string)[%s], timestamp(long)[%s]%n",
- consumerGroup, topic, force, timeStampStr, timestamp);
-
- System.out.printf("%-20s %-20s %-20s %-20s %-20s %-20s%n",
- "#brokerName",
- "#queueId",
- "#brokerOffset",
- "#consumerOffset",
- "#timestampOffset",
- "#rollbackOffset"
- );
-
- for (RollbackStats rollbackStats : rollbackStatsList) {
- System.out.printf("%-20s %-20d %-20d %-20d %-20d %-20d%n",
- UtilAll.frontStringAtLeast(rollbackStats.getBrokerName(), 32),
- rollbackStats.getQueueId(),
- rollbackStats.getBrokerOffset(),
- rollbackStats.getConsumerOffset(),
- rollbackStats.getTimestampOffset(),
- rollbackStats.getRollbackOffset()
- );
- }
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/stats/StatsAllSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/stats/StatsAllSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/stats/StatsAllSubCommand.java
index 90a361c..81a7f78 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/stats/StatsAllSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/stats/StatsAllSubCommand.java
@@ -17,6 +17,9 @@
package org.apache.rocketmq.tools.command.stats;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.MixAll;
@@ -32,82 +35,10 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
import org.apache.rocketmq.store.stats.BrokerStatsManager;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
public class StatsAllSubCommand implements SubCommand {
- @Override
- public String commandName() {
- return "statsAll";
- }
-
- @Override
- public String commandDesc() {
- return "Topic and Consumer tps stats";
- }
-
- @Override
- public Options buildCommandlineOptions(Options options) {
- Option opt = new Option("a", "activeTopic", false, "print active topic only");
- opt.setRequired(false);
- options.addOption(opt);
-
- opt = new Option("t", "topic", true, "print select topic only");
- opt.setRequired(false);
- options.addOption(opt);
-
- return options;
- }
-
- @Override
- public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
- DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
-
- defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
-
- try {
- defaultMQAdminExt.start();
-
- TopicList topicList = defaultMQAdminExt.fetchAllTopicList();
-
- System.out.printf("%-32s %-32s %12s %11s %11s %14s %14s%n",
- "#Topic",
- "#Consumer Group",
- "#Accumulation",
- "#InTPS",
- "#OutTPS",
- "#InMsg24Hour",
- "#OutMsg24Hour"
- );
-
- boolean activeTopic = commandLine.hasOption('a');
- String selectTopic = commandLine.getOptionValue('t');
-
- for (String topic : topicList.getTopicList()) {
- if (topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX) || topic.startsWith(MixAll.DLQ_GROUP_TOPIC_PREFIX)) {
- continue;
- }
-
- if (selectTopic != null && selectTopic != "" && !topic.equals(selectTopic)) {
- continue;
- }
-
- try {
- printTopicDetail(defaultMQAdminExt, topic, activeTopic);
- } catch (Exception e) {
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- defaultMQAdminExt.shutdown();
- }
- }
-
public static void printTopicDetail(final DefaultMQAdminExt admin, final String topic, final boolean activeTopic)
- throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
+ throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
TopicRouteData topicRouteData = admin.examineTopicRouteInfo(topic);
GroupList groupList = admin.queryTopicConsumeByWho(topic);
@@ -116,7 +47,6 @@ public class StatsAllSubCommand implements SubCommand {
long inMsgCntToday = 0;
-
for (BrokerData bd : topicRouteData.getBrokerDatas()) {
String masterAddr = bd.getBrokerAddrs().get(MixAll.MASTER_ID);
if (masterAddr != null) {
@@ -161,16 +91,16 @@ public class StatsAllSubCommand implements SubCommand {
}
if (!activeTopic || (inMsgCntToday > 0) ||
- (outMsgCntToday > 0)) {
+ (outMsgCntToday > 0)) {
System.out.printf("%-32s %-32s %12d %11.2f %11.2f %14d %14d%n",
- UtilAll.frontStringAtLeast(topic, 32),
- UtilAll.frontStringAtLeast(group, 32),
- accumulate,
- inTPS,
- outTPS,
- inMsgCntToday,
- outMsgCntToday
+ UtilAll.frontStringAtLeast(topic, 32),
+ UtilAll.frontStringAtLeast(group, 32),
+ accumulate,
+ inTPS,
+ outTPS,
+ inMsgCntToday,
+ outMsgCntToday
);
}
}
@@ -178,13 +108,13 @@ public class StatsAllSubCommand implements SubCommand {
if (!activeTopic || (inMsgCntToday > 0)) {
System.out.printf("%-32s %-32s %12d %11.2f %11s %14d %14s%n",
- UtilAll.frontStringAtLeast(topic, 32),
- "",
- 0,
- inTPS,
- "",
- inMsgCntToday,
- "NO_CONSUMER"
+ UtilAll.frontStringAtLeast(topic, 32),
+ "",
+ 0,
+ inTPS,
+ "",
+ inMsgCntToday,
+ "NO_CONSUMER"
);
}
}
@@ -205,4 +135,72 @@ public class StatsAllSubCommand implements SubCommand {
return 0;
}
+
+ @Override
+ public String commandName() {
+ return "statsAll";
+ }
+
+ @Override
+ public String commandDesc() {
+ return "Topic and Consumer tps stats";
+ }
+
+ @Override
+ public Options buildCommandlineOptions(Options options) {
+ Option opt = new Option("a", "activeTopic", false, "print active topic only");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+ opt = new Option("t", "topic", true, "print select topic only");
+ opt.setRequired(false);
+ options.addOption(opt);
+
+ return options;
+ }
+
+ @Override
+ public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
+ DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
+
+ defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
+
+ try {
+ defaultMQAdminExt.start();
+
+ TopicList topicList = defaultMQAdminExt.fetchAllTopicList();
+
+ System.out.printf("%-32s %-32s %12s %11s %11s %14s %14s%n",
+ "#Topic",
+ "#Consumer Group",
+ "#Accumulation",
+ "#InTPS",
+ "#OutTPS",
+ "#InMsg24Hour",
+ "#OutMsg24Hour"
+ );
+
+ boolean activeTopic = commandLine.hasOption('a');
+ String selectTopic = commandLine.getOptionValue('t');
+
+ for (String topic : topicList.getTopicList()) {
+ if (topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX) || topic.startsWith(MixAll.DLQ_GROUP_TOPIC_PREFIX)) {
+ continue;
+ }
+
+ if (selectTopic != null && selectTopic != "" && !topic.equals(selectTopic)) {
+ continue;
+ }
+
+ try {
+ printTopicDetail(defaultMQAdminExt, topic, activeTopic);
+ } catch (Exception e) {
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ defaultMQAdminExt.shutdown();
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/topic/AllocateMQSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/AllocateMQSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/AllocateMQSubCommand.java
index 09d8011..709aada 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/AllocateMQSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/AllocateMQSubCommand.java
@@ -16,6 +16,13 @@
*/
package org.apache.rocketmq.tools.command.topic;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.client.consumer.rebalance.AllocateMessageQueueAveragely;
import org.apache.rocketmq.client.impl.factory.MQClientInstance;
import org.apache.rocketmq.common.message.MessageQueue;
@@ -24,15 +31,6 @@ import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
public class AllocateMQSubCommand implements SubCommand {
@Override
@@ -40,13 +38,11 @@ public class AllocateMQSubCommand implements SubCommand {
return "allocateMQ";
}
-
@Override
public String commandDesc() {
return "Allocate MQ";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("t", "topic", true, "topic name");
@@ -60,7 +56,6 @@ public class AllocateMQSubCommand implements SubCommand {
return options;
}
-
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
DefaultMQAdminExt adminExt = new DefaultMQAdminExt(rpcHook);
@@ -81,7 +76,6 @@ public class AllocateMQSubCommand implements SubCommand {
final AllocateMessageQueueAveragely averagely = new AllocateMessageQueueAveragely();
-
RebalanceResult rr = new RebalanceResult();
for (String i : ipList) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java
index 0749e36..69cbc99 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java
@@ -6,16 +6,22 @@
* (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
+ * 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.
+ * 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.tools.command.topic;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.remoting.RPCHook;
@@ -24,32 +30,41 @@ import org.apache.rocketmq.srvutil.ServerUtil;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.CommandUtil;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
/**
*
*
*/
public class DeleteTopicSubCommand implements SubCommand {
+ public static void deleteTopic(final DefaultMQAdminExt adminExt,
+ final String clusterName,
+ final String topic
+ ) throws InterruptedException, MQBrokerException, RemotingException, MQClientException {
+
+ Set<String> masterSet = CommandUtil.fetchMasterAddrByClusterName(adminExt, clusterName);
+ adminExt.deleteTopicInBroker(masterSet, topic);
+ System.out.printf("delete topic [%s] from cluster [%s] success.%n", topic, clusterName);
+
+ Set<String> nameServerSet = null;
+ if (adminExt.getNamesrvAddr() != null) {
+ String[] ns = adminExt.getNamesrvAddr().trim().split(";");
+ nameServerSet = new HashSet(Arrays.asList(ns));
+ }
+
+ adminExt.deleteTopicInNameServer(nameServerSet, topic);
+ System.out.printf("delete topic [%s] from NameServer success.%n", topic);
+ }
+
@Override
public String commandName() {
return "deleteTopic";
}
-
@Override
public String commandDesc() {
return "Delete topic from broker and NameServer.";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("t", "topic", true, "topic name");
@@ -63,29 +78,6 @@ public class DeleteTopicSubCommand implements SubCommand {
return options;
}
-
- public static void deleteTopic(final DefaultMQAdminExt adminExt,
- final String clusterName,
- final String topic
- ) throws InterruptedException, MQBrokerException, RemotingException, MQClientException {
-
- Set<String> masterSet = CommandUtil.fetchMasterAddrByClusterName(adminExt, clusterName);
- adminExt.deleteTopicInBroker(masterSet, topic);
- System.out.printf("delete topic [%s] from cluster [%s] success.%n", topic, clusterName);
-
-
- Set<String> nameServerSet = null;
- if (adminExt.getNamesrvAddr() != null) {
- String[] ns = adminExt.getNamesrvAddr().trim().split(";");
- nameServerSet = new HashSet(Arrays.asList(ns));
- }
-
-
- adminExt.deleteTopicInNameServer(nameServerSet, topic);
- System.out.printf("delete topic [%s] from NameServer success.%n", topic);
- }
-
-
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
DefaultMQAdminExt adminExt = new DefaultMQAdminExt(rpcHook);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/topic/RebalanceResult.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/RebalanceResult.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/RebalanceResult.java
index 9f6c0b0..6e6e4ff 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/RebalanceResult.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/RebalanceResult.java
@@ -6,22 +6,21 @@
* (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
+ * 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.
+ * 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.tools.command.topic;
-import org.apache.rocketmq.common.message.MessageQueue;
-
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.rocketmq.common.message.MessageQueue;
public class RebalanceResult {
private Map<String/*ip*/, List<MessageQueue>> result = new HashMap<String, List<MessageQueue>>();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicClusterSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicClusterSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicClusterSubCommand.java
index 2bdedd6..6a267a5 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicClusterSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicClusterSubCommand.java
@@ -16,15 +16,13 @@
*/
package org.apache.rocketmq.tools.command.topic;
-import org.apache.rocketmq.remoting.RPCHook;
-import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
-import org.apache.rocketmq.tools.command.SubCommand;
+import java.util.Set;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
-
-import java.util.Set;
-
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
+import org.apache.rocketmq.tools.command.SubCommand;
/**
*
@@ -37,13 +35,11 @@ public class TopicClusterSubCommand implements SubCommand {
return "topicClusterList";
}
-
@Override
public String commandDesc() {
return "get cluster info for topic";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("t", "topic", true, "topic name");
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java
index 42184fb..5e23a96 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicListSubCommand.java
@@ -16,6 +16,12 @@
*/
package org.apache.rocketmq.tools.command.topic;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Set;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.UtilAll;
@@ -28,14 +34,6 @@ import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.remoting.exception.RemotingException;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.Set;
-
/**
*
@@ -72,15 +70,15 @@ public class TopicListSubCommand implements SubCommand {
ClusterInfo clusterInfo = defaultMQAdminExt.examineBrokerClusterInfo();
System.out.printf("%-20s %-48s %-48s%n",
- "#Cluster Name",
- "#Topic",
- "#Consumer Group"
+ "#Cluster Name",
+ "#Topic",
+ "#Consumer Group"
);
TopicList topicList = defaultMQAdminExt.fetchAllTopicList();
for (String topic : topicList.getTopicList()) {
if (topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)
- || topic.startsWith(MixAll.DLQ_GROUP_TOPIC_PREFIX)) {
+ || topic.startsWith(MixAll.DLQ_GROUP_TOPIC_PREFIX)) {
continue;
}
@@ -89,7 +87,7 @@ public class TopicListSubCommand implements SubCommand {
try {
clusterName =
- this.findTopicBelongToWhichCluster(topic, clusterInfo, defaultMQAdminExt);
+ this.findTopicBelongToWhichCluster(topic, clusterInfo, defaultMQAdminExt);
groupList = defaultMQAdminExt.queryTopicConsumeByWho(topic);
} catch (Exception e) {
}
@@ -101,9 +99,9 @@ public class TopicListSubCommand implements SubCommand {
for (String group : groupList.getGroupList()) {
System.out.printf("%-20s %-48s %-48s%n",
- UtilAll.frontStringAtLeast(clusterName, 20),
- UtilAll.frontStringAtLeast(topic, 48),
- UtilAll.frontStringAtLeast(group, 48)
+ UtilAll.frontStringAtLeast(clusterName, 20),
+ UtilAll.frontStringAtLeast(topic, 48),
+ UtilAll.frontStringAtLeast(group, 48)
);
}
}
@@ -121,8 +119,8 @@ public class TopicListSubCommand implements SubCommand {
}
private String findTopicBelongToWhichCluster(final String topic, final ClusterInfo clusterInfo,
- final DefaultMQAdminExt defaultMQAdminExt) throws RemotingException, MQClientException,
- InterruptedException {
+ final DefaultMQAdminExt defaultMQAdminExt) throws RemotingException, MQClientException,
+ InterruptedException {
TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic);
BrokerData brokerData = topicRouteData.getBrokerDatas().get(0);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java
index 6f89b22..b7a180f 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicRouteSubCommand.java
@@ -16,14 +16,13 @@
*/
package org.apache.rocketmq.tools.command.topic;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.common.protocol.route.TopicRouteData;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
/**
*
@@ -36,13 +35,11 @@ public class TopicRouteSubCommand implements SubCommand {
return "topicRoute";
}
-
@Override
public String commandDesc() {
return "Examine topic route info";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("t", "topic", true, "topic name");
@@ -52,7 +49,6 @@ public class TopicRouteSubCommand implements SubCommand {
return options;
}
-
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java
index 73b98c9..76d9cbc 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/TopicStatusSubCommand.java
@@ -6,16 +6,22 @@
* (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
+ * 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.
+ * 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.tools.command.topic;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.admin.TopicOffset;
import org.apache.rocketmq.common.admin.TopicStatsTable;
@@ -23,14 +29,6 @@ import org.apache.rocketmq.common.message.MessageQueue;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
/**
*
@@ -43,13 +41,11 @@ public class TopicStatusSubCommand implements SubCommand {
return "topicStatus";
}
-
@Override
public String commandDesc() {
return "Examine topic Status info";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("t", "topic", true, "topic name");
@@ -58,7 +54,6 @@ public class TopicStatusSubCommand implements SubCommand {
return options;
}
-
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
@@ -75,11 +70,11 @@ public class TopicStatusSubCommand implements SubCommand {
Collections.sort(mqList);
System.out.printf("%-32s %-4s %-20s %-20s %s%n",
- "#Broker Name",
- "#QID",
- "#Min Offset",
- "#Max Offset",
- "#Last Updated"
+ "#Broker Name",
+ "#QID",
+ "#Min Offset",
+ "#Max Offset",
+ "#Last Updated"
);
for (MessageQueue mq : mqList) {
@@ -91,11 +86,11 @@ public class TopicStatusSubCommand implements SubCommand {
}
System.out.printf("%-32s %-4d %-20d %-20d %s%n",
- UtilAll.frontStringAtLeast(mq.getBrokerName(), 32),
- mq.getQueueId(),
- topicOffset.getMinOffset(),
- topicOffset.getMaxOffset(),
- humanTimestamp
+ UtilAll.frontStringAtLeast(mq.getBrokerName(), 32),
+ mq.getQueueId(),
+ topicOffset.getMinOffset(),
+ topicOffset.getMaxOffset(),
+ humanTimestamp
);
}
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateOrderConfCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateOrderConfCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateOrderConfCommand.java
index 4cc88eb..f9f4f1f 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateOrderConfCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateOrderConfCommand.java
@@ -6,26 +6,25 @@
* (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
+ * 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.
+ * 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.tools.command.topic;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.namesrv.NamesrvUtil;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.srvutil.ServerUtil;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
/**
*
@@ -38,13 +37,11 @@ public class UpdateOrderConfCommand implements SubCommand {
return "updateOrderConf";
}
-
@Override
public String commandDesc() {
return "Create or update or delete order conf";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("t", "topic", true, "topic name");
@@ -62,7 +59,6 @@ public class UpdateOrderConfCommand implements SubCommand {
return options;
}
-
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
@@ -76,7 +72,7 @@ public class UpdateOrderConfCommand implements SubCommand {
defaultMQAdminExt.start();
String orderConf =
- defaultMQAdminExt.getKVConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, topic);
+ defaultMQAdminExt.getKVConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, topic);
System.out.printf("get orderConf success. topic=[%s], orderConf=[%s] ", topic, orderConf);
return;
@@ -93,7 +89,7 @@ public class UpdateOrderConfCommand implements SubCommand {
defaultMQAdminExt.createOrUpdateOrderConf(topic, orderConf, true);
System.out.printf("update orderConf success. topic=[%s], orderConf=[%s]", topic,
- orderConf.toString());
+ orderConf.toString());
return;
} else if ("delete".equals(type)) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicPermSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicPermSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicPermSubCommand.java
index cd119a0..fb7ab21 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicPermSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicPermSubCommand.java
@@ -16,6 +16,11 @@
*/
package org.apache.rocketmq.tools.command.topic;
+import java.util.List;
+import java.util.Set;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.common.TopicConfig;
import org.apache.rocketmq.common.protocol.route.QueueData;
import org.apache.rocketmq.common.protocol.route.TopicRouteData;
@@ -24,13 +29,6 @@ import org.apache.rocketmq.srvutil.ServerUtil;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.CommandUtil;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.List;
-import java.util.Set;
-
public class UpdateTopicPermSubCommand implements SubCommand {
@@ -39,13 +37,11 @@ public class UpdateTopicPermSubCommand implements SubCommand {
return "updateTopicPerm";
}
-
@Override
public String commandDesc() {
return "Update topic perm";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("b", "brokerAddr", true, "create topic to which broker");
@@ -67,7 +63,6 @@ public class UpdateTopicPermSubCommand implements SubCommand {
return options;
}
-
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
@@ -106,7 +101,7 @@ public class UpdateTopicPermSubCommand implements SubCommand {
} else if (commandLine.hasOption('c')) {
String clusterName = commandLine.getOptionValue('c').trim();
Set<String> masterSet =
- CommandUtil.fetchMasterAddrByClusterName(defaultMQAdminExt, clusterName);
+ CommandUtil.fetchMasterAddrByClusterName(defaultMQAdminExt, clusterName);
for (String addr : masterSet) {
defaultMQAdminExt.createAndUpdateTopicConfig(addr, topicConfig);
System.out.printf("update topic perm from %s to %s in %s success.%n", oldPerm, perm, addr);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicSubCommand.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicSubCommand.java
index 25dd1f3..d4437b1 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicSubCommand.java
@@ -16,6 +16,10 @@
*/
package org.apache.rocketmq.tools.command.topic;
+import java.util.Set;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
import org.apache.rocketmq.common.TopicConfig;
import org.apache.rocketmq.common.sysflag.TopicSysFlag;
import org.apache.rocketmq.remoting.RPCHook;
@@ -23,12 +27,6 @@ import org.apache.rocketmq.srvutil.ServerUtil;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.apache.rocketmq.tools.command.CommandUtil;
import org.apache.rocketmq.tools.command.SubCommand;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.Set;
-
public class UpdateTopicSubCommand implements SubCommand {
@@ -37,13 +35,11 @@ public class UpdateTopicSubCommand implements SubCommand {
return "updateTopic";
}
-
@Override
public String commandDesc() {
return "Update or create topic";
}
-
@Override
public Options buildCommandlineOptions(Options options) {
Option opt = new Option("b", "brokerAddr", true, "create topic to which broker");
@@ -85,7 +81,6 @@ public class UpdateTopicSubCommand implements SubCommand {
return options;
}
-
@Override
public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) {
DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
@@ -142,7 +137,7 @@ public class UpdateTopicSubCommand implements SubCommand {
String orderConf = brokerName + ":" + topicConfig.getWriteQueueNums();
defaultMQAdminExt.createOrUpdateOrderConf(topicConfig.getTopicName(), orderConf, false);
System.out.printf(String.format("set broker orderConf. isOrder=%s, orderConf=[%s]",
- isOrder, orderConf.toString()));
+ isOrder, orderConf.toString()));
}
System.out.printf("create topic to %s success.%n", addr);
System.out.printf("%s", topicConfig);
@@ -154,7 +149,7 @@ public class UpdateTopicSubCommand implements SubCommand {
defaultMQAdminExt.start();
Set<String> masterSet =
- CommandUtil.fetchMasterAddrByClusterName(defaultMQAdminExt, clusterName);
+ CommandUtil.fetchMasterAddrByClusterName(defaultMQAdminExt, clusterName);
for (String addr : masterSet) {
defaultMQAdminExt.createAndUpdateTopicConfig(addr, topicConfig);
System.out.printf("create topic to %s success.%n", addr);
@@ -162,18 +157,18 @@ public class UpdateTopicSubCommand implements SubCommand {
if (isOrder) {
Set<String> brokerNameSet =
- CommandUtil.fetchBrokerNameByClusterName(defaultMQAdminExt, clusterName);
+ CommandUtil.fetchBrokerNameByClusterName(defaultMQAdminExt, clusterName);
StringBuilder orderConf = new StringBuilder();
String splitor = "";
for (String s : brokerNameSet) {
orderConf.append(splitor).append(s).append(":")
- .append(topicConfig.getWriteQueueNums());
+ .append(topicConfig.getWriteQueueNums());
splitor = ";";
}
defaultMQAdminExt.createOrUpdateOrderConf(topicConfig.getTopicName(),
- orderConf.toString(), true);
+ orderConf.toString(), true);
System.out.printf(String.format("set cluster orderConf. isOrder=%s, orderConf=[%s]",
- isOrder, orderConf.toString()));
+ isOrder, orderConf.toString()));
}
System.out.printf("%s", topicConfig);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/monitor/DefaultMonitorListener.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/monitor/DefaultMonitorListener.java b/tools/src/main/java/org/apache/rocketmq/tools/monitor/DefaultMonitorListener.java
index 9bcb2df..63b81f8 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/monitor/DefaultMonitorListener.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/monitor/DefaultMonitorListener.java
@@ -6,60 +6,52 @@
* (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
+ * 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.
+ * 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.tools.monitor;
-import org.apache.rocketmq.client.log.ClientLogger;
-import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
-import org.slf4j.Logger;
-
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.TreeMap;
-
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
+import org.slf4j.Logger;
public class DefaultMonitorListener implements MonitorListener {
private final static String LOG_PREFIX = "[MONITOR] ";
private final static String LOG_NOTIFY = LOG_PREFIX + " [NOTIFY] ";
private final Logger log = ClientLogger.getLog();
-
public DefaultMonitorListener() {
}
-
@Override
public void beginRound() {
log.info(LOG_PREFIX + "=========================================beginRound");
}
-
@Override
public void reportUndoneMsgs(UndoneMsgs undoneMsgs) {
log.info(String.format(LOG_PREFIX + "reportUndoneMsgs: %s", undoneMsgs));
}
-
@Override
public void reportFailedMsgs(FailedMsgs failedMsgs) {
log.info(String.format(LOG_PREFIX + "reportFailedMsgs: %s", failedMsgs));
}
-
@Override
public void reportDeleteMsgsEvent(DeleteMsgsEvent deleteMsgsEvent) {
log.info(String.format(LOG_PREFIX + "reportDeleteMsgsEvent: %s", deleteMsgsEvent));
}
-
@Override
public void reportConsumerRunningInfo(TreeMap<String, ConsumerRunningInfo> criTable) {
@@ -67,12 +59,11 @@ public class DefaultMonitorListener implements MonitorListener {
boolean result = ConsumerRunningInfo.analyzeSubscription(criTable);
if (!result) {
log.info(String.format(LOG_NOTIFY
- + "reportConsumerRunningInfo: ConsumerGroup: %s, Subscription different", criTable
- .firstEntry().getValue().getProperties().getProperty("consumerGroup")));
+ + "reportConsumerRunningInfo: ConsumerGroup: %s, Subscription different", criTable
+ .firstEntry().getValue().getProperties().getProperty("consumerGroup")));
}
}
-
{
Iterator<Entry<String, ConsumerRunningInfo>> it = criTable.entrySet().iterator();
while (it.hasNext()) {
@@ -80,16 +71,15 @@ public class DefaultMonitorListener implements MonitorListener {
String result = ConsumerRunningInfo.analyzeProcessQueue(next.getKey(), next.getValue());
if (!result.isEmpty()) {
log.info(String.format(LOG_NOTIFY
- + "reportConsumerRunningInfo: ConsumerGroup: %s, ClientId: %s, %s",
- criTable.firstEntry().getValue().getProperties().getProperty("consumerGroup"),
- next.getKey(),
- result));
+ + "reportConsumerRunningInfo: ConsumerGroup: %s, ClientId: %s, %s",
+ criTable.firstEntry().getValue().getProperties().getProperty("consumerGroup"),
+ next.getKey(),
+ result));
}
}
}
}
-
@Override
public void endRound() {
log.info(LOG_PREFIX + "=========================================endRound");
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/monitor/DeleteMsgsEvent.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/monitor/DeleteMsgsEvent.java b/tools/src/main/java/org/apache/rocketmq/tools/monitor/DeleteMsgsEvent.java
index 5db446f..3270286 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/monitor/DeleteMsgsEvent.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/monitor/DeleteMsgsEvent.java
@@ -6,48 +6,42 @@
* (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
+ * 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.
+ * 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.tools.monitor;
import org.apache.rocketmq.common.protocol.topic.OffsetMovedEvent;
-
public class DeleteMsgsEvent {
private OffsetMovedEvent offsetMovedEvent;
private long eventTimestamp;
-
public OffsetMovedEvent getOffsetMovedEvent() {
return offsetMovedEvent;
}
-
public void setOffsetMovedEvent(OffsetMovedEvent offsetMovedEvent) {
this.offsetMovedEvent = offsetMovedEvent;
}
-
public long getEventTimestamp() {
return eventTimestamp;
}
-
public void setEventTimestamp(long eventTimestamp) {
this.eventTimestamp = eventTimestamp;
}
-
@Override
public String toString() {
return "DeleteMsgsEvent [offsetMovedEvent=" + offsetMovedEvent + ", eventTimestamp=" + eventTimestamp
- + "]";
+ + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/monitor/FailedMsgs.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/monitor/FailedMsgs.java b/tools/src/main/java/org/apache/rocketmq/tools/monitor/FailedMsgs.java
index 4c4e91c..bf63984 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/monitor/FailedMsgs.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/monitor/FailedMsgs.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.tools.monitor;
@@ -22,40 +22,33 @@ public class FailedMsgs {
private String topic;
private long failedMsgsTotalRecently;
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public long getFailedMsgsTotalRecently() {
return failedMsgsTotalRecently;
}
-
public void setFailedMsgsTotalRecently(long failedMsgsTotalRecently) {
this.failedMsgsTotalRecently = failedMsgsTotalRecently;
}
-
@Override
public String toString() {
return "FailedMsgs [consumerGroup=" + consumerGroup + ", topic=" + topic
- + ", failedMsgsTotalRecently=" + failedMsgsTotalRecently + "]";
+ + ", failedMsgsTotalRecently=" + failedMsgsTotalRecently + "]";
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/monitor/MonitorConfig.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/monitor/MonitorConfig.java b/tools/src/main/java/org/apache/rocketmq/tools/monitor/MonitorConfig.java
index fbe6c3c..e60d317 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/monitor/MonitorConfig.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/monitor/MonitorConfig.java
@@ -6,42 +6,37 @@
* (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
+ * 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.
+ * 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.tools.monitor;
import org.apache.rocketmq.common.MixAll;
-
public class MonitorConfig {
private String namesrvAddr = System.getProperty(MixAll.NAMESRV_ADDR_PROPERTY,
- System.getenv(MixAll.NAMESRV_ADDR_ENV));
+ System.getenv(MixAll.NAMESRV_ADDR_ENV));
private int roundInterval = 1000 * 60;
-
public String getNamesrvAddr() {
return namesrvAddr;
}
-
public void setNamesrvAddr(String namesrvAddr) {
this.namesrvAddr = namesrvAddr;
}
-
public int getRoundInterval() {
return roundInterval;
}
-
public void setRoundInterval(int roundInterval) {
this.roundInterval = roundInterval;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/monitor/MonitorListener.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/monitor/MonitorListener.java b/tools/src/main/java/org/apache/rocketmq/tools/monitor/MonitorListener.java
index a60a273..17f85ce 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/monitor/MonitorListener.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/monitor/MonitorListener.java
@@ -17,9 +17,8 @@
package org.apache.rocketmq.tools.monitor;
-import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
-
import java.util.TreeMap;
+import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
public interface MonitorListener {
void beginRound();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/monitor/MonitorService.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/monitor/MonitorService.java b/tools/src/main/java/org/apache/rocketmq/tools/monitor/MonitorService.java
index 8c368fe..d9c4cf8 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/monitor/MonitorService.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/monitor/MonitorService.java
@@ -6,17 +6,26 @@
* (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
+ * 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.
+ * 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.tools.monitor;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Random;
+import java.util.TreeMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
import org.apache.rocketmq.client.consumer.DefaultMQPullConsumer;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.consumer.PullResult;
@@ -43,17 +52,10 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
import org.slf4j.Logger;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-
public class MonitorService {
private final Logger log = ClientLogger.getLog();
private final ScheduledExecutorService scheduledExecutorService = Executors
- .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("MonitorService"));
+ .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("MonitorService"));
private final MonitorConfig monitorConfig;
@@ -61,10 +63,9 @@ public class MonitorService {
private final DefaultMQAdminExt defaultMQAdminExt;
private final DefaultMQPullConsumer defaultMQPullConsumer = new DefaultMQPullConsumer(
- MixAll.TOOLS_CONSUMER_GROUP);
+ MixAll.TOOLS_CONSUMER_GROUP);
private final DefaultMQPushConsumer defaultMQPushConsumer = new DefaultMQPushConsumer(
- MixAll.MONITOR_CONSUMER_GROUP);
-
+ MixAll.MONITOR_CONSUMER_GROUP);
public MonitorService(MonitorConfig monitorConfig, MonitorListener monitorListener, RPCHook rpcHook) {
this.monitorConfig = monitorConfig;
@@ -87,10 +88,10 @@ public class MonitorService {
@Override
public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
- ConsumeConcurrentlyContext context) {
+ ConsumeConcurrentlyContext context) {
try {
OffsetMovedEvent ome =
- OffsetMovedEvent.decode(msgs.get(0).getBody(), OffsetMovedEvent.class);
+ OffsetMovedEvent.decode(msgs.get(0).getBody(), OffsetMovedEvent.class);
DeleteMsgsEvent deleteMsgsEvent = new DeleteMsgsEvent();
deleteMsgsEvent.setOffsetMovedEvent(ome);
@@ -107,27 +108,18 @@ public class MonitorService {
}
}
-
- private String instanceName() {
- String name =
- System.currentTimeMillis() + new Random().nextInt() + this.monitorConfig.getNamesrvAddr();
-
- return "MonitorService_" + name.hashCode();
- }
-
public static void main(String[] args) throws MQClientException {
main0(args, null);
}
public static void main0(String[] args, RPCHook rpcHook) throws MQClientException {
final MonitorService monitorService =
- new MonitorService(new MonitorConfig(), new DefaultMonitorListener(), rpcHook);
+ new MonitorService(new MonitorConfig(), new DefaultMonitorListener(), rpcHook);
monitorService.start();
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
private volatile boolean hasShutdown = false;
-
@Override
public void run() {
synchronized (this) {
@@ -140,6 +132,13 @@ public class MonitorService {
}, "ShutdownHook"));
}
+ private String instanceName() {
+ String name =
+ System.currentTimeMillis() + new Random().nextInt() + this.monitorConfig.getNamesrvAddr();
+
+ return "MonitorService_" + name.hashCode();
+ }
+
public void start() throws MQClientException {
this.defaultMQPullConsumer.start();
this.defaultMQAdminExt.start();
@@ -181,7 +180,6 @@ public class MonitorService {
// log.error("reportUndoneMsgs Exception", e);
}
-
try {
this.reportConsumerRunningInfo(consumerGroup);
} catch (Exception e) {
@@ -228,7 +226,6 @@ public class MonitorService {
}
}
-
{
Iterator<Entry<String, ConsumeStats>> it = csByTopic.entrySet().iterator();
while (it.hasNext()) {
@@ -245,7 +242,7 @@ public class MonitorService {
}
public void reportConsumerRunningInfo(final String consumerGroup) throws InterruptedException,
- MQBrokerException, RemotingException, MQClientException {
+ MQBrokerException, RemotingException, MQClientException {
ConsumerConnection cc = defaultMQAdminExt.examineConsumerConnectionInfo(consumerGroup);
TreeMap<String, ConsumerRunningInfo> infoMap = new TreeMap<String, ConsumerRunningInfo>();
for (Connection c : cc.getConnectionSet()) {
@@ -257,7 +254,7 @@ public class MonitorService {
try {
ConsumerRunningInfo info =
- defaultMQAdminExt.getConsumerRunningInfo(consumerGroup, clientId, false);
+ defaultMQAdminExt.getConsumerRunningInfo(consumerGroup, clientId, false);
infoMap.put(clientId, info);
} catch (Exception e) {
}
@@ -296,7 +293,7 @@ public class MonitorService {
switch (pull.getPullStatus()) {
case FOUND:
long delay =
- pull.getMsgFoundList().get(0).getStoreTimestamp() - ow.getLastTimestamp();
+ pull.getMsgFoundList().get(0).getStoreTimestamp() - ow.getLastTimestamp();
if (delay > delayMax) {
delayMax = delay;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/tools/src/main/java/org/apache/rocketmq/tools/monitor/UndoneMsgs.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/monitor/UndoneMsgs.java b/tools/src/main/java/org/apache/rocketmq/tools/monitor/UndoneMsgs.java
index ac549af..abc0cb9 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/monitor/UndoneMsgs.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/monitor/UndoneMsgs.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.tools.monitor;
@@ -27,61 +27,50 @@ public class UndoneMsgs {
private long undoneMsgsDelayTimeMills;
-
public String getConsumerGroup() {
return consumerGroup;
}
-
public void setConsumerGroup(String consumerGroup) {
this.consumerGroup = consumerGroup;
}
-
public String getTopic() {
return topic;
}
-
public void setTopic(String topic) {
this.topic = topic;
}
-
public long getUndoneMsgsTotal() {
return undoneMsgsTotal;
}
-
public void setUndoneMsgsTotal(long undoneMsgsTotal) {
this.undoneMsgsTotal = undoneMsgsTotal;
}
-
public long getUndoneMsgsSingleMQ() {
return undoneMsgsSingleMQ;
}
-
public void setUndoneMsgsSingleMQ(long undoneMsgsSingleMQ) {
this.undoneMsgsSingleMQ = undoneMsgsSingleMQ;
}
-
public long getUndoneMsgsDelayTimeMills() {
return undoneMsgsDelayTimeMills;
}
-
public void setUndoneMsgsDelayTimeMills(long undoneMsgsDelayTimeMills) {
this.undoneMsgsDelayTimeMills = undoneMsgsDelayTimeMills;
}
-
@Override
public String toString() {
return "UndoneMsgs [consumerGroup=" + consumerGroup + ", topic=" + topic + ", undoneMsgsTotal="
- + undoneMsgsTotal + ", undoneMsgsSingleMQ=" + undoneMsgsSingleMQ
- + ", undoneMsgsDelayTimeMills=" + undoneMsgsDelayTimeMills + "]";
+ + undoneMsgsTotal + ", undoneMsgsSingleMQ=" + undoneMsgsSingleMQ
+ + ", undoneMsgsDelayTimeMills=" + undoneMsgsDelayTimeMills + "]";
}
}
[97/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Fix the
conflicts between code and check style.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
index 4954f6f..055d5b7 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetSerializeWrapper.java
@@ -23,7 +23,6 @@ import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
/**
* Wrapper class for offset serialization
- *
*/
public class OffsetSerializeWrapper extends RemotingSerializable {
private ConcurrentHashMap<MessageQueue, AtomicLong> offsetTable =
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
index 592796f..00008e5 100644
--- a/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
+++ b/client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
@@ -25,7 +25,6 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
/**
* Offset store interface
- *
*/
public interface OffsetStore {
/**
@@ -49,7 +48,6 @@ public interface OffsetStore {
*
* @param mq
* @param type
- *
* @return The fetched offset
*/
long readOffset(final MessageQueue mq, final ReadOffsetType type);
@@ -77,13 +75,11 @@ public interface OffsetStore {
/**
* @param topic
- *
* @return The cloned offset table of given topic
*/
Map<MessageQueue, Long> cloneOffsetTable(String topic);
/**
- *
* @param mq
* @param offset
* @param isOneway
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java b/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
index 46ce08c..5486229 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
@@ -84,7 +84,7 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
public RemotingCommand checkTransactionState(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final CheckTransactionStateRequestHeader requestHeader =
- (CheckTransactionStateRequestHeader)request.decodeCommandCustomHeader(CheckTransactionStateRequestHeader.class);
+ (CheckTransactionStateRequestHeader) request.decodeCommandCustomHeader(CheckTransactionStateRequestHeader.class);
final ByteBuffer byteBuffer = ByteBuffer.wrap(request.getBody());
final MessageExt messageExt = MessageDecoder.decode(byteBuffer);
if (messageExt != null) {
@@ -110,7 +110,7 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
public RemotingCommand notifyConsumerIdsChanged(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
try {
final NotifyConsumerIdsChangedRequestHeader requestHeader =
- (NotifyConsumerIdsChangedRequestHeader)request.decodeCommandCustomHeader(NotifyConsumerIdsChangedRequestHeader.class);
+ (NotifyConsumerIdsChangedRequestHeader) request.decodeCommandCustomHeader(NotifyConsumerIdsChangedRequestHeader.class);
log.info("receive broker's notification[{}], the consumer group: {} changed, rebalance immediately",
RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
requestHeader.getConsumerGroup());
@@ -123,7 +123,7 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
public RemotingCommand resetOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final ResetOffsetRequestHeader requestHeader =
- (ResetOffsetRequestHeader)request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
+ (ResetOffsetRequestHeader) request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
log.info("invoke reset offset operation from broker. brokerAddr={}, topic={}, group={}, timestamp={}",
new Object[] {
RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
@@ -141,7 +141,7 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
public RemotingCommand getConsumeStatus(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetConsumerStatusRequestHeader requestHeader =
- (GetConsumerStatusRequestHeader)request.decodeCommandCustomHeader(GetConsumerStatusRequestHeader.class);
+ (GetConsumerStatusRequestHeader) request.decodeCommandCustomHeader(GetConsumerStatusRequestHeader.class);
Map<MessageQueue, Long> offsetTable = this.mqClientFactory.getConsumerStatus(requestHeader.getTopic(), requestHeader.getGroup());
GetConsumerStatusBody body = new GetConsumerStatusBody();
@@ -154,7 +154,7 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final GetConsumerRunningInfoRequestHeader requestHeader =
- (GetConsumerRunningInfoRequestHeader)request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);
+ (GetConsumerRunningInfoRequestHeader) request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);
ConsumerRunningInfo consumerRunningInfo = this.mqClientFactory.consumerRunningInfo(requestHeader.getConsumerGroup());
if (null != consumerRunningInfo) {
@@ -177,7 +177,7 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
private RemotingCommand consumeMessageDirectly(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final ConsumeMessageDirectlyResultRequestHeader requestHeader =
- (ConsumeMessageDirectlyResultRequestHeader)request
+ (ConsumeMessageDirectlyResultRequestHeader) request
.decodeCommandCustomHeader(ConsumeMessageDirectlyResultRequestHeader.class);
final MessageExt msg = MessageDecoder.decode(ByteBuffer.wrap(request.getBody()));
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
index 5fdcab2..79338b0 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
@@ -307,7 +307,7 @@ public class MQAdminImpl {
QueryMessageResponseHeader responseHeader = null;
try {
responseHeader =
- (QueryMessageResponseHeader)response
+ (QueryMessageResponseHeader) response
.decodeCommandCustomHeader(QueryMessageResponseHeader.class);
} catch (RemotingCommandException e) {
log.error("decodeCommandCustomHeader exception", e);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
index 2dd9200..73dfcc5 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
@@ -505,7 +505,7 @@ public class MQClientAPIImpl {
}
SendMessageResponseHeader responseHeader =
- (SendMessageResponseHeader)response.decodeCommandCustomHeader(SendMessageResponseHeader.class);
+ (SendMessageResponseHeader) response.decodeCommandCustomHeader(SendMessageResponseHeader.class);
MessageQueue messageQueue = new MessageQueue(msg.getTopic(), brokerName, responseHeader.getQueueId());
@@ -622,7 +622,7 @@ public class MQClientAPIImpl {
}
PullMessageResponseHeader responseHeader =
- (PullMessageResponseHeader)response.decodeCommandCustomHeader(PullMessageResponseHeader.class);
+ (PullMessageResponseHeader) response.decodeCommandCustomHeader(PullMessageResponseHeader.class);
return new PullResultExt(pullStatus, responseHeader.getNextBeginOffset(), responseHeader.getMinOffset(),
responseHeader.getMaxOffset(), null, responseHeader.getSuggestWhichBrokerId(), response.getBody());
@@ -664,7 +664,7 @@ public class MQClientAPIImpl {
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
SearchOffsetResponseHeader responseHeader =
- (SearchOffsetResponseHeader)response.decodeCommandCustomHeader(SearchOffsetResponseHeader.class);
+ (SearchOffsetResponseHeader) response.decodeCommandCustomHeader(SearchOffsetResponseHeader.class);
return responseHeader.getOffset();
}
default:
@@ -687,7 +687,7 @@ public class MQClientAPIImpl {
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
GetMaxOffsetResponseHeader responseHeader =
- (GetMaxOffsetResponseHeader)response.decodeCommandCustomHeader(GetMaxOffsetResponseHeader.class);
+ (GetMaxOffsetResponseHeader) response.decodeCommandCustomHeader(GetMaxOffsetResponseHeader.class);
return responseHeader.getOffset();
}
@@ -738,7 +738,7 @@ public class MQClientAPIImpl {
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
GetMinOffsetResponseHeader responseHeader =
- (GetMinOffsetResponseHeader)response.decodeCommandCustomHeader(GetMinOffsetResponseHeader.class);
+ (GetMinOffsetResponseHeader) response.decodeCommandCustomHeader(GetMinOffsetResponseHeader.class);
return responseHeader.getOffset();
}
@@ -762,7 +762,7 @@ public class MQClientAPIImpl {
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
GetEarliestMsgStoretimeResponseHeader responseHeader =
- (GetEarliestMsgStoretimeResponseHeader)response.decodeCommandCustomHeader(GetEarliestMsgStoretimeResponseHeader.class);
+ (GetEarliestMsgStoretimeResponseHeader) response.decodeCommandCustomHeader(GetEarliestMsgStoretimeResponseHeader.class);
return responseHeader.getTimestamp();
}
@@ -786,7 +786,7 @@ public class MQClientAPIImpl {
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
QueryConsumerOffsetResponseHeader responseHeader =
- (QueryConsumerOffsetResponseHeader)response.decodeCommandCustomHeader(QueryConsumerOffsetResponseHeader.class);
+ (QueryConsumerOffsetResponseHeader) response.decodeCommandCustomHeader(QueryConsumerOffsetResponseHeader.class);
return responseHeader.getOffset();
}
@@ -1249,7 +1249,7 @@ public class MQClientAPIImpl {
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
WipeWritePermOfBrokerResponseHeader responseHeader =
- (WipeWritePermOfBrokerResponseHeader)response.decodeCommandCustomHeader(WipeWritePermOfBrokerResponseHeader.class);
+ (WipeWritePermOfBrokerResponseHeader) response.decodeCommandCustomHeader(WipeWritePermOfBrokerResponseHeader.class);
return responseHeader.getWipeTopicCount();
}
default:
@@ -1331,7 +1331,7 @@ public class MQClientAPIImpl {
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
GetKVConfigResponseHeader responseHeader =
- (GetKVConfigResponseHeader)response.decodeCommandCustomHeader(GetKVConfigResponseHeader.class);
+ (GetKVConfigResponseHeader) response.decodeCommandCustomHeader(GetKVConfigResponseHeader.class);
return responseHeader.getValue();
}
default:
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
index c22c515..f036b83 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
@@ -581,11 +581,11 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
if (this.getMessageListenerInner() instanceof MessageListenerOrderly) {
this.consumeOrderly = true;
this.consumeMessageService =
- new ConsumeMessageOrderlyService(this, (MessageListenerOrderly)this.getMessageListenerInner());
+ new ConsumeMessageOrderlyService(this, (MessageListenerOrderly) this.getMessageListenerInner());
} else if (this.getMessageListenerInner() instanceof MessageListenerConcurrently) {
this.consumeOrderly = false;
this.consumeMessageService =
- new ConsumeMessageConcurrentlyService(this, (MessageListenerConcurrently)this.getMessageListenerInner());
+ new ConsumeMessageConcurrentlyService(this, (MessageListenerConcurrently) this.getMessageListenerInner());
}
this.consumeMessageService.start();
@@ -1024,9 +1024,9 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
long computeAccTotal = this.computeAccumulationTotal();
long adjustThreadPoolNumsThreshold = this.defaultMQPushConsumer.getAdjustThreadPoolNumsThreshold();
- long incThreshold = (long)(adjustThreadPoolNumsThreshold * 1.0);
+ long incThreshold = (long) (adjustThreadPoolNumsThreshold * 1.0);
- long decThreshold = (long)(adjustThreadPoolNumsThreshold * 0.8);
+ long decThreshold = (long) (adjustThreadPoolNumsThreshold * 0.8);
if (computeAccTotal >= incThreshold) {
this.consumeMessageService.incCorePoolSize();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
index ce4f2b9..76784be 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
@@ -26,7 +26,6 @@ import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
/**
* Consumer inner interface
- *
*/
public interface MQConsumerInner {
String groupName();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
index 47ae2b0..9b3ab9f 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
@@ -21,7 +21,6 @@ import org.apache.rocketmq.common.message.MessageQueue;
/**
* Message lock,strictly ensure the single queue only one thread at a time consuming
- *
*/
public class MessageQueueLock {
private ConcurrentHashMap<MessageQueue, Object> mqLockTable =
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
index 2d17703..641b6c6 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
@@ -35,7 +35,6 @@ import org.slf4j.Logger;
/**
* Queue consumption snapshot
- *
*/
public class ProcessQueue {
public final static long REBALANCE_LOCK_MAX_LIVE_TIME =
@@ -69,8 +68,6 @@ public class ProcessQueue {
}
/**
-
- *
* @param pushConsumer
*/
public void cleanExpiredMsg(DefaultMQPushConsumer pushConsumer) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
index d358175..9cea5db 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
@@ -66,7 +66,7 @@ public class PullAPIWrapper {
public PullResult processPullResult(final MessageQueue mq, final PullResult pullResult,
final SubscriptionData subscriptionData) {
- PullResultExt pullResultExt = (PullResultExt)pullResult;
+ PullResultExt pullResultExt = (PullResultExt) pullResult;
this.updatePullFromWhichNode(mq, pullResultExt.getSuggestWhichBrokerId());
if (PullStatus.FOUND == pullResult.getPullStatus()) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
index 55e3d59..5cc052a 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
@@ -71,7 +71,7 @@ public class PullMessageService extends ServiceThread {
private void pullMessage(final PullRequest pullRequest) {
final MQConsumerInner consumer = this.mQClientFactory.selectConsumer(pullRequest.getConsumerGroup());
if (consumer != null) {
- DefaultMQPushConsumerImpl impl = (DefaultMQPushConsumerImpl)consumer;
+ DefaultMQPushConsumerImpl impl = (DefaultMQPushConsumerImpl) consumer;
impl.pullMessage(pullRequest);
} else {
log.warn("No matched consumer for the PullRequest {}, drop it", pullRequest);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
index 4850313..7a11d5f 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullRequest.java
@@ -74,7 +74,7 @@ public class PullRequest {
return false;
if (getClass() != obj.getClass())
return false;
- PullRequest other = (PullRequest)obj;
+ PullRequest other = (PullRequest) obj;
if (consumerGroup == null) {
if (other.consumerGroup != null)
return false;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
index 985129e..7c2d3af 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceService.java
@@ -23,7 +23,6 @@ import org.slf4j.Logger;
/**
* Rebalance Service
- *
*/
public class RebalanceService extends ServiceThread {
private static long waitInterval =
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java b/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
index 42b7a82..271199a 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
@@ -436,7 +436,7 @@ public class MQClientInstance {
if (impl != null) {
try {
if (impl instanceof DefaultMQPushConsumerImpl) {
- DefaultMQPushConsumerImpl dmq = (DefaultMQPushConsumerImpl)impl;
+ DefaultMQPushConsumerImpl dmq = (DefaultMQPushConsumerImpl) impl;
dmq.adjustThreadPool();
}
} catch (Exception e) {
@@ -1026,7 +1026,7 @@ public class MQClientInstance {
try {
MQConsumerInner impl = this.consumerTable.get(group);
if (impl != null && impl instanceof DefaultMQPushConsumerImpl) {
- consumer = (DefaultMQPushConsumerImpl)impl;
+ consumer = (DefaultMQPushConsumerImpl) impl;
} else {
log.info("[reset-offset] consumer dose not exist. group={}", group);
return;
@@ -1071,10 +1071,10 @@ public class MQClientInstance {
public Map<MessageQueue, Long> getConsumerStatus(String topic, String group) {
MQConsumerInner impl = this.consumerTable.get(group);
if (impl != null && impl instanceof DefaultMQPushConsumerImpl) {
- DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl)impl;
+ DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) impl;
return consumer.getOffsetStore().cloneOffsetTable(topic);
} else if (impl != null && impl instanceof DefaultMQPullConsumerImpl) {
- DefaultMQPullConsumerImpl consumer = (DefaultMQPullConsumerImpl)impl;
+ DefaultMQPullConsumerImpl consumer = (DefaultMQPullConsumerImpl) impl;
return consumer.getOffsetStore().cloneOffsetTable(topic);
} else {
return Collections.EMPTY_MAP;
@@ -1118,7 +1118,7 @@ public class MQClientInstance {
final String brokerName) {
MQConsumerInner mqConsumerInner = this.consumerTable.get(consumerGroup);
if (null != mqConsumerInner) {
- DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl)mqConsumerInner;
+ DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) mqConsumerInner;
ConsumeMessageDirectlyResult result = consumer.getConsumeMessageService().consumeMessageDirectly(msg, brokerName);
return result;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
index 42bf360..e588278 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
@@ -112,7 +112,7 @@ public class DefaultMQProducerImpl implements MQProducerInner {
}
public void initTransactionEnv() {
- TransactionMQProducer producer = (TransactionMQProducer)this.defaultMQProducer;
+ TransactionMQProducer producer = (TransactionMQProducer) this.defaultMQProducer;
this.checkRequestQueue = new LinkedBlockingQueue<Runnable>(producer.getCheckRequestHoldMax());
this.checkExecutor = new ThreadPoolExecutor(//
producer.getCheckThreadPoolMinSize(), //
@@ -238,7 +238,7 @@ public class DefaultMQProducerImpl implements MQProducerInner {
@Override
public TransactionCheckListener checkListener() {
if (this.defaultMQProducer instanceof TransactionMQProducer) {
- TransactionMQProducer producer = (TransactionMQProducer)defaultMQProducer;
+ TransactionMQProducer producer = (TransactionMQProducer) defaultMQProducer;
return producer.getTransactionCheckListener();
}
@@ -538,7 +538,7 @@ public class DefaultMQProducerImpl implements MQProducerInner {
MQClientException mqClientException = new MQClientException(info, exception);
if (exception instanceof MQBrokerException) {
- mqClientException.setResponseCode(((MQBrokerException)exception).getResponseCode());
+ mqClientException.setResponseCode(((MQBrokerException) exception).getResponseCode());
} else if (exception instanceof RemotingConnectException) {
mqClientException.setResponseCode(ClientErrorCode.CONNECT_BROKER_EXCEPTION);
} else if (exception instanceof RemotingTimeoutException) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java b/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
index b61d855..7df4b24 100644
--- a/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
@@ -137,8 +137,8 @@ public class LatencyFaultToleranceImpl implements LatencyFaultTolerance<String>
@Override
public int hashCode() {
int result = getName() != null ? getName().hashCode() : 0;
- result = 31 * result + (int)(getCurrentLatency() ^ (getCurrentLatency() >>> 32));
- result = 31 * result + (int)(getStartTimestamp() ^ (getStartTimestamp() >>> 32));
+ result = 31 * result + (int) (getCurrentLatency() ^ (getCurrentLatency() >>> 32));
+ result = 31 * result + (int) (getStartTimestamp() ^ (getStartTimestamp() >>> 32));
return result;
}
@@ -149,7 +149,7 @@ public class LatencyFaultToleranceImpl implements LatencyFaultTolerance<String>
if (!(o instanceof FaultItem))
return false;
- final FaultItem faultItem = (FaultItem)o;
+ final FaultItem faultItem = (FaultItem) o;
if (getCurrentLatency() != faultItem.getCurrentLatency())
return false;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/client/src/main/java/org/apache/rocketmq/client/stat/ConsumerStatsManager.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/stat/ConsumerStatsManager.java b/client/src/main/java/org/apache/rocketmq/client/stat/ConsumerStatsManager.java
index c723951..6b8b76e 100644
--- a/client/src/main/java/org/apache/rocketmq/client/stat/ConsumerStatsManager.java
+++ b/client/src/main/java/org/apache/rocketmq/client/stat/ConsumerStatsManager.java
@@ -62,23 +62,23 @@ public class ConsumerStatsManager {
}
public void incPullRT(final String group, final String topic, final long rt) {
- this.topicAndGroupPullRT.addValue(topic + "@" + group, (int)rt, 1);
+ this.topicAndGroupPullRT.addValue(topic + "@" + group, (int) rt, 1);
}
public void incPullTPS(final String group, final String topic, final long msgs) {
- this.topicAndGroupPullTPS.addValue(topic + "@" + group, (int)msgs, 1);
+ this.topicAndGroupPullTPS.addValue(topic + "@" + group, (int) msgs, 1);
}
public void incConsumeRT(final String group, final String topic, final long rt) {
- this.topicAndGroupConsumeRT.addValue(topic + "@" + group, (int)rt, 1);
+ this.topicAndGroupConsumeRT.addValue(topic + "@" + group, (int) rt, 1);
}
public void incConsumeOKTPS(final String group, final String topic, final long msgs) {
- this.topicAndGroupConsumeOKTPS.addValue(topic + "@" + group, (int)msgs, 1);
+ this.topicAndGroupConsumeOKTPS.addValue(topic + "@" + group, (int) msgs, 1);
}
public void incConsumeFailedTPS(final String group, final String topic, final long msgs) {
- this.topicAndGroupConsumeFailedTPS.addValue(topic + "@" + group, (int)msgs, 1);
+ this.topicAndGroupConsumeFailedTPS.addValue(topic + "@" + group, (int) msgs, 1);
}
public ConsumeStatus consumeStatus(final String group, final String topic) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/Configuration.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/Configuration.java b/common/src/main/java/org/apache/rocketmq/common/Configuration.java
index 5402057..187e42b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/Configuration.java
+++ b/common/src/main/java/org/apache/rocketmq/common/Configuration.java
@@ -119,7 +119,6 @@ public class Configuration {
*
* @param object
* @param fieldName
- *
* @throws java.lang.RuntimeException if the field of object is not exist.
*/
public void setStorePathFromConfig(Object object, String fieldName) {
@@ -156,7 +155,7 @@ public class Configuration {
if (this.storePathFromConfig) {
try {
- realStorePath = (String)storePathField.get(this.storePathObject);
+ realStorePath = (String) storePathField.get(this.storePathObject);
} catch (IllegalAccessException e) {
log.error("getStorePath error, ", e);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java b/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java
index c3e3372..8c416e6 100644
--- a/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java
+++ b/common/src/main/java/org/apache/rocketmq/common/CountDownLatch2.java
@@ -176,7 +176,7 @@ public class CountDownLatch2 {
protected boolean tryReleaseShared(int releases) {
// Decrement count; signal when transition to zero
- for (; ; ) {
+ for (;;) {
int c = getState();
if (c == 0)
return false;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/DataVersion.java b/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
index f3e4615..2c3d349 100644
--- a/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
+++ b/common/src/main/java/org/apache/rocketmq/common/DataVersion.java
@@ -56,7 +56,7 @@ public class DataVersion extends RemotingSerializable {
if (o == null || getClass() != o.getClass())
return false;
- final DataVersion that = (DataVersion)o;
+ final DataVersion that = (DataVersion) o;
if (timestatmp != that.timestatmp)
return false;
@@ -66,7 +66,7 @@ public class DataVersion extends RemotingSerializable {
@Override
public int hashCode() {
- int result = (int)(timestatmp ^ (timestatmp >>> 32));
+ int result = (int) (timestatmp ^ (timestatmp >>> 32));
result = 31 * result + (counter != null ? counter.hashCode() : 0);
return result;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/MixAll.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/MixAll.java b/common/src/main/java/org/apache/rocketmq/common/MixAll.java
index 8307dd5..b235859 100644
--- a/common/src/main/java/org/apache/rocketmq/common/MixAll.java
+++ b/common/src/main/java/org/apache/rocketmq/common/MixAll.java
@@ -186,7 +186,7 @@ public class MixAll {
public static final String file2String(final File file) {
if (file.exists()) {
- char[] data = new char[(int)file.length()];
+ char[] data = new char[(int) file.length()];
boolean result = false;
FileReader fileReader = null;
@@ -442,7 +442,7 @@ public class MixAll {
int unit = si ? 1000 : 1024;
if (bytes < unit)
return bytes + " B";
- int exp = (int)(Math.log(bytes) / Math.log(unit));
+ int exp = (int) (Math.log(bytes) / Math.log(unit));
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i");
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java b/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
index 2582b9f..4a1f6b2 100644
--- a/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
+++ b/common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
@@ -151,7 +151,7 @@ public class TopicConfig {
if (o == null || getClass() != o.getClass())
return false;
- final TopicConfig that = (TopicConfig)o;
+ final TopicConfig that = (TopicConfig) o;
if (readQueueNums != that.readQueueNums)
return false;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
index 54bcdef..e926707 100644
--- a/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
+++ b/common/src/main/java/org/apache/rocketmq/common/UtilAll.java
@@ -193,7 +193,7 @@ public class UtilAll {
long freeSpace = file.getFreeSpace();
long usedSpace = totalSpace - freeSpace;
if (totalSpace > 0) {
- return usedSpace / (double)totalSpace;
+ return usedSpace / (double) totalSpace;
}
} catch (Exception e) {
return -1;
@@ -213,7 +213,7 @@ public class UtilAll {
public static final int crc32(byte[] array, int offset, int length) {
CRC32 crc32 = new CRC32();
crc32.update(array, offset, length);
- return (int)(crc32.getValue() & 0x7FFFFFFF);
+ return (int) (crc32.getValue() & 0x7FFFFFFF);
}
public static String bytes2string(byte[] src) {
@@ -236,13 +236,13 @@ public class UtilAll {
byte[] d = new byte[length];
for (int i = 0; i < length; i++) {
int pos = i * 2;
- d[i] = (byte)(charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
+ d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
}
return d;
}
private static byte charToByte(char c) {
- return (byte)"0123456789ABCDEF".indexOf(c);
+ return (byte) "0123456789ABCDEF".indexOf(c);
}
public static byte[] uncompress(final byte[] src) throws IOException {
@@ -400,15 +400,15 @@ public class UtilAll {
//10.0.0.0~10.255.255.255
//172.16.0.0~172.31.255.255
//192.168.0.0~192.168.255.255
- if (ip[0] == (byte)10) {
+ if (ip[0] == (byte) 10) {
return true;
- } else if (ip[0] == (byte)172) {
- if (ip[1] >= (byte)16 && ip[1] <= (byte)31) {
+ } else if (ip[0] == (byte) 172) {
+ if (ip[1] >= (byte) 16 && ip[1] <= (byte) 31) {
return true;
}
- } else if (ip[0] == (byte)192) {
- if (ip[1] == (byte)168) {
+ } else if (ip[0] == (byte) 192) {
+ if (ip[1] == (byte) 168) {
return true;
}
}
@@ -423,27 +423,27 @@ public class UtilAll {
// if (ip[0] == (byte)30 && ip[1] == (byte)10 && ip[2] == (byte)163 && ip[3] == (byte)120) {
// }
- if (ip[0] >= (byte)1 && ip[0] <= (byte)126) {
- if (ip[1] == (byte)1 && ip[2] == (byte)1 && ip[3] == (byte)1) {
+ if (ip[0] >= (byte) 1 && ip[0] <= (byte) 126) {
+ if (ip[1] == (byte) 1 && ip[2] == (byte) 1 && ip[3] == (byte) 1) {
return false;
}
- if (ip[1] == (byte)0 && ip[2] == (byte)0 && ip[3] == (byte)0) {
+ if (ip[1] == (byte) 0 && ip[2] == (byte) 0 && ip[3] == (byte) 0) {
return false;
}
return true;
- } else if (ip[0] >= (byte)128 && ip[0] <= (byte)191) {
- if (ip[2] == (byte)1 && ip[3] == (byte)1) {
+ } else if (ip[0] >= (byte) 128 && ip[0] <= (byte) 191) {
+ if (ip[2] == (byte) 1 && ip[3] == (byte) 1) {
return false;
}
- if (ip[2] == (byte)0 && ip[3] == (byte)0) {
+ if (ip[2] == (byte) 0 && ip[3] == (byte) 0) {
return false;
}
return true;
- } else if (ip[0] >= (byte)192 && ip[0] <= (byte)223) {
- if (ip[3] == (byte)1) {
+ } else if (ip[0] >= (byte) 192 && ip[0] <= (byte) 223) {
+ if (ip[3] == (byte) 1) {
return false;
}
- if (ip[3] == (byte)0) {
+ if (ip[3] == (byte) 0) {
return false;
}
return true;
@@ -466,10 +466,10 @@ public class UtilAll {
InetAddress ip = null;
byte[] internalIP = null;
while (allNetInterfaces.hasMoreElements()) {
- NetworkInterface netInterface = (NetworkInterface)allNetInterfaces.nextElement();
+ NetworkInterface netInterface = (NetworkInterface) allNetInterfaces.nextElement();
Enumeration addresses = netInterface.getInetAddresses();
while (addresses.hasMoreElements()) {
- ip = (InetAddress)addresses.nextElement();
+ ip = (InetAddress) addresses.nextElement();
if (ip != null && ip instanceof Inet4Address) {
byte[] ipByte = ip.getAddress();
if (ipByte.length == 4) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/filter/impl/PolishExpr.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/filter/impl/PolishExpr.java b/common/src/main/java/org/apache/rocketmq/common/filter/impl/PolishExpr.java
index 2b89944..733eb6d 100644
--- a/common/src/main/java/org/apache/rocketmq/common/filter/impl/PolishExpr.java
+++ b/common/src/main/java/org/apache/rocketmq/common/filter/impl/PolishExpr.java
@@ -49,7 +49,7 @@ public class PolishExpr {
segments.add(token);
} else if (isLeftParenthesis(token)) {
- operatorStack.push((Operator)token);
+ operatorStack.push((Operator) token);
} else if (isRightParenthesis(token)) {
Operator opNew = null;
@@ -60,7 +60,7 @@ public class PolishExpr {
throw new IllegalArgumentException("mismatched parentheses");
} else if (isOperator(token)) {
- Operator opNew = (Operator)token;
+ Operator opNew = (Operator) token;
if (!operatorStack.empty()) {
Operator opOld = operatorStack.peek();
if (opOld.isCompareable() && opNew.compare(opOld) != 1) {
@@ -83,11 +83,8 @@ public class PolishExpr {
}
/**
- *
* @param expression
- *
* @return
- *
* @throws Exception
*/
private static List<Op> participle(String expression) {
@@ -99,7 +96,7 @@ public class PolishExpr {
Type preType = Type.NULL;
for (int i = 0; i < size; i++) {
- int chValue = (int)expression.charAt(i);
+ int chValue = (int) expression.charAt(i);
if ((97 <= chValue && chValue <= 122) || (65 <= chValue && chValue <= 90)
|| (49 <= chValue && chValue <= 57) || 95 == chValue) {
@@ -129,7 +126,7 @@ public class PolishExpr {
}
preType = Type.PARENTHESIS;
- segments.add(createOperator((char)chValue + ""));
+ segments.add(createOperator((char) chValue + ""));
} else if (38 == chValue || 124 == chValue) {
if (Type.OPERAND == preType || Type.SEPAERATOR == preType || Type.PARENTHESIS == preType) {
@@ -157,7 +154,7 @@ public class PolishExpr {
preType = Type.SEPAERATOR;
} else {
- throw new IllegalArgumentException("illegal expression, at index " + i + " " + (char)chValue);
+ throw new IllegalArgumentException("illegal expression, at index " + i + " " + (char) chValue);
}
}
@@ -173,11 +170,11 @@ public class PolishExpr {
}
public static boolean isLeftParenthesis(Op token) {
- return token instanceof Operator && LEFTPARENTHESIS == (Operator)token;
+ return token instanceof Operator && LEFTPARENTHESIS == (Operator) token;
}
public static boolean isRightParenthesis(Op token) {
- return token instanceof Operator && RIGHTPARENTHESIS == (Operator)token;
+ return token instanceof Operator && RIGHTPARENTHESIS == (Operator) token;
}
public static boolean isOperator(Op token) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/message/MessageClientIDSetter.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageClientIDSetter.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageClientIDSetter.java
index 1c27920..6e7b490 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageClientIDSetter.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageClientIDSetter.java
@@ -64,10 +64,10 @@ public class MessageClientIDSetter {
public static Date getNearlyTimeFromID(String msgID) {
ByteBuffer buf = ByteBuffer.allocate(8);
byte[] bytes = UtilAll.string2bytes(msgID);
- buf.put((byte)0);
- buf.put((byte)0);
- buf.put((byte)0);
- buf.put((byte)0);
+ buf.put((byte) 0);
+ buf.put((byte) 0);
+ buf.put((byte) 0);
+ buf.put((byte) 0);
buf.put(bytes, 10, 4);
buf.position(0);
long spanMS = buf.getLong();
@@ -113,8 +113,8 @@ public class MessageClientIDSetter {
setStartTime(current);
}
buffer.position(0);
- buffer.putInt((int)(System.currentTimeMillis() - startTime));
- buffer.putShort((short)COUNTER.getAndIncrement());
+ buffer.putInt((int) (System.currentTimeMillis() - startTime));
+ buffer.putShort((short) COUNTER.getAndIncrement());
return buffer.array();
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
index 6ae1d2a..2260078 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageDecoder.java
@@ -54,7 +54,7 @@ public class MessageDecoder {
public static String createMessageId(SocketAddress socketAddress, long transactionIdhashCode) {
ByteBuffer byteBuffer = ByteBuffer.allocate(MessageDecoder.MSG_ID_LENGTH);
- InetSocketAddress inetSocketAddress = (InetSocketAddress)socketAddress;
+ InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
byteBuffer.put(inetSocketAddress.getAddress().getAddress());
byteBuffer.putInt(inetSocketAddress.getPort());
byteBuffer.putLong(transactionIdhashCode);
@@ -95,10 +95,10 @@ public class MessageDecoder {
public static byte[] encode(MessageExt messageExt, boolean needCompress) throws Exception {
byte[] body = messageExt.getBody();
byte[] topics = messageExt.getTopic().getBytes(CHARSET_UTF8);
- byte topicLen = (byte)topics.length;
+ byte topicLen = (byte) topics.length;
String properties = messageProperties2String(messageExt.getProperties());
byte[] propertiesBytes = properties.getBytes(CHARSET_UTF8);
- short propertiesLength = (short)propertiesBytes.length;
+ short propertiesLength = (short) propertiesBytes.length;
int sysFlag = messageExt.getSysFlag();
byte[] newBody = messageExt.getBody();
if (needCompress && (sysFlag & MessageSysFlag.COMPRESSED_FLAG) == MessageSysFlag.COMPRESSED_FLAG) {
@@ -164,7 +164,7 @@ public class MessageDecoder {
byteBuffer.putLong(bornTimeStamp);
// 10 BORNHOST
- InetSocketAddress bornHost = (InetSocketAddress)messageExt.getBornHost();
+ InetSocketAddress bornHost = (InetSocketAddress) messageExt.getBornHost();
byteBuffer.put(bornHost.getAddress().getAddress());
byteBuffer.putInt(bornHost.getPort());
@@ -173,7 +173,7 @@ public class MessageDecoder {
byteBuffer.putLong(storeTimestamp);
// 12 STOREHOST
- InetSocketAddress serverHost = (InetSocketAddress)messageExt.getStoreHost();
+ InetSocketAddress serverHost = (InetSocketAddress) messageExt.getStoreHost();
byteBuffer.put(serverHost.getAddress().getAddress());
byteBuffer.putInt(serverHost.getPort());
@@ -295,7 +295,7 @@ public class MessageDecoder {
// 16 TOPIC
byte topicLen = byteBuffer.get();
- byte[] topic = new byte[(int)topicLen];
+ byte[] topic = new byte[(int) topicLen];
byteBuffer.get(topic);
msgExt.setTopic(new String(topic, CHARSET_UTF8));
@@ -314,7 +314,7 @@ public class MessageDecoder {
msgExt.setMsgId(msgId);
if (isClient) {
- ((MessageClientExt)msgExt).setOffsetMsgId(msgId);
+ ((MessageClientExt) msgExt).setOffsetMsgId(msgId);
}
return msgExt;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
index 9fec0ca..8a4ea89 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java
@@ -65,7 +65,7 @@ public class MessageExt extends Message {
}
private static ByteBuffer socketAddress2ByteBuffer(final SocketAddress socketAddress, final ByteBuffer byteBuffer) {
- InetSocketAddress inetSocketAddress = (InetSocketAddress)socketAddress;
+ InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
byteBuffer.put(inetSocketAddress.getAddress().getAddress(), 0, 4);
byteBuffer.putInt(inetSocketAddress.getPort());
byteBuffer.flip();
@@ -119,7 +119,7 @@ public class MessageExt extends Message {
public String getBornHostString() {
if (this.bornHost != null) {
- InetSocketAddress inetSocketAddress = (InetSocketAddress)this.bornHost;
+ InetSocketAddress inetSocketAddress = (InetSocketAddress) this.bornHost;
return inetSocketAddress.getAddress().getHostAddress();
}
@@ -128,7 +128,7 @@ public class MessageExt extends Message {
public String getBornHostNameString() {
if (this.bornHost != null) {
- InetSocketAddress inetSocketAddress = (InetSocketAddress)this.bornHost;
+ InetSocketAddress inetSocketAddress = (InetSocketAddress) this.bornHost;
return inetSocketAddress.getAddress().getHostName();
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
index fa2745d..fc162fa 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueue.java
@@ -76,7 +76,7 @@ public class MessageQueue implements Comparable<MessageQueue>, Serializable {
return false;
if (getClass() != obj.getClass())
return false;
- MessageQueue other = (MessageQueue)obj;
+ MessageQueue other = (MessageQueue) obj;
if (brokerName == null) {
if (other.brokerName != null)
return false;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java
index f5c43c9..1e36dd1 100644
--- a/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java
+++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageQueueForC.java
@@ -75,7 +75,7 @@ public class MessageQueueForC implements Comparable<MessageQueueForC>, Serializa
return false;
if (getClass() != obj.getClass())
return false;
- MessageQueueForC other = (MessageQueueForC)obj;
+ MessageQueueForC other = (MessageQueueForC) obj;
if (brokerName == null) {
if (other.brokerName != null)
return false;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
index d58ccf2..d024e80 100644
--- a/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
+++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/NamesrvConfig.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: NamesrvConfig.java 1839 2013-05-16 02:12:02Z vintagewang@apache.org $
+ *
+ * $Id: NamesrvConfig.java 1839 2013-05-16 02:12:02Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java b/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
index 4f0dfce..e2a7282 100644
--- a/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
+++ b/common/src/main/java/org/apache/rocketmq/common/namesrv/TopAddressing.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: TopAddressing.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
+ *
+ * $Id: TopAddressing.java 1831 2013-05-16 01:39:51Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerRunningInfo.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerRunningInfo.java b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerRunningInfo.java
index 9836b8d..aea95f1 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerRunningInfo.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerRunningInfo.java
@@ -53,7 +53,7 @@ public class ConsumerRunningInfo extends RemotingSerializable {
String property = prev.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUME_TYPE);
if (property == null) {
- property = ((ConsumeType)prev.getProperties().get(ConsumerRunningInfo.PROP_CONSUME_TYPE)).name();
+ property = ((ConsumeType) prev.getProperties().get(ConsumerRunningInfo.PROP_CONSUME_TYPE)).name();
}
push = ConsumeType.valueOf(property) == ConsumeType.CONSUME_PASSIVELY;
}
@@ -109,7 +109,7 @@ public class ConsumerRunningInfo extends RemotingSerializable {
String property = info.getProperties().getProperty(ConsumerRunningInfo.PROP_CONSUME_TYPE);
if (property == null) {
- property = ((ConsumeType)info.getProperties().get(ConsumerRunningInfo.PROP_CONSUME_TYPE)).name();
+ property = ((ConsumeType) info.getProperties().get(ConsumerRunningInfo.PROP_CONSUME_TYPE)).name();
}
push = ConsumeType.valueOf(property) == ConsumeType.CONSUME_PASSIVELY;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
index eb08c19..2eed1f2 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: EndTransactionRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: EndTransactionRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
index 7ad665f..fed5ced 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CheckTransactionStateResponseHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: EndTransactionResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: EndTransactionResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
index 46c183e..88fea2d 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CloneGroupOffsetRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: DeleteTopicRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: DeleteTopicRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
index 609d46d..6f98f22 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/CreateTopicRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: CreateTopicRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: CreateTopicRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
index 73d6556..412279c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteTopicRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: DeleteTopicRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: DeleteTopicRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
index e21016a..c5d0ac5 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: EndTransactionRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: EndTransactionRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
index 377a73c..1dd9ac7 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/EndTransactionResponseHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: EndTransactionResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: EndTransactionResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
index c8de641..fac1854 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetAllTopicConfigResponseHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: GetAllTopicConfigResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: GetAllTopicConfigResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
index a6b6bc0..88e8921 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerConfigResponseHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: GetBrokerConfigResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: GetBrokerConfigResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
index a99bbc6..5f5dbe0 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: GetEarliestMsgStoretimeRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: GetEarliestMsgStoretimeRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
index d074a91..f8c4af4 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeResponseHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: GetEarliestMsgStoretimeResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: GetEarliestMsgStoretimeResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
index 714d1b5..3b8f99c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: GetMaxOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: GetMaxOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
index e89ef21..e5ffd8d 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMaxOffsetResponseHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: GetMaxOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: GetMaxOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
index eef99e2..50e4e15 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: GetMinOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: GetMinOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
index 67b7a01..a9392f4 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetMinOffsetResponseHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: GetMinOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: GetMinOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
index b0e65ad..109b97b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: PullMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: PullMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
index 6907068..0871b8c 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/PullMessageResponseHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: PullMessageResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: PullMessageResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
index 9cbfaa2..3b90af2 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: QueryConsumerOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: QueryConsumerOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
index 51b50ea..f010624 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryConsumerOffsetResponseHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: QueryConsumerOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: QueryConsumerOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
index 04926fa..db5b306 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: GetMinOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: GetMinOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
index 5aed5f3..ffc83e6 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: QueryMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: QueryMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
index 14d4d54..a34522e 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryMessageResponseHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: QueryMessageResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: QueryMessageResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
index a58de58..bd8061d 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryTopicConsumeByWhoRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: QueryMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: QueryMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
index e686f90..93e3051 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: SearchOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: SearchOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
index bbac844..72e0efa 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetResponseHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: SearchOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: SearchOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
index 937a86e..592651b 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: SendMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: SendMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
index b6a8fa5..510c5fc 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageResponseHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: SendMessageResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: SendMessageResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
index 5822d8e..270c293 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: UpdateConsumerOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: UpdateConsumerOffsetRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
index c8b6083..cd25080 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/UpdateConsumerOffsetResponseHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: UpdateConsumerOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: UpdateConsumerOffsetResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
index f1c7622..5d3cdea 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: ViewMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: ViewMessageRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
index b2d97d4..a03d640 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/ViewMessageResponseHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: ViewMessageResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: ViewMessageResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
index 62abaec..21cefba 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoRequestHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: GetRouteInfoRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: GetRouteInfoRequestHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/853b167b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
index a122cea..131b664 100644
--- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
+++ b/common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
@@ -15,6 +15,8 @@
* limitations under the License.
*
* $Id: GetRouteInfoResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
+ *
+ * $Id: GetRouteInfoResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
/**
[42/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStorePluginContext.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStorePluginContext.java b/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStorePluginContext.java
new file mode 100644
index 0000000..32af402
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/plugin/MessageStorePluginContext.java
@@ -0,0 +1,61 @@
+/**
+ * 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.broker.plugin;
+
+import org.apache.rocketmq.common.BrokerConfig;
+import org.apache.rocketmq.store.MessageArrivingListener;
+import org.apache.rocketmq.store.config.MessageStoreConfig;
+import org.apache.rocketmq.store.stats.BrokerStatsManager;
+
+public class MessageStorePluginContext {
+ private MessageStoreConfig messageStoreConfig;
+ private BrokerStatsManager brokerStatsManager;
+ private MessageArrivingListener messageArrivingListener;
+ private BrokerConfig brokerConfig;
+
+ public MessageStorePluginContext(MessageStoreConfig messageStoreConfig,
+ BrokerStatsManager brokerStatsManager, MessageArrivingListener messageArrivingListener,
+ BrokerConfig brokerConfig) {
+ super();
+ this.messageStoreConfig = messageStoreConfig;
+ this.brokerStatsManager = brokerStatsManager;
+ this.messageArrivingListener = messageArrivingListener;
+ this.brokerConfig = brokerConfig;
+ }
+
+ public MessageStoreConfig getMessageStoreConfig() {
+ return messageStoreConfig;
+ }
+
+ public BrokerStatsManager getBrokerStatsManager() {
+ return brokerStatsManager;
+ }
+
+ public MessageArrivingListener getMessageArrivingListener() {
+ return messageArrivingListener;
+ }
+
+ public BrokerConfig getBrokerConfig() {
+ return brokerConfig;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
new file mode 100644
index 0000000..3cf28b3
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
@@ -0,0 +1,332 @@
+/**
+ * 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.broker.processor;
+
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.broker.mqtrace.SendMessageContext;
+import org.apache.rocketmq.broker.mqtrace.SendMessageHook;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.TopicConfig;
+import org.apache.rocketmq.common.TopicFilterType;
+import org.apache.rocketmq.common.constant.DBMsgConstants;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.constant.PermName;
+import org.apache.rocketmq.common.help.FAQUrl;
+import org.apache.rocketmq.common.message.MessageAccessor;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageDecoder;
+import org.apache.rocketmq.common.protocol.RequestCode;
+import org.apache.rocketmq.common.protocol.ResponseCode;
+import org.apache.rocketmq.common.protocol.header.SendMessageRequestHeader;
+import org.apache.rocketmq.common.protocol.header.SendMessageRequestHeaderV2;
+import org.apache.rocketmq.common.protocol.header.SendMessageResponseHeader;
+import org.apache.rocketmq.common.sysflag.MessageSysFlag;
+import org.apache.rocketmq.common.sysflag.TopicSysFlag;
+import org.apache.rocketmq.common.utils.ChannelUtil;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.apache.rocketmq.store.MessageExtBrokerInner;
+import io.netty.channel.ChannelHandlerContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+
+/**
+ * @author shijia.wxr
+ */
+public abstract class AbstractSendMessageProcessor implements NettyRequestProcessor {
+ protected static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+
+ protected final static int DLQ_NUMS_PER_GROUP = 1;
+ protected final BrokerController brokerController;
+ protected final Random random = new Random(System.currentTimeMillis());
+ protected final SocketAddress storeHost;
+ private List<SendMessageHook> sendMessageHookList;
+
+
+ public AbstractSendMessageProcessor(final BrokerController brokerController) {
+ this.brokerController = brokerController;
+ this.storeHost =
+ new InetSocketAddress(brokerController.getBrokerConfig().getBrokerIP1(), brokerController
+ .getNettyServerConfig().getListenPort());
+ }
+
+ protected SendMessageContext buildMsgContext(ChannelHandlerContext ctx,
+ SendMessageRequestHeader requestHeader) {
+ if (!this.hasSendMessageHook()) {
+ return null;
+ }
+ SendMessageContext mqtraceContext;
+ mqtraceContext = new SendMessageContext();
+ mqtraceContext.setProducerGroup(requestHeader.getProducerGroup());
+ mqtraceContext.setTopic(requestHeader.getTopic());
+ mqtraceContext.setMsgProps(requestHeader.getProperties());
+ mqtraceContext.setBornHost(RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
+ mqtraceContext.setBrokerAddr(this.brokerController.getBrokerAddr());
+ mqtraceContext.setBrokerRegionId(this.brokerController.getBrokerConfig().getRegionId());
+ mqtraceContext.setBornTimeStamp(requestHeader.getBornTimestamp());
+
+ Map<String, String> properties = MessageDecoder.string2messageProperties(requestHeader.getProperties());
+ String uniqueKey = properties.get(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX);
+ properties.put(MessageConst.PROPERTY_MSG_REGION, this.brokerController.getBrokerConfig().getRegionId());
+ properties.put(MessageConst.PROPERTY_TRACE_SWITCH, String.valueOf(this.brokerController.getBrokerConfig().isTraceOn()));
+ requestHeader.setProperties(MessageDecoder.messageProperties2String(properties));
+
+
+ if (uniqueKey == null) {
+ uniqueKey = "";
+ }
+ mqtraceContext.setMsgUniqueKey(uniqueKey);
+ return mqtraceContext;
+ }
+
+ public boolean hasSendMessageHook() {
+ return sendMessageHookList != null && !this.sendMessageHookList.isEmpty();
+ }
+
+ protected MessageExtBrokerInner buildInnerMsg(final ChannelHandlerContext ctx,
+ final SendMessageRequestHeader requestHeader, final byte[] body, TopicConfig topicConfig) {
+ int queueIdInt = requestHeader.getQueueId();
+ if (queueIdInt < 0) {
+ queueIdInt = Math.abs(this.random.nextInt() % 99999999) % topicConfig.getWriteQueueNums();
+ }
+ int sysFlag = requestHeader.getSysFlag();
+
+ if (TopicFilterType.MULTI_TAG == topicConfig.getTopicFilterType()) {
+ sysFlag |= MessageSysFlag.MULTI_TAGS_FLAG;
+ }
+
+ MessageExtBrokerInner msgInner = new MessageExtBrokerInner();
+ msgInner.setTopic(requestHeader.getTopic());
+ msgInner.setBody(body);
+ msgInner.setFlag(requestHeader.getFlag());
+ MessageAccessor.setProperties(msgInner,
+ MessageDecoder.string2messageProperties(requestHeader.getProperties()));
+ msgInner.setPropertiesString(requestHeader.getProperties());
+ msgInner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(topicConfig.getTopicFilterType(),
+ msgInner.getTags()));
+
+ msgInner.setQueueId(queueIdInt);
+ msgInner.setSysFlag(sysFlag);
+ msgInner.setBornTimestamp(requestHeader.getBornTimestamp());
+ msgInner.setBornHost(ctx.channel().remoteAddress());
+ msgInner.setStoreHost(this.getStoreHost());
+ msgInner.setReconsumeTimes(requestHeader.getReconsumeTimes() == null ? 0 : requestHeader
+ .getReconsumeTimes());
+ return msgInner;
+ }
+
+ public SocketAddress getStoreHost() {
+ return storeHost;
+ }
+
+ protected RemotingCommand msgContentCheck(final ChannelHandlerContext ctx,
+ final SendMessageRequestHeader requestHeader, RemotingCommand request,
+ final RemotingCommand response) {
+ if (requestHeader.getTopic().length() > Byte.MAX_VALUE) {
+ log.warn("putMessage message topic length too long " + requestHeader.getTopic().length());
+ response.setCode(ResponseCode.MESSAGE_ILLEGAL);
+ return response;
+ }
+ if (requestHeader.getProperties() != null && requestHeader.getProperties().length() > Short.MAX_VALUE) {
+ log.warn("putMessage message properties length too long "
+ + requestHeader.getProperties().length());
+ response.setCode(ResponseCode.MESSAGE_ILLEGAL);
+ return response;
+ }
+ if (request.getBody().length > DBMsgConstants.MAX_BODY_SIZE) {
+ log.warn(" topic {} msg body size {} from {}", requestHeader.getTopic(),
+ request.getBody().length, ChannelUtil.getRemoteIp(ctx.channel()));
+ response.setRemark("msg body must be less 64KB");
+ response.setCode(ResponseCode.MESSAGE_ILLEGAL);
+ return response;
+ }
+ return response;
+ }
+
+ protected RemotingCommand msgCheck(final ChannelHandlerContext ctx,
+ final SendMessageRequestHeader requestHeader, final RemotingCommand response) {
+ if (!PermName.isWriteable(this.brokerController.getBrokerConfig().getBrokerPermission())
+ && this.brokerController.getTopicConfigManager().isOrderTopic(requestHeader.getTopic())) {
+ response.setCode(ResponseCode.NO_PERMISSION);
+ response.setRemark("the broker[" + this.brokerController.getBrokerConfig().getBrokerIP1()
+ + "] sending message is forbidden");
+ return response;
+ }
+ if (!this.brokerController.getTopicConfigManager().isTopicCanSendMessage(requestHeader.getTopic())) {
+ String errorMsg =
+ "the topic[" + requestHeader.getTopic() + "] is conflict with system reserved words.";
+ log.warn(errorMsg);
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark(errorMsg);
+ return response;
+ }
+
+ TopicConfig topicConfig =
+ this.brokerController.getTopicConfigManager().selectTopicConfig(requestHeader.getTopic());
+ if (null == topicConfig) {
+ int topicSysFlag = 0;
+ if (requestHeader.isUnitMode()) {
+ if (requestHeader.getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
+ topicSysFlag = TopicSysFlag.buildSysFlag(false, true);
+ } else {
+ topicSysFlag = TopicSysFlag.buildSysFlag(true, false);
+ }
+ }
+
+ log.warn("the topic " + requestHeader.getTopic() + " not exist, producer: "
+ + ctx.channel().remoteAddress());
+ topicConfig = this.brokerController.getTopicConfigManager().createTopicInSendMessageMethod(//
+ requestHeader.getTopic(), //
+ requestHeader.getDefaultTopic(), //
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()), //
+ requestHeader.getDefaultTopicQueueNums(), topicSysFlag);
+
+ if (null == topicConfig) {
+ if (requestHeader.getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
+ topicConfig =
+ this.brokerController.getTopicConfigManager().createTopicInSendMessageBackMethod(
+ requestHeader.getTopic(), 1, PermName.PERM_WRITE | PermName.PERM_READ,
+ topicSysFlag);
+ }
+ }
+
+ if (null == topicConfig) {
+ response.setCode(ResponseCode.TOPIC_NOT_EXIST);
+ response.setRemark("topic[" + requestHeader.getTopic() + "] not exist, apply first please!"
+ + FAQUrl.suggestTodo(FAQUrl.APPLY_TOPIC_URL));
+ return response;
+ }
+ }
+
+ int queueIdInt = requestHeader.getQueueId();
+ int idValid = Math.max(topicConfig.getWriteQueueNums(), topicConfig.getReadQueueNums());
+ if (queueIdInt >= idValid) {
+ String errorInfo = String.format("request queueId[%d] is illagal, %s Producer: %s",
+ queueIdInt,
+ topicConfig.toString(),
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
+
+ log.warn(errorInfo);
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark(errorInfo);
+
+ return response;
+ }
+ return response;
+ }
+
+ public void registerSendMessageHook(List<SendMessageHook> sendMessageHookList) {
+ this.sendMessageHookList = sendMessageHookList;
+ }
+
+ protected void doResponse(ChannelHandlerContext ctx, RemotingCommand request,
+ final RemotingCommand response) {
+ if (!request.isOnewayRPC()) {
+ try {
+ ctx.writeAndFlush(response);
+ } catch (Throwable e) {
+ log.error("SendMessageProcessor process request over, but response failed", e);
+ log.error(request.toString());
+ log.error(response.toString());
+ }
+ }
+ }
+
+ public void executeSendMessageHookBefore(final ChannelHandlerContext ctx, final RemotingCommand request,
+ SendMessageContext context) {
+ if (hasSendMessageHook()) {
+ for (SendMessageHook hook : this.sendMessageHookList) {
+ try {
+ final SendMessageRequestHeader requestHeader = parseRequestHeader(request);
+
+ if (null != requestHeader) {
+ context.setProducerGroup(requestHeader.getProducerGroup());
+ context.setTopic(requestHeader.getTopic());
+ context.setBodyLength(request.getBody().length);
+ context.setMsgProps(requestHeader.getProperties());
+ context.setBornHost(RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
+ context.setBrokerAddr(this.brokerController.getBrokerAddr());
+ context.setQueueId(requestHeader.getQueueId());
+ }
+
+ hook.sendMessageBefore(context);
+ requestHeader.setProperties(context.getMsgProps());
+ } catch (Throwable e) {
+ }
+ }
+ }
+ }
+
+ protected SendMessageRequestHeader parseRequestHeader(RemotingCommand request)
+ throws RemotingCommandException {
+
+ SendMessageRequestHeaderV2 requestHeaderV2 = null;
+ SendMessageRequestHeader requestHeader = null;
+ switch (request.getCode()) {
+ case RequestCode.SEND_MESSAGE_V2:
+ requestHeaderV2 =
+ (SendMessageRequestHeaderV2) request
+ .decodeCommandCustomHeader(SendMessageRequestHeaderV2.class);
+ case RequestCode.SEND_MESSAGE:
+ if (null == requestHeaderV2) {
+ requestHeader =
+ (SendMessageRequestHeader) request
+ .decodeCommandCustomHeader(SendMessageRequestHeader.class);
+ } else {
+ requestHeader = SendMessageRequestHeaderV2.createSendMessageRequestHeaderV1(requestHeaderV2);
+ }
+ default:
+ break;
+ }
+ return requestHeader;
+ }
+
+ public void executeSendMessageHookAfter(final RemotingCommand response, final SendMessageContext context) {
+ if (hasSendMessageHook()) {
+ for (SendMessageHook hook : this.sendMessageHookList) {
+ try {
+ if (response != null) {
+ final SendMessageResponseHeader responseHeader =
+ (SendMessageResponseHeader) response.readCustomHeader();
+ context.setMsgId(responseHeader.getMsgId());
+ context.setQueueId(responseHeader.getQueueId());
+ context.setQueueOffset(responseHeader.getQueueOffset());
+ context.setCode(response.getCode());
+ context.setErrorMsg(response.getRemark());
+ }
+ hook.sendMessageAfter(context);
+ } catch (Throwable e) {
+
+ }
+ }
+ }
+ }
+
+ @Override
+ public boolean rejectRequest() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
----------------------------------------------------------------------
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
new file mode 100644
index 0000000..c1241bb
--- /dev/null
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
@@ -0,0 +1,1212 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.broker.processor;
+
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.broker.client.ClientChannelInfo;
+import org.apache.rocketmq.broker.client.ConsumerGroupInfo;
+import org.apache.rocketmq.common.MQVersion;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.TopicConfig;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.admin.ConsumeStats;
+import org.apache.rocketmq.common.admin.OffsetWrapper;
+import org.apache.rocketmq.common.admin.TopicOffset;
+import org.apache.rocketmq.common.admin.TopicStatsTable;
+import org.apache.rocketmq.common.constant.LoggerName;
+import org.apache.rocketmq.common.message.MessageDecoder;
+import org.apache.rocketmq.common.message.MessageId;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.RequestCode;
+import org.apache.rocketmq.common.protocol.ResponseCode;
+import org.apache.rocketmq.common.protocol.body.*;
+import org.apache.rocketmq.common.protocol.header.*;
+import org.apache.rocketmq.common.protocol.header.filtersrv.RegisterFilterServerRequestHeader;
+import org.apache.rocketmq.common.protocol.header.filtersrv.RegisterFilterServerResponseHeader;
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
+import org.apache.rocketmq.common.stats.StatsItem;
+import org.apache.rocketmq.common.stats.StatsSnapshot;
+import org.apache.rocketmq.common.subscription.SubscriptionGroupConfig;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.exception.RemotingCommandException;
+import org.apache.rocketmq.remoting.exception.RemotingTimeoutException;
+import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
+import org.apache.rocketmq.remoting.protocol.LanguageCode;
+import org.apache.rocketmq.remoting.protocol.RemotingCommand;
+import org.apache.rocketmq.remoting.protocol.RemotingSerializable;
+import org.apache.rocketmq.store.DefaultMessageStore;
+import org.apache.rocketmq.store.SelectMappedBufferResult;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.UnsupportedEncodingException;
+import java.net.UnknownHostException;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * @author shijia.wxr
+ * @author manhong.yqd
+ */
+public class AdminBrokerProcessor implements NettyRequestProcessor {
+ private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
+ private final BrokerController brokerController;
+
+ public AdminBrokerProcessor(final BrokerController brokerController) {
+ this.brokerController = brokerController;
+ }
+
+ @Override
+ public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ switch (request.getCode()) {
+ case RequestCode.UPDATE_AND_CREATE_TOPIC:
+ return this.updateAndCreateTopic(ctx, request);
+ case RequestCode.DELETE_TOPIC_IN_BROKER:
+ return this.deleteTopic(ctx, request);
+ case RequestCode.GET_ALL_TOPIC_CONFIG:
+ return this.getAllTopicConfig(ctx, request);
+ case RequestCode.UPDATE_BROKER_CONFIG:
+ return this.updateBrokerConfig(ctx, request);
+ case RequestCode.GET_BROKER_CONFIG:
+ return this.getBrokerConfig(ctx, request);
+ case RequestCode.SEARCH_OFFSET_BY_TIMESTAMP:
+ return this.searchOffsetByTimestamp(ctx, request);
+ case RequestCode.GET_MAX_OFFSET:
+ return this.getMaxOffset(ctx, request);
+ case RequestCode.GET_MIN_OFFSET:
+ return this.getMinOffset(ctx, request);
+ case RequestCode.GET_EARLIEST_MSG_STORETIME:
+ return this.getEarliestMsgStoretime(ctx, request);
+ case RequestCode.GET_BROKER_RUNTIME_INFO:
+ return this.getBrokerRuntimeInfo(ctx, request);
+ case RequestCode.LOCK_BATCH_MQ:
+ return this.lockBatchMQ(ctx, request);
+ case RequestCode.UNLOCK_BATCH_MQ:
+ return this.unlockBatchMQ(ctx, request);
+ case RequestCode.UPDATE_AND_CREATE_SUBSCRIPTIONGROUP:
+ return this.updateAndCreateSubscriptionGroup(ctx, request);
+ case RequestCode.GET_ALL_SUBSCRIPTIONGROUP_CONFIG:
+ return this.getAllSubscriptionGroup(ctx, request);
+ case RequestCode.DELETE_SUBSCRIPTIONGROUP:
+ return this.deleteSubscriptionGroup(ctx, request);
+ case RequestCode.GET_TOPIC_STATS_INFO:
+ return this.getTopicStatsInfo(ctx, request);
+ case RequestCode.GET_CONSUMER_CONNECTION_LIST:
+ return this.getConsumerConnectionList(ctx, request);
+ case RequestCode.GET_PRODUCER_CONNECTION_LIST:
+ return this.getProducerConnectionList(ctx, request);
+ case RequestCode.GET_CONSUME_STATS:
+ return this.getConsumeStats(ctx, request);
+ case RequestCode.GET_ALL_CONSUMER_OFFSET:
+ return this.getAllConsumerOffset(ctx, request);
+ case RequestCode.GET_ALL_DELAY_OFFSET:
+ return this.getAllDelayOffset(ctx, request);
+ case RequestCode.INVOKE_BROKER_TO_RESET_OFFSET:
+ return this.resetOffset(ctx, request);
+ case RequestCode.INVOKE_BROKER_TO_GET_CONSUMER_STATUS:
+ return this.getConsumerStatus(ctx, request);
+ case RequestCode.QUERY_TOPIC_CONSUME_BY_WHO:
+ return this.queryTopicConsumeByWho(ctx, request);
+ case RequestCode.REGISTER_FILTER_SERVER:
+ return this.registerFilterServer(ctx, request);
+ case RequestCode.QUERY_CONSUME_TIME_SPAN:
+ return this.queryConsumeTimeSpan(ctx, request);
+ case RequestCode.GET_SYSTEM_TOPIC_LIST_FROM_BROKER:
+ return this.getSystemTopicListFromBroker(ctx, request);
+ case RequestCode.CLEAN_EXPIRED_CONSUMEQUEUE:
+ return this.cleanExpiredConsumeQueue();
+ case RequestCode.CLEAN_UNUSED_TOPIC:
+ return this.cleanUnusedTopic();
+ case RequestCode.GET_CONSUMER_RUNNING_INFO:
+ return this.getConsumerRunningInfo(ctx, request);
+ case RequestCode.QUERY_CORRECTION_OFFSET:
+ return this.queryCorrectionOffset(ctx, request);
+ case RequestCode.CONSUME_MESSAGE_DIRECTLY:
+ return this.consumeMessageDirectly(ctx, request);
+ case RequestCode.CLONE_GROUP_OFFSET:
+ return this.cloneGroupOffset(ctx, request);
+ case RequestCode.VIEW_BROKER_STATS_DATA:
+ return ViewBrokerStatsData(ctx, request);
+ case RequestCode.GET_BROKER_CONSUME_STATS:
+ return fetchAllConsumeStatsInBroker(ctx, request);
+ default:
+ break;
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean rejectRequest() {
+ return false;
+ }
+
+ private RemotingCommand updateAndCreateTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ final CreateTopicRequestHeader requestHeader =
+ (CreateTopicRequestHeader) request.decodeCommandCustomHeader(CreateTopicRequestHeader.class);
+ log.info("updateAndCreateTopic called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
+
+
+ if (requestHeader.getTopic().equals(this.brokerController.getBrokerConfig().getBrokerClusterName())) {
+ String errorMsg = "the topic[" + requestHeader.getTopic() + "] is conflict with system reserved words.";
+ log.warn(errorMsg);
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark(errorMsg);
+ return response;
+ }
+
+ try {
+ response.setCode(ResponseCode.SUCCESS);
+ response.setOpaque(request.getOpaque());
+ response.markResponseType();
+ response.setRemark(null);
+ ctx.writeAndFlush(response);
+ } catch (Exception e) {
+ }
+
+ TopicConfig topicConfig = new TopicConfig(requestHeader.getTopic());
+ topicConfig.setReadQueueNums(requestHeader.getReadQueueNums());
+ topicConfig.setWriteQueueNums(requestHeader.getWriteQueueNums());
+ topicConfig.setTopicFilterType(requestHeader.getTopicFilterTypeEnum());
+ topicConfig.setPerm(requestHeader.getPerm());
+ topicConfig.setTopicSysFlag(requestHeader.getTopicSysFlag() == null ? 0 : requestHeader.getTopicSysFlag());
+
+ this.brokerController.getTopicConfigManager().updateTopicConfig(topicConfig);
+ this.brokerController.registerBrokerAll(false, true);
+ return null;
+ }
+
+ private RemotingCommand deleteTopic(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ DeleteTopicRequestHeader requestHeader =
+ (DeleteTopicRequestHeader) request.decodeCommandCustomHeader(DeleteTopicRequestHeader.class);
+
+ log.info("deleteTopic called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
+
+ this.brokerController.getTopicConfigManager().deleteTopicConfig(requestHeader.getTopic());
+ this.brokerController.getMessageStore()
+ .cleanUnusedTopic(this.brokerController.getTopicConfigManager().getTopicConfigTable().keySet());
+
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand getAllTopicConfig(ChannelHandlerContext ctx, RemotingCommand request) {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(GetAllTopicConfigResponseHeader.class);
+ // final GetAllTopicConfigResponseHeader responseHeader =
+ // (GetAllTopicConfigResponseHeader) response.readCustomHeader();
+
+ String content = this.brokerController.getTopicConfigManager().encode();
+ if (content != null && content.length() > 0) {
+ try {
+ response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
+ } catch (UnsupportedEncodingException e) {
+ log.error("", e);
+
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("UnsupportedEncodingException " + e);
+ return response;
+ }
+ } else {
+ log.error("No topic in this broker, client: " + ctx.channel().remoteAddress());
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("No topic in this broker");
+ return response;
+ }
+
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+
+ return response;
+ }
+
+ private RemotingCommand updateBrokerConfig(ChannelHandlerContext ctx, RemotingCommand request) {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+
+ log.info("updateBrokerConfig called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
+
+ byte[] body = request.getBody();
+ if (body != null) {
+ try {
+ String bodyStr = new String(body, MixAll.DEFAULT_CHARSET);
+ Properties properties = MixAll.string2Properties(bodyStr);
+ if (properties != null) {
+ log.info("updateBrokerConfig, new config: " + properties + " client: " + ctx.channel().remoteAddress());
+ this.brokerController.getConfiguration().update(properties);
+ if (properties.containsKey("brokerPermission")) {
+ this.brokerController.registerBrokerAll(false, false);
+ this.brokerController.getTopicConfigManager().getDataVersion().nextVersion();
+ }
+ } else {
+ log.error("string2Properties error");
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("string2Properties error");
+ return response;
+ }
+ } catch (UnsupportedEncodingException e) {
+ log.error("", e);
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("UnsupportedEncodingException " + e);
+ return response;
+ }
+ }
+
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand getBrokerConfig(ChannelHandlerContext ctx, RemotingCommand request) {
+
+ final RemotingCommand response = RemotingCommand.createResponseCommand(GetBrokerConfigResponseHeader.class);
+ final GetBrokerConfigResponseHeader responseHeader = (GetBrokerConfigResponseHeader) response.readCustomHeader();
+
+ String content = this.brokerController.getConfiguration().getAllConfigsFormatString();
+ if (content != null && content.length() > 0) {
+ try {
+ response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
+ } catch (UnsupportedEncodingException e) {
+ log.error("", e);
+
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("UnsupportedEncodingException " + e);
+ return response;
+ }
+ }
+
+ responseHeader.setVersion(this.brokerController.getConfiguration().getDataVersionJson());
+
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand searchOffsetByTimestamp(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(SearchOffsetResponseHeader.class);
+ final SearchOffsetResponseHeader responseHeader = (SearchOffsetResponseHeader) response.readCustomHeader();
+ final SearchOffsetRequestHeader requestHeader =
+ (SearchOffsetRequestHeader) request.decodeCommandCustomHeader(SearchOffsetRequestHeader.class);
+
+ long offset = this.brokerController.getMessageStore().getOffsetInQueueByTime(requestHeader.getTopic(), requestHeader.getQueueId(),
+ requestHeader.getTimestamp());
+
+ responseHeader.setOffset(offset);
+
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand getMaxOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(GetMaxOffsetResponseHeader.class);
+ final GetMaxOffsetResponseHeader responseHeader = (GetMaxOffsetResponseHeader) response.readCustomHeader();
+ final GetMaxOffsetRequestHeader requestHeader =
+ (GetMaxOffsetRequestHeader) request.decodeCommandCustomHeader(GetMaxOffsetRequestHeader.class);
+
+ long offset = this.brokerController.getMessageStore().getMaxOffsetInQuque(requestHeader.getTopic(), requestHeader.getQueueId());
+
+ responseHeader.setOffset(offset);
+
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand getMinOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(GetMinOffsetResponseHeader.class);
+ final GetMinOffsetResponseHeader responseHeader = (GetMinOffsetResponseHeader) response.readCustomHeader();
+ final GetMinOffsetRequestHeader requestHeader =
+ (GetMinOffsetRequestHeader) request.decodeCommandCustomHeader(GetMinOffsetRequestHeader.class);
+
+ long offset = this.brokerController.getMessageStore().getMinOffsetInQuque(requestHeader.getTopic(), requestHeader.getQueueId());
+
+ responseHeader.setOffset(offset);
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand getEarliestMsgStoretime(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(GetEarliestMsgStoretimeResponseHeader.class);
+ final GetEarliestMsgStoretimeResponseHeader responseHeader = (GetEarliestMsgStoretimeResponseHeader) response.readCustomHeader();
+ final GetEarliestMsgStoretimeRequestHeader requestHeader =
+ (GetEarliestMsgStoretimeRequestHeader) request.decodeCommandCustomHeader(GetEarliestMsgStoretimeRequestHeader.class);
+
+ long timestamp =
+ this.brokerController.getMessageStore().getEarliestMessageTime(requestHeader.getTopic(), requestHeader.getQueueId());
+
+ responseHeader.setTimestamp(timestamp);
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand getBrokerRuntimeInfo(ChannelHandlerContext ctx, RemotingCommand request) {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+
+ HashMap<String, String> runtimeInfo = this.prepareRuntimeInfo();
+ KVTable kvTable = new KVTable();
+ kvTable.setTable(runtimeInfo);
+
+ byte[] body = kvTable.encode();
+ response.setBody(body);
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand lockBatchMQ(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ LockBatchRequestBody requestBody = LockBatchRequestBody.decode(request.getBody(), LockBatchRequestBody.class);
+
+ Set<MessageQueue> lockOKMQSet = this.brokerController.getRebalanceLockManager().tryLockBatch(//
+ requestBody.getConsumerGroup(), //
+ requestBody.getMqSet(), //
+ requestBody.getClientId());
+
+ LockBatchResponseBody responseBody = new LockBatchResponseBody();
+ responseBody.setLockOKMQSet(lockOKMQSet);
+
+ response.setBody(responseBody.encode());
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand unlockBatchMQ(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ UnlockBatchRequestBody requestBody = UnlockBatchRequestBody.decode(request.getBody(), UnlockBatchRequestBody.class);
+
+ this.brokerController.getRebalanceLockManager().unlockBatch(//
+ requestBody.getConsumerGroup(), //
+ requestBody.getMqSet(), //
+ requestBody.getClientId());
+
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand updateAndCreateSubscriptionGroup(ChannelHandlerContext ctx, RemotingCommand request)
+ throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+
+ log.info("updateAndCreateSubscriptionGroup called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
+
+ SubscriptionGroupConfig config = RemotingSerializable.decode(request.getBody(), SubscriptionGroupConfig.class);
+ if (config != null) {
+ this.brokerController.getSubscriptionGroupManager().updateSubscriptionGroupConfig(config);
+ }
+
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand getAllSubscriptionGroup(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ String content = this.brokerController.getSubscriptionGroupManager().encode();
+ if (content != null && content.length() > 0) {
+ try {
+ response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
+ } catch (UnsupportedEncodingException e) {
+ log.error("", e);
+
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("UnsupportedEncodingException " + e);
+ return response;
+ }
+ } else {
+ log.error("No subscription group in this broker, client: " + ctx.channel().remoteAddress());
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("No subscription group in this broker");
+ return response;
+ }
+
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+
+ return response;
+ }
+
+ private RemotingCommand deleteSubscriptionGroup(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ DeleteSubscriptionGroupRequestHeader requestHeader =
+ (DeleteSubscriptionGroupRequestHeader) request.decodeCommandCustomHeader(DeleteSubscriptionGroupRequestHeader.class);
+
+ log.info("deleteSubscriptionGroup called by {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
+
+ this.brokerController.getSubscriptionGroupManager().deleteSubscriptionGroupConfig(requestHeader.getGroupName());
+
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand getTopicStatsInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ final GetTopicStatsInfoRequestHeader requestHeader =
+ (GetTopicStatsInfoRequestHeader) request.decodeCommandCustomHeader(GetTopicStatsInfoRequestHeader.class);
+
+ final String topic = requestHeader.getTopic();
+ TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
+ if (null == topicConfig) {
+ response.setCode(ResponseCode.TOPIC_NOT_EXIST);
+ response.setRemark("topic[" + topic + "] not exist");
+ return response;
+ }
+
+ TopicStatsTable topicStatsTable = new TopicStatsTable();
+ for (int i = 0; i < topicConfig.getWriteQueueNums(); i++) {
+ MessageQueue mq = new MessageQueue();
+ mq.setTopic(topic);
+ mq.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());
+ mq.setQueueId(i);
+
+ TopicOffset topicOffset = new TopicOffset();
+ long min = this.brokerController.getMessageStore().getMinOffsetInQuque(topic, i);
+ if (min < 0)
+ min = 0;
+
+ long max = this.brokerController.getMessageStore().getMaxOffsetInQuque(topic, i);
+ if (max < 0)
+ max = 0;
+
+ long timestamp = 0;
+ if (max > 0) {
+ timestamp = this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i, max - 1);
+ }
+
+ topicOffset.setMinOffset(min);
+ topicOffset.setMaxOffset(max);
+ topicOffset.setLastUpdateTimestamp(timestamp);
+
+ topicStatsTable.getOffsetTable().put(mq, topicOffset);
+ }
+
+ byte[] body = topicStatsTable.encode();
+ response.setBody(body);
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand getConsumerConnectionList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ final GetConsumerConnectionListRequestHeader requestHeader =
+ (GetConsumerConnectionListRequestHeader) request.decodeCommandCustomHeader(GetConsumerConnectionListRequestHeader.class);
+
+ ConsumerGroupInfo consumerGroupInfo =
+ this.brokerController.getConsumerManager().getConsumerGroupInfo(requestHeader.getConsumerGroup());
+ if (consumerGroupInfo != null) {
+ ConsumerConnection bodydata = new ConsumerConnection();
+ bodydata.setConsumeFromWhere(consumerGroupInfo.getConsumeFromWhere());
+ bodydata.setConsumeType(consumerGroupInfo.getConsumeType());
+ bodydata.setMessageModel(consumerGroupInfo.getMessageModel());
+ bodydata.getSubscriptionTable().putAll(consumerGroupInfo.getSubscriptionTable());
+
+ Iterator<Map.Entry<Channel, ClientChannelInfo>> it = consumerGroupInfo.getChannelInfoTable().entrySet().iterator();
+ while (it.hasNext()) {
+ ClientChannelInfo info = it.next().getValue();
+ Connection connection = new Connection();
+ connection.setClientId(info.getClientId());
+ connection.setLanguage(info.getLanguage());
+ connection.setVersion(info.getVersion());
+ connection.setClientAddr(RemotingHelper.parseChannelRemoteAddr(info.getChannel()));
+
+ bodydata.getConnectionSet().add(connection);
+ }
+
+ byte[] body = bodydata.encode();
+ response.setBody(body);
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+
+ return response;
+ }
+
+ response.setCode(ResponseCode.CONSUMER_NOT_ONLINE);
+ response.setRemark("the consumer group[" + requestHeader.getConsumerGroup() + "] not online");
+ return response;
+ }
+
+ private RemotingCommand getProducerConnectionList(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ final GetProducerConnectionListRequestHeader requestHeader =
+ (GetProducerConnectionListRequestHeader) request.decodeCommandCustomHeader(GetProducerConnectionListRequestHeader.class);
+
+ ProducerConnection bodydata = new ProducerConnection();
+ HashMap<Channel, ClientChannelInfo> channelInfoHashMap =
+ this.brokerController.getProducerManager().getGroupChannelTable().get(requestHeader.getProducerGroup());
+ if (channelInfoHashMap != null) {
+ Iterator<Map.Entry<Channel, ClientChannelInfo>> it = channelInfoHashMap.entrySet().iterator();
+ while (it.hasNext()) {
+ ClientChannelInfo info = it.next().getValue();
+ Connection connection = new Connection();
+ connection.setClientId(info.getClientId());
+ connection.setLanguage(info.getLanguage());
+ connection.setVersion(info.getVersion());
+ connection.setClientAddr(RemotingHelper.parseChannelRemoteAddr(info.getChannel()));
+
+ bodydata.getConnectionSet().add(connection);
+ }
+
+ byte[] body = bodydata.encode();
+ response.setBody(body);
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("the producer group[" + requestHeader.getProducerGroup() + "] not exist");
+ return response;
+ }
+
+ private RemotingCommand getConsumeStats(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ final GetConsumeStatsRequestHeader requestHeader =
+ (GetConsumeStatsRequestHeader) request.decodeCommandCustomHeader(GetConsumeStatsRequestHeader.class);
+
+ ConsumeStats consumeStats = new ConsumeStats();
+
+ Set<String> topics = new HashSet<String>();
+ if (UtilAll.isBlank(requestHeader.getTopic())) {
+ topics = this.brokerController.getConsumerOffsetManager().whichTopicByConsumer(requestHeader.getConsumerGroup());
+ } else {
+ topics.add(requestHeader.getTopic());
+ }
+
+ for (String topic : topics) {
+ TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
+ if (null == topicConfig) {
+ log.warn("consumeStats, topic config not exist, {}", topic);
+ continue;
+ }
+
+ /**
+
+ */
+ {
+ SubscriptionData findSubscriptionData =
+ this.brokerController.getConsumerManager().findSubscriptionData(requestHeader.getConsumerGroup(), topic);
+
+ if (null == findSubscriptionData //
+ && this.brokerController.getConsumerManager().findSubscriptionDataCount(requestHeader.getConsumerGroup()) > 0) {
+ log.warn("consumeStats, the consumer group[{}], topic[{}] not exist", requestHeader.getConsumerGroup(), topic);
+ continue;
+ }
+ }
+
+ for (int i = 0; i < topicConfig.getReadQueueNums(); i++) {
+ MessageQueue mq = new MessageQueue();
+ mq.setTopic(topic);
+ mq.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());
+ mq.setQueueId(i);
+
+ OffsetWrapper offsetWrapper = new OffsetWrapper();
+
+ long brokerOffset = this.brokerController.getMessageStore().getMaxOffsetInQuque(topic, i);
+ if (brokerOffset < 0)
+ brokerOffset = 0;
+
+ long consumerOffset = this.brokerController.getConsumerOffsetManager().queryOffset(//
+ requestHeader.getConsumerGroup(), //
+ topic, //
+ i);
+ if (consumerOffset < 0)
+ consumerOffset = 0;
+
+ offsetWrapper.setBrokerOffset(brokerOffset);
+ offsetWrapper.setConsumerOffset(consumerOffset);
+
+
+ long timeOffset = consumerOffset - 1;
+ if (timeOffset >= 0) {
+ long lastTimestamp = this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i, timeOffset);
+ if (lastTimestamp > 0) {
+ offsetWrapper.setLastTimestamp(lastTimestamp);
+ }
+ }
+
+ consumeStats.getOffsetTable().put(mq, offsetWrapper);
+ }
+
+ double consumeTps = this.brokerController.getBrokerStatsManager().tpsGroupGetNums(requestHeader.getConsumerGroup(), topic);
+
+ consumeTps += consumeStats.getConsumeTps();
+ consumeStats.setConsumeTps(consumeTps);
+ }
+
+ byte[] body = consumeStats.encode();
+ response.setBody(body);
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand getAllConsumerOffset(ChannelHandlerContext ctx, RemotingCommand request) {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+
+ String content = this.brokerController.getConsumerOffsetManager().encode();
+ if (content != null && content.length() > 0) {
+ try {
+ response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
+ } catch (UnsupportedEncodingException e) {
+ log.error("get all consumer offset from master error.", e);
+
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("UnsupportedEncodingException " + e);
+ return response;
+ }
+ } else {
+ log.error("No consumer offset in this broker, client: " + ctx.channel().remoteAddress());
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("No consumer offset in this broker");
+ return response;
+ }
+
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+
+ return response;
+ }
+
+ private RemotingCommand getAllDelayOffset(ChannelHandlerContext ctx, RemotingCommand request) {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+
+ String content = ((DefaultMessageStore) this.brokerController.getMessageStore()).getScheduleMessageService().encode();
+ if (content != null && content.length() > 0) {
+ try {
+ response.setBody(content.getBytes(MixAll.DEFAULT_CHARSET));
+ } catch (UnsupportedEncodingException e) {
+ log.error("get all delay offset from master error.", e);
+
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("UnsupportedEncodingException " + e);
+ return response;
+ }
+ } else {
+ log.error("No delay offset in this broker, client: " + ctx.channel().remoteAddress());
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark("No delay offset in this broker");
+ return response;
+ }
+
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+
+ return response;
+ }
+
+ public RemotingCommand resetOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final ResetOffsetRequestHeader requestHeader =
+ (ResetOffsetRequestHeader) request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
+ log.info("[reset-offset] reset offset started by {}. topic={}, group={}, timestamp={}, isForce={}",
+ new Object[]{RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
+ requestHeader.getTimestamp(), requestHeader.isForce()});
+ boolean isC = false;
+ LanguageCode language = request.getLanguage();
+ switch (language) {
+ case CPP:
+ isC = true;
+ break;
+ }
+ return this.brokerController.getBroker2Client().resetOffset(requestHeader.getTopic(), requestHeader.getGroup(),
+ requestHeader.getTimestamp(), requestHeader.isForce(), isC);
+ }
+
+ public RemotingCommand getConsumerStatus(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final GetConsumerStatusRequestHeader requestHeader =
+ (GetConsumerStatusRequestHeader) request.decodeCommandCustomHeader(GetConsumerStatusRequestHeader.class);
+
+ log.info("[get-consumer-status] get consumer status by {}. topic={}, group={}",
+ new Object[]{RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup()});
+
+ return this.brokerController.getBroker2Client().getConsumeStatus(requestHeader.getTopic(), requestHeader.getGroup(),
+ requestHeader.getClientAddr());
+ }
+
+ private RemotingCommand queryTopicConsumeByWho(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ QueryTopicConsumeByWhoRequestHeader requestHeader =
+ (QueryTopicConsumeByWhoRequestHeader) request.decodeCommandCustomHeader(QueryTopicConsumeByWhoRequestHeader.class);
+
+
+ HashSet<String> groups = this.brokerController.getConsumerManager().queryTopicConsumeByWho(requestHeader.getTopic());
+
+ Set<String> groupInOffset = this.brokerController.getConsumerOffsetManager().whichGroupByTopic(requestHeader.getTopic());
+ if (groupInOffset != null && !groupInOffset.isEmpty()) {
+ groups.addAll(groupInOffset);
+ }
+
+ GroupList groupList = new GroupList();
+ groupList.setGroupList(groups);
+ byte[] body = groupList.encode();
+
+ response.setBody(body);
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand registerFilterServer(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(RegisterFilterServerResponseHeader.class);
+ final RegisterFilterServerResponseHeader responseHeader = (RegisterFilterServerResponseHeader) response.readCustomHeader();
+ final RegisterFilterServerRequestHeader requestHeader =
+ (RegisterFilterServerRequestHeader) request.decodeCommandCustomHeader(RegisterFilterServerRequestHeader.class);
+
+ this.brokerController.getFilterServerManager().registerFilterServer(ctx.channel(), requestHeader.getFilterServerAddr());
+
+ responseHeader.setBrokerId(this.brokerController.getBrokerConfig().getBrokerId());
+ responseHeader.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());
+
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand queryConsumeTimeSpan(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ QueryConsumeTimeSpanRequestHeader requestHeader =
+ (QueryConsumeTimeSpanRequestHeader) request.decodeCommandCustomHeader(QueryConsumeTimeSpanRequestHeader.class);
+
+ final String topic = requestHeader.getTopic();
+ TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
+ if (null == topicConfig) {
+ response.setCode(ResponseCode.TOPIC_NOT_EXIST);
+ response.setRemark("topic[" + topic + "] not exist");
+ return response;
+ }
+
+ List<QueueTimeSpan> timeSpanSet = new ArrayList<QueueTimeSpan>();
+ for (int i = 0; i < topicConfig.getWriteQueueNums(); i++) {
+ QueueTimeSpan timeSpan = new QueueTimeSpan();
+ MessageQueue mq = new MessageQueue();
+ mq.setTopic(topic);
+ mq.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());
+ mq.setQueueId(i);
+ timeSpan.setMessageQueue(mq);
+
+ long minTime = this.brokerController.getMessageStore().getEarliestMessageTime(topic, i);
+ timeSpan.setMinTimeStamp(minTime);
+
+ long max = this.brokerController.getMessageStore().getMaxOffsetInQuque(topic, i);
+ long maxTime = this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i, max - 1);
+ timeSpan.setMaxTimeStamp(maxTime);
+
+ long consumeTime;
+ long consumerOffset = this.brokerController.getConsumerOffsetManager().queryOffset(
+ requestHeader.getGroup(), topic, i);
+ if (consumerOffset > 0) {
+ consumeTime = this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i, consumerOffset - 1);
+ } else {
+ consumeTime = minTime;
+ }
+ timeSpan.setConsumeTimeStamp(consumeTime);
+
+ long maxBrokerOffset = this.brokerController.getMessageStore().getMaxOffsetInQuque(requestHeader.getTopic(), i);
+ if (consumerOffset < maxBrokerOffset) {
+ long nextTime = this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i, consumerOffset);
+ timeSpan.setDelayTime(System.currentTimeMillis() - nextTime);
+ }
+ timeSpanSet.add(timeSpan);
+ }
+
+ QueryConsumeTimeSpanBody queryConsumeTimeSpanBody = new QueryConsumeTimeSpanBody();
+ queryConsumeTimeSpanBody.setConsumeTimeSpanSet(timeSpanSet);
+ response.setBody(queryConsumeTimeSpanBody.encode());
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand getSystemTopicListFromBroker(ChannelHandlerContext ctx, RemotingCommand request)
+ throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+
+ Set<String> topics = this.brokerController.getTopicConfigManager().getSystemTopic();
+ TopicList topicList = new TopicList();
+ topicList.setTopicList(topics);
+ response.setBody(topicList.encode());
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ public RemotingCommand cleanExpiredConsumeQueue() {
+ log.warn("invoke cleanExpiredConsumeQueue start.");
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ brokerController.getMessageStore().cleanExpiredConsumerQueue();
+ log.warn("invoke cleanExpiredConsumeQueue end.");
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ public RemotingCommand cleanUnusedTopic() {
+ log.warn("invoke cleanUnusedTopic start.");
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ brokerController.getMessageStore().cleanUnusedTopic(brokerController.getTopicConfigManager().getTopicConfigTable().keySet());
+ log.warn("invoke cleanUnusedTopic end.");
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ /**
+
+ */
+ private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final GetConsumerRunningInfoRequestHeader requestHeader =
+ (GetConsumerRunningInfoRequestHeader) request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class);
+
+ return this.callConsumer(RequestCode.GET_CONSUMER_RUNNING_INFO, request, requestHeader.getConsumerGroup(),
+ requestHeader.getClientId());
+ }
+
+ private RemotingCommand queryCorrectionOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ QueryCorrectionOffsetHeader requestHeader =
+ (QueryCorrectionOffsetHeader) request.decodeCommandCustomHeader(QueryCorrectionOffsetHeader.class);
+
+ Map<Integer, Long> correctionOffset = this.brokerController.getConsumerOffsetManager()
+ .queryMinOffsetInAllGroup(requestHeader.getTopic(), requestHeader.getFilterGroups());
+
+ Map<Integer, Long> compareOffset =
+ this.brokerController.getConsumerOffsetManager().queryOffset(requestHeader.getTopic(), requestHeader.getCompareGroup());
+
+ if (compareOffset != null && !compareOffset.isEmpty()) {
+ for (Map.Entry<Integer, Long> entry : compareOffset.entrySet()) {
+ Integer queueId = entry.getKey();
+ correctionOffset.put(queueId,
+ correctionOffset.get(queueId) > entry.getValue() ? Long.MAX_VALUE : correctionOffset.get(queueId));
+ }
+ }
+
+ QueryCorrectionOffsetBody body = new QueryCorrectionOffsetBody();
+ body.setCorrectionOffsets(correctionOffset);
+ response.setBody(body.encode());
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand consumeMessageDirectly(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final ConsumeMessageDirectlyResultRequestHeader requestHeader = (ConsumeMessageDirectlyResultRequestHeader) request
+ .decodeCommandCustomHeader(ConsumeMessageDirectlyResultRequestHeader.class);
+
+ request.getExtFields().put("brokerName", this.brokerController.getBrokerConfig().getBrokerName());
+ SelectMappedBufferResult selectMappedBufferResult = null;
+ try {
+ MessageId messageId = MessageDecoder.decodeMessageId(requestHeader.getMsgId());
+ selectMappedBufferResult = this.brokerController.getMessageStore().selectOneMessageByOffset(messageId.getOffset());
+
+ byte[] body = new byte[selectMappedBufferResult.getSize()];
+ selectMappedBufferResult.getByteBuffer().get(body);
+ request.setBody(body);
+ } catch (UnknownHostException e) {
+ } finally {
+ if (selectMappedBufferResult != null) {
+ selectMappedBufferResult.release();
+ }
+ }
+
+ return this.callConsumer(RequestCode.CONSUME_MESSAGE_DIRECTLY, request, requestHeader.getConsumerGroup(),
+ requestHeader.getClientId());
+ }
+
+ private RemotingCommand cloneGroupOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ CloneGroupOffsetRequestHeader requestHeader =
+ (CloneGroupOffsetRequestHeader) request.decodeCommandCustomHeader(CloneGroupOffsetRequestHeader.class);
+
+ Set<String> topics;
+ if (UtilAll.isBlank(requestHeader.getTopic())) {
+ topics = this.brokerController.getConsumerOffsetManager().whichTopicByConsumer(requestHeader.getSrcGroup());
+ } else {
+ topics = new HashSet<String>();
+ topics.add(requestHeader.getTopic());
+ }
+
+ for (String topic : topics) {
+ TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
+ if (null == topicConfig) {
+ log.warn("[cloneGroupOffset], topic config not exist, {}", topic);
+ continue;
+ }
+
+ /**
+
+ */
+ if (!requestHeader.isOffline()) {
+
+ SubscriptionData findSubscriptionData =
+ this.brokerController.getConsumerManager().findSubscriptionData(requestHeader.getSrcGroup(), topic);
+ if (this.brokerController.getConsumerManager().findSubscriptionDataCount(requestHeader.getSrcGroup()) > 0
+ && findSubscriptionData == null) {
+ log.warn("[cloneGroupOffset], the consumer group[{}], topic[{}] not exist", requestHeader.getSrcGroup(), topic);
+ continue;
+ }
+ }
+
+ this.brokerController.getConsumerOffsetManager().cloneOffset(requestHeader.getSrcGroup(), requestHeader.getDestGroup(),
+ requestHeader.getTopic());
+ }
+
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand ViewBrokerStatsData(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
+ final ViewBrokerStatsDataRequestHeader requestHeader =
+ (ViewBrokerStatsDataRequestHeader) request.decodeCommandCustomHeader(ViewBrokerStatsDataRequestHeader.class);
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ DefaultMessageStore messageStore = (DefaultMessageStore) this.brokerController.getMessageStore();
+
+ StatsItem statsItem = messageStore.getBrokerStatsManager().getStatsItem(requestHeader.getStatsName(), requestHeader.getStatsKey());
+ if (null == statsItem) {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark(String.format("The stats <%s> <%s> not exist", requestHeader.getStatsName(), requestHeader.getStatsKey()));
+ return response;
+ }
+
+ BrokerStatsData brokerStatsData = new BrokerStatsData();
+
+ {
+ BrokerStatsItem it = new BrokerStatsItem();
+ StatsSnapshot ss = statsItem.getStatsDataInMinute();
+ it.setSum(ss.getSum());
+ it.setTps(ss.getTps());
+ it.setAvgpt(ss.getAvgpt());
+ brokerStatsData.setStatsMinute(it);
+ }
+
+
+ {
+ BrokerStatsItem it = new BrokerStatsItem();
+ StatsSnapshot ss = statsItem.getStatsDataInHour();
+ it.setSum(ss.getSum());
+ it.setTps(ss.getTps());
+ it.setAvgpt(ss.getAvgpt());
+ brokerStatsData.setStatsHour(it);
+ }
+
+
+ {
+ BrokerStatsItem it = new BrokerStatsItem();
+ StatsSnapshot ss = statsItem.getStatsDataInDay();
+ it.setSum(ss.getSum());
+ it.setTps(ss.getTps());
+ it.setAvgpt(ss.getAvgpt());
+ brokerStatsData.setStatsDay(it);
+ }
+
+ response.setBody(brokerStatsData.encode());
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private RemotingCommand fetchAllConsumeStatsInBroker(ChannelHandlerContext ctx, RemotingCommand request)
+ throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ GetConsumeStatsInBrokerHeader requestHeader =
+ (GetConsumeStatsInBrokerHeader) request.decodeCommandCustomHeader(GetConsumeStatsInBrokerHeader.class);
+ boolean isOrder = requestHeader.isOrder();
+ ConcurrentHashMap<String, SubscriptionGroupConfig> subscriptionGroups =
+ brokerController.getSubscriptionGroupManager().getSubscriptionGroupTable();
+
+ List<Map<String/* subscriptionGroupName */, List<ConsumeStats>>> brokerConsumeStatsList =
+ new ArrayList<Map<String, List<ConsumeStats>>>();
+
+ long totalDiff = 0L;
+
+ for (String group : subscriptionGroups.keySet()) {
+ Map<String, List<ConsumeStats>> subscripTopicConsumeMap = new HashMap<String, List<ConsumeStats>>();
+ Set<String> topics = this.brokerController.getConsumerOffsetManager().whichTopicByConsumer(group);
+ List<ConsumeStats> consumeStatsList = new ArrayList<ConsumeStats>();
+ for (String topic : topics) {
+ ConsumeStats consumeStats = new ConsumeStats();
+ TopicConfig topicConfig = this.brokerController.getTopicConfigManager().selectTopicConfig(topic);
+ if (null == topicConfig) {
+ log.warn("consumeStats, topic config not exist, {}", topic);
+ continue;
+ }
+
+ if (isOrder && !topicConfig.isOrder()) {
+ continue;
+ }
+ /**
+
+ */
+ {
+ SubscriptionData findSubscriptionData = this.brokerController.getConsumerManager().findSubscriptionData(group, topic);
+
+ if (null == findSubscriptionData //
+ && this.brokerController.getConsumerManager().findSubscriptionDataCount(group) > 0) {
+ log.warn("consumeStats, the consumer group[{}], topic[{}] not exist", group, topic);
+ continue;
+ }
+ }
+
+ for (int i = 0; i < topicConfig.getWriteQueueNums(); i++) {
+ MessageQueue mq = new MessageQueue();
+ mq.setTopic(topic);
+ mq.setBrokerName(this.brokerController.getBrokerConfig().getBrokerName());
+ mq.setQueueId(i);
+ OffsetWrapper offsetWrapper = new OffsetWrapper();
+ long brokerOffset = this.brokerController.getMessageStore().getMaxOffsetInQuque(topic, i);
+ if (brokerOffset < 0)
+ brokerOffset = 0;
+ long consumerOffset = this.brokerController.getConsumerOffsetManager().queryOffset(//
+ group, //
+ topic, //
+ i);
+ if (consumerOffset < 0)
+ consumerOffset = 0;
+
+ offsetWrapper.setBrokerOffset(brokerOffset);
+ offsetWrapper.setConsumerOffset(consumerOffset);
+
+
+ long timeOffset = consumerOffset - 1;
+ if (timeOffset >= 0) {
+ long lastTimestamp = this.brokerController.getMessageStore().getMessageStoreTimeStamp(topic, i, timeOffset);
+ if (lastTimestamp > 0) {
+ offsetWrapper.setLastTimestamp(lastTimestamp);
+ }
+ }
+ consumeStats.getOffsetTable().put(mq, offsetWrapper);
+ }
+ double consumeTps = this.brokerController.getBrokerStatsManager().tpsGroupGetNums(group, topic);
+ consumeTps += consumeStats.getConsumeTps();
+ consumeStats.setConsumeTps(consumeTps);
+ totalDiff += consumeStats.computeTotalDiff();
+ consumeStatsList.add(consumeStats);
+ }
+ subscripTopicConsumeMap.put(group, consumeStatsList);
+ brokerConsumeStatsList.add(subscripTopicConsumeMap);
+ }
+ ConsumeStatsList consumeStats = new ConsumeStatsList();
+ consumeStats.setBrokerAddr(brokerController.getBrokerAddr());
+ consumeStats.setConsumeStatsList(brokerConsumeStatsList);
+ consumeStats.setTotalDiff(totalDiff);
+ response.setBody(consumeStats.encode());
+ response.setCode(ResponseCode.SUCCESS);
+ response.setRemark(null);
+ return response;
+ }
+
+ private HashMap<String, String> prepareRuntimeInfo() {
+ HashMap<String, String> runtimeInfo = this.brokerController.getMessageStore().getRuntimeInfo();
+ runtimeInfo.put("brokerVersionDesc", MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION));
+ runtimeInfo.put("brokerVersion", String.valueOf(MQVersion.CURRENT_VERSION));
+
+ runtimeInfo.put("msgPutTotalYesterdayMorning",
+ String.valueOf(this.brokerController.getBrokerStats().getMsgPutTotalYesterdayMorning()));
+ runtimeInfo.put("msgPutTotalTodayMorning", String.valueOf(this.brokerController.getBrokerStats().getMsgPutTotalTodayMorning()));
+ runtimeInfo.put("msgPutTotalTodayNow", String.valueOf(this.brokerController.getBrokerStats().getMsgPutTotalTodayNow()));
+
+ runtimeInfo.put("msgGetTotalYesterdayMorning",
+ String.valueOf(this.brokerController.getBrokerStats().getMsgGetTotalYesterdayMorning()));
+ runtimeInfo.put("msgGetTotalTodayMorning", String.valueOf(this.brokerController.getBrokerStats().getMsgGetTotalTodayMorning()));
+ runtimeInfo.put("msgGetTotalTodayNow", String.valueOf(this.brokerController.getBrokerStats().getMsgGetTotalTodayNow()));
+
+ runtimeInfo.put("sendThreadPoolQueueSize", String.valueOf(this.brokerController.getSendThreadPoolQueue().size()));
+
+ runtimeInfo.put("sendThreadPoolQueueCapacity",
+ String.valueOf(this.brokerController.getBrokerConfig().getSendThreadPoolQueueCapacity()));
+
+ runtimeInfo.put("pullThreadPoolQueueSize", String.valueOf(this.brokerController.getPullThreadPoolQueue().size()));
+ runtimeInfo.put("pullThreadPoolQueueCapacity",
+ String.valueOf(this.brokerController.getBrokerConfig().getPullThreadPoolQueueCapacity()));
+
+ runtimeInfo.put("dispatchBehindBytes", String.valueOf(this.brokerController.getMessageStore().dispatchBehindBytes()));
+ runtimeInfo.put("pageCacheLockTimeMills", String.valueOf(this.brokerController.getMessageStore().lockTimeMills()));
+
+ runtimeInfo.put("sendThreadPoolQueueHeadWaitTimeMills", String.valueOf(this.brokerController.headSlowTimeMills4SendThreadPoolQueue()));
+ runtimeInfo.put("pullThreadPoolQueueHeadWaitTimeMills", String.valueOf(this.brokerController.headSlowTimeMills4PullThreadPoolQueue()));
+ runtimeInfo.put("earliestMessageTimeStamp", String.valueOf(this.brokerController.getMessageStore().getEarliestMessageTime()));
+ runtimeInfo.put("startAcceptSendRequestTimeStamp", String.valueOf(this.brokerController.getBrokerConfig().getStartAcceptSendRequestTimeStamp()));
+ if (this.brokerController.getMessageStore() instanceof DefaultMessageStore) {
+ DefaultMessageStore defaultMessageStore = (DefaultMessageStore) this.brokerController.getMessageStore();
+ runtimeInfo.put("remainTransientStoreBufferNumbs", String.valueOf(defaultMessageStore.remainTransientStoreBufferNumbs()));
+ if (defaultMessageStore.getMessageStoreConfig().isTransientStorePoolEnable()) {
+ runtimeInfo.put("remainHowManyDataToCommit", MixAll.humanReadableByteCount(defaultMessageStore.getCommitLog().remainHowManyDataToCommit(), false));
+ }
+ runtimeInfo.put("remainHowManyDataToFlush", MixAll.humanReadableByteCount(defaultMessageStore.getCommitLog().remainHowManyDataToFlush(), false));
+ }
+
+ java.io.File commitLogDir = new java.io.File(this.brokerController.getMessageStoreConfig().getStorePathRootDir());
+ if (commitLogDir.exists()) {
+ runtimeInfo.put("commitLogDirCapacity", String.format("Total : %s, Free : %s.", MixAll.humanReadableByteCount(commitLogDir.getTotalSpace(), false), MixAll.humanReadableByteCount(commitLogDir.getFreeSpace(), false)));
+ }
+
+ return runtimeInfo;
+ }
+
+ private RemotingCommand callConsumer(//
+ final int requestCode, //
+ final RemotingCommand request, //
+ final String consumerGroup, //
+ final String clientId) throws RemotingCommandException {
+ final RemotingCommand response = RemotingCommand.createResponseCommand(null);
+ ClientChannelInfo clientChannelInfo = this.brokerController.getConsumerManager().findChannel(consumerGroup, clientId);
+
+ if (null == clientChannelInfo) {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark(String.format("The Consumer <%s> <%s> not online", consumerGroup, clientId));
+ return response;
+ }
+
+ if (clientChannelInfo.getVersion() < MQVersion.Version.V3_1_8_SNAPSHOT.ordinal()) {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark(String.format("The Consumer <%s> Version <%s> too low to finish, please upgrade it to V3_1_8_SNAPSHOT", //
+ clientId, //
+ MQVersion.getVersionDesc(clientChannelInfo.getVersion())));
+ return response;
+ }
+
+ try {
+ RemotingCommand newRequest = RemotingCommand.createRequestCommand(requestCode, null);
+ newRequest.setExtFields(request.getExtFields());
+ newRequest.setBody(request.getBody());
+
+ RemotingCommand consumerResponse =
+ this.brokerController.getBroker2Client().callClient(clientChannelInfo.getChannel(), newRequest);
+ return consumerResponse;
+ } catch (RemotingTimeoutException e) {
+ response.setCode(ResponseCode.CONSUME_MSG_TIMEOUT);
+ response
+ .setRemark(String.format("consumer <%s> <%s> Timeout: %s", consumerGroup, clientId, RemotingHelper.exceptionSimpleDesc(e)));
+ return response;
+ } catch (Exception e) {
+ response.setCode(ResponseCode.SYSTEM_ERROR);
+ response.setRemark(
+ String.format("invoke consumer <%s> <%s> Exception: %s", consumerGroup, clientId, RemotingHelper.exceptionSimpleDesc(e)));
+ return response;
+ }
+ }
+
+}
[13/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/route/TopicRouteData.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/route/TopicRouteData.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/route/TopicRouteData.java
deleted file mode 100644
index 72e1b96..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/route/TopicRouteData.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- * 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.
- */
-
-/**
- * $Id: TopicRouteData.java 1835 2013-05-16 02:00:50Z shijia.wxr $
- */
-package com.alibaba.rocketmq.common.protocol.route;
-
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-
-/**
- * @author shijia.wxr
- */
-public class TopicRouteData extends RemotingSerializable {
- private String orderTopicConf;
- private List<QueueData> queueDatas;
- private List<BrokerData> brokerDatas;
- private HashMap<String/* brokerAddr */, List<String>/* Filter Server */> filterServerTable;
-
-
- public TopicRouteData cloneTopicRouteData() {
- TopicRouteData topicRouteData = new TopicRouteData();
- topicRouteData.setQueueDatas(new ArrayList<QueueData>());
- topicRouteData.setBrokerDatas(new ArrayList<BrokerData>());
- topicRouteData.setFilterServerTable(new HashMap<String, List<String>>());
- topicRouteData.setOrderTopicConf(this.orderTopicConf);
-
- if (this.queueDatas != null) {
- topicRouteData.getQueueDatas().addAll(this.queueDatas);
- }
-
- if (this.brokerDatas != null) {
- topicRouteData.getBrokerDatas().addAll(this.brokerDatas);
- }
-
- if (this.filterServerTable != null) {
- topicRouteData.getFilterServerTable().putAll(this.filterServerTable);
- }
-
- return topicRouteData;
- }
-
-
- public List<QueueData> getQueueDatas() {
- return queueDatas;
- }
-
-
- public void setQueueDatas(List<QueueData> queueDatas) {
- this.queueDatas = queueDatas;
- }
-
-
- public List<BrokerData> getBrokerDatas() {
- return brokerDatas;
- }
-
-
- public void setBrokerDatas(List<BrokerData> brokerDatas) {
- this.brokerDatas = brokerDatas;
- }
-
- public HashMap<String, List<String>> getFilterServerTable() {
- return filterServerTable;
- }
-
- public void setFilterServerTable(HashMap<String, List<String>> filterServerTable) {
- this.filterServerTable = filterServerTable;
- }
-
- public String getOrderTopicConf() {
- return orderTopicConf;
- }
-
- public void setOrderTopicConf(String orderTopicConf) {
- this.orderTopicConf = orderTopicConf;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((brokerDatas == null) ? 0 : brokerDatas.hashCode());
- result = prime * result + ((orderTopicConf == null) ? 0 : orderTopicConf.hashCode());
- result = prime * result + ((queueDatas == null) ? 0 : queueDatas.hashCode());
- result = prime * result + ((filterServerTable == null) ? 0 : filterServerTable.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- TopicRouteData other = (TopicRouteData) obj;
- if (brokerDatas == null) {
- if (other.brokerDatas != null)
- return false;
- } else if (!brokerDatas.equals(other.brokerDatas))
- return false;
- if (orderTopicConf == null) {
- if (other.orderTopicConf != null)
- return false;
- } else if (!orderTopicConf.equals(other.orderTopicConf))
- return false;
- if (queueDatas == null) {
- if (other.queueDatas != null)
- return false;
- } else if (!queueDatas.equals(other.queueDatas))
- return false;
- if (filterServerTable == null) {
- if (other.filterServerTable != null)
- return false;
- } else if (!filterServerTable.equals(other.filterServerTable))
- return false;
- return true;
- }
-
- @Override
- public String toString() {
- return "TopicRouteData [orderTopicConf=" + orderTopicConf + ", queueDatas=" + queueDatas
- + ", brokerDatas=" + brokerDatas + ", filterServerTable=" + filterServerTable + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/protocol/topic/OffsetMovedEvent.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/protocol/topic/OffsetMovedEvent.java b/common/src/main/java/com/alibaba/rocketmq/common/protocol/topic/OffsetMovedEvent.java
deleted file mode 100644
index 86bdd3d..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/protocol/topic/OffsetMovedEvent.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * 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.common.protocol.topic;
-
-import com.alibaba.rocketmq.common.message.MessageQueue;
-import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
-
-
-public class OffsetMovedEvent extends RemotingSerializable {
- private String consumerGroup;
- private MessageQueue messageQueue;
- private long offsetRequest;
- private long offsetNew;
-
-
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
-
- public void setConsumerGroup(String consumerGroup) {
- this.consumerGroup = consumerGroup;
- }
-
-
- public MessageQueue getMessageQueue() {
- return messageQueue;
- }
-
-
- public void setMessageQueue(MessageQueue messageQueue) {
- this.messageQueue = messageQueue;
- }
-
-
- public long getOffsetRequest() {
- return offsetRequest;
- }
-
-
- public void setOffsetRequest(long offsetRequest) {
- this.offsetRequest = offsetRequest;
- }
-
-
- public long getOffsetNew() {
- return offsetNew;
- }
-
-
- public void setOffsetNew(long offsetNew) {
- this.offsetNew = offsetNew;
- }
-
-
- @Override
- public String toString() {
- return "OffsetMovedEvent [consumerGroup=" + consumerGroup + ", messageQueue=" + messageQueue
- + ", offsetRequest=" + offsetRequest + ", offsetNew=" + offsetNew + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/queue/ConcurrentTreeMap.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/queue/ConcurrentTreeMap.java b/common/src/main/java/com/alibaba/rocketmq/common/queue/ConcurrentTreeMap.java
deleted file mode 100644
index 8fc4e76..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/queue/ConcurrentTreeMap.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * 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.common.queue;
-
-import com.alibaba.rocketmq.common.constant.LoggerName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Comparator;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.concurrent.locks.ReentrantLock;
-
-
-/**
- * thread safe
- *
- * @author lansheng.zj
- */
-public class ConcurrentTreeMap<K, V> {
- private static final Logger log = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
- private final ReentrantLock lock;
- private TreeMap<K, V> tree;
- private RoundQueue<K> roundQueue;
-
-
- public ConcurrentTreeMap(int capacity, Comparator<? super K> comparator) {
- tree = new TreeMap<K, V>(comparator);
- roundQueue = new RoundQueue<K>(capacity);
- lock = new ReentrantLock(true);
- }
-
-
- public Map.Entry<K, V> pollFirstEntry() {
- lock.lock();
- try {
- return tree.pollFirstEntry();
- } finally {
- lock.unlock();
- }
- }
-
-
- public V putIfAbsentAndRetExsit(K key, V value) {
- lock.lock();
- try {
- if (roundQueue.put(key)) {
- V exsit = tree.get(key);
- if (null == exsit) {
- tree.put(key, value);
- exsit = value;
- }
- log.warn("putIfAbsentAndRetExsit success. {}", key);
- return exsit;
- }
-
- else {
- V exsit = tree.get(key);
- return exsit;
- }
- } finally {
- lock.unlock();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/queue/RoundQueue.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/queue/RoundQueue.java b/common/src/main/java/com/alibaba/rocketmq/common/queue/RoundQueue.java
deleted file mode 100644
index a3783ba..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/queue/RoundQueue.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * 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.common.queue;
-
-import java.util.LinkedList;
-import java.util.Queue;
-
-
-/**
- * not thread safe
- *
- * @author lansheng.zj
- */
-public class RoundQueue<E> {
-
- private Queue<E> queue;
- private int capacity;
-
-
- public RoundQueue(int capacity) {
- this.capacity = capacity;
- queue = new LinkedList<E>();
- }
-
-
- public boolean put(E e) {
- boolean ok = false;
- if (!queue.contains(e)) {
- if (queue.size() >= capacity) {
- queue.poll();
- }
- queue.add(e);
- ok = true;
- }
-
- return ok;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/running/RunningStats.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/running/RunningStats.java b/common/src/main/java/com/alibaba/rocketmq/common/running/RunningStats.java
deleted file mode 100644
index aa0bc54..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/running/RunningStats.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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.common.running;
-
-public enum RunningStats {
- commitLogMaxOffset,
- commitLogMinOffset,
- commitLogDiskRatio,
- consumeQueueDiskRatio,
- scheduleMessageOffset,
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/stats/MomentStatsItem.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/stats/MomentStatsItem.java b/common/src/main/java/com/alibaba/rocketmq/common/stats/MomentStatsItem.java
deleted file mode 100644
index 89eefa5..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/stats/MomentStatsItem.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * 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.common.stats;
-
-import com.alibaba.rocketmq.common.UtilAll;
-import org.slf4j.Logger;
-
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-
-
-public class MomentStatsItem {
-
- private final AtomicLong value = new AtomicLong(0);
-
- private final String statsName;
- private final String statsKey;
- private final ScheduledExecutorService scheduledExecutorService;
- private final Logger log;
-
-
- public MomentStatsItem(String statsName, String statsKey,
- ScheduledExecutorService scheduledExecutorService, Logger log) {
- this.statsName = statsName;
- this.statsKey = statsKey;
- this.scheduledExecutorService = scheduledExecutorService;
- this.log = log;
- }
-
-
- public void init() {
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- printAtMinutes();
-
- MomentStatsItem.this.value.set(0);
- } catch (Throwable e) {
- }
- }
- }, Math.abs(UtilAll.computNextMinutesTimeMillis() - System.currentTimeMillis()), 1000 * 60 * 5, TimeUnit.MILLISECONDS);
- }
-
-
- public void printAtMinutes() {
- log.info(String.format("[%s] [%s] Stats Every 5 Minutes, Value: %d",
- this.statsName,
- this.statsKey,
- this.value.get()));
- }
-
- public AtomicLong getValue() {
- return value;
- }
-
-
- public String getStatsKey() {
- return statsKey;
- }
-
-
- public String getStatsName() {
- return statsName;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/stats/MomentStatsItemSet.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/stats/MomentStatsItemSet.java b/common/src/main/java/com/alibaba/rocketmq/common/stats/MomentStatsItemSet.java
deleted file mode 100644
index fde88cd..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/stats/MomentStatsItemSet.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * 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.common.stats;
-
-import com.alibaba.rocketmq.common.UtilAll;
-import org.slf4j.Logger;
-
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-
-public class MomentStatsItemSet {
- private final ConcurrentHashMap<String/* key */, MomentStatsItem> statsItemTable =
- new ConcurrentHashMap<String, MomentStatsItem>(128);
- private final String statsName;
- private final ScheduledExecutorService scheduledExecutorService;
- private final Logger log;
-
-
- public MomentStatsItemSet(String statsName, ScheduledExecutorService scheduledExecutorService, Logger log) {
- this.statsName = statsName;
- this.scheduledExecutorService = scheduledExecutorService;
- this.log = log;
- this.init();
- }
-
- public ConcurrentHashMap<String, MomentStatsItem> getStatsItemTable() {
- return statsItemTable;
- }
-
- public String getStatsName() {
- return statsName;
- }
-
- public void init() {
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- printAtMinutes();
- } catch (Throwable e) {
- }
- }
- }, Math.abs(UtilAll.computNextMinutesTimeMillis() - System.currentTimeMillis()), 1000 * 60 * 5, TimeUnit.MILLISECONDS);
- }
-
- private void printAtMinutes() {
- Iterator<Entry<String, MomentStatsItem>> it = this.statsItemTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, MomentStatsItem> next = it.next();
- next.getValue().printAtMinutes();
- }
- }
-
- public void setValue(final String statsKey, final int value) {
- MomentStatsItem statsItem = this.getAndCreateStatsItem(statsKey);
- statsItem.getValue().set(value);
- }
-
- public MomentStatsItem getAndCreateStatsItem(final String statsKey) {
- MomentStatsItem statsItem = this.statsItemTable.get(statsKey);
- if (null == statsItem) {
- statsItem =
- new MomentStatsItem(this.statsName, statsKey, this.scheduledExecutorService, this.log);
- MomentStatsItem prev = this.statsItemTable.put(statsKey, statsItem);
-
- if (null == prev) {
-
- // statsItem.init();
- }
- }
-
- return statsItem;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/stats/StatsItem.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/stats/StatsItem.java b/common/src/main/java/com/alibaba/rocketmq/common/stats/StatsItem.java
deleted file mode 100644
index 1c99699..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/stats/StatsItem.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/**
- * 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.common.stats;
-
-import com.alibaba.rocketmq.common.UtilAll;
-import org.slf4j.Logger;
-
-import java.util.LinkedList;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-
-
-public class StatsItem {
-
- private final AtomicLong value = new AtomicLong(0);
-
- private final AtomicLong times = new AtomicLong(0);
-
- private final LinkedList<CallSnapshot> csListMinute = new LinkedList<CallSnapshot>();
-
-
- private final LinkedList<CallSnapshot> csListHour = new LinkedList<CallSnapshot>();
-
-
- private final LinkedList<CallSnapshot> csListDay = new LinkedList<CallSnapshot>();
-
- private final String statsName;
- private final String statsKey;
- private final ScheduledExecutorService scheduledExecutorService;
- private final Logger log;
-
-
- public StatsItem(String statsName, String statsKey, ScheduledExecutorService scheduledExecutorService,
- Logger log) {
- this.statsName = statsName;
- this.statsKey = statsKey;
- this.scheduledExecutorService = scheduledExecutorService;
- this.log = log;
- }
-
- public StatsSnapshot getStatsDataInMinute() {
- return computeStatsData(this.csListMinute);
- }
-
- private static StatsSnapshot computeStatsData(final LinkedList<CallSnapshot> csList) {
- StatsSnapshot statsSnapshot = new StatsSnapshot();
- synchronized (csList) {
- double tps = 0;
- double avgpt = 0;
- long sum = 0;
- if (!csList.isEmpty()) {
- CallSnapshot first = csList.getFirst();
- CallSnapshot last = csList.getLast();
- sum = last.getValue() - first.getValue();
- tps = (sum * 1000.0d) / (last.getTimestamp() - first.getTimestamp());
-
- long timesDiff = last.getTimes() - first.getTimes();
- if (timesDiff > 0) {
- avgpt = (sum * 1.0d) / timesDiff;
- }
- }
-
- statsSnapshot.setSum(sum);
- statsSnapshot.setTps(tps);
- statsSnapshot.setAvgpt(avgpt);
- }
-
- return statsSnapshot;
- }
-
- public StatsSnapshot getStatsDataInHour() {
- return computeStatsData(this.csListHour);
- }
-
- public StatsSnapshot getStatsDataInDay() {
- return computeStatsData(this.csListDay);
- }
-
- public void init() {
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- samplingInSeconds();
- } catch (Throwable e) {
- }
- }
- }, 0, 10, TimeUnit.SECONDS);
-
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- samplingInMinutes();
- } catch (Throwable e) {
- }
- }
- }, 0, 10, TimeUnit.MINUTES);
-
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- samplingInHour();
- } catch (Throwable e) {
- }
- }
- }, 0, 1, TimeUnit.HOURS);
-
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- printAtMinutes();
- } catch (Throwable ignored) {
- }
- }
- }, Math.abs(UtilAll.computNextMinutesTimeMillis() - System.currentTimeMillis()), 1000 * 60, TimeUnit.MILLISECONDS);
-
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- printAtHour();
- } catch (Throwable ignored) {
- }
- }
- }, Math.abs(UtilAll.computNextHourTimeMillis() - System.currentTimeMillis()), 1000 * 60 * 60, TimeUnit.MILLISECONDS);
-
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- printAtDay();
- } catch (Throwable ignored) {
- }
- }
- }, Math.abs(UtilAll.computNextMorningTimeMillis() - System.currentTimeMillis()) - 2000, 1000 * 60 * 60 * 24, TimeUnit.MILLISECONDS);
- }
-
- public void samplingInSeconds() {
- synchronized (this.csListMinute) {
- this.csListMinute.add(new CallSnapshot(System.currentTimeMillis(), this.times.get(), this.value
- .get()));
- if (this.csListMinute.size() > 7) {
- this.csListMinute.removeFirst();
- }
- }
- }
-
- public void samplingInMinutes() {
- synchronized (this.csListHour) {
- this.csListHour.add(new CallSnapshot(System.currentTimeMillis(), this.times.get(), this.value
- .get()));
- if (this.csListHour.size() > 7) {
- this.csListHour.removeFirst();
- }
- }
- }
-
- public void samplingInHour() {
- synchronized (this.csListDay) {
- this.csListDay.add(new CallSnapshot(System.currentTimeMillis(), this.times.get(), this.value
- .get()));
- if (this.csListDay.size() > 25) {
- this.csListDay.removeFirst();
- }
- }
- }
-
- public void printAtMinutes() {
- StatsSnapshot ss = computeStatsData(this.csListMinute);
- log.info(String.format("[%s] [%s] Stats In One Minute, SUM: %d TPS: %.2f AVGPT: %.2f",
- this.statsName,
- this.statsKey,
- ss.getSum(),
- ss.getTps(),
- ss.getAvgpt()));
- }
-
- public void printAtHour() {
- StatsSnapshot ss = computeStatsData(this.csListHour);
- log.info(String.format("[%s] [%s] Stats In One Hour, SUM: %d TPS: %.2f AVGPT: %.2f",
- this.statsName,
- this.statsKey,
- ss.getSum(),
- ss.getTps(),
- ss.getAvgpt()));
- }
-
- public void printAtDay() {
- StatsSnapshot ss = computeStatsData(this.csListDay);
- log.info(String.format("[%s] [%s] Stats In One Day, SUM: %d TPS: %.2f AVGPT: %.2f",
- this.statsName,
- this.statsKey,
- ss.getSum(),
- ss.getTps(),
- ss.getAvgpt()));
- }
-
- public AtomicLong getValue() {
- return value;
- }
-
-
- public String getStatsKey() {
- return statsKey;
- }
-
-
- public String getStatsName() {
- return statsName;
- }
-
-
- public AtomicLong getTimes() {
- return times;
- }
-}
-
-
-class CallSnapshot {
- private final long timestamp;
- private final long times;
-
- private final long value;
-
-
- public CallSnapshot(long timestamp, long times, long value) {
- super();
- this.timestamp = timestamp;
- this.times = times;
- this.value = value;
- }
-
-
- public long getTimestamp() {
- return timestamp;
- }
-
-
- public long getTimes() {
- return times;
- }
-
-
- public long getValue() {
- return value;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/stats/StatsItemSet.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/stats/StatsItemSet.java b/common/src/main/java/com/alibaba/rocketmq/common/stats/StatsItemSet.java
deleted file mode 100644
index 8a2b2a1..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/stats/StatsItemSet.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/**
- * 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.common.stats;
-
-import com.alibaba.rocketmq.common.UtilAll;
-import org.slf4j.Logger;
-
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-
-public class StatsItemSet {
- private final ConcurrentHashMap<String/* key */, StatsItem> statsItemTable =
- new ConcurrentHashMap<String, StatsItem>(128);
-
- private final String statsName;
- private final ScheduledExecutorService scheduledExecutorService;
- private final Logger log;
-
-
- public StatsItemSet(String statsName, ScheduledExecutorService scheduledExecutorService, Logger log) {
- this.statsName = statsName;
- this.scheduledExecutorService = scheduledExecutorService;
- this.log = log;
- this.init();
- }
-
- public void init() {
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- samplingInSeconds();
- } catch (Throwable e) {
- }
- }
- }, 0, 10, TimeUnit.SECONDS);
-
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- samplingInMinutes();
- } catch (Throwable e) {
- }
- }
- }, 0, 10, TimeUnit.MINUTES);
-
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- samplingInHour();
- } catch (Throwable e) {
- }
- }
- }, 0, 1, TimeUnit.HOURS);
-
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- printAtMinutes();
- } catch (Throwable e) {
- }
- }
- }, Math.abs(UtilAll.computNextMinutesTimeMillis() - System.currentTimeMillis()), 1000 * 60, TimeUnit.MILLISECONDS);
-
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- printAtHour();
- } catch (Throwable e) {
- }
- }
- }, Math.abs(UtilAll.computNextHourTimeMillis() - System.currentTimeMillis()), 1000 * 60 * 60, TimeUnit.MILLISECONDS);
-
-
- this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- printAtDay();
- } catch (Throwable e) {
- }
- }
- }, Math.abs(UtilAll.computNextMorningTimeMillis() - System.currentTimeMillis()), 1000 * 60 * 60 * 24, TimeUnit.MILLISECONDS);
- }
-
- private void samplingInSeconds() {
- Iterator<Entry<String, StatsItem>> it = this.statsItemTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, StatsItem> next = it.next();
- next.getValue().samplingInSeconds();
- }
- }
-
- private void samplingInMinutes() {
- Iterator<Entry<String, StatsItem>> it = this.statsItemTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, StatsItem> next = it.next();
- next.getValue().samplingInMinutes();
- }
- }
-
- private void samplingInHour() {
- Iterator<Entry<String, StatsItem>> it = this.statsItemTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, StatsItem> next = it.next();
- next.getValue().samplingInHour();
- }
- }
-
- private void printAtMinutes() {
- Iterator<Entry<String, StatsItem>> it = this.statsItemTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, StatsItem> next = it.next();
- next.getValue().printAtMinutes();
- }
- }
-
- private void printAtHour() {
- Iterator<Entry<String, StatsItem>> it = this.statsItemTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, StatsItem> next = it.next();
- next.getValue().printAtHour();
- }
- }
-
- private void printAtDay() {
- Iterator<Entry<String, StatsItem>> it = this.statsItemTable.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, StatsItem> next = it.next();
- next.getValue().printAtDay();
- }
- }
-
- public void addValue(final String statsKey, final int incValue, final int incTimes) {
- StatsItem statsItem = this.getAndCreateStatsItem(statsKey);
- statsItem.getValue().addAndGet(incValue);
- statsItem.getTimes().addAndGet(incTimes);
- }
-
- public StatsItem getAndCreateStatsItem(final String statsKey) {
- StatsItem statsItem = this.statsItemTable.get(statsKey);
- if (null == statsItem) {
- statsItem = new StatsItem(this.statsName, statsKey, this.scheduledExecutorService, this.log);
- StatsItem prev = this.statsItemTable.put(statsKey, statsItem);
-
- if (null == prev) {
-
- // statsItem.init();
- }
- }
-
- return statsItem;
- }
-
- public StatsSnapshot getStatsDataInMinute(final String statsKey) {
- StatsItem statsItem = this.statsItemTable.get(statsKey);
- if (null != statsItem) {
- return statsItem.getStatsDataInMinute();
- }
- return new StatsSnapshot();
- }
-
- public StatsSnapshot getStatsDataInHour(final String statsKey) {
- StatsItem statsItem = this.statsItemTable.get(statsKey);
- if (null != statsItem) {
- return statsItem.getStatsDataInHour();
- }
- return new StatsSnapshot();
- }
-
- public StatsSnapshot getStatsDataInDay(final String statsKey) {
- StatsItem statsItem = this.statsItemTable.get(statsKey);
- if (null != statsItem) {
- return statsItem.getStatsDataInDay();
- }
- return new StatsSnapshot();
- }
-
- public StatsItem getStatsItem(final String statsKey) {
- return this.statsItemTable.get(statsKey);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/stats/StatsSnapshot.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/stats/StatsSnapshot.java b/common/src/main/java/com/alibaba/rocketmq/common/stats/StatsSnapshot.java
deleted file mode 100644
index 4092a2b..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/stats/StatsSnapshot.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * 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.common.stats;
-
-public class StatsSnapshot {
- private long sum;
- private double tps;
- private double avgpt;
-
-
- public long getSum() {
- return sum;
- }
-
-
- public void setSum(long sum) {
- this.sum = sum;
- }
-
-
- public double getTps() {
- return tps;
- }
-
-
- public void setTps(double tps) {
- this.tps = tps;
- }
-
-
- public double getAvgpt() {
- return avgpt;
- }
-
-
- public void setAvgpt(double avgpt) {
- this.avgpt = avgpt;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/subscription/SubscriptionGroupConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/subscription/SubscriptionGroupConfig.java b/common/src/main/java/com/alibaba/rocketmq/common/subscription/SubscriptionGroupConfig.java
deleted file mode 100644
index cf8baf2..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/subscription/SubscriptionGroupConfig.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/**
- * 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.common.subscription;
-
-import com.alibaba.rocketmq.common.MixAll;
-
-
-/**
- * @author shijia.wxr
- */
-public class SubscriptionGroupConfig {
-
- private String groupName;
-
- private boolean consumeEnable = true;
- private boolean consumeFromMinEnable = true;
-
- private boolean consumeBroadcastEnable = true;
-
- private int retryQueueNums = 1;
-
- private int retryMaxTimes = 16;
-
- private long brokerId = MixAll.MASTER_ID;
-
- private long whichBrokerWhenConsumeSlowly = 1;
-
- private boolean notifyConsumerIdsChangedEnable = true;
-
-
- public String getGroupName() {
- return groupName;
- }
-
-
- public void setGroupName(String groupName) {
- this.groupName = groupName;
- }
-
-
- public boolean isConsumeEnable() {
- return consumeEnable;
- }
-
-
- public void setConsumeEnable(boolean consumeEnable) {
- this.consumeEnable = consumeEnable;
- }
-
-
- public boolean isConsumeFromMinEnable() {
- return consumeFromMinEnable;
- }
-
-
- public void setConsumeFromMinEnable(boolean consumeFromMinEnable) {
- this.consumeFromMinEnable = consumeFromMinEnable;
- }
-
-
- public boolean isConsumeBroadcastEnable() {
- return consumeBroadcastEnable;
- }
-
-
- public void setConsumeBroadcastEnable(boolean consumeBroadcastEnable) {
- this.consumeBroadcastEnable = consumeBroadcastEnable;
- }
-
-
- public int getRetryQueueNums() {
- return retryQueueNums;
- }
-
-
- public void setRetryQueueNums(int retryQueueNums) {
- this.retryQueueNums = retryQueueNums;
- }
-
-
- public int getRetryMaxTimes() {
- return retryMaxTimes;
- }
-
-
- public void setRetryMaxTimes(int retryMaxTimes) {
- this.retryMaxTimes = retryMaxTimes;
- }
-
-
- public long getBrokerId() {
- return brokerId;
- }
-
-
- public void setBrokerId(long brokerId) {
- this.brokerId = brokerId;
- }
-
-
- public long getWhichBrokerWhenConsumeSlowly() {
- return whichBrokerWhenConsumeSlowly;
- }
-
-
- public void setWhichBrokerWhenConsumeSlowly(long whichBrokerWhenConsumeSlowly) {
- this.whichBrokerWhenConsumeSlowly = whichBrokerWhenConsumeSlowly;
- }
-
- public boolean isNotifyConsumerIdsChangedEnable() {
- return notifyConsumerIdsChangedEnable;
- }
-
- public void setNotifyConsumerIdsChangedEnable(final boolean notifyConsumerIdsChangedEnable) {
- this.notifyConsumerIdsChangedEnable = notifyConsumerIdsChangedEnable;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (int) (brokerId ^ (brokerId >>> 32));
- result = prime * result + (consumeBroadcastEnable ? 1231 : 1237);
- result = prime * result + (consumeEnable ? 1231 : 1237);
- result = prime * result + (consumeFromMinEnable ? 1231 : 1237);
- result = prime * result + (notifyConsumerIdsChangedEnable ? 1231 : 1237);
- result = prime * result + ((groupName == null) ? 0 : groupName.hashCode());
- result = prime * result + retryMaxTimes;
- result = prime * result + retryQueueNums;
- result =
- prime * result + (int) (whichBrokerWhenConsumeSlowly ^ (whichBrokerWhenConsumeSlowly >>> 32));
- return result;
- }
-
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- SubscriptionGroupConfig other = (SubscriptionGroupConfig) obj;
- if (brokerId != other.brokerId)
- return false;
- if (consumeBroadcastEnable != other.consumeBroadcastEnable)
- return false;
- if (consumeEnable != other.consumeEnable)
- return false;
- if (consumeFromMinEnable != other.consumeFromMinEnable)
- return false;
- if (groupName == null) {
- if (other.groupName != null)
- return false;
- } else if (!groupName.equals(other.groupName))
- return false;
- if (retryMaxTimes != other.retryMaxTimes)
- return false;
- if (retryQueueNums != other.retryQueueNums)
- return false;
- if (whichBrokerWhenConsumeSlowly != other.whichBrokerWhenConsumeSlowly)
- return false;
- if (notifyConsumerIdsChangedEnable != other.notifyConsumerIdsChangedEnable)
- return false;
- return true;
- }
-
-
- @Override
- public String toString() {
- return "SubscriptionGroupConfig [groupName=" + groupName + ", consumeEnable=" + consumeEnable
- + ", consumeFromMinEnable=" + consumeFromMinEnable + ", consumeBroadcastEnable="
- + consumeBroadcastEnable + ", retryQueueNums=" + retryQueueNums + ", retryMaxTimes="
- + retryMaxTimes + ", brokerId=" + brokerId + ", whichBrokerWhenConsumeSlowly="
- + whichBrokerWhenConsumeSlowly + ", notifyConsumerIdsChangedEnable="
- + notifyConsumerIdsChangedEnable + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/sysflag/MessageSysFlag.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/sysflag/MessageSysFlag.java b/common/src/main/java/com/alibaba/rocketmq/common/sysflag/MessageSysFlag.java
deleted file mode 100644
index 2f9d057..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/sysflag/MessageSysFlag.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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.common.sysflag;
-
-/**
- * @author shijia.wxr
- */
-public class MessageSysFlag {
- public final static int COMPRESSED_FLAG = 0x1;
- public final static int MULTI_TAGS_FLAG = 0x1 << 1;
- public final static int TRANSACTION_NOT_TYPE = 0;
- public final static int TRANSACTION_PREPARED_TYPE = 0x1 << 2;
- public final static int TRANSACTION_COMMIT_TYPE = 0x2 << 2;
- public final static int TRANSACTION_ROLLBACK_TYPE = 0x3 << 2;
-
-
- public static int getTransactionValue(final int flag) {
- return flag & TRANSACTION_ROLLBACK_TYPE;
- }
-
-
- public static int resetTransactionValue(final int flag, final int type) {
- return (flag & (~TRANSACTION_ROLLBACK_TYPE)) | type;
- }
-
-
- public static int clearCompressedFlag(final int flag) {
- return flag & (~COMPRESSED_FLAG);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/sysflag/PullSysFlag.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/sysflag/PullSysFlag.java b/common/src/main/java/com/alibaba/rocketmq/common/sysflag/PullSysFlag.java
deleted file mode 100644
index d0f7287..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/sysflag/PullSysFlag.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * 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.common.sysflag;
-
-/**
- * @author shijia.wxr
- */
-public class PullSysFlag {
- private final static int FLAG_COMMIT_OFFSET = 0x1 << 0;
- private final static int FLAG_SUSPEND = 0x1 << 1;
- private final static int FLAG_SUBSCRIPTION = 0x1 << 2;
- private final static int FLAG_CLASS_FILTER = 0x1 << 3;
-
-
- public static int buildSysFlag(final boolean commitOffset, final boolean suspend,
- final boolean subscription, final boolean classFilter) {
- int flag = 0;
-
- if (commitOffset) {
- flag |= FLAG_COMMIT_OFFSET;
- }
-
- if (suspend) {
- flag |= FLAG_SUSPEND;
- }
-
- if (subscription) {
- flag |= FLAG_SUBSCRIPTION;
- }
-
- if (classFilter) {
- flag |= FLAG_CLASS_FILTER;
- }
-
- return flag;
- }
-
-
- public static int clearCommitOffsetFlag(final int sysFlag) {
- return sysFlag & (~FLAG_COMMIT_OFFSET);
- }
-
-
- public static boolean hasCommitOffsetFlag(final int sysFlag) {
- return (sysFlag & FLAG_COMMIT_OFFSET) == FLAG_COMMIT_OFFSET;
- }
-
-
- public static boolean hasSuspendFlag(final int sysFlag) {
- return (sysFlag & FLAG_SUSPEND) == FLAG_SUSPEND;
- }
-
-
- public static boolean hasSubscriptionFlag(final int sysFlag) {
- return (sysFlag & FLAG_SUBSCRIPTION) == FLAG_SUBSCRIPTION;
- }
-
-
- public static boolean hasClassFilterFlag(final int sysFlag) {
- return (sysFlag & FLAG_CLASS_FILTER) == FLAG_CLASS_FILTER;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/sysflag/SubscriptionSysFlag.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/sysflag/SubscriptionSysFlag.java b/common/src/main/java/com/alibaba/rocketmq/common/sysflag/SubscriptionSysFlag.java
deleted file mode 100644
index 65e3115..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/sysflag/SubscriptionSysFlag.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * 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.common.sysflag;
-
-/**
- * @author manhong.yqd
- */
-public class SubscriptionSysFlag {
-
- private final static int FLAG_UNIT = 0x1 << 0;
-
-
- public static int buildSysFlag(final boolean unit) {
- int sysFlag = 0;
-
- if (unit) {
- sysFlag |= FLAG_UNIT;
- }
-
- return sysFlag;
- }
-
-
- public static int setUnitFlag(final int sysFlag) {
- return sysFlag | FLAG_UNIT;
- }
-
-
- public static int clearUnitFlag(final int sysFlag) {
- return sysFlag & (~FLAG_UNIT);
- }
-
-
- public static boolean hasUnitFlag(final int sysFlag) {
- return (sysFlag & FLAG_UNIT) == FLAG_UNIT;
- }
-
-
- public static void main(String[] args) {
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/sysflag/TopicSysFlag.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/sysflag/TopicSysFlag.java b/common/src/main/java/com/alibaba/rocketmq/common/sysflag/TopicSysFlag.java
deleted file mode 100644
index 90d48f4..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/sysflag/TopicSysFlag.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * 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.common.sysflag;
-
-/**
-
- *
- * @author manhong.yqd
- *
- */
-public class TopicSysFlag {
-
- private final static int FLAG_UNIT = 0x1 << 0;
-
- private final static int FLAG_UNIT_SUB = 0x1 << 1;
-
-
- public static int buildSysFlag(final boolean unit, final boolean hasUnitSub) {
- int sysFlag = 0;
-
- if (unit) {
- sysFlag |= FLAG_UNIT;
- }
-
- if (hasUnitSub) {
- sysFlag |= FLAG_UNIT_SUB;
- }
-
- return sysFlag;
- }
-
-
- public static int setUnitFlag(final int sysFlag) {
- return sysFlag | FLAG_UNIT;
- }
-
-
- public static int clearUnitFlag(final int sysFlag) {
- return sysFlag & (~FLAG_UNIT);
- }
-
-
- public static boolean hasUnitFlag(final int sysFlag) {
- return (sysFlag & FLAG_UNIT) == FLAG_UNIT;
- }
-
-
- public static int setUnitSubFlag(final int sysFlag) {
- return sysFlag | FLAG_UNIT_SUB;
- }
-
-
- public static int clearUnitSubFlag(final int sysFlag) {
- return sysFlag & (~FLAG_UNIT_SUB);
- }
-
-
- public static boolean hasUnitSubFlag(final int sysFlag) {
- return (sysFlag & FLAG_UNIT_SUB) == FLAG_UNIT_SUB;
- }
-
-
- public static void main(String[] args) {
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/utils/ChannelUtil.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/utils/ChannelUtil.java b/common/src/main/java/com/alibaba/rocketmq/common/utils/ChannelUtil.java
deleted file mode 100644
index 444928f..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/utils/ChannelUtil.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * 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.common.utils;
-
-import io.netty.channel.Channel;
-
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-
-public class ChannelUtil {
- public static String getRemoteIp(Channel channel) {
- InetSocketAddress inetSocketAddress = (InetSocketAddress) channel.remoteAddress();
- if (inetSocketAddress == null) {
- return "";
- }
- final InetAddress inetAddr = inetSocketAddress.getAddress();
- return inetAddr != null ? inetAddr.getHostAddress() : inetSocketAddress.getHostName();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/utils/HttpTinyClient.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/utils/HttpTinyClient.java b/common/src/main/java/com/alibaba/rocketmq/common/utils/HttpTinyClient.java
deleted file mode 100755
index dadac46..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/utils/HttpTinyClient.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/**
- * 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.common.utils;
-
-import com.alibaba.rocketmq.common.MQVersion;
-import com.alibaba.rocketmq.common.MixAll;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.util.Iterator;
-import java.util.List;
-
-
-public class HttpTinyClient {
-
- static public HttpResult httpGet(String url, List<String> headers, List<String> paramValues,
- String encoding, long readTimeoutMs) throws IOException {
- String encodedContent = encodingParams(paramValues, encoding);
- url += (null == encodedContent) ? "" : ("?" + encodedContent);
-
- HttpURLConnection conn = null;
- try {
- conn = (HttpURLConnection) new URL(url).openConnection();
- conn.setRequestMethod("GET");
- conn.setConnectTimeout((int) readTimeoutMs);
- conn.setReadTimeout((int) readTimeoutMs);
- setHeaders(conn, headers, encoding);
-
- conn.connect();
- int respCode = conn.getResponseCode();
- String resp = null;
-
- if (HttpURLConnection.HTTP_OK == respCode) {
- resp = IOTinyUtils.toString(conn.getInputStream(), encoding);
- } else {
- resp = IOTinyUtils.toString(conn.getErrorStream(), encoding);
- }
- return new HttpResult(respCode, resp);
- } finally {
- if (conn != null) {
- conn.disconnect();
- }
- }
- }
-
- static private String encodingParams(List<String> paramValues, String encoding)
- throws UnsupportedEncodingException {
- StringBuilder sb = new StringBuilder();
- if (null == paramValues) {
- return null;
- }
-
- for (Iterator<String> iter = paramValues.iterator(); iter.hasNext(); ) {
- sb.append(iter.next()).append("=");
- sb.append(URLEncoder.encode(iter.next(), encoding));
- if (iter.hasNext()) {
- sb.append("&");
- }
- }
- return sb.toString();
- }
-
- static private void setHeaders(HttpURLConnection conn, List<String> headers, String encoding) {
- if (null != headers) {
- for (Iterator<String> iter = headers.iterator(); iter.hasNext(); ) {
- conn.addRequestProperty(iter.next(), iter.next());
- }
- }
- conn.addRequestProperty("Client-Version", MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION));
- conn.addRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + encoding);
-
-
- String ts = String.valueOf(System.currentTimeMillis());
- conn.addRequestProperty("Metaq-Client-RequestTS", ts);
- }
-
- /**
-
- *
- * @param url
- * @param headers
-
- * @param paramValues
-
- * @param encoding
-
- * @param readTimeoutMs
-
- *
- * @return the http response of given http post request
- *
- * @throws java.io.IOException
- */
- static public HttpResult httpPost(String url, List<String> headers, List<String> paramValues,
- String encoding, long readTimeoutMs) throws IOException {
- String encodedContent = encodingParams(paramValues, encoding);
-
- HttpURLConnection conn = null;
- try {
- conn = (HttpURLConnection) new URL(url).openConnection();
- conn.setRequestMethod("POST");
- conn.setConnectTimeout(3000);
- conn.setReadTimeout((int) readTimeoutMs);
- conn.setDoOutput(true);
- conn.setDoInput(true);
- setHeaders(conn, headers, encoding);
-
- conn.getOutputStream().write(encodedContent.getBytes(MixAll.DEFAULT_CHARSET));
-
- int respCode = conn.getResponseCode();
- String resp = null;
-
- if (HttpURLConnection.HTTP_OK == respCode) {
- resp = IOTinyUtils.toString(conn.getInputStream(), encoding);
- } else {
- resp = IOTinyUtils.toString(conn.getErrorStream(), encoding);
- }
- return new HttpResult(respCode, resp);
- } finally {
- if (null != conn) {
- conn.disconnect();
- }
- }
- }
-
- static public class HttpResult {
- final public int code;
- final public String content;
-
-
- public HttpResult(int code, String content) {
- this.code = code;
- this.content = content;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/com/alibaba/rocketmq/common/utils/IOTinyUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/alibaba/rocketmq/common/utils/IOTinyUtils.java b/common/src/main/java/com/alibaba/rocketmq/common/utils/IOTinyUtils.java
deleted file mode 100644
index ced2fae..0000000
--- a/common/src/main/java/com/alibaba/rocketmq/common/utils/IOTinyUtils.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/**
- * 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.common.utils;
-
-import com.alibaba.rocketmq.remoting.common.RemotingHelper;
-
-import java.io.*;
-import java.nio.channels.FileChannel;
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * @author manhong.yqd
- */
-public class IOTinyUtils {
-
- static public String toString(InputStream input, String encoding) throws IOException {
- return (null == encoding) ? toString(new InputStreamReader(input, RemotingHelper.DEFAULT_CHARSET)) : toString(new InputStreamReader(
- input, encoding));
- }
-
-
- static public String toString(Reader reader) throws IOException {
- CharArrayWriter sw = new CharArrayWriter();
- copy(reader, sw);
- return sw.toString();
- }
-
-
- static public long copy(Reader input, Writer output) throws IOException {
- char[] buffer = new char[1 << 12];
- long count = 0;
- for (int n = 0; (n = input.read(buffer)) >= 0; ) {
- output.write(buffer, 0, n);
- count += n;
- }
- return count;
- }
-
-
- /**
-
- */
- static public List<String> readLines(Reader input) throws IOException {
- BufferedReader reader = toBufferedReader(input);
- List<String> list = new ArrayList<String>();
- String line = null;
- for (;;) {
- line = reader.readLine();
- if (null != line) {
- list.add(line);
- } else {
- break;
- }
- }
- return list;
- }
-
-
- static private BufferedReader toBufferedReader(Reader reader) {
- return reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader);
- }
-
-
- static public void copyFile(String source, String target) throws IOException {
- File sf = new File(source);
- if (!sf.exists()) {
- throw new IllegalArgumentException("source file does not exist.");
- }
- File tf = new File(target);
- tf.getParentFile().mkdirs();
- if (!tf.exists() && !tf.createNewFile()) {
- throw new RuntimeException("failed to create target file.");
- }
-
- FileChannel sc = null;
- FileChannel tc = null;
- try {
- tc = new FileOutputStream(tf).getChannel();
- sc = new FileInputStream(sf).getChannel();
- sc.transferTo(0, sc.size(), tc);
- } finally {
- if (null != sc) {
- sc.close();
- }
- if (null != tc) {
- tc.close();
- }
- }
- }
-
-
- public static void delete(File fileOrDir) throws IOException {
- if (fileOrDir == null) {
- return;
- }
-
- if (fileOrDir.isDirectory()) {
- cleanDirectory(fileOrDir);
- }
-
- fileOrDir.delete();
- }
-
-
- /**
-
- */
- public static void cleanDirectory(File directory) throws IOException {
- if (!directory.exists()) {
- String message = directory + " does not exist";
- throw new IllegalArgumentException(message);
- }
-
- if (!directory.isDirectory()) {
- String message = directory + " is not a directory";
- throw new IllegalArgumentException(message);
- }
-
- File[] files = directory.listFiles();
- if (files == null) { // null if security restricted
- throw new IOException("Failed to list contents of " + directory);
- }
-
- IOException exception = null;
- for (File file : files) {
- try {
- delete(file);
- } catch (IOException ioe) {
- exception = ioe;
- }
- }
-
- if (null != exception) {
- throw exception;
- }
- }
-
-
- public static void writeStringToFile(File file, String data, String encoding) throws IOException {
- OutputStream os = null;
- try {
- os = new FileOutputStream(file);
- os.write(data.getBytes(encoding));
- } finally {
- if (null != os) {
- os.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java b/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java
new file mode 100644
index 0000000..f035ed6
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java
@@ -0,0 +1,549 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.common;
+
+import org.apache.rocketmq.common.annotation.ImportantField;
+import org.apache.rocketmq.common.constant.PermName;
+import org.apache.rocketmq.remoting.common.RemotingUtil;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class BrokerConfig {
+ private String rocketmqHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV));
+ @ImportantField
+ private String namesrvAddr = System.getProperty(MixAll.NAMESRV_ADDR_PROPERTY, System.getenv(MixAll.NAMESRV_ADDR_ENV));
+ @ImportantField
+ private String brokerIP1 = RemotingUtil.getLocalAddress();
+ private String brokerIP2 = RemotingUtil.getLocalAddress();
+ @ImportantField
+ private String brokerName = localHostName();
+ @ImportantField
+ private String brokerClusterName = "DefaultCluster";
+ @ImportantField
+ private long brokerId = MixAll.MASTER_ID;
+ private int brokerPermission = PermName.PERM_READ | PermName.PERM_WRITE;
+ private int defaultTopicQueueNums = 8;
+ @ImportantField
+ private boolean autoCreateTopicEnable = true;
+
+ private boolean clusterTopicEnable = true;
+
+ private boolean brokerTopicEnable = true;
+ @ImportantField
+ private boolean autoCreateSubscriptionGroup = true;
+ private String messageStorePlugIn = "";
+
+ private int sendMessageThreadPoolNums = 1; //16 + Runtime.getRuntime().availableProcessors() * 4;
+ private int pullMessageThreadPoolNums = 16 + Runtime.getRuntime().availableProcessors() * 2;
+ private int adminBrokerThreadPoolNums = 16;
+ private int clientManageThreadPoolNums = 32;
+ private int consumerManageThreadPoolNums = 32;
+
+ private int flushConsumerOffsetInterval = 1000 * 5;
+
+ private int flushConsumerOffsetHistoryInterval = 1000 * 60;
+
+ @ImportantField
+ private boolean rejectTransactionMessage = false;
+ @ImportantField
+ private boolean fetchNamesrvAddrByAddressServer = false;
+ private int sendThreadPoolQueueCapacity = 10000;
+ private int pullThreadPoolQueueCapacity = 100000;
+ private int clientManagerThreadPoolQueueCapacity = 1000000;
+ private int consumerManagerThreadPoolQueueCapacity = 1000000;
+
+ private int filterServerNums = 0;
+
+ private boolean longPollingEnable = true;
+
+ private long shortPollingTimeMills = 1000;
+
+ private boolean notifyConsumerIdsChangedEnable = true;
+
+ private boolean highSpeedMode = false;
+
+ private boolean commercialEnable = true;
+ private int commercialTimerCount = 1;
+ private int commercialTransCount = 1;
+ private int commercialBigCount = 1;
+ private int commercialBaseCount = 1;
+
+ private boolean transferMsgByHeap = true;
+ private int maxDelayTime = 40;
+
+
+ private String regionId = MixAll.DEFAULT_TRACE_REGION_ID;
+ private int registerBrokerTimeoutMills = 6000;
+
+ private boolean slaveReadEnable = false;
+
+ private boolean disableConsumeIfConsumerReadSlowly = false;
+ private long consumerFallbehindThreshold = 1024 * 1024 * 1024 * 16;
+
+ private long waitTimeMillsInSendQueue = 200;
+
+ private long startAcceptSendRequestTimeStamp = 0L;
+
+ private boolean traceOn = true;
+
+ public boolean isTraceOn() {
+ return traceOn;
+ }
+
+ public void setTraceOn(final boolean traceOn) {
+ this.traceOn = traceOn;
+ }
+
+ public long getStartAcceptSendRequestTimeStamp() {
+ return startAcceptSendRequestTimeStamp;
+ }
+
+ public void setStartAcceptSendRequestTimeStamp(final long startAcceptSendRequestTimeStamp) {
+ this.startAcceptSendRequestTimeStamp = startAcceptSendRequestTimeStamp;
+ }
+
+ public long getWaitTimeMillsInSendQueue() {
+ return waitTimeMillsInSendQueue;
+ }
+
+ public void setWaitTimeMillsInSendQueue(final long waitTimeMillsInSendQueue) {
+ this.waitTimeMillsInSendQueue = waitTimeMillsInSendQueue;
+ }
+
+ public long getConsumerFallbehindThreshold() {
+ return consumerFallbehindThreshold;
+ }
+
+ public void setConsumerFallbehindThreshold(final long consumerFallbehindThreshold) {
+ this.consumerFallbehindThreshold = consumerFallbehindThreshold;
+ }
+
+ public boolean isDisableConsumeIfConsumerReadSlowly() {
+ return disableConsumeIfConsumerReadSlowly;
+ }
+
+ public void setDisableConsumeIfConsumerReadSlowly(final boolean disableConsumeIfConsumerReadSlowly) {
+ this.disableConsumeIfConsumerReadSlowly = disableConsumeIfConsumerReadSlowly;
+ }
+
+ public boolean isSlaveReadEnable() {
+ return slaveReadEnable;
+ }
+
+ public void setSlaveReadEnable(final boolean slaveReadEnable) {
+ this.slaveReadEnable = slaveReadEnable;
+ }
+
+ public static String localHostName() {
+ try {
+ return InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ }
+
+ return "DEFAULT_BROKER";
+ }
+
+ public int getRegisterBrokerTimeoutMills() {
+ return registerBrokerTimeoutMills;
+ }
+
+ public void setRegisterBrokerTimeoutMills(final int registerBrokerTimeoutMills) {
+ this.registerBrokerTimeoutMills = registerBrokerTimeoutMills;
+ }
+
+ public String getRegionId() {
+ return regionId;
+ }
+
+ public void setRegionId(final String regionId) {
+ this.regionId = regionId;
+ }
+
+ public boolean isTransferMsgByHeap() {
+ return transferMsgByHeap;
+ }
+
+ public void setTransferMsgByHeap(final boolean transferMsgByHeap) {
+ this.transferMsgByHeap = transferMsgByHeap;
+ }
+
+ public String getMessageStorePlugIn() {
+ return messageStorePlugIn;
+ }
+
+ public void setMessageStorePlugIn(String messageStorePlugIn) {
+ this.messageStorePlugIn = messageStorePlugIn;
+ }
+
+ public boolean isHighSpeedMode() {
+ return highSpeedMode;
+ }
+
+
+ public void setHighSpeedMode(final boolean highSpeedMode) {
+ this.highSpeedMode = highSpeedMode;
+ }
+
+
+ public String getRocketmqHome() {
+ return rocketmqHome;
+ }
+
+
+ public void setRocketmqHome(String rocketmqHome) {
+ this.rocketmqHome = rocketmqHome;
+ }
+
+
+ public String getBrokerName() {
+ return brokerName;
+ }
+
+
+ public void setBrokerName(String brokerName) {
+ this.brokerName = brokerName;
+ }
+
+
+ public int getBrokerPermission() {
+ return brokerPermission;
+ }
+
+
+ public void setBrokerPermission(int brokerPermission) {
+ this.brokerPermission = brokerPermission;
+ }
+
+
+ public int getDefaultTopicQueueNums() {
+ return defaultTopicQueueNums;
+ }
+
+
+ public void setDefaultTopicQueueNums(int defaultTopicQueueNums) {
+ this.defaultTopicQueueNums = defaultTopicQueueNums;
+ }
+
+
+ public boolean isAutoCreateTopicEnable() {
+ return autoCreateTopicEnable;
+ }
+
+
+ public void setAutoCreateTopicEnable(boolean autoCreateTopic) {
+ this.autoCreateTopicEnable = autoCreateTopic;
+ }
+
+
+ public String getBrokerClusterName() {
+ return brokerClusterName;
+ }
+
+
+ public void setBrokerClusterName(String brokerClusterName) {
+ this.brokerClusterName = brokerClusterName;
+ }
+
+
+ public String getBrokerIP1() {
+ return brokerIP1;
+ }
+
+
+ public void setBrokerIP1(String brokerIP1) {
+ this.brokerIP1 = brokerIP1;
+ }
+
+
+ public String getBrokerIP2() {
+ return brokerIP2;
+ }
+
+
+ public void setBrokerIP2(String brokerIP2) {
+ this.brokerIP2 = brokerIP2;
+ }
+
+ public int getSendMessageThreadPoolNums() {
+ return sendMessageThreadPoolNums;
+ }
+
+ public void setSendMessageThreadPoolNums(int sendMessageThreadPoolNums) {
+ this.sendMessageThreadPoolNums = sendMessageThreadPoolNums;
+ }
+
+
+ public int getPullMessageThreadPoolNums() {
+ return pullMessageThreadPoolNums;
+ }
+
+
+ public void setPullMessageThreadPoolNums(int pullMessageThreadPoolNums) {
+ this.pullMessageThreadPoolNums = pullMessageThreadPoolNums;
+ }
+
+
+ public int getAdminBrokerThreadPoolNums() {
+ return adminBrokerThreadPoolNums;
+ }
+
+
+ public void setAdminBrokerThreadPoolNums(int adminBrokerThreadPoolNums) {
+ this.adminBrokerThreadPoolNums = adminBrokerThreadPoolNums;
+ }
+
+
+ public int getFlushConsumerOffsetInterval() {
+ return flushConsumerOffsetInterval;
+ }
+
+
+ public void setFlushConsumerOffsetInterval(int flushConsumerOffsetInterval) {
+ this.flushConsumerOffsetInterval = flushConsumerOffsetInterval;
+ }
+
+
+ public int getFlushConsumerOffsetHistoryInterval() {
+ return flushConsumerOffsetHistoryInterval;
+ }
+
+
+ public void setFlushConsumerOffsetHistoryInterval(int flushConsumerOffsetHistoryInterval) {
+ this.flushConsumerOffsetHistoryInterval = flushConsumerOffsetHistoryInterval;
+ }
+
+
+ public boolean isClusterTopicEnable() {
+ return clusterTopicEnable;
+ }
+
+
+ public void setClusterTopicEnable(boolean clusterTopicEnable) {
+ this.clusterTopicEnable = clusterTopicEnable;
+ }
+
+
+ public String getNamesrvAddr() {
+ return namesrvAddr;
+ }
+
+
+ public void setNamesrvAddr(String namesrvAddr) {
+ this.namesrvAddr = namesrvAddr;
+ }
+
+
+ public long getBrokerId() {
+ return brokerId;
+ }
+
+
+ public void setBrokerId(long brokerId) {
+ this.brokerId = brokerId;
+ }
+
+
+ public boolean isAutoCreateSubscriptionGroup() {
+ return autoCreateSubscriptionGroup;
+ }
+
+
+ public void setAutoCreateSubscriptionGroup(boolean autoCreateSubscriptionGroup) {
+ this.autoCreateSubscriptionGroup = autoCreateSubscriptionGroup;
+ }
+
+
+ public boolean isRejectTransactionMessage() {
+ return rejectTransactionMessage;
+ }
+
+
+ public void setRejectTransactionMessage(boolean rejectTransactionMessage) {
+ this.rejectTransactionMessage = rejectTransactionMessage;
+ }
+
+
+ public boolean isFetchNamesrvAddrByAddressServer() {
+ return fetchNamesrvAddrByAddressServer;
+ }
+
+
+ public void setFetchNamesrvAddrByAddressServer(boolean fetchNamesrvAddrByAddressServer) {
+ this.fetchNamesrvAddrByAddressServer = fetchNamesrvAddrByAddressServer;
+ }
+
+
+ public int getSendThreadPoolQueueCapacity() {
+ return sendThreadPoolQueueCapacity;
+ }
+
+
+ public void setSendThreadPoolQueueCapacity(int sendThreadPoolQueueCapacity) {
+ this.sendThreadPoolQueueCapacity = sendThreadPoolQueueCapacity;
+ }
+
+
+ public int getPullThreadPoolQueueCapacity() {
+ return pullThreadPoolQueueCapacity;
+ }
+
+
+ public void setPullThreadPoolQueueCapacity(int pullThreadPoolQueueCapacity) {
+ this.pullThreadPoolQueueCapacity = pullThreadPoolQueueCapacity;
+ }
+
+
+ public boolean isBrokerTopicEnable() {
+ return brokerTopicEnable;
+ }
+
+
+ public void setBrokerTopicEnable(boolean brokerTopicEnable) {
+ this.brokerTopicEnable = brokerTopicEnable;
+ }
+
+
+ public int getFilterServerNums() {
+ return filterServerNums;
+ }
+
+
+ public void setFilterServerNums(int filterServerNums) {
+ this.filterServerNums = filterServerNums;
+ }
+
+
+ public boolean isLongPollingEnable() {
+ return longPollingEnable;
+ }
+
+
+ public void setLongPollingEnable(boolean longPollingEnable) {
+ this.longPollingEnable = longPollingEnable;
+ }
+
+
+ public boolean isNotifyConsumerIdsChangedEnable() {
+ return notifyConsumerIdsChangedEnable;
+ }
+
+
+ public void setNotifyConsumerIdsChangedEnable(boolean notifyConsumerIdsChangedEnable) {
+ this.notifyConsumerIdsChangedEnable = notifyConsumerIdsChangedEnable;
+ }
+
+
+ public long getShortPollingTimeMills() {
+ return shortPollingTimeMills;
+ }
+
+
+ public void setShortPollingTimeMills(long shortPollingTimeMills) {
+ this.shortPollingTimeMills = shortPollingTimeMills;
+ }
+
+
+ public int getClientManageThreadPoolNums() {
+ return clientManageThreadPoolNums;
+ }
+
+
+ public void setClientManageThreadPoolNums(int clientManageThreadPoolNums) {
+ this.clientManageThreadPoolNums = clientManageThreadPoolNums;
+ }
+
+
+ public boolean isCommercialEnable() {
+ return commercialEnable;
+ }
+
+
+ public void setCommercialEnable(final boolean commercialEnable) {
+ this.commercialEnable = commercialEnable;
+ }
+
+ public int getCommercialTimerCount() {
+ return commercialTimerCount;
+ }
+
+ public void setCommercialTimerCount(final int commercialTimerCount) {
+ this.commercialTimerCount = commercialTimerCount;
+ }
+
+ public int getCommercialTransCount() {
+ return commercialTransCount;
+ }
+
+ public void setCommercialTransCount(final int commercialTransCount) {
+ this.commercialTransCount = commercialTransCount;
+ }
+
+ public int getCommercialBigCount() {
+ return commercialBigCount;
+ }
+
+ public void setCommercialBigCount(final int commercialBigCount) {
+ this.commercialBigCount = commercialBigCount;
+ }
+
+ public int getMaxDelayTime() {
+ return maxDelayTime;
+ }
+
+
+ public void setMaxDelayTime(final int maxDelayTime) {
+ this.maxDelayTime = maxDelayTime;
+ }
+
+ public int getClientManagerThreadPoolQueueCapacity() {
+ return clientManagerThreadPoolQueueCapacity;
+ }
+
+ public void setClientManagerThreadPoolQueueCapacity(int clientManagerThreadPoolQueueCapacity) {
+ this.clientManagerThreadPoolQueueCapacity = clientManagerThreadPoolQueueCapacity;
+ }
+
+ public int getConsumerManagerThreadPoolQueueCapacity() {
+ return consumerManagerThreadPoolQueueCapacity;
+ }
+
+ public void setConsumerManagerThreadPoolQueueCapacity(int consumerManagerThreadPoolQueueCapacity) {
+ this.consumerManagerThreadPoolQueueCapacity = consumerManagerThreadPoolQueueCapacity;
+ }
+
+ public int getConsumerManageThreadPoolNums() {
+ return consumerManageThreadPoolNums;
+ }
+
+ public void setConsumerManageThreadPoolNums(int consumerManageThreadPoolNums) {
+ this.consumerManageThreadPoolNums = consumerManageThreadPoolNums;
+ }
+
+ public int getCommercialBaseCount() {
+ return commercialBaseCount;
+ }
+
+ public void setCommercialBaseCount(int commercialBaseCount) {
+ this.commercialBaseCount = commercialBaseCount;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/common/src/main/java/org/apache/rocketmq/common/BrokerConfigSingleton.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/rocketmq/common/BrokerConfigSingleton.java b/common/src/main/java/org/apache/rocketmq/common/BrokerConfigSingleton.java
new file mode 100644
index 0000000..fc73b71
--- /dev/null
+++ b/common/src/main/java/org/apache/rocketmq/common/BrokerConfigSingleton.java
@@ -0,0 +1,39 @@
+/**
+ * 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.common;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+public class BrokerConfigSingleton {
+ private static AtomicBoolean isInit = new AtomicBoolean();
+ private static BrokerConfig brokerConfig;
+
+ public static BrokerConfig getBrokerConfig() {
+ if (brokerConfig == null) {
+ throw new IllegalArgumentException("brokerConfig Cannot be null !");
+ }
+ return brokerConfig;
+ }
+
+ public static void setBrokerConfig(BrokerConfig brokerConfig) {
+ if (!isInit.compareAndSet(false, true)) {
+ throw new IllegalArgumentException("broker config have inited !");
+ }
+ BrokerConfigSingleton.brokerConfig = brokerConfig;
+ }
+}
[24/99] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18
Rename package name from com.alibaba to org.apache
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
new file mode 100644
index 0000000..664b9fb
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
@@ -0,0 +1,1071 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.impl.consumer;
+
+import org.apache.rocketmq.client.QueryResult;
+import org.apache.rocketmq.client.Validators;
+import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
+import org.apache.rocketmq.client.consumer.PullCallback;
+import org.apache.rocketmq.client.consumer.PullResult;
+import org.apache.rocketmq.client.consumer.listener.MessageListener;
+import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
+import org.apache.rocketmq.client.consumer.listener.MessageListenerOrderly;
+import org.apache.rocketmq.client.consumer.store.LocalFileOffsetStore;
+import org.apache.rocketmq.client.consumer.store.OffsetStore;
+import org.apache.rocketmq.client.consumer.store.ReadOffsetType;
+import org.apache.rocketmq.client.consumer.store.RemoteBrokerOffsetStore;
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.hook.ConsumeMessageContext;
+import org.apache.rocketmq.client.hook.ConsumeMessageHook;
+import org.apache.rocketmq.client.hook.FilterMessageHook;
+import org.apache.rocketmq.client.impl.CommunicationMode;
+import org.apache.rocketmq.client.impl.MQClientManager;
+import org.apache.rocketmq.client.impl.factory.MQClientInstance;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.client.stat.ConsumerStatsManager;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.ServiceState;
+import org.apache.rocketmq.common.UtilAll;
+import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
+import org.apache.rocketmq.common.filter.FilterAPI;
+import org.apache.rocketmq.common.help.FAQUrl;
+import org.apache.rocketmq.common.message.*;
+import org.apache.rocketmq.common.protocol.body.ConsumeStatus;
+import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
+import org.apache.rocketmq.common.protocol.body.ProcessQueueInfo;
+import org.apache.rocketmq.common.protocol.body.QueueTimeSpan;
+import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
+import org.apache.rocketmq.common.protocol.route.BrokerData;
+import org.apache.rocketmq.common.protocol.route.TopicRouteData;
+import org.apache.rocketmq.common.sysflag.PullSysFlag;
+import org.apache.rocketmq.remoting.RPCHook;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+import org.slf4j.Logger;
+
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class DefaultMQPushConsumerImpl implements MQConsumerInner {
+ /**
+ * Delay some time when exception occur
+ */
+ private static final long PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION = 3000;
+ /**
+ * Flow control interval
+ */
+ private static final long PULL_TIME_DELAY_MILLS_WHEN_FLOW_CONTROL = 50;
+ /**
+ * Delay some time when suspend pull service
+ */
+ private static final long PULL_TIME_DELAY_MILLS_WHEN_SUSPEND = 1000;
+ private static final long BROKER_SUSPEND_MAX_TIME_MILLIS = 1000 * 15;
+ private static final long CONSUMER_TIMEOUT_MILLIS_WHEN_SUSPEND = 1000 * 30;
+ private final Logger log = ClientLogger.getLog();
+ private final DefaultMQPushConsumer defaultMQPushConsumer;
+ private final RebalanceImpl rebalanceImpl = new RebalancePushImpl(this);
+ private final ArrayList<FilterMessageHook> filterMessageHookList = new ArrayList<FilterMessageHook>();
+ private final long consumerStartTimestamp = System.currentTimeMillis();
+ private final ArrayList<ConsumeMessageHook> consumeMessageHookList = new ArrayList<ConsumeMessageHook>();
+ private final RPCHook rpcHook;
+ private ServiceState serviceState = ServiceState.CREATE_JUST;
+ private MQClientInstance mQClientFactory;
+ private PullAPIWrapper pullAPIWrapper;
+ private volatile boolean pause = false;
+ private boolean consumeOrderly = false;
+ private MessageListener messageListenerInner;
+ private OffsetStore offsetStore;
+ private ConsumeMessageService consumeMessageService;
+ private long flowControlTimes1 = 0;
+ private long flowControlTimes2 = 0;
+
+
+ public DefaultMQPushConsumerImpl(DefaultMQPushConsumer defaultMQPushConsumer, RPCHook rpcHook) {
+ this.defaultMQPushConsumer = defaultMQPushConsumer;
+ this.rpcHook = rpcHook;
+ }
+
+ public void registerFilterMessageHook(final FilterMessageHook hook) {
+ this.filterMessageHookList.add(hook);
+ log.info("register FilterMessageHook Hook, {}", hook.hookName());
+ }
+
+ public boolean hasHook() {
+ return !this.consumeMessageHookList.isEmpty();
+ }
+
+ public void registerConsumeMessageHook(final ConsumeMessageHook hook) {
+ this.consumeMessageHookList.add(hook);
+ log.info("register consumeMessageHook Hook, {}", hook.hookName());
+ }
+
+ public void executeHookBefore(final ConsumeMessageContext context) {
+ if (!this.consumeMessageHookList.isEmpty()) {
+ for (ConsumeMessageHook hook : this.consumeMessageHookList) {
+ try {
+ hook.consumeMessageBefore(context);
+ } catch (Throwable e) {
+ }
+ }
+ }
+ }
+
+ public void executeHookAfter(final ConsumeMessageContext context) {
+ if (!this.consumeMessageHookList.isEmpty()) {
+ for (ConsumeMessageHook hook : this.consumeMessageHookList) {
+ try {
+ hook.consumeMessageAfter(context);
+ } catch (Throwable e) {
+ }
+ }
+ }
+ }
+
+ public void createTopic(String key, String newTopic, int queueNum) throws MQClientException {
+ createTopic(key, newTopic, queueNum, 0);
+ }
+
+ public void createTopic(String key, String newTopic, int queueNum, int topicSysFlag) throws MQClientException {
+ this.mQClientFactory.getMQAdminImpl().createTopic(key, newTopic, queueNum, topicSysFlag);
+ }
+
+ public Set<MessageQueue> fetchSubscribeMessageQueues(String topic) throws MQClientException {
+ Set<MessageQueue> result = this.rebalanceImpl.getTopicSubscribeInfoTable().get(topic);
+ if (null == result) {
+ this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic);
+ result = this.rebalanceImpl.getTopicSubscribeInfoTable().get(topic);
+ }
+
+ if (null == result) {
+ throw new MQClientException("The topic[" + topic + "] not exist", null);
+ }
+
+ return result;
+ }
+
+ public DefaultMQPushConsumer getDefaultMQPushConsumer() {
+ return defaultMQPushConsumer;
+ }
+
+ public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {
+ return this.mQClientFactory.getMQAdminImpl().earliestMsgStoreTime(mq);
+ }
+
+ public long maxOffset(MessageQueue mq) throws MQClientException {
+ return this.mQClientFactory.getMQAdminImpl().maxOffset(mq);
+ }
+
+ public long minOffset(MessageQueue mq) throws MQClientException {
+ return this.mQClientFactory.getMQAdminImpl().minOffset(mq);
+ }
+
+ public OffsetStore getOffsetStore() {
+ return offsetStore;
+ }
+
+ public void setOffsetStore(OffsetStore offsetStore) {
+ this.offsetStore = offsetStore;
+ }
+
+ public void pullMessage(final PullRequest pullRequest) {
+ final ProcessQueue processQueue = pullRequest.getProcessQueue();
+ if (processQueue.isDropped()) {
+ log.info("the pull request[{}] is dropped.", pullRequest.toString());
+ return;
+ }
+
+ pullRequest.getProcessQueue().setLastPullTimestamp(System.currentTimeMillis());
+
+ try {
+ this.makeSureStateOK();
+ } catch (MQClientException e) {
+ log.warn("pullMessage exception, consumer state not ok", e);
+ this.executePullRequestLater(pullRequest, PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION);
+ return;
+ }
+
+ if (this.isPause()) {
+ log.warn("consumer was paused, execute pull request later. instanceName={}, group={}", this.defaultMQPushConsumer.getInstanceName(), this.defaultMQPushConsumer.getConsumerGroup());
+ this.executePullRequestLater(pullRequest, PULL_TIME_DELAY_MILLS_WHEN_SUSPEND);
+ return;
+ }
+
+ long size = processQueue.getMsgCount().get();
+ if (size > this.defaultMQPushConsumer.getPullThresholdForQueue()) {
+ this.executePullRequestLater(pullRequest, PULL_TIME_DELAY_MILLS_WHEN_FLOW_CONTROL);
+ if ((flowControlTimes1++ % 1000) == 0) {
+ log.warn(
+ "the consumer message buffer is full, so do flow control, minOffset={}, maxOffset={}, size={}, pullRequest={}, flowControlTimes={}",
+ processQueue.getMsgTreeMap().firstKey(), processQueue.getMsgTreeMap().lastKey(), size, pullRequest, flowControlTimes1);
+ }
+ return;
+ }
+
+ if (!this.consumeOrderly) {
+ if (processQueue.getMaxSpan() > this.defaultMQPushConsumer.getConsumeConcurrentlyMaxSpan()) {
+ this.executePullRequestLater(pullRequest, PULL_TIME_DELAY_MILLS_WHEN_FLOW_CONTROL);
+ if ((flowControlTimes2++ % 1000) == 0) {
+ log.warn(
+ "the queue's messages, span too long, so do flow control, minOffset={}, maxOffset={}, maxSpan={}, pullRequest={}, flowControlTimes={}",
+ processQueue.getMsgTreeMap().firstKey(), processQueue.getMsgTreeMap().lastKey(), processQueue.getMaxSpan(),
+ pullRequest, flowControlTimes2);
+ }
+ return;
+ }
+ } else {
+ if (processQueue.isLocked()) {
+ if (!pullRequest.isLockedFirst()) {
+ final long offset = this.rebalanceImpl.computePullFromWhere(pullRequest.getMessageQueue());
+ boolean brokerBusy = offset < pullRequest.getNextOffset();
+ log.info("the first time to pull message, so fix offset from broker. pullRequest: {} NewOffset: {} brokerBusy: {}",
+ pullRequest, offset, brokerBusy);
+ if (brokerBusy) {
+ log.info("[NOTIFYME]the first time to pull message, but pull request offset larger than broker consume offset. pullRequest: {} NewOffset: {}",
+ pullRequest, offset);
+ }
+
+ pullRequest.setLockedFirst(true);
+ pullRequest.setNextOffset(offset);
+ }
+ } else {
+ this.executePullRequestLater(pullRequest, PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION);
+ log.info("pull message later because not locked in broker, {}", pullRequest);
+ return;
+ }
+ }
+
+ final SubscriptionData subscriptionData = this.rebalanceImpl.getSubscriptionInner().get(pullRequest.getMessageQueue().getTopic());
+ if (null == subscriptionData) {
+ this.executePullRequestLater(pullRequest, PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION);
+ log.warn("find the consumer's subscription failed, {}", pullRequest);
+ return;
+ }
+
+ final long beginTimestamp = System.currentTimeMillis();
+
+ PullCallback pullCallback = new PullCallback() {
+ @Override
+ public void onSuccess(PullResult pullResult) {
+ if (pullResult != null) {
+ pullResult = DefaultMQPushConsumerImpl.this.pullAPIWrapper.processPullResult(pullRequest.getMessageQueue(), pullResult,
+ subscriptionData);
+
+ switch (pullResult.getPullStatus()) {
+ case FOUND:
+ long prevRequestOffset = pullRequest.getNextOffset();
+ pullRequest.setNextOffset(pullResult.getNextBeginOffset());
+ long pullRT = System.currentTimeMillis() - beginTimestamp;
+ DefaultMQPushConsumerImpl.this.getConsumerStatsManager().incPullRT(pullRequest.getConsumerGroup(),
+ pullRequest.getMessageQueue().getTopic(), pullRT);
+
+ long firstMsgOffset = Long.MAX_VALUE;
+ if (pullResult.getMsgFoundList() == null || pullResult.getMsgFoundList().isEmpty()) {
+ DefaultMQPushConsumerImpl.this.executePullRequestImmediately(pullRequest);
+ } else {
+ firstMsgOffset = pullResult.getMsgFoundList().get(0).getQueueOffset();
+
+ DefaultMQPushConsumerImpl.this.getConsumerStatsManager().incPullTPS(pullRequest.getConsumerGroup(),
+ pullRequest.getMessageQueue().getTopic(), pullResult.getMsgFoundList().size());
+
+ boolean dispathToConsume = processQueue.putMessage(pullResult.getMsgFoundList());
+ DefaultMQPushConsumerImpl.this.consumeMessageService.submitConsumeRequest(//
+ pullResult.getMsgFoundList(), //
+ processQueue, //
+ pullRequest.getMessageQueue(), //
+ dispathToConsume);
+
+ if (DefaultMQPushConsumerImpl.this.defaultMQPushConsumer.getPullInterval() > 0) {
+ DefaultMQPushConsumerImpl.this.executePullRequestLater(pullRequest,
+ DefaultMQPushConsumerImpl.this.defaultMQPushConsumer.getPullInterval());
+ } else {
+ DefaultMQPushConsumerImpl.this.executePullRequestImmediately(pullRequest);
+ }
+ }
+
+ if (pullResult.getNextBeginOffset() < prevRequestOffset//
+ || firstMsgOffset < prevRequestOffset) {
+ log.warn(
+ "[BUG] pull message result maybe data wrong, nextBeginOffset: {} firstMsgOffset: {} prevRequestOffset: {}", //
+ pullResult.getNextBeginOffset(), //
+ firstMsgOffset, //
+ prevRequestOffset);
+ }
+
+ break;
+ case NO_NEW_MSG:
+ pullRequest.setNextOffset(pullResult.getNextBeginOffset());
+
+ DefaultMQPushConsumerImpl.this.correctTagsOffset(pullRequest);
+
+ DefaultMQPushConsumerImpl.this.executePullRequestImmediately(pullRequest);
+ break;
+ case NO_MATCHED_MSG:
+ pullRequest.setNextOffset(pullResult.getNextBeginOffset());
+
+ DefaultMQPushConsumerImpl.this.correctTagsOffset(pullRequest);
+
+ DefaultMQPushConsumerImpl.this.executePullRequestImmediately(pullRequest);
+ break;
+ case OFFSET_ILLEGAL:
+ log.warn("the pull request offset illegal, {} {}", //
+ pullRequest.toString(), pullResult.toString());
+ pullRequest.setNextOffset(pullResult.getNextBeginOffset());
+
+ pullRequest.getProcessQueue().setDropped(true);
+ DefaultMQPushConsumerImpl.this.executeTaskLater(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ DefaultMQPushConsumerImpl.this.offsetStore.updateOffset(pullRequest.getMessageQueue(),
+ pullRequest.getNextOffset(), false);
+
+ DefaultMQPushConsumerImpl.this.offsetStore.persist(pullRequest.getMessageQueue());
+
+ DefaultMQPushConsumerImpl.this.rebalanceImpl.removeProcessQueue(pullRequest.getMessageQueue());
+
+ log.warn("fix the pull request offset, {}", pullRequest);
+ } catch (Throwable e) {
+ log.error("executeTaskLater Exception", e);
+ }
+ }
+ }, 10000);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+
+ @Override
+ public void onException(Throwable e) {
+ if (!pullRequest.getMessageQueue().getTopic().startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
+ log.warn("execute the pull request exception", e);
+ }
+
+ DefaultMQPushConsumerImpl.this.executePullRequestLater(pullRequest, PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION);
+ }
+ };
+
+ boolean commitOffsetEnable = false;
+ long commitOffsetValue = 0L;
+ if (MessageModel.CLUSTERING == this.defaultMQPushConsumer.getMessageModel()) {
+ commitOffsetValue = this.offsetStore.readOffset(pullRequest.getMessageQueue(), ReadOffsetType.READ_FROM_MEMORY);
+ if (commitOffsetValue > 0) {
+ commitOffsetEnable = true;
+ }
+ }
+
+ String subExpression = null;
+ boolean classFilter = false;
+ SubscriptionData sd = this.rebalanceImpl.getSubscriptionInner().get(pullRequest.getMessageQueue().getTopic());
+ if (sd != null) {
+ if (this.defaultMQPushConsumer.isPostSubscriptionWhenPull() && !sd.isClassFilterMode()) {
+ subExpression = sd.getSubString();
+ }
+
+ classFilter = sd.isClassFilterMode();
+ }
+
+ int sysFlag = PullSysFlag.buildSysFlag(//
+ commitOffsetEnable, // commitOffset
+ true, // suspend
+ subExpression != null, // subscription
+ classFilter // class filter
+ );
+ try {
+ this.pullAPIWrapper.pullKernelImpl(//
+ pullRequest.getMessageQueue(), // 1
+ subExpression, // 2
+ subscriptionData.getSubVersion(), // 3
+ pullRequest.getNextOffset(), // 4
+ this.defaultMQPushConsumer.getPullBatchSize(), // 5
+ sysFlag, // 6
+ commitOffsetValue, // 7
+ BROKER_SUSPEND_MAX_TIME_MILLIS, // 8
+ CONSUMER_TIMEOUT_MILLIS_WHEN_SUSPEND, // 9
+ CommunicationMode.ASYNC, // 10
+ pullCallback// 11
+ );
+ } catch (Exception e) {
+ log.error("pullKernelImpl exception", e);
+ this.executePullRequestLater(pullRequest, PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION);
+ }
+ }
+
+ private void makeSureStateOK() throws MQClientException {
+ if (this.serviceState != ServiceState.RUNNING) {
+ throw new MQClientException("The consumer service state not OK, "//
+ + this.serviceState//
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
+ null);
+ }
+ }
+
+ private void executePullRequestLater(final PullRequest pullRequest, final long timeDelay) {
+ this.mQClientFactory.getPullMessageService().executePullRequestLater(pullRequest, timeDelay);
+ }
+
+ public boolean isPause() {
+ return pause;
+ }
+
+ public void setPause(boolean pause) {
+ this.pause = pause;
+ }
+
+ public ConsumerStatsManager getConsumerStatsManager() {
+ return this.mQClientFactory.getConsumerStatsManager();
+ }
+
+ public void executePullRequestImmediately(final PullRequest pullRequest) {
+ this.mQClientFactory.getPullMessageService().executePullRequestImmediately(pullRequest);
+ }
+
+ private void correctTagsOffset(final PullRequest pullRequest) {
+ if (0L == pullRequest.getProcessQueue().getMsgCount().get()) {
+ this.offsetStore.updateOffset(pullRequest.getMessageQueue(), pullRequest.getNextOffset(), true);
+ }
+ }
+
+ public void executeTaskLater(final Runnable r, final long timeDelay) {
+ this.mQClientFactory.getPullMessageService().executeTaskLater(r, timeDelay);
+ }
+
+ public QueryResult queryMessage(String topic, String key, int maxNum, long begin, long end)
+ throws MQClientException, InterruptedException {
+ return this.mQClientFactory.getMQAdminImpl().queryMessage(topic, key, maxNum, begin, end);
+ }
+
+ public MessageExt queryMessageByUniqKey(String topic, String uniqKey) throws MQClientException,
+ InterruptedException {
+ return this.mQClientFactory.getMQAdminImpl().queryMessageByUniqKey(topic, uniqKey);
+ }
+
+
+ public void registerMessageListener(MessageListener messageListener) {
+ this.messageListenerInner = messageListener;
+ }
+
+ public void resume() {
+ this.pause = false;
+ doRebalance();
+ log.info("resume this consumer, {}", this.defaultMQPushConsumer.getConsumerGroup());
+ }
+
+ public void sendMessageBack(MessageExt msg, int delayLevel, final String brokerName)
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ try {
+ String brokerAddr = (null != brokerName) ? this.mQClientFactory.findBrokerAddressInPublish(brokerName)
+ : RemotingHelper.parseSocketAddressAddr(msg.getStoreHost());
+ this.mQClientFactory.getMQClientAPIImpl().consumerSendMessageBack(brokerAddr, msg,
+ this.defaultMQPushConsumer.getConsumerGroup(), delayLevel, 5000, getMaxReconsumeTimes());
+ } catch (Exception e) {
+ log.error("sendMessageBack Exception, " + this.defaultMQPushConsumer.getConsumerGroup(), e);
+
+ Message newMsg = new Message(MixAll.getRetryTopic(this.defaultMQPushConsumer.getConsumerGroup()), msg.getBody());
+
+ String originMsgId = MessageAccessor.getOriginMessageId(msg);
+ MessageAccessor.setOriginMessageId(newMsg, UtilAll.isBlank(originMsgId) ? msg.getMsgId() : originMsgId);
+
+ newMsg.setFlag(msg.getFlag());
+ MessageAccessor.setProperties(newMsg, msg.getProperties());
+ MessageAccessor.putProperty(newMsg, MessageConst.PROPERTY_RETRY_TOPIC, msg.getTopic());
+ MessageAccessor.setReconsumeTime(newMsg, String.valueOf(msg.getReconsumeTimes() + 1));
+ MessageAccessor.setMaxReconsumeTimes(newMsg, String.valueOf(getMaxReconsumeTimes()));
+ newMsg.setDelayTimeLevel(3 + msg.getReconsumeTimes());
+
+ this.mQClientFactory.getDefaultMQProducer().send(newMsg);
+ }
+ }
+
+ private int getMaxReconsumeTimes() {
+ // default reconsume times: 16
+ if (this.defaultMQPushConsumer.getMaxReconsumeTimes() == -1) {
+ return 16;
+ } else {
+ return this.defaultMQPushConsumer.getMaxReconsumeTimes();
+ }
+ }
+
+ public void shutdown() {
+ switch (this.serviceState) {
+ case CREATE_JUST:
+ break;
+ case RUNNING:
+ this.consumeMessageService.shutdown();
+ this.persistConsumerOffset();
+ this.mQClientFactory.unregisterConsumer(this.defaultMQPushConsumer.getConsumerGroup());
+ this.mQClientFactory.shutdown();
+ log.info("the consumer [{}] shutdown OK", this.defaultMQPushConsumer.getConsumerGroup());
+ this.rebalanceImpl.destroy();
+ this.serviceState = ServiceState.SHUTDOWN_ALREADY;
+ break;
+ case SHUTDOWN_ALREADY:
+ break;
+ default:
+ break;
+ }
+ }
+
+ public void start() throws MQClientException {
+ switch (this.serviceState) {
+ case CREATE_JUST:
+ log.info("the consumer [{}] start beginning. messageModel={}, isUnitMode={}", this.defaultMQPushConsumer.getConsumerGroup(),
+ this.defaultMQPushConsumer.getMessageModel(), this.defaultMQPushConsumer.isUnitMode());
+ this.serviceState = ServiceState.START_FAILED;
+
+ this.checkConfig();
+
+ this.copySubscription();
+
+ if (this.defaultMQPushConsumer.getMessageModel() == MessageModel.CLUSTERING) {
+ this.defaultMQPushConsumer.changeInstanceNameToPID();
+ }
+
+ this.mQClientFactory = MQClientManager.getInstance().getAndCreateMQClientInstance(this.defaultMQPushConsumer, this.rpcHook);
+
+ this.rebalanceImpl.setConsumerGroup(this.defaultMQPushConsumer.getConsumerGroup());
+ this.rebalanceImpl.setMessageModel(this.defaultMQPushConsumer.getMessageModel());
+ this.rebalanceImpl.setAllocateMessageQueueStrategy(this.defaultMQPushConsumer.getAllocateMessageQueueStrategy());
+ this.rebalanceImpl.setmQClientFactory(this.mQClientFactory);
+
+ this.pullAPIWrapper = new PullAPIWrapper(
+ mQClientFactory,
+ this.defaultMQPushConsumer.getConsumerGroup(), isUnitMode());
+ this.pullAPIWrapper.registerFilterMessageHook(filterMessageHookList);
+
+ if (this.defaultMQPushConsumer.getOffsetStore() != null) {
+ this.offsetStore = this.defaultMQPushConsumer.getOffsetStore();
+ } else {
+ switch (this.defaultMQPushConsumer.getMessageModel()) {
+ case BROADCASTING:
+ this.offsetStore = new LocalFileOffsetStore(this.mQClientFactory, this.defaultMQPushConsumer.getConsumerGroup());
+ break;
+ case CLUSTERING:
+ this.offsetStore = new RemoteBrokerOffsetStore(this.mQClientFactory, this.defaultMQPushConsumer.getConsumerGroup());
+ break;
+ default:
+ break;
+ }
+ }
+ this.offsetStore.load();
+
+ if (this.getMessageListenerInner() instanceof MessageListenerOrderly) {
+ this.consumeOrderly = true;
+ this.consumeMessageService =
+ new ConsumeMessageOrderlyService(this, (MessageListenerOrderly) this.getMessageListenerInner());
+ } else if (this.getMessageListenerInner() instanceof MessageListenerConcurrently) {
+ this.consumeOrderly = false;
+ this.consumeMessageService =
+ new ConsumeMessageConcurrentlyService(this, (MessageListenerConcurrently) this.getMessageListenerInner());
+ }
+
+ this.consumeMessageService.start();
+
+ boolean registerOK = mQClientFactory.registerConsumer(this.defaultMQPushConsumer.getConsumerGroup(), this);
+ if (!registerOK) {
+ this.serviceState = ServiceState.CREATE_JUST;
+ this.consumeMessageService.shutdown();
+ throw new MQClientException("The consumer group[" + this.defaultMQPushConsumer.getConsumerGroup()
+ + "] has been created before, specify another name please." + FAQUrl.suggestTodo(FAQUrl.GROUP_NAME_DUPLICATE_URL),
+ null);
+ }
+
+ mQClientFactory.start();
+ log.info("the consumer [{}] start OK.", this.defaultMQPushConsumer.getConsumerGroup());
+ this.serviceState = ServiceState.RUNNING;
+ break;
+ case RUNNING:
+ case START_FAILED:
+ case SHUTDOWN_ALREADY:
+ throw new MQClientException("The PushConsumer service state not OK, maybe started once, "//
+ + this.serviceState//
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),
+ null);
+ default:
+ break;
+ }
+
+ this.updateTopicSubscribeInfoWhenSubscriptionChanged();
+
+ this.mQClientFactory.sendHeartbeatToAllBrokerWithLock();
+
+ this.mQClientFactory.rebalanceImmediately();
+ }
+
+ private void checkConfig() throws MQClientException {
+ Validators.checkGroup(this.defaultMQPushConsumer.getConsumerGroup());
+
+ if (null == this.defaultMQPushConsumer.getConsumerGroup()) {
+ throw new MQClientException(
+ "consumerGroup is null"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
+ }
+
+ if (this.defaultMQPushConsumer.getConsumerGroup().equals(MixAll.DEFAULT_CONSUMER_GROUP)) {
+ throw new MQClientException(
+ "consumerGroup can not equal "
+ + MixAll.DEFAULT_CONSUMER_GROUP
+ + ", please specify another one."
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
+ }
+
+ if (null == this.defaultMQPushConsumer.getMessageModel()) {
+ throw new MQClientException(
+ "messageModel is null"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
+ }
+
+ if (null == this.defaultMQPushConsumer.getConsumeFromWhere()) {
+ throw new MQClientException(
+ "consumeFromWhere is null"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
+ }
+
+ Date dt = UtilAll.parseDate(this.defaultMQPushConsumer.getConsumeTimestamp(), UtilAll.YYYY_MMDD_HHMMSS);
+ if (null == dt) {
+ throw new MQClientException(
+ "consumeTimestamp is invalid, YYYY_MMDD_HHMMSS"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
+ }
+
+ // allocateMessageQueueStrategy
+ if (null == this.defaultMQPushConsumer.getAllocateMessageQueueStrategy()) {
+ throw new MQClientException(
+ "allocateMessageQueueStrategy is null"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
+ }
+
+ // subscription
+ if (null == this.defaultMQPushConsumer.getSubscription()) {
+ throw new MQClientException(
+ "subscription is null"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
+ }
+
+ // messageListener
+ if (null == this.defaultMQPushConsumer.getMessageListener()) {
+ throw new MQClientException(
+ "messageListener is null"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
+ }
+
+ boolean orderly = this.defaultMQPushConsumer.getMessageListener() instanceof MessageListenerOrderly;
+ boolean concurrently = this.defaultMQPushConsumer.getMessageListener() instanceof MessageListenerConcurrently;
+ if (!orderly && !concurrently) {
+ throw new MQClientException(
+ "messageListener must be instanceof MessageListenerOrderly or MessageListenerConcurrently"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
+ }
+
+ // consumeThreadMin
+ if (this.defaultMQPushConsumer.getConsumeThreadMin() < 1
+ || this.defaultMQPushConsumer.getConsumeThreadMin() > 1000
+ || this.defaultMQPushConsumer.getConsumeThreadMin() > this.defaultMQPushConsumer.getConsumeThreadMax()) {
+ throw new MQClientException(
+ "consumeThreadMin Out of range [1, 1000]"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
+ }
+
+ // consumeThreadMax
+ if (this.defaultMQPushConsumer.getConsumeThreadMax() < 1 || this.defaultMQPushConsumer.getConsumeThreadMax() > 1000) {
+ throw new MQClientException(
+ "consumeThreadMax Out of range [1, 1000]"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
+ }
+
+ // consumeConcurrentlyMaxSpan
+ if (this.defaultMQPushConsumer.getConsumeConcurrentlyMaxSpan() < 1
+ || this.defaultMQPushConsumer.getConsumeConcurrentlyMaxSpan() > 65535) {
+ throw new MQClientException(
+ "consumeConcurrentlyMaxSpan Out of range [1, 65535]"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
+ }
+
+ // pullThresholdForQueue
+ if (this.defaultMQPushConsumer.getPullThresholdForQueue() < 1 || this.defaultMQPushConsumer.getPullThresholdForQueue() > 65535) {
+ throw new MQClientException(
+ "pullThresholdForQueue Out of range [1, 65535]"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
+ }
+
+ // pullInterval
+ if (this.defaultMQPushConsumer.getPullInterval() < 0 || this.defaultMQPushConsumer.getPullInterval() > 65535) {
+ throw new MQClientException(
+ "pullInterval Out of range [0, 65535]"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
+ }
+
+ // consumeMessageBatchMaxSize
+ if (this.defaultMQPushConsumer.getConsumeMessageBatchMaxSize() < 1
+ || this.defaultMQPushConsumer.getConsumeMessageBatchMaxSize() > 1024) {
+ throw new MQClientException(
+ "consumeMessageBatchMaxSize Out of range [1, 1024]"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
+ }
+
+ // pullBatchSize
+ if (this.defaultMQPushConsumer.getPullBatchSize() < 1 || this.defaultMQPushConsumer.getPullBatchSize() > 1024) {
+ throw new MQClientException(
+ "pullBatchSize Out of range [1, 1024]"
+ + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),
+ null);
+ }
+ }
+
+ private void copySubscription() throws MQClientException {
+ try {
+ Map<String, String> sub = this.defaultMQPushConsumer.getSubscription();
+ if (sub != null) {
+ for (final Map.Entry<String, String> entry : sub.entrySet()) {
+ final String topic = entry.getKey();
+ final String subString = entry.getValue();
+ SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPushConsumer.getConsumerGroup(), //
+ topic, subString);
+ this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData);
+ }
+ }
+
+ if (null == this.messageListenerInner) {
+ this.messageListenerInner = this.defaultMQPushConsumer.getMessageListener();
+ }
+
+ switch (this.defaultMQPushConsumer.getMessageModel()) {
+ case BROADCASTING:
+ break;
+ case CLUSTERING:
+ final String retryTopic = MixAll.getRetryTopic(this.defaultMQPushConsumer.getConsumerGroup());
+ SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPushConsumer.getConsumerGroup(), //
+ retryTopic, SubscriptionData.SUB_ALL);
+ this.rebalanceImpl.getSubscriptionInner().put(retryTopic, subscriptionData);
+ break;
+ default:
+ break;
+ }
+ } catch (Exception e) {
+ throw new MQClientException("subscription exception", e);
+ }
+ }
+
+ public MessageListener getMessageListenerInner() {
+ return messageListenerInner;
+ }
+
+ private void updateTopicSubscribeInfoWhenSubscriptionChanged() {
+ Map<String, SubscriptionData> subTable = this.getSubscriptionInner();
+ if (subTable != null) {
+ for (final Map.Entry<String, SubscriptionData> entry : subTable.entrySet()) {
+ final String topic = entry.getKey();
+ this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic);
+ }
+ }
+ }
+
+ public ConcurrentHashMap<String, SubscriptionData> getSubscriptionInner() {
+ return this.rebalanceImpl.getSubscriptionInner();
+ }
+
+ public void subscribe(String topic, String subExpression) throws MQClientException {
+ try {
+ SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPushConsumer.getConsumerGroup(), //
+ topic, subExpression);
+ this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData);
+ if (this.mQClientFactory != null) {
+ this.mQClientFactory.sendHeartbeatToAllBrokerWithLock();
+ }
+ } catch (Exception e) {
+ throw new MQClientException("subscription exception", e);
+ }
+ }
+
+ public void subscribe(String topic, String fullClassName, String filterClassSource) throws MQClientException {
+ try {
+ SubscriptionData subscriptionData = FilterAPI.buildSubscriptionData(this.defaultMQPushConsumer.getConsumerGroup(), //
+ topic, "*");
+ subscriptionData.setSubString(fullClassName);
+ subscriptionData.setClassFilterMode(true);
+ subscriptionData.setFilterClassSource(filterClassSource);
+ this.rebalanceImpl.getSubscriptionInner().put(topic, subscriptionData);
+ if (this.mQClientFactory != null) {
+ this.mQClientFactory.sendHeartbeatToAllBrokerWithLock();
+ }
+
+ } catch (Exception e) {
+ throw new MQClientException("subscription exception", e);
+ }
+ }
+
+ public void suspend() {
+ this.pause = true;
+ log.info("suspend this consumer, {}", this.defaultMQPushConsumer.getConsumerGroup());
+ }
+
+ public void unsubscribe(String topic) {
+ this.rebalanceImpl.getSubscriptionInner().remove(topic);
+ }
+
+ public void updateConsumeOffset(MessageQueue mq, long offset) {
+ this.offsetStore.updateOffset(mq, offset, false);
+ }
+
+ public void updateCorePoolSize(int corePoolSize) {
+ this.consumeMessageService.updateCorePoolSize(corePoolSize);
+ }
+
+ public MessageExt viewMessage(String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ return this.mQClientFactory.getMQAdminImpl().viewMessage(msgId);
+ }
+
+ public RebalanceImpl getRebalanceImpl() {
+ return rebalanceImpl;
+ }
+
+ public boolean isConsumeOrderly() {
+ return consumeOrderly;
+ }
+
+ public void setConsumeOrderly(boolean consumeOrderly) {
+ this.consumeOrderly = consumeOrderly;
+ }
+
+ public void resetOffsetByTimeStamp(long timeStamp)
+ throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
+ for (String topic : rebalanceImpl.getSubscriptionInner().keySet()) {
+ Set<MessageQueue> mqs = rebalanceImpl.getTopicSubscribeInfoTable().get(topic);
+ Map<MessageQueue, Long> offsetTable = new HashMap<MessageQueue, Long>();
+ if (mqs != null) {
+ for (MessageQueue mq : mqs) {
+ long offset = searchOffset(mq, timeStamp);
+ offsetTable.put(mq, offset);
+ }
+ this.mQClientFactory.resetOffset(topic, groupName(), offsetTable);
+ }
+ }
+ }
+
+ public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
+ return this.mQClientFactory.getMQAdminImpl().searchOffset(mq, timestamp);
+ }
+
+ @Override
+ public String groupName() {
+ return this.defaultMQPushConsumer.getConsumerGroup();
+ }
+
+ @Override
+ public MessageModel messageModel() {
+ return this.defaultMQPushConsumer.getMessageModel();
+ }
+
+ @Override
+ public ConsumeType consumeType() {
+ return ConsumeType.CONSUME_PASSIVELY;
+ }
+
+ @Override
+ public ConsumeFromWhere consumeFromWhere() {
+ return this.defaultMQPushConsumer.getConsumeFromWhere();
+ }
+
+ @Override
+ public Set<SubscriptionData> subscriptions() {
+ Set<SubscriptionData> subSet = new HashSet<SubscriptionData>();
+
+ subSet.addAll(this.rebalanceImpl.getSubscriptionInner().values());
+
+ return subSet;
+ }
+
+ @Override
+ public void doRebalance() {
+ if (this.rebalanceImpl != null && !this.pause) {
+ this.rebalanceImpl.doRebalance(this.isConsumeOrderly());
+ }
+ }
+
+ @Override
+ public void persistConsumerOffset() {
+ try {
+ this.makeSureStateOK();
+ Set<MessageQueue> mqs = new HashSet<MessageQueue>();
+ Set<MessageQueue> allocateMq = this.rebalanceImpl.getProcessQueueTable().keySet();
+ if (allocateMq != null) {
+ mqs.addAll(allocateMq);
+ }
+
+ this.offsetStore.persistAll(mqs);
+ } catch (Exception e) {
+ log.error("group: " + this.defaultMQPushConsumer.getConsumerGroup() + " persistConsumerOffset exception", e);
+ }
+ }
+
+ @Override
+ public void updateTopicSubscribeInfo(String topic, Set<MessageQueue> info) {
+ Map<String, SubscriptionData> subTable = this.getSubscriptionInner();
+ if (subTable != null) {
+ if (subTable.containsKey(topic)) {
+ this.rebalanceImpl.topicSubscribeInfoTable.put(topic, info);
+ }
+ }
+ }
+
+ @Override
+ public boolean isSubscribeTopicNeedUpdate(String topic) {
+ Map<String, SubscriptionData> subTable = this.getSubscriptionInner();
+ if (subTable != null) {
+ if (subTable.containsKey(topic)) {
+ return !this.rebalanceImpl.topicSubscribeInfoTable.containsKey(topic);
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean isUnitMode() {
+ return this.defaultMQPushConsumer.isUnitMode();
+ }
+
+ @Override
+ public ConsumerRunningInfo consumerRunningInfo() {
+ ConsumerRunningInfo info = new ConsumerRunningInfo();
+
+ Properties prop = MixAll.object2Properties(this.defaultMQPushConsumer);
+
+ prop.put(ConsumerRunningInfo.PROP_CONSUME_ORDERLY, String.valueOf(this.consumeOrderly));
+ prop.put(ConsumerRunningInfo.PROP_THREADPOOL_CORE_SIZE, String.valueOf(this.consumeMessageService.getCorePoolSize()));
+ prop.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, String.valueOf(this.consumerStartTimestamp));
+
+ info.setProperties(prop);
+
+ Set<SubscriptionData> subSet = this.subscriptions();
+ info.getSubscriptionSet().addAll(subSet);
+
+ Iterator<Entry<MessageQueue, ProcessQueue>> it = this.rebalanceImpl.getProcessQueueTable().entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<MessageQueue, ProcessQueue> next = it.next();
+ MessageQueue mq = next.getKey();
+ ProcessQueue pq = next.getValue();
+
+ ProcessQueueInfo pqinfo = new ProcessQueueInfo();
+ pqinfo.setCommitOffset(this.offsetStore.readOffset(mq, ReadOffsetType.MEMORY_FIRST_THEN_STORE));
+ pq.fillProcessQueueInfo(pqinfo);
+ info.getMqTable().put(mq, pqinfo);
+ }
+
+ for (SubscriptionData sd : subSet) {
+ ConsumeStatus consumeStatus = this.mQClientFactory.getConsumerStatsManager().consumeStatus(this.groupName(), sd.getTopic());
+ info.getStatusTable().put(sd.getTopic(), consumeStatus);
+ }
+
+ return info;
+ }
+
+ public MQClientInstance getmQClientFactory() {
+ return mQClientFactory;
+ }
+
+ public void setmQClientFactory(MQClientInstance mQClientFactory) {
+ this.mQClientFactory = mQClientFactory;
+ }
+
+ public ServiceState getServiceState() {
+ return serviceState;
+ }
+
+ public void setServiceState(ServiceState serviceState) {
+ this.serviceState = serviceState;
+ }
+
+ public void adjustThreadPool() {
+ long computeAccTotal = this.computeAccumulationTotal();
+ long adjustThreadPoolNumsThreshold = this.defaultMQPushConsumer.getAdjustThreadPoolNumsThreshold();
+
+ long incThreshold = (long) (adjustThreadPoolNumsThreshold * 1.0);
+
+ long decThreshold = (long) (adjustThreadPoolNumsThreshold * 0.8);
+
+ if (computeAccTotal >= incThreshold) {
+ this.consumeMessageService.incCorePoolSize();
+ }
+
+ if (computeAccTotal < decThreshold) {
+ this.consumeMessageService.decCorePoolSize();
+ }
+ }
+
+ private long computeAccumulationTotal() {
+ long msgAccTotal = 0;
+ ConcurrentHashMap<MessageQueue, ProcessQueue> processQueueTable = this.rebalanceImpl.getProcessQueueTable();
+ Iterator<Entry<MessageQueue, ProcessQueue>> it = processQueueTable.entrySet().iterator();
+ while (it.hasNext()) {
+ Entry<MessageQueue, ProcessQueue> next = it.next();
+ ProcessQueue value = next.getValue();
+ msgAccTotal += value.getMsgAccCnt();
+ }
+
+ return msgAccTotal;
+ }
+
+ public List<QueueTimeSpan> queryConsumeTimeSpan(final String topic)
+ throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
+ List<QueueTimeSpan> queueTimeSpan = new ArrayList<QueueTimeSpan>();
+ TopicRouteData routeData = this.mQClientFactory.getMQClientAPIImpl().getTopicRouteInfoFromNameServer(topic, 3000);
+ for (BrokerData brokerData : routeData.getBrokerDatas()) {
+ String addr = brokerData.selectBrokerAddr();
+ queueTimeSpan.addAll(this.mQClientFactory.getMQClientAPIImpl().queryConsumeTimeSpan(addr, topic, groupName(), 3000));
+ }
+
+ return queueTimeSpan;
+ }
+
+
+ public ConsumeMessageService getConsumeMessageService() {
+ return consumeMessageService;
+ }
+
+
+ public void setConsumeMessageService(ConsumeMessageService consumeMessageService) {
+ this.consumeMessageService = consumeMessageService;
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
new file mode 100644
index 0000000..c1abd2f
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MQConsumerInner.java
@@ -0,0 +1,66 @@
+/**
+ * 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.impl.consumer;
+
+import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
+import org.apache.rocketmq.common.message.MessageQueue;
+import org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo;
+import org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;
+import org.apache.rocketmq.common.protocol.heartbeat.MessageModel;
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
+
+import java.util.Set;
+
+
+/**
+ * Consumer inner interface
+ *
+ * @author shijia.wxr
+ */
+public interface MQConsumerInner {
+ String groupName();
+
+
+ MessageModel messageModel();
+
+
+ ConsumeType consumeType();
+
+
+ ConsumeFromWhere consumeFromWhere();
+
+
+ Set<SubscriptionData> subscriptions();
+
+
+ void doRebalance();
+
+
+ void persistConsumerOffset();
+
+
+ void updateTopicSubscribeInfo(final String topic, final Set<MessageQueue> info);
+
+
+ boolean isSubscribeTopicNeedUpdate(final String topic);
+
+
+ boolean isUnitMode();
+
+
+ ConsumerRunningInfo consumerRunningInfo();
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
new file mode 100644
index 0000000..0849b5e
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/MessageQueueLock.java
@@ -0,0 +1,46 @@
+/**
+ * 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.impl.consumer;
+
+import org.apache.rocketmq.common.message.MessageQueue;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+
+/**
+ * Message lock,strictly ensure the single queue only one thread at a time consuming
+ *
+ * @author shijia.wxr
+ */
+public class MessageQueueLock {
+ private ConcurrentHashMap<MessageQueue, Object> mqLockTable =
+ new ConcurrentHashMap<MessageQueue, Object>();
+
+
+ public Object fetchLockObject(final MessageQueue mq) {
+ Object objLock = this.mqLockTable.get(mq);
+ if (null == objLock) {
+ objLock = new Object();
+ Object prevLock = this.mqLockTable.putIfAbsent(mq, objLock);
+ if (prevLock != null) {
+ objLock = prevLock;
+ }
+ }
+
+ return objLock;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
new file mode 100644
index 0000000..adca859
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/ProcessQueue.java
@@ -0,0 +1,451 @@
+/**
+ * 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.impl.consumer;
+
+import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.message.MessageAccessor;
+import org.apache.rocketmq.common.message.MessageConst;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.protocol.body.ProcessQueueInfo;
+import org.slf4j.Logger;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+
+/**
+ * Queue consumption snapshot
+ *
+ * @author shijia.wxr
+ */
+public class ProcessQueue {
+ public final static long REBALANCE_LOCK_MAX_LIVE_TIME =
+ Long.parseLong(System.getProperty("rocketmq.client.rebalance.lockMaxLiveTime", "30000"));
+ public final static long REBALANCE_LOCK_INTERVAL = Long.parseLong(System.getProperty("rocketmq.client.rebalance.lockInterval", "20000"));
+ private final static long PULL_MAX_IDLE_TIME = Long.parseLong(System.getProperty("rocketmq.client.pull.pullMaxIdleTime", "120000"));
+ private final Logger log = ClientLogger.getLog();
+ private final ReadWriteLock lockTreeMap = new ReentrantReadWriteLock();
+ private final TreeMap<Long, MessageExt> msgTreeMap = new TreeMap<Long, MessageExt>();
+ private final AtomicLong msgCount = new AtomicLong();
+ private final Lock lockConsume = new ReentrantLock();
+ private final TreeMap<Long, MessageExt> msgTreeMapTemp = new TreeMap<Long, MessageExt>();
+ private final AtomicLong tryUnlockTimes = new AtomicLong(0);
+ private volatile long queueOffsetMax = 0L;
+ private volatile boolean dropped = false;
+ private volatile long lastPullTimestamp = System.currentTimeMillis();
+ private volatile long lastConsumeTimestamp = System.currentTimeMillis();
+ private volatile boolean locked = false;
+ private volatile long lastLockTimestamp = System.currentTimeMillis();
+ private volatile boolean consuming = false;
+ private volatile long msgAccCnt = 0;
+
+ public boolean isLockExpired() {
+ boolean result = (System.currentTimeMillis() - this.lastLockTimestamp) > REBALANCE_LOCK_MAX_LIVE_TIME;
+ return result;
+ }
+
+
+ public boolean isPullExpired() {
+ boolean result = (System.currentTimeMillis() - this.lastPullTimestamp) > PULL_MAX_IDLE_TIME;
+ return result;
+ }
+
+ /**
+
+ *
+ * @param pushConsumer
+ */
+ public void cleanExpiredMsg(DefaultMQPushConsumer pushConsumer) {
+ if (pushConsumer.getDefaultMQPushConsumerImpl().isConsumeOrderly()) {
+ return;
+ }
+
+ int loop = msgTreeMap.size() < 16 ? msgTreeMap.size() : 16;
+ for (int i = 0; i < loop; i++) {
+ MessageExt msg = null;
+ try {
+ this.lockTreeMap.readLock().lockInterruptibly();
+ try {
+ if (!msgTreeMap.isEmpty() && System.currentTimeMillis() - Long.parseLong(MessageAccessor.getConsumeStartTimeStamp(msgTreeMap.firstEntry().getValue())) > pushConsumer.getConsumeTimeout() * 60 * 1000) {
+ msg = msgTreeMap.firstEntry().getValue();
+ } else {
+
+ break;
+ }
+ } finally {
+ this.lockTreeMap.readLock().unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("getExpiredMsg exception", e);
+ }
+
+ try {
+
+ pushConsumer.sendMessageBack(msg, 3);
+ log.info("send expire msg back. topic={}, msgId={}, storeHost={}, queueId={}, queueOffset={}", msg.getTopic(), msg.getMsgId(), msg.getStoreHost(), msg.getQueueId(), msg.getQueueOffset());
+ try {
+ this.lockTreeMap.writeLock().lockInterruptibly();
+ try {
+ if (!msgTreeMap.isEmpty() && msg.getQueueOffset() == msgTreeMap.firstKey()) {
+ try {
+ msgTreeMap.remove(msgTreeMap.firstKey());
+ } catch (Exception e) {
+ log.error("send expired msg exception", e);
+ }
+ }
+ } finally {
+ this.lockTreeMap.writeLock().unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("getExpiredMsg exception", e);
+ }
+ } catch (Exception e) {
+ log.error("send expired msg exception", e);
+ }
+ }
+ }
+
+
+ public boolean putMessage(final List<MessageExt> msgs) {
+ boolean dispatchToConsume = false;
+ try {
+ this.lockTreeMap.writeLock().lockInterruptibly();
+ try {
+ int validMsgCnt = 0;
+ for (MessageExt msg : msgs) {
+ MessageExt old = msgTreeMap.put(msg.getQueueOffset(), msg);
+ if (null == old) {
+ validMsgCnt++;
+ this.queueOffsetMax = msg.getQueueOffset();
+ }
+ }
+ msgCount.addAndGet(validMsgCnt);
+
+ if (!msgTreeMap.isEmpty() && !this.consuming) {
+ dispatchToConsume = true;
+ this.consuming = true;
+ }
+
+ if (!msgs.isEmpty()) {
+ MessageExt messageExt = msgs.get(msgs.size() - 1);
+ String property = messageExt.getProperty(MessageConst.PROPERTY_MAX_OFFSET);
+ if (property != null) {
+ long accTotal = Long.parseLong(property) - messageExt.getQueueOffset();
+ if (accTotal > 0) {
+ this.msgAccCnt = accTotal;
+ }
+ }
+ }
+ } finally {
+ this.lockTreeMap.writeLock().unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("putMessage exception", e);
+ }
+
+ return dispatchToConsume;
+ }
+
+
+ public long getMaxSpan() {
+ try {
+ this.lockTreeMap.readLock().lockInterruptibly();
+ try {
+ if (!this.msgTreeMap.isEmpty()) {
+ return this.msgTreeMap.lastKey() - this.msgTreeMap.firstKey();
+ }
+ } finally {
+ this.lockTreeMap.readLock().unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("getMaxSpan exception", e);
+ }
+
+ return 0;
+ }
+
+
+ public long removeMessage(final List<MessageExt> msgs) {
+ long result = -1;
+ final long now = System.currentTimeMillis();
+ try {
+ this.lockTreeMap.writeLock().lockInterruptibly();
+ this.lastConsumeTimestamp = now;
+ try {
+ if (!msgTreeMap.isEmpty()) {
+ result = this.queueOffsetMax + 1;
+ int removedCnt = 0;
+ for (MessageExt msg : msgs) {
+ MessageExt prev = msgTreeMap.remove(msg.getQueueOffset());
+ if (prev != null) {
+ removedCnt--;
+ }
+ }
+ msgCount.addAndGet(removedCnt);
+
+ if (!msgTreeMap.isEmpty()) {
+ result = msgTreeMap.firstKey();
+ }
+ }
+ } finally {
+ this.lockTreeMap.writeLock().unlock();
+ }
+ } catch (Throwable t) {
+ log.error("removeMessage exception", t);
+ }
+
+ return result;
+ }
+
+
+ public TreeMap<Long, MessageExt> getMsgTreeMap() {
+ return msgTreeMap;
+ }
+
+
+ public AtomicLong getMsgCount() {
+ return msgCount;
+ }
+
+
+ public boolean isDropped() {
+ return dropped;
+ }
+
+
+ public void setDropped(boolean dropped) {
+ this.dropped = dropped;
+ }
+
+ public boolean isLocked() {
+ return locked;
+ }
+
+ public void setLocked(boolean locked) {
+ this.locked = locked;
+ }
+
+ public void rollback() {
+ try {
+ this.lockTreeMap.writeLock().lockInterruptibly();
+ try {
+ this.msgTreeMap.putAll(this.msgTreeMapTemp);
+ this.msgTreeMapTemp.clear();
+ } finally {
+ this.lockTreeMap.writeLock().unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("rollback exception", e);
+ }
+ }
+
+
+ public long commit() {
+ try {
+ this.lockTreeMap.writeLock().lockInterruptibly();
+ try {
+ Long offset = this.msgTreeMapTemp.lastKey();
+ msgCount.addAndGet(this.msgTreeMapTemp.size() * (-1));
+ this.msgTreeMapTemp.clear();
+ if (offset != null) {
+ return offset + 1;
+ }
+ } finally {
+ this.lockTreeMap.writeLock().unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("commit exception", e);
+ }
+
+ return -1;
+ }
+
+
+ public void makeMessageToCosumeAgain(List<MessageExt> msgs) {
+ try {
+ this.lockTreeMap.writeLock().lockInterruptibly();
+ try {
+ for (MessageExt msg : msgs) {
+ this.msgTreeMapTemp.remove(msg.getQueueOffset());
+ this.msgTreeMap.put(msg.getQueueOffset(), msg);
+ }
+ } finally {
+ this.lockTreeMap.writeLock().unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("makeMessageToCosumeAgain exception", e);
+ }
+ }
+
+
+ public List<MessageExt> takeMessags(final int batchSize) {
+ List<MessageExt> result = new ArrayList<MessageExt>(batchSize);
+ final long now = System.currentTimeMillis();
+ try {
+ this.lockTreeMap.writeLock().lockInterruptibly();
+ this.lastConsumeTimestamp = now;
+ try {
+ if (!this.msgTreeMap.isEmpty()) {
+ for (int i = 0; i < batchSize; i++) {
+ Map.Entry<Long, MessageExt> entry = this.msgTreeMap.pollFirstEntry();
+ if (entry != null) {
+ result.add(entry.getValue());
+ msgTreeMapTemp.put(entry.getKey(), entry.getValue());
+ } else {
+ break;
+ }
+ }
+ }
+
+ if (result.isEmpty()) {
+ consuming = false;
+ }
+ } finally {
+ this.lockTreeMap.writeLock().unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("take Messages exception", e);
+ }
+
+ return result;
+ }
+
+
+ public boolean hasTempMessage() {
+ try {
+ this.lockTreeMap.readLock().lockInterruptibly();
+ try {
+ return !this.msgTreeMap.isEmpty();
+ } finally {
+ this.lockTreeMap.readLock().unlock();
+ }
+ } catch (InterruptedException e) {
+ }
+
+ return true;
+ }
+
+
+ public void clear() {
+ try {
+ this.lockTreeMap.writeLock().lockInterruptibly();
+ try {
+ this.msgTreeMap.clear();
+ this.msgTreeMapTemp.clear();
+ this.msgCount.set(0);
+ this.queueOffsetMax = 0L;
+ } finally {
+ this.lockTreeMap.writeLock().unlock();
+ }
+ } catch (InterruptedException e) {
+ log.error("rollback exception", e);
+ }
+ }
+
+
+ public long getLastLockTimestamp() {
+ return lastLockTimestamp;
+ }
+
+
+ public void setLastLockTimestamp(long lastLockTimestamp) {
+ this.lastLockTimestamp = lastLockTimestamp;
+ }
+
+
+ public Lock getLockConsume() {
+ return lockConsume;
+ }
+
+
+ public long getLastPullTimestamp() {
+ return lastPullTimestamp;
+ }
+
+
+ public void setLastPullTimestamp(long lastPullTimestamp) {
+ this.lastPullTimestamp = lastPullTimestamp;
+ }
+
+
+ public long getMsgAccCnt() {
+ return msgAccCnt;
+ }
+
+
+ public void setMsgAccCnt(long msgAccCnt) {
+ this.msgAccCnt = msgAccCnt;
+ }
+
+
+ public long getTryUnlockTimes() {
+ return this.tryUnlockTimes.get();
+ }
+
+
+ public void incTryUnlockTimes() {
+ this.tryUnlockTimes.incrementAndGet();
+ }
+
+
+ public void fillProcessQueueInfo(final ProcessQueueInfo info) {
+ try {
+ this.lockTreeMap.readLock().lockInterruptibly();
+
+ if (!this.msgTreeMap.isEmpty()) {
+ info.setCachedMsgMinOffset(this.msgTreeMap.firstKey());
+ info.setCachedMsgMaxOffset(this.msgTreeMap.lastKey());
+ info.setCachedMsgCount(this.msgTreeMap.size());
+ }
+
+ if (!this.msgTreeMapTemp.isEmpty()) {
+ info.setTransactionMsgMinOffset(this.msgTreeMapTemp.firstKey());
+ info.setTransactionMsgMaxOffset(this.msgTreeMapTemp.lastKey());
+ info.setTransactionMsgCount(this.msgTreeMapTemp.size());
+ }
+
+ info.setLocked(this.locked);
+ info.setTryUnlockTimes(this.tryUnlockTimes.get());
+ info.setLastLockTimestamp(this.lastLockTimestamp);
+
+ info.setDroped(this.dropped);
+ info.setLastPullTimestamp(this.lastPullTimestamp);
+ info.setLastConsumeTimestamp(this.lastConsumeTimestamp);
+ } catch (Exception e) {
+ } finally {
+ this.lockTreeMap.readLock().unlock();
+ }
+ }
+
+
+ public long getLastConsumeTimestamp() {
+ return lastConsumeTimestamp;
+ }
+
+
+ public void setLastConsumeTimestamp(long lastConsumeTimestamp) {
+ this.lastConsumeTimestamp = lastConsumeTimestamp;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
new file mode 100644
index 0000000..05aa8d1
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java
@@ -0,0 +1,255 @@
+/**
+ * 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.impl.consumer;
+
+import org.apache.rocketmq.client.consumer.PullCallback;
+import org.apache.rocketmq.client.consumer.PullResult;
+import org.apache.rocketmq.client.consumer.PullStatus;
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.hook.FilterMessageContext;
+import org.apache.rocketmq.client.hook.FilterMessageHook;
+import org.apache.rocketmq.client.impl.CommunicationMode;
+import org.apache.rocketmq.client.impl.FindBrokerResult;
+import org.apache.rocketmq.client.impl.factory.MQClientInstance;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.MixAll;
+import org.apache.rocketmq.common.message.*;
+import org.apache.rocketmq.common.protocol.header.PullMessageRequestHeader;
+import org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;
+import org.apache.rocketmq.common.protocol.route.TopicRouteData;
+import org.apache.rocketmq.common.sysflag.PullSysFlag;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+import org.slf4j.Logger;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicLong;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class PullAPIWrapper {
+ private final Logger log = ClientLogger.getLog();
+ private final MQClientInstance mQClientFactory;
+ private final String consumerGroup;
+ private final boolean unitMode;
+ private ConcurrentHashMap<MessageQueue, AtomicLong/* brokerId */> pullFromWhichNodeTable =
+ new ConcurrentHashMap<MessageQueue, AtomicLong>(32);
+ private volatile boolean connectBrokerByUser = false;
+ private volatile long defaultBrokerId = MixAll.MASTER_ID;
+ private Random random = new Random(System.currentTimeMillis());
+ private ArrayList<FilterMessageHook> filterMessageHookList = new ArrayList<FilterMessageHook>();
+
+ public PullAPIWrapper(MQClientInstance mQClientFactory, String consumerGroup, boolean unitMode) {
+ this.mQClientFactory = mQClientFactory;
+ this.consumerGroup = consumerGroup;
+ this.unitMode = unitMode;
+ }
+
+ public PullResult processPullResult(final MessageQueue mq, final PullResult pullResult,
+ final SubscriptionData subscriptionData) {
+ PullResultExt pullResultExt = (PullResultExt) pullResult;
+
+ this.updatePullFromWhichNode(mq, pullResultExt.getSuggestWhichBrokerId());
+ if (PullStatus.FOUND == pullResult.getPullStatus()) {
+ ByteBuffer byteBuffer = ByteBuffer.wrap(pullResultExt.getMessageBinary());
+ List<MessageExt> msgList = MessageDecoder.decodes(byteBuffer);
+
+ List<MessageExt> msgListFilterAgain = msgList;
+ if (!subscriptionData.getTagsSet().isEmpty() && !subscriptionData.isClassFilterMode()) {
+ msgListFilterAgain = new ArrayList<MessageExt>(msgList.size());
+ for (MessageExt msg : msgList) {
+ if (msg.getTags() != null) {
+ if (subscriptionData.getTagsSet().contains(msg.getTags())) {
+ msgListFilterAgain.add(msg);
+ }
+ }
+ }
+ }
+
+ if (this.hasHook()) {
+ FilterMessageContext filterMessageContext = new FilterMessageContext();
+ filterMessageContext.setUnitMode(unitMode);
+ filterMessageContext.setMsgList(msgListFilterAgain);
+ this.executeHook(filterMessageContext);
+ }
+
+ for (MessageExt msg : msgListFilterAgain) {
+ MessageAccessor.putProperty(msg, MessageConst.PROPERTY_MIN_OFFSET,
+ Long.toString(pullResult.getMinOffset()));
+ MessageAccessor.putProperty(msg, MessageConst.PROPERTY_MAX_OFFSET,
+ Long.toString(pullResult.getMaxOffset()));
+ }
+
+ pullResultExt.setMsgFoundList(msgListFilterAgain);
+ }
+
+ pullResultExt.setMessageBinary(null);
+
+ return pullResult;
+ }
+
+ public void updatePullFromWhichNode(final MessageQueue mq, final long brokerId) {
+ AtomicLong suggest = this.pullFromWhichNodeTable.get(mq);
+ if (null == suggest) {
+ this.pullFromWhichNodeTable.put(mq, new AtomicLong(brokerId));
+ } else {
+ suggest.set(brokerId);
+ }
+ }
+
+ public boolean hasHook() {
+ return !this.filterMessageHookList.isEmpty();
+ }
+
+ public void executeHook(final FilterMessageContext context) {
+ if (!this.filterMessageHookList.isEmpty()) {
+ for (FilterMessageHook hook : this.filterMessageHookList) {
+ try {
+ hook.filterMessage(context);
+ } catch (Throwable e) {
+ log.error("execute hook error. hookName={}", hook.hookName());
+ }
+ }
+ }
+ }
+
+ public PullResult pullKernelImpl(
+ final MessageQueue mq,
+ final String subExpression,
+ final long subVersion,
+ final long offset,
+ final int maxNums,
+ final int sysFlag,
+ final long commitOffset,
+ final long brokerSuspendMaxTimeMillis,
+ final long timeoutMillis,
+ final CommunicationMode communicationMode,
+ final PullCallback pullCallback
+ ) throws MQClientException, RemotingException, MQBrokerException, InterruptedException {
+ FindBrokerResult findBrokerResult =
+ this.mQClientFactory.findBrokerAddressInSubscribe(mq.getBrokerName(),
+ this.recalculatePullFromWhichNode(mq), false);
+ if (null == findBrokerResult) {
+ this.mQClientFactory.updateTopicRouteInfoFromNameServer(mq.getTopic());
+ findBrokerResult =
+ this.mQClientFactory.findBrokerAddressInSubscribe(mq.getBrokerName(),
+ this.recalculatePullFromWhichNode(mq), false);
+ }
+
+ if (findBrokerResult != null) {
+ int sysFlagInner = sysFlag;
+
+ if (findBrokerResult.isSlave()) {
+ sysFlagInner = PullSysFlag.clearCommitOffsetFlag(sysFlagInner);
+ }
+
+ PullMessageRequestHeader requestHeader = new PullMessageRequestHeader();
+ requestHeader.setConsumerGroup(this.consumerGroup);
+ requestHeader.setTopic(mq.getTopic());
+ requestHeader.setQueueId(mq.getQueueId());
+ requestHeader.setQueueOffset(offset);
+ requestHeader.setMaxMsgNums(maxNums);
+ requestHeader.setSysFlag(sysFlagInner);
+ requestHeader.setCommitOffset(commitOffset);
+ requestHeader.setSuspendTimeoutMillis(brokerSuspendMaxTimeMillis);
+ requestHeader.setSubscription(subExpression);
+ requestHeader.setSubVersion(subVersion);
+
+ String brokerAddr = findBrokerResult.getBrokerAddr();
+ if (PullSysFlag.hasClassFilterFlag(sysFlagInner)) {
+ brokerAddr = computPullFromWhichFilterServer(mq.getTopic(), brokerAddr);
+ }
+
+ PullResult pullResult = this.mQClientFactory.getMQClientAPIImpl().pullMessage(
+ brokerAddr,
+ requestHeader,
+ timeoutMillis,
+ communicationMode,
+ pullCallback);
+
+ return pullResult;
+ }
+
+ throw new MQClientException("The broker[" + mq.getBrokerName() + "] not exist", null);
+ }
+
+ public long recalculatePullFromWhichNode(final MessageQueue mq) {
+ if (this.isConnectBrokerByUser()) {
+ return this.defaultBrokerId;
+ }
+
+ AtomicLong suggest = this.pullFromWhichNodeTable.get(mq);
+ if (suggest != null) {
+ return suggest.get();
+ }
+
+ return MixAll.MASTER_ID;
+ }
+
+ private String computPullFromWhichFilterServer(final String topic, final String brokerAddr)
+ throws MQClientException {
+ ConcurrentHashMap<String, TopicRouteData> topicRouteTable = this.mQClientFactory.getTopicRouteTable();
+ if (topicRouteTable != null) {
+ TopicRouteData topicRouteData = topicRouteTable.get(topic);
+ List<String> list = topicRouteData.getFilterServerTable().get(brokerAddr);
+
+ if (list != null && !list.isEmpty()) {
+ return list.get(randomNum() % list.size());
+ }
+ }
+
+ throw new MQClientException("Find Filter Server Failed, Broker Addr: " + brokerAddr + " topic: "
+ + topic, null);
+ }
+
+ public boolean isConnectBrokerByUser() {
+ return connectBrokerByUser;
+ }
+
+ public int randomNum() {
+ int value = random.nextInt();
+ if (value < 0) {
+ value = Math.abs(value);
+ if (value < 0)
+ value = 0;
+ }
+ return value;
+ }
+
+ public void setConnectBrokerByUser(boolean connectBrokerByUser) {
+ this.connectBrokerByUser = connectBrokerByUser;
+
+ }
+
+ public void registerFilterMessageHook(ArrayList<FilterMessageHook> filterMessageHookList) {
+ this.filterMessageHookList = filterMessageHookList;
+ }
+
+ public long getDefaultBrokerId() {
+ return defaultBrokerId;
+ }
+
+ public void setDefaultBrokerId(long defaultBrokerId) {
+ this.defaultBrokerId = defaultBrokerId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/de6f9416/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
new file mode 100644
index 0000000..9f79543
--- /dev/null
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullMessageService.java
@@ -0,0 +1,109 @@
+/**
+ * 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.impl.consumer;
+
+import org.apache.rocketmq.client.impl.factory.MQClientInstance;
+import org.apache.rocketmq.client.log.ClientLogger;
+import org.apache.rocketmq.common.ServiceThread;
+import org.slf4j.Logger;
+
+import java.util.concurrent.*;
+
+
+/**
+ * @author shijia.wxr
+ */
+public class PullMessageService extends ServiceThread {
+ private final Logger log = ClientLogger.getLog();
+ private final LinkedBlockingQueue<PullRequest> pullRequestQueue = new LinkedBlockingQueue<PullRequest>();
+ private final MQClientInstance mQClientFactory;
+ private final ScheduledExecutorService scheduledExecutorService = Executors
+ .newSingleThreadScheduledExecutor(new ThreadFactory() {
+ @Override
+ public Thread newThread(Runnable r) {
+ return new Thread(r, "PullMessageServiceScheduledThread");
+ }
+ });
+
+ public PullMessageService(MQClientInstance mQClientFactory) {
+ this.mQClientFactory = mQClientFactory;
+ }
+
+ public void executePullRequestLater(final PullRequest pullRequest, final long timeDelay) {
+ this.scheduledExecutorService.schedule(new Runnable() {
+
+ @Override
+ public void run() {
+ PullMessageService.this.executePullRequestImmediately(pullRequest);
+ }
+ }, timeDelay, TimeUnit.MILLISECONDS);
+ }
+
+ public void executePullRequestImmediately(final PullRequest pullRequest) {
+ try {
+ this.pullRequestQueue.put(pullRequest);
+ } catch (InterruptedException e) {
+ log.error("executePullRequestImmediately pullRequestQueue.put", e);
+ }
+ }
+
+ public void executeTaskLater(final Runnable r, final long timeDelay) {
+ this.scheduledExecutorService.schedule(r, timeDelay, TimeUnit.MILLISECONDS);
+ }
+
+ public ScheduledExecutorService getScheduledExecutorService() {
+ return scheduledExecutorService;
+ }
+
+ private void pullMessage(final PullRequest pullRequest) {
+ final MQConsumerInner consumer = this.mQClientFactory.selectConsumer(pullRequest.getConsumerGroup());
+ if (consumer != null) {
+ DefaultMQPushConsumerImpl impl = (DefaultMQPushConsumerImpl) consumer;
+ impl.pullMessage(pullRequest);
+ } else {
+ log.warn("No matched consumer for the PullRequest {}, drop it", pullRequest);
+ }
+ }
+
+
+ @Override
+ public void run() {
+ log.info(this.getServiceName() + " service started");
+
+ while (!this.isStopped()) {
+ try {
+ PullRequest pullRequest = this.pullRequestQueue.take();
+ if (pullRequest != null) {
+ this.pullMessage(pullRequest);
+ }
+ } catch (InterruptedException e) {
+ } catch (Exception e) {
+ log.error("Pull Message Service Run Method exception", e);
+ }
+ }
+
+ log.info(this.getServiceName() + " service end");
+ }
+
+
+ @Override
+ public String getServiceName() {
+ return PullMessageService.class.getSimpleName();
+ }
+
+
+}
[76/99] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Reformat
all codes.
Posted by yu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/simple/RandomAsyncCommit.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/RandomAsyncCommit.java b/example/src/main/java/org/apache/rocketmq/example/simple/RandomAsyncCommit.java
index cda7952..1e13d39 100644
--- a/example/src/main/java/org/apache/rocketmq/example/simple/RandomAsyncCommit.java
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/RandomAsyncCommit.java
@@ -6,28 +6,25 @@
* (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
+ * 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.
+ * 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.example.simple;
-import org.apache.rocketmq.common.message.MessageExt;
-import org.apache.rocketmq.common.message.MessageQueue;
-
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
-
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.common.message.MessageQueue;
public class RandomAsyncCommit {
private final ConcurrentHashMap<MessageQueue, CachedQueue> mqCachedTable =
- new ConcurrentHashMap<MessageQueue, CachedQueue>();
-
+ new ConcurrentHashMap<MessageQueue, CachedQueue>();
public void putMessages(final MessageQueue mq, final List<MessageExt> msgs) {
CachedQueue cachedQueue = this.mqCachedTable.get(mq);
@@ -40,7 +37,6 @@ public class RandomAsyncCommit {
}
}
-
public void removeMessage(final MessageQueue mq, long offset) {
CachedQueue cachedQueue = this.mqCachedTable.get(mq);
if (null != cachedQueue) {
@@ -48,7 +44,6 @@ public class RandomAsyncCommit {
}
}
-
public long commitableOffset(final MessageQueue mq) {
CachedQueue cachedQueue = this.mqCachedTable.get(mq);
if (null != cachedQueue) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/simple/TestProducer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/TestProducer.java b/example/src/main/java/org/apache/rocketmq/example/simple/TestProducer.java
index 0304a63..8787fa8 100644
--- a/example/src/main/java/org/apache/rocketmq/example/simple/TestProducer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/TestProducer.java
@@ -33,14 +33,14 @@ public class TestProducer {
try {
{
Message msg = new Message("TopicTest1",
- "TagA",
- "key113",
- "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
+ "TagA",
+ "key113",
+ "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
SendResult sendResult = producer.send(msg);
System.out.printf("%s%n", sendResult);
QueryResult queryMessage =
- producer.queryMessage("TopicTest1", "key113", 10, 0, System.currentTimeMillis());
+ producer.queryMessage("TopicTest1", "key113", 10, 0, System.currentTimeMillis());
for (MessageExt m : queryMessage.getMessageList()) {
System.out.printf("%s%n", m);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionCheckListenerImpl.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionCheckListenerImpl.java b/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionCheckListenerImpl.java
index fea93a8..1beed71 100644
--- a/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionCheckListenerImpl.java
+++ b/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionCheckListenerImpl.java
@@ -16,17 +16,14 @@
*/
package org.apache.rocketmq.example.transaction;
+import java.util.concurrent.atomic.AtomicInteger;
import org.apache.rocketmq.client.producer.LocalTransactionState;
import org.apache.rocketmq.client.producer.TransactionCheckListener;
import org.apache.rocketmq.common.message.MessageExt;
-import java.util.concurrent.atomic.AtomicInteger;
-
-
public class TransactionCheckListenerImpl implements TransactionCheckListener {
private AtomicInteger transactionIndex = new AtomicInteger(0);
-
@Override
public LocalTransactionState checkLocalTransactionState(MessageExt msg) {
System.out.printf("server checking TrMsg " + msg.toString() + "%n");
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionExecuterImpl.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionExecuterImpl.java b/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionExecuterImpl.java
index eb787fd..b767a4a 100644
--- a/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionExecuterImpl.java
+++ b/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionExecuterImpl.java
@@ -6,26 +6,24 @@
* (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
+ * 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.
+ * 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.example.transaction;
+import java.util.concurrent.atomic.AtomicInteger;
import org.apache.rocketmq.client.producer.LocalTransactionExecuter;
import org.apache.rocketmq.client.producer.LocalTransactionState;
import org.apache.rocketmq.common.message.Message;
-import java.util.concurrent.atomic.AtomicInteger;
-
public class TransactionExecuterImpl implements LocalTransactionExecuter {
private AtomicInteger transactionIndex = new AtomicInteger(1);
-
@Override
public LocalTransactionState executeLocalTransactionBranch(final Message msg, final Object arg) {
int value = transactionIndex.getAndIncrement();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionProducer.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionProducer.java b/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionProducer.java
index 5a868c6..1609a81 100644
--- a/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionProducer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/transaction/TransactionProducer.java
@@ -16,6 +16,7 @@
*/
package org.apache.rocketmq.example.transaction;
+import java.io.UnsupportedEncodingException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.client.producer.TransactionCheckListener;
@@ -23,8 +24,6 @@ import org.apache.rocketmq.client.producer.TransactionMQProducer;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;
-import java.io.UnsupportedEncodingException;
-
public class TransactionProducer {
public static void main(String[] args) throws MQClientException, InterruptedException {
TransactionCheckListener transactionCheckListener = new TransactionCheckListenerImpl();
@@ -35,13 +34,13 @@ public class TransactionProducer {
producer.setTransactionCheckListener(transactionCheckListener);
producer.start();
- String[] tags = new String[]{"TagA", "TagB", "TagC", "TagD", "TagE"};
+ String[] tags = new String[] {"TagA", "TagB", "TagC", "TagD", "TagE"};
TransactionExecuterImpl tranExecuter = new TransactionExecuterImpl();
for (int i = 0; i < 100; i++) {
try {
Message msg =
- new Message("TopicTest", tags[i % tags.length], "KEY" + i,
- ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET));
+ new Message("TopicTest", tags[i % tags.length], "KEY" + i,
+ ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET));
SendResult sendResult = producer.sendMessageInTransaction(msg, tranExecuter, null);
System.out.printf("%s%n", sendResult);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/example/src/main/resources/MessageFilterImpl.java
----------------------------------------------------------------------
diff --git a/example/src/main/resources/MessageFilterImpl.java b/example/src/main/resources/MessageFilterImpl.java
index 3ff3f48..83ca00e 100644
--- a/example/src/main/resources/MessageFilterImpl.java
+++ b/example/src/main/resources/MessageFilterImpl.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.example.filter;
@@ -20,7 +20,6 @@ package org.apache.rocketmq.example.filter;
import org.apache.rocketmq.common.filter.MessageFilter;
import org.apache.rocketmq.common.message.MessageExt;
-
public class MessageFilterImpl implements MessageFilter {
@Override
@@ -29,7 +28,7 @@ public class MessageFilterImpl implements MessageFilter {
if (property != null) {
int id = Integer.parseInt(property);
if (((id % 10) == 0) && //
- (id > 100)) {
+ (id > 100)) {
return true;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/filtersrv/pom.xml
----------------------------------------------------------------------
diff --git a/filtersrv/pom.xml b/filtersrv/pom.xml
index bebd10a..cf5388d 100644
--- a/filtersrv/pom.xml
+++ b/filtersrv/pom.xml
@@ -15,7 +15,7 @@
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.rocketmq</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
index bd16e0d..32b8bad 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FilterServerOuterAPI.java
@@ -30,43 +30,38 @@ import org.apache.rocketmq.remoting.netty.NettyClientConfig;
import org.apache.rocketmq.remoting.netty.NettyRemotingClient;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
-
public class FilterServerOuterAPI {
private final RemotingClient remotingClient;
-
public FilterServerOuterAPI() {
this.remotingClient = new NettyRemotingClient(new NettyClientConfig());
}
-
public void start() {
this.remotingClient.start();
}
-
public void shutdown() {
this.remotingClient.shutdown();
}
-
public RegisterFilterServerResponseHeader registerFilterServerToBroker(
- final String brokerAddr,
- final String filterServerAddr
+ final String brokerAddr,
+ final String filterServerAddr
) throws RemotingCommandException, RemotingConnectException, RemotingSendRequestException,
- RemotingTimeoutException, InterruptedException, MQBrokerException {
+ RemotingTimeoutException, InterruptedException, MQBrokerException {
RegisterFilterServerRequestHeader requestHeader = new RegisterFilterServerRequestHeader();
requestHeader.setFilterServerAddr(filterServerAddr);
RemotingCommand request =
- RemotingCommand.createRequestCommand(RequestCode.REGISTER_FILTER_SERVER, requestHeader);
+ RemotingCommand.createRequestCommand(RequestCode.REGISTER_FILTER_SERVER, requestHeader);
RemotingCommand response = this.remotingClient.invokeSync(brokerAddr, request, 3000);
assert response != null;
switch (response.getCode()) {
case ResponseCode.SUCCESS: {
RegisterFilterServerResponseHeader responseHeader =
- (RegisterFilterServerResponseHeader) response
- .decodeCommandCustomHeader(RegisterFilterServerResponseHeader.class);
+ (RegisterFilterServerResponseHeader)response
+ .decodeCommandCustomHeader(RegisterFilterServerResponseHeader.class);
return responseHeader;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvConfig.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvConfig.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvConfig.java
index ec0381d..ee2ebee 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvConfig.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvConfig.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.filtersrv;
@@ -21,14 +21,13 @@ import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.annotation.ImportantField;
import org.apache.rocketmq.remoting.common.RemotingUtil;
-
public class FiltersrvConfig {
private String rocketmqHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY,
- System.getenv(MixAll.ROCKETMQ_HOME_ENV));
+ System.getenv(MixAll.ROCKETMQ_HOME_ENV));
@ImportantField
private String namesrvAddr = System.getProperty(MixAll.NAMESRV_ADDR_PROPERTY,
- System.getenv(MixAll.NAMESRV_ADDR_ENV));
+ System.getenv(MixAll.NAMESRV_ADDR_ENV));
private String connectWhichBroker = "127.0.0.1:10911";
private String filterServerIP = RemotingUtil.getLocalAddress();
@@ -36,122 +35,98 @@ public class FiltersrvConfig {
private int compressMsgBodyOverHowmuch = 1024 * 8;
private int zipCompressLevel = 5;
-
private boolean clientUploadFilterClassEnable = true;
-
private String filterClassRepertoryUrl = "http://fsrep.tbsite.net/filterclass";
private int fsServerAsyncSemaphoreValue = 2048;
private int fsServerCallbackExecutorThreads = 64;
private int fsServerWorkerThreads = 64;
-
public String getRocketmqHome() {
return rocketmqHome;
}
-
public void setRocketmqHome(String rocketmqHome) {
this.rocketmqHome = rocketmqHome;
}
-
public String getNamesrvAddr() {
return namesrvAddr;
}
-
public void setNamesrvAddr(String namesrvAddr) {
this.namesrvAddr = namesrvAddr;
}
-
public String getConnectWhichBroker() {
return connectWhichBroker;
}
-
public void setConnectWhichBroker(String connectWhichBroker) {
this.connectWhichBroker = connectWhichBroker;
}
-
public String getFilterServerIP() {
return filterServerIP;
}
-
public void setFilterServerIP(String filterServerIP) {
this.filterServerIP = filterServerIP;
}
-
public int getCompressMsgBodyOverHowmuch() {
return compressMsgBodyOverHowmuch;
}
-
public void setCompressMsgBodyOverHowmuch(int compressMsgBodyOverHowmuch) {
this.compressMsgBodyOverHowmuch = compressMsgBodyOverHowmuch;
}
-
public int getZipCompressLevel() {
return zipCompressLevel;
}
-
public void setZipCompressLevel(int zipCompressLevel) {
this.zipCompressLevel = zipCompressLevel;
}
-
public boolean isClientUploadFilterClassEnable() {
return clientUploadFilterClassEnable;
}
-
public void setClientUploadFilterClassEnable(boolean clientUploadFilterClassEnable) {
this.clientUploadFilterClassEnable = clientUploadFilterClassEnable;
}
-
public String getFilterClassRepertoryUrl() {
return filterClassRepertoryUrl;
}
-
public void setFilterClassRepertoryUrl(String filterClassRepertoryUrl) {
this.filterClassRepertoryUrl = filterClassRepertoryUrl;
}
-
public int getFsServerAsyncSemaphoreValue() {
return fsServerAsyncSemaphoreValue;
}
-
public void setFsServerAsyncSemaphoreValue(int fsServerAsyncSemaphoreValue) {
this.fsServerAsyncSemaphoreValue = fsServerAsyncSemaphoreValue;
}
-
public int getFsServerCallbackExecutorThreads() {
return fsServerCallbackExecutorThreads;
}
-
public void setFsServerCallbackExecutorThreads(int fsServerCallbackExecutorThreads) {
this.fsServerCallbackExecutorThreads = fsServerCallbackExecutorThreads;
}
-
public int getFsServerWorkerThreads() {
return fsServerWorkerThreads;
}
-
public void setFsServerWorkerThreads(int fsServerWorkerThreads) {
this.fsServerWorkerThreads = fsServerWorkerThreads;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java
index ca136e0..c46b613 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvController.java
@@ -16,6 +16,10 @@
*/
package org.apache.rocketmq.filtersrv;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
import org.apache.rocketmq.client.consumer.DefaultMQPullConsumer;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.ThreadFactoryImpl;
@@ -31,12 +35,6 @@ import org.apache.rocketmq.remoting.netty.NettyServerConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-
public class FiltersrvController {
private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
@@ -47,10 +45,10 @@ public class FiltersrvController {
private final FilterServerOuterAPI filterServerOuterAPI = new FilterServerOuterAPI();
private final DefaultMQPullConsumer defaultMQPullConsumer = new DefaultMQPullConsumer(
- MixAll.FILTERSRV_CONSUMER_GROUP);
+ MixAll.FILTERSRV_CONSUMER_GROUP);
private final ScheduledExecutorService scheduledExecutorService = Executors
- .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("FSScheduledThread"));
+ .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("FSScheduledThread"));
private final FilterServerStatsManager filterServerStatsManager = new FilterServerStatsManager();
private RemotingServer remotingServer;
@@ -58,29 +56,24 @@ public class FiltersrvController {
private ExecutorService remotingExecutor;
private volatile String brokerName = null;
-
public FiltersrvController(FiltersrvConfig filtersrvConfig, NettyServerConfig nettyServerConfig) {
this.filtersrvConfig = filtersrvConfig;
this.nettyServerConfig = nettyServerConfig;
this.filterClassManager = new FilterClassManager(this);
}
-
public boolean initialize() {
MixAll.printObjectProperties(log, this.filtersrvConfig);
-
this.remotingServer = new NettyRemotingServer(this.nettyServerConfig);
-
this.remotingExecutor =
- Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(),
- new ThreadFactoryImpl("RemotingExecutorThread_"));
+ Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(),
+ new ThreadFactoryImpl("RemotingExecutorThread_"));
this.registerProcessor();
-
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
@@ -90,9 +83,9 @@ public class FiltersrvController {
}, 3, 10, TimeUnit.SECONDS);
this.defaultMQPullConsumer.setBrokerSuspendMaxTimeMillis(this.defaultMQPullConsumer
- .getBrokerSuspendMaxTimeMillis() - 1000);
+ .getBrokerSuspendMaxTimeMillis() - 1000);
this.defaultMQPullConsumer.setConsumerTimeoutMillisWhenSuspend(this.defaultMQPullConsumer
- .getConsumerTimeoutMillisWhenSuspend() - 1000);
+ .getConsumerTimeoutMillisWhenSuspend() - 1000);
this.defaultMQPullConsumer.setNamesrvAddr(this.filtersrvConfig.getNamesrvAddr());
this.defaultMQPullConsumer.setInstanceName(String.valueOf(UtilAll.getPid()));
@@ -102,26 +95,26 @@ public class FiltersrvController {
private void registerProcessor() {
this.remotingServer
- .registerDefaultProcessor(new DefaultRequestProcessor(this), this.remotingExecutor);
+ .registerDefaultProcessor(new DefaultRequestProcessor(this), this.remotingExecutor);
}
public void registerFilterServerToBroker() {
try {
RegisterFilterServerResponseHeader responseHeader =
- this.filterServerOuterAPI.registerFilterServerToBroker(
- this.filtersrvConfig.getConnectWhichBroker(), this.localAddr());
+ this.filterServerOuterAPI.registerFilterServerToBroker(
+ this.filtersrvConfig.getConnectWhichBroker(), this.localAddr());
this.defaultMQPullConsumer.getDefaultMQPullConsumerImpl().getPullAPIWrapper()
- .setDefaultBrokerId(responseHeader.getBrokerId());
+ .setDefaultBrokerId(responseHeader.getBrokerId());
if (null == this.brokerName) {
this.brokerName = responseHeader.getBrokerName();
}
log.info("register filter server<{}> to broker<{}> OK, Return: {} {}",
- this.localAddr(),
- this.filtersrvConfig.getConnectWhichBroker(),
- responseHeader.getBrokerName(),
- responseHeader.getBrokerId());
+ this.localAddr(),
+ this.filtersrvConfig.getConnectWhichBroker(),
+ responseHeader.getBrokerName(),
+ responseHeader.getBrokerId());
} catch (Exception e) {
log.warn("register filter server Exception", e);
@@ -132,7 +125,7 @@ public class FiltersrvController {
public String localAddr() {
return String.format("%s:%d", this.filtersrvConfig.getFilterServerIP(),
- this.remotingServer.localListenPort());
+ this.remotingServer.localListenPort());
}
public void start() throws Exception {
@@ -140,12 +133,11 @@ public class FiltersrvController {
this.remotingServer.start();
this.filterServerOuterAPI.start();
this.defaultMQPullConsumer.getDefaultMQPullConsumerImpl().getPullAPIWrapper()
- .setConnectBrokerByUser(true);
+ .setConnectBrokerByUser(true);
this.filterClassManager.start();
this.filterServerStatsManager.start();
}
-
public void shutdown() {
this.remotingServer.shutdown();
this.remotingExecutor.shutdown();
@@ -156,67 +148,54 @@ public class FiltersrvController {
this.filterServerStatsManager.shutdown();
}
-
public RemotingServer getRemotingServer() {
return remotingServer;
}
-
public void setRemotingServer(RemotingServer remotingServer) {
this.remotingServer = remotingServer;
}
-
public ExecutorService getRemotingExecutor() {
return remotingExecutor;
}
-
public void setRemotingExecutor(ExecutorService remotingExecutor) {
this.remotingExecutor = remotingExecutor;
}
-
public FiltersrvConfig getFiltersrvConfig() {
return filtersrvConfig;
}
-
public NettyServerConfig getNettyServerConfig() {
return nettyServerConfig;
}
-
public ScheduledExecutorService getScheduledExecutorService() {
return scheduledExecutorService;
}
-
public FilterServerOuterAPI getFilterServerOuterAPI() {
return filterServerOuterAPI;
}
-
public FilterClassManager getFilterClassManager() {
return filterClassManager;
}
-
public DefaultMQPullConsumer getDefaultMQPullConsumer() {
return defaultMQPullConsumer;
}
-
public String getBrokerName() {
return brokerName;
}
-
public void setBrokerName(String brokerName) {
this.brokerName = brokerName;
}
-
public FilterServerStatsManager getFilterServerStatsManager() {
return filterServerStatsManager;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
index 461c79c..f239caf 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/FiltersrvStartup.java
@@ -18,6 +18,15 @@ package org.apache.rocketmq.filtersrv;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.PosixParser;
import org.apache.rocketmq.common.MQVersion;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.constant.LoggerName;
@@ -25,20 +34,9 @@ import org.apache.rocketmq.remoting.netty.NettyServerConfig;
import org.apache.rocketmq.remoting.netty.NettySystemConfig;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.apache.rocketmq.srvutil.ServerUtil;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.PosixParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicInteger;
-
-
public class FiltersrvStartup {
public static Logger log;
@@ -65,12 +63,10 @@ public class FiltersrvStartup {
public static FiltersrvController createController(String[] args) {
System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));
-
if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE)) {
NettySystemConfig.socketSndbufSize = 65535;
}
-
if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE)) {
NettySystemConfig.socketRcvbufSize = 1024;
}
@@ -78,8 +74,8 @@ public class FiltersrvStartup {
try {
Options options = ServerUtil.buildCommandlineOptions(new Options());
final CommandLine commandLine =
- ServerUtil.parseCmdLine("mqfiltersrv", args, buildCommandlineOptions(options),
- new PosixParser());
+ ServerUtil.parseCmdLine("mqfiltersrv", args, buildCommandlineOptions(options),
+ new PosixParser());
if (null == commandLine) {
System.exit(-1);
return null;
@@ -108,7 +104,7 @@ public class FiltersrvStartup {
nettyServerConfig.setListenPort(0);
nettyServerConfig.setServerAsyncSemaphoreValue(filtersrvConfig.getFsServerAsyncSemaphoreValue());
nettyServerConfig.setServerCallbackExecutorThreads(filtersrvConfig
- .getFsServerCallbackExecutorThreads());
+ .getFsServerCallbackExecutorThreads());
nettyServerConfig.setServerWorkerThreads(filtersrvConfig.getFsServerWorkerThreads());
if (commandLine.hasOption('p')) {
@@ -120,11 +116,11 @@ public class FiltersrvStartup {
MixAll.properties2Object(ServerUtil.commandLine2Properties(commandLine), filtersrvConfig);
if (null == filtersrvConfig.getRocketmqHome()) {
System.out.printf("Please set the " + MixAll.ROCKETMQ_HOME_ENV
- + " variable in your environment to match the location of the RocketMQ installation%n");
+ + " variable in your environment to match the location of the RocketMQ installation%n");
System.exit(-2);
}
- LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+ LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
@@ -132,7 +128,7 @@ public class FiltersrvStartup {
log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
final FiltersrvController controller =
- new FiltersrvController(filtersrvConfig, nettyServerConfig);
+ new FiltersrvController(filtersrvConfig, nettyServerConfig);
boolean initResult = controller.initialize();
if (!initResult) {
controller.shutdown();
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/DynaCode.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/DynaCode.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/DynaCode.java
index fd95685..11102d0 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/DynaCode.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/DynaCode.java
@@ -6,35 +6,43 @@
* (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
+ * 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.
+ * 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.filtersrv.filter;
+import java.io.BufferedWriter;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.tools.JavaCompiler;
+import javax.tools.ToolProvider;
+import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.common.filter.FilterAPI;
import org.apache.rocketmq.remoting.common.RemotingHelper;
-import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.tools.JavaCompiler;
-import javax.tools.ToolProvider;
-import java.io.*;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.URLDecoder;
-import java.util.*;
-
-
public class DynaCode {
private static final Logger LOGGER = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
@@ -43,46 +51,35 @@ public class DynaCode {
private static final String LINE_SP = System.getProperty("line.separator");
private String sourcePath = System.getProperty("user.home") + FILE_SP + "rocketmq_filter_class" + FILE_SP
- + UtilAll.getPid();
+ + UtilAll.getPid();
private String outPutClassPath = sourcePath;
-
private ClassLoader parentClassLoader;
-
private List<String> codeStrs;
-
private Map<String/* fullClassName */, Class<?>/* class */> loadClass;
-
private String classpath;
-
private String bootclasspath;
-
private String extdirs;
-
private String encoding = "UTF-8";
-
private String target;
-
@SuppressWarnings("unchecked")
public DynaCode(String code) {
this(Thread.currentThread().getContextClassLoader(), Arrays.asList(code));
}
-
public DynaCode(ClassLoader parentClassLoader, List<String> codeStrs) {
this(extractClasspath(parentClassLoader), parentClassLoader, codeStrs);
}
-
public DynaCode(String classpath, ClassLoader parentClassLoader, List<String> codeStrs) {
this.classpath = classpath;
this.parentClassLoader = parentClassLoader;
@@ -90,12 +87,15 @@ public class DynaCode {
this.loadClass = new HashMap<String, Class<?>>(codeStrs.size());
}
+ public DynaCode(List<String> codeStrs) {
+ this(Thread.currentThread().getContextClassLoader(), codeStrs);
+ }
private static String extractClasspath(ClassLoader cl) {
StringBuffer buf = new StringBuffer();
while (cl != null) {
if (cl instanceof URLClassLoader) {
- URL urls[] = ((URLClassLoader) cl).getURLs();
+ URL urls[] = ((URLClassLoader)cl).getURLs();
for (int i = 0; i < urls.length; i++) {
if (buf.length() > 0) {
buf.append(File.pathSeparatorChar);
@@ -115,13 +115,8 @@ public class DynaCode {
return buf.toString();
}
-
- public DynaCode(List<String> codeStrs) {
- this(Thread.currentThread().getContextClassLoader(), codeStrs);
- }
-
public static Class<?> compileAndLoadClass(final String className, final String javaSource)
- throws Exception {
+ throws Exception {
String classSimpleName = FilterAPI.simpleClassName(className);
String javaCode = javaSource;
@@ -138,16 +133,6 @@ public class DynaCode {
return clazz;
}
- public void compileAndLoadClass() throws Exception {
- String[] sourceFiles = this.uploadSrcFile();
- this.compile(sourceFiles);
- this.loadClass(this.loadClass.keySet());
- }
-
- public Map<String, Class<?>> getLoadClass() {
- return loadClass;
- }
-
public static String getQualifiedName(String code) {
StringBuilder sb = new StringBuilder();
String className = getClassName(code);
@@ -162,6 +147,57 @@ public class DynaCode {
return sb.toString();
}
+ public static String getClassName(String code) {
+ String className = StringUtils.substringBefore(code, "{");
+ if (StringUtils.isBlank(className)) {
+ return className;
+ }
+ if (StringUtils.contains(code, " class ")) {
+ className = StringUtils.substringAfter(className, " class ");
+ if (StringUtils.contains(className, " extends ")) {
+ className = StringUtils.substringBefore(className, " extends ").trim();
+ } else if (StringUtils.contains(className, " implements ")) {
+ className = StringUtils.trim(StringUtils.substringBefore(className, " implements "));
+ } else {
+ className = StringUtils.trim(className);
+ }
+ } else if (StringUtils.contains(code, " interface ")) {
+ className = StringUtils.substringAfter(className, " interface ");
+ if (StringUtils.contains(className, " extends ")) {
+ className = StringUtils.substringBefore(className, " extends ").trim();
+ } else {
+ className = StringUtils.trim(className);
+ }
+ } else if (StringUtils.contains(code, " enum ")) {
+ className = StringUtils.trim(StringUtils.substringAfter(className, " enum "));
+ } else {
+ return StringUtils.EMPTY;
+ }
+ return className;
+ }
+
+ public static String getPackageName(String code) {
+ String packageName =
+ StringUtils.substringBefore(StringUtils.substringAfter(code, "package "), ";").trim();
+ return packageName;
+ }
+
+ public static String getFullClassName(String code) {
+ String packageName = getPackageName(code);
+ String className = getClassName(code);
+ return StringUtils.isBlank(packageName) ? className : packageName + "." + className;
+ }
+
+ public void compileAndLoadClass() throws Exception {
+ String[] sourceFiles = this.uploadSrcFile();
+ this.compile(sourceFiles);
+ this.loadClass(this.loadClass.keySet());
+ }
+
+ public Map<String, Class<?>> getLoadClass() {
+ return loadClass;
+ }
+
private String[] uploadSrcFile() throws Exception {
List<String> srcFileAbsolutePaths = new ArrayList<String>(codeStrs.size());
for (String code : codeStrs) {
@@ -201,7 +237,7 @@ public class DynaCode {
srcFile.deleteOnExit();
}
OutputStreamWriter outputStreamWriter =
- new OutputStreamWriter(new FileOutputStream(srcFile), encoding);
+ new OutputStreamWriter(new FileOutputStream(srcFile), encoding);
bufferWriter = new BufferedWriter(outputStreamWriter);
for (String lineCode : code.split(LINE_SP)) {
bufferWriter.write(lineCode);
@@ -225,7 +261,7 @@ public class DynaCode {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
if (compiler == null) {
throw new NullPointerException(
- "ToolProvider.getSystemJavaCompiler() return null,please use JDK replace JRE!");
+ "ToolProvider.getSystemJavaCompiler() return null,please use JDK replace JRE!");
}
int resultCode = compiler.run(null, null, err, args);
if (resultCode != 0) {
@@ -236,8 +272,8 @@ public class DynaCode {
private void loadClass(Set<String> classFullNames) throws ClassNotFoundException, MalformedURLException {
synchronized (loadClass) {
ClassLoader classLoader =
- new URLClassLoader(new URL[]{new File(outPutClassPath).toURI().toURL()},
- parentClassLoader);
+ new URLClassLoader(new URL[] {new File(outPutClassPath).toURI().toURL()},
+ parentClassLoader);
for (String key : classFullNames) {
Class<?> classz = classLoader.loadClass(key);
if (null != classz) {
@@ -250,47 +286,6 @@ public class DynaCode {
}
}
- public static String getClassName(String code) {
- String className = StringUtils.substringBefore(code, "{");
- if (StringUtils.isBlank(className)) {
- return className;
- }
- if (StringUtils.contains(code, " class ")) {
- className = StringUtils.substringAfter(className, " class ");
- if (StringUtils.contains(className, " extends ")) {
- className = StringUtils.substringBefore(className, " extends ").trim();
- } else if (StringUtils.contains(className, " implements ")) {
- className = StringUtils.trim(StringUtils.substringBefore(className, " implements "));
- } else {
- className = StringUtils.trim(className);
- }
- } else if (StringUtils.contains(code, " interface ")) {
- className = StringUtils.substringAfter(className, " interface ");
- if (StringUtils.contains(className, " extends ")) {
- className = StringUtils.substringBefore(className, " extends ").trim();
- } else {
- className = StringUtils.trim(className);
- }
- } else if (StringUtils.contains(code, " enum ")) {
- className = StringUtils.trim(StringUtils.substringAfter(className, " enum "));
- } else {
- return StringUtils.EMPTY;
- }
- return className;
- }
-
- public static String getPackageName(String code) {
- String packageName =
- StringUtils.substringBefore(StringUtils.substringAfter(code, "package "), ";").trim();
- return packageName;
- }
-
- public static String getFullClassName(String code) {
- String packageName = getPackageName(code);
- String className = getClassName(code);
- return StringUtils.isBlank(packageName) ? className : packageName + "." + className;
- }
-
private String[] buildCompileJavacArgs(String srcFiles[]) {
ArrayList<String> args = new ArrayList<String>();
if (StringUtils.isNotBlank(classpath)) {
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassFetchMethod.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassFetchMethod.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassFetchMethod.java
index 36d6b7e..89f1883 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassFetchMethod.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassFetchMethod.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.filtersrv.filter;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassInfo.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassInfo.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassInfo.java
index d278fe3..1cb0e96 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassInfo.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassInfo.java
@@ -6,51 +6,44 @@
* (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
+ * 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.
+ * 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.filtersrv.filter;
import org.apache.rocketmq.common.filter.MessageFilter;
-
public class FilterClassInfo {
private String className;
private int classCRC;
private MessageFilter messageFilter;
-
public int getClassCRC() {
return classCRC;
}
-
public void setClassCRC(int classCRC) {
this.classCRC = classCRC;
}
-
public MessageFilter getMessageFilter() {
return messageFilter;
}
-
public void setMessageFilter(MessageFilter messageFilter) {
this.messageFilter = messageFilter;
}
-
public String getClassName() {
return className;
}
-
public void setClassName(String className) {
this.className = className;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassLoader.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassLoader.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassLoader.java
index 3269852..32f5ac2 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassLoader.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassLoader.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.filtersrv.filter;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassManager.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassManager.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassManager.java
index fab4d7d..66389e0 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassManager.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/FilterClassManager.java
@@ -6,17 +6,23 @@
* (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
+ * 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.
+ * 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.filtersrv.filter;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.ThreadFactoryImpl;
import org.apache.rocketmq.common.UtilAll;
@@ -26,14 +32,6 @@ import org.apache.rocketmq.filtersrv.FiltersrvController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-
public class FilterClassManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
@@ -41,19 +39,21 @@ public class FilterClassManager {
private final FiltersrvController filtersrvController;
private final ScheduledExecutorService scheduledExecutorService = Executors
- .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("FSGetClassScheduledThread"));
+ .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("FSGetClassScheduledThread"));
private ConcurrentHashMap<String/* topic@consumerGroup */, FilterClassInfo> filterClassTable =
- new ConcurrentHashMap<String, FilterClassInfo>(128);
+ new ConcurrentHashMap<String, FilterClassInfo>(128);
private FilterClassFetchMethod filterClassFetchMethod;
-
public FilterClassManager(FiltersrvController filtersrvController) {
this.filtersrvController = filtersrvController;
this.filterClassFetchMethod =
- new HttpFilterClassFetchMethod(this.filtersrvController.getFiltersrvConfig()
- .getFilterClassRepertoryUrl());
+ new HttpFilterClassFetchMethod(this.filtersrvController.getFiltersrvConfig()
+ .getFilterClassRepertoryUrl());
}
+ private static String buildKey(final String consumerGroup, final String topic) {
+ return topic + "@" + consumerGroup;
+ }
public void start() {
if (!this.filtersrvController.getFiltersrvConfig().isClientUploadFilterClassEnable()) {
@@ -75,20 +75,20 @@ public class FilterClassManager {
FilterClassInfo filterClassInfo = next.getValue();
String[] topicAndGroup = next.getKey().split("@");
String responseStr =
- this.filterClassFetchMethod.fetch(topicAndGroup[0], topicAndGroup[1],
- filterClassInfo.getClassName());
+ this.filterClassFetchMethod.fetch(topicAndGroup[0], topicAndGroup[1],
+ filterClassInfo.getClassName());
byte[] filterSourceBinary = responseStr.getBytes("UTF-8");
int classCRC = UtilAll.crc32(responseStr.getBytes("UTF-8"));
if (classCRC != filterClassInfo.getClassCRC()) {
String javaSource = new String(filterSourceBinary, MixAll.DEFAULT_CHARSET);
Class<?> newClass =
- DynaCode.compileAndLoadClass(filterClassInfo.getClassName(), javaSource);
+ DynaCode.compileAndLoadClass(filterClassInfo.getClassName(), javaSource);
Object newInstance = newClass.newInstance();
- filterClassInfo.setMessageFilter((MessageFilter) newInstance);
+ filterClassInfo.setMessageFilter((MessageFilter)newInstance);
filterClassInfo.setClassCRC(classCRC);
log.info("fetch Remote class File OK, {} {}", next.getKey(),
- filterClassInfo.getClassName());
+ filterClassInfo.getClassName());
}
} catch (Exception e) {
log.error("fetchClassFromRemoteHost Exception", e);
@@ -101,10 +101,9 @@ public class FilterClassManager {
}
public boolean registerFilterClass(final String consumerGroup, final String topic,
- final String className, final int classCRC, final byte[] filterSourceBinary) {
+ final String className, final int classCRC, final byte[] filterSourceBinary) {
final String key = buildKey(consumerGroup, topic);
-
boolean registerNew = false;
FilterClassInfo filterClassInfoPrev = this.filterClassTable.get(key);
if (null == filterClassInfoPrev) {
@@ -135,17 +134,17 @@ public class FilterClassManager {
String javaSource = new String(filterSourceBinary, MixAll.DEFAULT_CHARSET);
Class<?> newClass = DynaCode.compileAndLoadClass(className, javaSource);
Object newInstance = newClass.newInstance();
- filterClassInfoNew.setMessageFilter((MessageFilter) newInstance);
+ filterClassInfoNew.setMessageFilter((MessageFilter)newInstance);
filterClassInfoNew.setClassCRC(classCRC);
}
this.filterClassTable.put(key, filterClassInfoNew);
} catch (Throwable e) {
String info =
- String
- .format(
- "FilterServer, registerFilterClass Exception, consumerGroup: %s topic: %s className: %s",
- consumerGroup, topic, className);
+ String
+ .format(
+ "FilterServer, registerFilterClass Exception, consumerGroup: %s topic: %s className: %s",
+ consumerGroup, topic, className);
log.error(info, e);
return false;
}
@@ -155,20 +154,14 @@ public class FilterClassManager {
return true;
}
- private static String buildKey(final String consumerGroup, final String topic) {
- return topic + "@" + consumerGroup;
- }
-
public FilterClassInfo findFilterClass(final String consumerGroup, final String topic) {
return this.filterClassTable.get(buildKey(consumerGroup, topic));
}
-
public FilterClassFetchMethod getFilterClassFetchMethod() {
return filterClassFetchMethod;
}
-
public void setFilterClassFetchMethod(FilterClassFetchMethod filterClassFetchMethod) {
this.filterClassFetchMethod = filterClassFetchMethod;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/HttpFilterClassFetchMethod.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/HttpFilterClassFetchMethod.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/HttpFilterClassFetchMethod.java
index c8b1515..99bfad0 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/HttpFilterClassFetchMethod.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/filter/HttpFilterClassFetchMethod.java
@@ -6,13 +6,13 @@
* (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
+ * 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.
+ * 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.filtersrv.filter;
@@ -23,17 +23,14 @@ import org.apache.rocketmq.common.utils.HttpTinyClient.HttpResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
public class HttpFilterClassFetchMethod implements FilterClassFetchMethod {
private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
private final String url;
-
public HttpFilterClassFetchMethod(String url) {
this.url = url;
}
-
@Override
public String fetch(String topic, String consumerGroup, String className) {
String thisUrl = String.format("%s/%s.java", this.url, className);
@@ -45,7 +42,7 @@ public class HttpFilterClassFetchMethod implements FilterClassFetchMethod {
}
} catch (Exception e) {
log.error(
- String.format("call <%s> exception, Topic: %s Group: %s", thisUrl, topic, consumerGroup), e);
+ String.format("call <%s> exception, Topic: %s Group: %s", thisUrl, topic, consumerGroup), e);
}
return null;
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
index f2c98ae..1d56ac1 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/processor/DefaultRequestProcessor.java
@@ -16,6 +16,13 @@
*/
package org.apache.rocketmq.filtersrv.processor;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelFutureListener;
+import io.netty.channel.ChannelHandlerContext;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.rocketmq.client.consumer.DefaultMQPullConsumer;
import org.apache.rocketmq.client.consumer.PullCallback;
import org.apache.rocketmq.client.consumer.PullResult;
@@ -39,36 +46,25 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
import org.apache.rocketmq.remoting.netty.NettyRequestProcessor;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.apache.rocketmq.store.CommitLog;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelFutureListener;
-import io.netty.channel.ChannelHandlerContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.List;
-
-
public class DefaultRequestProcessor implements NettyRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
private final FiltersrvController filtersrvController;
-
public DefaultRequestProcessor(FiltersrvController filtersrvController) {
this.filtersrvController = filtersrvController;
}
-
@Override
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws Exception {
if (log.isDebugEnabled()) {
log.debug("receive request, {} {} {}",
- request.getCode(),
- RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
- request);
+ request.getCode(),
+ RemotingHelper.parseChannelRemoteAddr(ctx.channel()),
+ request);
}
switch (request.getCode()) {
@@ -89,14 +85,14 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
private RemotingCommand registerMessageFilterClass(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
final RemotingCommand response = RemotingCommand.createResponseCommand(null);
final RegisterMessageFilterClassRequestHeader requestHeader =
- (RegisterMessageFilterClassRequestHeader) request.decodeCommandCustomHeader(RegisterMessageFilterClassRequestHeader.class);
+ (RegisterMessageFilterClassRequestHeader)request.decodeCommandCustomHeader(RegisterMessageFilterClassRequestHeader.class);
try {
boolean ok = this.filtersrvController.getFilterClassManager().registerFilterClass(requestHeader.getConsumerGroup(),
- requestHeader.getTopic(),
- requestHeader.getClassName(),
- requestHeader.getClassCRC(),
- request.getBody());
+ requestHeader.getTopic(),
+ requestHeader.getClassName(),
+ requestHeader.getClassCRC(),
+ request.getBody());
if (!ok) {
throw new Exception("registerFilterClass error");
}
@@ -113,20 +109,19 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
private RemotingCommand pullMessageForward(final ChannelHandlerContext ctx, final RemotingCommand request) throws Exception {
final RemotingCommand response = RemotingCommand.createResponseCommand(PullMessageResponseHeader.class);
- final PullMessageResponseHeader responseHeader = (PullMessageResponseHeader) response.readCustomHeader();
+ final PullMessageResponseHeader responseHeader = (PullMessageResponseHeader)response.readCustomHeader();
final PullMessageRequestHeader requestHeader =
- (PullMessageRequestHeader) request.decodeCommandCustomHeader(PullMessageRequestHeader.class);
+ (PullMessageRequestHeader)request.decodeCommandCustomHeader(PullMessageRequestHeader.class);
final FilterContext filterContext = new FilterContext();
filterContext.setConsumerGroup(requestHeader.getConsumerGroup());
-
response.setOpaque(request.getOpaque());
DefaultMQPullConsumer pullConsumer = this.filtersrvController.getDefaultMQPullConsumer();
final FilterClassInfo findFilterClass =
- this.filtersrvController.getFilterClassManager()
- .findFilterClass(requestHeader.getConsumerGroup(), requestHeader.getTopic());
+ this.filtersrvController.getFilterClassManager()
+ .findFilterClass(requestHeader.getConsumerGroup(), requestHeader.getTopic());
if (null == findFilterClass) {
response.setCode(ResponseCode.SYSTEM_ERROR);
response.setRemark("Find Filter class failed, not registered");
@@ -141,7 +136,6 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
responseHeader.setSuggestWhichBrokerId(MixAll.MASTER_ID);
-
MessageQueue mq = new MessageQueue();
mq.setTopic(requestHeader.getTopic());
mq.setQueueId(requestHeader.getQueueId());
@@ -171,7 +165,6 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
}
}
-
if (!msgListOK.isEmpty()) {
returnResponse(requestHeader.getConsumerGroup(), requestHeader.getTopic(), ctx, response, msgListOK);
return;
@@ -180,8 +173,8 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
}
} catch (Throwable e) {
final String error =
- String.format("do Message Filter Exception, ConsumerGroup: %s Topic: %s ",
- requestHeader.getConsumerGroup(), requestHeader.getTopic());
+ String.format("do Message Filter Exception, ConsumerGroup: %s Topic: %s ",
+ requestHeader.getConsumerGroup(), requestHeader.getTopic());
log.error(error, e);
response.setCode(ResponseCode.SYSTEM_ERROR);
@@ -207,7 +200,6 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
returnResponse(requestHeader.getConsumerGroup(), requestHeader.getTopic(), ctx, response, null);
}
-
@Override
public void onException(Throwable e) {
response.setCode(ResponseCode.SYSTEM_ERROR);
@@ -223,7 +215,7 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
}
private void returnResponse(final String group, final String topic, ChannelHandlerContext ctx, final RemotingCommand response,
- final List<MessageExt> msgList) {
+ final List<MessageExt> msgList) {
if (null != msgList) {
ByteBuffer[] msgBufferList = new ByteBuffer[msgList.size()];
int bodyTotalSize = 0;
@@ -244,7 +236,6 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
response.setBody(body.array());
-
this.filtersrvController.getFilterServerStatsManager().incGroupGetNums(group, topic, msgList.size());
this.filtersrvController.getFilterServerStatsManager().incGroupGetSize(group, topic, bodyTotalSize);
@@ -285,23 +276,23 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
byte[] propertiesData = properties.getBytes(MixAll.DEFAULT_CHARSET);
final int propertiesLength = propertiesData.length;
final int msgLen = 4 // 1 TOTALSIZE
- + 4 // 2 MAGICCODE
- + 4 // 3 BODYCRC
- + 4 // 4 QUEUEID
- + 4 // 5 FLAG
- + 8 // 6 QUEUEOFFSET
- + 8 // 7 PHYSICALOFFSET
- + 4 // 8 SYSFLAG
- + 8 // 9 BORNTIMESTAMP
- + 8 // 10 BORNHOST
- + 8 // 11 STORETIMESTAMP
- + 8 // 12 STOREHOSTADDRESS
- + 4 // 13 RECONSUMETIMES
- + 8 // 14 Prepared Transaction Offset
- + 4 + bodyLength // 14 BODY
- + 1 + topicLength // 15 TOPIC
- + 2 + propertiesLength // 16 propertiesLength
- + 0;
+ + 4 // 2 MAGICCODE
+ + 4 // 3 BODYCRC
+ + 4 // 4 QUEUEID
+ + 4 // 5 FLAG
+ + 8 // 6 QUEUEOFFSET
+ + 8 // 7 PHYSICALOFFSET
+ + 4 // 8 SYSFLAG
+ + 8 // 9 BORNTIMESTAMP
+ + 8 // 10 BORNHOST
+ + 8 // 11 STORETIMESTAMP
+ + 8 // 12 STOREHOSTADDRESS
+ + 4 // 13 RECONSUMETIMES
+ + 8 // 14 Prepared Transaction Offset
+ + 4 + bodyLength // 14 BODY
+ + 1 + topicLength // 15 TOPIC
+ + 2 + propertiesLength // 16 propertiesLength
+ + 0;
ByteBuffer msgStoreItemMemory = ByteBuffer.allocate(msgLen);
@@ -340,10 +331,10 @@ public class DefaultRequestProcessor implements NettyRequestProcessor {
if (bodyLength > 0)
msgStoreItemMemory.put(msgInner.getBody());
// 16 TOPIC
- msgStoreItemMemory.put((byte) topicLength);
+ msgStoreItemMemory.put((byte)topicLength);
msgStoreItemMemory.put(topicData);
// 17 PROPERTIES
- msgStoreItemMemory.putShort((short) propertiesLength);
+ msgStoreItemMemory.putShort((short)propertiesLength);
if (propertiesLength > 0)
msgStoreItemMemory.put(propertiesData);
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/stats/FilterServerStatsManager.java
----------------------------------------------------------------------
diff --git a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/stats/FilterServerStatsManager.java b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/stats/FilterServerStatsManager.java
index 8665fbd..4f44e99 100644
--- a/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/stats/FilterServerStatsManager.java
+++ b/filtersrv/src/main/java/org/apache/rocketmq/filtersrv/stats/FilterServerStatsManager.java
@@ -6,59 +6,52 @@
* (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
+ * 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.
+ * 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.filtersrv.stats;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
import org.apache.rocketmq.common.ThreadFactoryImpl;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.common.stats.StatsItemSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-
-
public class FilterServerStatsManager {
private static final Logger log = LoggerFactory.getLogger(LoggerName.FILTERSRV_LOGGER_NAME);
private final ScheduledExecutorService scheduledExecutorService = Executors
- .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("FSStatsThread"));
+ .newSingleThreadScheduledExecutor(new ThreadFactoryImpl("FSStatsThread"));
// ConsumerGroup Get Nums
private final StatsItemSet groupGetNums = new StatsItemSet("GROUP_GET_NUMS",
- this.scheduledExecutorService, log);
+ this.scheduledExecutorService, log);
// ConsumerGroup Get Size
private final StatsItemSet groupGetSize = new StatsItemSet("GROUP_GET_SIZE",
- this.scheduledExecutorService, log);
-
+ this.scheduledExecutorService, log);
public FilterServerStatsManager() {
}
-
public void start() {
}
-
public void shutdown() {
this.scheduledExecutorService.shutdown();
}
-
public void incGroupGetNums(final String group, final String topic, final int incValue) {
this.groupGetNums.addValue(topic + "@" + group, incValue, 1);
}
-
public void incGroupGetSize(final String group, final String topic, final int incValue) {
this.groupGetSize.addValue(topic + "@" + group, incValue, 1);
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/namesrv/pom.xml
----------------------------------------------------------------------
diff --git a/namesrv/pom.xml b/namesrv/pom.xml
index 2ec2f5f..27a1c84 100644
--- a/namesrv/pom.xml
+++ b/namesrv/pom.xml
@@ -15,7 +15,7 @@
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.rocketmq</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvController.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvController.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvController.java
index 4c286e0..b212adb 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvController.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvController.java
@@ -6,16 +6,20 @@
* (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
+ * 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.
+ * 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.namesrv;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
import org.apache.rocketmq.common.Configuration;
import org.apache.rocketmq.common.ThreadFactoryImpl;
import org.apache.rocketmq.common.constant.LoggerName;
@@ -31,12 +35,6 @@ import org.apache.rocketmq.remoting.netty.NettyServerConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-
public class NamesrvController {
private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
@@ -45,7 +43,7 @@ public class NamesrvController {
private final NettyServerConfig nettyServerConfig;
private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl(
- "NSScheduledThread"));
+ "NSScheduledThread"));
private final KVConfigManager kvConfigManager;
private final RouteInfoManager routeInfoManager;
@@ -57,7 +55,6 @@ public class NamesrvController {
private Configuration configuration;
-
public NamesrvController(NamesrvConfig namesrvConfig, NettyServerConfig nettyServerConfig) {
this.namesrvConfig = namesrvConfig;
this.nettyServerConfig = nettyServerConfig;
@@ -65,26 +62,23 @@ public class NamesrvController {
this.routeInfoManager = new RouteInfoManager();
this.brokerHousekeepingService = new BrokerHousekeepingService(this);
this.configuration = new Configuration(
- log,
- this.namesrvConfig, this.nettyServerConfig
+ log,
+ this.namesrvConfig, this.nettyServerConfig
);
this.configuration.setStorePathFromConfig(this.namesrvConfig, "configStorePath");
}
-
public boolean initialize() {
this.kvConfigManager.load();
this.remotingServer = new NettyRemotingServer(this.nettyServerConfig, this.brokerHousekeepingService);
-
this.remotingExecutor =
- Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(), new ThreadFactoryImpl("RemotingExecutorThread_"));
+ Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(), new ThreadFactoryImpl("RemotingExecutorThread_"));
this.registerProcessor();
-
this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
@@ -104,56 +98,47 @@ public class NamesrvController {
return true;
}
-
private void registerProcessor() {
if (namesrvConfig.isClusterTest()) {
this.remotingServer.registerDefaultProcessor(new ClusterTestRequestProcessor(this, namesrvConfig.getProductEnvName()),
- this.remotingExecutor);
+ this.remotingExecutor);
} else {
this.remotingServer.registerDefaultProcessor(new DefaultRequestProcessor(this), this.remotingExecutor);
}
}
-
public void start() throws Exception {
this.remotingServer.start();
}
-
public void shutdown() {
this.remotingServer.shutdown();
this.remotingExecutor.shutdown();
this.scheduledExecutorService.shutdown();
}
-
public NamesrvConfig getNamesrvConfig() {
return namesrvConfig;
}
-
public NettyServerConfig getNettyServerConfig() {
return nettyServerConfig;
}
-
public KVConfigManager getKvConfigManager() {
return kvConfigManager;
}
-
public RouteInfoManager getRouteInfoManager() {
return routeInfoManager;
}
-
public RemotingServer getRemotingServer() {
return remotingServer;
}
-
public void setRemotingServer(RemotingServer remotingServer) {
this.remotingServer = remotingServer;
}
http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/388ba7a5/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
----------------------------------------------------------------------
diff --git a/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java b/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
index be824cd..0eb9a52 100644
--- a/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
+++ b/namesrv/src/main/java/org/apache/rocketmq/namesrv/NamesrvStartup.java
@@ -18,6 +18,15 @@ package org.apache.rocketmq.namesrv;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.PosixParser;
import org.apache.rocketmq.common.MQVersion;
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.constant.LoggerName;
@@ -26,20 +35,9 @@ import org.apache.rocketmq.remoting.netty.NettyServerConfig;
import org.apache.rocketmq.remoting.netty.NettySystemConfig;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.apache.rocketmq.srvutil.ServerUtil;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.PosixParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicInteger;
-
-
public class NamesrvStartup {
public static Properties properties = null;
public static CommandLine commandLine = null;
@@ -51,12 +49,10 @@ public class NamesrvStartup {
public static NamesrvController main0(String[] args) {
System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));
-
if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE)) {
NettySystemConfig.socketSndbufSize = 4096;
}
-
if (null == System.getProperty(NettySystemConfig.COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE)) {
NettySystemConfig.socketRcvbufSize = 4096;
}
@@ -66,14 +62,13 @@ public class NamesrvStartup {
Options options = ServerUtil.buildCommandlineOptions(new Options());
commandLine =
- ServerUtil.parseCmdLine("mqnamesrv", args, buildCommandlineOptions(options),
- new PosixParser());
+ ServerUtil.parseCmdLine("mqnamesrv", args, buildCommandlineOptions(options),
+ new PosixParser());
if (null == commandLine) {
System.exit(-1);
return null;
}
-
final NamesrvConfig namesrvConfig = new NamesrvConfig();
final NettyServerConfig nettyServerConfig = new NettyServerConfig();
nettyServerConfig.setListenPort(9876);
@@ -93,7 +88,6 @@ public class NamesrvStartup {
}
}
-
if (commandLine.hasOption('p')) {
MixAll.printObjectProperties(null, namesrvConfig);
MixAll.printObjectProperties(null, nettyServerConfig);
@@ -104,22 +98,20 @@ public class NamesrvStartup {
if (null == namesrvConfig.getRocketmqHome()) {
System.out.printf("Please set the " + MixAll.ROCKETMQ_HOME_ENV
- + " variable in your environment to match the location of the RocketMQ installation%n");
+ + " variable in your environment to match the location of the RocketMQ installation%n");
System.exit(-2);
}
- LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+ LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
configurator.doConfigure(namesrvConfig.getRocketmqHome() + "/conf/logback_namesrv.xml");
final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME);
-
MixAll.printObjectProperties(log, namesrvConfig);
MixAll.printObjectProperties(log, nettyServerConfig);
-
final NamesrvController controller = new NamesrvController(namesrvConfig, nettyServerConfig);
// remember all configs to prevent discard
@@ -135,7 +127,6 @@ public class NamesrvStartup {
private volatile boolean hasShutdown = false;
private AtomicInteger shutdownTimes = new AtomicInteger(0);
-
@Override
public void run() {
synchronized (this) {
@@ -151,7 +142,6 @@ public class NamesrvStartup {
}
}, "ShutdownHook"));
-
controller.start();
String tip = "The Name Server boot success. serializeType=" + RemotingCommand.getSerializeTypeConfigInThisServer();