net.jini.discovery
Class LookupDiscovery.Requestor

java.lang.Object
  extended by java.lang.Thread
      extended by net.jini.discovery.LookupDiscovery.Requestor
All Implemented Interfaces:
Runnable
Enclosing class:
LookupDiscovery

private class LookupDiscovery.Requestor
extends Thread

Thread that periodically sends out multicast requests for a limited period of time, and then exits.

An instance of this thread is run at startup, and each time the set of groups to discover is changed.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
private  boolean delayFlag
           
private  String[] groups
          Groups to request
private  int responsePort
          Unicast response port
private  MulticastSocket sock
          Multicast socket for sending packets
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
LookupDiscovery.Requestor(String[] groups, int port, boolean delayFlag)
          Create a daemon thread
 
Method Summary
 void run()
          This method sends out N (for small N) multicast requests.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sock

private MulticastSocket sock
Multicast socket for sending packets


responsePort

private int responsePort
Unicast response port


groups

private String[] groups
Groups to request


delayFlag

private boolean delayFlag
Constructor Detail

LookupDiscovery.Requestor

public LookupDiscovery.Requestor(String[] groups,
                                 int port,
                                 boolean delayFlag)
                          throws IOException
Create a daemon thread

Throws:
IOException
Method Detail

run

public void run()
This method sends out N (for small N) multicast requests. Until the last request is sent out, this method sleeps for 5 seconds after each request is sent. After the last request is sent, this method sleeps for 2 minutes to allow the ResponseListener time to receive and process any multicast responses sent in reply to the multicast requests. Before sending a request, a new multicast request is constructed so that updates can be made to the set of service IDs of the lookup services discovered due to previous requests.

After all requests have been sent, and the ResponseListener has been given the appropriate time to receive and process any multicast responses, if there are no more active instances of this thread, this method terminates (interrupts) the ResponseListener. Note that although it is more desirable to have the ResponseListener set a timeout on the server socket (using setSoTimeout) and then simply exit after a period of time in which both the ResponseListener has been idle, and there have been no active Requestor threads, using setSoTimeout in this way can cause random hangs on the Solaris(TM) operating system.

Specified by:
run in interface Runnable
Overrides:
run in class Thread


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.