-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use multiple separate counters for the single service with multiple protocols. #222
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a9c0cec
fix multi protol publish
leizhiyuan 78d43c5
Merge branch '5.4' into fix_multi_protocol
leizhiyuan 7c69887
fix multi protol unpublish
leizhiyuan f02102f
fix: optimize exception process
leizhiyuan 9f335cf
fix: multi protol unpublish
leizhiyuan 83896a9
Merge branch '5.4' into fix_multi_protocol
ujjboy 78d59f9
fix: multi protol unpublish
leizhiyuan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
78 changes: 78 additions & 0 deletions
78
...est-integration/src/test/java/com/alipay/sofa/rpc/server/multi/MultiProtolServerTest.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 |
---|---|---|
@@ -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 com.alipay.sofa.rpc.server.multi; | ||
|
||
import com.alipay.sofa.rpc.common.RpcConstants; | ||
import com.alipay.sofa.rpc.config.ProviderConfig; | ||
import com.alipay.sofa.rpc.config.ServerConfig; | ||
import com.alipay.sofa.rpc.context.RpcRuntimeContext; | ||
import com.alipay.sofa.rpc.server.rest.RestService; | ||
import com.alipay.sofa.rpc.server.rest.RestServiceImpl; | ||
import com.alipay.sofa.rpc.test.ActivelyDestroyTest; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
/** | ||
* @author <a href="mailto:zhanggeng.zg@antfin.com">GengZhang</a> | ||
*/ | ||
public class MultiProtolServerTest extends ActivelyDestroyTest { | ||
|
||
@Test | ||
public void testAll() { | ||
testMultiProtol(); | ||
RpcRuntimeContext.destroy(); | ||
} | ||
|
||
public void testMultiProtol() { | ||
|
||
try { | ||
// 只有2个线程 执行 | ||
ServerConfig serverConfig = new ServerConfig() | ||
.setStopTimeout(0) | ||
.setPort(22222) | ||
.setProtocol(RpcConstants.PROTOCOL_TYPE_BOLT) | ||
.setQueues(100).setCoreThreads(1).setMaxThreads(2); | ||
|
||
// 发布一个服务,每个请求要执行1秒 | ||
ProviderConfig<RestService> providerConfig = new ProviderConfig<RestService>() | ||
.setInterfaceId(RestService.class.getName()) | ||
.setRef(new RestServiceImpl()) | ||
.setServer(serverConfig) | ||
.setRepeatedExportLimit(1) | ||
.setRegister(false); | ||
providerConfig.export(); | ||
|
||
ServerConfig serverConfig2 = new ServerConfig() | ||
.setStopTimeout(0) | ||
.setPort(22223) | ||
.setProtocol(RpcConstants.PROTOCOL_TYPE_REST) | ||
.setQueues(100).setCoreThreads(1).setMaxThreads(2); | ||
|
||
// 发布一个服务,每个请求要执行1秒 | ||
ProviderConfig<RestService> providerConfig2 = new ProviderConfig<RestService>() | ||
.setInterfaceId(RestService.class.getName()) | ||
.setRef(new RestServiceImpl()) | ||
.setServer(serverConfig2) | ||
.setRepeatedExportLimit(1) | ||
.setRegister(false); | ||
providerConfig2.export(); | ||
} catch (Throwable e) { | ||
Assert.fail(); | ||
} | ||
|
||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里应该记录下已经增加的计数器,而不是全部计数器。 例如发布A、B、C协议,发到 B 的时候失败,应该只需要减去 A 的计数器即可,B 和 C 的计数器都不需要减。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个抛出异常的时候,比较难记录.. register();因为这行代码可能跑错.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果
register()
抛错, 那说明 A B C 都发布完了。 我举的例子应该是还在发 B 协议的时候。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改掉了.