Class MemberImpl
java.lang.Object
org.apache.catalina.tribes.membership.MemberImpl
- All Implemented Interfaces:
- Externalizable,- Serializable,- Member
- Direct Known Subclasses:
- StaticMember
A membership implementation using simple multicast.
 This is the representation of a multicast member.
 Carries the host, and port of the this or other cluster nodes.
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected byte[]Command, so that the custom payload doesn't have to be used This is for internal tribes use, such as SHUTDOWN_COMMANDprotected byte[]To avoid serialization over and over again, once the local dataPkg has been set, we use that to transmit dataprotected byte[]Domain if we want to filter based on domain.protected byte[]The listen host for this memberprotected Stringprotected booleanThe flag indicating that this member is a local member.protected longThe number of milliseconds since this member was created, is kept track of using the start timeprotected AtomicIntegerCounter for how many broadcast messages have been sent from this memberprotected byte[]Custom payload that an app framework can broadcast Also used to transport stop command.protected intThe tcp listen port for this memberprotected intThe tcp/SSL listen port for this memberprotected longFor the local member onlyprotected static final StringManagerstatic final byte[]static final byte[]protected intThe udp listen port for this memberprotected byte[]Unique session Id for this memberFields inherited from interface org.apache.catalina.tribes.MemberSHUTDOWN_PAYLOAD
- 
Constructor SummaryConstructorsConstructorDescriptionEmpty constructor for serializationMemberImpl(String host, int port, long aliveTime) Construct a new member object.MemberImpl(String host, int port, long aliveTime, byte[] payload) 
- 
Method SummaryModifier and TypeMethodDescriptionstatic StringbToS(byte[] data) static StringbToS(byte[] data, int max) booleanReturns true if the param o is a McastMember with the same namebyte[]returns the command associated with this memberbyte[]getData()Create a data package to send over the wire representing this member.byte[]getData(boolean getalive) Highly optimized version of serializing a member into a byte array Returns a cached byte[] reference, do not modify this databyte[]getData(boolean getalive, boolean reset) Highly optimized version of serializing a member into a byte array Returns a cached byte[] reference, do not modify this dataintLength of a message obtained byMember.getData(boolean)orMember.getData(boolean, boolean).byte[]Domain for this clusterbyte[]getHost()Return the TCP listen host for this memberstatic MembergetMember(byte[] data) static MembergetMember(byte[] data, int offset, int length) static MembergetMember(byte[] data, int offset, int length, MemberImpl member) static MembergetMember(byte[] data, MemberImpl member) Deserializes a member from data sent over the wire.longContains information on how long this member has been online.intgetName()Return the name of this objectbyte[]returns the payload associated with this memberintgetPort()Return the listen port of this memberintReturns the secure listen port for the ChannelReceiver implementation.longintReturns the UDP port that this member is listening to for UDP messages.byte[]returns a UUID unique for this member over all sessions.inthashCode()protected voidinc()Increment the message count.booleanbooleanisLocal()booleanisReady()The current state of the memberbooleanThe current state of the membervoidvoidsetCommand(byte[] command) voidsetDomain(byte[] domain) voidsetHost(byte[] host) voidsetHostname(String host) voidsetLocal(boolean local) voidsetMemberAliveTime(long time) voidsetMsgCount(int msgCount) voidsetPayload(byte[] payload) voidsetPort(int port) voidsetSecurePort(int securePort) voidsetServiceStartTime(long serviceStartTime) voidsetUdpPort(int port) voidsetUniqueId(byte[] uniqueId) toString()String representation of this objectvoid
- 
Field Details- 
TRIBES_MBR_BEGINpublic static final transient byte[] TRIBES_MBR_BEGIN
- 
TRIBES_MBR_ENDpublic static final transient byte[] TRIBES_MBR_END
- 
sm
- 
hostprotected volatile byte[] hostThe listen host for this member
- 
hostname
- 
portprotected volatile int portThe tcp listen port for this member
- 
udpPortprotected volatile int udpPortThe udp listen port for this member
- 
securePortprotected volatile int securePortThe tcp/SSL listen port for this member
- 
msgCountCounter for how many broadcast messages have been sent from this member
- 
memberAliveTimeprotected volatile long memberAliveTimeThe number of milliseconds since this member was created, is kept track of using the start time
- 
serviceStartTimeprotected transient long serviceStartTimeFor the local member only
- 
dataPkgprotected transient byte[] dataPkgTo avoid serialization over and over again, once the local dataPkg has been set, we use that to transmit data
- 
uniqueIdprotected volatile byte[] uniqueIdUnique session Id for this member
- 
payloadprotected volatile byte[] payloadCustom payload that an app framework can broadcast Also used to transport stop command.
- 
commandprotected volatile byte[] commandCommand, so that the custom payload doesn't have to be used This is for internal tribes use, such as SHUTDOWN_COMMAND
- 
domainprotected volatile byte[] domainDomain if we want to filter based on domain.
- 
localprotected volatile boolean localThe flag indicating that this member is a local member.
 
- 
- 
Constructor Details- 
MemberImplpublic MemberImpl()Empty constructor for serialization
- 
MemberImplConstruct a new member object.- Parameters:
- host- - the tcp listen host
- port- - the tcp listen port
- aliveTime- - the number of milliseconds since this member was created
- Throws:
- IOException- If there is an error converting the host name to an IP address
 
- 
MemberImpl- Throws:
- IOException
 
 
- 
- 
Method Details- 
isReadypublic boolean isReady()Description copied from interface:MemberThe current state of the member
- 
isSuspectpublic boolean isSuspect()Description copied from interface:MemberThe current state of the member
- 
isFailingpublic boolean isFailing()
- 
incprotected void inc()Increment the message count.
- 
getDatapublic byte[] getData()Create a data package to send over the wire representing this member. This is faster than serialization.- Returns:
- - the bytes for this member deserialized
 
- 
getDatapublic byte[] getData(boolean getalive) Description copied from interface:MemberHighly optimized version of serializing a member into a byte array Returns a cached byte[] reference, do not modify this data
- 
getDataLengthpublic int getDataLength()Description copied from interface:MemberLength of a message obtained byMember.getData(boolean)orMember.getData(boolean, boolean).- Specified by:
- getDataLengthin interface- Member
- Returns:
- the data length
 
- 
getDatapublic byte[] getData(boolean getalive, boolean reset) Description copied from interface:MemberHighly optimized version of serializing a member into a byte array Returns a cached byte[] reference, do not modify this data
- 
getMemberDeserializes a member from data sent over the wire.- Parameters:
- data- The bytes received
- member- The member object to populate
- Returns:
- The populated member object.
 
- 
getMember
- 
getMember
- 
getMember
- 
getNameReturn the name of this object
- 
getPortpublic int getPort()Return the listen port of this member
- 
getHostpublic byte[] getHost()Return the TCP listen host for this member
- 
getHostname
- 
getMsgCountpublic int getMsgCount()
- 
getMemberAliveTimepublic long getMemberAliveTime()Contains information on how long this member has been online. The result is the number of milli seconds this member has been broadcasting its membership to the cluster.- Specified by:
- getMemberAliveTimein interface- Member
- Returns:
- nr of milliseconds since this member started.
 
- 
getServiceStartTimepublic long getServiceStartTime()
- 
getUniqueIdpublic byte[] getUniqueId()Description copied from interface:Memberreturns a UUID unique for this member over all sessions. If the member crashes and restarts, the uniqueId will be different.- Specified by:
- getUniqueIdin interface- Member
- Returns:
- byte[]
 
- 
getPayloadpublic byte[] getPayload()Description copied from interface:Memberreturns the payload associated with this member- Specified by:
- getPayloadin interface- Member
- Returns:
- byte[]
 
- 
getCommandpublic byte[] getCommand()Description copied from interface:Memberreturns the command associated with this member- Specified by:
- getCommandin interface- Member
- Returns:
- byte[]
 
- 
getDomainpublic byte[] getDomain()Description copied from interface:MemberDomain for this cluster
- 
getSecurePortpublic int getSecurePort()Description copied from interface:MemberReturns the secure listen port for the ChannelReceiver implementation. Returns -1 if its not listening to a secure port.- Specified by:
- getSecurePortin interface- Member
- Returns:
- the listen port for this member, -1 if its not listening on a secure port
- See Also:
 
- 
getUdpPortpublic int getUdpPort()Description copied from interface:MemberReturns the UDP port that this member is listening to for UDP messages.- Specified by:
- getUdpPortin interface- Member
- Returns:
- the listen UDP port for this member, -1 if its not listening on a UDP port
 
- 
setMemberAliveTimepublic void setMemberAliveTime(long time) - Specified by:
- setMemberAliveTimein interface- Member
 
- 
toStringString representation of this object
- 
bToS
- 
bToS
- 
hashCodepublic int hashCode()
- 
equalsReturns true if the param o is a McastMember with the same name
- 
setHostpublic void setHost(byte[] host) 
- 
setHostname- Throws:
- IOException
 
- 
setMsgCountpublic void setMsgCount(int msgCount) 
- 
setPortpublic void setPort(int port) 
- 
setServiceStartTimepublic void setServiceStartTime(long serviceStartTime) 
- 
setUniqueIdpublic void setUniqueId(byte[] uniqueId) 
- 
setPayloadpublic void setPayload(byte[] payload) - Specified by:
- setPayloadin interface- Member
 
- 
setCommandpublic void setCommand(byte[] command) - Specified by:
- setCommandin interface- Member
 
- 
setDomainpublic void setDomain(byte[] domain) 
- 
setSecurePortpublic void setSecurePort(int securePort) 
- 
setUdpPortpublic void setUdpPort(int port) 
- 
isLocalpublic boolean isLocal()
- 
setLocalpublic void setLocal(boolean local) 
- 
readExternal- Specified by:
- readExternalin interface- Externalizable
- Throws:
- IOException
- ClassNotFoundException
 
- 
writeExternal- Specified by:
- writeExternalin interface- Externalizable
- Throws:
- IOException
 
 
-