-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Polish Dubbo 2.6.x adapter #1572
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 hidden or 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
This file contains hidden or 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
108 changes: 108 additions & 0 deletions
108
...dapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/DubboAdapterGlobalConfig.java
This file contains hidden or 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,108 @@ | ||
| /* | ||
| * Copyright 1999-2018 Alibaba Group Holding Ltd. | ||
| * | ||
| * 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. | ||
| */ | ||
| package com.alibaba.csp.sentinel.adapter.dubbo; | ||
|
|
||
| import com.alibaba.csp.sentinel.adapter.dubbo.fallback.DefaultDubboFallback; | ||
| import com.alibaba.csp.sentinel.adapter.dubbo.fallback.DubboFallback; | ||
| import com.alibaba.csp.sentinel.adapter.dubbo.origin.DefaultDubboOriginParser; | ||
| import com.alibaba.csp.sentinel.adapter.dubbo.origin.DubboOriginParser; | ||
| import com.alibaba.csp.sentinel.config.SentinelConfig; | ||
| import com.alibaba.csp.sentinel.util.AssertUtil; | ||
| import com.alibaba.csp.sentinel.util.StringUtil; | ||
|
|
||
| /** | ||
| * <p>Global config and callback registry of Dubbo legacy adapter.</p> | ||
| * | ||
| * @author lianglin | ||
| * @author Eric Zhao | ||
| * @since 1.7.0 | ||
| */ | ||
| public final class DubboAdapterGlobalConfig { | ||
|
|
||
| private static final String TRUE_STR = "true"; | ||
|
|
||
| public static final String DUBBO_RES_NAME_WITH_PREFIX_KEY = "csp.sentinel.dubbo.resource.use.prefix"; | ||
| public static final String DUBBO_PROVIDER_RES_NAME_PREFIX_KEY = "csp.sentinel.dubbo.resource.provider.prefix"; | ||
| public static final String DUBBO_CONSUMER_RES_NAME_PREFIX_KEY = "csp.sentinel.dubbo.resource.consumer.prefix"; | ||
|
|
||
| private static final String DEFAULT_DUBBO_PROVIDER_PREFIX = "dubbo:provider:"; | ||
| private static final String DEFAULT_DUBBO_CONSUMER_PREFIX = "dubbo:consumer:"; | ||
|
|
||
| private static volatile DubboFallback consumerFallback = new DefaultDubboFallback(); | ||
| private static volatile DubboFallback providerFallback = new DefaultDubboFallback(); | ||
| private static volatile DubboOriginParser originParser = new DefaultDubboOriginParser(); | ||
|
|
||
| public static boolean isUsePrefix() { | ||
| return TRUE_STR.equalsIgnoreCase(SentinelConfig.getConfig(DUBBO_RES_NAME_WITH_PREFIX_KEY)); | ||
| } | ||
|
|
||
| public static String getDubboProviderPrefix() { | ||
| if (isUsePrefix()) { | ||
| String config = SentinelConfig.getConfig(DUBBO_PROVIDER_RES_NAME_PREFIX_KEY); | ||
| return StringUtil.isNotBlank(config) ? config : DEFAULT_DUBBO_PROVIDER_PREFIX; | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| public static String getDubboConsumerPrefix() { | ||
| if (isUsePrefix()) { | ||
| String config = SentinelConfig.getConfig(DUBBO_CONSUMER_RES_NAME_PREFIX_KEY); | ||
| return StringUtil.isNotBlank(config) ? config : DEFAULT_DUBBO_CONSUMER_PREFIX; | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| public static DubboFallback getConsumerFallback() { | ||
| return consumerFallback; | ||
| } | ||
|
|
||
| public static void setConsumerFallback(DubboFallback consumerFallback) { | ||
| AssertUtil.notNull(consumerFallback, "consumerFallback cannot be null"); | ||
| DubboAdapterGlobalConfig.consumerFallback = consumerFallback; | ||
| } | ||
|
|
||
| public static DubboFallback getProviderFallback() { | ||
| return providerFallback; | ||
| } | ||
|
|
||
| public static void setProviderFallback(DubboFallback providerFallback) { | ||
| AssertUtil.notNull(providerFallback, "providerFallback cannot be null"); | ||
| DubboAdapterGlobalConfig.providerFallback = providerFallback; | ||
| } | ||
|
|
||
| /** | ||
| * Get the origin parser of Dubbo adapter. | ||
| * | ||
| * @return the origin parser | ||
| * @since 1.8.0 | ||
| */ | ||
| public static DubboOriginParser getOriginParser() { | ||
| return originParser; | ||
| } | ||
|
|
||
| /** | ||
| * Set the origin parser of Dubbo adapter. | ||
| * | ||
| * @param originParser the origin parser | ||
| * @since 1.8.0 | ||
| */ | ||
| public static void setOriginParser(DubboOriginParser originParser) { | ||
| AssertUtil.notNull(originParser, "originParser cannot be null"); | ||
| DubboAdapterGlobalConfig.originParser = originParser; | ||
| } | ||
|
|
||
| private DubboAdapterGlobalConfig() {} | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
62 changes: 0 additions & 62 deletions
62
...ubbo-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/dubbo/config/DubboConfig.java
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.