001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019 package org.apache.hadoop.hdfs.protocol;
020
021 import org.apache.hadoop.classification.InterfaceAudience;
022 import org.apache.hadoop.classification.InterfaceStability;
023
024 @InterfaceAudience.Private
025 @InterfaceStability.Evolving
026
027 /**
028 * Abstract class for deriving exceptions related to filesystem constraints
029 */
030 public abstract class FSLimitException extends QuotaExceededException {
031 protected static final long serialVersionUID = 1L;
032
033 protected FSLimitException() {}
034
035 protected FSLimitException(String msg) {
036 super(msg);
037 }
038
039 protected FSLimitException(long quota, long count) {
040 super(quota, count);
041 }
042
043 /**
044 * Path component length is too long
045 */
046 public static final
047 class PathComponentTooLongException extends FSLimitException {
048 protected static final long serialVersionUID = 1L;
049
050 private String childName;
051
052 protected PathComponentTooLongException() {}
053
054 protected PathComponentTooLongException(String msg) {
055 super(msg);
056 }
057
058 public PathComponentTooLongException(long quota, long count,
059 String parentPath, String childName) {
060 super(quota, count);
061 setPathName(parentPath);
062 this.childName = childName;
063 }
064
065 String getParentPath() {
066 return pathName;
067 }
068
069 @Override
070 public String getMessage() {
071 return "The maximum path component name limit of " + childName +
072 " in directory " + getParentPath() +
073 " is exceeded: limit=" + quota + " length=" + count;
074 }
075 }
076
077 /**
078 * Directory has too many items
079 */
080 public static final
081 class MaxDirectoryItemsExceededException extends FSLimitException {
082 protected static final long serialVersionUID = 1L;
083
084 protected MaxDirectoryItemsExceededException() {}
085
086 protected MaxDirectoryItemsExceededException(String msg) {
087 super(msg);
088 }
089
090 public MaxDirectoryItemsExceededException(long quota, long count) {
091 super(quota, count);
092 }
093
094 @Override
095 public String getMessage() {
096 return "The directory item limit of " + pathName +
097 " is exceeded: limit=" + quota + " items=" + count;
098 }
099 }
100 }