* the announcement merits further processing, an appropriate object is
* added to the pendingDiscoveries set, and control is transferred to a
* UnicastDiscoveryTask.
*/
private void doRun() {
MulticastAnnouncement ann;
try {
ann = decodeMulticastAnnouncement(datagram);
} catch (Exception e) {
if (!(e instanceof InterruptedIOException)) {
logger.log(Levels.HANDLED,
"exception decoding multicast announcement", e);
}
return;
}
/* If the registrars map contains the service ID of the registrar
* that sent the current announcement then that registrar has
* already been discovered.
*
* Determine if the member groups of the already-discovered
* registrar have been replaced by a set containing none of the
* desired groups. If yes, then discard the registrar.
*
* If the registrar that sent the current announcement has not
* already been discovered, then check to see if any of the
* group(s) in which the registrar is a member are in the set of
* desired groups to discover. If yes, then queue the registrar for
* unicast discovery.
*/
Object pending = null;
ServiceID srvcID = ann.getServiceID();
synchronized (registrars) {
UnicastResponse resp =
(UnicastResponse) registrars.get(srvcID);
if (resp != null) {
// already in discovered set, timestamp announcement
AnnouncementInfo aInfo =
(AnnouncementInfo) regInfo.get(srvcID);
aInfo.tStamp = System.currentTimeMillis();
long currNum = ann.getSequenceNumber();
if ((newSeqNum(currNum, aInfo.seqNum)) &&
(!groupSetsEqual(resp.getGroups(), ann.getGroups()))) {
/* Check if the groups have changed. In the case of
* split announcement messages, eventually, group difference
* will be seen for the given sequence number. This
* check ignores other differences, such as port numbers,
* but for the purposes of LookupDiscovery, this is not
* important.
*/
pending = new CheckGroupsMarker(ann);
}
} else if (groupsOverlap(ann.getGroups())) {
// newly discovered
pending = new LookupLocator(ann.getHost(), ann.getPort());
}
}
if (pending != null) {
try {
checkAnnouncementConstraints(ann);
} catch (Exception e) {
if (!(e instanceof InterruptedIOException)) {
logger.log(Levels.HANDLED,
"exception decoding multicast announcement", e);
}
return;
}
if (pending instanceof CheckGroupsMarker) {
synchronized(registrars) {
// Since this is a valid announcement, update the
// sequence number.
AnnouncementInfo aInfo =
(AnnouncementInfo) regInfo.get(srvcID);
aInfo.seqNum = ann.getSequenceNumber();
}
}
boolean added;
// enqueue and handle pending action, if not already enqueued
synchronized (pendingDiscoveries) {