< prev index next >

application/tests/org.openjdk.jmc.rjmx.test/src/test/java/org/openjdk/jmc/rjmx/test/testutil/JVMKeepAlive.java

Print this page

        

*** 51,62 **** */ public class JVMKeepAlive { private static int m_aliveTime; private static long m_startTime = System.currentTimeMillis(); public static final int DEFAULT_KILL_PORT = 4713; ! public static final byte[] KILL_MESSAGE = "KILL".getBytes(); //$NON-NLS-1$ ! private static final String PROPERTY_KILL_PORT = "jmc.test.kill.port"; //$NON-NLS-1$ /** * Small server that listens for datagram packets on the specified port and kills the JVM when * anything is received. */ --- 51,62 ---- */ public class JVMKeepAlive { private static int m_aliveTime; private static long m_startTime = System.currentTimeMillis(); public static final int DEFAULT_KILL_PORT = 4713; ! public static final byte[] KILL_MESSAGE = "KILL".getBytes(); ! private static final String PROPERTY_KILL_PORT = "jmc.test.kill.port"; /** * Small server that listens for datagram packets on the specified port and kills the JVM when * anything is received. */
*** 74,85 **** try { port = Integer.parseInt(portStr); } catch (NumberFormatException nfe) { port = DEFAULT_KILL_PORT; } ! System.out.println(buildClassNamePrefix(JVMKeepAliveSlayer.class) + "Send kill command to port " + port //$NON-NLS-1$ ! + " to kill me."); //$NON-NLS-1$ try { try (DatagramSocket s = new DatagramSocket(port)) { DatagramPacket p = new DatagramPacket(new byte[25], 25); s.receive(p); --- 74,85 ---- try { port = Integer.parseInt(portStr); } catch (NumberFormatException nfe) { port = DEFAULT_KILL_PORT; } ! System.out.println(buildClassNamePrefix(JVMKeepAliveSlayer.class) + "Send kill command to port " + port ! + " to kill me."); try { try (DatagramSocket s = new DatagramSocket(port)) { DatagramPacket p = new DatagramPacket(new byte[25], 25); s.receive(p);
*** 87,105 **** } } catch (IOException e) { System.out.println(buildClassNamePrefix(JVMKeepAliveSlayer.class) + e.getMessage()); System.out.println(buildClassNamePrefix(JVMKeepAliveSlayer.class) ! + "Proceeding without JRockitKeepAliveSlayer..."); //$NON-NLS-1$ return; } } } private static String buildClassNamePrefix(Class<?> clazz) { ! return '[' + clazz.getName() + "] "; //$NON-NLS-1$ } /** * Loops for a preset time... * --- 87,105 ---- } } catch (IOException e) { System.out.println(buildClassNamePrefix(JVMKeepAliveSlayer.class) + e.getMessage()); System.out.println(buildClassNamePrefix(JVMKeepAliveSlayer.class) ! + "Proceeding without JRockitKeepAliveSlayer..."); return; } } } private static String buildClassNamePrefix(Class<?> clazz) { ! return '[' + clazz.getName() + "] "; } /** * Loops for a preset time... *
*** 113,123 **** // Start the JRockitKeepAliveSlayer that listens for kill commands Thread t = new Thread(new JVMKeepAliveSlayer(), buildClassNamePrefix(JVMKeepAliveSlayer.class)); t.start(); ! System.out.println(buildClassNamePrefix(JVMKeepAlive.class) + "Started..."); //$NON-NLS-1$ while (m_aliveTime == 0 || (System.currentTimeMillis() - m_startTime) / 1000 <= m_aliveTime) { try { Thread.sleep(2000); } catch (InterruptedException e) { --- 113,123 ---- // Start the JRockitKeepAliveSlayer that listens for kill commands Thread t = new Thread(new JVMKeepAliveSlayer(), buildClassNamePrefix(JVMKeepAliveSlayer.class)); t.start(); ! System.out.println(buildClassNamePrefix(JVMKeepAlive.class) + "Started..."); while (m_aliveTime == 0 || (System.currentTimeMillis() - m_startTime) / 1000 <= m_aliveTime) { try { Thread.sleep(2000); } catch (InterruptedException e) {
< prev index next >