Search in sources :

Example 1 with HadoopClusterConnectionImpl

use of org.talend.repository.model.hadoopcluster.impl.HadoopClusterConnectionImpl in project tbd-studio-se by Talend.

the class HadoopImportConfsWizard method performFinish.

@Override
public boolean performFinish() {
    IImportConfsWizardPage currentPage = getCurrentConfPage();
    if (currentPage != null) {
        final IRetrieveConfsService confsService = currentPage.getConfsService();
        final boolean isCreateConnectionFromConfs = currentPage.isSupportCreateServiceConnection();
        try {
            if (confsService != null) {
                currentPage.applyFilter();
                List<String> selectedServices = currentPage.getSelectedServices();
                final String confsDir = confsService.exportConfs(selectedServices);
                if (confsDir != null) {
                    this.getContainer().run(true, true, new IRunnableWithProgress() {

                        @Override
                        public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                            // $NON-NLS-1$
                            monitor.beginTask(// $NON-NLS-1$
                            Messages.getString("HadoopImportConfsWizard.doingImport"), IProgressMonitor.UNKNOWN);
                            try {
                                if (contextGroup == null) {
                                    confJarName = HadoopConfsUtils.getConfsJarDefaultName(connectionItem, false);
                                } else {
                                    confJarName = HadoopConfsUtils.getConfsJarDefaultName(connectionItem, false, contextGroup);
                                }
                                HadoopConfsUtils.buildAndDeployConfsJar(connectionItem, contextGroup, confsDir, confJarName);
                            } catch (Exception e) {
                                confJarName = null;
                                throw new InvocationTargetException(e);
                            } finally {
                                monitor.done();
                            }
                        }
                    });
                }
                HadoopConfsManager confsManager = HadoopConfsManager.getInstance();
                confsManager.setHadoopClusterId(connectionItem.getProperty().getId());
                confsManager.setConfsMap(getSelectedConfsMap(selectedServices, confsService.getConfsMap()));
                confsManager.setCreateConnectionFromConfs(isCreateConnectionFromConfs);
            }
            if (creation) {
                HadoopConfsUtils.setConnectionParameters(connectionItem, optionPage.getDistribution(), optionPage.getVersion(), confsService);
                if ("SPARK".equals(((HadoopClusterConnectionImpl) this.connectionItem.getConnection()).getDistribution()) && confJarName != null) {
                    MavenArtifact artifact = new MavenArtifact();
                    artifact.setGroupId("org.talend.libraries");
                    artifact.setArtifactId(confJarName.split(".jar")[0]);
                    artifact.setVersion("6.0.0-SNAPSHOT");
                    artifact.setType(MavenConstants.TYPE_JAR);
                    HadoopClusterConnection connection = (HadoopClusterConnection) connectionItem.getConnection();
                    connection.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CONF_SPECIFIC_JAR, PomUtil.getArtifactFullPath(artifact));
                }
                if (parentForm != null) {
                    parentForm.reload();
                }
            }
        } catch (Exception e) {
            ExceptionHandler.process(e);
        }
    }
    return true;
}
Also used : HadoopConfsManager(org.talend.repository.hadoopcluster.conf.HadoopConfsManager) HadoopClusterConnectionImpl(org.talend.repository.model.hadoopcluster.impl.HadoopClusterConnectionImpl) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IRetrieveConfsService(org.talend.repository.hadoopcluster.service.IRetrieveConfsService) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) MavenArtifact(org.talend.core.runtime.maven.MavenArtifact)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 MavenArtifact (org.talend.core.runtime.maven.MavenArtifact)1 HadoopConfsManager (org.talend.repository.hadoopcluster.conf.HadoopConfsManager)1 IRetrieveConfsService (org.talend.repository.hadoopcluster.service.IRetrieveConfsService)1 HadoopClusterConnection (org.talend.repository.model.hadoopcluster.HadoopClusterConnection)1 HadoopClusterConnectionImpl (org.talend.repository.model.hadoopcluster.impl.HadoopClusterConnectionImpl)1