ソースを参照

HDFS-4077. Adding a file missed in the commit r1400318.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-2802@1400350 13f79535-47bb-0310-9956-ffa450edef68
Suresh Srinivas 12 年 前
コミット
a2d837b0e9

+ 48 - 0
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/INodeDirectorySnapshottable.java

@@ -0,0 +1,48 @@
+/**
+ * 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.snapshot;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.hdfs.server.namenode.INodeDirectory;
+import org.apache.hadoop.hdfs.server.namenode.INodeDirectoryWithQuota;
+
+/** Directories where taking snapshots is allowed. */
+@InterfaceAudience.Private
+public class INodeDirectorySnapshottable extends INodeDirectoryWithQuota {
+  static public INodeDirectorySnapshottable newInstance(final INodeDirectory dir) {
+    long nsq = -1L;
+    long dsq = -1L;
+
+    if (dir instanceof INodeDirectoryWithQuota) {
+      final INodeDirectoryWithQuota q = (INodeDirectoryWithQuota)dir;
+      nsq = q.getNsQuota();
+      dsq = q.getDsQuota();
+    }
+    return new INodeDirectorySnapshottable(nsq, dsq, dir);
+  }
+
+  private INodeDirectorySnapshottable(long nsQuota, long dsQuota,
+      INodeDirectory dir) {
+    super(nsQuota, dsQuota, dir);
+  }
+
+  @Override
+  public boolean isSnapshottable() {
+    return true;
+  }
+}