You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2019/07/02 11:58:55 UTC

[GitHub] [cassandra] kallelzied commented on a change in pull request #329: Adds Direct IO support for reads.

kallelzied commented on a change in pull request #329: Adds Direct IO support for reads.
URL: https://github.com/apache/cassandra/pull/329#discussion_r299444575
 
 

 ##########
 File path: src/java/org/apache/cassandra/io/util/ChannelProxy.java
 ##########
 @@ -43,43 +44,74 @@
 {
     private final String filePath;
     private final FileChannel channel;
+    private boolean useDirectIO;
 
-    public static FileChannel openChannel(File file)
+    public static FileChannel openChannel(File file, boolean useDirectIO)
     {
         try
         {
-            return FileChannel.open(file.toPath(), StandardOpenOption.READ);
+            return !useDirectIO ?
+                   FileChannel.open(file.toPath(), StandardOpenOption.READ) :
+                   FileChannel.open(file.toPath(), StandardOpenOption.READ, 
+                      (OpenOption) Enum.valueOf((Class<? extends Enum>) 
+                        Class.forName("com.sun.nio.file.ExtendedOpenOption"), "DIRECT"));
+
         }
-        catch (IOException e)
+        catch (Exception e)
         {
             throw new RuntimeException(e);
         }
     }
 
-    public ChannelProxy(String path)
+    public static FileChannel openChannel(File file)
     {
-        this (new File(path));
+        return openChannel(file, false);
+    }
+
+    public ChannelProxy(String filePath, FileChannel channel, boolean useDirectIO)
+    {
+        super(new Cleanup(filePath, channel));
+
 
 Review comment:
   why having an empty line here?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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