use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class Host method refreshSnapshots.
/**
* Refreshes the snapshots.
*/
private void refreshSnapshots() {
IPath hostDir;
try {
hostDir = getHostDir();
} catch (JvmCoreException e) {
// do nothing
return;
}
File[] files = hostDir.toFile().listFiles();
if (files == null) {
return;
}
for (File file : files) {
if (!file.isDirectory()) {
continue;
}
String jvmDir = file.getName();
if (!jvmDir.endsWith(IJvm.DIR_SUFFIX)) {
continue;
}
IPath filePath = hostDir.append(File.separator + jvmDir + File.separator + IJvm.PROPERTIES_FILE);
if (!filePath.toFile().exists() || file.list().length == 1) {
Util.deleteDir(file);
continue;
}
Properties props = Util.loadProperties(filePath);
if (props == null) {
Util.deleteDir(file);
continue;
}
String host = props.getProperty(IJvm.HOST_PROP_KEY);
if (!hostName.equals(host)) {
Util.deleteDir(file);
continue;
}
String pidString = props.getProperty(IJvm.PID_PROP_KEY);
int pid = (pidString == null) ? -1 : Integer.valueOf(pidString);
String portString = props.getProperty(IJvm.PORT_PROP_KEY);
int port = (portString == null) ? -1 : Integer.valueOf(portString);
String mainClass = props.getProperty(IJvm.MAIN_CLASS_PROP_KEY);
addTerminatedJvm(pid, port, mainClass);
}
}
use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class MBeanNotification method isSupported.
/*
* @see IMBeanNotification#isSupported(javax.management.ObjectName)
*/
@Override
public boolean isSupported(ObjectName objectName) {
MBeanInfo info = null;
try {
info = activeJvm.getMBeanServer().getMBeanInfo(objectName);
} catch (JvmCoreException e) {
return false;
}
if (info == null) {
return false;
}
MBeanNotificationInfo[] notificationInfoArray = info.getNotifications();
if (notificationInfoArray == null || notificationInfoArray.length == 0) {
return false;
}
return true;
}
use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class ActiveJvm method refreshHost.
/**
* Refreshes the host.
*
* @return True if JVM has been added to host
* @throws JvmCoreException
*/
private boolean refreshHost() throws JvmCoreException {
//$NON-NLS-1$
String[] elements = mBeanServer.getRuntimeName().split("@");
if (elements == null || elements.length != 2) {
throw new JvmCoreException(IStatus.ERROR, Messages.getHostNameFailedMsg, new Exception());
}
String hostName = elements[1];
Host host = (Host) JvmModel.getInstance().getHost(hostName);
if (host == null) {
host = new Host(hostName);
} else {
for (IJvm jvm : host.getActiveJvms()) {
if (jvm.getPid() == getPid()) {
return false;
}
}
}
host.addActiveJvm(this);
setHost(host);
return true;
}
use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class ActiveJvm method disconnect.
/*
* @see IActiveJvm#disconnect()
*/
@Override
public void disconnect() {
isConnected = false;
mBeanServer.dispose();
try {
if (swtResourceMonitor.isSupported()) {
swtResourceMonitor.setTracking(false);
}
} catch (JvmCoreException e) {
// do nothing
}
JvmModel.getInstance().fireJvmModelChangeEvent(new JvmModelEvent(State.JvmDisconnected, this));
}
use of org.talend.designer.runtime.visualization.JvmCoreException in project tdi-studio-se by Talend.
the class Host method removeJvm.
/*
* @see IHost#removeJvm(int)
*/
@Override
public void removeJvm(int pid) {
IPath hostDir = null;
try {
hostDir = getHostDir();
} catch (JvmCoreException e) {
Activator.log(IStatus.ERROR, NLS.bind(Messages.removeJvmFailedMsg, +pid), e);
return;
}
for (ITerminatedJvm jvm : terminatedJvms) {
if (jvm.getPid() == pid) {
terminatedJvms.remove(jvm);
int id = (jvm.getPid() != -1) ? jvm.getPid() : jvm.getPort();
IPath dirPath = hostDir.append(File.separator + id + IJvm.DIR_SUFFIX);
Util.deleteDir(dirPath.toFile());
JvmModel.getInstance().fireJvmModelChangeEvent(new JvmModelEvent(State.JvmRemoved, null));
break;
}
}
for (IActiveJvm jvm : activeJvms) {
if (jvm.getPid() == pid) {
if (jvm.isConnected()) {
jvm.disconnect();
}
if (jvm.getShapshots().size() > 0) {
addTerminatedJvm(jvm.getPid(), -1, jvm.getMainClass());
} else {
int id = (jvm.getPid() != -1) ? jvm.getPid() : jvm.getPort();
IPath dirPath = hostDir.append(File.separator + id + IJvm.DIR_SUFFIX);
Util.deleteDir(dirPath.toFile());
}
activeJvms.remove(jvm);
JvmModel.getInstance().fireJvmModelChangeEvent(new JvmModelEvent(State.JvmRemoved, null));
break;
}
}
}
Aggregations