forked from apache/dubbo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apache#1067: I18N effort for dubbo code base - dubbo-rpc (part12)
- Loading branch information
Showing
15 changed files
with
235 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 15 additions & 15 deletions
30
...bo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ClassNameGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
|
||
|
30 changes: 15 additions & 15 deletions
30
...c-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/DubboClassNameGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
|
30 changes: 15 additions & 15 deletions
30
...-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftClassNameGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
|
@@ -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 { | ||
|
||
|
19 changes: 16 additions & 3 deletions
19
...dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
|
@@ -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; | ||
|
@@ -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 { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
@@ -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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
|
@@ -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; | ||
|
@@ -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)); | ||
|
@@ -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); | ||
|
||
|
19 changes: 16 additions & 3 deletions
19
...-rpc/dubbo-rpc-thrift/src/main/java/com/alibaba/dubbo/rpc/protocol/thrift/ThriftType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
Oops, something went wrong.