virajith commented on a change in pull request #1726: [WIP] Syncservice rebased 
onto HDFS-12090
URL: https://github.com/apache/hadoop/pull/1726#discussion_r352255445
 
 

 ##########
 File path: 
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirSyncNodeToRemoteStoreOp.java
 ##########
 @@ -0,0 +1,214 @@
+/**
+ * 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.hdfs.server.namenode;
+
+
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.XAttr;
+import org.apache.hadoop.fs.XAttrSetFlag;
+import org.apache.hadoop.fs.permission.FsAction;
+import org.apache.hadoop.hdfs.XAttrHelper;
+import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
+import org.apache.hadoop.hdfs.server.namenode.FSDirectory.DirOp;
+import org.apache.hadoop.hdfs.server.namenode.sps.StoragePolicySatisfyManager;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.List;
+
+import static 
org.apache.hadoop.hdfs.server.common.HdfsServerConstants.XATTR_SYNC_TO_EXTERNAL;
+
+final class FSDirSyncNodeToRemoteStoreOp {
+  /**
+   * Private constructor for preventing FSDirSyncNodeToExternalStoreOp object
+   * creation. Static-only class.
+   */
+  private FSDirSyncNodeToRemoteStoreOp() {
+  }
+
+  /**
+   * Satisfy storage policy function which will add the entry to SPS call queue
+   * and will perform satisfaction async way.
+   *
+   * @param fsd
+   *          fs directory
+   * @param bm
+   *          block manager
+   * @param src
+   *          source path
+   * @param logRetryCache
+   *          whether to record RPC ids in editlog for retry cache rebuilding
+   * @return file status info
+   * @throws IOException
+   */
+  static FileStatus syncCreateToRemoteStore(FSDirectory fsd, BlockManager bm,
+      String src, boolean logRetryCache) throws IOException {
+    FSPermissionChecker pc = fsd.getPermissionChecker();
+    INodesInPath iip;
+    fsd.readLock();
+    try {
+      // check operation permission.
+      iip = fsd.resolvePath(pc, src, DirOp.READ);
+      if (fsd.isPermissionEnabled()) {
+        fsd.checkPathAccess(pc, iip, FsAction.READ);
+      }
+      INode inode = FSDirectory.resolveLastINode(iip);
+      if (inode.isFile() && inode.asFile().numBlocks() == 0) {
+        if (NameNode.LOG.isInfoEnabled()) {
 
 Review comment:
   Empty files would also have to be synced.

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


With regards,
Apache Git Services

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

Reply via email to