cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [6/6] cassandra git commit: Merge branch 'cassandra-3.11' into trunk
Date Mon, 02 Oct 2017 07:40:52 GMT
Merge branch 'cassandra-3.11' into trunk


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/694b3c40
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/694b3c40
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/694b3c40

Branch: refs/heads/trunk
Commit: 694b3c40137a3c9d9ec5d844ff40db6046882447
Parents: cecb2de 983c72a
Author: Marcus Eriksson <marcuse@apache.org>
Authored: Mon Oct 2 09:40:15 2017 +0200
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Mon Oct 2 09:40:15 2017 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../apache/cassandra/db/lifecycle/Helpers.java  | 15 +++++
 .../apache/cassandra/db/lifecycle/LogFile.java  | 26 ++++++++
 .../cassandra/db/lifecycle/LogRecord.java       | 66 +++++++++++++++++++-
 .../cassandra/db/lifecycle/LogTransaction.java  | 16 +++++
 .../apache/cassandra/db/lifecycle/Tracker.java  |  2 +-
 .../cassandra/db/lifecycle/HelpersTest.java     | 58 ++++++++++++++++-
 7 files changed, 181 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/694b3c40/CHANGES.txt
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/694b3c40/src/java/org/apache/cassandra/db/lifecycle/LogRecord.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/lifecycle/LogRecord.java
index 9c1ba31,dd3fcde..0a9d73c
--- a/src/java/org/apache/cassandra/db/lifecycle/LogRecord.java
+++ b/src/java/org/apache/cassandra/db/lifecycle/LogRecord.java
@@@ -148,7 -152,11 +152,7 @@@ final class LogRecor
  
      public static LogRecord make(Type type, SSTable table)
      {
-         String absoluteTablePath = FileUtils.getCanonicalPath(table.descriptor.baseFilename());
 -        // CASSANDRA-13294: add the sstable component separator because for legacy (2.1)
files
 -        // there is no separator after the generation number, and this would cause files
of sstables with
 -        // a higher generation number that starts with the same number, to be incorrectly
classified as files
 -        // of this record sstable
+         String absoluteTablePath = absolutePath(table.descriptor.baseFilename());
          return make(type, getExistingFiles(absoluteTablePath), table.getAllFilePaths().size(),
absoluteTablePath);
      }
  
@@@ -267,6 -300,41 +296,41 @@@
          return files == null ? Collections.emptyList() : Arrays.asList(files);
      }
  
+     /**
+      * absoluteFilePaths contains full file parts up to the component name
+      *
+      * this method finds all files on disk beginning with any of the paths in absoluteFilePaths
+      * @return a map from absoluteFilePath to actual file on disk.
+      */
+     public static Map<String, List<File>> getExistingFiles(Set<String>
absoluteFilePaths)
+     {
+         Set<File> uniqueDirectories = absoluteFilePaths.stream().map(path -> Paths.get(path).getParent().toFile()).collect(Collectors.toSet());
+         Map<String, List<File>> fileMap = new HashMap<>();
+         FilenameFilter ff = (dir, name) -> {
+             Descriptor descriptor = null;
+             try
+             {
 -                descriptor = Descriptor.fromFilename(dir, name).left;
++                descriptor = Descriptor.fromFilename(new File(dir, name));
+             }
+             catch (Throwable t)
+             {// ignored - if we can't parse the filename, just skip the file
+             }
+ 
+             String absolutePath = descriptor != null ? absolutePath(descriptor.baseFilename())
: null;
+             if (absolutePath != null && absoluteFilePaths.contains(absolutePath))
+                 fileMap.computeIfAbsent(absolutePath, k -> new ArrayList<>()).add(new
File(dir, name));
+ 
+             return false;
+         };
+ 
+         // populate the file map:
+         for (File f : uniqueDirectories)
+             f.listFiles(ff);
+ 
+         return fileMap;
+     }
+ 
+ 
      public boolean isFinal()
      {
          return type.isFinal();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/694b3c40/src/java/org/apache/cassandra/db/lifecycle/LogTransaction.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/694b3c40/src/java/org/apache/cassandra/db/lifecycle/Tracker.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/694b3c40/test/unit/org/apache/cassandra/db/lifecycle/HelpersTest.java
----------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


Mime
View raw message