amaliujia commented on a change in pull request #298:
URL: https://github.com/apache/incubator-ratis/pull/298#discussion_r534534617



##########
File path: 
ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileStore.java
##########
@@ -219,4 +225,67 @@ public void close() {
     reader.shutdownNow();
     deleter.shutdownNow();
   }
+
+  CompletableFuture<StreamWriteReplyProto> streamCommit(String p, long 
bytesWritten) {
+    return CompletableFuture.supplyAsync(() -> {
+      final Path full = buildFullPath(p);
+      try {
+        RandomAccessFile file = new RandomAccessFile(full.toFile(), "r");
+        long len = file.length();
+        return StreamWriteReplyProto.newBuilder().setIsSuccess(len == 
bytesWritten).setByteWritten(len).build();
+      } catch (FileNotFoundException e) {
+        throw new CompletionException("Failed to find " + p, e);
+      } catch (IOException e) {
+        throw new CompletionException("Failed to get length of " + p, e);

Review comment:
       In fact, because now I use `Path resolve(Path relative) throws 
IOException` so the order of exception is no longer holds. I have merged all 
into catching IOException




----------------------------------------------------------------
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]


Reply via email to