@Override public String toString() { if (valid) { return String.format("Command [name: %s, tenant-id: %s, device-id %s, request-id: %s]", getName(), getTenant(), getDeviceId(), getRequestId()); } else { return "Invalid Command"; } } }
if (delivery.remotelySettled()) { if (Accepted.class.isInstance(remoteState)) { LOG.trace("device accepted command message [command: {}]", command.getName()); logItems.put(Fields.EVENT, "device accepted command"); commandContext.getCurrentSpan().log(logItems); } else if (Rejected.class.isInstance(remoteState)) { final ErrorCondition error = ((Rejected) remoteState).getError(); LOG.debug("device rejected command message [command: {}, error: {}]", command.getName(), error); logItems.put(Fields.EVENT, "device rejected command"); commandContext.getCurrentSpan().log(logItems); commandContext.reject(error, 1); } else if (Released.class.isInstance(remoteState)) { LOG.debug("device released command message [command: {}]", command.getName()); logItems.put(Fields.EVENT, "device released command"); commandContext.getCurrentSpan().log(logItems); LOG.debug("device did not settle command message [command: {}, remote state: {}]", command.getName(), remoteState.getClass().getSimpleName()); logItems.put(Fields.EVENT, "device did not settle command");
private void setResponsePayload(final HttpServerResponse response, final CommandContext commandContext, final Span currentSpan) { if (commandContext == null) { response.setStatusCode(HttpURLConnection.HTTP_ACCEPTED); } else { final Command command = commandContext.getCommand(); response.putHeader(Constants.HEADER_COMMAND, command.getName()); currentSpan.setTag(Constants.HEADER_COMMAND, command.getName()); LOG.trace("adding command [name: {}, request-id: {}] to response for device [tenant-id: {}, device-id: {}]", command.getName(), command.getRequestId(), command.getTenant(), command.getDeviceId()); if (!command.isOneWay()) { response.putHeader(Constants.HEADER_COMMAND_REQUEST_ID, command.getRequestId()); currentSpan.setTag(Constants.HEADER_COMMAND_REQUEST_ID, command.getRequestId()); } response.setStatusCode(HttpURLConnection.HTTP_OK); HttpUtils.setResponseBody(response, command.getPayload(), command.getContentType()); } }
private void setResponsePayload(final HttpServerResponse response, final CommandContext commandContext, final Span currentSpan) { if (commandContext == null) { response.setStatusCode(HttpURLConnection.HTTP_ACCEPTED); } else { final Command command = commandContext.getCommand(); response.putHeader(Constants.HEADER_COMMAND, command.getName()); currentSpan.setTag(Constants.HEADER_COMMAND, command.getName()); LOG.trace("adding command [name: {}, request-id: {}] to response for device [tenant-id: {}, device-id: {}]", command.getName(), command.getRequestId(), command.getTenant(), command.getDeviceId()); if (!command.isOneWay()) { response.putHeader(Constants.HEADER_COMMAND_REQUEST_ID, command.getRequestId()); currentSpan.setTag(Constants.HEADER_COMMAND_REQUEST_ID, command.getRequestId()); } response.setStatusCode(HttpURLConnection.HTTP_OK); HttpUtils.setResponseBody(response, command.getPayload(), command.getContentType()); } }
TracingHelper.TAG_CORRELATION_ID.set(currentSpan, command.getCorrelationId()); items.put("reply-to", command.getCommandMessage().getReplyTo()); items.put("name", command.getName()); items.put("content-type", command.getContentType());
subscription.getRequestPart(), commandRequestId, command.getName()); endpoint.publish(topic, command.getPayload(), qos, false, false); metrics.incrementCommandDeliveredToDevice(subscription.getTenant());
subscription.getRequestPart(), commandRequestId, command.getName()); LOG.debug("Publishing command to device [tenant-id: {}, device-id: {}, MQTT client-id: {}, QoS: {}]", subscription.getTenant(), subscription.getDeviceId(), subscription.getClientId(),