Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ktkrg committed Aug 24, 2020
1 parent 8919220 commit a4fbb59
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,23 @@ public void removeActionImpact(@NonNull final String actionName,
*/
public boolean checkAlignmentAcrossDimensions(@NonNull final String actionName,
@NonNull final ImpactVector impactVector) {
boolean isAligned = true;

// If this is an action that increases pressure along some dimension for this node, and the
// overall assessment says there are actions that decrease pressure along those same
// dimensions, then this action is not aligned with the other proposed actions where the
// deciders are trying to reduce pressure for those dimensions.
boolean isAligned = true;

final Map<Dimension, Impact> impactMap = impactVector.getImpact();
for (final Map.Entry<Dimension, Impact> entry : impactMap.entrySet()) {
final Impact impactOnDimension = entry.getValue();
if (isAligned && impactOnDimension.equals(Impact.INCREASES_PRESSURE)) {
List<String> pressureDecreasingActions = perDimensionPressureDecreasingActions
.getOrDefault(entry.getKey(), Collections.emptyList());
isAligned = pressureDecreasingActions.isEmpty();
isAligned = !perDimensionPressureDecreasingActions.containsKey(entry.getKey());

if (!isAligned) {
LOG.info("action: {}'s impact is not aligned with node: {}'s overall impact for "
+ "dimension: {}. Found pressure decreasing actions: {}", actionName, nodeKey,
entry.getKey(), pressureDecreasingActions);
entry.getKey(), perDimensionPressureDecreasingActions.getOrDefault(entry.getKey(),
Collections.emptyList()));
}
}
}
Expand All @@ -140,15 +138,17 @@ public boolean checkAlignmentAcrossDimensions(@NonNull final String actionName,

private void addActionToMap(@NonNull final Map<Dimension, List<String>> map,
@NonNull final String actionName, @NonNull final Dimension dimension) {
map.computeIfAbsent(dimension,
dim -> new ArrayList<>()).add(actionName);
map.computeIfAbsent(dimension, dim -> new ArrayList<>()).add(actionName);
}

private void removeActionFromMap(@NonNull final Map<Dimension, List<String>> map,
@NonNull final String actionName, @NonNull final Dimension dimension) {
final List<String> actions = map.get(dimension);
if (actions != null) {
actions.remove(actionName);
if (actions.isEmpty()) {
map.remove(dimension);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,4 @@ public ImpactVector buildShardMoveInImpactVector() {

return impactVector;
}
}
}

0 comments on commit a4fbb59

Please sign in to comment.