Search in sources :

Example 1 with StartRuntimeProgress

use of org.talend.designer.esb.runcontainer.ui.progress.StartRuntimeProgress in project tesb-studio-se by Talend.

the class RunContainerProcessor method run.

@Override
public Process run(int statisticsPort, int tracePort, String watchParam, String log4jLevel, IProgressMonitor monitor, IProcessMessageManager processMessageManager) throws ProcessorException {
    if (!RuntimeServerController.getInstance().isRunning()) {
        try {
            new StartRuntimeProgress(true).run(monitor);
            new CheckingBundlesProgress().run(monitor);
        } catch (Exception e) {
            throw new ProcessorException(RunContainerMessages.getString("StartRuntimeAction.ErrorStart"), e);
        }
    }
    if (RuntimeServerController.getInstance().isRunning()) {
        RunESBRuntimeProcess esbRunContainerProcess = new RunESBRuntimeProcess(process, statisticsPort, tracePort, monitor);
        esbRunContainerProcess.setMessageManager(processMessageManager);
        try {
            esbRunContainerProcess.start();
        } catch (Exception e) {
            throw new ProcessorException(e);
        }
        return esbRunContainerProcess;
    } else {
        throw new ProcessorException(RunContainerMessages.getString("StartRuntimeAction.ErrorStart"));
    }
}
Also used : StartRuntimeProgress(org.talend.designer.esb.runcontainer.ui.progress.StartRuntimeProgress) ProcessorException(org.talend.designer.runprocess.ProcessorException) CheckingBundlesProgress(org.talend.designer.esb.runcontainer.ui.progress.CheckingBundlesProgress) ProcessorException(org.talend.designer.runprocess.ProcessorException)

Example 2 with StartRuntimeProgress

use of org.talend.designer.esb.runcontainer.ui.progress.StartRuntimeProgress in project tesb-studio-se by Talend.

the class RunContainerPreferencePage method initalizeRuntime.

private boolean initalizeRuntime(String location, String host) {
    boolean finished = true;
    performApply();
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
    try {
        dialog.run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                SubMonitor totalMonitor = SubMonitor.convert(monitor, 10);
                totalMonitor.beginTask("Initializing Runtime server", 10);
                // 1. try to stop first
                totalMonitor.setTaskName("Stoping Runtime server");
                new StopRuntimeProgress().run(totalMonitor);
                if (RuntimeServerController.getInstance().getRuntimeProcess() != null && RuntimeServerController.getInstance().getRuntimeProcess().isAlive()) {
                    RuntimeServerController.getInstance().getRuntimeProcess().waitFor(20, TimeUnit.SECONDS);
                }
                totalMonitor.worked(2);
                // 2. delete data(cannot use JMX to rebootCleanAll as a DLL delete failed)
                if (monitor.isCanceled()) {
                    throw new InterruptedException("Initalize is canceled by user");
                }
                totalMonitor.setTaskName("Deleting /data folder");
                try {
                    FileUtil.deleteFolder(location + "/data");
                } catch (IOException e) {
                    ExceptionHandler.process(e);
                    throw new InterruptedException(e.getMessage());
                }
                if (new File(location + "/data").exists()) {
                    throw new InterruptedException(RunContainerMessages.getString("RunContainerPreferencePage.InitailzeDialog7"));
                }
                totalMonitor.worked(1);
                // 3. start (again)
                if (monitor.isCanceled()) {
                    throw new InterruptedException("Initalize is canceled by user");
                }
                totalMonitor.setTaskName("Starting Runtime server");
                new StartRuntimeProgress(false).run(totalMonitor);
                totalMonitor.worked(2);
                // 4. command
                if (monitor.isCanceled()) {
                    throw new InterruptedException("Initalize is canceled by user");
                }
                File launcher;
                String os = System.getProperty("os.name");
                if (os != null && os.toLowerCase().contains("windows")) {
                    launcher = new File(location + "/bin/client.bat");
                } else {
                    launcher = new File(location + "/bin/client");
                }
                InputStream stream = RunContainerPreferencePage.class.getResourceAsStream("/resources/commands");
                File initFile = new File(location + "/scripts/initlocal.sh");
                if (!initFile.exists()) {
                    try {
                        Files.copy(stream, initFile.toPath());
                    } catch (IOException e) {
                        ExceptionHandler.process(e);
                        throw new InterruptedException(e.getMessage());
                    }
                }
                // without username and password is ok
                // fixed by KARAF-5019
                String command = launcher.getAbsolutePath() + " -h " + host + " -l 1 source file:scripts/initlocal.sh";
                RuntimeClientProgress clientProgress = new RuntimeClientProgress(command);
                clientProgress.run(totalMonitor);
                totalMonitor.done();
            }
        });
    } catch (Throwable e) {
        finished = false;
        ExceptionHandler.process(e);
        IStatus status = new Status(IStatus.ERROR, ESBRunContainerPlugin.PLUGIN_ID, e.getMessage(), e);
        if (e.getCause() != null) {
            status = new Status(IStatus.ERROR, ESBRunContainerPlugin.PLUGIN_ID, e.getCause().getMessage(), e.getCause());
        }
        RuntimeErrorDialog.openError(getShell(), RunContainerMessages.getString("RunContainerPreferencePage.InitailzeDialog2"), RunContainerMessages.getString("RunContainerPreferencePage.InitailzeDialog4"), status);
    }
    return finished;
}
Also used : StartRuntimeProgress(org.talend.designer.esb.runcontainer.ui.progress.StartRuntimeProgress) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) StopRuntimeProgress(org.talend.designer.esb.runcontainer.ui.progress.StopRuntimeProgress) IStatus(org.eclipse.core.runtime.IStatus) InputStream(java.io.InputStream) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) SubMonitor(org.eclipse.core.runtime.SubMonitor) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RuntimeClientProgress(org.talend.designer.esb.runcontainer.ui.progress.RuntimeClientProgress) File(java.io.File)

Aggregations

StartRuntimeProgress (org.talend.designer.esb.runcontainer.ui.progress.StartRuntimeProgress)2 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 CheckingBundlesProgress (org.talend.designer.esb.runcontainer.ui.progress.CheckingBundlesProgress)1 RuntimeClientProgress (org.talend.designer.esb.runcontainer.ui.progress.RuntimeClientProgress)1 StopRuntimeProgress (org.talend.designer.esb.runcontainer.ui.progress.StopRuntimeProgress)1 ProcessorException (org.talend.designer.runprocess.ProcessorException)1