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 Summary
Modifier 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 datastatic final boolean
Deprecated.This will be removed without replacement in Tomact 10 onwardsprotected byte[]
Domain if we want to filter based on domain.protected byte[]
The listen host for this memberprotected String
protected boolean
The flag indicating that this member is a local member.protected long
The number of milliseconds since this member was created, is kept track of using the start timeprotected AtomicInteger
Counter 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 int
The tcp listen port for this memberprotected int
The tcp/SSL listen port for this memberprotected long
For the local member onlyprotected static final StringManager
static final byte[]
static final byte[]
protected int
The udp listen port for this memberprotected byte[]
Unique session Id for this memberFields inherited from interface org.apache.catalina.tribes.Member
SHUTDOWN_PAYLOAD
-
Constructor Summary
ConstructorDescriptionEmpty constructor for serializationMemberImpl
(String host, int port, long aliveTime) Construct a new member object.MemberImpl
(String host, int port, long aliveTime, byte[] payload) -
Method Summary
Modifier and TypeMethodDescriptionstatic String
bToS
(byte[] data) static String
bToS
(byte[] data, int max) boolean
Returns true if the param o is a McastMember with the same namebyte[]
byte[]
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 dataint
Length of a message obtained byMember.getData(boolean)
orMember.getData(boolean, boolean)
.byte[]
byte[]
getHost()
Returns the listen host for the ChannelReceiver implementationstatic Member
getMember
(byte[] data) static Member
getMember
(byte[] data, int offset, int length) static Member
getMember
(byte[] data, int offset, int length, MemberImpl member) static Member
getMember
(byte[] data, MemberImpl member) Deserializes a member from data sent over the wire.long
Contains information on how long this member has been online.int
getName()
byte[]
int
getPort()
Returns the listen port for the ChannelReceiver implementationint
Returns the secure listen port for the ChannelReceiver implementation.long
int
Returns the UDP port that this member is listening to for UDP messages.byte[]
returns a UUID unique for this member over all sessions.int
hashCode()
protected void
inc()
Increment the message count.boolean
boolean
isLocal()
boolean
isReady()
The current state of the member.boolean
The current state of the member.void
void
setCommand
(byte[] command) Set the command associated with this member.void
setDomain
(byte[] domain) void
setHost
(byte[] host) void
setHostname
(String host) void
setLocal
(boolean local) Set if the member is local.void
setMemberAliveTime
(long time) Set the alive time in ms.void
setMsgCount
(int msgCount) void
setPayload
(byte[] payload) Set the payload associated with this member.void
setPort
(int port) void
setSecurePort
(int securePort) void
setServiceStartTime
(long serviceStartTime) void
setUdpPort
(int port) void
setUniqueId
(byte[] uniqueId) toString()
void
-
Field Details
-
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_BEGIN
public static final transient byte[] TRIBES_MBR_BEGIN -
TRIBES_MBR_END
public static final transient byte[] TRIBES_MBR_END -
sm
-
host
protected volatile byte[] hostThe listen host for this member -
hostname
-
port
protected volatile int portThe tcp listen port for this member -
udpPort
protected volatile int udpPortThe udp listen port for this member -
securePort
protected volatile int securePortThe tcp/SSL listen port for this member -
msgCount
Counter for how many broadcast messages have been sent from this member -
memberAliveTime
protected volatile long memberAliveTimeThe number of milliseconds since this member was created, is kept track of using the start time -
serviceStartTime
protected transient long serviceStartTimeFor the local member only -
dataPkg
protected transient byte[] dataPkgTo avoid serialization over and over again, once the local dataPkg has been set, we use that to transmit data -
uniqueId
protected volatile byte[] uniqueIdUnique session Id for this member -
payload
protected volatile byte[] payloadCustom payload that an app framework can broadcast Also used to transport stop command. -
command
protected volatile byte[] commandCommand, so that the custom payload doesn't have to be used This is for internal tribes use, such as SHUTDOWN_COMMAND -
domain
protected volatile byte[] domainDomain if we want to filter based on domain. -
local
protected volatile boolean localThe flag indicating that this member is a local member.
-
-
Constructor Details
-
MemberImpl
public MemberImpl()Empty constructor for serialization -
MemberImpl
Construct a new member object.- Parameters:
host
- - the tcp listen hostport
- - the tcp listen portaliveTime
- - 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
-
isReady
public boolean isReady()Description copied from interface:Member
The current state of the member. -
isSuspect
public boolean isSuspect()Description copied from interface:Member
The current state of the member. -
isFailing
public boolean isFailing() -
inc
protected void inc()Increment the message count. -
getData
public 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
-
getData
public byte[] getData(boolean getalive) Description copied from interface:Member
Highly optimized version of serializing a member into a byte array Returns a cached byte[] reference, do not modify this data -
getDataLength
public int getDataLength()Description copied from interface:Member
Length of a message obtained byMember.getData(boolean)
orMember.getData(boolean, boolean)
.- Specified by:
getDataLength
in interfaceMember
- Returns:
- the data length
-
getData
public byte[] getData(boolean getalive, boolean reset) Description copied from interface:Member
Highly optimized version of serializing a member into a byte array Returns a cached byte[] reference, do not modify this data -
getMember
Deserializes a member from data sent over the wire.- Parameters:
data
- The bytes receivedmember
- The member object to populate- Returns:
- The populated member object.
-
getMember
-
getMember
-
getMember
-
getName
-
getPort
public int getPort()Description copied from interface:Member
Returns the listen port for the ChannelReceiver implementation -
getHost
public byte[] getHost()Description copied from interface:Member
Returns the listen host for the ChannelReceiver implementation -
getHostname
-
getMsgCount
public int getMsgCount() -
getMemberAliveTime
public long getMemberAliveTime()Description copied from interface:Member
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 group.- Specified by:
getMemberAliveTime
in interfaceMember
- Returns:
- nr of milliseconds since this member started.
-
getServiceStartTime
public long getServiceStartTime() -
getUniqueId
public byte[] getUniqueId()Description copied from interface:Member
returns a UUID unique for this member over all sessions. If the member crashes and restarts, the uniqueId will be different.- Specified by:
getUniqueId
in interfaceMember
- Returns:
- byte[]
-
getPayload
public byte[] getPayload()- Specified by:
getPayload
in interfaceMember
- Returns:
- the payload associated with this member
-
getCommand
public byte[] getCommand()- Specified by:
getCommand
in interfaceMember
- Returns:
- the command associated with this member
-
getDomain
public byte[] getDomain() -
getSecurePort
public int getSecurePort()Description copied from interface:Member
Returns the secure listen port for the ChannelReceiver implementation. Returns -1 if its not listening to a secure port.- Specified by:
getSecurePort
in interfaceMember
- Returns:
- the listen port for this member, -1 if its not listening on a secure port
- See Also:
-
getUdpPort
public int getUdpPort()Description copied from interface:Member
Returns the UDP port that this member is listening to for UDP messages.- Specified by:
getUdpPort
in interfaceMember
- Returns:
- the listen UDP port for this member, -1 if its not listening on a UDP port
-
setMemberAliveTime
public void setMemberAliveTime(long time) Description copied from interface:Member
Set the alive time in ms.- Specified by:
setMemberAliveTime
in interfaceMember
- Parameters:
time
- the value to set
-
toString
-
bToS
-
bToS
-
hashCode
public int hashCode() -
equals
Returns true if the param o is a McastMember with the same name -
setHost
public void setHost(byte[] host) -
setHostname
- Throws:
IOException
-
setMsgCount
public void setMsgCount(int msgCount) -
setPort
public void setPort(int port) -
setServiceStartTime
public void setServiceStartTime(long serviceStartTime) -
setUniqueId
public void setUniqueId(byte[] uniqueId) -
setPayload
public void setPayload(byte[] payload) Description copied from interface:Member
Set the payload associated with this member.- Specified by:
setPayload
in interfaceMember
- Parameters:
payload
- the payload
-
setCommand
public void setCommand(byte[] command) Description copied from interface:Member
Set the command associated with this member.- Specified by:
setCommand
in interfaceMember
- Parameters:
command
- the command
-
setDomain
public void setDomain(byte[] domain) -
setSecurePort
public void setSecurePort(int securePort) -
setUdpPort
public void setUdpPort(int port) -
isLocal
public boolean isLocal() -
setLocal
public void setLocal(boolean local) Description copied from interface:Member
Set if the member is local. -
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-