com.sun.jini.fiddler
Class FiddlerImpl.RegistrationInfo

java.lang.Object
  extended by com.sun.jini.fiddler.FiddlerImpl.RegistrationInfo
All Implemented Interfaces:
Serializable, Comparable
Enclosing class:
FiddlerImpl

private static final class FiddlerImpl.RegistrationInfo
extends Object
implements Comparable, Serializable

This class acts as a record of one registration with the lookup discovery service; containing all of the information about that registration.


Field Summary
 boolean discardFlag
          When the lookup discovery service discards a registrar as a result of some internal condition (such as multicast announcements ceasing) and not as a result of a request from a registration, every registration configured for group discovery of that discarded registrar will be sent a remote discarded event.
 HashMap discoveredRegsMap
          Map from the set of instances of the ServiceRegistrar interface, to the set of marshalled instances of the ServiceRegistrar interface, where each key and each value (which is the marshalled form of its corresponding key) is a proxy to one of the lookup service(s) that have been discovered for the current registration.
 long eventID
          The identifier that maps the current registration to the remote event listener and the managed set of groups and locators.
 HashSet groups
          The managed set containing the names of the groups whose members are the lookup services the lookup discovery service should attempt to discover for the current registration.
 MarshalledObject handback
          The handback object returned with every remote discovery event sent to the current registration's listener.
 long leaseExpiration
          The absolute expiration time of the current lease.
 Uuid leaseID
          The ID of the lease placed on the current registration.
 RemoteEventListener listener
          The remote event listener registered by the client.
 HashSet locators
          The managed set containing the locators of the specific lookup services the lookup discovery service should attempt to discover for the current registration.
 Uuid registrationID
          The unique identifier assigned to the registration to which the data in the current implementation of this class corresponds.
 long seqNum
          The current sequence number of the set of remote discovery events sent to the current registration's listener.
private static long serialVersionUID
           
 
Constructor Summary
FiddlerImpl.RegistrationInfo(Uuid registrationID, String[] groups, LookupLocator[] locators, Uuid leaseID, long leaseExpiration, long eventID, MarshalledObject handback, RemoteEventListener listener)
          Constructs an instance of this class and stores the information related to the current registration: IDs, managed sets, lease information, and event registration information.
 
Method Summary
 HashMap addToDiscoveredRegs(HashMap regMapIn)
          Attempts to marshal each element of the input set of instances of the ServiceRegistrar interface and then map the registrar to its marshalled form, and store the mapping in this registration's discoveredRegsMap field.
 int compareTo(Object obj)
          Performs a primary sort by leaseExpiration, and a secondary sort by registrationID.
private  void readObject(ObjectInputStream stream)
          When this class is deserialized, this method is invoked.
private  void writeObject(ObjectOutputStream stream)
          When a registration is granted to a client, the client registers a remote listener with the lookup discovery service so that the lookup discovery service may send remote discovery events to the client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

registrationID

public final Uuid registrationID
The unique identifier assigned to the registration to which the data in the current implementation of this class corresponds. This identifier is unique across all other active registrations generated with the current instance of the lookup discovery service.


discoveredRegsMap

public HashMap discoveredRegsMap
Map from the set of instances of the ServiceRegistrar interface, to the set of marshalled instances of the ServiceRegistrar interface, where each key and each value (which is the marshalled form of its corresponding key) is a proxy to one of the lookup service(s) that have been discovered for the current registration. The contents of this set represents the 'remote state' of the registration's currently discovered lookup service(s).


groups

public HashSet groups
The managed set containing the names of the groups whose members are the lookup services the lookup discovery service should attempt to discover for the current registration. (HashSet is used to prevent duplicates.)


locators

public HashSet locators
The managed set containing the locators of the specific lookup services the lookup discovery service should attempt to discover for the current registration. (HashSet is used to prevent duplicates.)


leaseID

public final Uuid leaseID
The ID of the lease placed on the current registration.


leaseExpiration

public long leaseExpiration
The absolute expiration time of the current lease.


eventID

public long eventID
The identifier that maps the current registration to the remote event listener and the managed set of groups and locators.


seqNum

public long seqNum
The current sequence number of the set of remote discovery events sent to the current registration's listener. When a registration is granted, this class is instantiated to contain the information related to that particular registration. The event sequence number is initialized to 0 upon instantiation because the remote discovery events are sent to the listeners of each separate registration. Thus, each registration has its own sequence of events.


handback

public final MarshalledObject handback
The handback object returned with every remote discovery event sent to the current registration's listener.


discardFlag

public boolean discardFlag
When the lookup discovery service discards a registrar as a result of some internal condition (such as multicast announcements ceasing) and not as a result of a request from a registration, every registration configured for group discovery of that discarded registrar will be sent a remote discarded event. On the other hand, for the case where a registrar is discarded as a result of a request from a registration, only those registrations that actually request that the registrar be discarded will be sent a remote discarded event. This flag is used to determine whether to send a remote discarded event to one or multiple listeners.


listener

public transient RemoteEventListener listener
The remote event listener registered by the client. This field is transient because it is marshalled separately from the rest of this class when being serialized. (See the description for writeObject below.)

Constructor Detail

FiddlerImpl.RegistrationInfo

public FiddlerImpl.RegistrationInfo(Uuid registrationID,
                                    String[] groups,
                                    LookupLocator[] locators,
                                    Uuid leaseID,
                                    long leaseExpiration,
                                    long eventID,
                                    MarshalledObject handback,
                                    RemoteEventListener listener)
Constructs an instance of this class and stores the information related to the current registration: IDs, managed sets, lease information, and event registration information.

Method Detail

addToDiscoveredRegs

public HashMap addToDiscoveredRegs(HashMap regMapIn)
Attempts to marshal each element of the input set of instances of the ServiceRegistrar interface and then map the registrar to its marshalled form, and store the mapping in this registration's discoveredRegsMap field.

This method is typically invoked to handle discovered (as opposed to discarded) registrars. Note that if a particular registrar cannot be serialized (marshalled), it is not included in the mapping; nor is it included in the return set.

Parameters:
regMapIn - mapping in which the key values are the registrars to serialize and store, and the map values are data structures of type LocatorGroupsStruct that contain the locator and member groups of the corresponding registrar key
Returns:
a HashMap whose keys are the registrars whose marshalled form and un-marshalled form were inserted as key/value pairs into the discoveredRegsMap field of this regInfo; and whose values are the member groups of each corresponding registrar key.

compareTo

public int compareTo(Object obj)
Performs a primary sort by leaseExpiration, and a secondary sort by registrationID. The secondary sort is immaterial, except to ensure a total order (required by TreeMap).

Specified by:
compareTo in interface Comparable

writeObject

private void writeObject(ObjectOutputStream stream)
                  throws IOException
When a registration is granted to a client, the client registers a remote listener with the lookup discovery service so that the lookup discovery service may send remote discovery events to the client. The client typically annotates the listener with an RMI codebase from which the backend server can download the remote listener's proxy (stub). When the current registration is logged to persistent storage (for example, a snapshot is taken), the listener is written to the output snapshot or log file through an ObjectOutputStream which only serializes the listener; it does not marshal the listener. Thus, when the listener field of this class is logged, unless special action is taken, the codebase from which to retrieve the listener will not be included in the output. In order to include the codebase with the listener when saving state, the following custom writeObject method is provided which first serializes the current instance of this class (excluding the transient listener field), and then explicitly marshals the listener to preserve the codebase upon writing to the file. In this way, the listener -- along with its codebase -- is persisted through a mechanism that is separate from the normal mechanism applied to the remaining fields of this class.

Throws:
IOException

readObject

private void readObject(ObjectInputStream stream)
                 throws IOException,
                        ClassNotFoundException
When this class is deserialized, this method is invoked. This method first deserializes the non-transient elements of this class, and then unmarshals the remote event listener. (See the description for writeObject above.)

Throws:
IOException
ClassNotFoundException


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