use of org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem in project tbd-studio-se by Talend.
the class CreateHBaseAction method hideAction.
@Override
protected boolean hideAction(RepositoryNode node) {
HadoopClusterConnectionItem hcConnectionItem = HCRepositoryUtil.getHCConnectionItemFromRepositoryNode(node);
if (hcConnectionItem != null) {
HadoopClusterConnection hcConnection = (HadoopClusterConnection) hcConnectionItem.getConnection();
DistributionBean hbaseDistribution = HadoopDistributionsHelper.HBASE.getDistribution(hcConnection.getDistribution(), false);
if (hbaseDistribution != null) {
IHDistributionVersion hdVersion = hbaseDistribution.getHDVersion(hcConnection.getDfVersion(), false);
if (hdVersion != null) {
// found, don't hide
return false;
}
}
}
return true;
}
use of org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem in project tbd-studio-se by Talend.
the class AbstractHadoopSubnodeRepositoryContentHandler method deleteNode.
@Override
protected void deleteNode(Item item) throws Exception {
if (item instanceof HadoopSubConnectionItem) {
HadoopSubConnectionItem hadoopSubConnectionItem = (HadoopSubConnectionItem) item;
HadoopClusterConnectionItem hadoopClusterItem = HCRepositoryUtil.getRelativeHadoopClusterItem(hadoopSubConnectionItem);
if (hadoopClusterItem != null) {
HCRepositoryUtil.removeFromHadoopCluster(hadoopClusterItem, hadoopSubConnectionItem.getProperty().getId());
}
}
}
use of org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem in project tbd-studio-se by Talend.
the class HDFSConnectionCreator method initializeConnectionParameters.
@Override
protected void initializeConnectionParameters(Connection conn) {
if (!(conn instanceof HDFSConnection)) {
return;
}
HDFSConnection connection = (HDFSConnection) conn;
if (relativeHadoopClusterItem instanceof HadoopClusterConnectionItem) {
HadoopClusterConnection hcConnection = (HadoopClusterConnection) ((HadoopClusterConnectionItem) relativeHadoopClusterItem).getConnection();
String userName = ConnectionContextHelper.getParamValueOffContext(hcConnection, hcConnection.getUserName());
if (userName != null) {
connection.setUserName(userName);
}
}
connection.setRowSeparator(IExtractSchemaService.DEFAULT_ROW_SEPARATOR);
connection.setFieldSeparator(IExtractSchemaService.DEFAULT_FIELD_SEPARATOR);
}
use of org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem in project tbd-studio-se by Talend.
the class HadoopClusterService method copyHadoopCluster.
@Override
public void copyHadoopCluster(final Item sourceItem, final IPath path, String newName) throws PersistenceException, BusinessException {
if (isHadoopClusterItem(sourceItem)) {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
HadoopClusterConnectionItem sourceClusterItem = (HadoopClusterConnectionItem) sourceItem;
HadoopClusterConnectionItem targetClusterItem = null;
if (StringUtils.isNotBlank(newName)) {
targetClusterItem = (HadoopClusterConnectionItem) factory.copy(sourceClusterItem, path, newName);
} else {
targetClusterItem = (HadoopClusterConnectionItem) factory.copy(sourceClusterItem, path, true);
}
HadoopClusterConnection targetClusterConnection = (HadoopClusterConnection) targetClusterItem.getConnection();
targetClusterConnection.getConnectionList().clear();
String targetClusterId = targetClusterItem.getProperty().getId();
Set<Item> sourceSubitems = HCRepositoryUtil.getSubitemsOfHadoopCluster(sourceClusterItem);
for (Item subitem : sourceSubitems) {
Item newSubitem = factory.copy(subitem, path, true);
if (newSubitem instanceof HadoopSubConnectionItem) {
((HadoopSubConnection) ((HadoopSubConnectionItem) newSubitem).getConnection()).setRelativeHadoopClusterId(targetClusterId);
targetClusterConnection.getConnectionList().add(newSubitem.getProperty().getId());
} else if (subitem instanceof DatabaseConnectionItem) {
((DatabaseConnection) ((DatabaseConnectionItem) newSubitem).getConnection()).getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID, targetClusterId);
}
factory.save(newSubitem);
}
factory.save(targetClusterItem);
}
}
use of org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem in project tbd-studio-se by Talend.
the class AdaptDeprecatedHadoopVersionsMigrationTask method execute.
@Override
public ExecutionResult execute(Item item) {
if (item instanceof HadoopClusterConnectionItem) {
DistributionBean[] distributions = HadoopDistributionsHelper.HADOOP.getDistributions();
if (distributions != null && distributions.length > 0) {
boolean modified = false;
HadoopClusterConnectionItem hcItem = (HadoopClusterConnectionItem) item;
HadoopClusterConnection hcConnection = (HadoopClusterConnection) hcItem.getConnection();
DistributionBean distributionBean = HadoopDistributionsHelper.HADOOP.getDistribution(hcConnection.getDistribution(), false);
if (distributionBean == null) {
distributionBean = distributions[0];
hcConnection.setDistribution(distributionBean.getName());
modified = true;
}
String version = hcConnection.getDfVersion();
DistributionVersion distributionVersion = distributionBean.getVersion(version, false);
if (distributionVersion == null) {
DistributionVersion[] versions = distributionBean.getVersions();
if (versions != null && versions.length > 0) {
hcConnection.setDfVersion(versions[0].getVersion());
modified = true;
}
}
if (modified) {
try {
ProxyRepositoryFactory.getInstance().save(hcItem, true);
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
}
return ExecutionResult.NOTHING_TO_DO;
}
Aggregations