use of org.talend.designer.hdfsbrowse.exceptions.HadoopServerException in project tbd-studio-se by Talend.
the class HadoopServerUtil method testKnoxConnection.
/**
* DOC ycbai Comment method "testConnection".
*
* Test whether can connect to HDFS.
*
* @return
*/
public static ConnectionStatus testKnoxConnection(HDFSConnectionBean connection) {
ConnectionStatus connectionStatus = new ConnectionStatus();
connectionStatus.setResult(false);
String errorMsg = "Cannot connect to HDFS \"" + connection.getNameNodeURI() + "\". Please check the connection parameters. ";
try {
HadoopServiceProperties serviceProperties = new HadoopServiceProperties();
BeanUtils.copyProperties(serviceProperties, connection);
serviceProperties.setVersion(connection.getDfVersion());
serviceProperties.setKnoxURL(connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KNOX_URL));
serviceProperties.setKnoxUser(connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KNOX_USER));
serviceProperties.setKnoxPassword(connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KNOX_PASSWORD));
serviceProperties.setKnoxDirectory(connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KNOX_DIRECTORY));
CheckedKnoxNamenodeProvider hadoopKnox = new CheckedKnoxNamenodeProvider();
connectionStatus.setResult(hadoopKnox.checkService(serviceProperties, 1000));
connectionStatus.setMessageException("Connection successful");
} catch (HadoopServerException | InvocationTargetException | IllegalAccessException e) {
connectionStatus.setMessageException(ExceptionUtils.getFullStackTrace(e));
}
return connectionStatus;
}
Aggregations