Return-Path: Delivered-To: apmail-hadoop-core-commits-archive@www.apache.org Received: (qmail 68201 invoked from network); 7 Aug 2008 18:29:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Aug 2008 18:29:01 -0000 Received: (qmail 73895 invoked by uid 500); 7 Aug 2008 18:29:00 -0000 Delivered-To: apmail-hadoop-core-commits-archive@hadoop.apache.org Received: (qmail 73746 invoked by uid 500); 7 Aug 2008 18:29:00 -0000 Mailing-List: contact core-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: core-dev@hadoop.apache.org Delivered-To: mailing list core-commits@hadoop.apache.org Received: (qmail 73737 invoked by uid 99); 7 Aug 2008 18:29:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Aug 2008 11:29:00 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Aug 2008 18:28:12 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 173F8238899E; Thu, 7 Aug 2008 11:28:10 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r683671 - in /hadoop/core/trunk: CHANGES.txt src/hdfs/org/apache/hadoop/hdfs/server/namenode/INodeDirectory.java src/hdfs/org/apache/hadoop/hdfs/server/namenode/INodeDirectoryWithQuota.java Date: Thu, 07 Aug 2008 18:28:09 -0000 To: core-commits@hadoop.apache.org From: hairong@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080807182810.173F8238899E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: hairong Date: Thu Aug 7 11:28:09 2008 New Revision: 683671 URL: http://svn.apache.org/viewvc?rev=683671&view=rev Log: HADOOP-3907. Move INodeDirectoryWithQuota to its own .java file. Contributed by Tsz Wo (Nicholas), SZE. Added: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/INodeDirectoryWithQuota.java Modified: hadoop/core/trunk/CHANGES.txt hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/INodeDirectory.java Modified: hadoop/core/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=683671&r1=683670&r2=683671&view=diff ============================================================================== --- hadoop/core/trunk/CHANGES.txt (original) +++ hadoop/core/trunk/CHANGES.txt Thu Aug 7 11:28:09 2008 @@ -241,6 +241,9 @@ HADOOP-3319. Fix some HOD error messages to go stderr instead of stdout. (Vinod Kumar Vavilapalli via omalley) + HADOOP-3907. Move INodeDirectoryWithQuota to its own .java file. + (Tsz Wo (Nicholas), SZE via hairong) + Release 0.18.0 - Unreleased INCOMPATIBLE CHANGES Modified: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/INodeDirectory.java URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/INodeDirectory.java?rev=683671&r1=683670&r2=683671&view=diff ============================================================================== --- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/INodeDirectory.java (original) +++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/INodeDirectory.java Thu Aug 7 11:28:09 2008 @@ -26,8 +26,6 @@ import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.fs.permission.PermissionStatus; import org.apache.hadoop.hdfs.protocol.Block; -import org.apache.hadoop.hdfs.protocol.QuotaExceededException; - /** * Directory INode class. @@ -348,97 +346,3 @@ return total; } } - -/** - * Directory INode class that has a quota restriction - */ -class INodeDirectoryWithQuota extends INodeDirectory { - private long quota; - private long count; - - /** Convert an existing directory inode to one with the given quota - * - * @param quota Quota to be assigned to this inode - * @param other The other inode from which all other properties are copied - */ - INodeDirectoryWithQuota(long quota, INodeDirectory other) - throws QuotaExceededException { - super(other); - this.count = other.numItemsInTree(); - setQuota(quota); - } - - /** constructor with no quota verification */ - INodeDirectoryWithQuota( - PermissionStatus permissions, long modificationTime, long quota) - { - super(permissions, modificationTime); - this.quota = quota; - } - - /** constructor with no quota verification */ - INodeDirectoryWithQuota(String name, PermissionStatus permissions, long quota) - { - super(name, permissions); - this.quota = quota; - } - - /** Get this directory's quota - * @return this directory's quota - */ - long getQuota() { - return quota; - } - - /** Set this directory's quota - * - * @param quota Quota to be set - * @throws QuotaExceededException if the given quota is less than - * the size of the tree - */ - void setQuota(long quota) throws QuotaExceededException { - verifyQuota(quota, this.count); - this.quota = quota; - } - - /** Get the number of names in the subtree rooted at this directory - * @return the size of the subtree rooted at this directory - */ - long numItemsInTree() { - return count; - } - - /** Update the size of the tree - * - * @param delta the change of the tree size - * @throws QuotaExceededException if the changed size is greater - * than the quota - */ - void updateNumItemsInTree(long delta) throws QuotaExceededException { - long newCount = this.count + delta; - if (delta>0) { - verifyQuota(this.quota, newCount); - } - this.count = newCount; - } - - /** Set the size of the tree rooted at this directory - * - * @param count size of the directory to be set - * @throws QuotaExceededException if the given count is greater than quota - */ - void setCount(long count) throws QuotaExceededException { - verifyQuota(this.quota, count); - this.count = count; - } - - /** Verify if the count satisfies the quota restriction - * @throws QuotaExceededException if the given quota is less than the count - */ - private static void verifyQuota(long quota, long count) - throws QuotaExceededException { - if (quota < count) { - throw new QuotaExceededException(quota, count); - } - } -} Added: hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/INodeDirectoryWithQuota.java URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/INodeDirectoryWithQuota.java?rev=683671&view=auto ============================================================================== --- hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/INodeDirectoryWithQuota.java (added) +++ hadoop/core/trunk/src/hdfs/org/apache/hadoop/hdfs/server/namenode/INodeDirectoryWithQuota.java Thu Aug 7 11:28:09 2008 @@ -0,0 +1,115 @@ +/** + * 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.permission.PermissionStatus; +import org.apache.hadoop.hdfs.protocol.QuotaExceededException; + +/** + * Directory INode class that has a quota restriction + */ +class INodeDirectoryWithQuota extends INodeDirectory { + private long quota; + private long count; + + /** Convert an existing directory inode to one with the given quota + * + * @param quota Quota to be assigned to this inode + * @param other The other inode from which all other properties are copied + */ + INodeDirectoryWithQuota(long quota, INodeDirectory other) + throws QuotaExceededException { + super(other); + this.count = other.numItemsInTree(); + setQuota(quota); + } + + /** constructor with no quota verification */ + INodeDirectoryWithQuota( + PermissionStatus permissions, long modificationTime, long quota) + { + super(permissions, modificationTime); + this.quota = quota; + } + + /** constructor with no quota verification */ + INodeDirectoryWithQuota(String name, PermissionStatus permissions, long quota) + { + super(name, permissions); + this.quota = quota; + } + + /** Get this directory's quota + * @return this directory's quota + */ + long getQuota() { + return quota; + } + + /** Set this directory's quota + * + * @param quota Quota to be set + * @throws QuotaExceededException if the given quota is less than + * the size of the tree + */ + void setQuota(long quota) throws QuotaExceededException { + verifyQuota(quota, this.count); + this.quota = quota; + } + + /** Get the number of names in the subtree rooted at this directory + * @return the size of the subtree rooted at this directory + */ + long numItemsInTree() { + return count; + } + + /** Update the size of the tree + * + * @param delta the change of the tree size + * @throws QuotaExceededException if the changed size is greater + * than the quota + */ + void updateNumItemsInTree(long delta) throws QuotaExceededException { + long newCount = this.count + delta; + if (delta>0) { + verifyQuota(this.quota, newCount); + } + this.count = newCount; + } + + /** Set the size of the tree rooted at this directory + * + * @param count size of the directory to be set + * @throws QuotaExceededException if the given count is greater than quota + */ + void setCount(long count) throws QuotaExceededException { + verifyQuota(this.quota, count); + this.count = count; + } + + /** Verify if the count satisfies the quota restriction + * @throws QuotaExceededException if the given quota is less than the count + */ + private static void verifyQuota(long quota, long count) + throws QuotaExceededException { + if (quota < count) { + throw new QuotaExceededException(quota, count); + } + } +}