Search in sources :

Example 6 with ComponentTestResult

use of com.dtstack.taier.pluginapi.pojo.ComponentTestResult in project Taier by DTStack.

the class AbstractRdbsClient method testConnect.

@Override
public ComponentTestResult testConnect(String pluginInfo) {
    ComponentTestResult componentTestResult = new ComponentTestResult();
    try {
        Properties properties = PublicUtil.jsonStrToObject(pluginInfo, Properties.class);
        if (null == connFactory) {
            synchronized (AbstractRdbsClient.class) {
                if (null == connFactory) {
                    connFactory = getConnFactory();
                }
            }
        }
        connFactory.init(properties);
        componentTestResult.setResult(true);
    } catch (Exception e) {
        componentTestResult.setErrorMsg(ExceptionUtil.getErrorMessage(e));
        componentTestResult.setResult(false);
    }
    return componentTestResult;
}
Also used : ComponentTestResult(com.dtstack.taier.pluginapi.pojo.ComponentTestResult) Properties(java.util.Properties) IOException(java.io.IOException) PluginDefineException(com.dtstack.taier.pluginapi.exception.PluginDefineException)

Example 7 with ComponentTestResult

use of com.dtstack.taier.pluginapi.pojo.ComponentTestResult in project Taier by DTStack.

the class DummyClient method testConnect.

@Override
public ComponentTestResult testConnect(String pluginInfo) {
    ComponentTestResult componentTestResult = new ComponentTestResult();
    try {
        SftpConfig sftpConfig = PublicUtil.jsonStrToObject(pluginInfo, SftpConfig.class);
        // check sftpConfig 准确性
        SftpFileManage sftpFileManage = SftpFileManage.getSftpManager(sftpConfig);
        // 测试路径是否存在
        Vector res = sftpFileManage.listFile(sftpConfig.getPath());
        if (null != res) {
            componentTestResult.setResult(true);
        }
    } catch (Exception e) {
        componentTestResult.setErrorMsg(ExceptionUtil.getErrorMessage(e));
        componentTestResult.setResult(false);
    }
    return componentTestResult;
}
Also used : SftpFileManage(com.dtstack.taier.pluginapi.sftp.SftpFileManage) ComponentTestResult(com.dtstack.taier.pluginapi.pojo.ComponentTestResult) SftpConfig(com.dtstack.taier.pluginapi.sftp.SftpConfig) Vector(java.util.Vector) IOException(java.io.IOException)

Example 8 with ComponentTestResult

use of com.dtstack.taier.pluginapi.pojo.ComponentTestResult in project Taier by DTStack.

the class HadoopClient method checkHdfsConnect.

private ComponentTestResult checkHdfsConnect(Config testConnectConf) {
    // 测试hdfs联通性
    ComponentTestResult componentTestResult = new ComponentTestResult();
    try {
        if (null == testConnectConf) {
            componentTestResult.setResult(false);
            componentTestResult.setErrorMsg("配置信息不能你为空");
            return componentTestResult;
        }
        KerberosUtils.login(testConnectConf, () -> {
            HadoopConf hadoopConf = new HadoopConf();
            hadoopConf.initHadoopConf(testConnectConf.getHadoopConf());
            Configuration configuration = hadoopConf.getConfiguration();
            FileSystem fs = null;
            try {
                fs = FileSystem.get(configuration);
            } catch (Exception e) {
                componentTestResult.setResult(false);
                componentTestResult.setErrorMsg(ExceptionUtil.getErrorMessage(e));
                return componentTestResult;
            } finally {
                if (null != fs) {
                    try {
                        fs.close();
                    } catch (IOException e) {
                        LOG.error("close file system error ", e);
                    }
                }
            }
            componentTestResult.setResult(true);
            return componentTestResult;
        }, KerberosUtils.convertMapConfToConfiguration(testConnectConf.getHadoopConf()));
    } catch (Exception e) {
        LOG.error("close hdfs connect  error ", e);
        componentTestResult.setResult(false);
        componentTestResult.setErrorMsg(ExceptionUtil.getErrorMessage(e));
    }
    return componentTestResult;
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) ComponentTestResult(com.dtstack.taier.pluginapi.pojo.ComponentTestResult) FileSystem(org.apache.hadoop.fs.FileSystem) HadoopConf(com.dtstack.taier.hadoop.util.HadoopConf) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) PluginDefineException(com.dtstack.taier.pluginapi.exception.PluginDefineException)

Example 9 with ComponentTestResult

use of com.dtstack.taier.pluginapi.pojo.ComponentTestResult in project Taier by DTStack.

the class HadoopClient method testConnect.

/**
 * 测试联通性 yarn需要返回集群队列信息
 * @param pluginInfo
 * @return
 */
@Override
public ComponentTestResult testConnect(String pluginInfo) {
    ComponentTestResult testResult = new ComponentTestResult();
    testResult.setResult(false);
    try {
        Config allConfig = PublicUtil.jsonStrToObject(pluginInfo, Config.class);
        if ("hdfs".equalsIgnoreCase(allConfig.getComponentName())) {
            // 测试hdfs联通性
            return this.checkHdfsConnect(allConfig);
        }
        return KerberosUtils.login(allConfig, () -> testYarnConnect(testResult, allConfig), KerberosUtils.convertMapConfToConfiguration(allConfig.getYarnConf()));
    } catch (Exception e) {
        LOG.error("test yarn connect error", e);
        testResult.setErrorMsg(ExceptionUtil.getErrorMessage(e));
    }
    return testResult;
}
Also used : ComponentTestResult(com.dtstack.taier.pluginapi.pojo.ComponentTestResult) MRJobConfig(org.apache.hadoop.mapreduce.MRJobConfig) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) PluginDefineException(com.dtstack.taier.pluginapi.exception.PluginDefineException)

Example 10 with ComponentTestResult

use of com.dtstack.taier.pluginapi.pojo.ComponentTestResult in project Taier by DTStack.

the class DtYarnClient method testConnect.

/**
 * 测试联通性 yarn需要返回集群队列信息
 * @param pluginInfo
 * @return
 */
@Override
public ComponentTestResult testConnect(String pluginInfo) {
    ComponentTestResult testResult = new ComponentTestResult();
    testResult.setResult(false);
    try {
        Config allConfig = PublicUtil.jsonStrToObject(pluginInfo, Config.class);
        Configuration configuration = this.initYarnConf(allConfig.getYarnConf());
        return KerberosUtils.login(allConfig, () -> testYarnConnect(testResult, allConfig), configuration);
    } catch (Exception e) {
        LOG.error("test yarn connect error", e);
        testResult.setErrorMsg(ExceptionUtil.getErrorMessage(e));
    }
    return testResult;
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) ComponentTestResult(com.dtstack.taier.pluginapi.pojo.ComponentTestResult) IOException(java.io.IOException) PluginDefineException(com.dtstack.taier.pluginapi.exception.PluginDefineException)

Aggregations

ComponentTestResult (com.dtstack.taier.pluginapi.pojo.ComponentTestResult)15 PluginDefineException (com.dtstack.taier.pluginapi.exception.PluginDefineException)8 IOException (java.io.IOException)8 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)3 JSONObject (com.alibaba.fastjson.JSONObject)2 PartCluster (com.dtstack.taier.develop.model.PartCluster)2 HadoopConf (com.dtstack.taier.hadoop.util.HadoopConf)2 SftpConfig (com.dtstack.taier.pluginapi.sftp.SftpConfig)2 SftpFileManage (com.dtstack.taier.pluginapi.sftp.SftpFileManage)2 Configuration (org.apache.hadoop.conf.Configuration)2 YarnClient (org.apache.hadoop.yarn.client.api.YarnClient)2 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)2 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)2 JSONArray (com.alibaba.fastjson.JSONArray)1 ZIP_SUFFIX (com.dtstack.taier.common.constant.CommonConstant.ZIP_SUFFIX)1 DictType (com.dtstack.taier.common.enums.DictType)1 DownloadType (com.dtstack.taier.common.enums.DownloadType)1 EComponentType (com.dtstack.taier.common.enums.EComponentType)1 EnvironmentContext (com.dtstack.taier.common.env.EnvironmentContext)1 ErrorCode (com.dtstack.taier.common.exception.ErrorCode)1