[NO ISSUE][REPL] Use String.compareTo To Sort Replicated Files

- user model changes: no
- storage format changes: no
- interface changes: no

- Use String.compareTo to sort replicated files
  instead of custom comparator.

Change-Id: I45c106d5cff6e07d16a9a7ce286a2ac563a80338
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2547
Reviewed-by: Michael Blow <mb...@apache.org>
Sonar-Qube: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenk...@fulliautomatix.ics.uci.edu>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/6ee05df4
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/6ee05df4
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/6ee05df4

Branch: refs/heads/release-0.9.4-pre-rc
Commit: 6ee05df4c2a0c3a234d95d0375a18bf3aef496f2
Parents: 6ee96a9
Author: Murtadha Hubail <mhub...@apache.org>
Authored: Thu Mar 29 09:00:17 2018 +0300
Committer: Murtadha Hubail <mhub...@apache.org>
Committed: Thu Mar 29 01:40:16 2018 -0700

----------------------------------------------------------------------
 .../replication/sync/ReplicaFilesSynchronizer.java    | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/6ee05df4/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/sync/ReplicaFilesSynchronizer.java
----------------------------------------------------------------------
diff --git 
a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/sync/ReplicaFilesSynchronizer.java
 
b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/sync/ReplicaFilesSynchronizer.java
index 0d97a7a..583f33d 100644
--- 
a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/sync/ReplicaFilesSynchronizer.java
+++ 
b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/sync/ReplicaFilesSynchronizer.java
@@ -18,12 +18,9 @@
  */
 package org.apache.asterix.replication.sync;
 
-import static 
org.apache.asterix.common.utils.StorageConstants.METADATA_FILE_NAME;
-
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.channels.SocketChannel;
-import java.util.Comparator;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -43,13 +40,6 @@ import 
org.apache.asterix.transaction.management.resource.PersistentLocalResourc
  */
 public class ReplicaFilesSynchronizer {
 
-    private static final Comparator<String> REPLICATED_FILES_COMPARATOR = 
(file, anotherFile) -> {
-        if (file.endsWith(METADATA_FILE_NAME) && 
!anotherFile.endsWith(METADATA_FILE_NAME)) {
-            return -1;
-        }
-        return file.compareTo(anotherFile);
-    };
-
     private final PartitionReplica replica;
     private final INcApplicationContext appCtx;
 
@@ -89,8 +79,8 @@ public class ReplicaFilesSynchronizer {
 
     private void replicateMissingFiles(List<String> files) {
         final FileSynchronizer sync = new FileSynchronizer(appCtx, replica);
-        // sort files to ensure index metadata files are replicated first
-        files.sort(REPLICATED_FILES_COMPARATOR);
+        // sort files to ensure index metadata files starting with "." are 
replicated first
+        files.sort(String::compareTo);
         files.forEach(sync::replicate);
     }
 

Reply via email to