Package org.eclipse.hono.util
Class CommandConstants
java.lang.Object
org.eclipse.hono.util.CommandConstants
Constants & utility methods used throughout the Command and Control API.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The name of the Command and Control API endpoint.static final String
The short name of the Command and Control endpoint.static final String
The name of the Command and Control API endpoint provided by protocol adapters that use a separate endpoint for command responses.static final String
The short name of the Command and Control API endpoint provided by protocol adapters that use a separate endpoint for command responses.static final String
The part of the address for a command response between a device and an adapter, which identifies the request.static final String
Short version of COMMAND_RESPONSE_REQUEST_PART.static final String
The part of the address for a command response between a device and an adapter, which identifies the response.static final String
Short version of COMMAND_RESPONSE_RESPONSE_PART.static final String
The content type that is defined for error command response messages sent by a protocol adapter or Command Router.static final String
The name of the internal Command and Control API endpoint provided by protocol adapters for delegating commands from one adapter to another.static final String
The name of the message property containing the identifier of a protocol adapter instance.static final String
The name of the message property containing the time (in seconds) until a device will be available for receiving an upstream (command) message (short for Time till Disconnect).static final String
The name of the northbound Command and Control API request endpoint used by northbound applications.static final String
The name of the northbound Command and Control API response endpoint used by northbound applications.static final int
Position of the request id in the MQTT command response topic.static final int
Position of the status code in the MQTT command response topic. -
Method Summary
Modifier and TypeMethodDescriptiongetK8sPodNameAndContainerIdFromAdapterInstanceId
(String adapterInstanceId) Gets the pod name and container identifier from a given adapter instance identifier that was created viagetNewAdapterInstanceIdForK8sEnv(String, String, int)
.static String
getNewAdapterInstanceId
(String adapterName, int counter) Creates a new adapter instance identifier.static String
getNewAdapterInstanceIdForK8sEnv
(String podName, String containerId, int counter) Creates a new adapter instance identifier for use in a Kubernetes environment.static String
getNewAdapterInstanceIdForNonK8sEnv
(String adapterName) Creates a new adapter instance identifier for use in a non-Kubernetes environment.static boolean
isCommandEndpoint
(String endpoint) Returnstrue
if the passed endpoint denotes a command endpoint (full or short version).static boolean
isNorthboundCommandResponseEndpoint
(String endpoint) Returnstrue
if the passed endpoint denotes a command response endpoint as used by northbound applications.
-
Field Details
-
COMMAND_ENDPOINT
The name of the Command and Control API endpoint.- See Also:
-
COMMAND_ENDPOINT_SHORT
The short name of the Command and Control endpoint.- See Also:
-
COMMAND_RESPONSE_ENDPOINT
The name of the Command and Control API endpoint provided by protocol adapters that use a separate endpoint for command responses.- See Also:
-
COMMAND_RESPONSE_ENDPOINT_SHORT
The short name of the Command and Control API endpoint provided by protocol adapters that use a separate endpoint for command responses.- See Also:
-
INTERNAL_COMMAND_ENDPOINT
The name of the internal Command and Control API endpoint provided by protocol adapters for delegating commands from one adapter to another.- See Also:
-
NORTHBOUND_COMMAND_REQUEST_ENDPOINT
The name of the northbound Command and Control API request endpoint used by northbound applications.- See Also:
-
NORTHBOUND_COMMAND_RESPONSE_ENDPOINT
The name of the northbound Command and Control API response endpoint used by northbound applications.- See Also:
-
COMMAND_RESPONSE_REQUEST_PART
The part of the address for a command response between a device and an adapter, which identifies the request.- See Also:
-
COMMAND_RESPONSE_REQUEST_PART_SHORT
Short version of COMMAND_RESPONSE_REQUEST_PART.- See Also:
-
COMMAND_RESPONSE_RESPONSE_PART
The part of the address for a command response between a device and an adapter, which identifies the response.- See Also:
-
COMMAND_RESPONSE_RESPONSE_PART_SHORT
Short version of COMMAND_RESPONSE_RESPONSE_PART.- See Also:
-
CONTENT_TYPE_DELIVERY_FAILURE_NOTIFICATION
The content type that is defined for error command response messages sent by a protocol adapter or Command Router.- See Also:
-
MSG_PROPERTY_ADAPTER_INSTANCE_ID
The name of the message property containing the identifier of a protocol adapter instance.- See Also:
-
MSG_PROPERTY_DEVICE_TTD
The name of the message property containing the time (in seconds) until a device will be available for receiving an upstream (command) message (short for Time till Disconnect).- See Also:
-
TOPIC_POSITION_RESPONSE_STATUS
public static final int TOPIC_POSITION_RESPONSE_STATUSPosition of the status code in the MQTT command response topic.command/[tenant]/[device-id]/res/<req-id>/<status>
- See Also:
-
TOPIC_POSITION_RESPONSE_REQ_ID
public static final int TOPIC_POSITION_RESPONSE_REQ_IDPosition of the request id in the MQTT command response topic.command/[tenant]/[device-id]/res/<req-id>/<status>
- See Also:
-
-
Method Details
-
isCommandEndpoint
Returnstrue
if the passed endpoint denotes a command endpoint (full or short version).- Parameters:
endpoint
- The endpoint as a string.- Returns:
true
if the endpoint is a command endpoint.
-
isNorthboundCommandResponseEndpoint
Returnstrue
if the passed endpoint denotes a command response endpoint as used by northbound applications.- Parameters:
endpoint
- The endpoint as a string.- Returns:
true
if the endpoint is a command response endpoint.
-
getNewAdapterInstanceId
Creates a new adapter instance identifier.If this method is invoked from within a docker container in a Kubernetes cluster, the format is [prefix]_[docker_container_id]_[counter], with prefix being the name of the Kubernetes pod. See also
getK8sPodNameAndContainerIdFromAdapterInstanceId(String)
.If not running in a Kubernetes cluster, a random id with the given adapter name as prefix is used.
- Parameters:
adapterName
- The adapter name.counter
- The counter value to use.- Returns:
- The new adapter instance identifier.
-
getNewAdapterInstanceIdForNonK8sEnv
Creates a new adapter instance identifier for use in a non-Kubernetes environment.The format is [adapterName]_[uuid].
- Parameters:
adapterName
- The adapter name to use.- Returns:
- The new adapter instance identifier.
-
getNewAdapterInstanceIdForK8sEnv
public static String getNewAdapterInstanceIdForK8sEnv(String podName, String containerId, int counter) Creates a new adapter instance identifier for use in a Kubernetes environment.The format is [pod_name]_[docker_container_id]_[counter].
- Parameters:
podName
- The pod name to use.containerId
- The container identifier to use.counter
- The counter value to use.- Returns:
- The new adapter instance identifier.
- Throws:
NullPointerException
- If containerId isnull
.
-
getK8sPodNameAndContainerIdFromAdapterInstanceId
public static Pair<String,String> getK8sPodNameAndContainerIdFromAdapterInstanceId(String adapterInstanceId) Gets the pod name and container identifier from a given adapter instance identifier that was created viagetNewAdapterInstanceIdForK8sEnv(String, String, int)
.- Parameters:
adapterInstanceId
- The adapter instance identifier.- Returns:
- The pod name and container identifier pair or
null
if the adapter instance identifier didn't match. - Throws:
NullPointerException
- If adapterInstanceId isnull
.
-