HDFS-16207. Remove NN logs stack trace for non-existent xattr query (#3375)
Change-Id: Ibde523b20a6b8ac92991da52583e625a018d2ee6
This commit is contained in:
parent
a2242df10a
commit
1f61944e3b
@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
* 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.protocol;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
|
import org.apache.hadoop.classification.InterfaceStability;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The exception that happens when you ask to get a non existing XAttr.
|
||||||
|
*/
|
||||||
|
@InterfaceAudience.Private
|
||||||
|
@InterfaceStability.Evolving
|
||||||
|
public class XAttrNotFoundException extends IOException {
|
||||||
|
private static final long serialVersionUID = -6506239904158794057L;
|
||||||
|
public static final String DEFAULT_EXCEPTION_MSG =
|
||||||
|
"At least one of the attributes provided was not found.";
|
||||||
|
public XAttrNotFoundException() {
|
||||||
|
this(DEFAULT_EXCEPTION_MSG);
|
||||||
|
}
|
||||||
|
public XAttrNotFoundException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
@ -29,6 +29,7 @@
|
|||||||
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
||||||
import org.apache.hadoop.hdfs.DFSUtil;
|
import org.apache.hadoop.hdfs.DFSUtil;
|
||||||
import org.apache.hadoop.hdfs.XAttrHelper;
|
import org.apache.hadoop.hdfs.XAttrHelper;
|
||||||
|
import org.apache.hadoop.hdfs.protocol.XAttrNotFoundException;
|
||||||
import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos;
|
import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos;
|
||||||
import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.ReencryptionInfoProto;
|
import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.ReencryptionInfoProto;
|
||||||
import org.apache.hadoop.hdfs.protocolPB.PBHelperClient;
|
import org.apache.hadoop.hdfs.protocolPB.PBHelperClient;
|
||||||
@ -114,8 +115,7 @@ static List<XAttr> getXAttrs(FSDirectory fsd, FSPermissionChecker pc,
|
|||||||
return filteredAll;
|
return filteredAll;
|
||||||
}
|
}
|
||||||
if (filteredAll == null || filteredAll.isEmpty()) {
|
if (filteredAll == null || filteredAll.isEmpty()) {
|
||||||
throw new IOException(
|
throw new XAttrNotFoundException();
|
||||||
"At least one of the attributes provided was not found.");
|
|
||||||
}
|
}
|
||||||
List<XAttr> toGet = Lists.newArrayListWithCapacity(xAttrs.size());
|
List<XAttr> toGet = Lists.newArrayListWithCapacity(xAttrs.size());
|
||||||
for (XAttr xAttr : xAttrs) {
|
for (XAttr xAttr : xAttrs) {
|
||||||
@ -129,8 +129,7 @@ static List<XAttr> getXAttrs(FSDirectory fsd, FSPermissionChecker pc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!foundIt) {
|
if (!foundIt) {
|
||||||
throw new IOException(
|
throw new XAttrNotFoundException();
|
||||||
"At least one of the attributes provided was not found.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return toGet;
|
return toGet;
|
||||||
|
@ -127,6 +127,7 @@
|
|||||||
import org.apache.hadoop.hdfs.protocol.QuotaExceededException;
|
import org.apache.hadoop.hdfs.protocol.QuotaExceededException;
|
||||||
import org.apache.hadoop.hdfs.protocol.RecoveryInProgressException;
|
import org.apache.hadoop.hdfs.protocol.RecoveryInProgressException;
|
||||||
import org.apache.hadoop.hdfs.protocol.ReplicatedBlockStats;
|
import org.apache.hadoop.hdfs.protocol.ReplicatedBlockStats;
|
||||||
|
import org.apache.hadoop.hdfs.protocol.XAttrNotFoundException;
|
||||||
import org.apache.hadoop.hdfs.protocol.ZoneReencryptionStatus;
|
import org.apache.hadoop.hdfs.protocol.ZoneReencryptionStatus;
|
||||||
import org.apache.hadoop.hdfs.protocol.RollingUpgradeInfo;
|
import org.apache.hadoop.hdfs.protocol.RollingUpgradeInfo;
|
||||||
import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport;
|
import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport;
|
||||||
@ -544,7 +545,8 @@ public NameNodeRpcServer(Configuration conf, NameNode nn)
|
|||||||
AclException.class,
|
AclException.class,
|
||||||
FSLimitException.PathComponentTooLongException.class,
|
FSLimitException.PathComponentTooLongException.class,
|
||||||
FSLimitException.MaxDirectoryItemsExceededException.class,
|
FSLimitException.MaxDirectoryItemsExceededException.class,
|
||||||
DisallowedDatanodeException.class);
|
DisallowedDatanodeException.class,
|
||||||
|
XAttrNotFoundException.class);
|
||||||
|
|
||||||
clientRpcServer.addSuppressedLoggingExceptions(StandbyException.class,
|
clientRpcServer.addSuppressedLoggingExceptions(StandbyException.class,
|
||||||
UnresolvedPathException.class);
|
UnresolvedPathException.class);
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
import org.apache.hadoop.fs.permission.FsPermission;
|
import org.apache.hadoop.fs.permission.FsPermission;
|
||||||
import org.apache.hadoop.fs.permission.PermissionStatus;
|
import org.apache.hadoop.fs.permission.PermissionStatus;
|
||||||
import org.apache.hadoop.hdfs.XAttrHelper;
|
import org.apache.hadoop.hdfs.XAttrHelper;
|
||||||
|
import org.apache.hadoop.hdfs.protocol.XAttrNotFoundException;
|
||||||
import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos;
|
import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.FSImageFormatPBINode;
|
import org.apache.hadoop.hdfs.server.namenode.FSImageFormatPBINode;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.FSImageFormatProtobuf;
|
import org.apache.hadoop.hdfs.server.namenode.FSImageFormatProtobuf;
|
||||||
@ -452,8 +453,7 @@ String getXAttrs(String path, List<String> names, String encoder)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
throw new IOException(
|
throw new XAttrNotFoundException();
|
||||||
"At least one of the attributes provided was not found.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
import org.apache.hadoop.thirdparty.com.google.common.collect.Lists;
|
import org.apache.hadoop.thirdparty.com.google.common.collect.Lists;
|
||||||
|
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
|
import org.apache.hadoop.hdfs.protocol.XAttrNotFoundException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.apache.log4j.Level;
|
import org.apache.log4j.Level;
|
||||||
@ -3435,7 +3436,7 @@ public Object run() throws Exception {
|
|||||||
String str = out.toString();
|
String str = out.toString();
|
||||||
assertTrue("xattr value was incorrectly returned",
|
assertTrue("xattr value was incorrectly returned",
|
||||||
str.indexOf(
|
str.indexOf(
|
||||||
"getfattr: At least one of the attributes provided was not found")
|
"getfattr: " + XAttrNotFoundException.DEFAULT_EXCEPTION_MSG)
|
||||||
>= 0);
|
>= 0);
|
||||||
out.reset();
|
out.reset();
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
import org.apache.hadoop.hdfs.DistributedFileSystem;
|
import org.apache.hadoop.hdfs.DistributedFileSystem;
|
||||||
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
||||||
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
||||||
|
import org.apache.hadoop.hdfs.protocol.XAttrNotFoundException;
|
||||||
import org.apache.hadoop.io.IOUtils;
|
import org.apache.hadoop.io.IOUtils;
|
||||||
import org.apache.hadoop.security.AccessControlException;
|
import org.apache.hadoop.security.AccessControlException;
|
||||||
import org.apache.hadoop.security.UserGroupInformation;
|
import org.apache.hadoop.security.UserGroupInformation;
|
||||||
@ -408,7 +409,7 @@ public void testGetXAttrs() throws Exception {
|
|||||||
Assert.fail("expected IOException");
|
Assert.fail("expected IOException");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
GenericTestUtils.assertExceptionContains(
|
GenericTestUtils.assertExceptionContains(
|
||||||
"At least one of the attributes provided was not found.", e);
|
XAttrNotFoundException.DEFAULT_EXCEPTION_MSG, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Throw an exception if an xattr that was requested does not exist. */
|
/* Throw an exception if an xattr that was requested does not exist. */
|
||||||
@ -422,7 +423,7 @@ public void testGetXAttrs() throws Exception {
|
|||||||
Assert.fail("expected IOException");
|
Assert.fail("expected IOException");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
GenericTestUtils.assertExceptionContains(
|
GenericTestUtils.assertExceptionContains(
|
||||||
"At least one of the attributes provided was not found.", e);
|
XAttrNotFoundException.DEFAULT_EXCEPTION_MSG, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user