Search in sources :

Example 11 with HadoopServerException

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;
}
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

HadoopServerException (org.talend.designer.hdfsbrowse.exceptions.HadoopServerException)11 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 IOException (java.io.IOException)4 DynamicClassLoader (org.talend.core.classloader.DynamicClassLoader)3 URI (java.net.URI)2 BufferedInputStream (java.io.BufferedInputStream)1 DataOutputStream (java.io.DataOutputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 MalformedURLException (java.net.MalformedURLException)1 Entry (java.util.Map.Entry)1 ExecutorService (java.util.concurrent.ExecutorService)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 IHadoopClusterService (org.talend.core.hadoop.IHadoopClusterService)1 ConnectionStatus (org.talend.core.repository.model.connection.ConnectionStatus)1 ContextType (org.talend.designer.core.model.utils.emf.talendfile.ContextType)1 HadoopServiceProperties (org.talend.designer.hdfsbrowse.hadoop.service.HadoopServiceProperties)1 CheckedKnoxNamenodeProvider (org.talend.designer.hdfsbrowse.hadoop.service.check.provider.CheckedKnoxNamenodeProvider)1 HDFSFile (org.talend.designer.hdfsbrowse.model.HDFSFile)1