/**
  * ADVANCED: Stop accepting announcements from other services becoming available. Note that this
  * does not remove the local service from the cluster.
  */
 public void stopDiscovery() {
   if (rcm.isCommandProcessorASession()) {
     this.rcm.getCommandProcessor().processCommand(new ProfileDiscoveryStoppedCommand());
   }
   stopListening();
   try {
     // Put in a sleep to give the listener thread a chance to stop
     Thread.sleep(500);
   } catch (InterruptedException exception) {
   }
   communicationSocket = null;
 }
  /**
   * INTERNAL: This is the main execution method of discovery. It will create a socket to listen on,
   * create a local connection for this service and announce that we are open for business.
   */
  public void run() {
    // Initialize the communication socket
    createCommunicationSocket();

    // Create the local connection from which we will receive commands
    rcm.getTransportManager().createLocalConnection();

    // Announce to all other discovery managers that this service is up. The
    // delay allows time for posting of connections to the name service
    try {
      Thread.sleep(announcementDelay);
    } catch (InterruptedException exception) {
    }
    announceSession();

    // Listen for other sessions that are joining
    startListening();
  }