Search in sources :

Example 1 with Host

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

the class CpuProfiler method dump.

/*
     * @see ICpuProfiler#dump()
     */
@Override
public IFileStore dump() throws JvmCoreException {
    String dump = cpuModel.getCpuDumpString(//$NON-NLS-1$
    jvm.getPid() + "@" + jvm.getHost().getName(), jvm.getMainClass(), jvm.getMBeanServer().getJvmArguments());
    StringBuffer fileName = new StringBuffer();
    fileName.append(new Date().getTime()).append('.').append(SnapshotType.Cpu.getExtension());
    IFileStore fileStore = Util.getFileStore(fileName.toString(), jvm.getBaseDirectory());
    // restore the terminated JVM if already removed
    AbstractJvm abstractJvm = jvm;
    if (!((Host) jvm.getHost()).getJvms().contains(jvm)) {
        jvm.saveJvmProperties();
        abstractJvm = (AbstractJvm) ((Host) jvm.getHost()).addTerminatedJvm(jvm.getPid(), jvm.getPort(), jvm.getMainClass());
    }
    OutputStream os = null;
    try {
        os = fileStore.openOutputStream(EFS.NONE, null);
        os.write(dump.getBytes());
        Snapshot snapshot = new Snapshot(fileStore, abstractJvm);
        abstractJvm.addSnapshot(snapshot);
        JvmModel.getInstance().fireJvmModelChangeEvent(new JvmModelEvent(State.ShapshotTaken, jvm, snapshot));
    } catch (CoreException e) {
        throw new JvmCoreException(IStatus.ERROR, NLS.bind(Messages.openOutputStreamFailedMsg, fileStore.toURI().getPath()), e);
    } catch (IOException e) {
        try {
            fileStore.delete(EFS.NONE, null);
        } catch (CoreException e1) {
        // do nothing
        }
        throw new JvmCoreException(IStatus.ERROR, NLS.bind(Messages.dumpCpuProfileDataFailedMsg, fileStore.toURI().getPath()), e);
    } finally {
        if (os != null) {
            try {
                os.close();
            } catch (IOException e) {
            // do nothing
            }
        }
    }
    return fileStore;
}
Also used : Snapshot(org.talend.designer.runtime.visualization.internal.core.Snapshot) CoreException(org.eclipse.core.runtime.CoreException) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException) AbstractJvm(org.talend.designer.runtime.visualization.internal.core.AbstractJvm) OutputStream(java.io.OutputStream) IFileStore(org.eclipse.core.filesystem.IFileStore) Host(org.talend.designer.runtime.visualization.internal.core.Host) IOException(java.io.IOException) JvmModelEvent(org.talend.designer.runtime.visualization.JvmModelEvent) Date(java.util.Date) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 2 with Host

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

the class JvmModel method removeHost.

/**
     * Removes the host.
     * 
     * @param host The host
     */
public void removeHost(IHost host) {
    hosts.remove(host);
    try {
        IPath hostDir = ((Host) host).getHostDir();
        Util.deleteDir(hostDir.toFile());
    } catch (JvmCoreException e) {
        Activator.log(IStatus.ERROR, NLS.bind(Messages.removeHostFailedMsg, host.getName()), e);
    }
    fireJvmModelChangeEvent(new JvmModelEvent(State.HostRemoved, null));
}
Also used : IPath(org.eclipse.core.runtime.IPath) Host(org.talend.designer.runtime.visualization.internal.core.Host)

Example 3 with Host

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

the class JvmModel method addHost.

/**
     * Adds the host.
     * 
     * @param hostname The host name
     * @return The host
     */
public IHost addHost(String hostname) {
    IHost host = getHost(hostname);
    if (host != null) {
        return host;
    }
    host = new Host(hostname);
    hosts.add(host);
    fireJvmModelChangeEvent(new JvmModelEvent(State.HostAdded, null));
    return host;
}
Also used : Host(org.talend.designer.runtime.visualization.internal.core.Host)

Aggregations

Host (org.talend.designer.runtime.visualization.internal.core.Host)3 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 Date (java.util.Date)1 IFileStore (org.eclipse.core.filesystem.IFileStore)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 JvmCoreException (org.talend.designer.runtime.visualization.JvmCoreException)1 JvmModelEvent (org.talend.designer.runtime.visualization.JvmModelEvent)1 AbstractJvm (org.talend.designer.runtime.visualization.internal.core.AbstractJvm)1 Snapshot (org.talend.designer.runtime.visualization.internal.core.Snapshot)1