mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-23 14:08:40 +00:00
debuging
This commit is contained in:
+3
-2
@@ -2069,14 +2069,15 @@ public class AwsLandscapeImpl<ShardingKey> implements AwsLandscape<ShardingKey>
|
||||
@Override
|
||||
public <MetricsT extends ApplicationProcessMetrics, ProcessT extends AwsApplicationProcess<ShardingKey, MetricsT, ProcessT>>
|
||||
String createAutoScalingGroupFromExisting(AwsAutoScalingGroup autoScalingParent,
|
||||
String shardName, TargetGroup<ShardingKey> targetGroup,int minSize, Optional<Tags> tags) {
|
||||
String shardName, TargetGroup<ShardingKey> targetGroup, int minSize, Optional<Tags> tags) {
|
||||
final AutoScalingClient autoScalingClient = getAutoScalingClient(getRegion(autoScalingParent.getRegion()));
|
||||
final String launchConfigurationName = autoScalingParent.getAutoScalingGroup().launchConfigurationName();
|
||||
final String autoScalingGroupName = getAutoScalingGroupName(shardName);
|
||||
final List<String> availabilityZones = autoScalingParent.getAutoScalingGroup().availabilityZones();
|
||||
final int instanceWarmupTimeInSeconds = autoScalingParent.getAutoScalingGroup().defaultInstanceWarmup() != null ? autoScalingParent.getAutoScalingGroup().defaultInstanceWarmup() : 180 ;
|
||||
logger.info(
|
||||
"Creating Autoscalinggroup " + autoScalingGroupName +" for Shard "+shardName + ". Inheriting from Autoscalinggroup: " + autoScalingParent.getName() + ". Starting with " + minSize + " instances.");
|
||||
"Creating Auto-Scaling Group " + autoScalingGroupName +" for Shard "+shardName + ". Inheriting from Auto-Scalinggroup: " +
|
||||
autoScalingParent.getName() + ". Starting with " + minSize + " instances.");
|
||||
autoScalingClient.createAutoScalingGroup(b->{
|
||||
b
|
||||
.minSize(minSize)
|
||||
|
||||
+5
-2
@@ -19,6 +19,9 @@ public class ShardingRulePathConditionBuilder<ShardingKey> implements Builder<Sh
|
||||
return patterns.length;
|
||||
}
|
||||
|
||||
public static String unsedPathConditionValue = "gwt/*/leaderboard/lauycaluy3cla3yrclaurlIYQL8";
|
||||
|
||||
|
||||
public static String getShardingKeyFromCondition(String condition) {
|
||||
for (int i = 0;i < patterns.length; i++) {
|
||||
if (condition.startsWith(patterns[i][0]) && condition.endsWith(patterns[i][1])) {
|
||||
@@ -33,7 +36,7 @@ public class ShardingRulePathConditionBuilder<ShardingKey> implements Builder<Sh
|
||||
int idxLastSlash = condition.lastIndexOf('/');
|
||||
return condition.substring(condition.lastIndexOf('/', idxLastSlash - 1) + 1, condition.lastIndexOf('/'));
|
||||
default:
|
||||
throw new IllegalArgumentException(condition + " matches an pattern but no case has been assiged to it's index!");
|
||||
throw new IllegalArgumentException(condition + " matches pattern " + i + " but there is no case for extracting the Shardingkey it!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,7 +55,7 @@ public class ShardingRulePathConditionBuilder<ShardingKey> implements Builder<Sh
|
||||
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());
|
||||
RuleCondition.builder().field("path-pattern").values(paths).build());
|
||||
return ruleConditions;
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -64,9 +64,7 @@ public class AddShardingKeyToShard<ShardingKey, MetricsT extends ApplicationProc
|
||||
logger.info("Appending " + Util.joinStrings(", ", shardingKeys) + " to " + shardName);
|
||||
final TargetGroup<ShardingKey> targetgroup = shard.getTargetGroup();
|
||||
final ApplicationLoadBalancer<ShardingKey> loadBalancer = shard.getLoadBalancer();
|
||||
// final Collection<TargetGroup<ShardingKey>> t = new ArrayList<>();
|
||||
// t.add(targetgroup);
|
||||
|
||||
// building every condition for every shardingkey
|
||||
ArrayList<RuleCondition> ruleConditionToBeInserted = new ArrayList<>();
|
||||
for (ShardingKey k : shardingKeys) {
|
||||
ruleConditionToBeInserted.addAll((new ShardingRulePathConditionBuilder<>().ShardingKey(k).build()));
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@ import com.sap.sse.landscape.aws.AwsAutoScalingGroup;
|
||||
import com.sap.sse.landscape.aws.AwsInstance;
|
||||
import com.sap.sse.landscape.aws.TargetGroup;
|
||||
import com.sap.sse.landscape.aws.common.shared.ShardTargetGroupName;
|
||||
import com.sap.sse.landscape.aws.impl.ShardingRulePathConditionBuilder;
|
||||
import com.sap.sse.shared.util.Wait;
|
||||
|
||||
import software.amazon.awssdk.services.elasticloadbalancingv2.model.Action;
|
||||
@@ -130,7 +131,7 @@ public class CreateShard<ShardingKey, MetricsT extends ApplicationProcessMetrics
|
||||
.getB()))
|
||||
.build(),
|
||||
RuleCondition.builder().field("path-pattern")
|
||||
.pathPatternConfig(ppc -> ppc.values(getPathConditionForShardingKey(SHARDING_KEY_UNUSED_BY_ANY_APPLICATION))).build())
|
||||
.pathPatternConfig(ppc -> ppc.values(ShardingRulePathConditionBuilder.unsedPathConditionValue)).build())
|
||||
.actions(Action.builder()
|
||||
.forwardConfig(ForwardActionConfig.builder()
|
||||
.targetGroups(TargetGroupTuple.builder()
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package com.sap.sse.landscape.aws.orchestration;
|
||||
|
||||
public class RulesTests {
|
||||
|
||||
}
|
||||
+22
-29
@@ -196,29 +196,37 @@ implements ProcedureCreatingLoadBalancerMapping<ShardingKey> {
|
||||
}
|
||||
|
||||
/**
|
||||
* This function constructs a number of new rules for given {@code ruleConditions}.
|
||||
* They are constructed by creating rules and filling them with those conditions and the needed sharding rules.
|
||||
* And the forward to {@code targetgroup} gets also added.
|
||||
* @param ruleConditions are all condition, e.g. "paths", which are planned to be inserted.
|
||||
* @param alb Automatic loadbalancer where these rules are planned to be added
|
||||
* @param targetGroup targetgroup where the forward of the rule points to
|
||||
* @return all created rules which still need to be fed into the loadbalancer
|
||||
* @throws Exception
|
||||
* This function constructs a number of new rules for given {@code ruleConditions}. They are constructed by creating
|
||||
* rules and filling them with those conditions and the needed sharding (hostname and forward to replica) rules. And
|
||||
* the forward to {@code targetGroup} gets also added.
|
||||
*
|
||||
* @param ruleConditions
|
||||
* are all condition, e.g. "paths", which are planned to be inserted.
|
||||
* @param alb
|
||||
* automatic loadBalancer where these rules are planned to be added
|
||||
* @param targetGroup
|
||||
* targetGroup where the forward of the rule points to
|
||||
* @return all created rules which still need to be fed into the loadBalancer
|
||||
* @throws Exception
|
||||
*/
|
||||
protected Iterable<Rule> addNewRulesFromPathConditions(Iterable<RuleCondition> ruleConditions, ApplicationLoadBalancer<ShardingKey> alb, TargetGroup<ShardingKey> targetGroup) throws Exception{
|
||||
protected Iterable<Rule> addNewRulesFromPathConditions(Iterable<RuleCondition> ruleConditions,
|
||||
ApplicationLoadBalancer<ShardingKey> alb, TargetGroup<ShardingKey> targetGroup) throws Exception {
|
||||
final ArrayList<Rule> rules = new ArrayList<>();
|
||||
final int ruleIdx = alb.getFirstShardingPriority(replicaSet.getHostname());
|
||||
final Set<RuleCondition> ruleConditionsForConsumption = new HashSet<>();
|
||||
Util.addAll(ruleConditions, ruleConditionsForConsumption);
|
||||
while (!ruleConditionsForConsumption.isEmpty()) {
|
||||
LoadBalancerRuleInserter.create(alb, ApplicationLoadBalancer.MAX_PRIORITY, ApplicationLoadBalancer.MAX_RULES_PER_LOADBALANCER).shiftRulesToMakeSpaceAt(ruleIdx, 1);
|
||||
LoadBalancerRuleInserter.create(alb, ApplicationLoadBalancer.MAX_PRIORITY,
|
||||
ApplicationLoadBalancer.MAX_RULES_PER_LOADBALANCER).shiftRulesToMakeSpaceAt(ruleIdx, 1);
|
||||
final Collection<RuleCondition> conditionsForNextRule = new ArrayList<>();
|
||||
for (final Iterator<RuleCondition> i=ruleConditionsForConsumption.iterator();
|
||||
conditionsForNextRule.size() < ApplicationLoadBalancer.MAX_CONDITIONS_PER_RULE-NUMBER_OF_STANDARD_CONDITIONS_FOR_SHARDING_RULE && i.hasNext(); ) {
|
||||
for (final Iterator<RuleCondition> i = ruleConditionsForConsumption.iterator(); conditionsForNextRule
|
||||
.size() < ApplicationLoadBalancer.MAX_CONDITIONS_PER_RULE
|
||||
- NUMBER_OF_STANDARD_CONDITIONS_FOR_SHARDING_RULE
|
||||
&& i.hasNext();) {
|
||||
conditionsForNextRule.add(i.next());
|
||||
i.remove();
|
||||
}
|
||||
//Build rule with new conditions
|
||||
// Build rule with new conditions
|
||||
rules.add(Rule.builder().priority("" + ruleIdx).conditions(conditionsForNextRule)
|
||||
.actions(Action.builder()
|
||||
.forwardConfig(ForwardActionConfig.builder()
|
||||
@@ -393,7 +401,7 @@ implements ProcedureCreatingLoadBalancerMapping<ShardingKey> {
|
||||
}
|
||||
|
||||
protected int numberOfRequiredRules(int numberOfShardingKeys) {
|
||||
return (int) (numberOfShardingKeys / (ApplicationLoadBalancer.MAX_CONDITIONS_PER_RULE-NUMBER_OF_STANDARD_CONDITIONS_FOR_SHARDING_RULE))
|
||||
return (int) (numberOfShardingKeys * ShardingRulePathConditionBuilder.numberOfShardConditionsPerShard() / (ApplicationLoadBalancer.MAX_CONDITIONS_PER_RULE-NUMBER_OF_STANDARD_CONDITIONS_FOR_SHARDING_RULE))
|
||||
+ (int) Math.signum(/* one more because casting to int rounds down */ numberOfShardingKeys %
|
||||
(ApplicationLoadBalancer.MAX_CONDITIONS_PER_RULE-NUMBER_OF_STANDARD_CONDITIONS_FOR_SHARDING_RULE));
|
||||
}
|
||||
@@ -452,25 +460,10 @@ implements ProcedureCreatingLoadBalancerMapping<ShardingKey> {
|
||||
.min().getAsInt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Path conditions are constructed by pre-pending a "*" to the sharding key.
|
||||
*/
|
||||
//TODO delete -> changed so ShardingRulesBuilder
|
||||
public static <ShardingKey> String getPathConditionForShardingKey(ShardingKey shardingKey, String pathPrefixForShardingKey) {
|
||||
return pathPrefixForShardingKey+shardingKey.toString();
|
||||
}
|
||||
|
||||
// this silently assumes that a String casts into a ShardingKey without problems
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <ShardingKey> ShardingKey getShardingKeyFromPathCondition(String path) {
|
||||
return (ShardingKey) ShardingRulePathConditionBuilder.getShardingKeyFromCondition(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Path conditions are constructed by pre-pending a "*" to the sharding key.
|
||||
*/
|
||||
protected String getPathConditionForShardingKey(ShardingKey shardingKey) {
|
||||
return getPathConditionForShardingKey(shardingKey, pathPrefixForShardingKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user