Search in sources :

Example 1 with IDependencyResolver

use of org.talend.hadoop.distribution.dynamic.resolver.IDependencyResolver in project tbd-studio-se by Talend.

the class DynamicDistributionManager method getDependencyResolver.

public IDependencyResolver getDependencyResolver(DynamicConfiguration config) throws Exception {
    String distribution = config.getDistribution();
    IDynamicDistributionsGroup dynamicDistributionGroup = getDynamicDistributionGroup(distribution);
    IDependencyResolver resolver = null;
    if (dynamicDistributionGroup != null) {
        resolver = dynamicDistributionGroup.getDependencyResolver(config);
    }
    if (resolver == null) {
        throw new Exception("Can't find DependencyResolver for " + distribution);
    }
    return resolver;
}
Also used : IDependencyResolver(org.talend.hadoop.distribution.dynamic.resolver.IDependencyResolver)

Example 2 with IDependencyResolver

use of org.talend.hadoop.distribution.dynamic.resolver.IDependencyResolver in project tbd-studio-se by Talend.

the class AbstractDynamicDistributionsGroup method buildAllVersionList.

private List<String> buildAllVersionList(IDynamicMonitor monitor) throws Exception {
    Set<String> allVersion = new HashSet<>();
    DynamicDistributionManager dynamicDistributionManager = DynamicDistributionManager.getInstance();
    DynamicConfiguration dynamicConfiguration = new DynamicConfiguration();
    dynamicConfiguration.setDistribution(getDistribution());
    IDependencyResolver dependencyResolver = dynamicDistributionManager.getDependencyResolver(dynamicConfiguration);
    List<String> allHadoopVersions = dependencyResolver.listHadoopVersions(null, null, monitor);
    if (allHadoopVersions != null) {
        allVersion.addAll(allHadoopVersions);
    }
    List<String> versionList = new LinkedList<>(allVersion);
    Collections.sort(versionList, Collections.reverseOrder(new VersionStringComparator()));
    return new ArrayList<>(versionList);
}
Also used : VersionStringComparator(org.talend.designer.maven.aether.comparator.VersionStringComparator) ArrayList(java.util.ArrayList) IDependencyResolver(org.talend.hadoop.distribution.dynamic.resolver.IDependencyResolver) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 3 with IDependencyResolver

use of org.talend.hadoop.distribution.dynamic.resolver.IDependencyResolver 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);
            }
        });
    }
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) LoginException(org.talend.commons.exception.LoginException) InvocationTargetException(java.lang.reflect.InvocationTargetException) PersistenceException(org.talend.commons.exception.PersistenceException) IDependencyResolver(org.talend.hadoop.distribution.dynamic.resolver.IDependencyResolver) DynamicDistributionSetupWizard(org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupWizard) ModifyEvent(org.eclipse.swt.events.ModifyEvent) IDynamicDistributionsGroup(org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup) DynamicConfiguration(org.talend.hadoop.distribution.dynamic.DynamicConfiguration) TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) DummyDynamicMonitor(org.talend.designer.maven.aether.DummyDynamicMonitor) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DynamicDistributionSetupData(org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData) WizardDialog(org.eclipse.jface.wizard.WizardDialog) IDynamicMonitor(org.talend.designer.maven.aether.IDynamicMonitor)

Example 4 with IDependencyResolver

use of org.talend.hadoop.distribution.dynamic.resolver.IDependencyResolver in project tbd-studio-se by Talend.

the class AbstractDynamicDistribution method getCompatibleVersions.

@Override
public List<String> getCompatibleVersions(IDynamicMonitor monitor) throws Exception {
    Set<String> allCompatibleVersion = new HashSet<>();
    List<TemplateBean> templates = getTemplates(monitor);
    if (templates != null) {
        DynamicDistributionUtils.checkCancelOrNot(monitor);
        templateBeanCompatibleVersionMap = new HashMap<>();
        DynamicDistributionManager dynamicDistributionManager = DynamicDistributionManager.getInstance();
        DynamicConfiguration dynamicConfiguration = new DynamicConfiguration();
        dynamicConfiguration.setDistribution(getDistributionName());
        IDependencyResolver dependencyResolver = dynamicDistributionManager.getDependencyResolver(dynamicConfiguration);
        List<String> allHadoopVersions = dependencyResolver.listHadoopVersions(null, null, monitor);
        if (allHadoopVersions != null) {
            for (TemplateBean templateBean : templates) {
                DynamicDistributionUtils.checkCancelOrNot(monitor);
                String baseVersion = templateBean.getBaseVersion();
                String topVersion = templateBean.getTopVersion();
                // $NON-NLS-1$
                String versionRange = "[";
                if (StringUtils.isEmpty(baseVersion)) {
                    // $NON-NLS-1$
                    versionRange = versionRange + "0";
                } else {
                    versionRange = versionRange + baseVersion;
                }
                // $NON-NLS-1$
                versionRange = versionRange + ",";
                if (StringUtils.isNotEmpty(topVersion)) {
                    versionRange = versionRange + topVersion;
                }
                // $NON-NLS-1$
                versionRange = versionRange + ")";
                List<String> filteredVersions = DynamicDistributionAetherUtils.filterVersions(allHadoopVersions, versionRange);
                if (filteredVersions != null && !filteredVersions.isEmpty()) {
                    allCompatibleVersion.addAll(filteredVersions);
                    templateBeanCompatibleVersionMap.put(templateBean, filteredVersions);
                }
            }
        }
    }
    List<String> compatibleVersionList = new LinkedList<>(allCompatibleVersion);
    Collections.sort(compatibleVersionList, Collections.reverseOrder(new VersionStringComparator()));
    return compatibleVersionList;
}
Also used : VersionStringComparator(org.talend.designer.maven.aether.comparator.VersionStringComparator) TemplateBean(org.talend.hadoop.distribution.dynamic.bean.TemplateBean) IDependencyResolver(org.talend.hadoop.distribution.dynamic.resolver.IDependencyResolver) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 5 with IDependencyResolver

use of org.talend.hadoop.distribution.dynamic.resolver.IDependencyResolver in project tbd-studio-se by Talend.

the class AbstractDynamicDistribution method getAllVersions.

@Override
public List<String> getAllVersions(IDynamicMonitor monitor) throws Exception {
    Set<String> allVersion = new HashSet<>();
    DynamicDistributionManager dynamicDistributionManager = DynamicDistributionManager.getInstance();
    DynamicConfiguration dynamicConfiguration = new DynamicConfiguration();
    dynamicConfiguration.setDistribution(getDistributionName());
    IDependencyResolver dependencyResolver = dynamicDistributionManager.getDependencyResolver(dynamicConfiguration);
    List<String> allHadoopVersions = dependencyResolver.listHadoopVersions(null, null, monitor);
    if (allHadoopVersions != null) {
        allVersion.addAll(allHadoopVersions);
    }
    List<String> versionList = new LinkedList<>(allVersion);
    Collections.sort(versionList, Collections.reverseOrder(new VersionStringComparator()));
    return versionList;
}
Also used : VersionStringComparator(org.talend.designer.maven.aether.comparator.VersionStringComparator) IDependencyResolver(org.talend.hadoop.distribution.dynamic.resolver.IDependencyResolver) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Aggregations

IDependencyResolver (org.talend.hadoop.distribution.dynamic.resolver.IDependencyResolver)7 HashSet (java.util.HashSet)4 LinkedList (java.util.LinkedList)3 VersionStringComparator (org.talend.designer.maven.aether.comparator.VersionStringComparator)3 DynamicConfiguration (org.talend.hadoop.distribution.dynamic.DynamicConfiguration)3 TemplateBean (org.talend.hadoop.distribution.dynamic.bean.TemplateBean)3 DynamicDistributionManager (org.talend.hadoop.distribution.dynamic.DynamicDistributionManager)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Test (org.junit.Test)1 LoginException (org.talend.commons.exception.LoginException)1 PersistenceException (org.talend.commons.exception.PersistenceException)1