Search in sources :

Example 1 with CommandConsumer

use of org.eclipse.hono.client.command.CommandConsumer in project hono by eclipse.

the class AbstractVertxBasedHttpProtocolAdapterTest method testUploadTelemetryWithTtdClosesCommandConsumerIfSendingFails.

/**
 * Verifies that the adapter closes the command consumer created as part of
 * handling a request with a TTD parameter if sending of the telemetry
 * message fails.
 */
@Test
public void testUploadTelemetryWithTtdClosesCommandConsumerIfSendingFails() {
    // GIVEN an adapter
    givenAnAdapter(properties);
    // with the downstream telemetry sender unable to forward messages
    final Promise<Void> sendResult = Promise.promise();
    sendResult.fail(new ServerErrorException(HttpURLConnection.HTTP_UNAVAILABLE));
    givenATelemetrySenderForAnyTenant(sendResult);
    // WHEN a device publishes a telemetry message with a TTD
    final Buffer payload = Buffer.buffer("some payload");
    final HttpServerResponse response = mock(HttpServerResponse.class);
    final HttpServerRequest request = mock(HttpServerRequest.class);
    when(request.getHeader(eq(Constants.HEADER_TIME_TILL_DISCONNECT))).thenReturn("10");
    final HttpContext ctx = newHttpContext(payload, "text/plain", request, response);
    when(ctx.getRoutingContext().addBodyEndHandler(VertxMockSupport.anyHandler())).thenAnswer(invocation -> {
        final Handler<Void> handler = invocation.getArgument(0);
        handler.handle(null);
        return 0;
    });
    // and the creation of the command consumer completes at a later point
    final Promise<CommandConsumer> commandConsumerPromise = Promise.promise();
    when(commandConsumerFactory.createCommandConsumer(anyString(), anyString(), VertxMockSupport.anyHandler(), any(), any())).thenReturn(commandConsumerPromise.future());
    adapter.uploadTelemetryMessage(ctx, "tenant", "device");
    commandConsumerPromise.complete(commandConsumer);
    // THEN the request fails immediately
    verify(ctx.getRoutingContext()).fail(any());
    // the message has been reported
    verify(metrics).reportTelemetry(eq(EndpointType.TELEMETRY), eq("tenant"), any(), eq(ProcessingOutcome.UNDELIVERABLE), eq(MetricsTags.QoS.AT_MOST_ONCE), eq(payload.length()), eq(TtdStatus.NONE), any());
    // and the command consumer is closed
    verify(commandConsumer).close(any());
}
Also used : Buffer(io.vertx.core.buffer.Buffer) HttpServerResponse(io.vertx.core.http.HttpServerResponse) HttpServerRequest(io.vertx.core.http.HttpServerRequest) HttpContext(org.eclipse.hono.service.http.HttpContext) CommandConsumer(org.eclipse.hono.client.command.CommandConsumer) ServerErrorException(org.eclipse.hono.client.ServerErrorException) Test(org.junit.jupiter.api.Test)

Example 2 with CommandConsumer

use of org.eclipse.hono.client.command.CommandConsumer in project hono by eclipse.

the class AbstractVertxBasedHttpProtocolAdapter method doUploadMessage.

private void doUploadMessage(final HttpContext ctx, final String tenant, final String deviceId, final Buffer payload, final String contentType, final MetricsTags.EndpointType endpoint) {
    if (!ctx.hasValidQoS()) {
        HttpUtils.badRequest(ctx.getRoutingContext(), "unsupported QoS-Level header value");
        return;
    }
    if (!isPayloadOfIndicatedType(payload, contentType)) {
        HttpUtils.badRequest(ctx.getRoutingContext(), String.format("content type [%s] does not match payload", contentType));
        return;
    }
    final MetricsTags.QoS qos = getQoSLevel(endpoint, ctx.getRequestedQos());
    final Device authenticatedDevice = ctx.getAuthenticatedDevice();
    final String gatewayId = authenticatedDevice != null && !deviceId.equals(authenticatedDevice.getDeviceId()) ? authenticatedDevice.getDeviceId() : null;
    final Span currentSpan = TracingHelper.buildChildSpan(tracer, TracingHandler.serverSpanContext(ctx.getRoutingContext()), "upload " + endpoint.getCanonicalName(), getTypeName()).withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT).withTag(TracingHelper.TAG_TENANT_ID, tenant).withTag(TracingHelper.TAG_DEVICE_ID, deviceId).withTag(TracingHelper.TAG_AUTHENTICATED.getKey(), authenticatedDevice != null).withTag(TracingHelper.TAG_QOS, qos.name()).start();
    final Promise<Void> responseReady = Promise.promise();
    final Future<RegistrationAssertion> tokenTracker = getRegistrationAssertion(tenant, deviceId, authenticatedDevice, currentSpan.context());
    final int payloadSize = Optional.ofNullable(payload).map(ok -> payload.length()).orElse(0);
    final Future<TenantObject> tenantTracker = getTenantConfiguration(tenant, currentSpan.context());
    final Future<TenantObject> tenantValidationTracker = tenantTracker.compose(tenantObject -> CompositeFuture.all(isAdapterEnabled(tenantObject), checkMessageLimit(tenantObject, payloadSize, currentSpan.context())).map(success -> tenantObject));
    // we only need to consider TTD if the device and tenant are enabled and the adapter
    // is enabled for the tenant
    final Future<Integer> ttdTracker = CompositeFuture.all(tenantValidationTracker, tokenTracker).compose(ok -> {
        final Integer ttdParam = getTimeUntilDisconnectFromRequest(ctx);
        return getTimeUntilDisconnect(tenantTracker.result(), ttdParam).map(effectiveTtd -> {
            if (effectiveTtd != null) {
                currentSpan.setTag(MessageHelper.APP_PROPERTY_DEVICE_TTD, effectiveTtd);
            }
            return effectiveTtd;
        });
    });
    final Future<CommandConsumer> commandConsumerTracker = ttdTracker.compose(ttd -> createCommandConsumer(ttd, tenantTracker.result(), deviceId, gatewayId, ctx.getRoutingContext(), responseReady, currentSpan));
    commandConsumerTracker.compose(ok -> {
        final Map<String, Object> props = getDownstreamMessageProperties(ctx);
        Optional.ofNullable(commandConsumerTracker.result()).map(c -> ttdTracker.result()).ifPresent(ttd -> props.put(MessageHelper.APP_PROPERTY_DEVICE_TTD, ttd));
        props.put(MessageHelper.APP_PROPERTY_QOS, ctx.getRequestedQos().ordinal());
        customizeDownstreamMessageProperties(props, ctx);
        setTtdRequestConnectionCloseHandler(ctx.getRoutingContext(), commandConsumerTracker.result(), tenant, deviceId, currentSpan);
        if (EndpointType.EVENT.equals(endpoint)) {
            ctx.getTimeToLive().ifPresent(ttl -> props.put(MessageHelper.SYS_HEADER_PROPERTY_TTL, ttl.toSeconds()));
            return CompositeFuture.all(getEventSender(tenantValidationTracker.result()).sendEvent(tenantTracker.result(), tokenTracker.result(), contentType, payload, props, currentSpan.context()), responseReady.future()).map(s -> (Void) null);
        } else {
            // unsettled
            return CompositeFuture.all(getTelemetrySender(tenantValidationTracker.result()).sendTelemetry(tenantTracker.result(), tokenTracker.result(), ctx.getRequestedQos(), contentType, payload, props, currentSpan.context()), responseReady.future()).map(s -> (Void) null);
        }
    }).compose(proceed -> {
        // request and the CommandConsumer from the current request has not been closed yet
        return Optional.ofNullable(commandConsumerTracker.result()).map(consumer -> consumer.close(currentSpan.context()).otherwise(thr -> {
            TracingHelper.logError(currentSpan, thr);
            return (Void) null;
        })).orElseGet(Future::succeededFuture);
    }).map(proceed -> {
        if (ctx.response().closed()) {
            log.debug("failed to send http response for [{}] message from device [tenantId: {}, deviceId: {}]: response already closed", endpoint, tenant, deviceId);
            TracingHelper.logError(currentSpan, "failed to send HTTP response to device: response already closed");
            currentSpan.finish();
            // close the response here, ensuring that the TracingHandler bodyEndHandler gets called
            ctx.response().end();
        } else {
            final CommandContext commandContext = ctx.get(CommandContext.KEY_COMMAND_CONTEXT);
            setResponsePayload(ctx.response(), commandContext, currentSpan);
            ctx.getRoutingContext().addBodyEndHandler(ok -> {
                log.trace("successfully processed [{}] message for device [tenantId: {}, deviceId: {}]", endpoint, tenant, deviceId);
                if (commandContext != null) {
                    commandContext.getTracingSpan().log("forwarded command to device in HTTP response body");
                    commandContext.accept();
                    metrics.reportCommand(commandContext.getCommand().isOneWay() ? Direction.ONE_WAY : Direction.REQUEST, tenant, tenantTracker.result(), ProcessingOutcome.FORWARDED, commandContext.getCommand().getPayloadSize(), getMicrometerSample(commandContext));
                }
                metrics.reportTelemetry(endpoint, tenant, tenantTracker.result(), ProcessingOutcome.FORWARDED, qos, payloadSize, ctx.getTtdStatus(), getMicrometerSample(ctx.getRoutingContext()));
                currentSpan.finish();
            });
            ctx.response().exceptionHandler(t -> {
                log.debug("failed to send http response for [{}] message from device [tenantId: {}, deviceId: {}]", endpoint, tenant, deviceId, t);
                if (commandContext != null) {
                    TracingHelper.logError(commandContext.getTracingSpan(), "failed to forward command to device in HTTP response body", t);
                    commandContext.release(t);
                    metrics.reportCommand(commandContext.getCommand().isOneWay() ? Direction.ONE_WAY : Direction.REQUEST, tenant, tenantTracker.result(), ProcessingOutcome.UNDELIVERABLE, commandContext.getCommand().getPayloadSize(), getMicrometerSample(commandContext));
                }
                currentSpan.log("failed to send HTTP response to device");
                TracingHelper.logError(currentSpan, t);
                currentSpan.finish();
            });
            ctx.response().end();
        }
        return proceed;
    }).recover(t -> {
        log.debug("cannot process [{}] message from device [tenantId: {}, deviceId: {}]", endpoint, tenant, deviceId, t);
        final boolean responseClosedPrematurely = ctx.response().closed();
        final Future<Void> commandConsumerClosedTracker = Optional.ofNullable(commandConsumerTracker.result()).map(consumer -> consumer.close(currentSpan.context()).onFailure(thr -> TracingHelper.logError(currentSpan, thr))).orElseGet(Future::succeededFuture);
        final CommandContext commandContext = ctx.get(CommandContext.KEY_COMMAND_CONTEXT);
        if (commandContext != null) {
            TracingHelper.logError(commandContext.getTracingSpan(), "command won't be forwarded to device in HTTP response body, HTTP request handling failed", t);
            commandContext.release(t);
            currentSpan.log("released command for device");
        }
        final ProcessingOutcome outcome;
        if (ClientErrorException.class.isInstance(t)) {
            outcome = ProcessingOutcome.UNPROCESSABLE;
            ctx.fail(t);
        } else {
            outcome = ProcessingOutcome.UNDELIVERABLE;
            final String errorMessage = t instanceof ServerErrorException ? ((ServerErrorException) t).getClientFacingMessage() : null;
            HttpUtils.serviceUnavailable(ctx.getRoutingContext(), 2, Strings.isNullOrEmpty(errorMessage) ? "temporarily unavailable" : errorMessage);
        }
        if (responseClosedPrematurely) {
            log.debug("failed to send http response for [{}] message from device [tenantId: {}, deviceId: {}]: response already closed", endpoint, tenant, deviceId);
            TracingHelper.logError(currentSpan, "failed to send HTTP response to device: response already closed");
        }
        metrics.reportTelemetry(endpoint, tenant, tenantTracker.result(), outcome, qos, payloadSize, ctx.getTtdStatus(), getMicrometerSample(ctx.getRoutingContext()));
        TracingHelper.logError(currentSpan, t);
        commandConsumerClosedTracker.onComplete(res -> currentSpan.finish());
        return Future.failedFuture(t);
    });
}
Also used : HttpURLConnection(java.net.HttpURLConnection) HttpServer(io.vertx.core.http.HttpServer) Router(io.vertx.ext.web.Router) RoutingContext(io.vertx.ext.web.RoutingContext) BodyHandler(io.vertx.ext.web.handler.BodyHandler) Tags(io.opentracing.tag.Tags) ProcessingOutcome(org.eclipse.hono.service.metric.MetricsTags.ProcessingOutcome) EndpointType(org.eclipse.hono.service.metric.MetricsTags.EndpointType) TtdStatus(org.eclipse.hono.service.metric.MetricsTags.TtdStatus) DeviceCredentials(org.eclipse.hono.adapter.auth.device.DeviceCredentials) References(io.opentracing.References) Duration(java.time.Duration) Map(java.util.Map) WebSpanDecorator(org.eclipse.hono.service.http.WebSpanDecorator) TracingHelper(org.eclipse.hono.tracing.TracingHelper) CommandContext(org.eclipse.hono.client.command.CommandContext) MetricsTags(org.eclipse.hono.service.metric.MetricsTags) RegistrationAssertion(org.eclipse.hono.util.RegistrationAssertion) MessageHelper(org.eclipse.hono.util.MessageHelper) Future(io.vertx.core.Future) Device(org.eclipse.hono.auth.Device) Objects(java.util.Objects) List(java.util.List) ComponentMetaDataDecorator(org.eclipse.hono.service.http.ComponentMetaDataDecorator) TenantTraceSamplingHelper(org.eclipse.hono.tracing.TenantTraceSamplingHelper) Buffer(io.vertx.core.buffer.Buffer) CommandConsumer(org.eclipse.hono.client.command.CommandConsumer) HttpServerResponse(io.vertx.core.http.HttpServerResponse) DefaultFailureHandler(org.eclipse.hono.service.http.DefaultFailureHandler) Optional(java.util.Optional) Span(io.opentracing.Span) HttpContext(org.eclipse.hono.service.http.HttpContext) Command(org.eclipse.hono.client.command.Command) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) ClientErrorException(org.eclipse.hono.client.ClientErrorException) Constants(org.eclipse.hono.util.Constants) ArrayList(java.util.ArrayList) TracingHandler(org.eclipse.hono.service.http.TracingHandler) CompositeFuture(io.vertx.core.CompositeFuture) HttpUtils(org.eclipse.hono.service.http.HttpUtils) AsyncResult(io.vertx.core.AsyncResult) Strings(org.eclipse.hono.util.Strings) Route(io.vertx.ext.web.Route) CredentialsApiAuthProvider(org.eclipse.hono.adapter.auth.device.CredentialsApiAuthProvider) AbstractProtocolAdapterBase(org.eclipse.hono.adapter.AbstractProtocolAdapterBase) Direction(org.eclipse.hono.service.metric.MetricsTags.Direction) Promise(io.vertx.core.Promise) ServerErrorException(org.eclipse.hono.client.ServerErrorException) Sample(io.micrometer.core.instrument.Timer.Sample) CommandResponse(org.eclipse.hono.client.command.CommandResponse) TenantObject(org.eclipse.hono.util.TenantObject) SpanContext(io.opentracing.SpanContext) HttpServerOptions(io.vertx.core.http.HttpServerOptions) NoopSpan(io.opentracing.noop.NoopSpan) Handler(io.vertx.core.Handler) CommandContext(org.eclipse.hono.client.command.CommandContext) Device(org.eclipse.hono.auth.Device) Span(io.opentracing.Span) NoopSpan(io.opentracing.noop.NoopSpan) ProcessingOutcome(org.eclipse.hono.service.metric.MetricsTags.ProcessingOutcome) TenantObject(org.eclipse.hono.util.TenantObject) RegistrationAssertion(org.eclipse.hono.util.RegistrationAssertion) CommandConsumer(org.eclipse.hono.client.command.CommandConsumer) MetricsTags(org.eclipse.hono.service.metric.MetricsTags) Future(io.vertx.core.Future) CompositeFuture(io.vertx.core.CompositeFuture) ServerErrorException(org.eclipse.hono.client.ServerErrorException) Map(java.util.Map) HashMap(java.util.HashMap)

Example 3 with CommandConsumer

use of org.eclipse.hono.client.command.CommandConsumer in project hono by eclipse.

the class AbstractVertxBasedMqttProtocolAdapterTest method testOnSubscribeRegistersAndClosesConnection.

private void testOnSubscribeRegistersAndClosesConnection(final MqttQoS qos) {
    // GIVEN a device connected to an adapter
    givenAnAdapter(properties);
    givenAnEventSenderForAnyTenant();
    final MqttEndpoint endpoint = mockEndpoint();
    // 10 seconds
    when(endpoint.keepAliveTimeSeconds()).thenReturn(10);
    // WHEN a device subscribes to commands
    final CommandConsumer commandConsumer = mock(CommandConsumer.class);
    when(commandConsumer.close(any())).thenReturn(Future.succeededFuture());
    when(commandConsumerFactory.createCommandConsumer(eq("tenant"), eq("deviceId"), VertxMockSupport.anyHandler(), any(), any())).thenReturn(Future.succeededFuture(commandConsumer));
    final List<MqttTopicSubscription> subscriptions = Collections.singletonList(newMockTopicSubscription(getCommandSubscriptionTopic("tenant", "deviceId"), qos));
    final MqttSubscribeMessage msg = mock(MqttSubscribeMessage.class);
    when(msg.messageId()).thenReturn(15);
    when(msg.topicSubscriptions()).thenReturn(subscriptions);
    final var mqttDeviceEndpoint = adapter.createMqttDeviceEndpoint(endpoint, null, OptionalInt.empty());
    endpoint.closeHandler(handler -> mqttDeviceEndpoint.onClose());
    mqttDeviceEndpoint.onSubscribe(msg);
    // THEN the adapter creates a command consumer that is checked periodically
    verify(commandConsumerFactory).createCommandConsumer(eq("tenant"), eq("deviceId"), VertxMockSupport.anyHandler(), any(), any());
    // and the adapter registers a hook on the connection to the device
    final ArgumentCaptor<Handler<Void>> closeHookCaptor = VertxMockSupport.argumentCaptorHandler();
    verify(endpoint).closeHandler(closeHookCaptor.capture());
    // which closes the command consumer when the device disconnects
    closeHookCaptor.getValue().handle(null);
    verify(commandConsumer).close(any());
    // and sends an empty notification downstream with TTD 0
    assertEmptyNotificationHasBeenSentDownstream("tenant", "deviceId", 0);
}
Also used : MqttSubscribeMessage(io.vertx.mqtt.messages.MqttSubscribeMessage) MqttEndpoint(io.vertx.mqtt.MqttEndpoint) MqttTopicSubscription(io.vertx.mqtt.MqttTopicSubscription) CommandConsumer(org.eclipse.hono.client.command.CommandConsumer) AuthHandler(org.eclipse.hono.adapter.auth.device.AuthHandler) Handler(io.vertx.core.Handler)

Example 4 with CommandConsumer

use of org.eclipse.hono.client.command.CommandConsumer in project hono by eclipse.

the class ProtocolGateway method handleConnect.

void handleConnect(final NetSocket socket) {
    final Map<String, Object> dict = new HashMap<>();
    final RecordParser commandParser = RecordParser.newDelimited("\n", socket);
    commandParser.endHandler(end -> socket.close());
    commandParser.exceptionHandler(t -> {
        LOG.debug("error processing data from device", t);
        socket.close();
    });
    commandParser.handler(data -> handleData(socket, dict, data));
    socket.closeHandler(remoteClose -> {
        LOG.debug("device closed connection");
        Optional.ofNullable((CommandConsumer) dict.get(KEY_COMMAND_CONSUMER)).ifPresent(c -> {
            c.close(null).onComplete(res -> LOG.debug("closed device's command consumer"));
        });
        socket.close();
    });
    socket.write(String.format("Welcome to the Protocol Gateway for devices of tenant [%s], please enter a command\n", tenant));
    LOG.debug("connection with client established");
}
Also used : HashMap(java.util.HashMap) CommandConsumer(org.eclipse.hono.client.command.CommandConsumer) RecordParser(io.vertx.core.parsetools.RecordParser)

Example 5 with CommandConsumer

use of org.eclipse.hono.client.command.CommandConsumer in project hono by eclipse.

the class VertxBasedAmqpProtocolAdapter method createCommandConsumer.

private Future<CommandConsumer> createCommandConsumer(final ProtonSender sender, final ResourceIdentifier sourceAddress, final Device authenticatedDevice, final Span span) {
    final Handler<CommandContext> commandHandler = commandContext -> {
        final Sample timer = metrics.startTimer();
        addMicrometerSample(commandContext, timer);
        Tags.COMPONENT.set(commandContext.getTracingSpan(), getTypeName());
        final Command command = commandContext.getCommand();
        final Future<TenantObject> tenantTracker = getTenantConfiguration(sourceAddress.getTenantId(), commandContext.getTracingContext());
        tenantTracker.compose(tenantObject -> {
            if (!command.isValid()) {
                return Future.failedFuture(new ClientErrorException(HttpURLConnection.HTTP_BAD_REQUEST, "malformed command message"));
            }
            if (!HonoProtonHelper.isLinkOpenAndConnected(sender)) {
                return Future.failedFuture(new ServerErrorException(HttpURLConnection.HTTP_UNAVAILABLE, "sender link is not open"));
            }
            return checkMessageLimit(tenantObject, command.getPayloadSize(), commandContext.getTracingContext());
        }).compose(success -> {
            // check the via-gateways, ensuring that the gateway may act on behalf of the device at this point in time
            if (authenticatedDevice != null && !authenticatedDevice.getDeviceId().equals(sourceAddress.getResourceId())) {
                return getRegistrationAssertion(authenticatedDevice.getTenantId(), sourceAddress.getResourceId(), authenticatedDevice, commandContext.getTracingContext());
            }
            return Future.succeededFuture();
        }).compose(success -> {
            onCommandReceived(tenantTracker.result(), sender, commandContext);
            return Future.succeededFuture();
        }).otherwise(failure -> {
            if (failure instanceof ClientErrorException) {
                commandContext.reject(failure);
            } else {
                commandContext.release(failure);
            }
            metrics.reportCommand(command.isOneWay() ? Direction.ONE_WAY : Direction.REQUEST, sourceAddress.getTenantId(), tenantTracker.result(), ProcessingOutcome.from(failure), command.getPayloadSize(), timer);
            return null;
        });
    };
    final Future<RegistrationAssertion> tokenTracker = Optional.ofNullable(authenticatedDevice).map(v -> getRegistrationAssertion(authenticatedDevice.getTenantId(), sourceAddress.getResourceId(), authenticatedDevice, span.context())).orElseGet(Future::succeededFuture);
    if (authenticatedDevice != null && !authenticatedDevice.getDeviceId().equals(sourceAddress.getResourceId())) {
        // gateway scenario
        return tokenTracker.compose(v -> getCommandConsumerFactory().createCommandConsumer(sourceAddress.getTenantId(), sourceAddress.getResourceId(), authenticatedDevice.getDeviceId(), commandHandler, null, span.context()));
    } else {
        return tokenTracker.compose(v -> getCommandConsumerFactory().createCommandConsumer(sourceAddress.getTenantId(), sourceAddress.getResourceId(), commandHandler, null, span.context()));
    }
}
Also used : HttpURLConnection(java.net.HttpURLConnection) ProtonConnection(io.vertx.proton.ProtonConnection) ProtonReceiver(io.vertx.proton.ProtonReceiver) LifecycleChange(org.eclipse.hono.notification.deviceregistry.LifecycleChange) DeviceChangeNotification(org.eclipse.hono.notification.deviceregistry.DeviceChangeNotification) Tags(io.opentracing.tag.Tags) ProtonServer(io.vertx.proton.ProtonServer) HonoProtonHelper(org.eclipse.hono.util.HonoProtonHelper) ProcessingOutcome(org.eclipse.hono.service.metric.MetricsTags.ProcessingOutcome) EndpointType(org.eclipse.hono.service.metric.MetricsTags.EndpointType) Modified(org.apache.qpid.proton.amqp.messaging.Modified) DeviceCredentials(org.eclipse.hono.adapter.auth.device.DeviceCredentials) Map(java.util.Map) DeliveryState(org.apache.qpid.proton.amqp.transport.DeliveryState) AuthorizationException(org.eclipse.hono.adapter.AuthorizationException) ResourceIdentifier(org.eclipse.hono.util.ResourceIdentifier) Fields(io.opentracing.log.Fields) AmqpError(org.apache.qpid.proton.amqp.transport.AmqpError) TracingHelper(org.eclipse.hono.tracing.TracingHelper) ProtonSaslAuthenticatorFactory(io.vertx.proton.sasl.ProtonSaslAuthenticatorFactory) AllDevicesOfTenantDeletedNotification(org.eclipse.hono.notification.deviceregistry.AllDevicesOfTenantDeletedNotification) TenantServiceBasedX509Authentication(org.eclipse.hono.adapter.auth.device.TenantServiceBasedX509Authentication) Predicate(java.util.function.Predicate) Collection(java.util.Collection) CommandContext(org.eclipse.hono.client.command.CommandContext) RegistrationAssertion(org.eclipse.hono.util.RegistrationAssertion) ProtonQoS(io.vertx.proton.ProtonQoS) MessageHelper(org.eclipse.hono.util.MessageHelper) Collectors(java.util.stream.Collectors) Future(io.vertx.core.Future) Device(org.eclipse.hono.auth.Device) Objects(java.util.Objects) ErrorCondition(org.apache.qpid.proton.amqp.transport.ErrorCondition) List(java.util.List) QoS(org.eclipse.hono.service.metric.MetricsTags.QoS) TenantTraceSamplingHelper(org.eclipse.hono.tracing.TenantTraceSamplingHelper) CommandConsumer(org.eclipse.hono.client.command.CommandConsumer) Optional(java.util.Optional) Span(io.opentracing.Span) ProtonSender(io.vertx.proton.ProtonSender) NotificationEventBusSupport(org.eclipse.hono.notification.NotificationEventBusSupport) ProtonLink(io.vertx.proton.ProtonLink) Accepted(org.apache.qpid.proton.amqp.messaging.Accepted) ProtonServerOptions(io.vertx.proton.ProtonServerOptions) Rejected(org.apache.qpid.proton.amqp.messaging.Rejected) ConnectionLimitManager(org.eclipse.hono.adapter.limiting.ConnectionLimitManager) Command(org.eclipse.hono.client.command.Command) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) ClientErrorException(org.eclipse.hono.client.ClientErrorException) AdapterDisabledException(org.eclipse.hono.adapter.AdapterDisabledException) ServiceInvocationException(org.eclipse.hono.client.ServiceInvocationException) OptionalInt(java.util.OptionalInt) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) Commands(org.eclipse.hono.client.command.Commands) Constants(org.eclipse.hono.util.Constants) CompositeFuture(io.vertx.core.CompositeFuture) ProtonSession(io.vertx.proton.ProtonSession) Symbol(org.apache.qpid.proton.amqp.Symbol) AdapterConnectionsExceededException(org.eclipse.hono.adapter.AdapterConnectionsExceededException) Target(org.apache.qpid.proton.amqp.transport.Target) UnsignedLong(org.apache.qpid.proton.amqp.UnsignedLong) Message(org.apache.qpid.proton.message.Message) HttpUtils(org.eclipse.hono.service.http.HttpUtils) AsyncResult(io.vertx.core.AsyncResult) CommandConstants(org.eclipse.hono.util.CommandConstants) TenantChangeNotification(org.eclipse.hono.notification.deviceregistry.TenantChangeNotification) Strings(org.eclipse.hono.util.Strings) UsernamePasswordAuthProvider(org.eclipse.hono.adapter.auth.device.UsernamePasswordAuthProvider) CredentialsApiAuthProvider(org.eclipse.hono.adapter.auth.device.CredentialsApiAuthProvider) AbstractProtocolAdapterBase(org.eclipse.hono.adapter.AbstractProtocolAdapterBase) Direction(org.eclipse.hono.service.metric.MetricsTags.Direction) Promise(io.vertx.core.Promise) ServerErrorException(org.eclipse.hono.client.ServerErrorException) ProtonHelper(io.vertx.proton.ProtonHelper) Sample(io.micrometer.core.instrument.Timer.Sample) Released(org.apache.qpid.proton.amqp.messaging.Released) CommandResponse(org.eclipse.hono.client.command.CommandResponse) TenantObject(org.eclipse.hono.util.TenantObject) SpanContext(io.opentracing.SpanContext) Source(org.apache.qpid.proton.amqp.transport.Source) ConnectionAttemptOutcome(org.eclipse.hono.service.metric.MetricsTags.ConnectionAttemptOutcome) MemoryBasedConnectionLimitStrategy(org.eclipse.hono.adapter.limiting.MemoryBasedConnectionLimitStrategy) X509AuthProvider(org.eclipse.hono.adapter.auth.device.X509AuthProvider) Handler(io.vertx.core.Handler) Collections(java.util.Collections) DefaultConnectionLimitManager(org.eclipse.hono.adapter.limiting.DefaultConnectionLimitManager) CommandContext(org.eclipse.hono.client.command.CommandContext) Command(org.eclipse.hono.client.command.Command) Sample(io.micrometer.core.instrument.Timer.Sample) RegistrationAssertion(org.eclipse.hono.util.RegistrationAssertion) Future(io.vertx.core.Future) CompositeFuture(io.vertx.core.CompositeFuture) ClientErrorException(org.eclipse.hono.client.ClientErrorException) ServerErrorException(org.eclipse.hono.client.ServerErrorException)

Aggregations

CommandConsumer (org.eclipse.hono.client.command.CommandConsumer)23 Handler (io.vertx.core.Handler)15 ClientErrorException (org.eclipse.hono.client.ClientErrorException)14 Device (org.eclipse.hono.auth.Device)12 CommandContext (org.eclipse.hono.client.command.CommandContext)11 Future (io.vertx.core.Future)10 HttpURLConnection (java.net.HttpURLConnection)10 ServerErrorException (org.eclipse.hono.client.ServerErrorException)10 Command (org.eclipse.hono.client.command.Command)10 Test (org.junit.jupiter.api.Test)10 Sample (io.micrometer.core.instrument.Timer.Sample)9 Span (io.opentracing.Span)9 SpanContext (io.opentracing.SpanContext)9 Promise (io.vertx.core.Promise)9 Buffer (io.vertx.core.buffer.Buffer)9 List (java.util.List)9 Map (java.util.Map)9 Constants (org.eclipse.hono.util.Constants)9 Tags (io.opentracing.tag.Tags)8 AsyncResult (io.vertx.core.AsyncResult)8