Skip to content

Commit

Permalink
apache#1067: I18N effort for dubbo code base - dubbo-rpc (part12)
Browse files Browse the repository at this point in the history
  • Loading branch information
beiwei30 committed Dec 21, 2017
1 parent 611617c commit 0718389
Show file tree
Hide file tree
Showing 15 changed files with 235 additions and 180 deletions.
27 changes: 14 additions & 13 deletions dubbo-rpc/dubbo-rpc-thrift/pom.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<!--
- Copyright 1999-2011 Alibaba Group.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT 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/maven-v4_0_0.xsd">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
/**
* File Created at 2012-02-02
* $Id$
* <p>
* Copyright 2008 Alibaba.com Croporation Limited.
* All rights reserved.
* <p>
* This software is the confidential and proprietary information of
* Alibaba Company. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Alibaba.com.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.dubbo.rpc.protocol.thrift;

import com.alibaba.dubbo.common.extension.SPI;

/**
* @author <a href="mailto:[email protected]">kimi</a>
*/
@SPI(DubboClassNameGenerator.NAME)
public interface ClassNameGenerator {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/**
* File Created at 2012-02-02
* $Id$
* <p>
* Copyright 2008 Alibaba.com Croporation Limited.
* All rights reserved.
* <p>
* This software is the confidential and proprietary information of
* Alibaba Company. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Alibaba.com.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.dubbo.rpc.protocol.thrift;

/**
* @author <a href="mailto:[email protected]">kimi</a>
*/
public class DubboClassNameGenerator implements ClassNameGenerator {

public static final String NAME = "dubbo";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/**
* File Created at 2012-02-02
* $Id$
* <p>
* Copyright 2008 Alibaba.com Croporation Limited.
* All rights reserved.
* <p>
* This software is the confidential and proprietary information of
* Alibaba Company. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Alibaba.com.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.dubbo.rpc.protocol.thrift;

/**
* @author <a href="mailto:[email protected]">kimi</a>
*/
public class ThriftClassNameGenerator implements ClassNameGenerator {

public static final String NAME = "thrift";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
/**
* File Created at 2011-12-05
* $Id$
* <p>
* Copyright 2008 Alibaba.com Croporation Limited.
* All rights reserved.
* <p>
* This software is the confidential and proprietary information of
* Alibaba Company. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Alibaba.com.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.dubbo.rpc.protocol.thrift;

Expand Down Expand Up @@ -68,8 +71,6 @@
* <li>long - dubbo request id</li>
* </ol>
* </p>
*
* @author <a href="mailto:[email protected]">gang.lvg</a>
*/
public class ThriftCodec implements Codec2 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +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 com.alibaba.dubbo.rpc.protocol.thrift;

/**
* @author <a href="mailto:[email protected]">kimi</a>
*/
public final class ThriftConstants {

public static final String THRIFT_PROTOCOL_KEY = "thrift.protocol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
/**
* File Created at 2011-12-06
* $Id$
* <p>
* Copyright 2008 Alibaba.com Croporation Limited.
* All rights reserved.
* <p>
* This software is the confidential and proprietary information of
* Alibaba Company. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Alibaba.com.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.dubbo.rpc.protocol.thrift;

Expand All @@ -30,10 +33,6 @@
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;


/**
* @author <a href="mailto:[email protected]">gang.lvg</a>
*/
public class ThriftInvoker<T> extends AbstractInvoker<T> {

private final ExchangeClient[] clients;
Expand Down Expand Up @@ -113,11 +112,13 @@ public boolean isAvailable() {
}

public void destroy() {
//防止client被关闭多次.在connect per jvm的情况下,client.close方法会调用计数器-1,当计数器小于等于0的情况下,才真正关闭
// in order to avoid closing a client multiple times, a counter is used in case of connection per jvm, every
// time when client.close() is called, counter counts down once, and when counter reaches zero, client will be
// closed.
if (super.isDestroyed()) {
return;
} else {
//dubbo check ,避免多次关闭
// double check to avoid dup close
destroyLock.lock();

try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.dubbo.rpc.protocol.thrift;

import com.alibaba.dubbo.common.URL;
Expand All @@ -20,9 +36,6 @@
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;

/**
* @author <a href="mailto:[email protected]">kimi</a>
*/
public class ThriftNativeCodec implements Codec2 {

private final AtomicInteger thriftSeq = new AtomicInteger(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
/**
* File Created at 2011-12-06
* $Id$
* <p>
* Copyright 2008 Alibaba.com Croporation Limited.
* All rights reserved.
* <p>
* This software is the confidential and proprietary information of
* Alibaba Company. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Alibaba.com.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.dubbo.rpc.protocol.thrift;

Expand Down Expand Up @@ -38,9 +41,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
* @author <a href="mailto:[email protected]">gang.lvg</a>
*/
public class ThriftProtocol extends AbstractProtocol {

public static final int DEFAULT_PORT = 40880;
Expand Down Expand Up @@ -107,11 +107,11 @@ public int getDefaultPort() {

public <T> Exporter<T> export(Invoker<T> invoker) throws RpcException {

// 只能使用 thrift codec
// can use thrift codec only
URL url = invoker.getUrl().addParameter(Constants.CODEC_KEY, ThriftCodec.NAME);
// find server.
String key = url.getAddress();
//client 也可以暴露一个只有server可以调用的服务。
// client can expose a service for server to invoke only.
boolean isServer = url.getParameter(Constants.IS_SERVER_KEY, true);
if (isServer && !serverMap.containsKey(key)) {
serverMap.put(key, getServer(url));
Expand Down Expand Up @@ -187,7 +187,7 @@ private ExchangeClient initClient(URL url) {
}

private ExchangeServer getServer(URL url) {
//默认开启server关闭时发送readonly事件
// enable sending readonly event when server closes by default
url = url.addParameterIfAbsent(Constants.CHANNEL_READONLYEVENT_SENT_KEY, Boolean.TRUE.toString());
String str = url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_SERVER);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +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 com.alibaba.dubbo.rpc.protocol.thrift;

import java.util.HashMap;
import java.util.Map;

/**
* @author <a href="mailto:[email protected]">kimi</a>
*/
public enum ThriftType {

BOOL, BYTE, I16, I32, I64, DOUBLE, STRING;
Expand Down
Loading

0 comments on commit 0718389

Please sign in to comment.