Package fr.dyade.aaa.jndi2.distributed
Class ReplicationManager
- java.lang.Object
-
- fr.dyade.aaa.jndi2.server.RequestManager
-
- fr.dyade.aaa.jndi2.distributed.ReplicationManager
-
- All Implemented Interfaces:
UpdateListener,LifeCycleListener,Serializable
public class ReplicationManager extends RequestManager implements UpdateListener
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classReplicationManager.RequestContextList
-
Field Summary
Fields Modifier and Type Field Description static StringINIT_REQUEST_TABLEprivate HashtableinitRequestContextListsTable that contains the requests (read or write) waiting for the initialization of the context.private booleanlooseCouplingprivate AgentIdrootOwnerIdIdentifier of the server that owns the root naming context.private static longserialVersionUIDdefine serialVersionUID for interoperabilitystatic StringSERVER_LISTprivate short[]serverIdsList of the initially known servers.private VectorserversList of the JNDI servers discovered by this server.static StringSYNC_REQUEST_TABLEprivate HashtablesyncRequestContextListsTable that contains the requests (read or write) waiting for the synchronization of the context.static StringWRITE_REQUEST_TABLEprivate HashtablewriteRequestContextListsTable that contains the write requests forwarded to the owner.
-
Constructor Summary
Constructors Constructor Description ReplicationManager(short[] serverIds)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidagentInitialize(boolean firstTime)protected voidchangeOwner(ChangeOwnerRequest request)private voidcreateRemoteSubcontext(CreateRemoteSubcontextRequest request)protected voidcreateSubcontext(CreateSubcontextRequest request)(package private) voiddoReact(AgentId from, InitJndiServerNot not)(package private) voiddoReact(AgentId from, JndiUpdateNot not)Reacts to an update notification from an other JNDI server.(package private) voiddoReact(AgentId from, SyncReplyNot not)(package private) voiddoReact(AgentId from, SyncRequestNot not)(package private) voiddoReact(AgentId from, JndiReplyNot not)(package private) voiddoReact(AgentId from, JndiScriptReplyNot not)protected AgentIdgetRootOwnerId()Overrides theJndiServerbehavior.protected JndiReplyinvokeOwner(AgentId owner, RequestContext reqCtx)Overrides theJndiServerbehavior.protected JndiReplyonMissingContext(MissingContextException mce, RequestContext reqCtx)In a centralized JNDI server a missing context shows that the naming data are unconsistent.protected JndiReplyonMissingRecord(MissingRecordException mre, RequestContext reqCtx)In a centralized JNDI server a missing record shows that the name asked by the JNDI request doesn't exist.private voidonReply(AgentId from, JndiReply reply)Reacts to the reply of a JNDI server that has been called as it is the owner of a naming context.voidonUpdate(UpdateEvent event)private voidonUpdateEvent(AgentId from, BindEvent evt)private voidonUpdateEvent(AgentId from, ChangeOwnerEvent evt)private voidonUpdateEvent(AgentId from, CreateSubcontextEvent evt)private voidonUpdateEvent(AgentId from, DestroySubcontextEvent evt)private voidonUpdateEvent(AgentId from, RebindEvent evt)private voidonUpdateEvent(AgentId from, UnbindEvent evt)private voidsaveInitRequestTable()private voidsaveServers()private voidsaveSyncRequestTable()private voidsaveWriteRequestTable()private voidsynchronizeRequest(AgentId owner, RequestContext reqCtx)-
Methods inherited from class fr.dyade.aaa.jndi2.server.RequestManager
agentFinalize, getId, getServerImpl, invoke, invokeAdminRequest, invokeReadRequest, invokeWriteRequest, sendTo, setContainer
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
define serialVersionUID for interoperability- See Also:
- Constant Field Values
-
INIT_REQUEST_TABLE
public static final String INIT_REQUEST_TABLE
- See Also:
- Constant Field Values
-
SYNC_REQUEST_TABLE
public static final String SYNC_REQUEST_TABLE
- See Also:
- Constant Field Values
-
WRITE_REQUEST_TABLE
public static final String WRITE_REQUEST_TABLE
- See Also:
- Constant Field Values
-
SERVER_LIST
public static final String SERVER_LIST
- See Also:
- Constant Field Values
-
rootOwnerId
private AgentId rootOwnerId
Identifier of the server that owns the root naming context.
-
serverIds
private short[] serverIds
List of the initially known servers.
-
servers
private transient Vector servers
List of the JNDI servers discovered by this server. These servers first receive an initialization notification that contain the naming data owned by this server. Then they receive the update notifications about the contexts owned by this server.
-
writeRequestContextLists
private transient Hashtable writeRequestContextLists
Table that contains the write requests forwarded to the owner. key = owner identifier (AgentId) value = requests list (RequestContextList)
-
initRequestContextLists
private transient Hashtable initRequestContextLists
Table that contains the requests (read or write) waiting for the initialization of the context. key = id of the missing context value = requests list (RequestContextList)
-
syncRequestContextLists
private transient Hashtable syncRequestContextLists
Table that contains the requests (read or write) waiting for the synchronization of the context. key = owner identifier (AgentId) value = requests list (RequestContextList)
-
looseCoupling
private boolean looseCoupling
-
-
Method Detail
-
getRootOwnerId
protected AgentId getRootOwnerId()
Overrides theJndiServerbehavior.- Overrides:
getRootOwnerIdin classRequestManager- Returns:
- the owner id.
-
agentInitialize
public void agentInitialize(boolean firstTime) throws Exception- Specified by:
agentInitializein interfaceLifeCycleListener- Overrides:
agentInitializein classRequestManager- Throws:
Exception
-
doReact
void doReact(AgentId from, JndiUpdateNot not) throws Exception
Reacts to an update notification from an other JNDI server.- Parameters:
from- Identifier of sender.not- Notification.- Throws:
Exception- an error occurs during handling.
-
onUpdateEvent
private void onUpdateEvent(AgentId from, BindEvent evt) throws NamingException
- Throws:
NamingException
-
onUpdateEvent
private void onUpdateEvent(AgentId from, RebindEvent evt) throws NamingException
- Throws:
NamingException
-
onUpdateEvent
private void onUpdateEvent(AgentId from, UnbindEvent evt) throws NamingException
- Throws:
NamingException
-
onUpdateEvent
private void onUpdateEvent(AgentId from, CreateSubcontextEvent evt) throws NamingException
- Throws:
NamingException
-
onUpdateEvent
private void onUpdateEvent(AgentId from, DestroySubcontextEvent evt) throws NamingException
- Throws:
NamingException
-
onUpdateEvent
private void onUpdateEvent(AgentId from, ChangeOwnerEvent evt) throws NamingException
- Throws:
NamingException
-
invokeOwner
protected JndiReply invokeOwner(AgentId owner, RequestContext reqCtx)
Overrides theJndiServerbehavior. Send a JNDI request to the owner (JNDI server). Waits for the asynchronous reply.- Overrides:
invokeOwnerin classRequestManager- Parameters:
owner- the owner.reqCtx- the request.- Returns:
- the reply.
-
doReact
void doReact(AgentId from, JndiScriptReplyNot not) throws Exception
- Throws:
Exception
-
doReact
void doReact(AgentId from, JndiReplyNot not) throws Exception
- Throws:
Exception
-
onReply
private void onReply(AgentId from, JndiReply reply) throws Exception
Reacts to the reply of a JNDI server that has been called as it is the owner of a naming context.- Parameters:
from- Identifier of sender.reply- the reply.- Throws:
Exception- an error occurs.
-
doReact
void doReact(AgentId from, InitJndiServerNot not) throws Exception
- Throws:
Exception
-
onMissingContext
protected JndiReply onMissingContext(MissingContextException mce, RequestContext reqCtx)
Description copied from class:RequestManagerIn a centralized JNDI server a missing context shows that the naming data are unconsistent. So it throws an error. A subclass may override this behavior in order to try to resolve the missing context.- Overrides:
onMissingContextin classRequestManager- Parameters:
mce- the missing context exceptionreqCtx- the JNDI request context that raised the exception.- Returns:
- the JNDI reply. May be
nullif the resolution is asynchronous.
-
onMissingRecord
protected JndiReply onMissingRecord(MissingRecordException mre, RequestContext reqCtx)
Description copied from class:RequestManagerIn a centralized JNDI server a missing record shows that the name asked by the JNDI request doesn't exist. So theNameNotFoundExceptionis directly forwarded to the client. A subclass may override this behavior in order to try to resolve the missing record.- Overrides:
onMissingRecordin classRequestManager- Parameters:
mre- the missing context exceptionreqCtx- the JNDI request context that raised the exception.- Returns:
- the JNDI reply. May be
nullif the resolution is asynchronous.
-
synchronizeRequest
private void synchronizeRequest(AgentId owner, RequestContext reqCtx)
-
doReact
void doReact(AgentId from, SyncRequestNot not)
-
doReact
void doReact(AgentId from, SyncReplyNot not)
-
onUpdate
public void onUpdate(UpdateEvent event)
- Specified by:
onUpdatein interfaceUpdateListener
-
createSubcontext
protected void createSubcontext(CreateSubcontextRequest request) throws NamingException
- Overrides:
createSubcontextin classRequestManager- Throws:
NamingException
-
createRemoteSubcontext
private void createRemoteSubcontext(CreateRemoteSubcontextRequest request) throws NamingException
- Throws:
NamingException
-
changeOwner
protected void changeOwner(ChangeOwnerRequest request) throws NamingException
- Overrides:
changeOwnerin classRequestManager- Throws:
NamingException
-
saveInitRequestTable
private void saveInitRequestTable()
-
saveWriteRequestTable
private void saveWriteRequestTable()
-
saveSyncRequestTable
private void saveSyncRequestTable()
-
saveServers
private void saveServers()
-
-