20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package sun.management.jdp; 26 27 import java.io.IOException; 28 import java.net.InetAddress; 29 import java.net.UnknownHostException; 30 import java.util.UUID; 31 32 import java.lang.management.ManagementFactory; 33 import java.lang.management.RuntimeMXBean; 34 import java.lang.reflect.Field; 35 import java.lang.reflect.Method; 36 import sun.management.VMManagement; 37 import sun.misc.ManagedLocalsThread; 38 39 /** 40 * JdpController is responsible to create and manage a broadcast loop 41 * 42 * <p> Other part of code has no access to broadcast loop and have to use 43 * provided static methods 44 * {@link #startDiscoveryService(InetAddress,int,String,String) startDiscoveryService} 45 * and {@link #stopDiscoveryService() stopDiscoveryService}</p> 46 * <p>{@link #startDiscoveryService(InetAddress,int,String,String) startDiscoveryService} could be called multiple 47 * times as it stops the running service if it is necessary. Call to {@link #stopDiscoveryService() stopDiscoveryService} 48 * ignored if service isn't run</p> 49 * 50 * 51 * </p> 52 * 53 * <p> System properties below could be used to control broadcast loop behavior. 54 * Property below have to be set explicitly in command line. It's not possible to 55 * set it in management.config file. Careless changes of these properties could 56 * lead to security or network issues. 57 * <ul> 58 * <li>com.sun.management.jdp.ttl - set ttl for broadcast packet</li> 59 * <li>com.sun.management.jdp.pause - set broadcast interval in seconds</li> 60 * <li>com.sun.management.jdp.source_addr - an address of interface to use for broadcast</li> 61 * </ul> 62 </p> 63 * <p>null parameters values are filtered out on {@link JdpPacketWriter} level and 64 * corresponding keys are not placed to packet.</p> 65 */ 66 public final class JdpController { 67 68 private static class JDPControllerRunner implements Runnable { 69 70 private final JdpJmxPacket packet; 71 private final JdpBroadcaster bcast; 72 private final int pause; 73 private volatile boolean shutdown = false; 74 75 private JDPControllerRunner(JdpBroadcaster bcast, JdpJmxPacket packet, int pause) { 76 this.bcast = bcast; 77 this.packet = packet; 78 this.pause = pause; 79 } 80 81 @Override 82 public void run() { 83 try { 84 while (!shutdown) { | 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package sun.management.jdp; 26 27 import java.io.IOException; 28 import java.net.InetAddress; 29 import java.net.UnknownHostException; 30 import java.util.UUID; 31 32 import java.lang.management.ManagementFactory; 33 import java.lang.management.RuntimeMXBean; 34 import java.lang.reflect.Field; 35 import java.lang.reflect.Method; 36 import sun.management.VMManagement; 37 import sun.misc.ManagedLocalsThread; 38 39 /** 40 * JdpController is responsible to create and manage a broadcast loop. 41 * 42 * <p> Other part of code has no access to broadcast loop and have to use 43 * provided static methods 44 * {@link #startDiscoveryService(InetAddress,int,String,String) startDiscoveryService} 45 * and {@link #stopDiscoveryService() stopDiscoveryService} 46 * <p>{@link #startDiscoveryService(InetAddress,int,String,String) startDiscoveryService} could be called multiple 47 * times as it stops the running service if it is necessary. 48 * Call to {@link #stopDiscoveryService() stopDiscoveryService} 49 * ignored if service isn't run. 50 * 51 * 52 * <p> System properties below could be used to control broadcast loop behavior. 53 * Property below have to be set explicitly in command line. It's not possible to 54 * set it in management.config file. Careless changes of these properties could 55 * lead to security or network issues. 56 * <ul> 57 * <li>com.sun.management.jdp.ttl - set ttl for broadcast packet</li> 58 * <li>com.sun.management.jdp.pause - set broadcast interval in seconds</li> 59 * <li>com.sun.management.jdp.source_addr - an address of interface to use for broadcast</li> 60 * </ul> 61 * 62 * <p>null parameters values are filtered out on {@link JdpPacketWriter} level and 63 * corresponding keys are not placed to packet. 64 */ 65 public final class JdpController { 66 67 private static class JDPControllerRunner implements Runnable { 68 69 private final JdpJmxPacket packet; 70 private final JdpBroadcaster bcast; 71 private final int pause; 72 private volatile boolean shutdown = false; 73 74 private JDPControllerRunner(JdpBroadcaster bcast, JdpJmxPacket packet, int pause) { 75 this.bcast = bcast; 76 this.packet = packet; 77 this.pause = pause; 78 } 79 80 @Override 81 public void run() { 82 try { 83 while (!shutdown) { |