- All Implemented Interfaces:
Serializable
AFSocketAddress
for TIPC sockets.
The TIPC socket API provides three different address types:
- Service Address.
This address type consists of a 32-bit service type identifier and a 32-bit service instance identifier.
The type identifier is typically determined and hard-coded by the user application programmer, but its value may have to be coordinated with other applications which might be present in the same cluster. The instance identifier is often calculated by the program, based on application specific criteria.
Typical invocation:
ofService(int, int)
. - Service Range.
This address type represents a range of service addresses of the same type and with instances between a lower and an upper range limit.
By binding a socket to this address type one can make it represent many instances, something which has proved useful in many cases. This address type is also used as multicast address.
Typical invocation:
ofServiceRange(int, int, int)
. - Socket Address.
This address is a reference to a specific socket in the cluster.
It contains a 32-bit port number and a 32-bit node hash number. The port number is generated by the system when the socket is created, and the node hash is generated from the corresponding node identity.
An address of this type can be used for connecting or for sending messages in the same way as service addresses can be used, but is only valid as long as the referenced socket exists.
Typical invocation:
ofSocket(int, int)
.
When binding a socket to a service address or address range, the visibility scope of the binding
must be indicated. There are two options, AFTIPCSocketAddress.Scope.SCOPE_NODE
if the user only wants node
local visibility, and AFTIPCSocketAddress.Scope.SCOPE_CLUSTER
if he wants cluster global visibility. There
are almost no limitations to how sockets can be bound to service addresses: one socket can be
bound to many addresses or ranges, and many sockets can be bound to the same address or range.
The service types 0 through 63 are however reserved for system internal use, and are not available for user space applications.
When sending a message by service address the sender may indicate a lookup domain, also called lookup scope. This is a node hash number, limiting the set of eligible destination sockets to the indicated node. If this value is zero, all matching sockets in the whole cluster, as visible from the source node, are eligible.
- Author:
- Christian Kohlschütter (documentation credits to Jon Maloy and the TIPC team).
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
The TIPC address type.static final class
The TIPC visibility scope.Nested classes/interfaces inherited from class org.newsclub.net.unix.AFSocketAddress
AFSocketAddress.AFSocketAddressConstructor<T extends AFSocketAddress>
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The lowest user-publishable name type.static final int
The "topology" service name type. -
Method Summary
Modifier and TypeMethodDescriptionstatic AFAddressFamily
<AFTIPCSocketAddress> Returns the correspondingAFAddressFamily
.getFile()
Returns theFile
corresponding with this address, if possible.getScope()
Returns the scope of this address.int
Returns the TIPC domain part of this address.int
Returns the TIPC instance part of this address.int
Returns the TIPC lower instance of this address.int
Returns the TIPC node hash of this address.int
Returns the TIPC ref of this address.int
Returns the TIPC type part of this address.int
Returns the TIPC upper instance of this address.boolean
Checks if the address can be resolved to aFile
.static boolean
Checks if anInetAddress
can be unwrapped to anAFTIPCSocketAddress
.static boolean
Checks if aSocketAddress
can be unwrapped to anAFTIPCSocketAddress
.static AFTIPCSocketAddress
Returns anAFTIPCSocketAddress
for the given URI, if possible.static AFTIPCSocketAddress
Returns anAFTIPCSocketAddress
for the given URI, if possible.static AFTIPCSocketAddress
ofService
(int type, int instance) Returns anAFTIPCSocketAddress
that refers to a given service type and instance, implicitly using cluster scope (AFTIPCSocketAddress.Scope.SCOPE_CLUSTER
).static AFTIPCSocketAddress
ofService
(int javaPort, AFTIPCSocketAddress.Scope scope, int type, int instance, int domain) Returns anAFTIPCSocketAddress
that refers to a given service type and instance, using the given scope and the given lookup domain.static AFTIPCSocketAddress
ofService
(AFTIPCSocketAddress.Scope scope, int type, int instance) Returns anAFTIPCSocketAddress
that refers to a given service type and instance, using the given scope.static AFTIPCSocketAddress
ofService
(AFTIPCSocketAddress.Scope scope, int type, int instance, int domain) Returns anAFTIPCSocketAddress
that refers to a given service type and instance, using the given scope and the given lookup domain.static AFTIPCSocketAddress
ofServiceRange
(int type, int lower, int upper) Returns anAFTIPCSocketAddress
that refers to a given service range type and instance boundaries (lower/upper values), implicitly using cluster scope (AFTIPCSocketAddress.Scope.SCOPE_CLUSTER
).static AFTIPCSocketAddress
ofServiceRange
(int javaPort, AFTIPCSocketAddress.Scope scope, int type, int lower, int upper) Returns anAFTIPCSocketAddress
that refers to a given service range type and instance boundaries (lower/upper values), implicitly using cluster scope (AFTIPCSocketAddress.Scope.SCOPE_CLUSTER
).static AFTIPCSocketAddress
ofServiceRange
(AFTIPCSocketAddress.Scope scope, int type, int lower, int upper) Returns anAFTIPCSocketAddress
that refers to a given service range type and instance boundaries (lower/upper values), using the given scope.static AFTIPCSocketAddress
ofSocket
(int ref, int node) Returns anAFTIPCSocketAddress
that refers to a given TIPC socket address (i.e., referring to a particular socket instance instead of a service address).static AFTIPCSocketAddress
ofSocket
(int javaPort, int ref, int node) Returns anAFTIPCSocketAddress
that refers to a given TIPC socket address (i.e., referring to a particular socket instance instead of a service address).static AFTIPCSocketAddress
Returns anAFTIPCSocketAddress
that refers to the topology service.toString()
Tries to create a URI based on thisAFSocketAddress
.static AFTIPCSocketAddress
Returns anAFTIPCSocketAddress
given a specialInetAddress
hostname that encodes the byte sequence of an AF_TIPC socket address, like those returned byAFSocketAddress.wrapAddress()
.static AFTIPCSocketAddress
unwrap
(InetAddress address, int port) Returns anAFTIPCSocketAddress
given a specialInetAddress
that encodes the byte sequence of an AF_TIPC socket address, like those returned byAFSocketAddress.wrapAddress()
.static AFTIPCSocketAddress
unwrap
(SocketAddress address) Returns anAFTIPCSocketAddress
given a genericSocketAddress
.Methods inherited from class org.newsclub.net.unix.AFSocketAddress
canMap, canMap, covers, getAddressFamily, getBytes, getInetAddress, getInetAddress, getInetAddress, getSocketAddress, isSupportedAddress, isUseDeserializationForInit, mapOrFail, mapOrFail, newBoundServerSocket, newConnectedSocket, newDeserializedAFSocketAddress, newForceBoundServerSocket, parseUnsignedInt, resolveAddress, toSocatAddressString, unwrap, unwrap, wrapAddress, writeNativeAddressTo
Methods inherited from class java.net.InetSocketAddress
createUnresolved, equals, getAddress, getHostName, getHostString, getPort, hashCode, isUnresolved
-
Field Details
-
TIPC_TOP_SRV
public static final int TIPC_TOP_SRVThe "topology" service name type.- See Also:
-
TIPC_RESERVED_TYPES
public static final int TIPC_RESERVED_TYPESThe lowest user-publishable name type.- See Also:
-
-
Method Details
-
ofService
public static AFTIPCSocketAddress ofService(AFTIPCSocketAddress.Scope scope, int type, int instance) throws SocketException Returns anAFTIPCSocketAddress
that refers to a given service type and instance, using the given scope.- Parameters:
scope
- The address scope.type
- The service type (0-63 are reserved).instance
- The service instance ID.- Returns:
- A corresponding
AFTIPCSocketAddress
instance. - Throws:
SocketException
- if the operation fails.
-
ofService
Returns anAFTIPCSocketAddress
that refers to a given service type and instance, implicitly using cluster scope (AFTIPCSocketAddress.Scope.SCOPE_CLUSTER
).- Parameters:
type
- The service type (0-63 are reserved).instance
- The service instance ID.- Returns:
- A corresponding
AFTIPCSocketAddress
instance. - Throws:
SocketException
- if the operation fails.
-
ofService
public static AFTIPCSocketAddress ofService(AFTIPCSocketAddress.Scope scope, int type, int instance, int domain) throws SocketException Returns anAFTIPCSocketAddress
that refers to a given service type and instance, using the given scope and the given lookup domain.- Parameters:
scope
- The address scope.type
- The service type (0-63 are reserved).instance
- The service instance ID.domain
- The lookup domain. 0 indicates cluster global lookup, otherwise a node hash, indicating that lookup should be performed only on that node- Returns:
- A corresponding
AFTIPCSocketAddress
instance. - Throws:
SocketException
- if the operation fails.
-
ofService
public static AFTIPCSocketAddress ofService(int javaPort, AFTIPCSocketAddress.Scope scope, int type, int instance, int domain) throws SocketException Returns anAFTIPCSocketAddress
that refers to a given service type and instance, using the given scope and the given lookup domain. A Java-only "IP port number" is stored along the instance for compatibility reasons.- Parameters:
javaPort
- The emulated "port" number (not part of TIPC).scope
- The address scope.type
- The service type (0-63 are reserved).instance
- The service instance ID.domain
- The lookup domain. 0 indicates cluster global lookup, otherwise a node hash, indicating that lookup should be performed only on that node- Returns:
- A corresponding
AFTIPCSocketAddress
instance. - Throws:
SocketException
- if the operation fails.
-
ofServiceRange
public static AFTIPCSocketAddress ofServiceRange(AFTIPCSocketAddress.Scope scope, int type, int lower, int upper) throws SocketException Returns anAFTIPCSocketAddress
that refers to a given service range type and instance boundaries (lower/upper values), using the given scope.- Parameters:
scope
- The address scope.type
- The service type (0-63 are reserved).lower
- Lower end of service instance ID range.upper
- Upper end of service instance ID range.- Returns:
- A corresponding
AFTIPCSocketAddress
instance. - Throws:
SocketException
- if the operation fails.
-
ofServiceRange
public static AFTIPCSocketAddress ofServiceRange(int type, int lower, int upper) throws SocketException Returns anAFTIPCSocketAddress
that refers to a given service range type and instance boundaries (lower/upper values), implicitly using cluster scope (AFTIPCSocketAddress.Scope.SCOPE_CLUSTER
).- Parameters:
type
- The service type (0-63 are reserved).lower
- Lower end of service instance ID range.upper
- Upper end of service instance ID range.- Returns:
- A corresponding
AFTIPCSocketAddress
instance. - Throws:
SocketException
- if the operation fails.
-
ofServiceRange
public static AFTIPCSocketAddress ofServiceRange(int javaPort, AFTIPCSocketAddress.Scope scope, int type, int lower, int upper) throws SocketException Returns anAFTIPCSocketAddress
that refers to a given service range type and instance boundaries (lower/upper values), implicitly using cluster scope (AFTIPCSocketAddress.Scope.SCOPE_CLUSTER
). A Java-only "IP port number" is stored along the instance for compatibility reasons.- Parameters:
javaPort
- The emulated "port" number (not part of TIPC).scope
- The address scope.type
- The service type (0-63 are reserved).lower
- Lower end of service instance ID range.upper
- Upper end of service instance ID range.- Returns:
- A corresponding
AFTIPCSocketAddress
instance. - Throws:
SocketException
- if the operation fails.
-
ofSocket
Returns anAFTIPCSocketAddress
that refers to a given TIPC socket address (i.e., referring to a particular socket instance instead of a service address).- Parameters:
ref
- 32-bit port reference ID (not to be confused with theInetSocketAddress.getPort()
port).node
- Node hash number (can be used as lookup domain withofService(Scope, int, int, int)
).- Returns:
- A corresponding
AFTIPCSocketAddress
instance. - Throws:
SocketException
- if the operation fails.
-
ofSocket
Returns anAFTIPCSocketAddress
that refers to a given TIPC socket address (i.e., referring to a particular socket instance instead of a service address). A Java-only "IP port number" is stored along the instance for compatibility reasons.- Parameters:
javaPort
- The emulated "port" number (not part of TIPC).ref
- 32-bit port reference ID (not to be confused with theInetSocketAddress.getPort()
port).node
- Node hash number (can be used as lookup domain withofService(Scope, int, int, int)
).- Returns:
- A corresponding
AFTIPCSocketAddress
instance. - Throws:
SocketException
- if the operation fails.
-
ofTopologyService
Returns anAFTIPCSocketAddress
that refers to the topology service.- Returns:
- A corresponding
AFTIPCSocketAddress
instance. - Throws:
SocketException
- if the operation fails.
-
unwrap
Returns anAFTIPCSocketAddress
given a specialInetAddress
that encodes the byte sequence of an AF_TIPC socket address, like those returned byAFSocketAddress.wrapAddress()
.- Parameters:
address
- The "special"InetAddress
.port
- The port (use 0 for "none").- Returns:
- The
AFTIPCSocketAddress
instance. - Throws:
SocketException
- if the operation fails, for example when an unsupported address is specified.
-
unwrap
Returns anAFTIPCSocketAddress
given a specialInetAddress
hostname that encodes the byte sequence of an AF_TIPC socket address, like those returned byAFSocketAddress.wrapAddress()
.- Parameters:
hostname
- The "special" hostname, as provided byInetAddress.getHostName()
.port
- The port (use 0 for "none").- Returns:
- The
AFTIPCSocketAddress
instance. - Throws:
SocketException
- if the operation fails, for example when an unsupported address is specified.
-
unwrap
Returns anAFTIPCSocketAddress
given a genericSocketAddress
.- Parameters:
address
- The address to unwrap.- Returns:
- The
AFTIPCSocketAddress
instance. - Throws:
SocketException
- if the operation fails, for example when an unsupported address is specified.
-
getScope
-
getTIPCType
public int getTIPCType()Returns the TIPC type part of this address.- Returns:
- The type identifier
-
getTIPCInstance
public int getTIPCInstance()Returns the TIPC instance part of this address.- Returns:
- The instance identifier.
-
getTIPCDomain
public int getTIPCDomain()Returns the TIPC domain part of this address.- Returns:
- The domain identifier.
-
getTIPCLower
public int getTIPCLower()Returns the TIPC lower instance of this address.- Returns:
- The lower instance identifier.
-
getTIPCUpper
public int getTIPCUpper()Returns the TIPC upper instance of this address.- Returns:
- The lower instance identifier.
-
getTIPCRef
public int getTIPCRef()Returns the TIPC ref of this address.- Returns:
- The ref identifier.
-
getTIPCNodeHash
public int getTIPCNodeHash()Returns the TIPC node hash of this address.- Returns:
- The node hash.
-
toString
- Overrides:
toString
in classInetSocketAddress
-
hasFilename
public boolean hasFilename()Description copied from class:AFSocketAddress
Checks if the address can be resolved to aFile
.- Specified by:
hasFilename
in classAFSocketAddress
- Returns:
true
if the address has a filename.
-
getFile
Description copied from class:AFSocketAddress
Returns theFile
corresponding with this address, if possible. AFileNotFoundException
is thrown if there is no filename associated with the address, which applies to addresses in the abstract namespace, for example.- Specified by:
getFile
in classAFSocketAddress
- Returns:
- The filename.
- Throws:
FileNotFoundException
- if the address is not associated with a filename.
-
isSupportedAddress
Checks if anInetAddress
can be unwrapped to anAFTIPCSocketAddress
.- Parameters:
addr
- The instance to check.- Returns:
true
if so.- See Also:
-
isSupportedAddress
Checks if aSocketAddress
can be unwrapped to anAFTIPCSocketAddress
.- Parameters:
addr
- The instance to check.- Returns:
true
if so.- See Also:
-
addressFamily
Returns the correspondingAFAddressFamily
.- Returns:
- The address family instance.
-
of
Returns anAFTIPCSocketAddress
for the given URI, if possible.- Parameters:
uri
- The URI.- Returns:
- The address.
- Throws:
SocketException
- if the operation fails.
-
of
Returns anAFTIPCSocketAddress
for the given URI, if possible.- Parameters:
uri
- The URI.overridePort
- The port to forcibly use, or-1
for "don't override".- Returns:
- The address.
- Throws:
SocketException
- if the operation fails.
-
toURI
Description copied from class:AFSocketAddress
Tries to create a URI based on thisAFSocketAddress
.- Overrides:
toURI
in classAFSocketAddress
- Parameters:
scheme
- The target scheme.template
- An optional template to reuse certain parameters (e.g., the "path" component for anhttp
request), ornull
.- Returns:
- The URI.
- Throws:
IOException
- on error.
-