class JoinStateManager extends LogHandler
JoinStateManager provides a utility that manages
a service's join state (optionally persisting that state) and
manages the join protocol protocol on behalf of the service.ServiceIDListener,
LogHandler| Modifier and Type | Field and Description |
|---|---|
private Entry[] |
attributes
The join state, this data needs to be persisted between restarts
|
private DiscoveryManagement |
dm
Object used to find lookups.
|
private String[] |
groups |
private boolean |
initial
Conceptually, true if this is the first time this
service has come up, implemented as if there was
no previous state then this is the first time.
|
private static Logger |
initlogger
Logger for logging initialization related messages
|
private LookupLocator[] |
locators |
private ReliableLog |
log
The object coordinating our persistent state.
|
private ProxyPreparer |
lookupLocatorPreparer
ProxyPreparer for LookupLocators |
private JoinManager |
mgr
JoinManager that is handling the details of binding
into Jini lookup services. |
private static Logger |
operationsLogger
Logger for logging operations related messages
|
private static Logger |
persistenceLogger
Logger for transaction persistence related messages
|
private Uuid |
serviceUuid
Service's internal
Uuid which needs to be persisted |
| Constructor and Description |
|---|
JoinStateManager(String logPath)
Simple constructor.
|
| Modifier and Type | Method and Description |
|---|---|
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 |
applyUpdate(Object update)
This method always throws
UnsupportedOperationException since
FileJoinAdminState should never update a
log. |
void |
destroy() |
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.
|
Uuid |
getServiceUuid() |
void |
modifyLookupAttributes(Entry[] attrSetTemplates,
Entry[] attrSets)
Modify the current attribute sets, using the same semantics as
ServiceRegistration.modifyAttributes.
|
private void |
prepareLocators(LookupLocator[] locators)
Apply
lookupLocatorPreparer to each locator in the
array, replacing the original locator with the result of the
prepareProxy call. |
private static Entry[] |
readAttributes(ObjectInput in)
Utility method to read in an array of entities from a
ObjectInputStream. |
(package private) void |
recover() |
void |
recover(InputStream in)
Read the snapshot from a stream.
|
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 |
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 |
setServiceUuid(Uuid serviceUuid) |
void |
snapshot(OutputStream out)
Writes the snapshot to a stream.
|
(package private) void |
startManager(Configuration config,
Object service,
ServiceID serviceID,
Entry[] baseAttributes)
Start the manager.
|
void |
stop()
Make a good faith attempt to terminate
discovery, and cancel any lookup registrations.
|
private void |
update() |
private static void |
writeAttributes(Entry[] attributes,
ObjectOutput out)
Utility method to write out an array of entities to an
ObjectOutputStream. |
readUpdate, writeUpdateprivate static final Logger initlogger
private static final Logger operationsLogger
private static final Logger persistenceLogger
private volatile ProxyPreparer lookupLocatorPreparer
ProxyPreparer for LookupLocatorsprivate volatile DiscoveryManagement dm
private volatile JoinManager mgr
JoinManager that is handling the details of binding
into Jini lookup services.private volatile ReliableLog log
private volatile Entry[] attributes
private volatile LookupLocator[] locators
private volatile String[] groups
private volatile Uuid serviceUuid
Uuid which needs to be persistedprivate volatile boolean initial
JoinStateManager(String logPath) throws IOException
IOExceptionvoid recover()
throws IOException
IOExceptionvoid startManager(Configuration config, Object service, ServiceID serviceID, Entry[] baseAttributes) throws IOException, ConfigurationException
config - object to use to obtain
DiscoveryManagement object, and if
this is the initial incarnation of this service,
the object used to get the initial set of groups,
locators, and deployer defined attributes.service - The proxy object to register with lookups.baseAttributes - Any attributes the implementation wants
attached, only used if this is the
initial incarnation.IOException - if the is problem persisting the
initial state or in starting discovery.ConfigurationException - if the configuration
is invalid.public void setServiceUuid(Uuid serviceUuid)
public Uuid getServiceUuid()
public void stop()
public void destroy()
public Entry[] getLookupAttributes()
public void addLookupAttributes(Entry[] attrSets)
attrSets - the attribute sets to addjava.rmi.RuntimeException - if the change can not be persisted.public void modifyLookupAttributes(Entry[] attrSetTemplates, Entry[] attrSets)
attrSetTemplates - the templates for matching attribute setsattrSets - the modifications to make to matching setsjava.rmi.RuntimeException - if the change can not be persisted.ServiceRegistration.modifyAttributes(net.jini.core.entry.Entry[], net.jini.core.entry.Entry[])public String[] getLookupGroups()
setLookupGroups(java.lang.String[])public void addLookupGroups(String[] groups)
groups - groups to joinjava.rmi.RuntimeException - if the change can not be persisted.removeLookupGroups(java.lang.String[])public void removeLookupGroups(String[] groups)
groups - groups to leavejava.rmi.RuntimeException - if the change can not be persisted.addLookupGroups(java.lang.String[])public void setLookupGroups(String[] groups)
groups - groups to joinjava.rmi.RuntimeException - if the change can not be persisted.getLookupGroups()public LookupLocator[] getLookupLocators()
setLookupLocators(net.jini.core.discovery.LookupLocator[])public void addLookupLocators(LookupLocator[] locators) throws RemoteException
locators - locators of specific lookup services to joinjava.rmi.RuntimeException - if the change can not be persisted.RemoteExceptionremoveLookupLocators(net.jini.core.discovery.LookupLocator[])public void removeLookupLocators(LookupLocator[] locators) throws RemoteException
locators - locators of specific lookup services to leavejava.rmi.RuntimeException - if the change can not be persisted.RemoteExceptionaddLookupLocators(net.jini.core.discovery.LookupLocator[])public void setLookupLocators(LookupLocator[] locators) throws RemoteException
locators - locators of specific lookup services to joinjava.rmi.RuntimeException - if the change can not be persisted.RemoteExceptiongetLookupLocators()private void prepareLocators(LookupLocator[] locators) throws RemoteException
lookupLocatorPreparer to each locator in the
array, replacing the original locator with the result of the
prepareProxy call. If call fails with an exception
throw that exception.locators - the LookupLocators to be prepared.RemoteException - if preparation of any of the locators
does.SecurityException - if preparation of any of the locators
does.private void update()
private static void writeAttributes(Entry[] attributes, ObjectOutput out) throws IOException
ObjectOutputStream. Can be recovered by a call
to readAttributes()
Packages each attribute in its own MarshalledObject so
a bad codebase on an attribute class will not corrupt the whole array.
IOExceptionprivate static Entry[] readAttributes(ObjectInput in) throws IOException, ClassNotFoundException
ObjectInputStream. Array should have been written
by a call to writeAttributes()
Will try and recover as many attributes as possible. Attributes which can't be recovered won't be returned but they will remain in the log.
IOExceptionClassNotFoundExceptionpublic void snapshot(OutputStream out) throws IOException
LogHandlersnapshot in class LogHandlerout - the output streamIOExceptionpublic void recover(InputStream in) throws Exception
LogHandlerrecover in class LogHandlerin - the input streamException - can raise any exceptionpublic void applyUpdate(Object update) throws Exception
UnsupportedOperationException since
FileJoinAdminState should never update a
log.applyUpdate in class LogHandlerupdate - the update objectException - can raise any exceptionCopyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.