gpt4 book ai didi

hadoop - "RemoteException"在HDFS中一般是什么意思?

转载 作者:可可西里 更新时间:2023-11-01 16:43:22 28 4
gpt4 key购买 nike

1) 谁能帮助我了解“Remoteexception”的概念?一般是什么意思?

2) 另外,unwrapRemoteException 是什么意思?不确定它的意思是“如果这个远程异常包含一个 lookupTypes”

  /**
* If this remote exception wraps up one of the lookupTypes
* then return this exception.
* <p>
* Unwraps any IOException.
*
* @param lookupTypes the desired exception class.
* @return IOException, which is either the lookupClass exception or this.
*/
public IOException unwrapRemoteException(Class<?>... lookupTypes) {
if(lookupTypes == null)
return this;
for(Class<?> lookupClass : lookupTypes) {
if(!lookupClass.getName().equals(getClassName()))
continue;
try {
return instantiateException(lookupClass.asSubclass(IOException.class));
} catch(Exception e) {
// cannot instantiate lookupClass, just return this
return this;
}
}
// wrapped up exception is not in lookupTypes, just return this
return this;
}

(Hadoop_HDFS_Open_Source:https://github.com/apache/hadoop)

提前致谢!任何帮助将不胜感激!

最佳答案

1) May anyone help me about the concept of "Remoteexception"? What does it mean in general?

服务器端抛出(创建)了远程异常。服务器抛出此类异常是因为客户端发送了无效请求,或者服务器有内部错误或其他原因。服务器端的 RPC 服务器序列化异常,并将其发送到客户端。客户端反序列化异常,获取异常。

2) Also what does it mean by unwrapRemoteException?

问题是“为什么我们需要包装异常”。首先,RemoteException 是一个包装器而不是真正的异常。服务器抛出的真正异常可能是AccessControlException(用户没有权限),FileNotFoundException(无效请求)。我们将它们包装在 RemoteException 中。但为什么?因为代码更清晰,更具可读性。

Was not sure it means by "if this remote exception wraps up one of the lookupTypes"

例如,在 DFSClient.java 中

public HdfsFileStatus getFileInfo(String src) throws IOException {
checkOpen();
try {
return namenode.getFileInfo(src);
} catch(RemoteException re) {
throw re.unwrapRemoteException(AccessControlException.class,
FileNotFoundException.class,
UnresolvedPathException.class);
}
}

如果 re 包装了一个 FileNotFoundException,那么 getFileInfo 只返回 FileNotFoundException。然后用户可以看到更短更清晰的异常消息。用户只需要知道文件没有找到,不关心是否远程。

但是如果 re 包装了一个 SafeModeException 或一些未知的异常。这可能是某些服务器的内部错误或配置错误。我们准确地抛出 re(RemoteException)。所以用户可以知道错误来自远程(服务器端),即使用户不知道包装的 SafeModeException(或一些未知的异常)。用户可以向技术支持寻求帮助。

关于hadoop - "RemoteException"在HDFS中一般是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38558641/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com