Package io.aeron
Class ChannelUri
java.lang.Object
io.aeron.ChannelUri
Parser for Aeron channel URIs. The format is:
aeron-uri = "aeron:" media [ "?" param *( "|" param ) ] media = *( "[^?:]" ) param = key "=" value key = *( "[^=]" ) value = *( "[^|]" )
Multiple params with the same key are allowed, the last value specified takes precedence.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringURI Scheme for Aeron channels and destinations.static final longInvalid tag value returned when callinggetTag(String)and the channel is not tagged.static final intMax length in characters for the URI string.static final StringQualifier for spy subscriptions which spy on outgoing network destined traffic efficiently. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringaddAliasIfAbsent(String uri, String alias) Add alias to the uri if none exists.static StringaddSessionId(String channel, int sessionId) Add a sessionId to a given channel.Get the channel tag, if it exists, that refers to another channel.booleancontainsKey(String key) Does the URI contain a value for the given key.static StringcreateDestinationUri(String channel, String endpoint) Create a channel URI for a destination, i.e.Get the entity tag, if it exists, that refers to an entity such as subscription or publication.booleanvoidforEachParameter(BiConsumer<String, String> consumer) Call consumer for each parameter defined in the URI.Get a value for a given parameter key.Get the value for a given parameter key or the default value provided if the key does not exist.static longGet the value of the tag from a given parameter value.booleanDetermines if this channel has specifiedcontrol-mode=response.inthashCode()voidinitialPosition(long position, int initialTermId, int termLength) Initialise a channel for restarting a publication at a given position.static booleanisControlModeResponse(String channelUri) Determines if the supplied channel has specifiedcontrol-mode=response.booleanisIpc()Is the channelmedia()equal toCommonContext.IPC_MEDIA.static booleanIs the param value tagged? (starts with the "tag:" prefix).booleanisUdp()Is the channelmedia()equal toCommonContext.UDP_MEDIA.media()The media over which the channel operates.Set the media over which the channel operates.static ChannelUriparse(CharSequence uri) Parse aCharSequencewhich contains an Aeron URI.prefix()The prefix for the channel.Change the prefix from what has been parsed.Put a key and value pair in the map of params.Remove a key pair in the map of params.voidreplaceEndpointWildcardPort(String resolvedEndpoint) Uses the supplied endpoint to resolve any wildcard ports.static StringreplacePortWithWildcard(String endpoint) Take an endpoint with the formathost:portand replace the port with a wildcard (0).scheme()The scheme for the URI.toString()Generate a String representation of the URI that is valid for an Aeron channel.static StringtransformAlias(String uri, Function<String, String> function) Transforms an alias of the given uri using the given function.
-
Field Details
-
AERON_SCHEME
URI Scheme for Aeron channels and destinations.- See Also:
-
SPY_QUALIFIER
Qualifier for spy subscriptions which spy on outgoing network destined traffic efficiently.- See Also:
-
INVALID_TAG
public static final long INVALID_TAGInvalid tag value returned when callinggetTag(String)and the channel is not tagged.- See Also:
-
MAX_URI_LENGTH
public static final int MAX_URI_LENGTHMax length in characters for the URI string.- See Also:
-
-
Method Details
-
prefix
The prefix for the channel.- Returns:
- the prefix for the channel.
-
prefix
Change the prefix from what has been parsed.- Parameters:
prefix- to replace the existing prefix.- Returns:
- this for a fluent API.
-
media
The media over which the channel operates.- Returns:
- the media over which the channel operates.
-
media
Set the media over which the channel operates.- Parameters:
media- to replace the parsed value.- Returns:
- this for a fluent API.
-
isUdp
public boolean isUdp()Is the channelmedia()equal toCommonContext.UDP_MEDIA.- Returns:
- true the channel
media()equalsCommonContext.UDP_MEDIA.
-
isIpc
public boolean isIpc()Is the channelmedia()equal toCommonContext.IPC_MEDIA.- Returns:
- true the channel
media()equalsCommonContext.IPC_MEDIA.
-
scheme
The scheme for the URI. Must be "aeron".- Returns:
- the scheme for the URI.
-
get
Get a value for a given parameter key.- Parameters:
key- to lookup.- Returns:
- the value if set for the key otherwise null.
-
get
Get the value for a given parameter key or the default value provided if the key does not exist.- Parameters:
key- to lookup.defaultValue- to be returned if no key match is found.- Returns:
- the value if set for the key otherwise the default value provided.
-
put
Put a key and value pair in the map of params.- Parameters:
key- of the param to be put.value- of the param to be put.- Returns:
- the existing value otherwise null.
-
remove
Remove a key pair in the map of params.- Parameters:
key- of the param to be removed.- Returns:
- the previous value of the param or null.
-
containsKey
Does the URI contain a value for the given key.- Parameters:
key- to be lookup.- Returns:
- true if the key has a value otherwise false.
-
channelTag
Get the channel tag, if it exists, that refers to another channel.- Returns:
- channel tag if it exists or null if not in this URI.
- See Also:
-
entityTag
Get the entity tag, if it exists, that refers to an entity such as subscription or publication.- Returns:
- entity tag if it exists or null if not in this URI.
- See Also:
-
equals
-
hashCode
public int hashCode() -
toString
Generate a String representation of the URI that is valid for an Aeron channel. -
initialPosition
public void initialPosition(long position, int initialTermId, int termLength) Initialise a channel for restarting a publication at a given position.- Parameters:
position- at which the publication should be started.initialTermId- what which the stream would start.termLength- for the stream.
-
parse
Parse aCharSequencewhich contains an Aeron URI.- Parameters:
uri- to be parsed.- Returns:
- a new
ChannelUrirepresenting the URI string.
-
addSessionId
Add a sessionId to a given channel.- Parameters:
channel- to add sessionId to.sessionId- to add to channel.- Returns:
- new string that represents channel with sessionId added.
-
addAliasIfAbsent
Add alias to the uri if none exists.- Parameters:
uri- to add alias to.alias- to add to the uri.- Returns:
- original uri if alias is empty or one is already defined, otherwise new uri with an alias.
-
transformAlias
Transforms an alias of the given uri using the given function. The function will be invoked with the original alias or null if absent. The function's return value will be used as the alias in the returned uri. If the function returns null or an empty string, the alias will be removed.- Parameters:
uri- the uri to transform the alias of.function- the transformation function.- Returns:
- uri equivalent to the one passed in with its alias transformed.
-
isTagged
Is the param value tagged? (starts with the "tag:" prefix).- Parameters:
paramValue- to check if tagged.- Returns:
- true if tagged or false if not.
- See Also:
-
getTag
Get the value of the tag from a given parameter value.- Parameters:
paramValue- to extract the tag value from.- Returns:
- the value of the tag or
INVALID_TAGif not tagged. - See Also:
-
createDestinationUri
Create a channel URI for a destination, i.e. a channel that usesmediaandinterfaceparameters of the original channel and adds specifiedendpointto it. For example given the input channel isaeron:udp?mtu=1440|ttl=0|endpoint=localhost:8090|term-length=128k|interface=eth0and the endpoint is192.168.0.14the output of this method will beaeron:udp?endpoint=192.168.0.14|interface=eth0.- Parameters:
channel- for which the destination is being added.endpoint- for the target destination.- Returns:
- new channel URI for a destination.
-
replaceEndpointWildcardPort
Uses the supplied endpoint to resolve any wildcard ports. If the existing endpoint has a value of "0" for then the port of this endpoint will be used instead. If the endpoint is not specified in this uri, then the whole supplied endpoint is used. If the endpoint exists and has a non-wildcard port, then the existing endpoint is retained.- Parameters:
resolvedEndpoint- The endpoint to supply a resolved endpoint port.- Throws:
IllegalArgumentException- if the supplied resolvedEndpoint does not have a port or the port is zero.NullPointerException- if the supplied resolvedEndpoint is null
-
forEachParameter
Call consumer for each parameter defined in the URI.- Parameters:
consumer- to be invoked for each parameter.
-
hasControlModeResponse
public boolean hasControlModeResponse()Determines if this channel has specifiedcontrol-mode=response.- Returns:
- true if this channel has specified
control-mode=response.
-
replacePortWithWildcard
Take an endpoint with the formathost:portand replace the port with a wildcard (0).- Parameters:
endpoint- to replace with a wildcard.- Returns:
- the transformed value.
-
isControlModeResponse
Determines if the supplied channel has specifiedcontrol-mode=response.- Parameters:
channelUri- to check if the control mode is response- Returns:
- true if the supplied channel has specified
control-mode=response.
-