forked from alibaba/nacos
-
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.
- Loading branch information
Showing
18 changed files
with
156 additions
and
112 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
17 changes: 17 additions & 0 deletions
17
api/src/main/java/com/alibaba/nacos/api/selector/AbstractSelector.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,17 @@ | ||
package com.alibaba.nacos.api.selector; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">nkorange</a> | ||
*/ | ||
public abstract class AbstractSelector { | ||
|
||
private String type; | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
api/src/main/java/com/alibaba/nacos/api/selector/SelectorType.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,19 @@ | ||
package com.alibaba.nacos.api.selector; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">nkorange</a> | ||
*/ | ||
public enum SelectorType { | ||
/** | ||
* not match any type | ||
*/ | ||
unknown, | ||
/** | ||
* not filter out | ||
*/ | ||
none, | ||
/** | ||
* select by label | ||
*/ | ||
label | ||
} |
9 changes: 9 additions & 0 deletions
9
api/src/main/java/com/alibaba/nacos/api/selector/label/ExpressionBuilder.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,9 @@ | ||
package com.alibaba.nacos.api.selector.label; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">nkorange</a> | ||
*/ | ||
public class ExpressionBuilder { | ||
|
||
|
||
} |
27 changes: 27 additions & 0 deletions
27
api/src/main/java/com/alibaba/nacos/api/selector/label/LabelSelector.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,27 @@ | ||
package com.alibaba.nacos.api.selector.label; | ||
|
||
import com.alibaba.nacos.api.selector.AbstractSelector; | ||
import com.alibaba.nacos.api.selector.SelectorType; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">nkorange</a> | ||
*/ | ||
public class LabelSelector extends AbstractSelector { | ||
|
||
/** | ||
* Label expression of this selector. | ||
*/ | ||
private String expression; | ||
|
||
public LabelSelector() { | ||
this.setType(SelectorType.label.name()); | ||
} | ||
|
||
public String getExpression() { | ||
return expression; | ||
} | ||
|
||
public void setExpression(String expression) { | ||
this.expression = expression; | ||
} | ||
} |
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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
|
||
|
||
import com.alibaba.nacos.api.cmdb.pojo.PreservedEntityTypes; | ||
import com.alibaba.nacos.api.selector.SelectorType; | ||
import com.alibaba.nacos.cmdb.service.CmdbReader; | ||
import com.alibaba.nacos.naming.boot.SpringContext; | ||
import com.alibaba.nacos.naming.core.IpAddress; | ||
|
@@ -52,7 +53,7 @@ | |
* @author <a href="mailto:[email protected]">nkorange</a> | ||
* @see CmdbReader | ||
*/ | ||
public class LabelSelector extends AbstractSelector { | ||
public class LabelSelector extends com.alibaba.nacos.api.selector.label.LabelSelector implements Selector { | ||
|
||
private CmdbReader cmdbReader; | ||
|
||
|
@@ -63,17 +64,6 @@ public class LabelSelector extends AbstractSelector { | |
*/ | ||
private Set<String> labels; | ||
|
||
/** | ||
* Label expression of this selector. | ||
* <p> | ||
* Currently we only support this very single type of expression: | ||
* <pre> | ||
* consumer.labelA = provider.labelA & consumer.labelB = provider.labelB | ||
* </pre> | ||
* TODO what this expression means? | ||
*/ | ||
private String expression; | ||
|
||
private static final Set<String> SUPPORTED_INNER_CONNCETORS = new HashSet<>(); | ||
|
||
private static final Set<String> SUPPORTED_OUTER_CONNCETORS = new HashSet<>(); | ||
|
@@ -95,15 +85,8 @@ public void setLabels(Set<String> labels) { | |
this.labels = labels; | ||
} | ||
|
||
public String getExpression() { | ||
return expression; | ||
} | ||
|
||
public void setExpression(String expression) { | ||
this.expression = expression; | ||
} | ||
|
||
public LabelSelector() { | ||
setType(SelectorType.label.name()); | ||
ApplicationContext context = SpringContext.getAppContext(); | ||
cmdbReader = context.getBean(CmdbReader.class); | ||
} | ||
|
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 |
---|---|---|
|
@@ -15,14 +15,15 @@ | |
*/ | ||
package com.alibaba.nacos.naming.selector; | ||
|
||
import com.alibaba.nacos.api.selector.SelectorType; | ||
import com.alibaba.nacos.naming.core.IpAddress; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">nkorange</a> | ||
*/ | ||
public class NoneSelector extends AbstractSelector { | ||
public class NoneSelector extends com.alibaba.nacos.api.selector.AbstractSelector implements Selector { | ||
|
||
public NoneSelector() { | ||
this.setType(SelectorType.none.name()); | ||
|
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 |
---|---|---|
|
@@ -32,23 +32,17 @@ | |
* recognizes it and can correctly create this type of selector. | ||
* | ||
* @author <a href="mailto:[email protected]">nkorange</a> | ||
* @see SelectorType | ||
* @see com.alibaba.nacos.api.selector.SelectorType | ||
* @see SelectorJsonAdapter | ||
*/ | ||
public abstract class AbstractSelector { | ||
public interface Selector { | ||
|
||
/** | ||
* @see SelectorType | ||
* Get the type of this selector | ||
* | ||
* @return type of selector | ||
*/ | ||
protected String type = "unknown"; | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
String getType(); | ||
|
||
/** | ||
* Select qualified instances from providers | ||
|
@@ -57,5 +51,5 @@ public void setType(String type) { | |
* @param providers candidate provider addresses | ||
* @return selected provider addresses | ||
*/ | ||
public abstract List<IpAddress> select(String consumer, List<IpAddress> providers); | ||
List<IpAddress> select(String consumer, List<IpAddress> providers); | ||
} |
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
32 changes: 0 additions & 32 deletions
32
naming/src/main/java/com/alibaba/nacos/naming/selector/SelectorType.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.