Search in sources :

Example 1 with IDynamicDistributionTemplate

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

the class AbstractDynamicDistribution method unregister.

@Override
public void unregister(IDynamicPlugin dynamicPlugin, IDynamicMonitor monitor, boolean reloadLibCache) throws Exception {
    IDynamicPluginConfiguration pluginConfiguration = dynamicPlugin.getPluginConfiguration();
    String id = pluginConfiguration.getId();
    IDynamicDistributionTemplate distribution = registedDistribution.remove(id);
    if (distribution != null) {
        unloadDistribution(distribution, reloadLibCache);
    }
}
Also used : IDynamicDistributionTemplate(org.talend.hadoop.distribution.dynamic.template.IDynamicDistributionTemplate) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)

Example 2 with IDynamicDistributionTemplate

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

the class DynamicHDPDistribution method initTemplate.

@Override
protected IDynamicDistributionTemplate initTemplate(DynamicPluginAdapter pluginAdapter, IDynamicMonitor monitor) throws Exception {
    IDynamicDistributionTemplate dynamicDistributionTemplate = null;
    IDynamicPluginConfiguration pluginConfiguration = pluginAdapter.getPluginConfiguration();
    String templateId = pluginConfiguration.getTemplateId();
    switch(templateId) {
        case HDP2xxDistributionTemplate.TEMPLATE_ID:
            dynamicDistributionTemplate = new HDP2xxDistributionTemplate(pluginAdapter);
            break;
        case HDP3xxDistributionTemplate.TEMPLATE_ID:
            dynamicDistributionTemplate = new HDP3xxDistributionTemplate(pluginAdapter);
            break;
        default:
            throw new Exception("Unknown templateId: " + templateId);
    }
    return dynamicDistributionTemplate;
}
Also used : IDynamicDistributionTemplate(org.talend.hadoop.distribution.dynamic.template.IDynamicDistributionTemplate) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)

Example 3 with IDynamicDistributionTemplate

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

the class AbstractDynamicDistribution method register.

@Override
public void register(IDynamicPlugin dynamicPlugin, IDynamicMonitor monitor) throws Exception {
    DynamicDistributionManager dynamicDistributionManager = DynamicDistributionManager.getInstance();
    IDynamicPlugin copiedDynamicPlugin = DynamicFactory.getInstance().createPluginFromJson(dynamicPlugin.toXmlJson().toString());
    Project project = ProjectManager.getInstance().getProjectFromProjectTechLabel((String) copiedDynamicPlugin.getPluginConfiguration().getAttribute(DynamicConstants.ATTR_PROJECT_TECHNICAL_NAME));
    IDynamicDistributionPreference dynamicDistributionPreference = dynamicDistributionManager.getDynamicDistributionGroup(getDistributionName()).getDynamicDistributionPreference(project);
    Bundle bundle = getBundle();
    DynamicPluginAdapter pluginAdapter = new DynamicPluginAdapter(copiedDynamicPlugin, dynamicDistributionPreference, bundle);
    pluginAdapter.adapt();
    IDynamicPluginConfiguration pluginConfiguration = pluginAdapter.getPluginConfiguration();
    String id = pluginConfiguration.getId();
    try {
        IDynamicDistributionTemplate existingTemplate = registedDistribution.get(id);
        if (existingTemplate != null) {
            unloadDistribution(existingTemplate, true);
            DynamicPluginAdapter existingPluginAdapter = existingTemplate.getPluginAdapter();
            IDynamicPluginConfiguration existingPluginConfig = existingPluginAdapter.getPluginConfiguration();
            String existingProjectName = (String) existingPluginConfig.getAttribute(DynamicConstants.ATTR_PROJECT_TECHNICAL_NAME);
            ExceptionHandler.log("Dynamic distribution: " + existingProjectName + "/" + id + " already exists, unloaded the old one and reload the new one");
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    boolean isBuiltin = Boolean.parseBoolean((String) pluginConfiguration.getAttribute(DynamicConstants.ATTR_IS_BUILTIN));
    if (isBuiltin) {
        // $NON-NLS-1$
        pluginConfiguration.setName(Messages.getString("DynamicDistribution.name.builtin", pluginConfiguration.getName()));
    } else {
        Project currentProject = ProjectManager.getInstance().getCurrentProject();
        String curProjLabel = currentProject.getTechnicalLabel();
        String projLabel = (String) pluginConfiguration.getAttribute(DynamicConstants.ATTR_PROJECT_TECHNICAL_NAME);
        if (StringUtils.equals(curProjLabel, projLabel)) {
            // $NON-NLS-1$
            projLabel = Messages.getString("DynamicDistribution.name.current");
        }
        pluginConfiguration.setName(// $NON-NLS-1$
        Messages.getString(// $NON-NLS-1$
        "DynamicDistribution.name.project", // $NON-NLS-1$
        pluginConfiguration.getName(), projLabel));
    }
    IDynamicDistributionTemplate distributionTemplate = initTemplate(pluginAdapter, monitor);
    registedDistribution.put(pluginConfiguration.getId(), distributionTemplate);
    distributionTemplate.registOsgiServices();
    if (Boolean.getBoolean(PROP_LOAD_DYNAMIC_DISTRIBUTION_MODULE)) {
        distributionTemplate.registPluginExtensions();
    }
}
Also used : Project(org.talend.core.model.general.Project) IDynamicDistributionPreference(org.talend.hadoop.distribution.dynamic.pref.IDynamicDistributionPreference) DynamicPluginAdapter(org.talend.hadoop.distribution.dynamic.adapter.DynamicPluginAdapter) IDynamicDistributionTemplate(org.talend.hadoop.distribution.dynamic.template.IDynamicDistributionTemplate) IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) Bundle(org.osgi.framework.Bundle) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)

Example 4 with IDynamicDistributionTemplate

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

the class DynamicCDH6xDistribution method initTemplate.

@Override
protected IDynamicDistributionTemplate initTemplate(DynamicPluginAdapter pluginAdapter, IDynamicMonitor monitor) throws Exception {
    IDynamicDistributionTemplate dynamicDistributionTemplate = null;
    IDynamicPluginConfiguration pluginConfiguration = pluginAdapter.getPluginConfiguration();
    String templateId = pluginConfiguration.getTemplateId();
    switch(templateId) {
        case CDH6xDistributionTemplate.TEMPLATE_ID:
            dynamicDistributionTemplate = new CDH6xDistributionTemplate(pluginAdapter);
            break;
        default:
            throw new Exception("Unknown templateId: " + templateId);
    }
    return dynamicDistributionTemplate;
}
Also used : CDH6xDistributionTemplate(org.talend.hadoop.distribution.cdh6x.CDH6xDistributionTemplate) IDynamicDistributionTemplate(org.talend.hadoop.distribution.dynamic.template.IDynamicDistributionTemplate) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)

Aggregations

IDynamicPluginConfiguration (org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)4 IDynamicDistributionTemplate (org.talend.hadoop.distribution.dynamic.template.IDynamicDistributionTemplate)4 Bundle (org.osgi.framework.Bundle)1 Project (org.talend.core.model.general.Project)1 IDynamicPlugin (org.talend.core.runtime.dynamic.IDynamicPlugin)1 CDH6xDistributionTemplate (org.talend.hadoop.distribution.cdh6x.CDH6xDistributionTemplate)1 DynamicPluginAdapter (org.talend.hadoop.distribution.dynamic.adapter.DynamicPluginAdapter)1 IDynamicDistributionPreference (org.talend.hadoop.distribution.dynamic.pref.IDynamicDistributionPreference)1