Package org.apache.bookkeeper.net
Class BookieSocketAddress
- java.lang.Object
-
- org.apache.bookkeeper.net.BookieSocketAddress
-
public class BookieSocketAddress extends java.lang.Object
This is a data wrapper class that is an InetSocketAddress, it would use the hostname provided in constructors directly.The string representation of a BookieSocketAddress is : <hostname>:<port>
-
-
Field Summary
Fields Modifier and Type Field Description static BookieAddressResolver
LEGACY_BOOKIEID_RESOLVER
Simple converter from legacy BookieId to a real network address.
-
Constructor Summary
Constructors Constructor Description BookieSocketAddress(java.lang.String addr)
BookieSocketAddress(java.lang.String hostname, int port)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BookieId
createDummyBookieIdForHostname(java.lang.String hostname)
Utility for Placement Policies that need to create a dummy BookieId that represents a given host.boolean
equals(java.lang.Object obj)
java.lang.String
getHostName()
int
getPort()
java.net.InetSocketAddress
getSocketAddress()
int
hashCode()
static boolean
isDummyBookieIdForHostname(BookieId bookieId)
Tells whether a BookieId may be a dummy id.static BookieSocketAddress
resolveLegacyBookieId(BookieId bookieId)
Use legacy resolver to resolve a bookieId.BookieId
toBookieId()
Create a BookieID in legacy format hostname:port.java.lang.String
toString()
-
-
-
Field Detail
-
LEGACY_BOOKIEID_RESOLVER
public static final BookieAddressResolver LEGACY_BOOKIEID_RESOLVER
Simple converter from legacy BookieId to a real network address.
-
-
Method Detail
-
getHostName
public java.lang.String getHostName()
-
getPort
public int getPort()
-
getSocketAddress
public java.net.InetSocketAddress getSocketAddress()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toBookieId
public BookieId toBookieId()
Create a BookieID in legacy format hostname:port.- Returns:
- the BookieID
-
createDummyBookieIdForHostname
public static BookieId createDummyBookieIdForHostname(java.lang.String hostname)
Utility for Placement Policies that need to create a dummy BookieId that represents a given host.- Parameters:
hostname
- the hostname- Returns:
- a dummy bookie id, compatible with the BookieSocketAddress#toBookieId, with a 0 tcp port.
-
isDummyBookieIdForHostname
public static boolean isDummyBookieIdForHostname(BookieId bookieId)
Tells whether a BookieId may be a dummy id.- Parameters:
bookieId
-- Returns:
- true if the BookieId looks like it has been generated by
createDummyBookieIdForHostname(java.lang.String)
-
resolveLegacyBookieId
public static BookieSocketAddress resolveLegacyBookieId(BookieId bookieId) throws BookieAddressResolver.BookieIdNotResolvedException
Use legacy resolver to resolve a bookieId.- Parameters:
bookieId
- legacy style bookie ID consisting of address (or hostname) and port- Returns:
- the BookieSocketAddress
- Throws:
BookieAddressResolver.BookieIdNotResolvedException
-
-