Search in sources :

Example 16 with IDynamicConfiguration

use of org.talend.core.runtime.dynamic.IDynamicConfiguration in project tbd-studio-se by Talend.

the class DynamicModuleGroupAdapter method adapt.

public IDynamicConfiguration adapt(IDynamicMonitor monitor) throws Exception {
    DynamicDistributionUtils.checkCancelOrNot(monitor);
    resolve();
    if (monitor != null) {
        monitor.setTaskName(// $NON-NLS-1$
        Messages.getString("DynamicModuleGroupAdapter.monitor.buildModuleGroup", moduleGroupBean.getId()));
    }
    DynamicConfiguration configuration = getConfiguration();
    String distribution = configuration.getDistribution();
    String version = configuration.getVersion();
    String id = configuration.getId();
    String moduleGroupId = moduleGroupBean.getId();
    String description = moduleGroupBean.getDescription();
    List<ESparkVersion> selectedSparkVersions = configuration.getSelectedSparkVersions();
    List<String> sparkVersions = moduleGroupBean.getSupportedSparkVersions();
    if (sparkVersions != null && !sparkVersions.isEmpty()) {
        boolean isSupport = false;
        for (String sparkVersion : sparkVersions) {
            try {
                ESparkVersion eSparkVersion = ESparkVersion.valueOf(sparkVersion);
                if (selectedSparkVersions.contains(eSparkVersion)) {
                    isSupport = true;
                    break;
                }
            } catch (Exception e) {
                ExceptionHandler.process(e);
            }
        }
        if (!isSupport) {
            return null;
        }
    }
    runtimeId = DynamicDistributionUtils.getPluginKey(distribution, version, id, moduleGroupId);
    IDynamicConfiguration dynamicModuleGroup = DynamicFactory.getInstance().createDynamicConfiguration();
    dynamicModuleGroup.setConfigurationName(TAG_NAME);
    dynamicModuleGroup.setAttribute(ATTR_ID, runtimeId);
    dynamicModuleGroup.setAttribute(ATTR_GROUP_TEMPLATE_ID, moduleGroupId);
    dynamicModuleGroup.setAttribute(ATTR_DESCRIPTION, description);
    List<String> modules = moduleGroupBean.getModules();
    Set<String> runtimeModulesSet = new HashSet<>();
    if (modules != null) {
        for (String module : modules) {
            DynamicModuleAdapter moduleAdapter = moduleBeanAdapterMap.get(module);
            if (moduleAdapter == null) {
                throw new Exception(// $NON-NLS-1$
                Messages.getString(// $NON-NLS-1$
                "DynamicModuleGroupAdapter.exception.noModuleAdapterFound", // $NON-NLS-1$
                module, DynamicModuleAdapter.class.getName()));
            }
            if (moduleAdapter.isSkipped()) {
                continue;
            }
            List<String> runtimeIds = moduleAdapter.getRuntimeIds();
            if (runtimeIds == null || runtimeIds.isEmpty()) {
                // means it is using existing modules of studio
                runtimeModulesSet.add(module);
            } else {
                runtimeModulesSet.addAll(runtimeIds);
            }
        }
        if (runtimeModulesSet != null) {
            for (String runtimeModule : runtimeModulesSet) {
                IDynamicConfiguration createDynamicLibrary = createDynamicLibrary(runtimeModule);
                dynamicModuleGroup.addChildConfiguration(createDynamicLibrary);
            }
        }
    }
    this.runtimeModules.addAll(runtimeModulesSet);
    return dynamicModuleGroup;
}
Also used : ESparkVersion(org.talend.hadoop.distribution.ESparkVersion) IDynamicConfiguration(org.talend.core.runtime.dynamic.IDynamicConfiguration) IDynamicConfiguration(org.talend.core.runtime.dynamic.IDynamicConfiguration) DynamicConfiguration(org.talend.hadoop.distribution.dynamic.DynamicConfiguration) HashSet(java.util.HashSet)

Example 17 with IDynamicConfiguration

use of org.talend.core.runtime.dynamic.IDynamicConfiguration in project tbd-studio-se by Talend.

the class DynamicClassloaderAdapter method adapt.

public IDynamicConfiguration adapt(IDynamicMonitor monitor) throws Exception {
    DynamicDistributionUtils.checkCancelOrNot(monitor);
    resolve();
    if (monitor != null) {
        monitor.setTaskName(// $NON-NLS-1$
        Messages.getString("DynamicClassloaderAdapter.monitor.buildClassLoader", classLoaderBean.getId()));
    }
    IDynamicConfiguration classLoader = DynamicFactory.getInstance().createDynamicConfiguration();
    classLoader.setConfigurationName(TAG_NAME);
    classLoader.setAttribute(ATTR_INDEX, classLoaderBean.getIndex());
    String moduleGroupId = classLoaderBean.getModuleGroup();
    DynamicModuleGroupAdapter dynamicModuleGroupAdapter = moduleGroupBeanAdapterMap.get(moduleGroupId);
    if (dynamicModuleGroupAdapter == null) {
        throw new Exception(// $NON-NLS-1$
        Messages.getString(// $NON-NLS-1$
        "DynamicClassloaderAdapter.exception.noModuleAdapterFound", // $NON-NLS-1$
        moduleGroupId, DynamicModuleGroupAdapter.class.getName()));
    }
    classLoader.setAttribute(ATTR_MODULE_GROUP_TEMPLATE_ID, moduleGroupId);
    List<String> runtimeModules = dynamicModuleGroupAdapter.getRuntimeModules();
    if (runtimeModules != null) {
        String libraries = buildLibrariesString(runtimeModules);
        classLoader.setAttribute(ATTR_LIBRARIES, libraries);
    }
    return classLoader;
}
Also used : IDynamicConfiguration(org.talend.core.runtime.dynamic.IDynamicConfiguration)

Example 18 with IDynamicConfiguration

use of org.talend.core.runtime.dynamic.IDynamicConfiguration in project tbd-studio-se by Talend.

the class ModuleGroupDetailsForm method initData.

protected void initData() {
    try {
        DynamicModuleGroupData moduleGroupData = getModuleGroupData();
        String groupTemplateId = moduleGroupData.getGroupTemplateId();
        groupTemplateIdLabel.setText(// $NON-NLS-1$
        Messages.getString("ModuleGroupDetailsForm.groupDetails.label.groupTemplateId", groupTemplateId));
        DynamicPluginAdapter pluginAdapter = moduleGroupData.getPluginAdapter();
        IDynamicConfiguration moduleGroup = pluginAdapter.getModuleGroupByTemplateId(groupTemplateId);
        List<IDynamicConfiguration> childConfigurations = moduleGroup.getChildConfigurations();
        if (childConfigurations != null) {
            Collections.sort(childConfigurations, new DynamicAttributeComparator());
        }
        groupDetailsViewer.setInput(childConfigurations);
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}
Also used : IDynamicConfiguration(org.talend.core.runtime.dynamic.IDynamicConfiguration) DynamicPluginAdapter(org.talend.hadoop.distribution.dynamic.adapter.DynamicPluginAdapter) DynamicModuleGroupData(org.talend.repository.hadoopcluster.ui.dynamic.DynamicModuleGroupData) DynamicAttributeComparator(org.talend.hadoop.distribution.dynamic.comparator.DynamicAttributeComparator)

Example 19 with IDynamicConfiguration

use of org.talend.core.runtime.dynamic.IDynamicConfiguration in project tbd-studio-se by Talend.

the class ModuleGroupDetailsForm method checkLibraries.

private boolean checkLibraries() {
    List<IDynamicConfiguration> childConfigurations = (List<IDynamicConfiguration>) groupDetailsViewer.getInput();
    List<String> errorLines = new ArrayList<>();
    for (int i = 0; i < childConfigurations.size(); ++i) {
        IDynamicConfiguration library = childConfigurations.get(i);
        if (checkLibrary(library) != null) {
            errorLines.add(String.valueOf(i + 1));
        }
    }
    if (errorLines.isEmpty()) {
        return true;
    } else {
        // $NON-NLS-1$
        String seperator = ", ";
        StringBuffer errorLinesBuf = new StringBuffer();
        for (String errorLine : errorLines) {
            if (0 < errorLinesBuf.length()) {
                errorLinesBuf.append(seperator);
            }
            groupDetailsViewer.refresh(childConfigurations.get(Integer.valueOf(errorLine) - 1));
            errorLinesBuf.append(errorLine);
        }
        String errorLinesStr = errorLinesBuf.toString();
        // $NON-NLS-1$
        String message = Messages.getString("ModuleGroupDetailsForm.groupDetails.check.errorLines", errorLinesStr);
        showMessage(message, WizardPage.ERROR);
        return false;
    }
}
Also used : IDynamicConfiguration(org.talend.core.runtime.dynamic.IDynamicConfiguration) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 20 with IDynamicConfiguration

use of org.talend.core.runtime.dynamic.IDynamicConfiguration in project tbd-studio-se by Talend.

the class ModuleGroupDetailsForm method onDeleteBtnSelected.

protected void onDeleteBtnSelected() {
    IStructuredSelection selection = (IStructuredSelection) groupDetailsViewer.getSelection();
    IDynamicConfiguration firstElement = (IDynamicConfiguration) selection.getFirstElement();
    DynamicModuleGroupData moduleGroupData = getModuleGroupData();
    String groupTemplateId = moduleGroupData.getGroupTemplateId();
    DynamicPluginAdapter pluginAdapter = moduleGroupData.getPluginAdapter();
    IDynamicConfiguration moduleGroup = pluginAdapter.getModuleGroupByTemplateId(groupTemplateId);
    List<IDynamicConfiguration> childConfigurations = moduleGroup.getChildConfigurations();
    childConfigurations.remove(firstElement);
    groupDetailsViewer.refresh();
}
Also used : IDynamicConfiguration(org.talend.core.runtime.dynamic.IDynamicConfiguration) DynamicPluginAdapter(org.talend.hadoop.distribution.dynamic.adapter.DynamicPluginAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DynamicModuleGroupData(org.talend.repository.hadoopcluster.ui.dynamic.DynamicModuleGroupData)

Aggregations

IDynamicConfiguration (org.talend.core.runtime.dynamic.IDynamicConfiguration)21 IDynamicExtension (org.talend.core.runtime.dynamic.IDynamicExtension)7 ArrayList (java.util.ArrayList)6 DynamicConfiguration (org.talend.hadoop.distribution.dynamic.DynamicConfiguration)5 HashSet (java.util.HashSet)4 MavenArtifact (org.talend.core.runtime.maven.MavenArtifact)4 DynamicPluginAdapter (org.talend.hadoop.distribution.dynamic.adapter.DynamicPluginAdapter)4 TemplateBean (org.talend.hadoop.distribution.dynamic.bean.TemplateBean)4 DynamicAttributeComparator (org.talend.hadoop.distribution.dynamic.comparator.DynamicAttributeComparator)4 DynamicModuleGroupData (org.talend.repository.hadoopcluster.ui.dynamic.DynamicModuleGroupData)4 List (java.util.List)3 ModuleNeeded (org.talend.core.model.general.ModuleNeeded)3 HashMap (java.util.HashMap)2 DependencyNode (org.talend.designer.maven.aether.node.DependencyNode)2 ESparkVersion (org.talend.hadoop.distribution.ESparkVersion)2 ModuleBean (org.talend.hadoop.distribution.dynamic.bean.ModuleBean)2 FileNotFoundException (java.io.FileNotFoundException)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 Test (org.junit.Test)1 ExclusionNode (org.talend.designer.maven.aether.node.ExclusionNode)1