use of org.talend.hadoop.distribution.model.DistributionBean in project tbd-studio-se by Talend.
the class DistributionsManager method addDistribution.
private void addDistribution(BundleContext bc, Map<String, DistributionBean> disctributionsMap, ComponentType type, ServiceReference<? extends HadoopComponent> sr) {
HadoopComponent hc = bc.getService(sr);
if (hc != null && hc.isActivated()) {
final String distribution = hc.getDistribution();
final String distributionName = hc.getDistributionName();
String key = getKey(hc);
DistributionBean distributionBean = disctributionsMap.get(key);
if (distributionBean == null) {
distributionBean = new DistributionBean(type, distribution, distributionName, ((AbstractDistribution) hc).isSparkLocal());
if (ISparkDistribution.DISTRIBUTION_NAME.equals(distribution)) {
distributionBean.setHadoopFSVersions(((AbstractDistribution) hc).getSupportedHadoopFSVersion());
distributionBean.setHiveVersions(((AbstractDistribution) hc).getSupportedHiveVersion());
distributionBean.sethBaseVersions(((AbstractDistribution) hc).getSupportedHBaseVersion());
distributionBean.sethCatalogVersions(((AbstractDistribution) hc).getSupportedHCatalogVersion());
}
disctributionsMap.put(key, distributionBean);
} else {
// check the name and displayName
if (!distribution.equals(distributionBean.name) || !distributionName.equals(distributionBean.displayName)) {
// $NON-NLS-1$
CommonExceptionHandler.warn(" There are different distribution name for " + distributionBean);
return;
}
}
clearCache();
DistributionVersion versionBean = null;
final String version = hc.getVersion();
if (hc instanceof AbstractDynamicDistributionTemplate) {
AbstractDynamicDistributionTemplate dynamicDistribution = (AbstractDynamicDistributionTemplate) hc;
versionBean = new DynamicDistributionVersion(dynamicDistribution, distributionBean, type, version, hc.getVersionName(type));
} else {
versionBean = new DistributionVersion(hc, distributionBean, version, hc.getVersionName(type));
}
versionBean.addModuleGroups(hc.getModuleGroups(type));
// special condition for current version
versionBean.displayCondition = hc.getDisplayCondition(type);
distributionBean.addVersion(versionBean);
// add all version conditions ?
distributionBean.addCondition(hc.getDisplayCondition(type));
}
}
use of org.talend.hadoop.distribution.model.DistributionBean in project tbd-studio-se by Talend.
the class HadoopClusterForm method init.
public void init() {
final DistributionBean distribution = HadoopDistributionsHelper.HADOOP.getDistribution(getConnection().getDistribution(), false);
if (distribution != null) {
distributionCombo.setText(distribution.displayName);
} else {
distributionCombo.select(0);
}
updateVersionPart();
updateKnoxPart();
useYarnButton.setSelection(getConnection().isUseYarn());
String useKnoxStr = getConnection().getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USE_KNOX);
useKnoxButton.setSelection("true".equals(useKnoxStr));
switchToInfoForm();
updateStatus(IStatus.OK, EMPTY_STRING);
}
use of org.talend.hadoop.distribution.model.DistributionBean in project tbd-studio-se by Talend.
the class HadoopClusterForm method addFieldsListeners.
@Override
protected void addFieldsListeners() {
distributionCombo.addModifyListener(new ModifyListener() {
@Override
public void modifyText(final ModifyEvent e) {
String newDistributionDisplayName = distributionCombo.getText();
DistributionBean newDistribution = HadoopDistributionsHelper.HADOOP.getDistribution(newDistributionDisplayName, true);
String newDistributionName = newDistribution.name;
String originalDistributionName = getConnection().getDistribution();
getConnection().setDistribution(newDistributionName);
getConnection().setUseCustomVersion(newDistribution.useCustom());
boolean distrChanged = !StringUtils.equals(newDistributionName, originalDistributionName);
if (distrChanged) {
getConnection().setDfVersion(null);
}
updateVersionPart();
updateKnoxPart();
updateYarnContent();
updateKnoxContent();
switchToInfoForm();
checkFieldsValue();
}
});
versionCombo.addModifyListener(new ModifyListener() {
@Override
public void modifyText(final ModifyEvent e) {
String newVersionDisplayName = versionCombo.getText();
if (StringUtils.isEmpty(newVersionDisplayName)) {
return;
}
DistributionBean hadoopDistribution = HadoopDistributionsHelper.HADOOP.getDistribution(distributionCombo.getText(), true);
DistributionVersion hadoopVersion = hadoopDistribution.getVersion(newVersionDisplayName, true);
getConnection().setDfVersion(hadoopVersion.version);
if (hadoopVersion.hadoopComponent.isHadoop2() || hadoopVersion.hadoopComponent.isHadoop3()) {
getConnection().setUseYarn(true);
} else {
getConnection().setUseYarn(false);
}
updateKnoxPart();
updateYarnContent();
updateKnoxContent();
switchToInfoForm();
checkFieldsValue();
}
});
customButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
HadoopCustomVersionDefineDialog customVersionDialog = new HadoopCustomVersionDefineDialog(getShell(), HCVersionUtil.getCustomVersionMap(getConnection()));
if (customVersionDialog.open() == Window.OK) {
HCVersionUtil.injectCustomVersionMap(getConnection(), customVersionDialog.getLibMap());
}
}
});
useYarnButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
getConnection().setUseYarn(useYarnButton.getSelection());
switchToInfoForm();
}
});
useKnoxButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String selection = String.valueOf(useKnoxButton.getSelection());
getConnection().getParameters().put(ConnParameterKeys.CONN_PARA_KEY_USE_KNOX, selection);
switchToInfoForm();
checkFieldsValue();
}
});
}
use of org.talend.hadoop.distribution.model.DistributionBean in project tbd-studio-se by Talend.
the class HadoopClusterForm method updateVersionPart.
private void updateVersionPart() {
DistributionBean distribution = HadoopDistributionsHelper.HADOOP.getDistribution(distributionCombo.getText(), true);
versionCombo.getCombo().setItems(distribution.getVersionsDisplay());
final DistributionVersion defaultVersion = distribution.getDefaultVersion();
DistributionVersion hadoopVersion = distribution.getVersion(getConnection().getDfVersion(), false);
if (hadoopVersion != null && hadoopVersion.displayVersion != null) {
versionCombo.setText(hadoopVersion.displayVersion);
} else if (defaultVersion != null) {
versionCombo.setText(defaultVersion.displayVersion);
} else {
versionCombo.getCombo().select(0);
}
if (distribution.useCustom()) {
versionCombo.setHideWidgets(true);
hideControl(useYarnButton, false);
hideControl(customButton, false);
} else {
versionCombo.setHideWidgets(false);
hideControl(useYarnButton, true);
hideControl(customButton, true);
}
}
use of org.talend.hadoop.distribution.model.DistributionBean 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