com.sun.jini.fiddler
Class FiddlerImpl.ChangedEventTask

java.lang.Object
  extended by com.sun.jini.fiddler.FiddlerImpl.ChangedEventTask
All Implemented Interfaces:
TaskManager.Task, Runnable
Enclosing class:
FiddlerImpl

private final class FiddlerImpl.ChangedEventTask
extends Object
implements TaskManager.Task

This class represents a Task object that is placed in the TaskManager queue for processing in the thread pool. An instance of this class is placed on the task queue when a DiscoveryEvent instance indicating a changed event is received from the local discovery process.

The run method of this class will process event information resulting from a change in the state of the member groups of one or more lookup services (registrars). This task analyzes the group information in the event and, based on that information, determines which active registrations are no longer interested in the registrars referenced in the event. A RemoteDiscoveryEvent indicating a discarded event will be sent to each active registration that has lost interest in any of the registrars of the event.


Field Summary
 DiscoveryEvent event
          The local event sent by the discovery manager.
 
Constructor Summary
FiddlerImpl.ChangedEventTask(DiscoveryEvent event)
          Constructs an instance of this class and stores the event
 
Method Summary
private  HashSet maybeSendDiscardedEvent(FiddlerImpl.RegistrationInfo regInfo, Map groupsMap, Map locatorMap)
          This method determines, based on the current state of the regInfo parameter, whether or not to send a remote discarded event to the regInfo's listener, and then builds and sends the event if appropriate.
 void run()
          This method processes the local discovery event information and determines, based on the current state of each active registration, to which such registration the appropriate RemoteDiscoveryEvent should be sent.
 boolean runAfter(List tasks, int size)
          This method returns true if the current instance of this class must be run after at least one task in the input task list with an index less than the size parameter (size may be less than tasks.size()).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

event

public final DiscoveryEvent event
The local event sent by the discovery manager.

Constructor Detail

FiddlerImpl.ChangedEventTask

public FiddlerImpl.ChangedEventTask(DiscoveryEvent event)
Constructs an instance of this class and stores the event

Method Detail

run

public void run()
This method processes the local discovery event information and determines, based on the current state of each active registration, to which such registration the appropriate RemoteDiscoveryEvent should be sent. After making the determination, the remote event appropriate for each registration is constructed and sent.

Specified by:
run in interface Runnable

maybeSendDiscardedEvent

private HashSet maybeSendDiscardedEvent(FiddlerImpl.RegistrationInfo regInfo,
                                        Map groupsMap,
                                        Map locatorMap)
This method determines, based on the current state of the regInfo parameter, whether or not to send a remote discarded event to the regInfo's listener, and then builds and sends the event if appropriate. This method is called in response to the receipt of a changed event from the discovery manager.

Such an event may indicate what is referred to as a "passive, no interest" discard; passive because the event resulted from action taken by the discovery manager rather than the client, and no interest because the discovery manager sends such an event when it determines that one or more of the previously discovered registrars - although still reachable - have changed their member groups in such a way that they may now be of no interest to one or more of the client registrations.

Note that changed events can be sent for registrars having a locator and member groups that the current regInfo never asked to be discovered. This can happen because some other regInfo asked that the registrar's locator or groups be discovered.

If a particular registrar is contained in the discovered set of the given regInfo, then we know that that regInfo must have requested discovery of the registrar (through either locator or group discovery). If the registrar is not contained in that set, then there's no need to proceed with the processing of the registrar since we don't want to send a discarded event to a regInfo that was never interested in that registrar in the first place.

If the locator of the registrar is contained in the regInfo's set of locators to discover, then that regInfo is considered "still interested" in the registrar; and so no discarded event is sent to the regInfo.

Thus, a discarded event is sent to the given regInfo only if the regInfo is not interested in discovering the registrar through locator discovery, and the registrar's member groups have changed in such a way that it now belongs to groups that the regInfo is not interested in discovering and joining.

Parameters:
regInfo - the data structure record corresponding to the registration whose listener will receive the event
groupsMap - mapping from the registrars referenced in the just-received event to their corresponding set of member groups
locatorMap - mapping from the registrars referenced in the just-received event to their corresponding locator
Returns:
the registrars that were discarded for the given regInfo

runAfter

public boolean runAfter(List tasks,
                        int size)
This method returns true if the current instance of this class must be run after at least one task in the input task list with an index less than the size parameter (size may be less than tasks.size()).

Note that using List.get will be more efficient than List.iterator.

Specified by:
runAfter in interface TaskManager.Task
Parameters:
tasks - the tasks to consider. A read-only List, with all elements being an instanceof Task.
size - elements with index less than size should be considered


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