public final class DataPathId extends CacheableDataType implements Comparable<DataPathId>
virtual
identifier and a MAC address.
All constructors for this class are private. Creating instances of
DataPathId is done via the static methods on the class.
Instances of this class are immutable, making them inherently thread-safe.
This class overrides equals(java.lang.Object) and hashCode() so that it plays
nicely with the Collection classes.
This class implements the Comparable interface to ensure that a
sorted list is presented in an intuitive order.
| Modifier and Type | Field and Description |
|---|---|
static int |
LENGTH_IN_BYTES
The length of a datapath id in bytes.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(DataPathId o) |
boolean |
equals(Object o) |
MacAddress |
getMacAddress()
Returns the MAC address.
|
VId |
getVid()
Returns the virtual identifier.
|
int |
hashBucket(int nBuckets)
Returns a bucket index, based on the hash code of this dpid instance
and the specified number of buckets.
|
int |
hashCode() |
String |
toAltString()
Returns an alternative string representation for this datapath ID.
|
byte[] |
toByteArray()
Returns a byte array representation of this datapath ID.
|
long |
toLong()
Returns a long value representation of this datapath ID.
|
String |
toString() |
static DataPathId |
valueOf(byte[] bytes)
Returns a datapath ID instance from the given byte array.
|
static DataPathId |
valueOf(long value)
Returns a datapath ID instance from the given long value.
|
static DataPathId |
valueOf(String spec)
Returns a datpath ID instance that encapsulates the virtual
identifier and MAC address expressed in the given string specification.
|
static DataPathId |
valueOf(VId vid,
MacAddress mac)
Returns a datapath ID instance that encapsulates the given
virtual identifier and MAC address.
|
getRefQ, keyFromBytespublic static final int LENGTH_IN_BYTES
public String toAltString()
public VId getVid()
public MacAddress getMacAddress()
public long toLong()
public byte[] toByteArray()
public int hashBucket(int nBuckets)
For N buckets, the value returned will be in the range 0 .. N-1; the value is deterministic, meaning that the same value is always returned for a specific value of N.
nBuckets - the number of bucketspublic int compareTo(DataPathId o)
compareTo in interface Comparable<DataPathId>public static DataPathId valueOf(VId vid, MacAddress mac)
vid - the virtual identifiermac - the MAC addressNullPointerException - if either parameter is nullpublic static DataPathId valueOf(String spec)
The string spec can take three basic forms:
"<virtual-id>/<mac-address>""<16-char-hex>""<colon-delim-hex>"virtual-id is an integer in the range 0..65535 (or
0x0..0xffff), mac-address is a MAC address format
accepted by MacAddress.valueOf(String), 16-char-hex is
a 16-digit hex number, and colon-delim-hex is a 16-digit hex
number with colons between each byte.
For example, the following statements all yield the same value:
DataPathId dpid = DataPathId.valueOf("123/00:05:53:AF:AA:C0");
DataPathId same = DataPathId.valueOf("0x7b/000553:afaac0");
DataPathId also = DataPathId.valueOf("007b000553AFAAC0");
DataPathId copy = DataPathId.valueOf("00:7B:00:05:53:AF:AA:C0");
spec - the string specificationNullPointerException - if spec is nullIllegalArgumentException - if spec is malformedpublic static DataPathId valueOf(byte[] bytes)
The first two bytes are interpreted as a VId, and the remaining
six bytes are interpreted as a MacAddress.
For example:
int B = 256;
byte[] bytes = new byte[] {
0, 123, // VID
0x00, 0x05, 0x53, 0xaf-B, 0xaa-B, 0xc0-B // MAC
};
DataPathId dpid = DataPathId.valueOf(bytes);
bytes - the byte arrayNullPointerException - if the byte array is nullIllegalArgumentException - if the byte array is not 8 bytes longpublic static DataPathId valueOf(long value)
value - the valueCopyright © 2014. All Rights Reserved.