com.sun.jini.reggie
Class RegistrarImpl

java.lang.Object
  extended by com.sun.jini.reggie.RegistrarImpl
All Implemented Interfaces:
DestroyAdmin, Registrar, ServiceProxyAccessor, Remote, Administrable, JoinAdmin, ProxyAccessor, DiscoveryAdmin, ServerProxyTrust
Direct Known Subclasses:
PersistentRegistrarImpl, TransientRegistrarImpl

 class RegistrarImpl
extends Object
implements Registrar, ProxyAccessor, ServerProxyTrust

Base server-side implementation of a lookup service, subclassed by TransientRegistrarImpl and PersistentRegistrarImpl. Multiple client-side proxy classes are used, for the ServiceRegistrar interface as well as for leases and administration; their methods transform the parameters and then make corresponding calls on the Registrar interface implemented on the server side.

Author:
Sun Microsystems, Inc.

Nested Class Summary
private  class RegistrarImpl.AddressTask
          Address for unicast discovery response.
private  class RegistrarImpl.AllItemIter
          Iterate over all Items.
private  class RegistrarImpl.AnnounceThread
          Multicast discovery announcement thread code.
private  class RegistrarImpl.AttrItemIter
          Iterate over all matching Items by attribute value.
private static class RegistrarImpl.AttrsAddedLogObj
          LogObj class whose instances are recorded to the log file whenever new attributes are added to an existing service in the Registrar.
private static class RegistrarImpl.AttrsModifiedLogObj
          LogObj class whose instances are recorded to the log file whenever existing attributes of an existing service in the Registrar are modified.
private static class RegistrarImpl.AttrsSetLogObj
          LogObj class whose instances are recorded to the log file whenever new attributes are set on an existing service in the Registrar.
private  class RegistrarImpl.ClassItemIter
          Iterate over all matching Items by entry class, dups possible.
private  class RegistrarImpl.DecodeRequestTask
          Task for decoding multicast request packets.
private  class RegistrarImpl.DestroyThread
          Termination thread code.
private  class RegistrarImpl.EmptyAttrItemIter
          Iterate over all matching Items by no-fields entry class.
private  class RegistrarImpl.EventExpireThread
          Event lease expiration thread code
private static class RegistrarImpl.EventLeaseCancelledLogObj
          LogObj class whose instances are recorded to the log file whenever a lease on a registered event is cancelled.
private static class RegistrarImpl.EventLeaseRenewedLogObj
          LogObj class whose instances are recorded to the log file whenever a lease on a registered event is renewed.
private static class RegistrarImpl.EventReg
          An event registration record.
private static class RegistrarImpl.EventRegisteredLogObj
          LogObj class whose instances are recorded to the log file whenever a new event is registered.
private  class RegistrarImpl.EventTask
          An event to be sent, and the listener to send it to.
private  class RegistrarImpl.IDItemIter
          Iterate over a singleton matching Item by serviceID.
private  class RegistrarImpl.ItemIter
          Base class for iterating over all Items that match a Template.
private static class RegistrarImpl.LeasesCancelledLogObj
          LogObj class whose instances are recorded to the log file whenever lease are cancelled via a LeaseMap.
private static class RegistrarImpl.LeasesRenewedLogObj
          LogObj class whose instances are recorded to the log file whenever a leases in the Registrar is renewed via a LeaseMap.
private  class RegistrarImpl.LocalLogHandler
          Handler class for the persistent storage facility.
private static interface RegistrarImpl.LogRecord
          Interface defining the method(s) that must be implemented by each of the concrete LogObj classes.
private static class RegistrarImpl.LookupAttributesChangedLogObj
          LogObj class whose instances are recorded to the log file whenever the attributes for the lookup service are changed.
private static class RegistrarImpl.LookupGroupsChangedLogObj
          LogObj class whose instances are recorded to the log file whenever the set of groups to join is changed.
private static class RegistrarImpl.LookupLocatorsChangedLogObj
          LogObj class whose instances are recorded to the log file whenever the set of locators of lookup services to join is changed.
private static class RegistrarImpl.MemberGroupsChangedLogObj
          LogObj class whose instances are recorded to the log file whenever the memberGroups array is set to reference a new array of strings.
private  class RegistrarImpl.MulticastThread
          Multicast discovery request thread code.
private  class RegistrarImpl.ServiceExpireThread
          Service lease expiration thread code
private static class RegistrarImpl.ServiceLeaseCancelledLogObj
          LogObj class whose instances are recorded to the log file whenever a lease on an existing service in the Registrar is cancelled.
private static class RegistrarImpl.ServiceLeaseRenewedLogObj
          LogObj class whose instances are recorded to the log file whenever a lease on an existing service in the Registrar is renewed.
private  class RegistrarImpl.SnapshotThread
          Snapshot-taking thread.
private  class RegistrarImpl.SocketTask
          Socket for unicast discovery response.
private  class RegistrarImpl.SvcIterator
          Iterates over all services that match template's service types
private static class RegistrarImpl.SvcReg
          A service item registration record.
private static class RegistrarImpl.SvcRegisteredLogObj
          LogObj class whose instances are recorded to the log file whenever a new service is registered.
private static class RegistrarImpl.UnicastPortSetLogObj
          LogObj class whose instances are recorded to the log file whenever the Unicast Port Number is set to a new value.
private  class RegistrarImpl.UnicastThread
          Unicast discovery request thread code.
 
Field Summary
private  ActivationID activationID
          Our activation id, or null if not activatable
private  ActivationSystem activationSystem
          Associated activation system, or null if not activatable
private  long announcementSeqNo
          Multicast announcement sequence number
private  Thread announcer
          Multicast discovery announcement sending thread
private static Entry[] baseAttrs
          Base set of initial attributes for self
private static String COMPONENT
          Logger and configuration component name
private  ReadersWriter concurrentObj
          Concurrent object to control read and write access
private static int DEFAULT_MAX_PACKET_SIZE
          Default maximum size of multicast packets to send and receive
private static int DEFAULT_MULTICAST_TTL
          Default time to live value to use for sending multicast packets
private static int DEFAULT_SOCKET_TIMEOUT
          Default timeout to set on sockets used for unicast discovery
private  DiscoveryManagement discoer
          Manager for discovering other lookup services
private static EntryRep[] emptyAttrs
          Empty attribute set
private  ArrayList entryClasses
          All EntryClasses with non-zero numInstances
private  HashMap eventByID
          Map from Long(eventID) to EventReg.
private  TreeMap eventByTime
          Identity map from EventReg to EventReg, ordered by lease expiration.
private  Thread eventExpirer
          Event lease expiration thread
private  long eventID
          Event ID
private  Object eventNotifier
          Object for synchronizing with the event expire thread
private  boolean inRecovery
          Flag indicating whether system is in a state of recovery
private  JoinManager joiner
          Manager for joining other lookup services
private  LifeCycle lifeCycle
          Shutdown callback object, or null if no callback needed
private  ProxyPreparer listenerPreparer
          Preparer for received remote event listeners
private  ProxyPreparer locatorPreparer
          Preparer for received lookup locators
private  ReliableLog log
          Log for recovering/storing state, or null if running as transient
private static int LOG_VERSION
          Log format version
private  int logFileSize
          Current number of records in the Log File since the last snapshot
private static Logger logger
          Logger used by this service
private  LoginContext loginContext
          Our login context, for logging out
private  Entry[] lookupAttrs
          The attributes to use when joining (including with myself)
private  String[] lookupGroups
          The groups we should join
private  LookupLocator[] lookupLocators
          The locators of other lookups we should join
private static long MAX_LEASE
          Maximum minMax lease duration for both services and events
private static long MAX_RENEW
          Maximum minimum renewal interval
private  long maxEventLease
          Current maximum event lease duration granted, in milliseconds.
private  long maxServiceLease
          Current maximum service lease duration granted, in milliseconds.
private  String[] memberGroups
          The groups we are a member of
private  long minEventExpiration
          Earliest expiration time of an EventReg
private  long minMaxEventLease
          Minimum value for maxEventLease.
private  long minMaxServiceLease
          Minimum value for maxServiceLease.
private  long minRenewalInterval
          Minimum average time between lease renewals, in milliseconds.
private  long minSvcExpiration
          Earliest expiration time of a SvcReg
private  DiscoveryConstraints multicastAnnouncementConstraints
          Constraints specified for outgoing multicast announcements
private  long multicastAnnouncementInterval
          Interval to wait in between sending multicast announcements
private  Thread multicaster
          Multicast discovery request packet receiving thread
private  int multicastInterfaceRetryInterval
          Interval to wait in between retrying failed interfaces
private  NetworkInterface[] multicastInterfaces
          Network interfaces to use for multicast discovery
private  boolean multicastInterfacesSpecified
          Flag indicating whether network interfaces were explicitly specified
private  DiscoveryConstraints multicastRequestConstraints
          Constraints specified for incoming multicast requests
private  ClientSubjectChecker multicastRequestSubjectChecker
          Client subject checker to apply to incoming multicast requests
private static Uuid myLeaseID
          Lease ID always assigned to self
private  LookupLocator myLocator
          Our LookupLocator
private  Registrar myRef
          Remote reference for myself
private  ServiceID myServiceID
          Our service ID
private  ArrayList newNotifies
          ArrayList of pending EventTasks
private  ServiceType objectServiceType
          Canonical ServiceType for java.lang.Object
private  int persistenceSnapshotThreshold
          Log file must contain this many records before snapshot allowed
private  float persistenceSnapshotWeight
          Weight factor applied to snapshotSize when deciding to take snapshot
private  Discovery protocol2
          Utility for participating in version 2 of discovery protocols
private  RegistrarProxy proxy
          Proxy for myself
private  Random random
          Random number generator for use in lookup
private  InvocationConstraints rawUnicastDiscoveryConstraints
          Cached raw constraints associated with unicastDiscovery method
private  ReadyState ready
          Lock protecting startup and shutdown
private  ProxyPreparer recoveredListenerPreparer
          Preparer for remote event listeners recovered from state log
private  ProxyPreparer recoveredLocatorPreparer
          Preparer for lookup locators recovered from state log
private  boolean recoveredSnapshot
          Flag indicating whether system state was recovered from a snapshot
private  UuidGenerator resourceIdGenerator
          Generator for resource (e.g., registration, lease) Uuids
private  Exporter serverExporter
          Exporter for myself
private  ServerSocketFactory serverSocketFactory
          Unicast socket factories
private  HashMap serviceByAttr
          Map from EntryClass to HashMap[] where each HashMap is a map from Object (field value) to ArrayList(SvcReg).
private  HashMap serviceByEmptyAttr
          Map from EntryClass to ArrayList(SvcReg).
private  HashMap serviceByID
          Map from ServiceID to SvcReg.
private  TreeMap serviceByTime
          Identity map from SvcReg to SvcReg, ordered by lease expiration.
private  HashMap serviceByTypeName
          Map from String to HashMap mapping ServiceID to SvcReg.
private  Thread serviceExpirer
          Service lease expiration thread
private  UuidGenerator serviceIdGenerator
          Generator for service IDs
private  Object serviceNotifier
          Object for synchronizing with the service expire thread
private  Object snapshotNotifier
          Object on which the snapshot-taking thread will synchronize
private  Thread snapshotter
          Snapshot-taking thread
private  SocketFactory socketFactory
           
private  HashMap subEventByID
          Map from Long(eventID) to EventReg.
private  HashMap subEventByService
          Map from ServiceID to EventReg or EventReg[].
private  TaskManager tasker
          Task manager for sending events and discovery responses
private  long unexportTimeout
          Maximum time to wait for calls to finish before forcing unexport
private  long unexportWait
          Time to wait between unexport attempts
private  DiscoveryConstraints unicastDiscoveryConstraints
          Constraints specified for handling unicast discovery
private  ClientSubjectChecker unicastDiscoverySubjectChecker
          Client subject checker to apply to unicast discovery attempts
private  RegistrarImpl.UnicastThread unicaster
          Unicast discovery request packet receiving thread
private  int unicastPort
          Port for unicast discovery
 
Constructor Summary
RegistrarImpl(Configuration config, ActivationID activationID, boolean persistent, LifeCycle lifeCycle)
          Constructs RegistrarImpl based on the Configuration argument.
RegistrarImpl(String[] configArgs, ActivationID activationID, boolean persistent, LifeCycle lifeCycle)
          Constructs RegistrarImpl based on a configuration obtained using the provided string arguments.
 
Method Summary
private  HashMap addAttr(RegistrarImpl.SvcReg reg, EntryClass eclass, int fldidx, Object value)
          Put the service under the given attribute value for the given defining class and field, if it isn't already there.
 void addAttributes(ServiceID serviceID, Uuid leaseID, EntryRep[] attrSets)
          Adds the specified attribute sets (those that aren't duplicates of existing attribute sets) to the registered service item.
private  void addAttributesDo(ServiceID serviceID, Uuid leaseID, EntryRep[] attrSets)
          The code that does the real work of addAttributes.
private  void addAttrs(RegistrarImpl.SvcReg reg, EntryRep entry)
          Put the service in the serviceByAttr map under all attribute values in the given entry, or in the serviceByEmptyAttr map if the entry has no attributes, add a new instance of the EntryClass, and update entryClasses as necessary.
private  void addEvent(RegistrarImpl.EventReg reg)
          Add an event registration to our state.
private  void addInstance(EntryClass eclass)
          Add an instance of the EntryClass, and add the class to entryClasses if this is the first such instance.
private  void addLogRecord(RegistrarImpl.LogRecord rec)
          Add a state-change record to persistent storage.
 void addLookupAttributes(Entry[] attrSets)
          Add attribute sets for the service.
 void addLookupGroups(String[] groups)
          Add new groups to the set to join.
 void addLookupLocators(LookupLocator[] locators)
          Add locators for specific new lookup services to join.
 void addMemberGroups(String[] groups)
          Adds the given set of names to the set whose elements are the names of the groups in which the lookup service is currently a member.
private  void addService(RegistrarImpl.SvcReg reg)
          Add a service to our state.
private  void addServiceByTypes(ServiceType type, RegistrarImpl.SvcReg reg)
          Adds a service registration to types in its hierarchy
private static void addTypes(ArrayList types, ArrayList codebases, ServiceType[] bases, String prefix, ServiceType type, String codebase)
          Find the most specific types (of type) that don't match prefix and aren't equal to or a supertype of any types in bases, and add them to types.
private static boolean allNull(Object[] array)
          Test if all elements of the array are null.
private static Object[] arrayAdd(Object[] array, Object elt)
          Return a new array containing the elements of the given array plus the given element added to the end.
private static Object[] arrayDel(Object[] array, int i)
          Return a new array containing all the elements of the given array except the one at the specified index.
private static boolean attrMatch(EntryRep[] tmpls, EntryRep attrSet)
          Test if an entry either doesn't match any template in an array, or matches a template but is a subclass of the template type.
 void cancelEventLease(long eventID, Uuid leaseID)
          Cancels an event lease.
private  void cancelEventLeaseDo(long eventID, Uuid leaseID)
          The code that does the real work of cancelEventLease.
 Exception[] cancelLeases(Object[] regIDs, Uuid[] leaseIDs)
          Cancels service and event leases from a LeaseMap.
private  Exception[] cancelLeasesDo(Object[] regIDs, Uuid[] leaseIDs)
          The code that does the real work of cancelLeases.
 void cancelServiceLease(ServiceID serviceID, Uuid leaseID)
          Cancels a service lease.
private  void cancelServiceLeaseDo(ServiceID serviceID, Uuid leaseID)
          The code that does the real work of cancelServiceLease.
private  void closeRequestSockets(ArrayList tasks)
          Close any sockets that were sitting in the task queue.
private  void computeMaxLeases()
          Compute new maxServiceLease and maxEventLease values.
private static Item copyItem(Item item)
          Do a deep copy of the item, and substitute replacements for all embedded EntryClass instances and null for the ServiceType and codebase (since they aren't needed on the client side).
private  void deleteAttrs(RegistrarImpl.SvcReg reg, EntryRep entry, boolean checkDups)
          If checkDups is false, delete the service (if present) from serviceByAttr under all attribute values of the given entry or from serviceByEmptyAttr if the entry has no attributes.
private  void deleteEvent(RegistrarImpl.EventReg reg)
          Remove an event registration from our state.
private  void deleteInstance(EntryClass eclass)
          Delete an instance of the EntryClass, and remove the class from entryClasses if this is the last such instance.
private  void deleteService(RegistrarImpl.SvcReg reg, long now)
          Delete given service, generating events as necessary.
private  void deleteServiceFromTypes(ServiceType type, RegistrarImpl.SvcReg reg)
          Deletes a service registration from types in its hierarchy
private static EntryRep[] deleteSet(Item item, int i)
          Delete item.attributeSets[i] and return the new array.
 void destroy()
          Destroy the service, if possible, including its persistent storage.
private  void generateEvent(RegistrarImpl.EventReg reg, Item pre, Item post, ServiceID sid, long now)
          Generate an event if the event registration matches.
private  void generateEvents(Item pre, Item post, long now)
          Generate events for all matching event registrations.
 Object getAdmin()
          Returns an object that implements whatever administration interfaces are appropriate for the particular service.
private static EntryClass getDefiningClass(EntryClass eclass, int fldidx)
          Return the first (highest) class that defines the given field.
private  Discovery getDiscovery(int version)
          Returns Discovery instance implementing the given protocol version
private  EntryClass getEmptyEntryClass(EntryClass eclass)
          Return member of entryClasses that is equal to or a subclass of the specified class, provided there is exactly one such member and it has no fields.
 EntryClassBase[] getEntryClasses(Template tmpl)
          Looks at all service items that match the specified template, finds every entry (among those service items) that either doesn't match any entry templates or is a subclass of at least one matching entry template, and returns the set of the (most specific) classes of those entries.
private  EntryClassBase[] getEntryClassesDo(Template tmpl)
          The code that does the real work of getEntryClasses.
 Object[] getFieldValues(Template tmpl, int setIndex, int field)
          Looks at all service items that match the specified template, finds every entry (among those service items) that matches tmpl.attributeSetTemplates[setIndex], and returns the set of values of the specified field of those entries.
private  Object[] getFieldValuesDo(Template tmpl, int setidx, int fldidx)
          The code that does the real work of getFieldValues.
 LookupLocator getLocator()
          Returns a LookupLocator that can be used if necessary for unicast discovery of the lookup service.
 Entry[] getLookupAttributes()
          Get the current attribute sets for the service.
 String[] getLookupGroups()
          Get the list of groups to join.
 LookupLocator[] getLookupLocators()
          Get the list of locators of specific lookup services to join.
 String[] getMemberGroups()
          Returns an array consisting of the names of the groups in which the lookup service is a member.
 Object getProxy()
          Returns a proxy object for this remote object.
 TrustVerifier getProxyVerifier()
          Returns a TrustVerifier that can be used to verify that a proxy can be trusted as a proxy for the service; that is, the isTrustedObject method of the returned verifier can be called with a candidate proxy.
 Object getServiceProxy()
          Returns a proxy object for this object.
 ServiceTypeBase[] getServiceTypes(Template tmpl, String prefix)
          Looks at all service items that match the specified template, and for every service item finds the most specific type (class or interface) or types the service item is an instance of that are neither equal to, nor a superclass of, any of the service types in the template and that have names that start with the specified prefix, and returns the set of all such types.
private  ServiceTypeBase[] getServiceTypesDo(Template tmpl, String prefix)
          The code that does the real work of getServiceTypes.
 int getUnicastPort()
          Returns the port number on which the lookup service listens for unicast discovery queries.
private static boolean hasAttr(RegistrarImpl.SvcReg reg, EntryClass eclass, int fldidx, Object value)
          Test if the service has an entry of the given class or subclass with a field of the given value.
private static boolean hasEmptyAttr(RegistrarImpl.SvcReg reg, EntryClass eclass)
          Test if the service has an entry of the exact given class (assumed to have no fields).
private static int indexOf(Object[] array, int len, Object elt)
          Returns the first index of elt in the array if < len, else -1.
private static int indexOf(Object[] array, Object elt)
          Returns the first index of elt in the array, else -1.
private  void init(Configuration config, ActivationID activationID, boolean persistent, LifeCycle lifeCycle)
          Post-login (if login configured) initialization.
private static boolean isEmpty(Object[] array)
          Return true if the array is null or zero length
private static long limitDuration(long leaseDuration, long limit)
          Limit leaseDuration by limit, and check for negative value.
private  void loginAndRun(Configuration config, ActivationID activationID, boolean persistent, LifeCycle lifeCycle)
           
private static void logThrow(Level level, String className, String methodName, String message, Object[] args, Throwable thrown)
          Logs a thrown exception.
 MarshalledWrapper lookup(Template tmpl)
          Returns the service object (i.e., just ServiceItem.service) from an item matching the template, or null if there is no match.
 Matches lookup(Template tmpl, int maxMatches)
          Returns at most maxMatches items matching the template, plus the total number of items that match the template.
private  MarshalledWrapper lookupDo(Template tmpl)
          The code that does the real work of lookup.
private  Matches lookupDo(Template tmpl, int maxMatches)
          The code that does the real work of lookup.
private static void marshalAttributes(Entry[] attrs, ObjectOutputStream out)
          Writes reggie's attributes to ObjectOutputStream as a null-terminated list of MarshalledInstances.
private static void marshalLocators(LookupLocator[] locators, ObjectOutputStream out)
          Writes locators to the given stream as a null-terminated list of MarshalledInstances.
private static boolean matchAttributes(Template tmpl, Item item)
          Test if there is at least one matching entry in the Item for each entry template in the Template.
private static boolean matchEntry(EntryRep tmpl, EntryRep entry)
          Test if an entry matches a template.
private  RegistrarImpl.ItemIter matchingItems(Template tmpl)
          Return an appropriate iterator for Items matching the Template.
private  ArrayList matchingServices(ServiceType[] types)
          Returns a list of services that match all types passed in
private static boolean matchItem(Template tmpl, Item item)
          Test if an item matches a template.
private static boolean matchType(ServiceType[] types, ServiceType type)
          Test if a type is equal to or a subtype of every type in an array.
 void modifyAttributes(ServiceID serviceID, Uuid leaseID, EntryRep[] attrSetTmpls, EntryRep[] attrSets)
          Modifies existing attribute sets of a registered service item.
private  void modifyAttributesDo(ServiceID serviceID, Uuid leaseID, EntryRep[] attrSetTmpls, EntryRep[] attrSets)
          The code that does the real work of modifyAttributes.
 void modifyLookupAttributes(Entry[] attrSetTemplates, Entry[] attrSets)
          Modify the current attribute sets, using the same semantics as ServiceRegistration.modifyAttributes.
private  Uuid newLeaseID()
          Generate a new lease ID
private  ServiceID newServiceID()
          Generate a new service ID
 EventRegistration notify(Template tmpl, int transitions, RemoteEventListener listener, MarshalledObject handback, long leaseDuration)
          Registers for event notification.
private  EventRegistration notifyDo(Template tmpl, int transitions, RemoteEventListener listener, MarshalledObject handback, long leaseDuration)
          The code that does the real work of notify.
private static boolean overlap(Object[] arr1, Object[] arr2)
          Return true if some object is an element of both arrays
private  void pendingEvent(RegistrarImpl.EventReg reg, ServiceID sid, Item item, int transition)
          Add a pending EventTask for this event registration.
private  String pickCodebase(EntryClass eclass, ArrayList svcs, long now)
          Return any valid codebase for an entry of the exact given class.
private  String pickCodebase(EntryClass eclass, long now)
          Return any valid codebase for an entry class that has instances.
private static LookupLocator[] prepareLocators(LookupLocator[] locators, ProxyPreparer preparer, boolean tolerateFailures)
          Returns new array containing locators from the given non-null array prepared using the given proxy preparer.
private  void queueEvents()
          Queue all pending EventTasks for processing by the task manager.
private  void recoverEventRegistrations(ObjectInputStream stream)
          Recovers event registrations
private  void recoverServiceRegistrations(ObjectInputStream stream, int logVersion)
          Recovers service registrations and reggie's lookup attributes
private  void recoverSnapshot(InputStream in)
          Retrieve the contents of the snapshot file and reconstitute the 'base' state of the Registrar from the retrieved data.
 ServiceRegistration register(Item nitem, long leaseDuration)
          Register a new service or re-register an existing service.
private  ServiceRegistration registerDo(Item nitem, long leaseDuration)
          The code that does the real work of register.
private static Object[] removeDups(Object[] arr)
          Weed out duplicates.
 void removeLookupGroups(String[] groups)
          Remove groups from the set to join.
 void removeLookupLocators(LookupLocator[] locators)
          Remove locators for specific lookup services from the set to join.
 void removeMemberGroups(String[] groups)
          Deletes the elements of the given set of names from the set whose elements are the names of the groups in which the lookup service is currently a member.
 long renewEventLease(long eventID, Uuid leaseID, long renewDuration)
          Renews an event lease.
private  void renewEventLeaseAbs(long eventID, Uuid leaseID, long renewExpiration)
          Renew the event lease for an absolute expiration time.
private  long renewEventLeaseDo(long eventID, Uuid leaseID, long renewDuration)
          The code that does the real work of renewEventLease.
private  long renewEventLeaseInt(long eventID, Uuid leaseID, long renewDuration, long now)
           
 RenewResults renewLeases(Object[] regIDs, Uuid[] leaseIDs, long[] renewDurations)
          Renews service and event leases from a LeaseMap.
private  void renewLeasesAbs(Object[] regIDs, Uuid[] leaseIDs, long[] renewExpirations)
          Renew the leases for absolute expiration times.
private  RenewResults renewLeasesDo(Object[] regIDs, Uuid[] leaseIDs, long[] renewals)
          The code that does the real work of renewLeases.
 long renewServiceLease(ServiceID serviceID, Uuid leaseID, long renewDuration)
          Renews a service lease.
private  void renewServiceLeaseAbs(ServiceID serviceID, Uuid leaseID, long renewExpiration)
          Renew the service lease for an absolute expiration time.
private  long renewServiceLeaseDo(ServiceID serviceID, Uuid leaseID, long renewDuration)
          The code that does the real work of renewServiceLease.
private  long renewServiceLeaseInt(ServiceID serviceID, Uuid leaseID, long renewDuration, long now)
          Renew a service lease for a relative duration from now.
private  void respond(Socket socket)
          Process a unicast discovery request, and respond.
 void setAttributes(ServiceID serviceID, Uuid leaseID, EntryRep[] attrSets)
          Deletes all of the service item's existing attributes, and replaces them with the specified attribute sets.
private  void setAttributesDo(ServiceID serviceID, Uuid leaseID, EntryRep[] attrSets)
          The code that does the real work of setAttributes.
 void setLookupGroups(String[] groups)
          Replace the list of groups to join with a new list.
 void setLookupLocators(LookupLocator[] locators)
          Replace the list of locators of specific lookup services to join with a new list.
 void setMemberGroups(String[] groups)
          Replaces the set whose elements are the names of the groups in which the lookup service is currently a member with the given set of group names.
 void setUnicastPort(int port)
          Changes the number of the port on which the lookup service is currently listening for unicast discovery queries to the given port number.
private  void takeSnapshot(OutputStream out)
          Write the current state of the Registrar to persistent storage.
private static Entry[] unmarshalAttributes(ObjectInputStream in)
          Returns reggie's attributes unmarshalled from a null-terminated list of MarshalledInstances read from the given stream, logging (but tolerating) unmarshalling failures.
private static LookupLocator[] unmarshalLocators(ObjectInputStream in)
          Returns locators unmarshalled from a null-terminated list of MarshalledInstances read from the given stream, logging (but tolerating) unmarshalling failures.
private  void updateAttrs(RegistrarImpl.SvcReg reg, EntryRep entry, Object[] values)
          Store all non-null elements of values into the given entry, and update serviceByAttr to match.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_LEASE

private static final long MAX_LEASE
Maximum minMax lease duration for both services and events

See Also:
Constant Field Values

MAX_RENEW

private static final long MAX_RENEW
Maximum minimum renewal interval

See Also:
Constant Field Values

DEFAULT_MAX_PACKET_SIZE

private static final int DEFAULT_MAX_PACKET_SIZE
Default maximum size of multicast packets to send and receive

See Also:
Constant Field Values

DEFAULT_MULTICAST_TTL

private static final int DEFAULT_MULTICAST_TTL
Default time to live value to use for sending multicast packets

See Also:
Constant Field Values

DEFAULT_SOCKET_TIMEOUT

private static final int DEFAULT_SOCKET_TIMEOUT
Default timeout to set on sockets used for unicast discovery

See Also:
Constant Field Values

LOG_VERSION

private static final int LOG_VERSION
Log format version

See Also:
Constant Field Values

COMPONENT

private static final String COMPONENT
Logger and configuration component name

See Also:
Constant Field Values

myLeaseID

private static final Uuid myLeaseID
Lease ID always assigned to self


logger

private static final Logger logger
Logger used by this service


baseAttrs

private static final Entry[] baseAttrs
Base set of initial attributes for self


emptyAttrs

private static final EntryRep[] emptyAttrs
Empty attribute set


proxy

private RegistrarProxy proxy
Proxy for myself


serverExporter

private Exporter serverExporter
Exporter for myself


myRef

private Registrar myRef
Remote reference for myself


myServiceID

private ServiceID myServiceID
Our service ID


activationID

private ActivationID activationID
Our activation id, or null if not activatable


activationSystem

private ActivationSystem activationSystem
Associated activation system, or null if not activatable


myLocator

private volatile LookupLocator myLocator
Our LookupLocator


loginContext

private LoginContext loginContext
Our login context, for logging out


lifeCycle

private LifeCycle lifeCycle
Shutdown callback object, or null if no callback needed


serverSocketFactory

private ServerSocketFactory serverSocketFactory
Unicast socket factories


socketFactory

private SocketFactory socketFactory

serviceByID

private final HashMap serviceByID
Map from ServiceID to SvcReg. Every service is in this map under its serviceID.


serviceByTime

private final TreeMap serviceByTime
Identity map from SvcReg to SvcReg, ordered by lease expiration. Every service is in this map.


serviceByTypeName

private final HashMap serviceByTypeName
Map from String to HashMap mapping ServiceID to SvcReg. Every service is in this map under its types.


serviceByAttr

private final HashMap serviceByAttr
Map from EntryClass to HashMap[] where each HashMap is a map from Object (field value) to ArrayList(SvcReg). The HashMap array has as many elements as the EntryClass has fields (including fields defined by superclasses). Services are in this map multiple times, once for each field of each entry it has. The outer map is indexed by the first (highest) superclass that defines the field. This means that a HashMap[] has null elements for fields defined by superclasses, but this is a small memory hit and is simpler than subtracting off base index values when accessing the arrays.


serviceByEmptyAttr

private final HashMap serviceByEmptyAttr
Map from EntryClass to ArrayList(SvcReg). Services are in this map multiple times, once for each no-fields entry it has (no fields meaning none of the superclasses have fields either). The map is indexed by the exact type of the entry.


entryClasses

private final ArrayList entryClasses
All EntryClasses with non-zero numInstances


eventByID

private final HashMap eventByID
Map from Long(eventID) to EventReg. Every event registration is in this map under its eventID.


eventByTime

private final TreeMap eventByTime
Identity map from EventReg to EventReg, ordered by lease expiration. Every event registration is in this map.


subEventByService

private final HashMap subEventByService
Map from ServiceID to EventReg or EventReg[]. An event registration is in this map if its template matches on (at least) a specific serviceID.


subEventByID

private final HashMap subEventByID
Map from Long(eventID) to EventReg. An event registration is in this map if its template matches on ANY_SERVICE_ID.


resourceIdGenerator

private UuidGenerator resourceIdGenerator
Generator for resource (e.g., registration, lease) Uuids


serviceIdGenerator

private UuidGenerator serviceIdGenerator
Generator for service IDs


eventID

private long eventID
Event ID


random

private final Random random
Random number generator for use in lookup


listenerPreparer

private ProxyPreparer listenerPreparer
Preparer for received remote event listeners


recoveredListenerPreparer

private ProxyPreparer recoveredListenerPreparer
Preparer for remote event listeners recovered from state log


locatorPreparer

private ProxyPreparer locatorPreparer
Preparer for received lookup locators


recoveredLocatorPreparer

private ProxyPreparer recoveredLocatorPreparer
Preparer for lookup locators recovered from state log


newNotifies

private final ArrayList newNotifies
ArrayList of pending EventTasks


maxServiceLease

private long maxServiceLease
Current maximum service lease duration granted, in milliseconds.


maxEventLease

private long maxEventLease
Current maximum event lease duration granted, in milliseconds.


minSvcExpiration

private long minSvcExpiration
Earliest expiration time of a SvcReg


minEventExpiration

private long minEventExpiration
Earliest expiration time of an EventReg


discoer

private DiscoveryManagement discoer
Manager for discovering other lookup services


joiner

private JoinManager joiner
Manager for joining other lookup services


tasker

private TaskManager tasker
Task manager for sending events and discovery responses


serviceExpirer

private Thread serviceExpirer
Service lease expiration thread


eventExpirer

private Thread eventExpirer
Event lease expiration thread


unicaster

private RegistrarImpl.UnicastThread unicaster
Unicast discovery request packet receiving thread


multicaster

private Thread multicaster
Multicast discovery request packet receiving thread


announcer

private Thread announcer
Multicast discovery announcement sending thread


snapshotter

private Thread snapshotter
Snapshot-taking thread


concurrentObj

private final ReadersWriter concurrentObj
Concurrent object to control read and write access


serviceNotifier

private final Object serviceNotifier
Object for synchronizing with the service expire thread


eventNotifier

private final Object eventNotifier
Object for synchronizing with the event expire thread


snapshotNotifier

private final Object snapshotNotifier
Object on which the snapshot-taking thread will synchronize


objectServiceType

private ServiceType objectServiceType
Canonical ServiceType for java.lang.Object


log

private ReliableLog log
Log for recovering/storing state, or null if running as transient


inRecovery

private boolean inRecovery
Flag indicating whether system is in a state of recovery


recoveredSnapshot

private boolean recoveredSnapshot
Flag indicating whether system state was recovered from a snapshot


logFileSize

private int logFileSize
Current number of records in the Log File since the last snapshot


persistenceSnapshotThreshold

private int persistenceSnapshotThreshold
Log file must contain this many records before snapshot allowed


persistenceSnapshotWeight

private float persistenceSnapshotWeight
Weight factor applied to snapshotSize when deciding to take snapshot


minMaxServiceLease

private long minMaxServiceLease
Minimum value for maxServiceLease.


minMaxEventLease

private long minMaxEventLease
Minimum value for maxEventLease.


minRenewalInterval

private long minRenewalInterval
Minimum average time between lease renewals, in milliseconds.


unicastPort

private int unicastPort
Port for unicast discovery


memberGroups

private volatile String[] memberGroups
The groups we are a member of


lookupGroups

private String[] lookupGroups
The groups we should join


lookupLocators

private LookupLocator[] lookupLocators
The locators of other lookups we should join


lookupAttrs

private Entry[] lookupAttrs
The attributes to use when joining (including with myself)


multicastAnnouncementInterval

private long multicastAnnouncementInterval
Interval to wait in between sending multicast announcements


announcementSeqNo

private volatile long announcementSeqNo
Multicast announcement sequence number


multicastInterfaces

private NetworkInterface[] multicastInterfaces
Network interfaces to use for multicast discovery


multicastInterfacesSpecified

private boolean multicastInterfacesSpecified
Flag indicating whether network interfaces were explicitly specified


multicastInterfaceRetryInterval

private int multicastInterfaceRetryInterval
Interval to wait in between retrying failed interfaces


protocol2

private Discovery protocol2
Utility for participating in version 2 of discovery protocols


rawUnicastDiscoveryConstraints

private InvocationConstraints rawUnicastDiscoveryConstraints
Cached raw constraints associated with unicastDiscovery method


multicastRequestConstraints

private DiscoveryConstraints multicastRequestConstraints
Constraints specified for incoming multicast requests


multicastAnnouncementConstraints

private DiscoveryConstraints multicastAnnouncementConstraints
Constraints specified for outgoing multicast announcements


unicastDiscoveryConstraints

private DiscoveryConstraints unicastDiscoveryConstraints
Constraints specified for handling unicast discovery


multicastRequestSubjectChecker

private ClientSubjectChecker multicastRequestSubjectChecker
Client subject checker to apply to incoming multicast requests


unexportTimeout

private volatile long unexportTimeout
Maximum time to wait for calls to finish before forcing unexport


unexportWait

private volatile long unexportWait
Time to wait between unexport attempts


unicastDiscoverySubjectChecker

private ClientSubjectChecker unicastDiscoverySubjectChecker
Client subject checker to apply to unicast discovery attempts


ready

private final ReadyState ready
Lock protecting startup and shutdown

Constructor Detail

RegistrarImpl

RegistrarImpl(String[] configArgs,
              ActivationID activationID,
              boolean persistent,
              LifeCycle lifeCycle)
        throws Exception
Constructs RegistrarImpl based on a configuration obtained using the provided string arguments. If activationID is non-null, the created RegistrarImpl runs as activatable; if persistent is true, it persists/recovers its state to/from disk. A RegistrarImpl instance cannot be constructed as both activatable and non-persistent. If lifeCycle is non-null, its unregister method is invoked during shutdown.

Throws:
Exception

RegistrarImpl

RegistrarImpl(Configuration config,
              ActivationID activationID,
              boolean persistent,
              LifeCycle lifeCycle)
        throws Exception
Constructs RegistrarImpl based on the Configuration argument. If activationID is non-null, the created RegistrarImpl runs as activatable; if persistent is true, it persists/recovers its state to/from disk. A RegistrarImpl instance cannot be constructed as both activatable and non-persistent. If lifeCycle is non-null, its unregister method is invoked during shutdown.

Throws:
Exception
Method Detail

loginAndRun

private void loginAndRun(Configuration config,
                         ActivationID activationID,
                         boolean persistent,
                         LifeCycle lifeCycle)
                  throws Throwable
Throws:
Throwable

getServiceProxy

public Object getServiceProxy()
                       throws NoSuchObjectException
Description copied from interface: ServiceProxyAccessor
Returns a proxy object for this object. This value should not be null.

Specified by:
getServiceProxy in interface ServiceProxyAccessor
Returns:
a proxy object reference
Throws:
NoSuchObjectException

getProxy

public Object getProxy()
Description copied from interface: ProxyAccessor
Returns a proxy object for this remote object. If this remote object is not exported (and hence, no proxy is available), then null is returned.

Specified by:
getProxy in interface ProxyAccessor
Returns:
a proxy, or null

getProxyVerifier

public TrustVerifier getProxyVerifier()
                               throws NoSuchObjectException
Description copied from interface: ServerProxyTrust
Returns a TrustVerifier that can be used to verify that a proxy can be trusted as a proxy for the service; that is, the isTrustedObject method of the returned verifier can be called with a candidate proxy. The verifier should be able to verify all proxies for the service, including proxies for resources (such as leases and registrations).

Specified by:
getProxyVerifier in interface ServerProxyTrust
Returns:
a TrustVerifier that can be used to verify that a proxy can be trusted as a proxy for the service
Throws:
NoSuchObjectException

register

public ServiceRegistration register(Item nitem,
                                    long leaseDuration)
                             throws NoSuchObjectException
Description copied from interface: Registrar
Register a new service or re-register an existing service.

Specified by:
register in interface Registrar
Throws:
NoSuchObjectException
See Also:
ServiceRegistrar.register(net.jini.core.lookup.ServiceItem, long)

lookup

public MarshalledWrapper lookup(Template tmpl)
                         throws NoSuchObjectException
Description copied from interface: Registrar
Returns the service object (i.e., just ServiceItem.service) from an item matching the template, or null if there is no match.

Specified by:
lookup in interface Registrar
Throws:
NoSuchObjectException
See Also:
ServiceRegistrar.lookup(net.jini.core.lookup.ServiceTemplate)

lookup

public Matches lookup(Template tmpl,
                      int maxMatches)
               throws NoSuchObjectException
Description copied from interface: Registrar
Returns at most maxMatches items matching the template, plus the total number of items that match the template.

Specified by:
lookup in interface Registrar
Throws:
NoSuchObjectException
See Also:
ServiceRegistrar.lookup(net.jini.core.lookup.ServiceTemplate)

notify

public EventRegistration notify(Template tmpl,
                                int transitions,
                                RemoteEventListener listener,
                                MarshalledObject handback,
                                long leaseDuration)
                         throws RemoteException
Description copied from interface: Registrar
Registers for event notification.

Specified by:
notify in interface Registrar
Throws:
RemoteException
See Also:
ServiceRegistrar.notify(net.jini.core.lookup.ServiceTemplate, int, net.jini.core.event.RemoteEventListener, java.rmi.MarshalledObject, long)

getEntryClasses

public EntryClassBase[] getEntryClasses(Template tmpl)
                                 throws NoSuchObjectException
Description copied from interface: Registrar
Looks at all service items that match the specified template, finds every entry (among those service items) that either doesn't match any entry templates or is a subclass of at least one matching entry template, and returns the set of the (most specific) classes of those entries.

Specified by:
getEntryClasses in interface Registrar
Throws:
NoSuchObjectException
See Also:
ServiceRegistrar.getEntryClasses(net.jini.core.lookup.ServiceTemplate)

getFieldValues

public Object[] getFieldValues(Template tmpl,
                               int setIndex,
                               int field)
                        throws NoSuchObjectException
Description copied from interface: Registrar
Looks at all service items that match the specified template, finds every entry (among those service items) that matches tmpl.attributeSetTemplates[setIndex], and returns the set of values of the specified field of those entries. The field name has been converted to an index (fields numbered from super to subclass).

Specified by:
getFieldValues in interface Registrar
Throws:
NoSuchObjectException
See Also:
ServiceRegistrar.getFieldValues(net.jini.core.lookup.ServiceTemplate, int, java.lang.String)

getServiceTypes

public ServiceTypeBase[] getServiceTypes(Template tmpl,
                                         String prefix)
                                  throws NoSuchObjectException
Description copied from interface: Registrar
Looks at all service items that match the specified template, and for every service item finds the most specific type (class or interface) or types the service item is an instance of that are neither equal to, nor a superclass of, any of the service types in the template and that have names that start with the specified prefix, and returns the set of all such types.

Specified by:
getServiceTypes in interface Registrar
Throws:
NoSuchObjectException
See Also:
ServiceRegistrar.getServiceTypes(net.jini.core.lookup.ServiceTemplate, java.lang.String)

getLocator

public LookupLocator getLocator()
                         throws NoSuchObjectException
Description copied from interface: Registrar
Returns a LookupLocator that can be used if necessary for unicast discovery of the lookup service.

Specified by:
getLocator in interface Registrar
Throws:
NoSuchObjectException
See Also:
ServiceRegistrar.getLocator()

getAdmin

public Object getAdmin()
                throws NoSuchObjectException
Description copied from interface: Administrable
Returns an object that implements whatever administration interfaces are appropriate for the particular service.

Specified by:
getAdmin in interface Administrable
Returns:
an object that implements whatever administration interfaces are appropriate for the particular service.
Throws:
NoSuchObjectException
See Also:
JoinAdmin

addAttributes

public void addAttributes(ServiceID serviceID,
                          Uuid leaseID,
                          EntryRep[] attrSets)
                   throws NoSuchObjectException,
                          UnknownLeaseException
Description copied from interface: Registrar
Adds the specified attribute sets (those that aren't duplicates of existing attribute sets) to the registered service item.

Specified by:
addAttributes in interface Registrar
Throws:
NoSuchObjectException
UnknownLeaseException
See Also:
ServiceRegistration.addAttributes(net.jini.core.entry.Entry[])

modifyAttributes

public void modifyAttributes(ServiceID serviceID,
                             Uuid leaseID,
                             EntryRep[] attrSetTmpls,
                             EntryRep[] attrSets)
                      throws NoSuchObjectException,
                             UnknownLeaseException
Description copied from interface: Registrar
Modifies existing attribute sets of a registered service item.

Specified by:
modifyAttributes in interface Registrar
Throws:
NoSuchObjectException
UnknownLeaseException
See Also:
ServiceRegistration.modifyAttributes(net.jini.core.entry.Entry[], net.jini.core.entry.Entry[])

setAttributes

public void setAttributes(ServiceID serviceID,
                          Uuid leaseID,
                          EntryRep[] attrSets)
                   throws NoSuchObjectException,
                          UnknownLeaseException
Description copied from interface: Registrar
Deletes all of the service item's existing attributes, and replaces them with the specified attribute sets.

Specified by:
setAttributes in interface Registrar
Throws:
NoSuchObjectException
UnknownLeaseException
See Also:
ServiceRegistration.setAttributes(net.jini.core.entry.Entry[])

cancelServiceLease

public void cancelServiceLease(ServiceID serviceID,
                               Uuid leaseID)
                        throws NoSuchObjectException,
                               UnknownLeaseException
Description copied from interface: Registrar
Cancels a service lease.

Specified by:
cancelServiceLease in interface Registrar
Throws:
NoSuchObjectException
UnknownLeaseException
See Also:
Lease.cancel()

renewServiceLease

public long renewServiceLease(ServiceID serviceID,
                              Uuid leaseID,
                              long renewDuration)
                       throws NoSuchObjectException,
                              UnknownLeaseException
Description copied from interface: Registrar
Renews a service lease.

Specified by:
renewServiceLease in interface Registrar
Throws:
NoSuchObjectException
UnknownLeaseException
See Also:
Lease.renew(long)

cancelEventLease

public void cancelEventLease(long eventID,
                             Uuid leaseID)
                      throws NoSuchObjectException,
                             UnknownLeaseException
Description copied from interface: Registrar
Cancels an event lease.

Specified by:
cancelEventLease in interface Registrar
Throws:
NoSuchObjectException
UnknownLeaseException
See Also:
Lease.cancel()

renewEventLease

public long renewEventLease(long eventID,
                            Uuid leaseID,
                            long renewDuration)
                     throws NoSuchObjectException,
                            UnknownLeaseException
Description copied from interface: Registrar
Renews an event lease.

Specified by:
renewEventLease in interface Registrar
Throws:
NoSuchObjectException
UnknownLeaseException
See Also:
Lease.renew(long)

renewLeases

public RenewResults renewLeases(Object[] regIDs,
                                Uuid[] leaseIDs,
                                long[] renewDurations)
                         throws NoSuchObjectException
Description copied from interface: Registrar
Renews service and event leases from a LeaseMap.

Specified by:
renewLeases in interface Registrar
Throws:
NoSuchObjectException
See Also:
LeaseMap.renewAll()

cancelLeases

public Exception[] cancelLeases(Object[] regIDs,
                                Uuid[] leaseIDs)
                         throws NoSuchObjectException
Description copied from interface: Registrar
Cancels service and event leases from a LeaseMap.

Specified by:
cancelLeases in interface Registrar
Throws:
NoSuchObjectException
See Also:
LeaseMap.cancelAll()

getLookupAttributes

public Entry[] getLookupAttributes()
                            throws NoSuchObjectException
Description copied from interface: JoinAdmin
Get the current attribute sets for the service.

Specified by:
getLookupAttributes in interface JoinAdmin
Returns:
the current attribute sets for the service
Throws:
NoSuchObjectException

addLookupAttributes

public void addLookupAttributes(Entry[] attrSets)
                         throws RemoteException
Description copied from interface: JoinAdmin
Add attribute sets for the service. The resulting set will be used for all future joins. The attribute sets are also added to all currently-joined lookup services.

Specified by:
addLookupAttributes in interface JoinAdmin
Parameters:
attrSets - the attribute sets to add
Throws:
RemoteException

modifyLookupAttributes

public void modifyLookupAttributes(Entry[] attrSetTemplates,
                                   Entry[] attrSets)
                            throws RemoteException
Description copied from interface: JoinAdmin
Modify the current attribute sets, using the same semantics as ServiceRegistration.modifyAttributes. The resulting set will be used for all future joins. The same modifications are also made to all currently-joined lookup services.

Specified by:
modifyLookupAttributes in interface JoinAdmin
Parameters:
attrSetTemplates - the templates for matching attribute sets
attrSets - the modifications to make to matching sets
Throws:
RemoteException
See Also:
ServiceRegistration.modifyAttributes(net.jini.core.entry.Entry[], net.jini.core.entry.Entry[])

getLookupGroups

public String[] getLookupGroups()
                         throws NoSuchObjectException
Description copied from interface: JoinAdmin
Get the list of groups to join. An empty array means the service joins no groups (as opposed to "all" groups).

Specified by:
getLookupGroups in interface JoinAdmin
Returns:
an array of groups to join. An empty array means the service joins no groups (as opposed to "all" groups).
Throws:
NoSuchObjectException
See Also:
JoinAdmin.setLookupGroups(java.lang.String[])

addLookupGroups

public void addLookupGroups(String[] groups)
                     throws NoSuchObjectException
Description copied from interface: JoinAdmin
Add new groups to the set to join. Lookup services in the new groups will be discovered and joined.

Specified by:
addLookupGroups in interface JoinAdmin
Parameters:
groups - groups to join
Throws:
NoSuchObjectException
See Also:
JoinAdmin.removeLookupGroups(java.lang.String[])

removeLookupGroups

public void removeLookupGroups(String[] groups)
                        throws NoSuchObjectException
Description copied from interface: JoinAdmin
Remove groups from the set to join. Leases are cancelled at lookup services that are not members of any of the remaining groups.

Specified by:
removeLookupGroups in interface JoinAdmin
Parameters:
groups - groups to leave
Throws:
NoSuchObjectException
See Also:
JoinAdmin.addLookupGroups(java.lang.String[])

setLookupGroups

public void setLookupGroups(String[] groups)
                     throws NoSuchObjectException
Description copied from interface: JoinAdmin
Replace the list of groups to join with a new list. Leases are cancelled at lookup services that are not members of any of the new groups. Lookup services in the new groups will be discovered and joined.

Specified by:
setLookupGroups in interface JoinAdmin
Parameters:
groups - groups to join
Throws:
NoSuchObjectException
See Also:
JoinAdmin.getLookupGroups()

getLookupLocators

public LookupLocator[] getLookupLocators()
                                  throws NoSuchObjectException
Description copied from interface: JoinAdmin
Get the list of locators of specific lookup services to join.

Specified by:
getLookupLocators in interface JoinAdmin
Returns:
the list of locators of specific lookup services to join
Throws:
NoSuchObjectException
See Also:
JoinAdmin.setLookupLocators(net.jini.core.discovery.LookupLocator[])

addLookupLocators

public void addLookupLocators(LookupLocator[] locators)
                       throws RemoteException
Description copied from interface: JoinAdmin
Add locators for specific new lookup services to join. The new lookup services will be discovered and joined.

Specified by:
addLookupLocators in interface JoinAdmin
Parameters:
locators - locators of specific lookup services to join
Throws:
RemoteException
See Also:
JoinAdmin.removeLookupLocators(net.jini.core.discovery.LookupLocator[])

removeLookupLocators

public void removeLookupLocators(LookupLocator[] locators)
                          throws RemoteException
Description copied from interface: JoinAdmin
Remove locators for specific lookup services from the set to join. Any leases held at the lookup services are cancelled.

Specified by:
removeLookupLocators in interface JoinAdmin
Parameters:
locators - locators of specific lookup services to leave
Throws:
RemoteException
See Also:
JoinAdmin.addLookupLocators(net.jini.core.discovery.LookupLocator[])

setLookupLocators

public void setLookupLocators(LookupLocator[] locators)
                       throws RemoteException
Description copied from interface: JoinAdmin
Replace the list of locators of specific lookup services to join with a new list. Leases are cancelled at lookup services that were in the old list but are not in the new list. Any new lookup services will be discovered and joined.

Specified by:
setLookupLocators in interface JoinAdmin
Parameters:
locators - locators of specific lookup services to join
Throws:
RemoteException
See Also:
JoinAdmin.getLookupLocators()

addMemberGroups

public void addMemberGroups(String[] groups)
                     throws NoSuchObjectException
Description copied from interface: DiscoveryAdmin
Adds the given set of names to the set whose elements are the names of the groups in which the lookup service is currently a member. Elements in the input set that duplicate names of groups in which the lookup service is already a member will be ignored. If the empty array (NO_GROUPS) is input, this method takes no action.

Specified by:
addMemberGroups in interface DiscoveryAdmin
Parameters:
groups - String array consisting of the names of the new, additional groups in which the lookup service is to be a member.
Throws:
NoSuchObjectException

removeMemberGroups

public void removeMemberGroups(String[] groups)
                        throws NoSuchObjectException
Description copied from interface: DiscoveryAdmin
Deletes the elements of the given set of names from the set whose elements are the names of the groups in which the lookup service is currently a member. Any element in the input set that is not a name of a group in which the lookup service is currently a member will be ignored. If the empty array (NO_GROUPS) is input, this method takes no action.

Specified by:
removeMemberGroups in interface DiscoveryAdmin
Parameters:
groups - String array consisting of the names to remove from the set whose elements are the names of the groups in which the lookup service is currently a member.
Throws:
NoSuchObjectException

getMemberGroups

public String[] getMemberGroups()
                         throws NoSuchObjectException
Description copied from interface: DiscoveryAdmin
Returns an array consisting of the names of the groups in which the lookup service is a member. If the lookup service currently belongs to no groups, this method will return the empty array.

Specified by:
getMemberGroups in interface DiscoveryAdmin
Returns:
String array consisting of the names of the groups in which the lookup service is a member
Throws:
NoSuchObjectException

setMemberGroups

public void setMemberGroups(String[] groups)
                     throws NoSuchObjectException
Description copied from interface: DiscoveryAdmin
Replaces the set whose elements are the names of the groups in which the lookup service is currently a member with the given set of group names. Elements in the input set that duplicate other elements in the input set will be ignored. If the empty array (NO_GROUPS) is input, then the lookup service will be a member of no groups.

Specified by:
setMemberGroups in interface DiscoveryAdmin
Parameters:
groups - String array consisting of the names of the new groups in which the lookup service is to be a member.
Throws:
NoSuchObjectException

getUnicastPort

public int getUnicastPort()
                   throws NoSuchObjectException
Description copied from interface: DiscoveryAdmin
Returns the port number on which the lookup service listens for unicast discovery queries.

Specified by:
getUnicastPort in interface DiscoveryAdmin
Returns:
an int representing the port number on which the lookup service listens for unicast discovery queries.
Throws:
NoSuchObjectException

setUnicastPort

public void setUnicastPort(int port)
                    throws IOException,
                           RemoteException
Description copied from interface: DiscoveryAdmin
Changes the number of the port on which the lookup service is currently listening for unicast discovery queries to the given port number. If a value of zero is input, then the lookup service will first try to listen on the standard unicast discovery port, but if that fails, the lookup service will listen on an arbitrary port.

Specified by:
setUnicastPort in interface DiscoveryAdmin
Parameters:
port - int representing the new port number on which the lookup service should listen for unicast discovery queries.
Throws:
IOException - because an invocation of this method will result in the re-initiation of the unicast discovery process, which can throw an IOException when socket allocation occurs.
RemoteException - typically, this exception occurs when there is a communication failure between the client and the server.

destroy

public void destroy()
             throws RemoteException
Description copied from interface: DestroyAdmin
Destroy the service, if possible, including its persistent storage. This method should (in effect) spawn a separate thread to do the actual work asynchronously, and make a reasonable attempt to let this remote call return successfully. As such, a successful return from this method does not mean that the service has been destroyed. Although the service should make a reasonable attempt to let this remote call return successfully, the service must not wait indefinitely for other (in-progress and subsequent) remote calls to finish before proceeding to destroy itself. Once this method has been called, the service can, but need not, reject all other (in-progress and subsequent) remote calls to the service.

Specified by:
destroy in interface DestroyAdmin
Throws:
RemoteException

arrayAdd

private static Object[] arrayAdd(Object[] array,
                                 Object elt)
Return a new array containing the elements of the given array plus the given element added to the end.


arrayDel

private static Object[] arrayDel(Object[] array,
                                 int i)
Return a new array containing all the elements of the given array except the one at the specified index.


indexOf

private static int indexOf(Object[] array,
                           Object elt)
Returns the first index of elt in the array, else -1.


indexOf

private static int indexOf(Object[] array,
                           int len,
                           Object elt)
Returns the first index of elt in the array if < len, else -1.


isEmpty

private static boolean isEmpty(Object[] array)
Return true if the array is null or zero length


overlap

private static boolean overlap(Object[] arr1,
                               Object[] arr2)
Return true if some object is an element of both arrays


allNull

private static boolean allNull(Object[] array)
Test if all elements of the array are null.


removeDups

private static Object[] removeDups(Object[] arr)
Weed out duplicates.


deleteSet

private static EntryRep[] deleteSet(Item item,
                                    int i)
Delete item.attributeSets[i] and return the new array.


copyItem

private static Item copyItem(Item item)
Do a deep copy of the item, and substitute replacements for all embedded EntryClass instances and null for the ServiceType and codebase (since they aren't needed on the client side).


getDefiningClass

private static EntryClass getDefiningClass(EntryClass eclass,
                                           int fldidx)
Return the first (highest) class that defines the given field. This would be a method on EntryClass, but we want to minimize code downloaded into the client.


addServiceByTypes

private void addServiceByTypes(ServiceType type,
                               RegistrarImpl.SvcReg reg)
Adds a service registration to types in its hierarchy


deleteServiceFromTypes

private void deleteServiceFromTypes(ServiceType type,
                                    RegistrarImpl.SvcReg reg)
Deletes a service registration from types in its hierarchy


matchItem

private static boolean matchItem(Template tmpl,
                                 Item item)
Test if an item matches a template. This would be a method on Template, but we want to minimize code downloaded into the client.


matchType

private static boolean matchType(ServiceType[] types,
                                 ServiceType type)
Test if a type is equal to or a subtype of every type in an array.


matchEntry

private static boolean matchEntry(EntryRep tmpl,
                                  EntryRep entry)
Test if an entry matches a template. This would be a method on EntryRep, but we want to minimize code downloaded into the client.


matchAttributes

private static boolean matchAttributes(Template tmpl,
                                       Item item)
Test if there is at least one matching entry in the Item for each entry template in the Template.


attrMatch

private static boolean attrMatch(EntryRep[] tmpls,
                                 EntryRep attrSet)
Test if an entry either doesn't match any template in an array, or matches a template but is a subclass of the template type.


hasAttr

private static boolean hasAttr(RegistrarImpl.SvcReg reg,
                               EntryClass eclass,
                               int fldidx,
                               Object value)
Test if the service has an entry of the given class or subclass with a field of the given value.


hasEmptyAttr

private static boolean hasEmptyAttr(RegistrarImpl.SvcReg reg,
                                    EntryClass eclass)
Test if the service has an entry of the exact given class (assumed to have no fields).


addTypes

private static void addTypes(ArrayList types,
                             ArrayList codebases,
                             ServiceType[] bases,
                             String prefix,
                             ServiceType type,
                             String codebase)
Find the most specific types (of type) that don't match prefix and aren't equal to or a supertype of any types in bases, and add them to types.


limitDuration

private static long limitDuration(long leaseDuration,
                                  long limit)
Limit leaseDuration by limit, and check for negative value.


marshalAttributes

private static void marshalAttributes(Entry[] attrs,
                                      ObjectOutputStream out)
                               throws IOException
Writes reggie's attributes to ObjectOutputStream as a null-terminated list of MarshalledInstances.

Throws:
IOException

unmarshalAttributes

private static Entry[] unmarshalAttributes(ObjectInputStream in)
                                    throws IOException,
                                           ClassNotFoundException
Returns reggie's attributes unmarshalled from a null-terminated list of MarshalledInstances read from the given stream, logging (but tolerating) unmarshalling failures.

Throws:
IOException
ClassNotFoundException

marshalLocators

private static void marshalLocators(LookupLocator[] locators,
                                    ObjectOutputStream out)
                             throws IOException
Writes locators to the given stream as a null-terminated list of MarshalledInstances.

Throws:
IOException

unmarshalLocators

private static LookupLocator[] unmarshalLocators(ObjectInputStream in)
                                          throws IOException,
                                                 ClassNotFoundException
Returns locators unmarshalled from a null-terminated list of MarshalledInstances read from the given stream, logging (but tolerating) unmarshalling failures.

Throws:
IOException
ClassNotFoundException

prepareLocators

private static LookupLocator[] prepareLocators(LookupLocator[] locators,
                                               ProxyPreparer preparer,
                                               boolean tolerateFailures)
                                        throws RemoteException
Returns new array containing locators from the given non-null array prepared using the given proxy preparer. If tolerateFailures is false, then any proxy preparation exception is propagated to the caller. Otherwise, such exceptions are logged, and only successfully prepared locators are included in the returned array.

Throws:
RemoteException

logThrow

private static void logThrow(Level level,
                             String className,
                             String methodName,
                             String message,
                             Object[] args,
                             Throwable thrown)
Logs a thrown exception.


addService

private void addService(RegistrarImpl.SvcReg reg)
Add a service to our state. This includes putting it in the serviceByID map under the serviceID, in the serviceByTime map, in the serviceByType map under the service's most-specific ServiceType, and in the serviceByAttr map under all of its attribute values, incrementing the number of instances of each EntryClass, and updating entryClasses as necessary. If this is the first instance of that ServiceType registered, then we need to add concrete class information to the type and all supertypes.


deleteService

private void deleteService(RegistrarImpl.SvcReg reg,
                           long now)
Delete given service, generating events as necessary. This includes deleting from the serviceByID, serviceByTime, serviceByType, and serviceByAttr maps, decrementing the number of instances of each EntryClass, and updating entryClasses as necessary. If this is the last registered instance of the service type, then we delete the concrete class information from the type and all supertypes.


addEvent

private void addEvent(RegistrarImpl.EventReg reg)
Add an event registration to our state. This includes adding a template of each EntryClass, putting the registration in the eventByID map, in the eventByTime map, and in either subEventByService (if the template is for a specific service id) or subEventByID. Since we expect in most cases there will only ever be a single event registration for a given service id, we avoid creating a singleton array in that case.


deleteEvent

private void deleteEvent(RegistrarImpl.EventReg reg)
Remove an event registration from our state. This includes deleting a template of each EntryClass, deleting the registration from the eventByID map, the eventByTime map, and either the subEventByService or subEventByID map.


addAttrs

private void addAttrs(RegistrarImpl.SvcReg reg,
                      EntryRep entry)
Put the service in the serviceByAttr map under all attribute values in the given entry, or in the serviceByEmptyAttr map if the entry has no attributes, add a new instance of the EntryClass, and update entryClasses as necessary.


deleteAttrs

private void deleteAttrs(RegistrarImpl.SvcReg reg,
                         EntryRep entry,
                         boolean checkDups)
If checkDups is false, delete the service (if present) from serviceByAttr under all attribute values of the given entry or from serviceByEmptyAttr if the entry has no attributes. If checkDups is true, only delete for a given attribute value if the service has no other entries of similar type that still have the same value. Either way, delete an instance of the EntryClass, and update entryClasses as necessary.


updateAttrs

private void updateAttrs(RegistrarImpl.SvcReg reg,
                         EntryRep entry,
                         Object[] values)
Store all non-null elements of values into the given entry, and update serviceByAttr to match.


addAttr

private HashMap addAttr(RegistrarImpl.SvcReg reg,
                        EntryClass eclass,
                        int fldidx,
                        Object value)
Put the service under the given attribute value for the given defining class and field, if it isn't already there. Return the HashMap for the given class and field.


addInstance

private void addInstance(EntryClass eclass)
Add an instance of the EntryClass, and add the class to entryClasses if this is the first such instance.


deleteInstance

private void deleteInstance(EntryClass eclass)
Delete an instance of the EntryClass, and remove the class from entryClasses if this is the last such instance.


matchingItems

private RegistrarImpl.ItemIter matchingItems(Template tmpl)
Return an appropriate iterator for Items matching the Template.


getEmptyEntryClass

private EntryClass getEmptyEntryClass(EntryClass eclass)
Return member of entryClasses that is equal to or a subclass of the specified class, provided there is exactly one such member and it has no fields.


matchingServices

private ArrayList matchingServices(ServiceType[] types)
Returns a list of services that match all types passed in


pickCodebase

private String pickCodebase(EntryClass eclass,
                            long now)
                     throws ClassNotFoundException
Return any valid codebase for an entry class that has instances.

Throws:
ClassNotFoundException

pickCodebase

private String pickCodebase(EntryClass eclass,
                            ArrayList svcs,
                            long now)
                     throws ClassNotFoundException
Return any valid codebase for an entry of the exact given class.

Throws:
ClassNotFoundException

computeMaxLeases

private void computeMaxLeases()
Compute new maxServiceLease and maxEventLease values. This needs to be called whenever the number of services (#S) or number of events (#E) changes, or whenever any of the configuration parameters change. The two base equations driving the computation are: #S/maxServiceLease + #E/maxEventLease <= 1/minRenewalInterval maxServiceLease/maxEventLease = minMaxServiceLease/minMaxEventLease


respond

private void respond(Socket socket)
              throws Exception
Process a unicast discovery request, and respond.

Throws:
Exception

getDiscovery

private Discovery getDiscovery(int version)
                        throws DiscoveryProtocolException
Returns Discovery instance implementing the given protocol version

Throws:
DiscoveryProtocolException

closeRequestSockets

private void closeRequestSockets(ArrayList tasks)
Close any sockets that were sitting in the task queue.


init

private void init(Configuration config,
                  ActivationID activationID,
                  boolean persistent,
                  LifeCycle lifeCycle)
           throws IOException,
                  ConfigurationException,
                  ActivationException
Post-login (if login configured) initialization.

Throws:
IOException
ConfigurationException
ActivationException

registerDo

private ServiceRegistration registerDo(Item nitem,
                                       long leaseDuration)
The code that does the real work of register.


lookupDo

private MarshalledWrapper lookupDo(Template tmpl)
The code that does the real work of lookup. As a special case, if the template specifies at least one service type to match, and there are multiple items that match the template, then we make a random pick among them, in an attempt to load balance use of "equivalent" services and avoid starving any of them.


lookupDo

private Matches lookupDo(Template tmpl,
                         int maxMatches)
The code that does the real work of lookup. We do a deep copy of the items being returned, both to avoid having them modified while being marshalled (by a concurrent update method), and to substitute replacements for embedded EntryClass and ServiceType instances, to minimize data sent back to the client. If duplicates are possible from the iterator, we save all matches, weeding out duplicates as we go, then trim to maxMatches and deep copy.


notifyDo

private EventRegistration notifyDo(Template tmpl,
                                   int transitions,
                                   RemoteEventListener listener,
                                   MarshalledObject handback,
                                   long leaseDuration)
                            throws RemoteException
The code that does the real work of notify. Every registration is given a unique event id. The event id can thus also serve as a lease id.

Throws:
RemoteException

getEntryClassesDo

private EntryClassBase[] getEntryClassesDo(Template tmpl)
The code that does the real work of getEntryClasses. If the template is empty, then we can just use entryClasses, without having to iterate over items, but we have to work harder to get codebases.


getFieldValuesDo

private Object[] getFieldValuesDo(Template tmpl,
                                  int setidx,
                                  int fldidx)
The code that does the real work of getFieldValues. If the template is just a singleton entry with all null fields, then we can do a faster computation by iterating over keys in the given attribute's serviceByAttr map, rather than iterating over items.


getServiceTypesDo

private ServiceTypeBase[] getServiceTypesDo(Template tmpl,
                                            String prefix)
The code that does the real work of getServiceTypes. If the template has at most service types, then we can do a fast computation based solely on concrete classes, without having to iterate over items, but we have to work a bit harder to get codebases.


addAttributesDo

private void addAttributesDo(ServiceID serviceID,
                             Uuid leaseID,
                             EntryRep[] attrSets)
                      throws UnknownLeaseException
The code that does the real work of addAttributes. Add every element of attrSets to item, updating serviceByAttr as necessary, incrementing the number of EntryClass instances, and updating entryClasses as necessary.

Throws:
UnknownLeaseException

modifyAttributesDo

private void modifyAttributesDo(ServiceID serviceID,
                                Uuid leaseID,
                                EntryRep[] attrSetTmpls,
                                EntryRep[] attrSets)
                         throws UnknownLeaseException
The code that does the real work of modifyAttributes. Modify the attribute sets that match attrSetTmpls, updating or deleting based on attrSets, updating serviceByAttr as necessary, decrementing the number of EntryClass instances, and updating entryClasses as necessary.

Throws:
UnknownLeaseException

setAttributesDo

private void setAttributesDo(ServiceID serviceID,
                             Uuid leaseID,
                             EntryRep[] attrSets)
                      throws UnknownLeaseException
The code that does the real work of setAttributes. Replace all attributes of item with attrSets, updating serviceByAttr as necessary, incrementing the number of EntryClass instances, and updating entryClasses as necessary.

Throws:
UnknownLeaseException

cancelServiceLeaseDo

private void cancelServiceLeaseDo(ServiceID serviceID,
                                  Uuid leaseID)
                           throws UnknownLeaseException
The code that does the real work of cancelServiceLease.

Throws:
UnknownLeaseException

renewServiceLeaseDo

private long renewServiceLeaseDo(ServiceID serviceID,
                                 Uuid leaseID,
                                 long renewDuration)
                          throws UnknownLeaseException
The code that does the real work of renewServiceLease.

Throws:
UnknownLeaseException

renewServiceLeaseInt

private long renewServiceLeaseInt(ServiceID serviceID,
                                  Uuid leaseID,
                                  long renewDuration,
                                  long now)
                           throws UnknownLeaseException
Renew a service lease for a relative duration from now.

Throws:
UnknownLeaseException

renewServiceLeaseAbs

private void renewServiceLeaseAbs(ServiceID serviceID,
                                  Uuid leaseID,
                                  long renewExpiration)
Renew the service lease for an absolute expiration time.


cancelEventLeaseDo

private void cancelEventLeaseDo(long eventID,
                                Uuid leaseID)
                         throws UnknownLeaseException
The code that does the real work of cancelEventLease.

Throws:
UnknownLeaseException

renewEventLeaseDo

private long renewEventLeaseDo(long eventID,
                               Uuid leaseID,
                               long renewDuration)
                        throws UnknownLeaseException
The code that does the real work of renewEventLease.

Throws:
UnknownLeaseException

renewEventLeaseInt

private long renewEventLeaseInt(long eventID,
                                Uuid leaseID,
                                long renewDuration,
                                long now)
                         throws UnknownLeaseException
Throws:
UnknownLeaseException

renewEventLeaseAbs

private void renewEventLeaseAbs(long eventID,
                                Uuid leaseID,
                                long renewExpiration)
Renew the event lease for an absolute expiration time.


renewLeasesDo

private RenewResults renewLeasesDo(Object[] regIDs,
                                   Uuid[] leaseIDs,
                                   long[] renewals)
The code that does the real work of renewLeases. Each element of regIDs must either be a ServiceID (for a service lease) or a Long (for an event lease). Renewals contains durations. All three arrays must be the same length.


renewLeasesAbs

private void renewLeasesAbs(Object[] regIDs,
                            Uuid[] leaseIDs,
                            long[] renewExpirations)
Renew the leases for absolute expiration times. Skip any leases with negative expiration times.


cancelLeasesDo

private Exception[] cancelLeasesDo(Object[] regIDs,
                                   Uuid[] leaseIDs)
The code that does the real work of cancelLeases. Each element of regIDs must either be a ServiceID (for a service lease) or a Long (for an event lease). The two arrays must be the same length. If there are no exceptions, the return value is null. Otherwise, the return value has the same length as regIDs, and has nulls for leases that successfully renewed.


generateEvents

private void generateEvents(Item pre,
                            Item post,
                            long now)
Generate events for all matching event registrations. A null pre represents creation of a new item, a null post represents deletion of an item.


generateEvent

private void generateEvent(RegistrarImpl.EventReg reg,
                           Item pre,
                           Item post,
                           ServiceID sid,
                           long now)
Generate an event if the event registration matches. A null pre represents creation of a new item, a null post represents deletion of an item. sid is the serviceID of the item.


pendingEvent

private void pendingEvent(RegistrarImpl.EventReg reg,
                          ServiceID sid,
                          Item item,
                          int transition)
Add a pending EventTask for this event registration.


queueEvents

private void queueEvents()
Queue all pending EventTasks for processing by the task manager.


newServiceID

private ServiceID newServiceID()
Generate a new service ID


newLeaseID

private Uuid newLeaseID()
Generate a new lease ID


takeSnapshot

private void takeSnapshot(OutputStream out)
                   throws IOException
Write the current state of the Registrar to persistent storage.

A 'snapshot' of the Registrar's current state is represented by the data contained in certain fields of the Registrar. That data represents many changes -- over time -- to the Registrar's state. This method will record that data to a file referred to as the snapshot file.

The data written by this method to the snapshot file -- as well as the format of the file -- is shown below:

Each data item is written to the snapshot file in serialized form.

Throws:
IOException
See Also:
RegistrarImpl.LocalLogHandler

recoverSnapshot

private void recoverSnapshot(InputStream in)
                      throws IOException,
                             ClassNotFoundException
Retrieve the contents of the snapshot file and reconstitute the 'base' state of the Registrar from the retrieved data.

The data retrieved by this method from the snapshot file is shown below:

During recovery, the state of the Registrar at the time of a crash or outage is re-constructed by first reconstituting the 'base state' from the snapshot file; and then modifying that base state according to the records retrieved from the log file. This method is invoked to perform the first step in that reconstruction. As each registered service or event is retrieved, it is resolved and then inserted into its appropriate container object.

Because events can be generated before the next snapshot is taken, the event sequence numbers must be incremented. This is because the event specification requires that set of event sequence numbers be monotonically increasing. Since the number of events that might have been sent is arbitrary, each sequence number will be incremented by a 'large' number so as to guarantee adherence to the specification.

Throws:
IOException
ClassNotFoundException
See Also:
RegistrarImpl.LocalLogHandler

recoverServiceRegistrations

private void recoverServiceRegistrations(ObjectInputStream stream,
                                         int logVersion)
                                  throws IOException,
                                         ClassNotFoundException
Recovers service registrations and reggie's lookup attributes

Throws:
IOException
ClassNotFoundException

recoverEventRegistrations

private void recoverEventRegistrations(ObjectInputStream stream)
                                throws IOException,
                                       ClassNotFoundException
Recovers event registrations

Throws:
IOException
ClassNotFoundException

addLogRecord

private void addLogRecord(RegistrarImpl.LogRecord rec)
Add a state-change record to persistent storage.

Whenever a significant change occurs to the Registrar's state, this method is invoked to record that change in a file called a log file. Each record written to the log file is an object reflecting both the data used and the ACTIONS taken to make one change to the Registrar's state at a particular point in time. If the number of records contained in the log file exceeds the pre-defined threshold, a snapshot of the current state of the Registrar will be recorded.

Whenever one of the following state changes occurs, this method will be invoked with the appropriate implementation of the LogRecord interface as the input argument.

See Also:
RegistrarImpl.LocalLogHandler


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