This is an automated email from the ASF dual-hosted git repository.
iluo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new 4f9d896 constants step4 remoting (#4057)
4f9d896 is described below
commit 4f9d8960665ae1e8cfae1f398c6017d6def5593f
Author: huazhongming <[email protected]>
AuthorDate: Wed May 15 12:42:51 2019 +0800
constants step4 remoting (#4057)
---
.../dubbo/common/constants/RemotingConstants.java | 56 ------------------
.../java/org/apache/dubbo/remoting/Constants.java | 68 ++++++++++++++++++++++
.../support/header/HeaderExchangeClient.java | 11 ++--
.../support/header/HeaderExchangeServer.java | 12 ++--
.../dubbo/remoting/telnet/codec/TelnetCodec.java | 10 ++--
.../dubbo/remoting/transport/AbstractServer.java | 16 +++--
.../ConnectionOrderedChannelHandler.java | 8 ++-
.../dubbo/remoting/PerformanceServerTest.java | 4 +-
.../exchange/support/header/HeartBeatTaskTest.java | 6 +-
.../transport/codec/DeprecatedTelnetCodec.java | 5 +-
.../transport/grizzly/GrizzlyCodecAdapter.java | 10 +++-
dubbo-remoting/dubbo-remoting-http/pom.xml | 5 ++
.../remoting/http/tomcat/TomcatHttpServer.java | 4 +-
.../remoting/transport/mina/MinaCodecAdapter.java | 10 +++-
.../transport/netty/NettyCodecAdapter.java | 10 +++-
15 files changed, 141 insertions(+), 94 deletions(-)
diff --git
a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RemotingConstants.java
b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RemotingConstants.java
index 4e50fee..c2532aa 100644
---
a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RemotingConstants.java
+++
b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/RemotingConstants.java
@@ -30,17 +30,6 @@ public interface RemotingConstants {
*/
int DEFAULT_PAYLOAD = 8 * 1024 * 1024;
- String BUFFER_KEY = "buffer";
-
- /**
- * default buffer size is 8k.
- */
- int DEFAULT_BUFFER_SIZE = 8 * 1024;
-
- int MAX_BUFFER_SIZE = 16 * 1024;
-
- int MIN_BUFFER_SIZE = 1 * 1024;
-
String CONNECT_TIMEOUT_KEY = "connect.timeout";
int DEFAULT_CONNECT_TIMEOUT = 3000;
@@ -49,22 +38,12 @@ public interface RemotingConstants {
int DEFAULT_HEARTBEAT = 60 * 1000;
- String IDLE_TIMEOUT_KEY = "idle.timeout";
-
- int DEFAULT_IDLE_TIMEOUT = 600 * 1000;
-
- String ACCEPTS_KEY = "accepts";
-
- int DEFAULT_ACCEPTS = 0;
-
String SERIALIZATION_KEY = "serialization";
String DEFAULT_REMOTING_SERIALIZATION = "hessian2";
String CODEC_KEY = "codec";
- String DEFAULT_REMOTING_CODEC = "dubbo";
-
String SERVER_KEY = "server";
String DEFAULT_REMOTING_SERVER = "netty";
@@ -91,22 +70,8 @@ public interface RemotingConstants {
String SENT_KEY = "sent";
- boolean DEFAULT_SENT = false;
-
String DISPATCHER_KEY = "dispatcher";
- String CHANNEL_HANDLER_KEY = "channel.handler";
-
- String DEFAULT_CHANNEL_HANDLER = "default";
-
- String SERVICE_DESCIPTOR_KEY = "serviceDescriptor";
-
- String CONNECT_QUEUE_CAPACITY = "connect.queue.capacity";
-
- String CONNECT_QUEUE_WARNING_SIZE = "connect.queue.warning.size";
-
- int DEFAULT_CONNECT_QUEUE_WARNING_SIZE = 1000;
-
String CHANNEL_ATTRIBUTE_READONLY_KEY = "channel.readonly";
String CHANNEL_READONLYEVENT_SENT_KEY = "channel.readonly.sent";
@@ -115,29 +80,8 @@ public interface RemotingConstants {
String EXECUTOR_SERVICE_COMPONENT_KEY = ExecutorService.class.getName();
- String CHARSET_KEY = "charset";
-
- String DEFAULT_CHARSET = "UTF-8";
-
String BACKUP_KEY = "backup";
- /**
- * Every heartbeat duration / HEATBEAT_CHECK_TICK, check if a heartbeat
should be sent. Every heartbeat timeout
- * duration / HEATBEAT_CHECK_TICK, check if a connection should be closed
on server side, and if reconnect on
- * client side
- */
- int HEARTBEAT_CHECK_TICK = 3;
-
- /**
- * the least heartbeat during is 1000 ms.
- */
- long LEAST_HEARTBEAT_DURATION = 1000;
-
- /**
- * ticks per wheel.
- */
- int TICKS_PER_WHEEL = 128;
-
String HEARTBEAT_TIMEOUT_KEY = "heartbeat.timeout";
String RECONNECT_KEY = "reconnect";
diff --git
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Constants.java
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Constants.java
new file mode 100644
index 0000000..a057da1
--- /dev/null
+++
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/Constants.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.dubbo.remoting;
+
+
+public interface Constants {
+
+ String BUFFER_KEY = "buffer";
+
+ /**
+ * default buffer size is 8k.
+ */
+ int DEFAULT_BUFFER_SIZE = 8 * 1024;
+
+ int MAX_BUFFER_SIZE = 16 * 1024;
+
+ int MIN_BUFFER_SIZE = 1 * 1024;
+
+ String IDLE_TIMEOUT_KEY = "idle.timeout";
+
+ int DEFAULT_IDLE_TIMEOUT = 600 * 1000;
+
+ String ACCEPTS_KEY = "accepts";
+
+ int DEFAULT_ACCEPTS = 0;
+
+ String CONNECT_QUEUE_CAPACITY = "connect.queue.capacity";
+
+ String CONNECT_QUEUE_WARNING_SIZE = "connect.queue.warning.size";
+
+ int DEFAULT_CONNECT_QUEUE_WARNING_SIZE = 1000;
+
+ String CHARSET_KEY = "charset";
+
+ String DEFAULT_CHARSET = "UTF-8";
+
+ /**
+ * Every heartbeat duration / HEATBEAT_CHECK_TICK, check if a heartbeat
should be sent. Every heartbeat timeout
+ * duration / HEATBEAT_CHECK_TICK, check if a connection should be closed
on server side, and if reconnect on
+ * client side
+ */
+ int HEARTBEAT_CHECK_TICK = 3;
+
+ /**
+ * the least heartbeat during is 1000 ms.
+ */
+ long LEAST_HEARTBEAT_DURATION = 1000;
+
+ /**
+ * ticks per wheel.
+ */
+ int TICKS_PER_WHEEL = 128;
+}
diff --git
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeClient.java
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeClient.java
index 944daac..a57f82d 100644
---
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeClient.java
+++
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeClient.java
@@ -35,6 +35,9 @@ import java.util.concurrent.TimeUnit;
import static org.apache.dubbo.common.utils.UrlUtils.getHeartbeat;
import static org.apache.dubbo.common.utils.UrlUtils.getIdleTimeout;
+import static org.apache.dubbo.remoting.Constants.HEARTBEAT_CHECK_TICK;
+import static org.apache.dubbo.remoting.Constants.LEAST_HEARTBEAT_DURATION;
+import static org.apache.dubbo.remoting.Constants.TICKS_PER_WHEEL;
/**
* DefaultMessageClient
@@ -45,7 +48,7 @@ public class HeaderExchangeClient implements ExchangeClient {
private final ExchangeChannel channel;
private static final HashedWheelTimer IDLE_CHECK_TIMER = new
HashedWheelTimer(
- new NamedThreadFactory("dubbo-client-idleCheck", true), 1,
TimeUnit.SECONDS, RemotingConstants.TICKS_PER_WHEEL);
+ new NamedThreadFactory("dubbo-client-idleCheck", true), 1,
TimeUnit.SECONDS, TICKS_PER_WHEEL);
private HeartbeatTimerTask heartBeatTimerTask;
private ReconnectTimerTask reconnectTimerTask;
@@ -206,10 +209,10 @@ public class HeaderExchangeClient implements
ExchangeClient {
* Each interval cannot be less than 1000ms.
*/
private long calculateLeastDuration(int time) {
- if (time / RemotingConstants.HEARTBEAT_CHECK_TICK <= 0) {
- return RemotingConstants.LEAST_HEARTBEAT_DURATION;
+ if (time / HEARTBEAT_CHECK_TICK <= 0) {
+ return LEAST_HEARTBEAT_DURATION;
} else {
- return time / RemotingConstants.HEARTBEAT_CHECK_TICK;
+ return time / HEARTBEAT_CHECK_TICK;
}
}
diff --git
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java
index be52d6d..0f1e71f 100644
---
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java
+++
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java
@@ -42,6 +42,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
import static java.util.Collections.unmodifiableCollection;
+import static org.apache.dubbo.remoting.Constants.HEARTBEAT_CHECK_TICK;
+import static org.apache.dubbo.remoting.Constants.LEAST_HEARTBEAT_DURATION;
+import static org.apache.dubbo.remoting.Constants.TICKS_PER_WHEEL;
+
/**
* ExchangeServerImpl
*/
@@ -53,7 +57,7 @@ public class HeaderExchangeServer implements ExchangeServer {
private AtomicBoolean closed = new AtomicBoolean(false);
private static final HashedWheelTimer IDLE_CHECK_TIMER = new
HashedWheelTimer(new NamedThreadFactory("dubbo-server-idleCheck", true), 1,
- TimeUnit.SECONDS, RemotingConstants.TICKS_PER_WHEEL);
+ TimeUnit.SECONDS, TICKS_PER_WHEEL);
private CloseTimerTask closeTimerTask;
@@ -246,10 +250,10 @@ public class HeaderExchangeServer implements
ExchangeServer {
* Each interval cannot be less than 1000ms.
*/
private long calculateLeastDuration(int time) {
- if (time / RemotingConstants.HEARTBEAT_CHECK_TICK <= 0) {
- return RemotingConstants.LEAST_HEARTBEAT_DURATION;
+ if (time / HEARTBEAT_CHECK_TICK <= 0) {
+ return LEAST_HEARTBEAT_DURATION;
} else {
- return time / RemotingConstants.HEARTBEAT_CHECK_TICK;
+ return time / HEARTBEAT_CHECK_TICK;
}
}
diff --git
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/codec/TelnetCodec.java
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/codec/TelnetCodec.java
index b34ee15..3ac276b 100644
---
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/codec/TelnetCodec.java
+++
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/codec/TelnetCodec.java
@@ -17,7 +17,6 @@
package org.apache.dubbo.remoting.telnet.codec;
import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.CollectionUtils;
@@ -34,6 +33,9 @@ import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
+import static org.apache.dubbo.remoting.Constants.CHARSET_KEY;
+import static org.apache.dubbo.remoting.Constants.DEFAULT_CHARSET;
+
/**
* TelnetCodec
*/
@@ -60,7 +62,7 @@ public class TelnetCodec extends TransportCodec {
private static Charset getCharset(Channel channel) {
if (channel != null) {
- Object attribute =
channel.getAttribute(RemotingConstants.CHARSET_KEY);
+ Object attribute = channel.getAttribute(CHARSET_KEY);
if (attribute instanceof String) {
try {
return Charset.forName((String) attribute);
@@ -72,7 +74,7 @@ public class TelnetCodec extends TransportCodec {
}
URL url = channel.getUrl();
if (url != null) {
- String parameter =
url.getParameter(RemotingConstants.CHARSET_KEY);
+ String parameter = url.getParameter(CHARSET_KEY);
if (StringUtils.isNotEmpty(parameter)) {
try {
return Charset.forName(parameter);
@@ -83,7 +85,7 @@ public class TelnetCodec extends TransportCodec {
}
}
try {
- return Charset.forName(RemotingConstants.DEFAULT_CHARSET);
+ return Charset.forName(DEFAULT_CHARSET);
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
}
diff --git
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractServer.java
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractServer.java
index a252ca4..ea801a0 100644
---
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractServer.java
+++
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractServer.java
@@ -37,6 +37,10 @@ import java.util.concurrent.ThreadPoolExecutor;
import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_VALUE;
import static org.apache.dubbo.common.constants.CommonConstants.THREADS_KEY;
+import static org.apache.dubbo.remoting.Constants.IDLE_TIMEOUT_KEY;
+import static org.apache.dubbo.remoting.Constants.DEFAULT_IDLE_TIMEOUT;
+import static org.apache.dubbo.remoting.Constants.ACCEPTS_KEY;
+import static org.apache.dubbo.remoting.Constants.DEFAULT_ACCEPTS;
/**
* AbstractServer
@@ -61,8 +65,8 @@ public abstract class AbstractServer extends AbstractEndpoint
implements Server
bindIp = ANYHOST_VALUE;
}
bindAddress = new InetSocketAddress(bindIp, bindPort);
- this.accepts = url.getParameter(RemotingConstants.ACCEPTS_KEY,
RemotingConstants.DEFAULT_ACCEPTS);
- this.idleTimeout =
url.getParameter(RemotingConstants.IDLE_TIMEOUT_KEY,
RemotingConstants.DEFAULT_IDLE_TIMEOUT);
+ this.accepts = url.getParameter(ACCEPTS_KEY, DEFAULT_ACCEPTS);
+ this.idleTimeout = url.getParameter(IDLE_TIMEOUT_KEY,
DEFAULT_IDLE_TIMEOUT);
try {
doOpen();
if (logger.isInfoEnabled()) {
@@ -87,8 +91,8 @@ public abstract class AbstractServer extends AbstractEndpoint
implements Server
return;
}
try {
- if (url.hasParameter(RemotingConstants.ACCEPTS_KEY)) {
- int a = url.getParameter(RemotingConstants.ACCEPTS_KEY, 0);
+ if (url.hasParameter(ACCEPTS_KEY)) {
+ int a = url.getParameter(ACCEPTS_KEY, 0);
if (a > 0) {
this.accepts = a;
}
@@ -97,8 +101,8 @@ public abstract class AbstractServer extends
AbstractEndpoint implements Server
logger.error(t.getMessage(), t);
}
try {
- if (url.hasParameter(RemotingConstants.IDLE_TIMEOUT_KEY)) {
- int t = url.getParameter(RemotingConstants.IDLE_TIMEOUT_KEY,
0);
+ if (url.hasParameter(IDLE_TIMEOUT_KEY)) {
+ int t = url.getParameter(IDLE_TIMEOUT_KEY, 0);
if (t > 0) {
this.idleTimeout = t;
}
diff --git
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/dispatcher/connection/ConnectionOrderedChannelHandler.java
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/dispatcher/connection/ConnectionOrderedChannelHandler.java
index 91310ef..33bc279 100644
---
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/dispatcher/connection/ConnectionOrderedChannelHandler.java
+++
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/dispatcher/connection/ConnectionOrderedChannelHandler.java
@@ -17,7 +17,6 @@
package org.apache.dubbo.remoting.transport.dispatcher.connection;
import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.threadpool.support.AbortPolicyWithReport;
import org.apache.dubbo.common.utils.NamedThreadFactory;
import org.apache.dubbo.remoting.Channel;
@@ -38,6 +37,9 @@ import java.util.concurrent.TimeUnit;
import static
org.apache.dubbo.common.constants.CommonConstants.THREAD_NAME_KEY;
import static
org.apache.dubbo.common.constants.CommonConstants.DEFAULT_THREAD_NAME;
+import static org.apache.dubbo.remoting.Constants.CONNECT_QUEUE_CAPACITY;
+import static org.apache.dubbo.remoting.Constants.CONNECT_QUEUE_WARNING_SIZE;
+import static
org.apache.dubbo.remoting.Constants.DEFAULT_CONNECT_QUEUE_WARNING_SIZE;
public class ConnectionOrderedChannelHandler extends WrappedChannelHandler {
@@ -49,11 +51,11 @@ public class ConnectionOrderedChannelHandler extends
WrappedChannelHandler {
String threadName = url.getParameter(THREAD_NAME_KEY,
DEFAULT_THREAD_NAME);
connectionExecutor = new ThreadPoolExecutor(1, 1,
0L, TimeUnit.MILLISECONDS,
- new
LinkedBlockingQueue<Runnable>(url.getPositiveParameter(RemotingConstants.CONNECT_QUEUE_CAPACITY,
Integer.MAX_VALUE)),
+ new
LinkedBlockingQueue<Runnable>(url.getPositiveParameter(CONNECT_QUEUE_CAPACITY,
Integer.MAX_VALUE)),
new NamedThreadFactory(threadName, true),
new AbortPolicyWithReport(threadName, url)
); // FIXME There's no place to release connectionExecutor!
- queuewarninglimit =
url.getParameter(RemotingConstants.CONNECT_QUEUE_WARNING_SIZE,
RemotingConstants.DEFAULT_CONNECT_QUEUE_WARNING_SIZE);
+ queuewarninglimit = url.getParameter(CONNECT_QUEUE_WARNING_SIZE,
DEFAULT_CONNECT_QUEUE_WARNING_SIZE);
}
@Override
diff --git
a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceServerTest.java
b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceServerTest.java
index 04c9c67..8f3808a 100644
---
a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceServerTest.java
+++
b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/PerformanceServerTest.java
@@ -36,6 +36,8 @@ import static
org.apache.dubbo.common.constants.CommonConstants.DEFAULT_THREADPO
import static org.apache.dubbo.common.constants.CommonConstants.THREADS_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.THREADPOOL_KEY;
import static
org.apache.dubbo.common.constants.CommonConstants.DEFAULT_THREADS;
+import static org.apache.dubbo.remoting.Constants.BUFFER_KEY;
+import static org.apache.dubbo.remoting.Constants.DEFAULT_BUFFER_SIZE;
/**
* PerformanceServer
@@ -71,7 +73,7 @@ public class PerformanceServerTest {
final String threadpool = PerformanceUtils.getProperty(THREADPOOL_KEY,
DEFAULT_THREADPOOL);
final int threads = PerformanceUtils.getIntProperty(THREADS_KEY,
DEFAULT_THREADS);
final int iothreads = PerformanceUtils.getIntProperty(IO_THREADS_KEY,
RemotingConstants.DEFAULT_IO_THREADS);
- final int buffer =
PerformanceUtils.getIntProperty(RemotingConstants.BUFFER_KEY,
RemotingConstants.DEFAULT_BUFFER_SIZE);
+ final int buffer = PerformanceUtils.getIntProperty(BUFFER_KEY,
DEFAULT_BUFFER_SIZE);
final String channelHandler =
PerformanceUtils.getProperty(RemotingConstants.DISPATCHER_KEY,
ExecutionDispatcher.NAME);
diff --git
a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/exchange/support/header/HeartBeatTaskTest.java
b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/exchange/support/header/HeartBeatTaskTest.java
index 23a0e3a..aaf8f7a 100644
---
a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/exchange/support/header/HeartBeatTaskTest.java
+++
b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/exchange/support/header/HeartBeatTaskTest.java
@@ -18,7 +18,6 @@
package org.apache.dubbo.remoting.exchange.support.header;
import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.timer.HashedWheelTimer;
import org.apache.dubbo.remoting.Channel;
import org.apache.dubbo.remoting.exchange.Request;
@@ -31,6 +30,7 @@ import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.apache.dubbo.common.constants.RpcConstants.DUBBO_VERSION_KEY;
+import static org.apache.dubbo.remoting.Constants.HEARTBEAT_CHECK_TICK;
public class HeartBeatTaskTest {
@@ -44,7 +44,7 @@ public class HeartBeatTaskTest {
@BeforeEach
public void setup() throws Exception {
long tickDuration = 1000;
- heartbeatTimer = new HashedWheelTimer(tickDuration /
RemotingConstants.HEARTBEAT_CHECK_TICK, TimeUnit.MILLISECONDS);
+ heartbeatTimer = new HashedWheelTimer(tickDuration /
HEARTBEAT_CHECK_TICK, TimeUnit.MILLISECONDS);
channel = new MockChannel() {
@@ -55,7 +55,7 @@ public class HeartBeatTaskTest {
};
AbstractTimerTask.ChannelProvider cp = () ->
Collections.<Channel>singletonList(channel);
- heartbeatTimerTask = new HeartbeatTimerTask(cp, tickDuration /
RemotingConstants.HEARTBEAT_CHECK_TICK, (int) tickDuration);
+ heartbeatTimerTask = new HeartbeatTimerTask(cp, tickDuration /
HEARTBEAT_CHECK_TICK, (int) tickDuration);
}
@Test
diff --git
a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/transport/codec/DeprecatedTelnetCodec.java
b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/transport/codec/DeprecatedTelnetCodec.java
index 419f01e..2b37e89 100644
---
a/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/transport/codec/DeprecatedTelnetCodec.java
+++
b/dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/transport/codec/DeprecatedTelnetCodec.java
@@ -39,6 +39,7 @@ import java.util.LinkedList;
import java.util.List;
import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY;
+import static org.apache.dubbo.remoting.Constants.CHARSET_KEY;
public class DeprecatedTelnetCodec implements Codec {
@@ -70,7 +71,7 @@ public class DeprecatedTelnetCodec implements Codec {
private static Charset getCharset(Channel channel) {
if (channel != null) {
- Object attribute =
channel.getAttribute(RemotingConstants.CHARSET_KEY);
+ Object attribute = channel.getAttribute(CHARSET_KEY);
if (attribute instanceof String) {
try {
return Charset.forName((String) attribute);
@@ -82,7 +83,7 @@ public class DeprecatedTelnetCodec implements Codec {
}
URL url = channel.getUrl();
if (url != null) {
- String parameter =
url.getParameter(RemotingConstants.CHARSET_KEY);
+ String parameter = url.getParameter(CHARSET_KEY);
if (StringUtils.isNotEmpty(parameter)) {
try {
return Charset.forName(parameter);
diff --git
a/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/org/apache/dubbo/remoting/transport/grizzly/GrizzlyCodecAdapter.java
b/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/org/apache/dubbo/remoting/transport/grizzly/GrizzlyCodecAdapter.java
index a716245..39e6990 100644
---
a/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/org/apache/dubbo/remoting/transport/grizzly/GrizzlyCodecAdapter.java
+++
b/dubbo-remoting/dubbo-remoting-grizzly/src/main/java/org/apache/dubbo/remoting/transport/grizzly/GrizzlyCodecAdapter.java
@@ -17,7 +17,6 @@
package org.apache.dubbo.remoting.transport.grizzly;
import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.remoting.Channel;
import org.apache.dubbo.remoting.ChannelHandler;
import org.apache.dubbo.remoting.Codec2;
@@ -33,6 +32,11 @@ import org.glassfish.grizzly.filterchain.NextAction;
import java.io.IOException;
+import static org.apache.dubbo.remoting.Constants.BUFFER_KEY;
+import static org.apache.dubbo.remoting.Constants.DEFAULT_BUFFER_SIZE;
+import static org.apache.dubbo.remoting.Constants.MAX_BUFFER_SIZE;
+import static org.apache.dubbo.remoting.Constants.MIN_BUFFER_SIZE;
+
/**
* GrizzlyCodecAdapter
*/
@@ -52,8 +56,8 @@ public class GrizzlyCodecAdapter extends BaseFilter {
this.codec = codec;
this.url = url;
this.handler = handler;
- int b = url.getPositiveParameter(RemotingConstants.BUFFER_KEY,
RemotingConstants.DEFAULT_BUFFER_SIZE);
- this.bufferSize = b >= RemotingConstants.MIN_BUFFER_SIZE && b <=
RemotingConstants.MAX_BUFFER_SIZE ? b : RemotingConstants.DEFAULT_BUFFER_SIZE;
+ int b = url.getPositiveParameter(BUFFER_KEY, DEFAULT_BUFFER_SIZE);
+ this.bufferSize = b >= MIN_BUFFER_SIZE && b <= MAX_BUFFER_SIZE ? b :
DEFAULT_BUFFER_SIZE;
}
@Override
diff --git a/dubbo-remoting/dubbo-remoting-http/pom.xml
b/dubbo-remoting/dubbo-remoting-http/pom.xml
index 9937a19..19c8220 100644
--- a/dubbo-remoting/dubbo-remoting-http/pom.xml
+++ b/dubbo-remoting/dubbo-remoting-http/pom.xml
@@ -35,6 +35,11 @@
<version>${project.parent.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-remoting-api</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</dependency>
diff --git
a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpServer.java
b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpServer.java
index e59f8f6..df42130 100755
---
a/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpServer.java
+++
b/dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/tomcat/TomcatHttpServer.java
@@ -17,7 +17,6 @@
package org.apache.dubbo.remoting.http.tomcat;
import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.remoting.http.HttpHandler;
@@ -33,6 +32,7 @@ import java.io.File;
import static org.apache.dubbo.common.constants.CommonConstants.THREADS_KEY;
import static
org.apache.dubbo.common.constants.CommonConstants.DEFAULT_THREADS;
+import static org.apache.dubbo.remoting.Constants.ACCEPTS_KEY;
public class TomcatHttpServer extends AbstractHttpServer {
@@ -57,7 +57,7 @@ public class TomcatHttpServer extends AbstractHttpServer {
// "minSpareThreads",
String.valueOf(url.getParameter(Constants.THREADS_KEY,
Constants.DEFAULT_THREADS)));
tomcat.getConnector().setProperty(
- "maxConnections",
String.valueOf(url.getParameter(RemotingConstants.ACCEPTS_KEY, -1)));
+ "maxConnections", String.valueOf(url.getParameter(ACCEPTS_KEY,
-1)));
tomcat.getConnector().setProperty("URIEncoding", "UTF-8");
tomcat.getConnector().setProperty("connectionTimeout", "60000");
diff --git
a/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaCodecAdapter.java
b/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaCodecAdapter.java
index 128f119..7ce9253 100644
---
a/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaCodecAdapter.java
+++
b/dubbo-remoting/dubbo-remoting-mina/src/main/java/org/apache/dubbo/remoting/transport/mina/MinaCodecAdapter.java
@@ -17,7 +17,6 @@
package org.apache.dubbo.remoting.transport.mina;
import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.remoting.Channel;
import org.apache.dubbo.remoting.ChannelHandler;
import org.apache.dubbo.remoting.Codec2;
@@ -33,6 +32,11 @@ import org.apache.mina.filter.codec.ProtocolDecoderOutput;
import org.apache.mina.filter.codec.ProtocolEncoder;
import org.apache.mina.filter.codec.ProtocolEncoderOutput;
+import static org.apache.dubbo.remoting.Constants.BUFFER_KEY;
+import static org.apache.dubbo.remoting.Constants.DEFAULT_BUFFER_SIZE;
+import static org.apache.dubbo.remoting.Constants.MAX_BUFFER_SIZE;
+import static org.apache.dubbo.remoting.Constants.MIN_BUFFER_SIZE;
+
/**
* MinaCodecAdapter.
*/
@@ -54,8 +58,8 @@ final class MinaCodecAdapter implements ProtocolCodecFactory {
this.codec = codec;
this.url = url;
this.handler = handler;
- int b = url.getPositiveParameter(RemotingConstants.BUFFER_KEY,
RemotingConstants.DEFAULT_BUFFER_SIZE);
- this.bufferSize = b >= RemotingConstants.MIN_BUFFER_SIZE && b <=
RemotingConstants.MAX_BUFFER_SIZE ? b : RemotingConstants.DEFAULT_BUFFER_SIZE;
+ int b = url.getPositiveParameter(BUFFER_KEY, DEFAULT_BUFFER_SIZE);
+ this.bufferSize = b >= MIN_BUFFER_SIZE && b <= MAX_BUFFER_SIZE ? b :
DEFAULT_BUFFER_SIZE;
}
@Override
diff --git
a/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyCodecAdapter.java
b/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyCodecAdapter.java
index 5088001..94e6c17 100644
---
a/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyCodecAdapter.java
+++
b/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyCodecAdapter.java
@@ -17,7 +17,6 @@
package org.apache.dubbo.remoting.transport.netty;
import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.constants.RemotingConstants;
import org.apache.dubbo.remoting.Codec2;
import org.apache.dubbo.remoting.buffer.DynamicChannelBuffer;
@@ -35,6 +34,11 @@ import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
import java.io.IOException;
+import static org.apache.dubbo.remoting.Constants.BUFFER_KEY;
+import static org.apache.dubbo.remoting.Constants.DEFAULT_BUFFER_SIZE;
+import static org.apache.dubbo.remoting.Constants.MAX_BUFFER_SIZE;
+import static org.apache.dubbo.remoting.Constants.MIN_BUFFER_SIZE;
+
/**
* NettyCodecAdapter.
*/
@@ -56,8 +60,8 @@ final class NettyCodecAdapter {
this.codec = codec;
this.url = url;
this.handler = handler;
- int b = url.getPositiveParameter(RemotingConstants.BUFFER_KEY,
RemotingConstants.DEFAULT_BUFFER_SIZE);
- this.bufferSize = b >= RemotingConstants.MIN_BUFFER_SIZE && b <=
RemotingConstants.MAX_BUFFER_SIZE ? b : RemotingConstants.DEFAULT_BUFFER_SIZE;
+ int b = url.getPositiveParameter(BUFFER_KEY, DEFAULT_BUFFER_SIZE);
+ this.bufferSize = b >= MIN_BUFFER_SIZE && b <= MAX_BUFFER_SIZE ? b :
DEFAULT_BUFFER_SIZE;
}
public ChannelHandler getEncoder() {