- 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
Nested ClassesModifier and TypeClassDescriptionstatic final classThe TIPC address type.static final classThe TIPC visibility scope.Nested classes/interfaces inherited from class org.newsclub.net.unix.AFSocketAddress
AFSocketAddress.AFSocketAddressConstructor<T extends AFSocketAddress> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe lowest user-publishable name type.static final intThe "topology" service name type. -
Method Summary
Modifier and TypeMethodDescriptionstatic AFAddressFamily<AFTIPCSocketAddress> Returns the correspondingAFAddressFamily.getFile()Returns theFilecorresponding with this address, if possible.getScope()Returns the scope of this address.intReturns the TIPC domain part of this address.intReturns the TIPC instance part of this address.intReturns the TIPC lower instance of this address.intReturns the TIPC node hash of this address.intReturns the TIPC ref of this address.intReturns the TIPC type part of this address.intReturns the TIPC upper instance of this address.booleanChecks if the address can be resolved to aFile.static booleanChecks if anInetAddresscan be unwrapped to anAFTIPCSocketAddress.static booleanChecks if aSocketAddresscan be unwrapped to anAFTIPCSocketAddress.static AFTIPCSocketAddressReturns anAFTIPCSocketAddressfor the given URI, if possible.static AFTIPCSocketAddressReturns anAFTIPCSocketAddressfor the given URI, if possible.static AFTIPCSocketAddressofService(int type, int instance) Returns anAFTIPCSocketAddressthat refers to a given service type and instance, implicitly using cluster scope (AFTIPCSocketAddress.Scope.SCOPE_CLUSTER).static AFTIPCSocketAddressofService(int javaPort, AFTIPCSocketAddress.Scope scope, int type, int instance, int domain) Returns anAFTIPCSocketAddressthat refers to a given service type and instance, using the given scope and the given lookup domain.static AFTIPCSocketAddressofService(AFTIPCSocketAddress.Scope scope, int type, int instance) Returns anAFTIPCSocketAddressthat refers to a given service type and instance, using the given scope.static AFTIPCSocketAddressofService(AFTIPCSocketAddress.Scope scope, int type, int instance, int domain) Returns anAFTIPCSocketAddressthat refers to a given service type and instance, using the given scope and the given lookup domain.static AFTIPCSocketAddressofServiceRange(int type, int lower, int upper) Returns anAFTIPCSocketAddressthat refers to a given service range type and instance boundaries (lower/upper values), implicitly using cluster scope (AFTIPCSocketAddress.Scope.SCOPE_CLUSTER).static AFTIPCSocketAddressofServiceRange(int javaPort, AFTIPCSocketAddress.Scope scope, int type, int lower, int upper) Returns anAFTIPCSocketAddressthat refers to a given service range type and instance boundaries (lower/upper values), implicitly using cluster scope (AFTIPCSocketAddress.Scope.SCOPE_CLUSTER).static AFTIPCSocketAddressofServiceRange(AFTIPCSocketAddress.Scope scope, int type, int lower, int upper) Returns anAFTIPCSocketAddressthat refers to a given service range type and instance boundaries (lower/upper values), using the given scope.static AFTIPCSocketAddressofSocket(int ref, int node) Returns anAFTIPCSocketAddressthat refers to a given TIPC socket address (i.e., referring to a particular socket instance instead of a service address).static AFTIPCSocketAddressofSocket(int javaPort, int ref, int node) Returns anAFTIPCSocketAddressthat refers to a given TIPC socket address (i.e., referring to a particular socket instance instead of a service address).static AFTIPCSocketAddressReturns anAFTIPCSocketAddressthat refers to the topology service.toString()Tries to create a URI based on thisAFSocketAddress.static AFTIPCSocketAddressReturns anAFTIPCSocketAddressgiven a specialInetAddresshostname that encodes the byte sequence of an AF_TIPC socket address, like those returned byAFSocketAddress.wrapAddress().static AFTIPCSocketAddressunwrap(InetAddress address, int port) Returns anAFTIPCSocketAddressgiven a specialInetAddressthat encodes the byte sequence of an AF_TIPC socket address, like those returned byAFSocketAddress.wrapAddress().static AFTIPCSocketAddressunwrap(SocketAddress address) Returns anAFTIPCSocketAddressgiven 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, writeNativeAddressToMethods 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 anAFTIPCSocketAddressthat 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
AFTIPCSocketAddressinstance. - Throws:
SocketException- if the operation fails.
-
ofService
Returns anAFTIPCSocketAddressthat 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
AFTIPCSocketAddressinstance. - Throws:
SocketException- if the operation fails.
-
ofService
public static AFTIPCSocketAddress ofService(AFTIPCSocketAddress.Scope scope, int type, int instance, int domain) throws SocketException Returns anAFTIPCSocketAddressthat 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
AFTIPCSocketAddressinstance. - 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 anAFTIPCSocketAddressthat 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
AFTIPCSocketAddressinstance. - Throws:
SocketException- if the operation fails.
-
ofServiceRange
public static AFTIPCSocketAddress ofServiceRange(AFTIPCSocketAddress.Scope scope, int type, int lower, int upper) throws SocketException Returns anAFTIPCSocketAddressthat 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
AFTIPCSocketAddressinstance. - Throws:
SocketException- if the operation fails.
-
ofServiceRange
public static AFTIPCSocketAddress ofServiceRange(int type, int lower, int upper) throws SocketException Returns anAFTIPCSocketAddressthat 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
AFTIPCSocketAddressinstance. - 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 anAFTIPCSocketAddressthat 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
AFTIPCSocketAddressinstance. - Throws:
SocketException- if the operation fails.
-
ofSocket
Returns anAFTIPCSocketAddressthat 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
AFTIPCSocketAddressinstance. - Throws:
SocketException- if the operation fails.
-
ofSocket
Returns anAFTIPCSocketAddressthat 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
AFTIPCSocketAddressinstance. - Throws:
SocketException- if the operation fails.
-
ofTopologyService
Returns anAFTIPCSocketAddressthat refers to the topology service.- Returns:
- A corresponding
AFTIPCSocketAddressinstance. - Throws:
SocketException- if the operation fails.
-
unwrap
Returns anAFTIPCSocketAddressgiven a specialInetAddressthat 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
AFTIPCSocketAddressinstance. - Throws:
SocketException- if the operation fails, for example when an unsupported address is specified.
-
unwrap
Returns anAFTIPCSocketAddressgiven a specialInetAddresshostname 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
AFTIPCSocketAddressinstance. - Throws:
SocketException- if the operation fails, for example when an unsupported address is specified.
-
unwrap
Returns anAFTIPCSocketAddressgiven a genericSocketAddress.- Parameters:
address- The address to unwrap.- Returns:
- The
AFTIPCSocketAddressinstance. - 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:
toStringin classInetSocketAddress
-
hasFilename
public boolean hasFilename()Description copied from class:AFSocketAddressChecks if the address can be resolved to aFile.- Specified by:
hasFilenamein classAFSocketAddress- Returns:
trueif the address has a filename.
-
getFile
Description copied from class:AFSocketAddressReturns theFilecorresponding with this address, if possible. AFileNotFoundExceptionis thrown if there is no filename associated with the address, which applies to addresses in the abstract namespace, for example.- Specified by:
getFilein classAFSocketAddress- Returns:
- The filename.
- Throws:
FileNotFoundException- if the address is not associated with a filename.
-
isSupportedAddress
Checks if anInetAddresscan be unwrapped to anAFTIPCSocketAddress.- Parameters:
addr- The instance to check.- Returns:
trueif so.- See Also:
-
isSupportedAddress
Checks if aSocketAddresscan be unwrapped to anAFTIPCSocketAddress.- Parameters:
addr- The instance to check.- Returns:
trueif so.- See Also:
-
addressFamily
Returns the correspondingAFAddressFamily.- Returns:
- The address family instance.
-
of
Returns anAFTIPCSocketAddressfor the given URI, if possible.- Parameters:
uri- The URI.- Returns:
- The address.
- Throws:
SocketException- if the operation fails.
-
of
Returns anAFTIPCSocketAddressfor the given URI, if possible.- Parameters:
uri- The URI.overridePort- The port to forcibly use, or-1for "don't override".- Returns:
- The address.
- Throws:
SocketException- if the operation fails.
-
toURI
Description copied from class:AFSocketAddressTries to create a URI based on thisAFSocketAddress.- Overrides:
toURIin classAFSocketAddress- Parameters:
scheme- The target scheme.template- An optional template to reuse certain parameters (e.g., the "path" component for anhttprequest), ornull.- Returns:
- The URI.
- Throws:
IOException- on error.
-