autumnust commented on a change in pull request #2986:
URL: https://github.com/apache/incubator-gobblin/pull/2986#discussion_r425563714



##########
File path: 
gobblin-utility/src/main/java/org/apache/gobblin/util/HadoopUtils.java
##########
@@ -266,19 +268,25 @@ public static void renamePath(FileSystem fs, Path 
oldName, Path newName) throws
    * {@link FileSystem#rename(Path, Path)} returns False.
    */
   public static void renamePath(FileSystem fs, Path oldName, Path newName, 
boolean overwrite) throws IOException {
-    if (!fs.exists(oldName)) {
-      throw new FileNotFoundException(String.format("Failed to rename %s to 
%s: src not found", oldName, newName));
-    }
-    if (fs.exists(newName)) {
-      if (overwrite) {
-        HadoopUtils.moveToTrash(fs, newName);
-      } else {
-        throw new FileAlreadyExistsException(
-            String.format("Failed to rename %s to %s: dst already exists", 
oldName, newName));
+    //In default implementation of rename with rewrite option in FileSystem, 
if the parent dir of dst does not exist, it will throw exception,
+    //Which will fail some of our job unintentionally. So we only call that 
method when fs is an instance of DistributedFileSystem to avoid inconsistency 
problem

Review comment:
       Are you referring to the fact that the implementation of rename in 
DistributedFileSystem is guaranteed to be atomic?  I am not getting this 
comment. 

##########
File path: 
gobblin-utility/src/main/java/org/apache/hadoop/fs/FileSystemAdapter.java
##########
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.fs;
+
+import java.io.IOException;
+
+
+public class FileSystemAdapter {
+  public static void rename(FileSystem fs, Path src, Path dst, Options.Rename 
options) throws IOException {

Review comment:
       `FileContext` is introduced to handle the protected problem of rename : 
http://hadoop.apache.org/docs/current/api/org/apache/hadoop/fs/FileSystem.html#rename-org.apache.hadoop.fs.Path-org.apache.hadoop.fs.Path-org.apache.hadoop.fs.Options.Rename...-




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