commit | 107c2059dec2e493eff891a112b69319886df1c2 | [log] [tgz] |
---|---|---|
author | Murtadha Hubail <mhubail@apache.org> | Thu Aug 09 18:16:12 2018 -0700 |
committer | Michael Blow <mblow@apache.org> | Thu Aug 09 22:11:34 2018 -0700 |
tree | 58e00a355e63da7491d89d02fe026df2eea83dac | |
parent | b674b1b542b3d04f4befe2884e3a9dbe13e37475 [diff] |
[NO ISSUE][COMP] Ensure Consistent Locations in Splits and Constraints - user model changes: no - storage format changes: no - interface changes: no Details: - This change ensures that the splits provider and constraints have the same order of locations to avoid a possibility where splits of a node are assigned to another node. Change-Id: Id969251eb17bfb5139bc656b1e5025c2742d5318 Reviewed-on: https://asterix-gerrit.ics.uci.edu/2872 Reviewed-by: Michael Blow <mblow@apache.org> Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu> Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/StoragePathUtil.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/StoragePathUtil.java index aa2c7af..63e29ce 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/StoragePathUtil.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/StoragePathUtil.java
@@ -21,6 +21,8 @@ import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Comparator; import org.apache.asterix.common.cluster.ClusterPartition; import org.apache.asterix.common.storage.ResourceReference; @@ -39,12 +41,15 @@ public class StoragePathUtil { private static final Logger LOGGER = LogManager.getLogger(); + private static final Comparator<FileSplit> FILE_SPLIT_COMPARATOR = + Comparator.comparing(FileSplit::getNodeName).thenComparing(FileSplit::getPath); private StoragePathUtil() { } public static Pair<IFileSplitProvider, AlgebricksPartitionConstraint> splitProviderAndPartitionConstraints( FileSplit[] splits) { + Arrays.sort(splits, FILE_SPLIT_COMPARATOR); IFileSplitProvider splitProvider = new ConstantFileSplitProvider(splits); String[] loc = new String[splits.length]; for (int p = 0; p < splits.length; p++) {
diff --git a/hyracks-fullstack/algebricks/algebricks-common/src/main/java/org/apache/hyracks/algebricks/common/constraints/AlgebricksAbsolutePartitionConstraint.java b/hyracks-fullstack/algebricks/algebricks-common/src/main/java/org/apache/hyracks/algebricks/common/constraints/AlgebricksAbsolutePartitionConstraint.java index 1bb217a..7a1bb28 100644 --- a/hyracks-fullstack/algebricks/algebricks-common/src/main/java/org/apache/hyracks/algebricks/common/constraints/AlgebricksAbsolutePartitionConstraint.java +++ b/hyracks-fullstack/algebricks/algebricks-common/src/main/java/org/apache/hyracks/algebricks/common/constraints/AlgebricksAbsolutePartitionConstraint.java
@@ -27,8 +27,7 @@ private final String[] locations; public AlgebricksAbsolutePartitionConstraint(String[] locations) { - this.locations = locations.clone(); - Arrays.sort(this.locations); + this.locations = locations; } @Override