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