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 02:43:57 UTC

[01/58] [abbrv] [partial] incubator-rocketmq git commit: ROCKETMQ-18 Rename package name from com.alibaba to org.apache

Repository: incubator-rocketmq
Updated Branches:
  refs/heads/ROCKETMQ-18 [created] c8ee3289b


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;
-    }
-}


[50/58] [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);
-            }
-        }
-    }
-}


[15/58] [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



[05/58] [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();
-    }
-}


[46/58] [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);
-            }
-        }
-    }
-}


[29/58] [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";
+    }
+}



[24/58] [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();
+    }
+
+
+}


[33/58] [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();
-    }
-}



[43/58] [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;
+    }
+}


[12/58] [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);
+        }
+    }
+}


[07/58] [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;
+    }
+}


[02/58] [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;
-    }
-}


[47/58] [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;
-    }
-}


[11/58] [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&parameter_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;
+    }
+}


[45/58] [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";
+    }
+
+}


[48/58] [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;
-    }
-}


[51/58] [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/ROCKETMQ-18
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>


[41/58] [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;
+    }
+}


[37/58] [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");
-    }
-}


[32/58] [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;
-    }
-}


[16/58] [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 {
-
-    }
-
-}



[56/58] [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/ROCKETMQ-18
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();



[40/58] [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);
-            }
-        }
-    }
-}


[42/58] [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;
+        }
+    }
+
+}


[20/58] [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/58] [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;
-    }
-}


Re: [54/58] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Use apache email as author.

Posted by Von Gosling <vo...@apache.org>.

Alright, we will remove it in the latest commmits. Thanks justin and willem making account for this :-)

> 在 2016年12月28日,11:16,Justin Mclean <ju...@classsoftware.com> 写道:
> 
> Hi,
> 
>> Can we just remove the @author annotation to avoid this kind of change?
> 
> Apache is not fond of author tags as:
> - A file is usually edited by multiple people over time.
> - Version control will record who checks in what changes when.
> - We would rather people contact the project than committers directly.
> 
> There's certainly no reason to add or change them in existing code.  Given that all the code is now ASF code I think they should be removed, but up to the PPMC to decide / work out a policy on this.
> 
> I can provide some link where this has come up before on other projects if anyone needs.
> 
> Thanks,
> Justin
> 


Re: [54/58] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Use apache email as author.

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

> Can we just remove the @author annotation to avoid this kind of change?

Apache is not fond of author tags as:
- A file is usually edited by multiple people over time.
- Version control will record who checks in what changes when.
- We would rather people contact the project than committers directly.

There's certainly no reason to add or change them in existing code.  Given that all the code is now ASF code I think they should be removed, but up to the PPMC to decide / work out a policy on this.

I can provide some link where this has come up before on other projects if anyone needs.

Thanks,
Justin


Re: [54/58] [abbrv] incubator-rocketmq git commit: ROCKETMQ-18 Use apache email as author.

Posted by Willem Jiang <wi...@gmail.com>.
Can we just remove the @author annotation to avoid this kind of change?


Willem Jiang

Blog: http://willemjiang.blogspot.com (English)
          http://jnn.iteye.com  (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem

On Wed, Dec 28, 2016 at 10:44 AM, <yu...@apache.org> wrote:

> 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;
>
>
>

[54/58] [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;



[03/58] [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;
-    }
-}



[53/58] [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 {
 


[08/58] [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;
+    }
+}



[52/58] [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/ROCKETMQ-18
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();
-    }
-}



[26/58] [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>


[23/58] [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();
+    }
+}



[55/58] [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 {
 



[39/58] [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;
-}



[34/58] [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();
-    }
-
-
-}


[04/58] [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");
+    }
+}



[27/58] [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");
+    }
+}


[49/58] [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);
-}


[44/58] [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;
+        }
+    }
+}



[13/58] [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;
+    }
+}



[38/58] [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;
-}


[25/58] [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;
+    }
+}


[31/58] [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;
-    }
-}


[09/58] [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;
+    }
+}



[19/58] [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
-}


[58/58] [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/ROCKETMQ-18
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);
 }


[35/58] [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;
-    }
-}


[28/58] [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;
+    }
+}


[21/58] [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;
+    }
+}


[30/58] [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();
+}


[57/58] [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/ROCKETMQ-18
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();
 }


[36/58] [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>


[22/58] [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;
+    }
+}


[17/58] [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;
-    }
-}



[10/58] [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;
+    }
+}



[18/58] [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&parameter_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;
-    }
-}
-    


[06/58] [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>