Class MemberImpl
- java.lang.Object
- 
- org.apache.catalina.tribes.membership.MemberImpl
 
- 
- All Implemented Interfaces:
- java.io.Externalizable,- java.io.Serializable,- Member
 - Direct Known Subclasses:
- StaticMember
 
 public class MemberImpl extends java.lang.Object implements Member, java.io.Externalizable 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:
- Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected byte[]commandCommand, so that the custom payload doesn't have to be used This is for internal tribes use, such as SHUTDOWN_COMMANDprotected byte[]dataPkgTo avoid serialization over and over again, once the local dataPkg has been set, we use that to transmit datastatic booleanDO_DNS_LOOKUPSDeprecated.This will be removed without replacement in Tomact 10 onwardsprotected byte[]domainDomain if we want to filter based on domain.protected byte[]hostThe listen host for this memberprotected java.lang.Stringhostnameprotected booleanlocalThe flag indicating that this member is a local member.protected longmemberAliveTimeThe number of milliseconds since this member was created, is kept track of using the start timeprotected java.util.concurrent.atomic.AtomicIntegermsgCountCounter for how many broadcast messages have been sent from this memberprotected byte[]payloadCustom payload that an app framework can broadcast Also used to transport stop command.protected intportThe tcp listen port for this memberprotected intsecurePortThe tcp/SSL listen port for this memberprotected longserviceStartTimeFor the local member onlyprotected static StringManagersmstatic byte[]TRIBES_MBR_BEGINstatic byte[]TRIBES_MBR_ENDprotected intudpPortThe udp listen port for this memberprotected byte[]uniqueIdUnique session Id for this member- 
Fields inherited from interface org.apache.catalina.tribes.MemberSHUTDOWN_PAYLOAD
 
- 
 - 
Constructor SummaryConstructors Constructor Description MemberImpl()Empty constructor for serializationMemberImpl(java.lang.String host, int port, long aliveTime)Construct a new member object.MemberImpl(java.lang.String host, int port, long aliveTime, byte[] payload)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.StringbToS(byte[] data)static java.lang.StringbToS(byte[] data, int max)booleanequals(java.lang.Object o)Returns true if the param o is a McastMember with the same namebyte[]getCommand()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 dataintgetDataLength()Length of a message obtained byMember.getData(boolean)orMember.getData(boolean, boolean).byte[]getDomain()Domain for this clusterbyte[]getHost()Return the TCP listen host for this memberjava.lang.StringgetHostname()static 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.longgetMemberAliveTime()Contains information on how long this member has been online.intgetMsgCount()java.lang.StringgetName()Return the name of this objectbyte[]getPayload()returns the payload associated with this memberintgetPort()Return the listen port of this memberintgetSecurePort()Returns the secure listen port for the ChannelReceiver implementation.longgetServiceStartTime()intgetUdpPort()Returns the UDP port that this member is listening to for UDP messages.byte[]getUniqueId()returns a UUID unique for this member over all sessions.inthashCode()protected voidinc()Increment the message count.booleanisFailing()booleanisLocal()booleanisReady()The current state of the memberbooleanisSuspect()The current state of the membervoidreadExternal(java.io.ObjectInput in)voidsetCommand(byte[] command)voidsetDomain(byte[] domain)voidsetHost(byte[] host)voidsetHostname(java.lang.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)java.lang.StringtoString()String representation of this objectvoidwriteExternal(java.io.ObjectOutput out)
 
- 
- 
- 
Field Detail- 
DO_DNS_LOOKUPS@Deprecated public static final boolean DO_DNS_LOOKUPS Deprecated.This will be removed without replacement in Tomact 10 onwardsShould a call to getName or getHostName try to do a DNS lookup? default is false
 - 
TRIBES_MBR_BEGINpublic static final transient byte[] TRIBES_MBR_BEGIN 
 - 
TRIBES_MBR_ENDpublic static final transient byte[] TRIBES_MBR_END 
 - 
smprotected static final StringManager sm 
 - 
hostprotected volatile byte[] host The listen host for this member
 - 
hostnameprotected transient volatile java.lang.String hostname 
 - 
portprotected volatile int port The tcp listen port for this member
 - 
udpPortprotected volatile int udpPort The udp listen port for this member
 - 
securePortprotected volatile int securePort The tcp/SSL listen port for this member
 - 
msgCountprotected java.util.concurrent.atomic.AtomicInteger msgCount Counter for how many broadcast messages have been sent from this member
 - 
memberAliveTimeprotected volatile long memberAliveTime The number of milliseconds since this member was created, is kept track of using the start time
 - 
serviceStartTimeprotected transient long serviceStartTime For the local member only
 - 
dataPkgprotected transient byte[] dataPkg To avoid serialization over and over again, once the local dataPkg has been set, we use that to transmit data
 - 
uniqueIdprotected volatile byte[] uniqueId Unique session Id for this member
 - 
payloadprotected volatile byte[] payload Custom payload that an app framework can broadcast Also used to transport stop command.
 - 
commandprotected volatile byte[] command Command, so that the custom payload doesn't have to be used This is for internal tribes use, such as SHUTDOWN_COMMAND
 - 
domainprotected volatile byte[] domain Domain if we want to filter based on domain.
 - 
localprotected volatile boolean local The flag indicating that this member is a local member.
 
- 
 - 
Constructor Detail- 
MemberImplpublic MemberImpl() Empty constructor for serialization
 - 
MemberImplpublic MemberImpl(java.lang.String host, int port, long aliveTime) throws java.io.IOExceptionConstruct 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:
- java.io.IOException- If there is an error converting the host name to an IP address
 
 - 
MemberImplpublic MemberImpl(java.lang.String host, int port, long aliveTime, byte[] payload) throws java.io.IOException- Throws:
- java.io.IOException
 
 
- 
 - 
Method Detail- 
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
 - 
getMemberpublic static Member getMember(byte[] data, MemberImpl member) Deserializes a member from data sent over the wire.- Parameters:
- data- The bytes received
- member- The member object to populate
- Returns:
- The populated member object.
 
 - 
getMemberpublic static Member getMember(byte[] data, int offset, int length, MemberImpl member) 
 - 
getMemberpublic static Member getMember(byte[] data) 
 - 
getMemberpublic static Member getMember(byte[] data, int offset, int length) 
 - 
getNamepublic java.lang.String getName() Return the name of this object
 - 
getPortpublic int getPort() Return the listen port of this member- Specified by:
- getPortin interface- Member
- Returns:
- - tcp listen port
- See Also:
- ChannelReceiver
 
 - 
getHostpublic byte[] getHost() Return the TCP listen host for this member- Specified by:
- getHostin interface- Member
- Returns:
- IP address or host name
- See Also:
- ChannelReceiver
 
 - 
getHostnamepublic java.lang.String 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:
- ChannelReceiver
 
 - 
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
 
 - 
toStringpublic java.lang.String toString() String representation of this object- Overrides:
- toStringin class- java.lang.Object
 
 - 
bToSpublic static java.lang.String bToS(byte[] data) 
 - 
bToSpublic static java.lang.String bToS(byte[] data, int max)
 - 
hashCodepublic int hashCode() - Overrides:
- hashCodein class- java.lang.Object
- Returns:
- The hash code
- See Also:
- Object.hashCode()
 
 - 
equalspublic boolean equals(java.lang.Object o) Returns true if the param o is a McastMember with the same name- Overrides:
- equalsin class- java.lang.Object
- Parameters:
- o- The object to test for equality
 
 - 
setHostpublic void setHost(byte[] host) 
 - 
setHostnamepublic void setHostname(java.lang.String host) throws java.io.IOException- Throws:
- java.io.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() 
 - 
readExternalpublic void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Specified by:
- readExternalin interface- java.io.Externalizable
- Throws:
- java.io.IOException
- java.lang.ClassNotFoundException
 
 - 
writeExternalpublic void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
- writeExternalin interface- java.io.Externalizable
- Throws:
- java.io.IOException
 
 
- 
 
-