Package com.hazelcast.cluster
Class Address
- java.lang.Object
-
- com.hazelcast.cluster.Address
-
- All Implemented Interfaces:
DataSerializable
,IdentifiedDataSerializable
public final class Address extends java.lang.Object implements IdentifiedDataSerializable
Represents an address of a member in the cluster.
-
-
Constructor Summary
Constructors Constructor Description Address()
Address(Address address)
Address(java.lang.String host, int port)
Address(java.lang.String hostname, java.net.InetAddress inetAddress, int port)
Address(java.net.InetAddress inetAddress, int port)
Address(java.net.InetSocketAddress inetSocketAddress)
Creates a new Address
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Address
createUnresolvedAddress(java.lang.String host, int port)
Creates an unresolved address.boolean
equals(java.lang.Object o)
int
getClassId()
Returns type identifier for this class.int
getFactoryId()
Returns DataSerializableFactory factory ID for this class.java.lang.String
getHost()
java.net.InetAddress
getInetAddress()
java.net.InetSocketAddress
getInetSocketAddress()
int
getPort()
java.lang.String
getScopedHost()
java.lang.String
getScopeId()
int
hashCode()
boolean
isIPv4()
boolean
isIPv6()
void
readData(ObjectDataInput in)
Reads fields from the input streamvoid
setScopeId(java.lang.String scopeId)
java.lang.String
toString()
void
writeData(ObjectDataOutput out)
Writes object fields to output stream
-
-
-
Constructor Detail
-
Address
public Address()
-
Address
public Address(java.lang.String host, int port) throws java.net.UnknownHostException
- Throws:
java.net.UnknownHostException
-
Address
public Address(java.net.InetAddress inetAddress, int port)
-
Address
public Address(java.net.InetSocketAddress inetSocketAddress)
Creates a new Address- Parameters:
inetSocketAddress
- the InetSocketAddress to use- Throws:
java.lang.NullPointerException
- if inetSocketAddress is nulljava.lang.IllegalArgumentException
- if the address can't be resolved.
-
Address
public Address(java.lang.String hostname, java.net.InetAddress inetAddress, int port)
-
Address
public Address(Address address)
-
-
Method Detail
-
getHost
public java.lang.String getHost()
-
getPort
public int getPort()
-
getInetAddress
public java.net.InetAddress getInetAddress() throws java.net.UnknownHostException
- Throws:
java.net.UnknownHostException
-
getInetSocketAddress
public java.net.InetSocketAddress getInetSocketAddress() throws java.net.UnknownHostException
- Throws:
java.net.UnknownHostException
-
isIPv4
public boolean isIPv4()
-
isIPv6
public boolean isIPv6()
-
getScopeId
public java.lang.String getScopeId()
-
setScopeId
public void setScopeId(java.lang.String scopeId)
-
getScopedHost
public java.lang.String getScopedHost()
-
getFactoryId
public int getFactoryId()
Description copied from interface:IdentifiedDataSerializable
Returns DataSerializableFactory factory ID for this class.- Specified by:
getFactoryId
in interfaceIdentifiedDataSerializable
- Returns:
- factory ID
-
getClassId
public int getClassId()
Description copied from interface:IdentifiedDataSerializable
Returns type identifier for this class. It should be unique per DataSerializableFactory.- Specified by:
getClassId
in interfaceIdentifiedDataSerializable
- Returns:
- type ID
-
writeData
public void writeData(ObjectDataOutput out) throws java.io.IOException
Description copied from interface:DataSerializable
Writes object fields to output stream- Specified by:
writeData
in interfaceDataSerializable
- Parameters:
out
- output- Throws:
java.io.IOException
- if an I/O error occurs. In particular, anIOException
may be thrown if the output stream has been closed.
-
readData
public void readData(ObjectDataInput in) throws java.io.IOException
Description copied from interface:DataSerializable
Reads fields from the input stream- Specified by:
readData
in interfaceDataSerializable
- Parameters:
in
- input- Throws:
java.io.IOException
- if an I/O error occurs. In particular, anIOException
may be thrown if the input stream has been closed.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
createUnresolvedAddress
@PrivateApi public static Address createUnresolvedAddress(java.lang.String host, int port)
Creates an unresolved address. This API is used by the client for the case where the hostname can not be resolved. Members achieve the same thing via Serialization where we don't resolve the hostname when Address comes as Data from another member.- Parameters:
host
- hostname or IPport
- port- Returns:
- an unresolved address
-
-