/** * Sends a leave message to the multicast group and leaves it. The <CODE>DiscoveryResponder</CODE> * leaves its multicast group. This method has no effect if the <CODE>DiscoveryResponder</CODE> is * <CODE>OFFLINE</CODE> or <CODE>STOPPING</CODE> or <CODE>STARTING</CODE>. */ public void stop() { if (state == ONLINE) { changeState(STOPPING); // ------------------------ // Stop corresponding thread // ------------------------ responder.stopRequested = true; synchronized (responder.interrupted) { if (!responder.interrupted.booleanValue()) { responderThread.interrupt(); } } // Fix for cases when the interrupt does not work (Windows NT) try { MulticastSocket ms = new MulticastSocket(multicastPort); // NPCTE fix for bugId 4499338, esc 0, 04 Sept 2001 if (usrInet != null) { ms.setInterface(usrInet); if (logger.finerOn()) { logger.finer("stop ", "use the interface " + usrInet); } } // end of NPCTE fix for bugId 4499338 InetAddress group = InetAddress.getByName(multicastGroup); ms.joinGroup(group); ms.send(new DatagramPacket(new byte[1], 1, group, multicastPort)); ms.leaveGroup(group); } catch (Exception e) { if (logger.finerOn()) { logger.finer( "stop ", "Unexpected exception occurred trying to send empty message " + e.getMessage()); } } // ------------------------ // free 'remained' allocated resource // ------------------------ responder = null; System.runFinalization(); // ---------------- // Update state // ---------------- // changeState(OFFLINE) ; } else { if (logger.finerOn()) { logger.finer("stop ", "Responder is not ONLINE"); } } }
// To be called exactly twice by the child process public static void rendezvousChild() { try { for (int i = 0; i < 100; i++) { System.gc(); System.runFinalization(); Thread.sleep(50); } System.out.write((byte) '\n'); System.out.flush(); System.in.read(); } catch (Throwable t) { throw new Error(t); } }
protected void runtest(String name) { // Try to ensure we start off with a reasonably clean slate. System.gc(); System.runFinalization(); checkPoint(null); Testlet t = null; try { Class k = Class.forName(name); Object o = k.newInstance(); if (!(o instanceof Testlet)) return; t = (Testlet) o; } catch (Throwable ex) { String d = "FAIL: uncaught exception loading " + name; if (verbose) d += ": " + ex.toString(); System.out.println(d); debug(ex); ++failures; ++total; } if (t != null) { description = name; try { t.test(this); } catch (Throwable ex) { String d = ("FAIL: " + description + ": uncaught exception at " + ((last_check == null) ? "" : ("\"" + last_check + "\"")) + " number " + (count + 1)); if (verbose) d += ": " + ex.toString(); System.out.println(d); debug(ex); ++failures; ++total; } } }