mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-14 22:43:57 +00:00
added wildcard logic stuff and deleted duplicate function
This commit is contained in:
1 parent
c4cb25361e
commit
dec620beb3
1 file changed
+21
-8
+21
-8
@@ -15,10 +15,31 @@ public class ShardingRulePathConditionBuilder<ShardingKey> implements Builder<Sh
|
||||
{"*/api/*/v?/regattas/", ""}, //3
|
||||
{"*/api/*/v?/regattas/","/*"} //4
|
||||
};
|
||||
private static char[] wildcards = {'*', '?'};
|
||||
public static int numberOfShardConditionsPerShard() {
|
||||
return patterns.length;
|
||||
}
|
||||
|
||||
|
||||
//expects an entry like patterns
|
||||
static public int countOfWildcards(String pattern) {
|
||||
int nrOfWildcards = 0;
|
||||
for(char wildcard : wildcards) {
|
||||
nrOfWildcards += countChars(pattern, wildcard);
|
||||
}
|
||||
return nrOfWildcards;
|
||||
}
|
||||
|
||||
static public int countChars(String s, char x) {
|
||||
int count = 0;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (s.charAt(i) == x) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public static String unsedPathConditionValue = "gwt/*/leaderboard/lauycaluy3cla3yrclaurlIYQL8";
|
||||
|
||||
|
||||
@@ -59,14 +80,6 @@ public class ShardingRulePathConditionBuilder<ShardingKey> implements Builder<Sh
|
||||
return ruleConditions;
|
||||
}
|
||||
|
||||
protected Collection<RuleCondition> getPathConditionsForOneShardingKey(ShardingKey shardingKey) throws InterruptedException, ExecutionException {
|
||||
final Collection<RuleCondition> ruleConditions = new ArrayList<>();
|
||||
final Collection<String> paths = getPathsForShardingKey(shardingKey);
|
||||
ruleConditions.add(
|
||||
RuleCondition.builder().field("path-pattern").pathPatternConfig(hhcb -> hhcb.values(paths)).build());
|
||||
return ruleConditions;
|
||||
}
|
||||
|
||||
// returns every required path condition
|
||||
Collection<String> getPathsForShardingKey(ShardingKey shardingKey) {
|
||||
ArrayList<String> c = new ArrayList<>();
|
||||
|
||||
Reference in new issue
Block a user