I18N effort for dubbo-remoting, translate the missing content
This commit is contained in:
parent
64b8ef6b7e
commit
b04e83e241
|
|
@ -36,7 +36,7 @@ public interface Dispatcher {
|
|||
* @return channel handler
|
||||
*/
|
||||
@Adaptive({Constants.DISPATCHER_KEY, "dispather", "channel.handler"})
|
||||
// 后两个参数为兼容旧配置
|
||||
// The last two parameters are reserved for compatibility with the old configuration
|
||||
ChannelHandler dispatch(ChannelHandler handler, URL url);
|
||||
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ public interface Endpoint {
|
|||
* send message.
|
||||
*
|
||||
* @param message
|
||||
* @param sent 是否已发送完成
|
||||
* @param sent already sent to socket?
|
||||
*/
|
||||
void send(Object message, boolean sent) throws RemotingException;
|
||||
|
||||
|
|
|
|||
|
|
@ -282,9 +282,9 @@ public class ExchangeCodec extends TelnetCodec {
|
|||
buffer.writeBytes(header); // write header.
|
||||
buffer.writerIndex(savedWriteIndex + HEADER_LENGTH + len);
|
||||
} catch (Throwable t) {
|
||||
// 将buffer内容清空
|
||||
// clear buffer
|
||||
buffer.writerIndex(savedWriteIndex);
|
||||
// 发送失败信息给Consumer,否则Consumer只能等超时了
|
||||
// send error message to Consumer, otherwise, Consumer will wait till timeout.
|
||||
if (!res.isEvent() && res.getStatus() != Response.BAD_RESPONSE) {
|
||||
Response r = new Response(res.getId(), res.getVersion());
|
||||
r.setStatus(Response.BAD_RESPONSE);
|
||||
|
|
@ -299,7 +299,7 @@ public class ExchangeCodec extends TelnetCodec {
|
|||
logger.warn("Failed to send bad_response info back: " + t.getMessage() + ", cause: " + e.getMessage(), e);
|
||||
}
|
||||
} else {
|
||||
// FIXME 在Codec中打印出错日志?在IoHanndler的caught中统一处理?
|
||||
// FIXME log error message in Codec and handle in caught() of IoHanndler?
|
||||
logger.warn("Fail to encode response: " + res + ", send bad_response info instead, cause: " + t.getMessage(), t);
|
||||
try {
|
||||
r.setErrorMessage("Failed to send response: " + res + ", cause: " + StringUtils.toString(t));
|
||||
|
|
@ -311,7 +311,7 @@ public class ExchangeCodec extends TelnetCodec {
|
|||
}
|
||||
}
|
||||
|
||||
// 重新抛出收到的异常
|
||||
// Rethrow exception
|
||||
if (t instanceof IOException) {
|
||||
throw (IOException) t;
|
||||
} else if (t instanceof RuntimeException) {
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ public class HeaderExchangeClient implements ExchangeClient {
|
|||
}
|
||||
|
||||
public void close(int timeout) {
|
||||
// 标记client进入关闭流程
|
||||
// Mark the client into the closure process
|
||||
startClose();
|
||||
doClose();
|
||||
channel.close(timeout);
|
||||
|
|
|
|||
|
|
@ -55,14 +55,14 @@ public abstract class AbstractClient extends AbstractEndpoint implements Client
|
|||
private final Lock connectLock = new ReentrantLock();
|
||||
private final boolean send_reconnect;
|
||||
private final AtomicInteger reconnect_count = new AtomicInteger(0);
|
||||
//重连的error日志是否已经被调用过.
|
||||
// Reconnection error log has been called before?
|
||||
private final AtomicBoolean reconnect_error_log_flag = new AtomicBoolean(false);
|
||||
//reconnect warning period 重连warning的间隔.(waring多少次之后,warning一次) //for test
|
||||
// reconnect warning period. Reconnect warning interval (log warning after how many times) //for test
|
||||
private final int reconnect_warning_period;
|
||||
private final long shutdown_timeout;
|
||||
protected volatile ExecutorService executor;
|
||||
private volatile ScheduledFuture<?> reconnectExecutorFuture = null;
|
||||
//the last successed connected time
|
||||
// the last successed connected time
|
||||
private long lastConnectedTime = System.currentTimeMillis();
|
||||
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ public abstract class AbstractClient extends AbstractEndpoint implements Client
|
|||
|
||||
shutdown_timeout = url.getParameter(Constants.SHUTDOWN_TIMEOUT_KEY, Constants.DEFAULT_SHUTDOWN_TIMEOUT);
|
||||
|
||||
//默认重连间隔2s,1800表示1小时warning一次.
|
||||
// The default reconnection interval is 2s, 1800 means warning interval is 1 hour.
|
||||
reconnect_warning_period = url.getParameter("reconnect.waring.period", 1800);
|
||||
|
||||
try {
|
||||
|
|
@ -249,7 +249,7 @@ public abstract class AbstractClient extends AbstractEndpoint implements Client
|
|||
connect();
|
||||
}
|
||||
Channel channel = getChannel();
|
||||
//TODO getChannel返回的状态是否包含null需要改进
|
||||
//TODO Can the value returned by getChannel() be null? need improvement.
|
||||
if (channel == null || !channel.isConnected()) {
|
||||
throw new RemotingException(this, "message can not send, because channel is closed . url:" + getUrl());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public abstract class AbstractPeer implements Endpoint, ChannelHandler {
|
|||
}
|
||||
|
||||
/**
|
||||
* 返回最终的handler,可能已被wrap,需要区别于getChannelHandler
|
||||
* Return the final handler (which may have been wrapped). This method should be distinguished with getChannelHandler() method
|
||||
*
|
||||
* @return ChannelHandler
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ public abstract class AbstractServer extends AbstractEndpoint implements Server
|
|||
|
||||
@Override
|
||||
public void connected(Channel ch) throws RemotingException {
|
||||
// 如果server已进入关闭流程,拒绝新的连接
|
||||
// If the server has entered the shutdown process, reject any new connection
|
||||
if (this.isClosing() || this.isClosed()) {
|
||||
logger.warn("Close new channel " + ch + ", cause: server is closing or has been closed. For example, receive a new connect request while in shutdown process.");
|
||||
ch.close();
|
||||
|
|
|
|||
|
|
@ -16,12 +16,6 @@
|
|||
*/
|
||||
package com.alibaba.dubbo.remoting.transport.dispatcher.connection;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.alibaba.dubbo.common.Constants;
|
||||
import com.alibaba.dubbo.common.URL;
|
||||
import com.alibaba.dubbo.common.threadpool.support.AbortPolicyWithReport;
|
||||
|
|
@ -36,6 +30,12 @@ import com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable;
|
|||
import com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.ChannelState;
|
||||
import com.alibaba.dubbo.remoting.transport.dispatcher.WrappedChannelHandler;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ConnectionOrderedChannelHandler extends WrappedChannelHandler {
|
||||
|
||||
protected final ThreadPoolExecutor connectionExecutor;
|
||||
|
|
@ -79,7 +79,7 @@ public class ConnectionOrderedChannelHandler extends WrappedChannelHandler {
|
|||
try {
|
||||
cexecutor.execute(new ChannelEventRunnable(channel, handler, ChannelState.RECEIVED, message));
|
||||
} catch (Throwable t) {
|
||||
//fix 线程池满了拒绝调用不返回,导致消费者一直等待超时
|
||||
//fix, reject exception can not be sent to consumer because thread pool is full, resulting in consumers waiting till timeout.
|
||||
if (message instanceof Request && t instanceof RejectedExecutionException) {
|
||||
Request request = (Request) message;
|
||||
if (request.isTwoWay()) {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public class ChanelHandlerTest extends TestCase {
|
|||
private static final Logger logger = LoggerFactory.getLogger(ChanelHandlerTest.class);
|
||||
|
||||
public static ExchangeClient initClient(String url) {
|
||||
// 创建客户端
|
||||
// Create client and build connection
|
||||
ExchangeClient exchangeClient = null;
|
||||
PeformanceTestHandler handler = new PeformanceTestHandler(url);
|
||||
boolean run = true;
|
||||
|
|
@ -73,7 +73,7 @@ public class ChanelHandlerTest extends TestCase {
|
|||
|
||||
@Test
|
||||
public void testClient() throws Throwable {
|
||||
// 读取参数
|
||||
// read server info from property
|
||||
if (PerformanceUtils.getProperty("server", null) == null) {
|
||||
logger.warn("Please set -Dserver=127.0.0.1:9911");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class PerformanceClientCloseTest extends TestCase {
|
|||
|
||||
@Test
|
||||
public void testClient() throws Throwable {
|
||||
// 读取参数
|
||||
// read server info from property
|
||||
if (PerformanceUtils.getProperty("server", null) == null) {
|
||||
logger.warn("Please set -Dserver=127.0.0.1:9911");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class PerformanceClientTest extends TestCase {
|
|||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testClient() throws Throwable {
|
||||
// 读取参数
|
||||
// read server info from property
|
||||
if (PerformanceUtils.getProperty("server", null) == null) {
|
||||
logger.warn("Please set -Dserver=127.0.0.1:9911");
|
||||
return;
|
||||
|
|
@ -62,7 +62,7 @@ public class PerformanceClientTest extends TestCase {
|
|||
final String onerror = PerformanceUtils.getProperty("onerror", "continue");
|
||||
|
||||
final String url = "exchange://" + server + "?transporter=" + transporter + "&serialization=" + serialization + "&timeout=" + timeout;
|
||||
// 创建客户端
|
||||
// Create clients and build connections
|
||||
final ExchangeClient[] exchangeClients = new ExchangeClient[connections];
|
||||
for (int i = 0; i < connections; i++) {
|
||||
//exchangeClients[i] = Exchangers.connect(url,handler);
|
||||
|
|
@ -72,20 +72,20 @@ public class PerformanceClientTest extends TestCase {
|
|||
List<String> serverEnvironment = (List<String>) exchangeClients[0].request("environment").get();
|
||||
List<String> serverScene = (List<String>) exchangeClients[0].request("scene").get();
|
||||
|
||||
// 制造数据
|
||||
// Create some data for test
|
||||
StringBuilder buf = new StringBuilder(length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
buf.append("A");
|
||||
}
|
||||
final String data = buf.toString();
|
||||
|
||||
// 计数器
|
||||
// counters
|
||||
final AtomicLong count = new AtomicLong();
|
||||
final AtomicLong error = new AtomicLong();
|
||||
final AtomicLong time = new AtomicLong();
|
||||
final AtomicLong all = new AtomicLong();
|
||||
|
||||
// 并发调用
|
||||
// Start multiple threads
|
||||
final CountDownLatch latch = new CountDownLatch(concurrent);
|
||||
for (int i = 0; i < concurrent; i++) {
|
||||
new Thread(new Runnable() {
|
||||
|
|
@ -127,7 +127,7 @@ public class PerformanceClientTest extends TestCase {
|
|||
}).start();
|
||||
}
|
||||
|
||||
// 输出,tps不精确,但大概反映情况
|
||||
// Output, tps is not for accuracy, but it reflects the situation to a certain extent.
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
|
|
@ -138,7 +138,7 @@ public class PerformanceClientTest extends TestCase {
|
|||
boolean bfirst = true;
|
||||
while (latch.getCount() > 0) {
|
||||
long c = count.get() - lastCount;
|
||||
if (!bfirst)//第一次不准
|
||||
if (!bfirst)// The first time is inaccurate.
|
||||
System.out.println("[" + dateFormat.format(new Date()) + "] count: " + count.get() + ", error: " + error.get() + ",tps:" + (c / elapsd));
|
||||
|
||||
bfirst = false;
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class PerformanceServerTest extends TestCase {
|
|||
final String channelHandler = PerformanceUtils.getProperty(Constants.DISPATCHER_KEY, ExecutionDispatcher.NAME);
|
||||
|
||||
|
||||
// 启动服务器
|
||||
// Start server
|
||||
ExchangeServer server = Exchangers.bind("exchange://0.0.0.0:" + port + "?transporter="
|
||||
+ transporter + "&serialization="
|
||||
+ serialization + "&threadpool=" + threadpool
|
||||
|
|
@ -96,7 +96,7 @@ public class PerformanceServerTest extends TestCase {
|
|||
}
|
||||
|
||||
private static ExchangeServer statTelnetServer(int port) throws Exception {
|
||||
// 启动服务器
|
||||
// Start server
|
||||
ExchangeServer telnetserver = Exchangers.bind("exchange://0.0.0.0:" + port, new ExchangeHandlerAdapter() {
|
||||
public String telnet(Channel channel, String message) throws RemotingException {
|
||||
if (message.equals("help")) {
|
||||
|
|
@ -141,7 +141,7 @@ public class PerformanceServerTest extends TestCase {
|
|||
|
||||
@Test
|
||||
public void testServer() throws Exception {
|
||||
// 读取参数
|
||||
// Read port from property
|
||||
if (PerformanceUtils.getProperty("port", null) == null) {
|
||||
logger.warn("Please set -Dport=9911");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ public class ExchangeCodecTest extends TelnetCodecTest {
|
|||
ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(header);
|
||||
Object obj = codec.decode(channel, buffer);
|
||||
Assert.assertEquals(TelnetCodec.DecodeResult.NEED_MORE_INPUT, obj);
|
||||
//如果telnet数据与request数据在同一个数据包中,不能因为telnet没有结尾字符而影响其他数据的接收.
|
||||
//If the telnet data and request data are in the same data packet, we should guarantee that the receipt of request data won't be affected by the factor that telnet does not have an end characters.
|
||||
Assert.assertEquals(2, buffer.readerIndex());
|
||||
}
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ public class ExchangeCodecTest extends TelnetCodecTest {
|
|||
System.out.println(obj);
|
||||
}
|
||||
|
||||
@Test //status输入有问题,序列化时读取信息出错.
|
||||
@Test //The status input has a problem, and the read information is wrong when the serialization is serialized.
|
||||
public void test_Decode_Return_Response_Error() throws IOException {
|
||||
byte[] header = new byte[]{MAGIC_HIGH, MAGIC_LOW, 2, 90, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
String errorString = "encode request data error ";
|
||||
|
|
|
|||
|
|
@ -245,14 +245,14 @@ public class TelnetCodecTest {
|
|||
|
||||
@Test
|
||||
public void testDecode_Backspace() throws IOException {
|
||||
//32 8 先加空格在补退格.
|
||||
//32 8 first add space and then add backspace.
|
||||
testDecode_assertEquals(new byte[]{'\b'}, Codec2.DecodeResult.NEED_MORE_INPUT, new String(new byte[]{32, 8}));
|
||||
|
||||
//测试中文
|
||||
// test chinese
|
||||
byte[] chineseBytes = "中".getBytes();
|
||||
byte[] request = join(chineseBytes, new byte[]{'\b'});
|
||||
testDecode_assertEquals(request, Codec2.DecodeResult.NEED_MORE_INPUT, new String(new byte[]{32, 32, 8, 8}));
|
||||
//中文会带来此问题 (-数判断) 忽略此问题,退格键只有在真的telnet程序中才输入有意义.
|
||||
//There may be some problem handling chinese (negative number recognition). Ignoring this problem, the backspace key is only meaningfully input in a real telnet program.
|
||||
testDecode_assertEquals(new byte[]{'a', 'x', -1, 'x', '\b'}, Codec2.DecodeResult.NEED_MORE_INPUT, new String(new byte[]{32, 32, 8, 8}));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,13 +62,13 @@ public class ConnectChannelHandlerTest extends WrappedChannelHandlerTest {
|
|||
Assert.assertEquals(taskCount, executor.getCompletedTaskCount());
|
||||
}
|
||||
|
||||
@Test //biz error 不抛出到线程异常上来.
|
||||
@Test //biz error should not throw and affect biz thread.
|
||||
public void test_Connect_Biz_Error() throws RemotingException {
|
||||
handler = new ConnectionOrderedChannelHandler(new BizChannelHander(true), url);
|
||||
handler.connected(new MockedChannel());
|
||||
}
|
||||
|
||||
@Test //biz error 不抛出到线程异常上来.
|
||||
@Test //biz error should not throw and affect biz thread.
|
||||
public void test_Disconnect_Biz_Error() throws RemotingException {
|
||||
handler = new ConnectionOrderedChannelHandler(new BizChannelHander(true), url);
|
||||
handler.disconnected(new MockedChannel());
|
||||
|
|
@ -113,7 +113,7 @@ public class ConnectChannelHandlerTest extends WrappedChannelHandlerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* 事件不通过线程池,直接在IO上执行
|
||||
* Events do not pass through the thread pool and execute directly on the IO
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Ignore("Heartbeat is processed in HeartbeatHandler not WrappedChannelHandler.")
|
||||
|
|
|
|||
|
|
@ -274,10 +274,10 @@ final class DeprecatedExchangeCodec extends DeprecatedTelnetCodec implements Cod
|
|||
os.write(header); // write header.
|
||||
os.write(data); // write data.
|
||||
} catch (Throwable t) {
|
||||
// 发送失败信息给Consumer,否则Consumer只能等超时了
|
||||
// send error message to Consumer, otherwise, Consumer will wait until timeout.
|
||||
if (!res.isEvent() && res.getStatus() != Response.BAD_RESPONSE) {
|
||||
try {
|
||||
// FIXME 在Codec中打印出错日志?在IoHanndler的caught中统一处理?
|
||||
// FIXME log error info in Codec and put all error handle logic in IoHanndler?
|
||||
logger.warn("Fail to encode response: " + res + ", send bad_response info instead, cause: " + t.getMessage(), t);
|
||||
|
||||
Response r = new Response(res.getId(), res.getVersion());
|
||||
|
|
@ -291,7 +291,7 @@ final class DeprecatedExchangeCodec extends DeprecatedTelnetCodec implements Cod
|
|||
}
|
||||
}
|
||||
|
||||
// 重新抛出收到的异常
|
||||
// Rethrow exception
|
||||
if (t instanceof IOException) {
|
||||
throw (IOException) t;
|
||||
} else if (t instanceof RuntimeException) {
|
||||
|
|
|
|||
|
|
@ -84,8 +84,8 @@ public class GrizzlyCodecAdapter extends BaseFilter {
|
|||
Connection<?> connection = context.getConnection();
|
||||
Channel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler);
|
||||
try {
|
||||
if (message instanceof Buffer) { // 收到新的数据包
|
||||
Buffer grizzlyBuffer = (Buffer) message; // 缓存
|
||||
if (message instanceof Buffer) { // receive a new packet
|
||||
Buffer grizzlyBuffer = (Buffer) message; // buffer
|
||||
|
||||
ChannelBuffer frame;
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ public class GrizzlyCodecAdapter extends BaseFilter {
|
|||
}
|
||||
}
|
||||
} while (frame.readable());
|
||||
} else { // 其它事件直接往下传
|
||||
} else { // Other events are passed down directly
|
||||
return context.getInvokeAction();
|
||||
}
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public class MinaClient extends AbstractClient {
|
|||
if (future.isReady()) {
|
||||
IoSession newSession = future.getSession();
|
||||
try {
|
||||
// 关闭旧的连接
|
||||
// Close old channel
|
||||
IoSession oldSession = MinaClient.this.session; // copy reference
|
||||
if (oldSession != null) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ public class NettyClient extends AbstractClient {
|
|||
Channel newChannel = future.getChannel();
|
||||
newChannel.setInterestOps(Channel.OP_READ_WRITE);
|
||||
try {
|
||||
// 关闭旧的连接
|
||||
// Close old channel
|
||||
Channel oldChannel = NettyClient.this.channel; // copy reference
|
||||
if (oldChannel != null) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public class ClientReconnectTest {
|
|||
int port = NetUtils.getAvailablePort();
|
||||
DubboAppender.doStart();
|
||||
String url = "exchange://127.0.0.2:" + port + "/client.reconnect.test?check=false&"
|
||||
+ Constants.RECONNECT_KEY + "=" + 1; //1ms reconnect,保证有足够频率的重连
|
||||
+ Constants.RECONNECT_KEY + "=" + 1; //1ms reconnect, ensure that there is enough frequency to reconnect
|
||||
try {
|
||||
Exchangers.connect(url);
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public class NettyClient extends AbstractClient {
|
|||
if (ret && future.isSuccess()) {
|
||||
Channel newChannel = future.channel();
|
||||
try {
|
||||
// 关闭旧的连接
|
||||
// Close old channel
|
||||
Channel oldChannel = NettyClient.this.channel; // copy reference
|
||||
if (oldChannel != null) {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue