private void updateProcessId() { try { // TODO: this is Sun JVM specific ... // String processName = (String) mbeanServer.get().getAttribute(new // ObjectName("java.lang:type=Runtime"), "Name"); String processName = ManagementFactory.getRuntimeMXBean().getName(); Long processId = Long.parseLong(processName.split("@")[0]); String runtimeIdentity = runtimeProperties.get().getRuntimeIdentity(); String path = ZkPath.CONTAINER_PROCESS_ID.getPath(runtimeIdentity); Stat stat = exists(curator.get(), path); if (stat != null) { if (stat.getEphemeralOwner() != curator.get().getZookeeperClient().getZooKeeper().getSessionId()) { delete(curator.get(), path); if (processId != null) { create(curator.get(), path, processId.toString(), CreateMode.EPHEMERAL); } } } else { if (processId != null) { create(curator.get(), path, processId.toString(), CreateMode.EPHEMERAL); } } } catch (Exception ex) { LOGGER.error("Error while updating the process id.", ex); } }