krummas commented on a change in pull request #875:
URL: https://github.com/apache/cassandra/pull/875#discussion_r573474150



##########
File path: src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
##########
@@ -2276,8 +2276,13 @@ public static SSTableReader 
moveAndOpenSSTable(ColumnFamilyStore cfs, Descriptor
             throw new RuntimeException(msg);
         }
 
-        logger.info("Renaming new SSTable {} to {}", oldDescriptor, 
newDescriptor);
-        SSTableWriter.rename(oldDescriptor, newDescriptor, components);
+        if (copyData) {
+            logger.info("Copying new SSTable {} to {}", oldDescriptor, 
newDescriptor);
+            SSTableWriter.copy(oldDescriptor, newDescriptor, components);

Review comment:
       We should probably try to hard link the file here? If it fails we can 
fall back to copy

##########
File path: src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
##########
@@ -2276,8 +2276,13 @@ public static SSTableReader 
moveAndOpenSSTable(ColumnFamilyStore cfs, Descriptor
             throw new RuntimeException(msg);
         }
 
-        logger.info("Renaming new SSTable {} to {}", oldDescriptor, 
newDescriptor);
-        SSTableWriter.rename(oldDescriptor, newDescriptor, components);
+        if (copyData) {

Review comment:
       brace on newline (same for the whole patch)

##########
File path: src/java/org/apache/cassandra/io/util/FileUtils.java
##########
@@ -240,6 +240,35 @@ public static void deleteWithConfirmWithThrottle(File 
file, RateLimiter rateLimi
         maybeFail(deleteWithConfirm(file, null, rateLimiter));
     }
 
+    public static void copyWithOutConfirm(String from, String to)
+    {
+        try {
+            Files.copy(new File(from).toPath(), new File(to).toPath());
+        } catch (IOException e) {
+            if (logger.isTraceEnabled())
+                logger.trace("Could not copy file" + from + " to " + to, e);
+        }
+    }
+
+    public static void copyWithConfirm(String from, String to)
+    {
+        copyWithConfirm(new File(from), new File(to));
+    }
+
+    public static void copyWithConfirm(File from, File to)
+    {
+        assert from.exists();
+        if (logger.isTraceEnabled())
+            logger.trace("Copying {} to {}", from.getPath(), to.getPath());
+
+        try {
+            Files.copy(from.toPath(), to.toPath());
+        } catch (IOException e) {

Review comment:
       we should not ignore `IOException` here 

##########
File path: src/java/org/apache/cassandra/io/util/FileUtils.java
##########
@@ -240,6 +240,35 @@ public static void deleteWithConfirmWithThrottle(File 
file, RateLimiter rateLimi
         maybeFail(deleteWithConfirm(file, null, rateLimiter));
     }
 
+    public static void copyWithOutConfirm(String from, String to)
+    {
+        try {
+            Files.copy(new File(from).toPath(), new File(to).toPath());

Review comment:
       nit: `Paths.get(from)`, `Paths.get(to)`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to