Class HubServerProp
- All Implemented Interfaces:
EventListener, IGProp<GProp<?>[]>, IPropCnr, Cloneable
HUB-DESIGN.md sections 3.2 to 3.4, built by B-7b): one instance per member connection, the only child of the member's $device container, created by the member client (HubMemberClient) and mirrored on the principal by the property factory, which instantiates it because it is registered in base-properties.xml as hubServer.Events are remote events, dispatched on getLocalID() (section 3.4): the principal opens every connection with REMOTE_CHALLENGE (ruled LV-12 (a)), the member answers with REMOTE_REGISTER and is admitted or refused (section 2.4). A request carries the request id P_REQUEST and its reply goes back on the same local id carrying the id, with P_OK and the result members or P_REASON, the way the License System replies. Each id has one direction: the principal sends CHALLENGE and 20 to 23, the member sends 1 to 10, 40 to 49 are reserved for D-PUSH-CLUSTER in both; so on each side an incoming event on an id this side sends is a reply and everything else is a request, handed to the HubServerProp.IHubEventHandler the owner set.
Pending requests (section 3.2, the pattern of PushChannelProps): a table keyed by an id from a per-connection counter never reused, each entry with a deadline; a reply with an unknown id is logged at INFO and dropped; at disposal every pending entry is logged at INFO and dropped.
Epoch (sections 3.4, 4.5): every event the principal sends carries P_EPOCH; the member drops, and logs at WARNING, an event whose epoch is lower than the highest it has seen. The principal's epoch is set by B-7c's election; until then it is 0.
Threads. A reply or a request arrives on the connection's thread (the end point's worker on the principal, the client's worker on the member) and a deadline on the timer's: the listener and the handler are called there, at once.
Public properties only (section 3.3): a payload travels as ordinary properties, a credential as a ByteArrayProp; nothing here is serialized by Java.
- Author:
- Christopher Mindus
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe handler of the requests the peer sends: called ONCE per request, on the connection's thread.static interfaceThe listener of a request's outcome: called ONCE, on the connection's thread for a reply and on the timer's thread for a deadline.static enumThe side of the channel an instance is on.Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AtomThe atom of the channel under$device.static final StringThe atom name of the channel under the member's$devicecontainer: "hub".static final intThe number of random bytes of a challenge: 32 (section 2.2).static final StringTheREGISTERmember "apps": the application IDs the member serves, joined with,.static final StringTheREGISTERmember "build":SystemConfig.VERSION_BUILD.static final StringTheREGISTERmember "cred": the credential, aByteArrayProp.static final StringTheREGISTERmember "db": theHUB.CLUSTERUUID, or empty (section 2.3).static final StringTheREGISTERmember "def": the SHA-256 of the member's definition file as read.static final StringThe epoch member "epoch" on every event the principal sends: a long.static final StringTheREGISTERmember "keys": the fingerprint of the member's ACTIVE server keys file key, compared by the principal asP_DEFis (ruled RB-6 (a)); empty when the member has none yet.static final StringTheREGISTERmember "member": the member ID.static final StringTheMEMBERSmember "members": the container of members, one child container per member named by its member ID, each withP_URL,P_STATE,P_RTTandP_RTT_MEMBER.static final StringThe reply's success member "ok": a boolean.static final StringTheCHALLENGEmember "pn": the 32 random bytes, aByteArrayProp.static final StringThe reply's reason member "reason" on a refusal: one of theREASON_constants.static final StringThe request id member "r": an int from the per-connection counter, on every request and its reply.static final StringTheREPORTandMEMBERSmember "rtt": a link round-trip time in milliseconds, a long; -1 when not measured yet.static final StringTheMEMBERSmember "rttm": the round-trip time the member itself measured and reported, in milliseconds, a long; -1 when not reported yet.static final StringTheREGISTERmember "run": the run UUID generated at process start, to tell a restart from a reconnect.static final StringTheREGISTERmember "staged": the fingerprints of the server keys the member holds STAGED by the rotation protocol of RB-6 (locked, not yet used to encrypt), joined with,; empty until that protocol exists.static final StringTheMEMBERSmember "state": a member's state,admitted.static final StringTheREGISTERandMEMBERSmember "url": a member's public base URL.static final StringThe reply members "warnings": what the principal warns about at admission, joined with,(deffor a differing definition,keysfor differing server keys); absent when nothing.static final StringTheREGISTERmember "w": the hub wire version, an int.static final StringRefused "auth": the credential does not verify as the answer to this connection's challenge.static final StringRefused "build": the build differs from the principal's (ruled R-18 (a)); the member runs standalone and retries.static final StringRefused "internal": the principal could not process the request.static final StringRefused "licence": the member's document names another entitlement than the principal's (from B-9, ruled LV-13 (a)).static final StringRefused "servers": admitting the member would exceed the licence's server count (R-6).static final StringRefused "timeout": the principal did not answer within the deadline.static final StringRefused "unknown-member": the member ID is not in the principal's[members](ruled H-6).static final StringRefused "wire": the wire version differs from the principal's.static final longHow long the principal waits forREGISTERafter the WebSocket opened, in milliseconds: 10000L (section 13).static final intPrincipal to member 0:CHALLENGE, sent when the connection opens, withP_PN: 32 random bytes fresh for this connection (ruled LV-12 (a), section 2.2).static final intMember to principal 4:CLAIM(B-7d).static final intPrincipal to member 22:INVALIDATE_USER, withuid(B-7d).static final intMember to principal 10:LOGIN(B-9).static final intMember to principal 6:LOOKUP(B-8a).static final intPrincipal to member 21:MEMBERS, the member list with state and link RTT (P_MEMBERS); nothing replies.static final intPrincipal to member 23:NOT_PRINCIPAL, naming the principal it knows; the connection closes (B-7c).static final intstatic final intThe first and last of the ids reserved for D-PUSH-CLUSTER, in both directions: 40 to 49.static final intThe first and last of the ids reserved for D-PUSH-CLUSTER, in both directions: 40 to 49.static final intstatic final intMember to principal 5:RELEASE(B-7d).static final intMember to principal 2:REPORT, withP_RTT: the member's measure of the link, in milliseconds (section 3.5).static final intMember to principal 3:SESSIONS(B-7d).static final intA to principal to B 7:TRANSFER(B-8a).static final intB to principal to A 8:TRANSFER_DONE(B-8a).static final intMember to principal 9:USER_CHANGED(B-7d).static final longThe deadline of an ordinary request, in milliseconds: 10000L (section 13).static final intThe hub wire version this build speaks: 1 (section 2.4,P_WIRE).Fields inherited from class PropCnr
EMPTY, EMPTY_CLASSES, EMPTY_CNRS, EXTENDS_FRAMEWORK_ERROR_IDFields inherited from class GProp
GPDEBUG, PROP_ATTR_STRING_EDITOR_PROP, PROP_ATTR_STRING_ERRORED_NAME, PROP_ATTR_STRING_EXTENDS, PROP_ATTR_STRING_EXTENDS_FINAL, PROP_ATTR_STRING_EXTENDS_PRIVATE, PROP_ATTR_STRING_NULLABLE, PROP_ATTR_STRING_PRIVATE, PROP_ATTR_STRING_PRIVATE_CHANGE_EVENT, PROP_ATTR_STRING_READ_ONLY, PROP_ATTR_STRING_SECRET, PROP_USER_1, PROP_USER_2Fields inherited from interface IGProp
EQC_ERROR_IGNORE_ALL, EQC_ERROR_IGNORE_REFERENCES, EQC_IGNORE_ARRAY, EQC_IGNORE_VOLATILE_OR_EDITOR, EQC_INCLUDE_PRIVATE, EQC_SAVE_FILE, EQC_SAVE_RELEVANT_ONLY, EXT_CONTAINER_EXTENDS, EXT_CONTAINER_EXTENDS_VALID, EXT_EXTENDED, EXT_FINAL, EXT_OVERRIDES, EXT_OVERRIDES_FINAL_ERR, EXT_PRIVATEConstructor Summary
ConstructorsConstructorDescriptionCreates the channel without a name.HubServerProp(Atom atom) Creates the channel with a name.Method Summary
Modifier and TypeMethodDescriptionclone()Clones the channel: the pending table is not cloned.longgetEpoch()Gets the epoch the principal stamps on every event it sends.longGets the highest epoch a member has seen from the principal.intGets the number of requests waiting for the peer, for diagnostics and tests.getRole()Gets the role.static booleanisMemberToPrincipal(int localID) Tells whether an event id is one the member sends.static booleanisPrincipalToMember(int localID) Tells whether an event id is one the principal sends.static HubServerPropFinds the channel of a member connection.protected voidDrops every pending request at disposal, logged at INFO.voidonRemoteEvent(RemoteEvent event) Dispatches an event of the peer: a reply on an id this side sends resolves its pending request; anything else is a request for the handler.booleanReplies to a request of the peer on the same local id, carrying its request id back.intrequest(int localID, String operation, PropCnr params, long deadlineMillis, HubServerProp.IReplyListener listener) Sends a request to the peer and registers its outcome listener and deadline.booleanSends an event to the peer that expects no reply, the principal stamping its epoch on it.voidsetEpoch(long epoch) Sets the epoch the principal stamps on every event it sends (B-7c's election sets it).voidsetRole(HubServerProp.Role role, HubServerProp.IHubEventHandler handler) Sets the side this instance is on and the handler of the peer's requests.voidsetTimerEngine(ITimerEngine engine) Sets the timer engine the deadlines are registered with.protected booleanshouldSerializeToXML(int programType) The channel is never written to XML.Methods inherited from class PropCnr
__transferChildProps, addPredefinedProps, addProp, addProp, addProp2, addProp2, appendPropValue, canRequestFocus, completeVirtualize, containsProp, containsProp, convertLoadedProp, couldRequestFocusIfVirtualized, createCopyOfAtom, createUniqueAtom, createUniqueAtom, createUniqueAtom, createVSReference, doPropEqualsArrayValues, enablePropCommunication, enablePropHashMap, equalsTree, equalsTree, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getAllProps, getBool, getBool, getBool, getBool, getChildPropError, getChildPropError, getChildPropErrorSeverity, getChildPropErrorSeverity, getErrorsProp, getExtendsContainer, getExtendsError, getExtendsName, getExtendsOverride, getExtendsPossibleClasses, getFirstProp, getFirstProp, getFocusEngine, getInt, getInt, getInt, getInt, getLong, getLong, getLong, getLong, getNumber, getNumber, getNumber, getNumber, getPossibleChildren, getPredefinedProps, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getProp, getPropBaseReference, getPropCnr, getPropCount, getPropCount, getPropIndex, getPropIndex, getPropIndexes, getProps, getProps, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue, getPropValue0, getRetargetedVerifyContainer, getString, getString, getString, getString, getValueClasses, getVSReference, hasFocus, hasSendData, initializeElement, initializeExtendsFramework, initializeProp, initializePropTree, initializeValue, initPropCnr, insertProp, insertProp2, isChild, isExtendsOverriden, isExtendsPropertyValid, isExtendsRoot, isPropAddRemoveAllowed, isPropCommunicating, isPropExtended, isPropValueTreeLockNeeded, list, list, logPropNotFound, maybeAddProp, onInsertProp, onPropRemoved, onPropTreeInitialized, onReferenceEvent, onVirtualContainerCreated, onVirtualizationCompleted, paramString, prepare, removeAllProps, removeAllProps2, removeProp, removeProp, removeProp, removeProp, removeProp, removeProp, removeProp, removeProp2, removeProp2, removeProp2, removeProp2, removeProp2, removeProp2, removeProp2, reorderProps, replaceProps, requestFocus, requestFocus, requestFocusEx, requestFocusEx, resolveReferences, resolveRuntimeReferences, setBool, setBool, setBool, setBool, setCreateRequiredProp, setExtendsName, setExtendsOverride, setInt, setInt, setInt, setLong, setLong, setLong, setLong, setNumber, setNumber, setNumber, setNumber, setProp, setProp, setProp, setProp2, setProp2, setPropValue, setPropValue, setPropValue, setPropValue, setPropValue, setPropValue, setString, setString, setString, setString, shouldCreateProps, shouldSerializeToXML, toElementString, toNativeValue0, usePropHashMap, usesPropIndex, validateChildPropInValue, validateClassInstances, validatePropType, validatePropValue, verify, verifyInternalUseOnly, verifyTree, virtualizeMethods inherited from class GProp
addPropError, addPropListener, appendProp, convertPropError, dispose, equals, equals, equalsErrors, equalsObj, equalsPropValue, equalValues, finalize, fine, fine, finer, finer, finest, finest, fromElementString, getAliasName, getAppSessionGyro, getAppWorker, getAtomPath, getAttribute, getChildReferencePropName, getClientSessionGyro, getClientWorker, getConstraints, getEnvironment, getErroredPropItems, getErroredProps, getErrorsProp, getExtendsRootContainer, getFullPropName, getFullPropName, getFullPropNameDebug, getFullPropNameDebug, getListeners, getModuleFolder, getModuleFolder, getParent, getParent, getProjectName, getPropAtom, getPropError, getPropError, getPropErroredName, getPropErrorSeverity, getPropExtendsFlags, getPropFromPath, getPropFromPath, getPropFromReference, getPropFromReference, getPropIndex, getPropName, getPropPath, getPropPath, getPropReferenceTarget, getPropRootPropMgr, getPropTreeErrorSeverity, getPropValue, getPropValue, getPropValueObject, getReferencePropName, getReferencePropNameNoAssert, getRelativePropName, getRootFromName, getRootName, getRootParent, getRootParentNoAssert, getTreeLock, hasChanged, hasCircularReferencesError, hashCode, hasPrivateChangeEventProp, hasPropError, hasPropTreeError, info, info, initializeGElement, initializeGProp, isDisposed, isPropChildOf, isPropClientCreated, isPropCreateRequired, isPropErrorPersisted, isPropExtended, isPropExtendsFinal, isPropExtendsPrivate, isPropExtendsPrivateInRoot, isPropExtendsPrivateInRoot, isPropFile, isPropFolder, isPropForEditor, isPropForEditorAtCreation, isPropNullable, isPropPrivate, isPropPrivateAtCreation, isPropReadOnly, isPropReferenceTreeValid, isPropRoot, isPropRootLoading, isPropRootTreeModificationsAllowed, isPropSaveRelevant, isPropSecret, isPropSecretCapable, isPropUSER, isPropVirtualized, isPropVirtualizing, isPropVolatile, isPropVolatileOrEditorOnly, isProxied, isSibling, list, list, list, mapAliasToReference, mapAliasToReference, mapReferenceToAlias, mapReferenceToAlias, mapReferenceToProjectRelative, modifyPropValue, moveProp, moveProp, moveProp, onEvent, onEventSelf, onInitialize, onPrepare, onPropInvalidateCache, onPropParentChanged, onPropValueSet, paramString, paramValue, post, post, removePropError, removePropListener, removePropUSER, renameProp, renameProp2, resetChangedTree, setChanged, setConstraints, setConstraints, setParent, setPrivateChangeEventProp, setPrivateCreateRequiredProp, setPropError, setPropErroredName, setPropExtended, setPropExtendsFinal, setPropExtendsPrivate, setPropForEditor, setPropNullable, setPropPrivate, setPropReadOnly, setPropSecret, setPropUSER, setPropValue, setPropValue, setPropValue, setPropValueIncognito, setPropVolatile, severe, severe, severe, throwIfReadOnly, toNativeValue, toShortString, toShortString, toString, toString, triggerRemoteEvent, triggerRemoteEvent, validateProp, warning, warning, warningMethods inherited from interface IGProp
addPropError, addPropListener, dispose, equals, fine, fine, finer, finer, finest, finest, fromElementString, getAppSessionGyro, getAtomPath, getClientSessionGyro, getConstraints, getEnvironment, getErroredPropItems, getErroredProps, getErrorsProp, getExtendsRootContainer, getFullPropName, getFullPropNameDebug, getModuleFolder, getModuleFolder, getParent, getParent, getPropAtom, getPropError, getPropError, getPropErrorSeverity, getPropExtendsFlags, getPropFromPath, getPropFromReference, getPropIndex, getPropName, getPropPath, getPropPath, getPropRootPropMgr, getPropTreeErrorSeverity, getPropValue, getPropValue, getReferencePropName, getRelativePropName, getRootParent, getTreeLock, hasChanged, hasCircularReferencesError, hasPrivateChangeEventProp, hasPropError, hasPropTreeError, info, info, initializeGElement, initializeGProp, isDisposed, isPropChildOf, isPropClientCreated, isPropCreateRequired, isPropExtended, isPropExtendsFinal, isPropExtendsPrivate, isPropExtendsPrivateInRoot, isPropExtendsPrivateInRoot, isPropFile, isPropFolder, isPropNullable, isPropPrivate, isPropReadOnly, isPropReferenceTreeValid, isPropRoot, isPropVirtualized, isSibling, list, list, list, mapAliasToReference, mapReferenceToAlias, mapReferenceToProjectRelative, moveProp, moveProp, moveProp, onEvent, onEventSelf, removePropError, removePropListener, renameProp, setChanged, setConstraints, setConstraints, setParent, setPrivateChangeEventProp, setPropError, setPropExtendsFinal, setPropExtendsPrivate, setPropNullable, setPropPrivate, setPropReadOnly, setPropValue, setPropValue, severe, severe, severe, toNativeValue, triggerRemoteEvent, triggerRemoteEvent, validateProp, warning, warning, warningMethods inherited from interface IPropCnr
canRequestFocus, canRequestFocus, couldRequestFocusIfVirtualized, couldRequestFocusIfVirtualized
Field Details
ATOM_NAME
The atom name of the channel under the member's$devicecontainer: "hub".- See Also:
ATOM
The atom of the channel under$device.WIRE_VERSION
public static final int WIRE_VERSIONThe hub wire version this build speaks: 1 (section 2.4,P_WIRE).- See Also:
CHALLENGE_BYTES
public static final int CHALLENGE_BYTESThe number of random bytes of a challenge: 32 (section 2.2).- See Also:
REGISTER_DEADLINE_MILLIS
public static final long REGISTER_DEADLINE_MILLISHow long the principal waits forREGISTERafter the WebSocket opened, in milliseconds: 10000L (section 13).- See Also:
REQUEST_DEADLINE_MILLIS
public static final long REQUEST_DEADLINE_MILLISThe deadline of an ordinary request, in milliseconds: 10000L (section 13).- See Also:
REMOTE_CHALLENGE
public static final int REMOTE_CHALLENGEPrincipal to member 0:CHALLENGE, sent when the connection opens, withP_PN: 32 random bytes fresh for this connection (ruled LV-12 (a), section 2.2). Nothing replies; the member'sREGISTERanswers it.- See Also:
REMOTE_PRINCIPAL
REMOTE_MEMBERS
public static final int REMOTE_MEMBERSPrincipal to member 21:MEMBERS, the member list with state and link RTT (P_MEMBERS); nothing replies.- See Also:
REMOTE_INVALIDATE_USER
public static final int REMOTE_INVALIDATE_USERPrincipal to member 22:INVALIDATE_USER, withuid(B-7d).- See Also:
REMOTE_NOT_PRINCIPAL
public static final int REMOTE_NOT_PRINCIPALPrincipal to member 23:NOT_PRINCIPAL, naming the principal it knows; the connection closes (B-7c).- See Also:
REMOTE_REGISTER
REMOTE_REPORT
public static final int REMOTE_REPORTMember to principal 2:REPORT, withP_RTT: the member's measure of the link, in milliseconds (section 3.5). The counts per application of R-19 join it when B-6a's counters and B-7d's directory exist. Nothing replies.- See Also:
REMOTE_SESSIONS
public static final int REMOTE_SESSIONSMember to principal 3:SESSIONS(B-7d).- See Also:
REMOTE_CLAIM
public static final int REMOTE_CLAIMMember to principal 4:CLAIM(B-7d).- See Also:
REMOTE_RELEASE
public static final int REMOTE_RELEASEMember to principal 5:RELEASE(B-7d).- See Also:
REMOTE_LOOKUP
public static final int REMOTE_LOOKUPMember to principal 6:LOOKUP(B-8a).- See Also:
REMOTE_TRANSFER
public static final int REMOTE_TRANSFERA to principal to B 7:TRANSFER(B-8a).- See Also:
REMOTE_TRANSFER_DONE
public static final int REMOTE_TRANSFER_DONEB to principal to A 8:TRANSFER_DONE(B-8a).- See Also:
REMOTE_USER_CHANGED
public static final int REMOTE_USER_CHANGEDMember to principal 9:USER_CHANGED(B-7d).- See Also:
REMOTE_LOGIN
public static final int REMOTE_LOGINMember to principal 10:LOGIN(B-9).- See Also:
REMOTE_PUSH_FIRST
public static final int REMOTE_PUSH_FIRSTThe first and last of the ids reserved for D-PUSH-CLUSTER, in both directions: 40 to 49.- See Also:
REMOTE_PUSH_LAST
public static final int REMOTE_PUSH_LASTThe first and last of the ids reserved for D-PUSH-CLUSTER, in both directions: 40 to 49.- See Also:
P_REQUEST
The request id member "r": an int from the per-connection counter, on every request and its reply.- See Also:
P_OK
P_REASON
The reply's reason member "reason" on a refusal: one of theREASON_constants.- See Also:
P_EPOCH
The epoch member "epoch" on every event the principal sends: a long.- See Also:
P_PN
TheCHALLENGEmember "pn": the 32 random bytes, aByteArrayProp.- See Also:
P_WIRE
P_MEMBER
P_RUN
TheREGISTERmember "run": the run UUID generated at process start, to tell a restart from a reconnect.- See Also:
P_BUILD
P_DEF
TheREGISTERmember "def": the SHA-256 of the member's definition file as read.- See Also:
P_DB
TheREGISTERmember "db": theHUB.CLUSTERUUID, or empty (section 2.3).- See Also:
P_URL
TheREGISTERandMEMBERSmember "url": a member's public base URL.- See Also:
P_APPS
TheREGISTERmember "apps": the application IDs the member serves, joined with,.- See Also:
P_CRED
TheREGISTERmember "cred": the credential, aByteArrayProp. Until B-9 the interim cluster key's HMAC over the challenge (HubClusterKey, ruled H-8); from B-9 the member's document and its installation key's signature.- See Also:
P_KEYS
P_STAGED
TheREGISTERmember "staged": the fingerprints of the server keys the member holds STAGED by the rotation protocol of RB-6 (locked, not yet used to encrypt), joined with,; empty until that protocol exists. Reported, never compared.- See Also:
P_RTT
TheREPORTandMEMBERSmember "rtt": a link round-trip time in milliseconds, a long; -1 when not measured yet.- See Also:
P_RTT_MEMBER
TheMEMBERSmember "rttm": the round-trip time the member itself measured and reported, in milliseconds, a long; -1 when not reported yet.- See Also:
P_MEMBERS
TheMEMBERSmember "members": the container of members, one child container per member named by its member ID, each withP_URL,P_STATE,P_RTTandP_RTT_MEMBER.- See Also:
P_STATE
P_WARNINGS
The reply members "warnings": what the principal warns about at admission, joined with,(deffor a differing definition,keysfor differing server keys); absent when nothing.- See Also:
REASON_WIRE
Refused "wire": the wire version differs from the principal's.- See Also:
REASON_AUTH
Refused "auth": the credential does not verify as the answer to this connection's challenge.- See Also:
REASON_LICENCE
Refused "licence": the member's document names another entitlement than the principal's (from B-9, ruled LV-13 (a)).- See Also:
REASON_UNKNOWN_MEMBER
Refused "unknown-member": the member ID is not in the principal's[members](ruled H-6).- See Also:
REASON_BUILD
Refused "build": the build differs from the principal's (ruled R-18 (a)); the member runs standalone and retries.- See Also:
REASON_SERVERS
Refused "servers": admitting the member would exceed the licence's server count (R-6).- See Also:
REASON_TIMEOUT
Refused "timeout": the principal did not answer within the deadline.- See Also:
REASON_INTERNAL
Refused "internal": the principal could not process the request.- See Also:
Constructor Details
HubServerProp
public HubServerProp()Creates the channel without a name.HubServerProp
Method Details
clone
Clones the channel: the pending table is not cloned.shouldSerializeToXML
protected boolean shouldSerializeToXML(int programType) The channel is never written to XML.- Overrides:
shouldSerializeToXMLin classGProp<GProp<?>[]>- Parameters:
programType- FromPropFactory.getProgramType().- Returns:
- false.
of
Finds the channel of a member connection.- Parameters:
device- The member's$devicecontainer, or null.- Returns:
- The channel, or null when the container holds none: not a member of the hub.
setRole
Sets the side this instance is on and the handler of the peer's requests.- Parameters:
role- The role.handler- The handler, or null for none.
getRole
setTimerEngine
Sets the timer engine the deadlines are registered with.- Parameters:
engine- The engine, or null for the system's.
setEpoch
public void setEpoch(long epoch) Sets the epoch the principal stamps on every event it sends (B-7c's election sets it).- Parameters:
epoch- The epoch.
getEpoch
public long getEpoch()Gets the epoch the principal stamps on every event it sends.- Returns:
- The epoch, 0 before an election.
getHighestEpoch
public long getHighestEpoch()Gets the highest epoch a member has seen from the principal.- Returns:
- The epoch, -1 before the first event.
isPrincipalToMember
public static boolean isPrincipalToMember(int localID) Tells whether an event id is one the principal sends.- Parameters:
localID- The id.- Returns:
- true for
CHALLENGEand 20 to 23.
isMemberToPrincipal
public static boolean isMemberToPrincipal(int localID) Tells whether an event id is one the member sends.- Parameters:
localID- The id.- Returns:
- true for 1 to 10.
getPendingCount
public int getPendingCount()Gets the number of requests waiting for the peer, for diagnostics and tests.- Returns:
- The count.
request
public int request(int localID, String operation, PropCnr params, long deadlineMillis, HubServerProp.IReplyListener listener) Sends a request to the peer and registers its outcome listener and deadline.- Parameters:
localID- The event id.operation- The operation, e.g.REGISTER, for the log lines.params- The parameters, or null for none but the request id, which is added.deadlineMillis- The deadline in milliseconds from now.listener- The outcome listener, called once.- Returns:
- The request id.
- Throws:
IllegalStateException- If the channel is disposed of.NullPointerException- Ifoperationorlisteneris null.
reply
Replies to a request of the peer on the same local id, carrying its request id back.- Parameters:
localID- The event id of the request.request- The request's parameters, whoseP_REQUESTis carried back; null or without one, the reply carries none.ok- true for success, false for a refusal.reason- The reason of a refusal, ignored whenok.params- The reply's result members, or null for none: a container is created.- Returns:
- true when sent, false when the channel is disposed of.
send
Sends an event to the peer that expects no reply, the principal stamping its epoch on it.- Parameters:
localID- The event id.params- The parameters, or null for none: a container is created.- Returns:
- true when sent, false when the channel is disposed of.
onRemoteEvent
Dispatches an event of the peer: a reply on an id this side sends resolves its pending request; anything else is a request for the handler.- Specified by:
onRemoteEventin interfaceIGProp<GProp<?>[]>- Overrides:
onRemoteEventin classGProp<GProp<?>[]>- Parameters:
event- The remote event.
onPropDispose
protected void onPropDispose()Drops every pending request at disposal, logged at INFO.- Overrides:
onPropDisposein classPropCnr