/** * ************************************************************************ Start Java Process * Class. instanciate the class implementing the interface ProcessCall. The class can be a * Server/Client class (when in Package org compiere.process or org.compiere.model) or a client * only class (e.g. in org.compiere.report) * * @return true if success */ private boolean startProcess() { log.fine(m_pi.toString()); boolean started = false; if (DB.isRemoteProcess()) { Server server = CConnection.get().getServer(); try { if (server != null) { // See ServerBean m_pi = server.process(m_wscctx, m_pi); log.finest("server => " + m_pi); started = true; } } catch (UndeclaredThrowableException ex) { Throwable cause = ex.getCause(); if (cause != null) { if (cause instanceof InvalidClassException) log.log( Level.SEVERE, "Version Server <> Client: " + cause.toString() + " - " + m_pi, ex); else log.log(Level.SEVERE, "AppsServer error(1b): " + cause.toString() + " - " + m_pi, ex); } else log.log(Level.SEVERE, " AppsServer error(1) - " + m_pi, ex); started = false; } catch (Exception ex) { Throwable cause = ex.getCause(); if (cause == null) cause = ex; log.log(Level.SEVERE, "AppsServer error - " + m_pi, cause); started = false; } } // Run locally if (!started && !m_IsServerProcess) { ProcessCall myObject = null; try { Class myClass = Class.forName(m_pi.getClassName()); myObject = (ProcessCall) myClass.newInstance(); if (myObject == null) m_pi.setSummary("No Instance for " + m_pi.getClassName(), true); else myObject.startProcess(m_wscctx, m_pi, m_trx); if (m_trx != null) { m_trx.commit(); m_trx.close(); } } catch (Exception e) { if (m_trx != null) { m_trx.rollback(); m_trx.close(); } m_pi.setSummary("Error starting Class " + m_pi.getClassName(), true); log.log(Level.SEVERE, m_pi.getClassName(), e); } } return !m_pi.isError(); } // startProcess
/** * Indicates a user request to answer an incoming call from this <tt>CallPeer</tt>. * * <p>Sends an OK response to <tt>callPeer</tt>. Make sure that the call peer contains an SDP * description when you call this method. * * @throws OperationFailedException if we fail to create or send the response. */ public synchronized void answer() throws OperationFailedException { RtpDescriptionPacketExtension answer = null; try { getMediaHandler().getTransportManager().wrapupConnectivityEstablishment(); answer = getMediaHandler().generateSessionAccept(true); } catch (IllegalArgumentException e) { sessAcceptedWithNoCands = new SessionIQ(); // HACK apparently FreeSwitch need to have accept before answer = getMediaHandler().generateSessionAccept(false); SessionIQ response = GTalkPacketFactory.createSessionAccept( sessionInitIQ.getTo(), sessionInitIQ.getFrom(), getSID(), answer); getProtocolProvider().getConnection().sendPacket(response); return; } catch (Exception exc) { logger.info("Failed to answer an incoming call", exc); // send an error response String reasonText = "Error: " + exc.getMessage(); SessionIQ errResp = GTalkPacketFactory.createSessionTerminate( sessionInitIQ.getTo(), sessionInitIQ.getFrom(), sessionInitIQ.getID(), Reason.FAILED_APPLICATION, reasonText); setState(CallPeerState.FAILED, reasonText); getProtocolProvider().getConnection().sendPacket(errResp); return; } SessionIQ response = GTalkPacketFactory.createSessionAccept( sessionInitIQ.getTo(), sessionInitIQ.getFrom(), getSID(), answer); // send the packet first and start the stream later in case the media // relay needs to see it before letting hole punching techniques through. if (sessAcceptedWithNoCands == null) getProtocolProvider().getConnection().sendPacket(response); try { getMediaHandler().start(); } catch (UndeclaredThrowableException e) { Throwable exc = e.getUndeclaredThrowable(); logger.info("Failed to establish a connection", exc); // send an error response String reasonText = "Error: " + exc.getMessage(); SessionIQ errResp = GTalkPacketFactory.createSessionTerminate( sessionInitIQ.getTo(), sessionInitIQ.getFrom(), sessionInitIQ.getID(), Reason.GENERAL_ERROR, reasonText); getMediaHandler().getTransportManager().close(); setState(CallPeerState.FAILED, reasonText); getProtocolProvider().getConnection().sendPacket(errResp); return; } // tell everyone we are connecting so that the audio notifications would // stop setState(CallPeerState.CONNECTED); }
synchronized Result formatSummary() { Result result = new Result(); ProxyClient proxyClient = vmPanel.getProxyClient(); if (proxyClient.isDead()) { return null; } buf = new StringBuilder(); append("<table cellpadding=1>"); try { RuntimeMXBean rmBean = proxyClient.getRuntimeMXBean(); CompilationMXBean cmpMBean = proxyClient.getCompilationMXBean(); ThreadMXBean tmBean = proxyClient.getThreadMXBean(); MemoryMXBean memoryBean = proxyClient.getMemoryMXBean(); ClassLoadingMXBean clMBean = proxyClient.getClassLoadingMXBean(); OperatingSystemMXBean osMBean = proxyClient.getOperatingSystemMXBean(); com.sun.management.OperatingSystemMXBean sunOSMBean = proxyClient.getSunOperatingSystemMXBean(); append("<tr><td colspan=4>"); append("<center><b>" + Messages.SUMMARY_TAB_TAB_NAME + "</b></center>"); String dateTime = headerDateTimeFormat.format(System.currentTimeMillis()); append("<center>" + dateTime + "</center>"); append(newDivider); { // VM info append(newLeftTable); append(Messages.CONNECTION_NAME, vmPanel.getDisplayName()); append( Messages.VIRTUAL_MACHINE, Resources.format( Messages.SUMMARY_TAB_VM_VERSION, rmBean.getVmName(), rmBean.getVmVersion())); append(Messages.VENDOR, rmBean.getVmVendor()); append(Messages.NAME, rmBean.getName()); append(endTable); append(newRightTable); result.upTime = rmBean.getUptime(); append(Messages.UPTIME, formatTime(result.upTime)); if (sunOSMBean != null) { result.processCpuTime = sunOSMBean.getProcessCpuTime(); append(Messages.PROCESS_CPU_TIME, formatNanoTime(result.processCpuTime)); } if (cmpMBean != null) { append(Messages.JIT_COMPILER, cmpMBean.getName()); append( Messages.TOTAL_COMPILE_TIME, cmpMBean.isCompilationTimeMonitoringSupported() ? formatTime(cmpMBean.getTotalCompilationTime()) : Messages.UNAVAILABLE); } else { append(Messages.JIT_COMPILER, Messages.UNAVAILABLE); } append(endTable); } append(newDivider); { // Threads and Classes append(newLeftTable); int tlCount = tmBean.getThreadCount(); int tdCount = tmBean.getDaemonThreadCount(); int tpCount = tmBean.getPeakThreadCount(); long ttCount = tmBean.getTotalStartedThreadCount(); String[] strings1 = formatLongs( tlCount, tpCount, tdCount, ttCount); append(Messages.LIVE_THREADS, strings1[0]); append(Messages.PEAK, strings1[1]); append(Messages.DAEMON_THREADS, strings1[2]); append(Messages.TOTAL_THREADS_STARTED, strings1[3]); append(endTable); append(newRightTable); long clCount = clMBean.getLoadedClassCount(); long cuCount = clMBean.getUnloadedClassCount(); long ctCount = clMBean.getTotalLoadedClassCount(); String[] strings2 = formatLongs(clCount, cuCount, ctCount); append(Messages.CURRENT_CLASSES_LOADED, strings2[0]); append(Messages.TOTAL_CLASSES_LOADED, strings2[2]); append(Messages.TOTAL_CLASSES_UNLOADED, strings2[1]); append(null, ""); append(endTable); } append(newDivider); { // Memory MemoryUsage u = memoryBean.getHeapMemoryUsage(); append(newLeftTable); String[] strings1 = formatKByteStrings(u.getUsed(), u.getMax()); append(Messages.CURRENT_HEAP_SIZE, strings1[0]); append(Messages.MAXIMUM_HEAP_SIZE, strings1[1]); append(endTable); append(newRightTable); String[] strings2 = formatKByteStrings(u.getCommitted()); append(Messages.COMMITTED_MEMORY, strings2[0]); append( Messages.SUMMARY_TAB_PENDING_FINALIZATION_LABEL, Messages.SUMMARY_TAB_PENDING_FINALIZATION_VALUE, memoryBean.getObjectPendingFinalizationCount()); append(endTable); append(newTable); Collection<GarbageCollectorMXBean> garbageCollectors = proxyClient.getGarbageCollectorMXBeans(); for (GarbageCollectorMXBean garbageCollectorMBean : garbageCollectors) { String gcName = garbageCollectorMBean.getName(); long gcCount = garbageCollectorMBean.getCollectionCount(); long gcTime = garbageCollectorMBean.getCollectionTime(); append( Messages.GARBAGE_COLLECTOR, Resources.format( Messages.GC_INFO, gcName, gcCount, (gcTime >= 0) ? formatTime(gcTime) : Messages.UNAVAILABLE), 4); } append(endTable); } append(newDivider); { // Operating System info append(newLeftTable); String osName = osMBean.getName(); String osVersion = osMBean.getVersion(); String osArch = osMBean.getArch(); result.nCPUs = osMBean.getAvailableProcessors(); append(Messages.OPERATING_SYSTEM, osName + " " + osVersion); append(Messages.ARCHITECTURE, osArch); append(Messages.NUMBER_OF_PROCESSORS, result.nCPUs + ""); if (pathSeparator == null) { // Must use separator of remote OS, not File.pathSeparator // from this local VM. In the future, consider using // RuntimeMXBean to get the remote system property. pathSeparator = osName.startsWith("Windows ") ? ";" : ":"; } if (sunOSMBean != null) { String[] kbStrings1 = formatKByteStrings(sunOSMBean.getCommittedVirtualMemorySize()); String[] kbStrings2 = formatKByteStrings( sunOSMBean.getTotalPhysicalMemorySize(), sunOSMBean.getFreePhysicalMemorySize(), sunOSMBean.getTotalSwapSpaceSize(), sunOSMBean.getFreeSwapSpaceSize()); append(Messages.COMMITTED_VIRTUAL_MEMORY, kbStrings1[0]); append(endTable); append(newRightTable); append(Messages.TOTAL_PHYSICAL_MEMORY, kbStrings2[0]); append(Messages.FREE_PHYSICAL_MEMORY, kbStrings2[1]); append(Messages.TOTAL_SWAP_SPACE, kbStrings2[2]); append(Messages.FREE_SWAP_SPACE, kbStrings2[3]); } append(endTable); } append(newDivider); { // VM arguments and paths append(newTable); String args = ""; java.util.List<String> inputArguments = rmBean.getInputArguments(); for (String arg : inputArguments) { args += arg + " "; } append(Messages.VM_ARGUMENTS, args, 4); append(Messages.CLASS_PATH, rmBean.getClassPath(), 4); append(Messages.LIBRARY_PATH, rmBean.getLibraryPath(), 4); append( Messages.BOOT_CLASS_PATH, rmBean.isBootClassPathSupported() ? rmBean.getBootClassPath() : Messages.UNAVAILABLE, 4); append(endTable); } } catch (IOException e) { if (JConsole.isDebug()) { e.printStackTrace(); } proxyClient.markAsDead(); return null; } catch (UndeclaredThrowableException e) { if (JConsole.isDebug()) { e.printStackTrace(); } proxyClient.markAsDead(); return null; } append("</table>"); result.timeStamp = System.currentTimeMillis(); result.summary = buf.toString(); return result; }