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 2017/09/19 07:23:52 UTC

[8/8] incubator-rocketmq git commit: initialize RocketMQ5

initialize RocketMQ5


Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/commit/0b88e66f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/tree/0b88e66f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/diff/0b88e66f

Branch: refs/heads/rocketmq5
Commit: 0b88e66fa8c8121d35a133e277d9e40093e91b06
Parents: 
Author: yukon <yu...@apache.org>
Authored: Tue Sep 19 15:22:16 2017 +0800
Committer: yukon <yu...@apache.org>
Committed: Tue Sep 19 15:22:16 2017 +0800

----------------------------------------------------------------------
 .gitignore                                      |  10 +
 CONTRIBUTING.md                                 |  15 +
 README.md                                       |  51 ++
 example/pom.xml                                 |  39 ++
 .../rpc/example/model/TradeRequest.java         |  47 ++
 .../rpc/example/model/TradeResponse.java        |  38 ++
 .../rpc/example/model/TradeServiceAPI.java      |  47 ++
 .../rpc/example/model/TradeServiceAPIGen.java   |  60 ++
 .../rpc/example/model/TradeServiceAPIImpl.java  |  68 ++
 .../rocketmq/rpc/example/quickstart/Client.java |  35 +
 .../rocketmq/rpc/example/quickstart/Server.java |  30 +
 pom.xml                                         | 166 +++++
 remoting-core/pom.xml                           | 146 +++++
 remoting-core/remoting-api/pom.xml              |  41 ++
 .../rocketmq/remoting/api/AsyncHandler.java     |  34 +
 .../remoting/api/ConnectionService.java         |  24 +
 .../rocketmq/remoting/api/ObjectLifecycle.java  |  29 +
 .../rocketmq/remoting/api/RemotingClient.java   |  28 +
 .../rocketmq/remoting/api/RemotingEndPoint.java |  23 +
 .../remoting/api/RemotingMarshaller.java        |  27 +
 .../rocketmq/remoting/api/RemotingServer.java   |  32 +
 .../rocketmq/remoting/api/RemotingService.java  |  40 ++
 .../rocketmq/remoting/api/RequestProcessor.java |  25 +
 .../remoting/api/buffer/ByteBufferWrapper.java  |  56 ++
 .../api/channel/ChannelEventListener.java       |  28 +
 .../channel/ChannelHandlerContextWrapper.java   |  21 +
 .../remoting/api/channel/ChunkRegion.java       |  54 ++
 .../remoting/api/channel/RemotingChannel.java   |  78 +++
 .../remoting/api/command/RemotingCommand.java   |  90 +++
 .../api/command/RemotingCommandFactory.java     |  24 +
 .../remoting/api/command/TrafficType.java       |  40 ++
 .../remoting/api/compressable/Compressor.java   |  28 +
 .../api/compressable/CompressorFactory.java     |  28 +
 .../api/exception/NestedRuntimeException.java   |  97 +++
 .../api/exception/RemoteAccessException.java    |  57 ++
 .../api/exception/RemoteCodecException.java     |  33 +
 .../RemoteConnectFailureException.java          |  49 ++
 .../api/exception/RemoteTimeoutException.java   |  70 ++
 .../api/interceptor/ExceptionContext.java       |  76 +++
 .../remoting/api/interceptor/Interceptor.java   |  26 +
 .../api/interceptor/InterceptorGroup.java       |  49 ++
 .../api/interceptor/RequestContext.java         |  65 ++
 .../api/interceptor/ResponseContext.java        |  73 +++
 .../remoting/api/protocol/Protocol.java         |  39 ++
 .../remoting/api/protocol/ProtocolFactory.java  |  30 +
 .../remoting/api/serializable/Serializer.java   |  36 ++
 .../api/serializable/SerializerFactory.java     |  28 +
 .../apache/rocketmq/remoting/common/Pair.java   |  44 ++
 .../remoting/common/TypePresentation.java       |  73 +++
 remoting-core/remoting-impl/pom.xml             |  71 ++
 .../common/ChannelEventListenerGroup.java       |  61 ++
 .../common/RemotingCommandFactoryMeta.java      |  49 ++
 .../remoting/common/ResponseResult.java         | 190 ++++++
 .../common/SemaphoreReleaseOnlyOnce.java        |  40 ++
 .../remoting/common/metrics/ChannelMetrics.java |  27 +
 .../remoting/config/RemotingConfig.java         | 375 +++++++++++
 .../remoting/config/TcpSocketConfig.java        |  98 +++
 .../rocketmq/remoting/external/ThreadUtils.java | 177 +++++
 .../impl/buffer/NettyByteBufferWrapper.java     | 114 ++++
 .../ChannelHandlerContextWrapperImpl.java       |  33 +
 .../remoting/impl/channel/FileRegionImpl.java   |  85 +++
 .../remoting/impl/channel/NettyChannelImpl.java |  94 +++
 .../remoting/impl/command/CodecHelper.java      | 180 ++++++
 .../command/RemotingCommandFactoryImpl.java     |  53 ++
 .../impl/command/RemotingCommandImpl.java       | 210 ++++++
 .../impl/command/RequestIdGenerator.java        |  34 +
 .../remoting/impl/netty/NettyChannelEvent.java  |  55 ++
 .../impl/netty/NettyChannelEventType.java       |  25 +
 .../impl/netty/NettyRemotingAbstract.java       | 641 +++++++++++++++++++
 .../impl/netty/NettyRemotingClient.java         | 499 +++++++++++++++
 .../impl/netty/NettyRemotingServer.java         | 286 +++++++++
 .../impl/netty/RemotingBootstrapFactory.java    |  60 ++
 .../impl/netty/handler/ChannelStatistics.java   |  61 ++
 .../remoting/impl/netty/handler/Decoder.java    | 107 ++++
 .../remoting/impl/netty/handler/Encoder.java    |  89 +++
 .../impl/netty/handler/ExceptionHandler.java    |  37 ++
 .../impl/netty/handler/Http2Handler.java        | 139 ++++
 .../impl/netty/handler/ProtocolSelector.java    |  65 ++
 .../remoting/impl/protocol/Httpv2Protocol.java  |  53 ++
 .../impl/protocol/ProtocolFactoryImpl.java      |  83 +++
 .../impl/protocol/RemotingCoreProtocol.java     |  46 ++
 .../impl/protocol/WebSocketProtocol.java        |  38 ++
 .../compression/CompressorFactoryImpl.java      |  68 ++
 .../protocol/compression/GZipCompressor.java    | 100 +++
 .../protocol/serializer/JsonSerializer.java     |  88 +++
 .../protocol/serializer/Kryo3Serializer.java    |  90 +++
 .../protocol/serializer/MsgPackSerializer.java  |  78 +++
 .../serializer/SerializerFactoryImpl.java       |  69 ++
 .../protocol/serializer/ThreadSafeKryo.java     |  99 +++
 .../rocketmq/remoting/internal/BeanUtils.java   | 210 ++++++
 .../rocketmq/remoting/internal/ByteUtils.java   | 379 +++++++++++
 .../remoting/internal/ExceptionUtils.java       |  80 +++
 .../rocketmq/remoting/internal/JvmUtils.java    |  94 +++
 .../remoting/internal/NetworkUtils.java         |  81 +++
 .../remoting/internal/PropertyUtils.java        |  60 ++
 .../remoting/internal/UIDGenerator.java         |  97 +++
 .../apache/rocketmq/remoting/package-info.java  |  49 ++
 .../impl/netty/handler/DecoderTest.java         | 163 +++++
 .../protocol/serializer/SerializersTest.java    | 263 ++++++++
 .../remoting/internal/BeanUtilsTest.java        | 134 ++++
 .../remoting/internal/ExceptionUtilsTest.java   |  43 ++
 .../remoting/internal/JvmUtilsTest.java         |  32 +
 remoting-core/rpc-api/pom.xml                   |  38 ++
 .../rocketmq/rpc/annotation/MethodType.java     |  35 +
 .../rocketmq/rpc/annotation/RemoteMethod.java   |  53 ++
 .../rocketmq/rpc/annotation/RemoteService.java  |  48 ++
 .../rpc/annotation/VisibleForInternal.java      |  32 +
 .../apache/rocketmq/rpc/api/AdvancedClient.java |  36 ++
 .../apache/rocketmq/rpc/api/AdvancedServer.java |  38 ++
 .../org/apache/rocketmq/rpc/api/Promise.java    | 114 ++++
 .../rocketmq/rpc/api/PromiseListener.java       |  41 ++
 .../apache/rocketmq/rpc/api/SimpleClient.java   |  32 +
 .../apache/rocketmq/rpc/api/SimpleServer.java   |  33 +
 remoting-core/rpc-impl/pom.xml                  |  45 ++
 .../rocketmq/rpc/RpcBootstrapFactory.java       |  36 ++
 .../rpc/impl/client/AdvancedClientImpl.java     |  57 ++
 .../rpc/impl/client/SimpleClientImpl.java       | 132 ++++
 .../rocketmq/rpc/impl/command/ResponseCode.java | 118 ++++
 .../rpc/impl/command/RpcRequestCode.java        |  22 +
 .../rpc/impl/config/RpcCommonConfig.java        |  63 ++
 .../rpc/impl/context/RpcCallerContext.java      |  48 ++
 .../rpc/impl/context/RpcProviderContext.java    |  67 ++
 .../impl/exception/ServiceAuthException.java    |  68 ++
 .../exception/ServiceExceptionHandlerCode.java  |  56 ++
 .../ServiceExceptionHandlerManager.java         | 133 ++++
 .../ServiceExceptionInvokeMessage.java          |  50 ++
 .../impl/exception/ServiceExceptionManager.java |  32 +
 .../impl/exception/ServiceRuntimeException.java |  87 +++
 .../exception/ServiceSignatureException.java    |  47 ++
 .../rpc/impl/metrics/DefaultServiceAPI.java     |  42 ++
 .../rpc/impl/metrics/DefaultServiceAPIImpl.java |  59 ++
 .../rpc/impl/metrics/DownloadFileRequest.java   |  56 ++
 .../rpc/impl/metrics/ExecuteResult.java         |  57 ++
 .../rocketmq/rpc/impl/metrics/MethodStats.java  |  92 +++
 .../rocketmq/rpc/impl/metrics/ServiceStats.java | 125 ++++
 .../rpc/impl/metrics/StackTracesAll.java        |  38 ++
 .../rocketmq/rpc/impl/metrics/StatsAll.java     |  60 ++
 .../rocketmq/rpc/impl/metrics/StatsItem.java    | 442 +++++++++++++
 .../rocketmq/rpc/impl/metrics/StatsItemSet.java | 193 ++++++
 .../rocketmq/rpc/impl/metrics/ThreadStats.java  |  55 ++
 .../rocketmq/rpc/impl/metrics/Threading.java    |  87 +++
 .../rpc/impl/metrics/TimestampRegion.java       |  65 ++
 .../rocketmq/rpc/impl/metrics/UtilAll.java      |  84 +++
 .../rpc/impl/processor/RpcRequestProcessor.java | 213 ++++++
 .../rpc/impl/promise/DefaultPromise.java        | 228 +++++++
 .../rocketmq/rpc/impl/promise/FutureState.java  |  51 ++
 .../rpc/impl/server/AdvancedServerImpl.java     |  57 ++
 .../rpc/impl/server/SimpleServerImpl.java       | 104 +++
 .../rpc/impl/service/RpcConnectionListener.java |  49 ++
 .../rocketmq/rpc/impl/service/RpcEntry.java     |  51 ++
 .../rpc/impl/service/RpcInstanceAbstract.java   |  88 +++
 .../rocketmq/rpc/impl/service/RpcJdkProxy.java  |  54 ++
 .../rpc/impl/service/RpcJdkProxyClient.java     |  50 ++
 .../rpc/impl/service/RpcJdkProxyServer.java     |  51 ++
 .../rpc/impl/service/RpcProxyCommon.java        | 329 ++++++++++
 .../rpc/impl/service/RpcProxyFactory.java       |  41 ++
 .../rpc/impl/service/RpcServiceCallBody.java    |  81 +++
 .../rpc/internal/ExceptionMessageUtil.java      |  24 +
 .../rocketmq/rpc/internal/HttpTinyClient.java   | 130 ++++
 .../rocketmq/rpc/internal/IOTinyUtils.java      | 157 +++++
 .../rocketmq/rpc/internal/RpcErrorMapper.java   |  67 ++
 .../rocketmq/rpc/internal/ServiceUtil.java      | 218 +++++++
 style/checkstyle.xml                            | 140 ++++
 style/codeStyle.xml                             | 143 +++++
 style/copyright/Apache.xml                      |  24 +
 style/copyright/profiles_settings.xml           |  64 ++
 166 files changed, 14229 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f12ac58
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,10 @@
+# Created by .ignore support plugin (hsz.mobi)
+.classpath
+.project
+.settings/
+target/
+*.log*
+*.iml
+.idea/
+*.versionsBackup
+*.DS_Store

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/CONTRIBUTING.md
----------------------------------------------------------------------
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..3a0a87f
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,15 @@
+## How To Contribute
+
+We are always very happy to have contributions, whether for trivial cleanups or big new features. We want to have high quality, well documented codes for each programming language. Nor is code the only way to contribute to the project. We strongly value documentation and gladly accept improvements to the documentation.
+Contributing code
+
+To submit a change for inclusion, please do the following:
+If the change is non-trivial please include some unit tests that cover the new functionality.
+
+If you are introducing a completely new feature or API it is a good idea to start a wiki and get consensus on the basic design first.
+
+It is our job to follow up on patches in a timely fashion. Nag us if we aren't doing our job (sometimes we drop things).
+
+## Becoming a Committer
+
+We are always interested in adding new contributors. What we look for are series of contributions, good taste and ongoing interest in the project. If you are interested in becoming a committer, please let one of the existing committers know and they can help you walk through the process.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..d356b6b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,51 @@
+## Angelia
+Angelia provides a single API for most network related service that uses pluggable transports and codecs. The Angelia API provides the ability for making synchronous, asynchronous, oneway remote calls, push and pull callbacks. The intention is to allow for the use of different transports to fit different needs, yet still maintain the same API for making the remote invocations and only requiring configuration changes, not code changes.
+
+Angelia is a standalone project, separate from the Alibaba RocketMQ and Jukola project, but will be the framework used for many of the projects and components when making remote calls. Angelia is included in the recent releases of the Alibaba Jukola and can be run as a service within the container as well.
+
+### Features
+The features available with Angelia are:
+
+#### 1. Pluggable transports – can use different protocol transports the same remoting API.
+Provided transports:
+
+##### **MVP, a custom-build Minimum Viable Protocol**
+##### **HTTP2**
+     
+#### 2. Pluggable codecs – can use different codecs to convert the invocation payloads into desired data format for wire transfer.
+
+#### 3. Pluggable serialization - can use different serialization implementations for data streams.
+
+Provided serialization implementations:
+
+##### **MessagePack**
+##### **Kryo**
+##### **Fastjson**
+
+#### 4. Data Compression - can use compression codec for compresssion of large payloads.
+
+All the features within Angelia were created with ease of use and extensibility in mind. If you have a suggestion for a new feature or an improvement to a current feature, please let me know.
+
+
+
+
+
+
+
+
+## Documentation
+### [Quick Start]()
+### [User Guide]()
+### [Developer Guide]()
+### [Release Note]()
+
+
+
+----------
+
+## Contributing
+We are always very happy to have contributions, whether for trivial cleanups,big new features or other material rewards. more details see [here](CONTRIBUTING.md) 
+ 
+----------
+## License
+[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) Copyright (C) 2010-2016 Alibaba Group Holding Limited
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/example/pom.xml
----------------------------------------------------------------------
diff --git a/example/pom.xml b/example/pom.xml
new file mode 100644
index 0000000..0bf832e
--- /dev/null
+++ b/example/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>org.apache.rocketmq</groupId>
+        <artifactId>rpc-all</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>example</artifactId>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.rocketmq</groupId>
+            <artifactId>rpc-impl</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeRequest.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeRequest.java b/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeRequest.java
new file mode 100644
index 0000000..f84afcd
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeRequest.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.rpc.example.model;
+
+import org.msgpack.annotation.Message;
+
+@Message
+public class TradeRequest {
+    private long orderId;
+    private String orderDesc;
+
+    public long getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(long orderId) {
+        this.orderId = orderId;
+    }
+
+    public String getOrderDesc() {
+        return orderDesc;
+    }
+
+    public void setOrderDesc(String orderDesc) {
+        this.orderDesc = orderDesc;
+    }
+
+    @Override
+    public String toString() {
+        return "TradeRequest [orderId=" + orderId + ", orderDesc=" + orderDesc + "]";
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeResponse.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeResponse.java b/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeResponse.java
new file mode 100644
index 0000000..1c9358c
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeResponse.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.rpc.example.model;
+
+import org.msgpack.annotation.Message;
+
+@Message
+public class TradeResponse {
+    private long storeTimestamp;
+
+    public long getStoreTimestamp() {
+        return storeTimestamp;
+    }
+
+    public void setStoreTimestamp(long storeTimestamp) {
+        this.storeTimestamp = storeTimestamp;
+    }
+
+    @Override
+    public String toString() {
+        return "TradeResponse [storeTimestamp=" + storeTimestamp + "]";
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeServiceAPI.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeServiceAPI.java b/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeServiceAPI.java
new file mode 100644
index 0000000..6014558
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeServiceAPI.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.rpc.example.model;
+
+import java.util.ArrayList;
+import org.apache.rocketmq.rpc.annotation.RemoteMethod;
+import org.apache.rocketmq.rpc.annotation.RemoteService;
+
+@RemoteService(name = "TradeServiceAPI")
+public interface TradeServiceAPI {
+    @RemoteMethod(name = "commitOrder")
+    TradeResponse commitOrder(TradeRequest request) throws InterruptedException;
+
+    @RemoteMethod(name = "deleteOrder")
+    void deleteOrder(TradeRequest request) throws InterruptedException;
+
+    @RemoteMethod(name = "throwUserException")
+    void throwUserException(TradeRequest request) throws Exception;
+
+    @RemoteMethod(name = "throwRuntimeException")
+    void throwRuntimeException(TradeRequest request);
+
+    @RemoteMethod(name = "getOrderList")
+    ArrayList<TradeResponse> getOrderList(TradeRequest request, int count);
+
+    @RemoteMethod(name = "getOrderListSize")
+    int getOrderListSize(ArrayList<TradeRequest> request, String obj);
+
+    @RemoteMethod(name = "setOrder")
+    String setOrder();
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeServiceAPIGen.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeServiceAPIGen.java b/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeServiceAPIGen.java
new file mode 100644
index 0000000..b7aa788
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeServiceAPIGen.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.rpc.example.model;
+
+import java.util.ArrayList;
+import org.apache.rocketmq.rpc.annotation.MethodType;
+import org.apache.rocketmq.rpc.annotation.RemoteMethod;
+import org.apache.rocketmq.rpc.annotation.RemoteService;
+import org.apache.rocketmq.rpc.api.Promise;
+
+@RemoteService(name = "TradeServiceAPI")
+public interface TradeServiceAPIGen extends TradeServiceAPI {
+    @RemoteMethod(name = "commitOrder", type = MethodType.ASYNC)
+    Promise<TradeResponse> commitOrderAsync(TradeRequest request);
+
+    @RemoteMethod(name = "commitOrder", type = MethodType.ONEWAY)
+    void commitOrderOneway(final TradeRequest request);
+
+    @RemoteMethod(name = "deleteOrder", type = MethodType.ASYNC)
+    Promise<TradeResponse> deleteOrderAsync(TradeRequest request);
+
+    @RemoteMethod(name = "deleteOrder", type = MethodType.ONEWAY)
+    void deleteOrderOneway(TradeRequest request);
+
+    @RemoteMethod(name = "throwUserException", type = MethodType.ASYNC)
+    void throwUserExceptionAsync(TradeRequest request);
+
+    @RemoteMethod(name = "throwUserException", type = MethodType.ONEWAY)
+    void throwUserExceptionOneway(TradeRequest request);
+
+    @RemoteMethod(name = "throwRuntimeException", type = MethodType.ASYNC)
+    void throwRuntimeExceptionAsync(TradeRequest request);
+
+    @RemoteMethod(name = "throwRuntimeException", type = MethodType.ONEWAY)
+    void throwRuntimeExceptionOneway(TradeRequest request);
+
+    @RemoteMethod(name = "getOrderList", type = MethodType.ASYNC)
+    Promise<ArrayList<TradeResponse>> getOrderListAsync(TradeRequest request, int count);
+
+    @RemoteMethod(name = "getOrderListSize", type = MethodType.ASYNC)
+    Promise<Integer> getOrderListSizeAsync(ArrayList<TradeRequest> request, String obj);
+
+    @RemoteMethod(name = "setOrder", type = MethodType.ASYNC)
+    Promise<String> setOrderAsync();
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeServiceAPIImpl.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeServiceAPIImpl.java b/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeServiceAPIImpl.java
new file mode 100644
index 0000000..cd196f4
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/rpc/example/model/TradeServiceAPIImpl.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.rpc.example.model;
+
+import java.util.ArrayList;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class TradeServiceAPIImpl implements TradeServiceAPI {
+
+    private final AtomicLong count = new AtomicLong();
+
+    public TradeServiceAPIImpl() {
+        super();
+
+    }
+
+    @Override
+    public TradeResponse commitOrder(TradeRequest request) throws InterruptedException {
+        TradeResponse response = new TradeResponse();
+        response.setStoreTimestamp(System.currentTimeMillis());
+        return response;
+    }
+
+    @Override
+    public void deleteOrder(TradeRequest request) throws InterruptedException {
+        System.out.println("deleteOrder: " + request);
+    }
+
+    @Override
+    public void throwUserException(TradeRequest request) throws Exception {
+        throw new Exception("User Exception detail message");
+    }
+
+    @Override
+    public void throwRuntimeException(TradeRequest request) {
+        throw new RuntimeException("runtime");
+    }
+
+    @Override
+    public ArrayList<TradeResponse> getOrderList(final TradeRequest request, final int count) {
+        return null;
+    }
+
+    @Override
+    public int getOrderListSize(final ArrayList<TradeRequest> request, final String obj) {
+        return 0;
+    }
+
+    @Override
+    public String setOrder() {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/example/src/main/java/org/apache/rocketmq/rpc/example/quickstart/Client.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/rpc/example/quickstart/Client.java b/example/src/main/java/org/apache/rocketmq/rpc/example/quickstart/Client.java
new file mode 100644
index 0000000..a8c0745
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/rpc/example/quickstart/Client.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.rpc.example.quickstart;
+
+import java.util.Properties;
+import org.apache.rocketmq.rpc.RpcBootstrapFactory;
+import org.apache.rocketmq.rpc.api.SimpleClient;
+import org.apache.rocketmq.rpc.example.model.TradeRequest;
+import org.apache.rocketmq.rpc.example.model.TradeResponse;
+import org.apache.rocketmq.rpc.example.model.TradeServiceAPI;
+
+public class Client {
+    public static void main(String[] args) throws InterruptedException {
+        SimpleClient client = RpcBootstrapFactory.createClientBootstrap(new Properties());
+        TradeServiceAPI tradeService = client.bind(TradeServiceAPI.class, "127.0.0.1:8888", new Properties());
+        client.start();
+
+        TradeResponse tradeResponse = tradeService.commitOrder(new TradeRequest());
+        System.out.println(tradeResponse);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/example/src/main/java/org/apache/rocketmq/rpc/example/quickstart/Server.java
----------------------------------------------------------------------
diff --git a/example/src/main/java/org/apache/rocketmq/rpc/example/quickstart/Server.java b/example/src/main/java/org/apache/rocketmq/rpc/example/quickstart/Server.java
new file mode 100644
index 0000000..3a1aad2
--- /dev/null
+++ b/example/src/main/java/org/apache/rocketmq/rpc/example/quickstart/Server.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.rpc.example.quickstart;
+
+import java.util.Properties;
+import org.apache.rocketmq.rpc.RpcBootstrapFactory;
+import org.apache.rocketmq.rpc.api.SimpleServer;
+import org.apache.rocketmq.rpc.example.model.TradeServiceAPIImpl;
+
+public class Server {
+    public static void main(String[] args) {
+        SimpleServer server = RpcBootstrapFactory.createServerBootstrap(new Properties());
+        server.publish(new TradeServiceAPIImpl());
+        server.start();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..9a24623
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <inceptionYear>2012</inceptionYear>
+    <groupId>org.apache.rocketmq</groupId>
+    <artifactId>rpc-all</artifactId>
+    <version>2.0.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>remoting-core</module>
+        <module>example</module>
+    </modules>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.test.skip>false</maven.test.skip>
+        <maven.javadoc.skip>true</maven.javadoc.skip>
+        <!-- compiler settings properties -->
+        <maven.compiler.source>1.7</maven.compiler.source>
+        <maven.compiler.target>1.7</maven.compiler.target>
+        <metrics.version>3.1.2</metrics.version>
+    </properties>
+
+    <build>
+
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>versions-maven-plugin</artifactId>
+                <version>2.2</version>
+            </plugin>
+            <plugin>
+                <artifactId>maven-enforcer-plugin</artifactId>
+                <version>1.4.1</version>
+                <executions>
+                    <execution>
+                        <id>enforce-ban-circular-dependencies</id>
+                        <goals>
+                            <goal>enforce</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <rules>
+                        <banCircularDependencies/>
+                    </rules>
+                    <fail>true</fail>
+                </configuration>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>extra-enforcer-rules</artifactId>
+                        <version>1.0-beta-4</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.5.1</version>
+                <configuration>
+                    <source>${maven.compiler.source}</source>
+                    <target>${maven.compiler.target}</target>
+                    <compilerVersion>${maven.compiler.source}</compilerVersion>
+                    <showDeprecation>true</showDeprecation>
+                    <showWarnings>true</showWarnings>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <version>2.10.4</version>
+                <executions>
+                    <execution>
+                        <id>attach-javadocs</id>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-source-plugin</artifactId>
+                <version>3.0.1</version>
+                <executions>
+                    <execution>
+                        <id>attach-sources</id>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <version>2.17</version>
+                <executions>
+                    <execution>
+                        <id>verify</id>
+                        <phase>verify</phase>
+                        <configuration>
+                            <configLocation>style/checkstyle.xml</configLocation>
+                            <encoding>${project.build.sourceEncoding}</encoding>
+                            <consoleOutput>true</consoleOutput>
+                            <failsOnError>true</failsOnError>
+                        </configuration>
+                        <goals>
+                            <goal>check</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+                </configuration>
+            </plugin>
+        </plugins>
+
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.codehaus.mojo</groupId>
+                    <artifactId>clirr-maven-plugin</artifactId>
+                    <version>2.7</version>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>false</filtering>
+            </resource>
+        </resources>
+    </build>
+
+    <distributionManagement>
+        <repository>
+            <id>releases</id>
+            <url>http://mvnrepo.alibaba-inc.com/mvn/releases</url>
+        </repository>
+        <snapshotRepository>
+            <id>snapshots</id>
+            <url>http://mvnrepo.alibaba-inc.com/mvn/snapshots</url>
+        </snapshotRepository>
+    </distributionManagement>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/pom.xml
----------------------------------------------------------------------
diff --git a/remoting-core/pom.xml b/remoting-core/pom.xml
new file mode 100644
index 0000000..702b826
--- /dev/null
+++ b/remoting-core/pom.xml
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>org.apache.rocketmq</groupId>
+        <artifactId>rpc-all</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>remoting-core</artifactId>
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>remoting-api</module>
+        <module>remoting-impl</module>
+        <module>rpc-api</module>
+        <module>rpc-impl</module>
+    </modules>
+
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.11</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+            <version>2.6.0</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <version>2.6.3</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.slf4j</groupId>
+                <artifactId>slf4j-api</artifactId>
+                <version>1.7.6</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.commons</groupId>
+                <artifactId>commons-lang3</artifactId>
+                <version>3.4</version>
+            </dependency>
+            <dependency>
+                <groupId>org.jetbrains</groupId>
+                <artifactId>annotations</artifactId>
+                <version>15.0</version>
+            </dependency>
+            <dependency>
+                <groupId>io.netty</groupId>
+                <artifactId>netty-all</artifactId>
+                <version>4.1.6.Final</version>
+            </dependency>
+            <dependency>
+                <groupId>com.alibaba</groupId>
+                <artifactId>fastjson</artifactId>
+                <version>1.2.29</version>
+            </dependency>
+            <dependency>
+                <groupId>org.msgpack</groupId>
+                <artifactId>msgpack</artifactId>
+                <version>0.6.12</version>
+            </dependency>
+            <dependency>
+                <groupId>com.esotericsoftware</groupId>
+                <artifactId>kryo</artifactId>
+                <version>3.0.3</version>
+            </dependency>
+            <dependency>
+                <groupId>org.javassist</groupId>
+                <artifactId>javassist</artifactId>
+                <version>3.20.0-GA</version>
+            </dependency>
+            <!-- http://netty.io/wiki/requirements-for-4.x.html#wiki-h3-8 -->
+            <dependency>
+                <groupId>io.netty</groupId>
+                <artifactId>netty-tcnative-boringssl-static</artifactId>
+                <version>1.1.33.Fork22</version>
+            </dependency>
+            <dependency>
+                <groupId>io.dropwizard.metrics</groupId>
+                <artifactId>metrics-core</artifactId>
+                <version>${metrics.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>io.dropwizard.metrics</groupId>
+                <artifactId>metrics-healthchecks</artifactId>
+                <version>${metrics.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>com.google.guava</groupId>
+                <artifactId>guava</artifactId>
+                <version>19.0</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.rocketmq</groupId>
+                <artifactId>remoting-api</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.rocketmq</groupId>
+                <artifactId>rpc-api</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.rocketmq</groupId>
+                <artifactId>remoting-impl</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.rocketmq</groupId>
+                <artifactId>rpc-impl</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/pom.xml
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/pom.xml b/remoting-core/remoting-api/pom.xml
new file mode 100644
index 0000000..c0b87da
--- /dev/null
+++ b/remoting-core/remoting-api/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>org.apache.rocketmq</groupId>
+        <artifactId>remoting-core</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>remoting-api</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.jetbrains</groupId>
+            <artifactId>annotations</artifactId>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/AsyncHandler.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/AsyncHandler.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/AsyncHandler.java
new file mode 100644
index 0000000..106431b
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/AsyncHandler.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.remoting.api;
+
+import org.apache.rocketmq.remoting.api.command.RemotingCommand;
+
+/**
+ * The AsyncHandler interface is implemented when wishing to receive callback notification of the completion of
+ * service invoked asynchronously.
+ *
+ * @since 1.0.0
+ */
+public interface AsyncHandler {
+    void onFailure(RemotingCommand command);
+
+    void onSuccess(RemotingCommand command);
+
+    void onTimeout(long costTimeMillis, long timeoutMillis);
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/ConnectionService.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/ConnectionService.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/ConnectionService.java
new file mode 100644
index 0000000..c42498f
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/ConnectionService.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.remoting.api;
+
+import org.apache.rocketmq.remoting.api.channel.ChannelEventListener;
+
+public interface ConnectionService {
+    void registerChannelEventListener(ChannelEventListener listener);
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/ObjectLifecycle.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/ObjectLifecycle.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/ObjectLifecycle.java
new file mode 100644
index 0000000..c4a75c8
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/ObjectLifecycle.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.remoting.api;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+public interface ObjectLifecycle {
+    @PostConstruct
+    void start();
+
+    @PreDestroy
+    void stop();
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingClient.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingClient.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingClient.java
new file mode 100644
index 0000000..1603af4
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingClient.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.remoting.api;
+
+import org.apache.rocketmq.remoting.api.command.RemotingCommand;
+
+public interface RemotingClient extends RemotingService {
+    RemotingCommand invoke(String address, RemotingCommand request, long timeoutMillis);
+
+    void invokeAsync(String address, RemotingCommand request, AsyncHandler asyncHandler, long timeoutMillis);
+
+    void invokeOneWay(String address, RemotingCommand request, long timeoutMillis);
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingEndPoint.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingEndPoint.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingEndPoint.java
new file mode 100644
index 0000000..2bc3edf
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingEndPoint.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF 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.api;
+
+public enum RemotingEndPoint {
+    REQUEST,
+    RESPONSE
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingMarshaller.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingMarshaller.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingMarshaller.java
new file mode 100644
index 0000000..0386a03
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingMarshaller.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.remoting.api;
+
+import org.apache.rocketmq.remoting.api.protocol.ProtocolFactory;
+import org.apache.rocketmq.remoting.api.serializable.SerializerFactory;
+
+public interface RemotingMarshaller {
+    ProtocolFactory protocolFactory();
+
+    SerializerFactory serializerFactory();
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingServer.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingServer.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingServer.java
new file mode 100644
index 0000000..f36c83c
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingServer.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.remoting.api;
+
+import org.apache.rocketmq.remoting.api.channel.RemotingChannel;
+import org.apache.rocketmq.remoting.api.command.RemotingCommand;
+
+public interface RemotingServer extends RemotingService {
+    int localListenPort();
+
+    RemotingCommand invoke(RemotingChannel remotingChannel, RemotingCommand request, long timeoutMillis);
+
+    void invokeAsync(RemotingChannel remotingChannel, RemotingCommand request, AsyncHandler asyncHandler,
+        long timeoutMillis);
+
+    void invokeOneWay(RemotingChannel remotingChannel, RemotingCommand request, long timeoutMillis);
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingService.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingService.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingService.java
new file mode 100644
index 0000000..2f6343c
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingService.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.remoting.api;
+
+import java.util.concurrent.ExecutorService;
+import org.apache.rocketmq.remoting.api.command.RemotingCommandFactory;
+import org.apache.rocketmq.remoting.api.interceptor.Interceptor;
+import org.apache.rocketmq.remoting.common.Pair;
+
+public interface RemotingService extends RemotingMarshaller, ConnectionService, ObjectLifecycle {
+    void registerInterceptor(Interceptor interceptor);
+
+    void registerRequestProcessor(final String requestCode, final RequestProcessor processor,
+        final ExecutorService executor);
+
+    void registerRequestProcessor(final String requestCode, final RequestProcessor processor);
+
+    void unregisterRequestProcessor(final String requestCode);
+
+    Pair<RequestProcessor, ExecutorService> processor(final String requestCode);
+
+    String remotingInstanceId();
+
+    RemotingCommandFactory commandFactory();
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RequestProcessor.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RequestProcessor.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RequestProcessor.java
new file mode 100644
index 0000000..cd201c2
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RequestProcessor.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.remoting.api;
+
+import org.apache.rocketmq.remoting.api.channel.RemotingChannel;
+import org.apache.rocketmq.remoting.api.command.RemotingCommand;
+
+public interface RequestProcessor {
+    RemotingCommand processRequest(RemotingChannel channel, RemotingCommand request);
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/buffer/ByteBufferWrapper.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/buffer/ByteBufferWrapper.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/buffer/ByteBufferWrapper.java
new file mode 100644
index 0000000..7cae3ac
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/buffer/ByteBufferWrapper.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.remoting.api.buffer;
+
+import java.nio.ByteBuffer;
+
+public interface ByteBufferWrapper {
+    void writeByte(int index, byte data);
+
+    void writeByte(byte data);
+
+    byte readByte();
+
+    void writeInt(int data);
+
+    void writeBytes(byte[] data);
+
+    void writeBytes(ByteBuffer data);
+
+    int readableBytes();
+
+    int readInt();
+
+    void readBytes(byte[] dst);
+
+    void readBytes(ByteBuffer dst);
+
+    int readerIndex();
+
+    void setReaderIndex(int readerIndex);
+
+    void writeLong(long id);
+
+    long readLong();
+
+    void ensureCapacity(int capacity);
+
+    short readShort();
+
+    void writeShort(short value);
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/channel/ChannelEventListener.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/channel/ChannelEventListener.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/channel/ChannelEventListener.java
new file mode 100644
index 0000000..0c0afcf
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/channel/ChannelEventListener.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.remoting.api.channel;
+
+public interface ChannelEventListener {
+    void onChannelConnect(final RemotingChannel channel);
+
+    void onChannelClose(final RemotingChannel channel);
+
+    void onChannelException(final RemotingChannel channel);
+
+    void onChannelIdle(final RemotingChannel channel);
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/channel/ChannelHandlerContextWrapper.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/channel/ChannelHandlerContextWrapper.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/channel/ChannelHandlerContextWrapper.java
new file mode 100644
index 0000000..05c3b18
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/channel/ChannelHandlerContextWrapper.java
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF 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.api.channel;
+
+public interface ChannelHandlerContextWrapper<T> {
+    T getContext();
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/channel/ChunkRegion.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/channel/ChunkRegion.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/channel/ChunkRegion.java
new file mode 100644
index 0000000..8266ff0
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/channel/ChunkRegion.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.remoting.api.channel;
+
+import java.io.IOException;
+import java.nio.channels.WritableByteChannel;
+
+public interface ChunkRegion {
+    void release();
+
+    /**
+     * @return Returns the offset in the file where the transfer began.
+     */
+    long position();
+
+    /**
+     * @return Return the bytes which was transferred already
+     */
+    long transferred();
+
+    /**
+     * @return Returns the number of bytes to transfer.
+     */
+    long count();
+
+    /**
+     * Transfers the content of this file region to the specified channel.
+     *
+     * @param target the destination of the transfer
+     * @param position the relative offset of the file where the transfer begins
+     * from. For example, <tt>0</tt> will make the transfer start
+     * from {@link #position()}th byte and
+     * <tt>{@link #count()} - 1</tt> will make the last byte of the
+     * region transferred.
+     * @return the length of the transferred file region
+     * @throws IOException IOException
+     */
+    long transferTo(WritableByteChannel target, long position) throws IOException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/channel/RemotingChannel.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/channel/RemotingChannel.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/channel/RemotingChannel.java
new file mode 100644
index 0000000..28cfc53
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/channel/RemotingChannel.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.remoting.api.channel;
+
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import org.apache.rocketmq.remoting.api.command.RemotingCommand;
+
+public interface RemotingChannel {
+    /**
+     * Returns the local address where this {@code RemotingChannel} is bound to.  The returned
+     * {@link SocketAddress} is supposed to be down-cast into more concrete
+     * type such as {@link InetSocketAddress} to retrieve the detailed
+     * information.
+     *
+     * @return the local address of this channel.
+     * {@code null} if this channel is not bound.
+     */
+    SocketAddress localAddress();
+
+    /**
+     * Returns the remote address where this {@code RemotingChannel} is connected to.  The
+     * returned {@link SocketAddress} is supposed to be down-cast into more
+     * concrete type such as {@link InetSocketAddress} to retrieve the detailed
+     * information.
+     *
+     * @return the remote address of this channel.
+     * {@code null} if this channel is not connected.
+     */
+    SocketAddress remoteAddress();
+
+    /**
+     * Returns {@code true} if and only if the I/O thread will perform the
+     * requested write operation immediately.  Any write requests made when
+     * this method returns {@code false} are queued until the I/O thread is
+     * ready to process the queued write requests.
+     */
+    boolean isWritable();
+
+    /**
+     * Returns {@code true} if the {@code RemotingChannel} is active and so connected.
+     */
+    boolean isActive();
+
+    /**
+     * Requests to close the {@code RemotingChannel} immediately.
+     */
+    void close();
+
+    /**
+     * Writes a response {@code RemotingCommand} to remote.
+     *
+     * @param command the response command
+     */
+    void reply(RemotingCommand command);
+
+    /**
+     * Writes a response {@code ChunkRegion} to remote.
+     *
+     * @param fileRegion the response chunk file region
+     */
+    void reply(ChunkRegion fileRegion);
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/command/RemotingCommand.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/command/RemotingCommand.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/command/RemotingCommand.java
new file mode 100644
index 0000000..f21a45d
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/command/RemotingCommand.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.remoting.api.command;
+
+import java.lang.reflect.Type;
+import java.util.Map;
+import org.apache.rocketmq.remoting.api.serializable.SerializerFactory;
+import org.apache.rocketmq.remoting.common.TypePresentation;
+
+public interface RemotingCommand {
+    byte protocolType();
+
+    void protocolType(byte value);
+
+    int requestID();
+
+    void requestID(int value);
+
+    byte serializerType();
+
+    void serializerType(byte value);
+
+    TrafficType trafficType();
+
+    void trafficType(TrafficType value);
+
+    String opCode();
+
+    void opCode(String value);
+
+    String remark();
+
+    void remark(String value);
+
+    Map<String, String> properties();
+
+    void properties(Map<String, String> value);
+
+    String property(String key);
+
+    void property(String key, String value);
+
+    Object parameter();
+
+    void parameter(Object value);
+
+    byte[] parameterBytes();
+
+    void parameterBytes(byte[] value);
+
+    byte[] extraPayload();
+
+    void extraPayload(byte[] value);
+
+    <T> T parameter(final SerializerFactory serializerFactory, Class<T> c);
+
+    <T> T parameter(final SerializerFactory serializerFactory, final TypePresentation<T> typePresentation);
+
+    <T> T parameter(final SerializerFactory serializerFactory, final Type type);
+
+    enum CommandFlag {
+        SUCCESS("0"),
+        ERROR("-1");
+
+        private String flag;
+
+        CommandFlag(final String flag) {
+            this.flag = flag;
+        }
+
+        public String flag() {
+            return flag;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/command/RemotingCommandFactory.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/command/RemotingCommandFactory.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/command/RemotingCommandFactory.java
new file mode 100644
index 0000000..82a5c6a
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/command/RemotingCommandFactory.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.remoting.api.command;
+
+public interface RemotingCommandFactory {
+    RemotingCommand createRequest();
+
+    RemotingCommand createResponse(RemotingCommand command);
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/command/TrafficType.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/command/TrafficType.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/command/TrafficType.java
new file mode 100644
index 0000000..efebfe7
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/command/TrafficType.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.remoting.api.command;
+
+public enum TrafficType {
+    REQUEST_SYNC,
+    REQUEST_ASYNC,
+    REQUEST_ONEWAY,
+    RESPONSE;
+
+    public static TrafficType parse(int index) {
+        switch (index) {
+            case 0:
+                return REQUEST_SYNC;
+            case 1:
+                return REQUEST_ASYNC;
+            case 2:
+                return REQUEST_ONEWAY;
+            case 3:
+                return RESPONSE;
+            default:
+                throw new IllegalArgumentException("Not supported " + index);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/compressable/Compressor.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/compressable/Compressor.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/compressable/Compressor.java
new file mode 100644
index 0000000..4688c45
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/compressable/Compressor.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.remoting.api.compressable;
+
+public interface Compressor {
+    String name();
+
+    byte type();
+
+    byte[] compress(final byte[] content) throws Exception;
+
+    byte[] deCompress(final byte[] content) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/0b88e66f/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/compressable/CompressorFactory.java
----------------------------------------------------------------------
diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/compressable/CompressorFactory.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/compressable/CompressorFactory.java
new file mode 100644
index 0000000..2494c78
--- /dev/null
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/compressable/CompressorFactory.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.remoting.api.compressable;
+
+public interface CompressorFactory {
+    void register(Compressor compressor);
+
+    byte type(String compressionName);
+
+    Compressor get(byte type);
+
+    void clearAll();
+}