Package org.jboss.util.id
Class VMID
- java.lang.Object
-
- org.jboss.util.id.VMID
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,ID
public class VMID extends java.lang.Object implements ID
An object that uniquely identifies a virtual machine.The identifier is composed of:
- The Internet address of the physical machine.
- The process identifier of the virtual machine.
- A UID to guarantee uniqness across multipule virtual machines on the same physical machine.
[ address ] - [ process id ] - [ time ] - [ counter ] |------- UID --------|
Numbers are converted to radix(Character.MAX_RADIX) when converting to strings.
- Version:
- $Revision$
- See Also:
UID
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]
address
The address of the current virtual machineprotected int
hashCode
The hash code of this VMIDprivate static VMID
instance
The single instance of VMID for the running Virtual Machineprotected PID
pid
The process identifier of the current virtual machineprivate static long
serialVersionUID
The serialVersionUIDprotected UID
uid
A unique identifier to ensure uniqueness across the host machinestatic byte[]
UNKNOWN_HOST
The address used when conventional methods fail to return the address of the current machine.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String
asString()
Returns a VMID as a string.java.lang.Object
clone()
Returns a copy of this VMID.private static VMID
create()
Create the VMID for the current virtual mahcine.boolean
equals(java.lang.Object obj)
Check if the given object is equal to this VMID.byte[]
getAddress()
Get the address portion of this VMID.private static byte[]
getHostAddress()
Return the current host internet address.static VMID
getInstance()
Get the VMID for the current virtual machine.PID
getProcessID()
Get the process identifier portion of this VMID.UID
getUID()
Get the UID portion of this VMID.int
hashCode()
Return the hash code of this VMID.java.lang.String
toString()
Return a string representation of this VMID.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
The serialVersionUID- See Also:
- Constant Field Values
-
address
protected final byte[] address
The address of the current virtual machine
-
pid
protected final PID pid
The process identifier of the current virtual machine
-
uid
protected final UID uid
A unique identifier to ensure uniqueness across the host machine
-
hashCode
protected final int hashCode
The hash code of this VMID
-
instance
private static VMID instance
The single instance of VMID for the running Virtual Machine
-
UNKNOWN_HOST
public static final byte[] UNKNOWN_HOST
The address used when conventional methods fail to return the address of the current machine.
-
-
Constructor Detail
-
VMID
protected VMID(byte[] address, PID pid, UID uid)
Construct a new VMID.- Parameters:
address
- The address of the current virtual machine.pid
- Process identifier.uid
- Unique identifier.- See Also:
For getting a VMID instance reference.
-
VMID
protected VMID(VMID vmid)
Copy a VMID.- Parameters:
vmid
- VMID to copy.
-
-
Method Detail
-
getAddress
public final byte[] getAddress()
Get the address portion of this VMID.- Returns:
- The address portion of this VMID.
-
getProcessID
public final PID getProcessID()
Get the process identifier portion of this VMID.- Returns:
- The process identifier portion of this VMID.
-
getUID
public final UID getUID()
Get the UID portion of this VMID.- Returns:
- The UID portion of this VMID.
-
toString
public java.lang.String toString()
Return a string representation of this VMID.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of this VMID.
-
hashCode
public final int hashCode()
Return the hash code of this VMID.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- The hash code of this VMID.
-
equals
public boolean equals(java.lang.Object obj)
Check if the given object is equal to this VMID.A VMID is equals to another VMID if the address, process identifer and UID portions are equal.
- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- Object to test equality with.- Returns:
- True if object is equals to this VMID.
-
clone
public java.lang.Object clone()
Returns a copy of this VMID.- Overrides:
clone
in classjava.lang.Object
- Returns:
- A copy of this VMID.
-
asString
public static java.lang.String asString()
Returns a VMID as a string.- Returns:
- VMID as a string.
-
getInstance
public static VMID getInstance()
Get the VMID for the current virtual machine.- Returns:
- Virtual machine identifier.
-
getHostAddress
private static byte[] getHostAddress()
Return the current host internet address.
-
create
private static VMID create()
Create the VMID for the current virtual mahcine.- Returns:
- Virtual machine identifer.
-
-