-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Make the slot as the SPI interface and add a @Order annotation for define slot order #411
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b89be2c
Merge from master and use @SpiOrder and SpiLoader.loadInstanceListSor…
cdfive 7029867
Merge from master and fix conflicts
cdfive 7f228af
Merge remote-tracking branch 'Sentinel/master' into enhancement/slot-…
cdfive 3331aa8
Fix conflicts and some improvement
cdfive f9cd3df
Make GatewayFlowSlot loaded by SPI, mark all slots with @SpiOrder fro…
cdfive ce0797b
Fix SpiLoaderTest test cases
cdfive b5925b8
Reserved gateway and hot param slot chain builder and mark them as @D…
cdfive 68be55c
Keep GatewaySlotChainBuilder,HotParamSlotChainBuilder class empty and…
cdfive 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
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
1 change: 1 addition & 0 deletions
1
...mon/src/main/resources/META-INF/services/com.alibaba.csp.sentinel.slotchain.ProcessorSlot
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 @@ | ||
com.alibaba.csp.sentinel.adapter.gateway.common.slot.GatewayFlowSlot |
1 change: 0 additions & 1 deletion
1
.../src/main/resources/META-INF/services/com.alibaba.csp.sentinel.slotchain.SlotChainBuilder
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
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
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
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
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
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
9 changes: 9 additions & 0 deletions
9
...ore/src/main/resources/META-INF/services/com.alibaba.csp.sentinel.slotchain.ProcessorSlot
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,9 @@ | ||
# Sentinel default ProcessorSlots | ||
com.alibaba.csp.sentinel.slots.nodeselector.NodeSelectorSlot | ||
com.alibaba.csp.sentinel.slots.clusterbuilder.ClusterBuilderSlot | ||
com.alibaba.csp.sentinel.slots.logger.LogSlot | ||
com.alibaba.csp.sentinel.slots.statistic.StatisticSlot | ||
com.alibaba.csp.sentinel.slots.system.SystemSlot | ||
com.alibaba.csp.sentinel.slots.block.authority.AuthoritySlot | ||
com.alibaba.csp.sentinel.slots.block.flow.FlowSlot | ||
com.alibaba.csp.sentinel.slots.block.degrade.DegradeSlot |
89 changes: 89 additions & 0 deletions
89
sentinel-core/src/test/java/com/alibaba/csp/sentinel/slots/DefaultSlotChainBuilderTest.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,89 @@ | ||
/* | ||
* 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.slots; | ||
|
||
import com.alibaba.csp.sentinel.slotchain.AbstractLinkedProcessorSlot; | ||
import com.alibaba.csp.sentinel.slotchain.ProcessorSlotChain; | ||
import com.alibaba.csp.sentinel.slots.block.authority.AuthoritySlot; | ||
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeSlot; | ||
import com.alibaba.csp.sentinel.slots.block.flow.FlowSlot; | ||
import com.alibaba.csp.sentinel.slots.clusterbuilder.ClusterBuilderSlot; | ||
import com.alibaba.csp.sentinel.slots.logger.LogSlot; | ||
import com.alibaba.csp.sentinel.slots.nodeselector.NodeSelectorSlot; | ||
import com.alibaba.csp.sentinel.slots.statistic.StatisticSlot; | ||
import com.alibaba.csp.sentinel.slots.system.SystemSlot; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Test cases for {@link DefaultSlotChainBuilder}. | ||
* | ||
* @author cdfive | ||
*/ | ||
public class DefaultSlotChainBuilderTest { | ||
|
||
@Test | ||
public void testBuild() { | ||
DefaultSlotChainBuilder builder = new DefaultSlotChainBuilder(); | ||
ProcessorSlotChain slotChain = builder.build(); | ||
assertNotNull(slotChain); | ||
|
||
// Verify the order of slot | ||
AbstractLinkedProcessorSlot<?> next = slotChain.getNext(); | ||
assertTrue(next instanceof NodeSelectorSlot); | ||
|
||
// Store the first NodeSelectorSlot instance | ||
NodeSelectorSlot nodeSelectorSlot = (NodeSelectorSlot) next; | ||
|
||
next = next.getNext(); | ||
assertTrue(next instanceof ClusterBuilderSlot); | ||
|
||
next = next.getNext(); | ||
assertTrue(next instanceof LogSlot); | ||
|
||
next = next.getNext(); | ||
assertTrue(next instanceof StatisticSlot); | ||
|
||
next = next.getNext(); | ||
assertTrue(next instanceof AuthoritySlot); | ||
|
||
next = next.getNext(); | ||
assertTrue(next instanceof SystemSlot); | ||
|
||
next = next.getNext(); | ||
assertTrue(next instanceof FlowSlot); | ||
|
||
next = next.getNext(); | ||
assertTrue(next instanceof DegradeSlot); | ||
|
||
next = next.getNext(); | ||
assertNull(next); | ||
|
||
// Build again to verify different instances | ||
ProcessorSlotChain slotChain2 = builder.build(); | ||
assertNotNull(slotChain2); | ||
// Verify the two ProcessorSlotChain instances are different | ||
assertNotSame(slotChain, slotChain2); | ||
|
||
next = slotChain2.getNext(); | ||
assertTrue(next instanceof NodeSelectorSlot); | ||
// Store the second NodeSelectorSlot instance | ||
NodeSelectorSlot nodeSelectorSlot2 = (NodeSelectorSlot) next; | ||
// Verify the two NodeSelectorSlot instances are different | ||
assertNotSame(nodeSelectorSlot, nodeSelectorSlot2); | ||
} | ||
} |
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.
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.
Oh if you take my advice keeping an empty legacy one you should make it a real EMPTY one.
According to the new
DefaultSlotChainBuilder
i think there is no need keeping overriding ofbuild()
here, right?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.
I'm sorry for misunderstanding the point.It has been fixed, please check.