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 import org.apache.hadoop.fs.Path; 024 025 @InterfaceAudience.Private 026 @InterfaceStability.Evolving 027 028 /** 029 * Abstract class for deriving exceptions related to filesystem constraints 030 */ 031 public abstract class FSLimitException extends QuotaExceededException { 032 protected static final long serialVersionUID = 1L; 033 034 protected FSLimitException() {} 035 036 protected FSLimitException(String msg) { 037 super(msg); 038 } 039 040 protected FSLimitException(long quota, long count) { 041 super(quota, count); 042 } 043 044 /** 045 * Path component length is too long 046 */ 047 public static final 048 class PathComponentTooLongException extends FSLimitException { 049 protected static final long serialVersionUID = 1L; 050 051 protected PathComponentTooLongException() {} 052 053 protected PathComponentTooLongException(String msg) { 054 super(msg); 055 } 056 057 public PathComponentTooLongException(long quota, long count) { 058 super(quota, count); 059 } 060 061 @Override 062 public String getMessage() { 063 Path violator = new Path(pathName); 064 return "The maximum path component name limit of " + violator.getName() + 065 " in directory " + violator.getParent() + 066 " is exceeded: limit=" + quota + " length=" + count; 067 } 068 } 069 070 /** 071 * Directory has too many items 072 */ 073 public static final 074 class MaxDirectoryItemsExceededException extends FSLimitException { 075 protected static final long serialVersionUID = 1L; 076 077 protected MaxDirectoryItemsExceededException() {} 078 079 protected MaxDirectoryItemsExceededException(String msg) { 080 super(msg); 081 } 082 083 public MaxDirectoryItemsExceededException(long quota, long count) { 084 super(quota, count); 085 } 086 087 @Override 088 public String getMessage() { 089 return "The directory item limit of " + pathName + 090 " is exceeded: limit=" + quota + " items=" + count; 091 } 092 } 093 }