Search in sources :

Example 1 with CheckedKnoxNamenodeProvider

use of org.talend.designer.hdfsbrowse.hadoop.service.check.provider.CheckedKnoxNamenodeProvider 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;
}
Also used : HadoopServerException(org.talend.designer.hdfsbrowse.exceptions.HadoopServerException) HadoopServiceProperties(org.talend.designer.hdfsbrowse.hadoop.service.HadoopServiceProperties) CheckedKnoxNamenodeProvider(org.talend.designer.hdfsbrowse.hadoop.service.check.provider.CheckedKnoxNamenodeProvider) ConnectionStatus(org.talend.core.repository.model.connection.ConnectionStatus) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ConnectionStatus (org.talend.core.repository.model.connection.ConnectionStatus)1 HadoopServerException (org.talend.designer.hdfsbrowse.exceptions.HadoopServerException)1 HadoopServiceProperties (org.talend.designer.hdfsbrowse.hadoop.service.HadoopServiceProperties)1 CheckedKnoxNamenodeProvider (org.talend.designer.hdfsbrowse.hadoop.service.check.provider.CheckedKnoxNamenodeProvider)1