use of org.talend.hadoop.distribution.dynamic.DynamicConfiguration in project tbd-studio-se by Talend.
the class DynamicDistribConfigAdapter method adapt.
public IDynamicPluginConfiguration adapt(IDynamicMonitor monitor) throws Exception {
DynamicDistributionUtils.checkCancelOrNot(monitor);
resolve();
IDynamicPluginConfiguration pluginConfiguration = DynamicFactory.getInstance().createDynamicPluginConfiguration();
TemplateBean templateBean = getTemplateBean();
DynamicConfiguration configuration = getConfiguration();
String distribution = templateBean.getDistribution();
String templateId = templateBean.getTemplateId();
if (!StringUtils.equals(distribution, configuration.getDistribution())) {
throw new Exception(// $NON-NLS-1$
Messages.getString("DynamicDistriConfigAdapter.diffDistri", distribution, configuration.getDistribution()));
}
String projectTechnicalName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
// String id = projectTechnicalName + "_" + configuration.getId(); //$NON-NLS-1$
String id = configuration.getId();
pluginConfiguration.setId(id);
pluginConfiguration.setName(configuration.getName());
pluginConfiguration.setVersion(configuration.getVersion());
pluginConfiguration.setDescription(configuration.getDescription());
pluginConfiguration.setDistribution(distribution);
pluginConfiguration.setTemplateId(templateId);
pluginConfiguration.setRepository(configuration.getRemoteRepositoryUrl());
pluginConfiguration.setAttribute(DynamicConstants.ATTR_PROJECT_TECHNICAL_NAME, projectTechnicalName);
pluginConfiguration.setAttribute(DynamicConstants.ATTR_SELECTED_SPARK_VERSIONS, DynamicDistributionUtils.convert2SparkVersions(configuration.getSelectedSparkVersions()));
return pluginConfiguration;
}
use of org.talend.hadoop.distribution.dynamic.DynamicConfiguration in project tbd-studio-se by Talend.
the class AbstractDependencyResolver method listHadoopVersions.
@Override
public List<String> listHadoopVersions(String baseVersion, String topVersion, IDynamicMonitor monitor) throws Exception {
// $NON-NLS-1$
String groupId = "org.apache.hadoop";
// $NON-NLS-1$
String artifactId = "hadoop-client";
DynamicConfiguration configuration = getConfiguration();
IDynamicDistributionPreference preference = configuration.getPreference();
String remoteRepositoryUrl = preference.getRepository();
String username = null;
String password = null;
if (!preference.isAnonymous()) {
username = preference.getUsername();
password = preference.getPassword();
}
String localRepositoryPath = getLocalRepositoryPath();
List<String> versionRange = DynamicDistributionAetherUtils.versionRange(remoteRepositoryUrl, username, password, localRepositoryPath, groupId, artifactId, baseVersion, topVersion, monitor);
return getCleanHadoopVersion(versionRange);
}
use of org.talend.hadoop.distribution.dynamic.DynamicConfiguration in project tbd-studio-se by Talend.
the class AbstractDependencyResolver method getDependencyVersionByHadoopVersion.
@Override
public String getDependencyVersionByHadoopVersion(String groupId, String artifactId, IDynamicMonitor monitor) throws Exception {
DynamicConfiguration configuration = getConfiguration();
String distributionVersion = configuration.getVersion();
IDynamicDistributionPreference preference = configuration.getPreference();
String remoteRepositoryUrl = preference.getRepository();
String username = null;
String password = null;
if (!preference.isAnonymous()) {
username = preference.getUsername();
password = preference.getPassword();
}
String localRepositoryPath = getLocalRepositoryPath();
List<String> versionRange = DynamicDistributionAetherUtils.versionRange(remoteRepositoryUrl, username, password, localRepositoryPath, groupId, artifactId, null, null, monitor);
String dependencyVersion = getVersionByHadoopVersion(versionRange, distributionVersion);
return dependencyVersion;
}
use of org.talend.hadoop.distribution.dynamic.DynamicConfiguration in project tbd-studio-se by Talend.
the class DynamicLibraryNeededExtensionAdaper method adapt.
public IDynamicExtension adapt(IDynamicMonitor monitor) throws Exception {
DynamicDistributionUtils.checkCancelOrNot(monitor);
resolve();
TemplateBean templateBean = getTemplateBean();
DynamicConfiguration configuration = getConfiguration();
String templateId = templateBean.getId();
String distributionName = configuration.getDistribution();
String id = configuration.getId();
IDynamicExtension libNeededExtension = DynamicFactory.getInstance().createDynamicExtension();
libNeededExtension.setExtensionId(DynamicDistributionUtils.getExtensionId(DynamicDistributionUtils.getPluginKey(distributionName, templateId, id, ATTR_POINT)));
libNeededExtension.setExtensionPoint(ATTR_POINT);
List<ModuleBean> modules = templateBean.getModules();
if (modules != null) {
try {
Exception[] ex = new Exception[1];
Set<String> registedModules = Collections.synchronizedSet(new LinkedHashSet<>());
for (ModuleBean moduleBean : modules) {
DynamicDistributionUtils.checkCancelOrNot(monitor);
Runnable runnable = new Runnable() {
int count = 0;
@Override
public void run() {
try {
DynamicModuleAdapter dynamicModuleAdapter = new DynamicModuleAdapter(templateBean, configuration, moduleBean, dependencyResolver, registedModules);
List<IDynamicConfiguration> librariesNeeded = dynamicModuleAdapter.adapt(monitor, isEnableMultiThread());
if (librariesNeeded != null && !librariesNeeded.isEmpty()) {
addDynamicConfigurations(libNeededExtension, librariesNeeded);
}
String beanId = moduleBean.getId();
moduleBeanAdapterMap.put(beanId, dynamicModuleAdapter);
} catch (Exception e) {
Throwable rootCause = ExceptionUtils.getRootCause(e);
if (e instanceof FileNotFoundException || rootCause instanceof FileNotFoundException) {
if (count < 5) {
count++;
run();
} else {
ex[0] = e;
}
} else {
ex[0] = e;
}
}
}
};
if (isEnableMultiThread()) {
getThreadPool().execute(runnable);
continue;
} else {
runnable.run();
if (ex[0] != null) {
throw ex[0];
}
}
}
if (isEnableMultiThread()) {
int totalTasks = modules.size();
if (monitor != null) {
monitor.beginTask(// $NON-NLS-1$
Messages.getString("DynamicLibraryNeededExtensionAdaper.monitor.waitAllFinish", totalTasks), totalTasks);
}
int completed = 0;
while (true) {
int activeCount = getThreadPool().getActiveCount();
if (activeCount <= 0) {
break;
}
if (monitor != null) {
int newCompleted = (int) getThreadPool().getCompletedTaskCount();
int newWorked = newCompleted - completed;
completed = newCompleted;
monitor.setTaskName(// $NON-NLS-1$
Messages.getString(// $NON-NLS-1$
"DynamicLibraryNeededExtensionAdaper.monitor.waitAllFinish", activeCount));
monitor.worked(newWorked);
}
Thread.sleep(200);
DynamicDistributionUtils.checkCancelOrNot(monitor);
if (ex[0] != null) {
throw ex[0];
}
}
}
} finally {
if (isEnableMultiThread()) {
if (monitor != null) {
// $NON-NLS-1$
monitor.beginTask("", IProgressMonitor.UNKNOWN);
}
getThreadPool().clearThreads();
threadPool = null;
}
}
}
List<ModuleGroupBean> moduleGroups = templateBean.getModuleGroups();
if (moduleGroups != null) {
for (ModuleGroupBean moduleGroupBean : moduleGroups) {
DynamicDistributionUtils.checkCancelOrNot(monitor);
DynamicModuleGroupAdapter libNeededGroupAdapter = new DynamicModuleGroupAdapter(templateBean, configuration, moduleGroupBean, moduleBeanAdapterMap);
IDynamicConfiguration dynamicModuleGroup = libNeededGroupAdapter.adapt(monitor);
if (dynamicModuleGroup != null) {
libNeededExtension.addConfiguration(dynamicModuleGroup);
String groupId = moduleGroupBean.getId();
moduleGroupBeanAdapterMap.put(groupId, libNeededGroupAdapter);
}
}
}
return libNeededExtension;
}
use of org.talend.hadoop.distribution.dynamic.DynamicConfiguration in project tbd-studio-se by Talend.
the class DynamicDistributionPreferenceForm method addListeners.
private void addListeners() {
if (ITalendCorePrefConstants.DYNAMIC_DISTRIBUTION_SETTING == showPart) {
distributionCombo.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
refreshVersionList(new DummyDynamicMonitor());
updateButtons();
}
});
versionCombo.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
updateButtons();
}
});
buildConfigBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
try {
IStructuredSelection selection = (IStructuredSelection) distributionCombo.getSelection();
if (selection == null) {
ExceptionHandler.process(new Exception(// $NON-NLS-1$
Messages.getString("DynamicDistributionPreferenceForm.exception.noDistributionSelected")));
return;
}
String distribution = (String) selection.getFirstElement();
if (distribution == null) {
ExceptionHandler.process(new Exception(// $NON-NLS-1$
Messages.getString("DynamicDistributionPreferenceForm.exception.noDistributionSelected")));
return;
}
IDynamicDistributionsGroup dynamicDistributionsGroup = DynamicDistributionManager.getInstance().getDynamicDistributionGroup(distribution);
DynamicDistributionSetupData configData = new DynamicDistributionSetupData();
configData.setDynamicDistributionsGroup(dynamicDistributionsGroup);
DynamicDistributionSetupWizard wizard = new DynamicDistributionSetupWizard(configData);
WizardDialog wizardDialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard);
wizardDialog.setMinimumPageSize(600, 400);
wizardDialog.create();
if (wizardDialog.open() == IDialogConstants.OK_ID) {
// nothing to do
}
IDynamicMonitor monitor = new DummyDynamicMonitor();
refreshVersionList(monitor);
} catch (Throwable ex) {
ExceptionHandler.process(ex);
}
updateButtons();
}
});
deleteBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
onDeleteBtnPressed();
updateButtons();
}
});
} else {
setupDistriCombo.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
try {
loadRepositorySetupGroup();
} catch (Exception e) {
ExceptionHandler.process(e);
}
updateButtons();
}
});
overrideDefaultSetupBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateButtons();
}
});
repositoryText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String newRepositoryText = repositoryText.getText();
if (StringUtils.equals(newRepositoryText, repositoryUrlCache)) {
return;
}
repositoryUrlCache = newRepositoryText;
updateButtons();
}
});
anonymousBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateButtons();
}
});
userText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String newUsername = userText.getText();
if (StringUtils.equals(newUsername, usernameCache)) {
return;
}
usernameCache = newUsername;
updateButtons();
}
});
passwordText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String newPassword = passwordText.getText();
if (StringUtils.equals(newPassword, passwordCache)) {
return;
}
passwordCache = newPassword;
updateButtons();
}
});
checkConnectionBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (!isComplete()) {
return;
}
TypedReturnCode tc = new TypedReturnCode();
try {
IDynamicDistributionsGroup distriGroup = getSelectedSetupDynamicDistriGroup();
DynamicConfiguration dynamicConfiguration = new DynamicConfiguration();
dynamicConfiguration.setDistribution(distriGroup.getDistribution());
IDependencyResolver dependencyResolver = distriGroup.getDependencyResolver(dynamicConfiguration);
tc = dependencyResolver.checkConnection(repositoryText.getText(), userText.getText(), passwordText.getText());
} catch (Exception e1) {
ExceptionHandler.process(e1);
tc.setOk(false);
tc.setMessage(e1.getMessage());
}
showCheckConnectionInformation(true, tc);
}
});
}
}
Aggregations