Search in sources :

Example 1 with JvmModel

use of org.talend.designer.runtime.visualization.JvmModel in project tdi-studio-se by Talend.

the class MemoryRuntimeComposite method initCurrentActiveJobJvm.

private boolean initCurrentActiveJobJvm() {
    boolean isJvmFound = false;
    JvmModel jvmModel = JvmModel.getInstance();
    if (isRemoteRun) {
        if (isRemoteMonitoring && remotePort != -1) {
            try {
                if (currentJvm == null) {
                    currentJvm = jvmModel.addRemoteHostAndJvm(remoteHost, remotePort);
                    return true;
                }
                if (remotePort == currentJvm.getPort() && currentJvm.isConnected()) {
                    return true;
                }
                if (currentJvm.isConnected()) {
                    currentJvm.disconnect();
                }
                currentJvm = jvmModel.addRemoteHostAndJvm(remoteHost, remotePort);
                return true;
            } catch (JvmCoreException e) {
                ExceptionHandler.process(e);
                return false;
            }
        }
    } else {
        String jobClassName = JavaResourcesHelper.getJobClassName(processContext.getProcess());
        List<IActiveJvm> activateJvms = jvmModel.getHost(IHost.LOCALHOST).getActiveJvms();
        for (IActiveJvm jvm : activateJvms) {
            String activeJvmClassName = jvm.getMainClass();
            //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            System.out.println("target:[" + jobClassName + "],loop item[" + activeJvmClassName + "]");
            if (activeJvmClassName != null) {
                activeJvmClassName = activeJvmClassName.trim();
            }
            if (activeJvmClassName.equals(jobClassName)) {
                currentJvm = jvm;
                isJvmFound = true;
                break;
            }
        }
    }
    return isJvmFound;
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) JvmModel(org.talend.designer.runtime.visualization.JvmModel) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Aggregations

IActiveJvm (org.talend.designer.runtime.visualization.IActiveJvm)1 JvmCoreException (org.talend.designer.runtime.visualization.JvmCoreException)1 JvmModel (org.talend.designer.runtime.visualization.JvmModel)1