Search in sources :

Example 1 with AuthenticationService

use of org.eclipse.hono.service.auth.AuthenticationService in project hono by eclipse.

the class Application method doStart.

@Override
protected void doStart() {
    if (!(authenticationService instanceof Verticle)) {
        throw new IllegalStateException("Authentication service must be a vert.x Verticle");
    }
    LOG.info("adding common tags to meter registry");
    meterRegistry.config().commonTags(MetricsTags.forService(Constants.SERVICE_NAME_DEVICE_REGISTRY));
    LOG.info("deploying {} {} instances ...", appConfig.getMaxInstances(), getComponentName());
    final CompletableFuture<Void> startup = new CompletableFuture<>();
    // deploy authentication service (once only)
    final Promise<String> authServiceDeploymentTracker = Promise.promise();
    vertx.deployVerticle((Verticle) authenticationService, authServiceDeploymentTracker);
    // deploy notification sender (once only)
    final Promise<String> notificationSenderDeploymentTracker = Promise.promise();
    vertx.deployVerticle(new WrappedLifecycleComponentVerticle(notificationSender), notificationSenderDeploymentTracker);
    // deploy AMQP 1.0 server
    final Promise<String> amqpServerDeploymentTracker = Promise.promise();
    vertx.deployVerticle(() -> amqpServerFactory.newServer(), new DeploymentOptions().setInstances(appConfig.getMaxInstances()), amqpServerDeploymentTracker);
    // deploy HTTP server
    final Promise<String> httpServerDeploymentTracker = Promise.promise();
    vertx.deployVerticle(() -> httpServerFactory.newServer(), new DeploymentOptions().setInstances(appConfig.getMaxInstances()), httpServerDeploymentTracker);
    CompositeFuture.all(authServiceDeploymentTracker.future(), notificationSenderDeploymentTracker.future(), amqpServerDeploymentTracker.future(), httpServerDeploymentTracker.future()).onSuccess(ok -> registerHealthCheckProvider(authenticationService)).compose(s -> healthCheckServer.start()).onSuccess(ok -> startup.complete(null)).onFailure(t -> startup.completeExceptionally(t));
    startup.join();
}
Also used : NotificationSender(org.eclipse.hono.notification.NotificationSender) Logger(org.slf4j.Logger) Promise(io.vertx.core.Promise) AuthenticationService(org.eclipse.hono.service.auth.AuthenticationService) MetricsTags(org.eclipse.hono.service.metric.MetricsTags) LoggerFactory(org.slf4j.LoggerFactory) CompletableFuture(java.util.concurrent.CompletableFuture) Verticle(io.vertx.core.Verticle) Constants(org.eclipse.hono.util.Constants) Inject(javax.inject.Inject) AbstractServiceApplication(org.eclipse.hono.service.quarkus.AbstractServiceApplication) CompositeFuture(io.vertx.core.CompositeFuture) DeploymentOptions(io.vertx.core.DeploymentOptions) ApplicationScoped(javax.enterprise.context.ApplicationScoped) WrappedLifecycleComponentVerticle(org.eclipse.hono.util.WrappedLifecycleComponentVerticle) Verticle(io.vertx.core.Verticle) WrappedLifecycleComponentVerticle(org.eclipse.hono.util.WrappedLifecycleComponentVerticle) CompletableFuture(java.util.concurrent.CompletableFuture) WrappedLifecycleComponentVerticle(org.eclipse.hono.util.WrappedLifecycleComponentVerticle) DeploymentOptions(io.vertx.core.DeploymentOptions)

Example 2 with AuthenticationService

use of org.eclipse.hono.service.auth.AuthenticationService in project hono by eclipse.

the class Application method doStart.

@Override
protected void doStart() {
    if (!(authenticationService instanceof Verticle)) {
        throw new IllegalStateException("Authentication service must be a vert.x Verticle");
    }
    LOG.info("adding common tags to meter registry");
    meterRegistry.config().commonTags(MetricsTags.forService(Constants.SERVICE_NAME_DEVICE_REGISTRY));
    LOG.info("deploying {} {} instances ...", appConfig.getMaxInstances(), getComponentName());
    final CompletableFuture<Void> startup = new CompletableFuture<>();
    // deploy authentication service (once only)
    final Promise<String> authServiceDeploymentTracker = Promise.promise();
    vertx.deployVerticle((Verticle) authenticationService, authServiceDeploymentTracker);
    // deploy notification sender (once only)
    final Promise<String> notificationSenderDeploymentTracker = Promise.promise();
    vertx.deployVerticle(new WrappedLifecycleComponentVerticle(notificationSender), notificationSenderDeploymentTracker);
    // deploy AMQP 1.0 server
    final Promise<String> amqpServerDeploymentTracker = Promise.promise();
    vertx.deployVerticle(() -> amqpServerFactory.newServer(), new DeploymentOptions().setInstances(appConfig.getMaxInstances()), amqpServerDeploymentTracker);
    // deploy HTTP server
    final Promise<String> httpServerDeploymentTracker = Promise.promise();
    vertx.deployVerticle(() -> httpServerFactory.newServer(), new DeploymentOptions().setInstances(appConfig.getMaxInstances()), httpServerDeploymentTracker);
    CompositeFuture.all(authServiceDeploymentTracker.future(), notificationSenderDeploymentTracker.future(), amqpServerDeploymentTracker.future(), httpServerDeploymentTracker.future()).onSuccess(ok -> registerHealthCheckProvider(authenticationService)).compose(s -> healthCheckServer.start()).onSuccess(ok -> startup.complete(null)).onFailure(t -> startup.completeExceptionally(t));
    startup.join();
}
Also used : NotificationSender(org.eclipse.hono.notification.NotificationSender) Logger(org.slf4j.Logger) Promise(io.vertx.core.Promise) AuthenticationService(org.eclipse.hono.service.auth.AuthenticationService) MetricsTags(org.eclipse.hono.service.metric.MetricsTags) LoggerFactory(org.slf4j.LoggerFactory) CompletableFuture(java.util.concurrent.CompletableFuture) Verticle(io.vertx.core.Verticle) Constants(org.eclipse.hono.util.Constants) Inject(javax.inject.Inject) AbstractServiceApplication(org.eclipse.hono.service.quarkus.AbstractServiceApplication) CompositeFuture(io.vertx.core.CompositeFuture) DeploymentOptions(io.vertx.core.DeploymentOptions) ApplicationScoped(javax.enterprise.context.ApplicationScoped) WrappedLifecycleComponentVerticle(org.eclipse.hono.util.WrappedLifecycleComponentVerticle) Verticle(io.vertx.core.Verticle) WrappedLifecycleComponentVerticle(org.eclipse.hono.util.WrappedLifecycleComponentVerticle) CompletableFuture(java.util.concurrent.CompletableFuture) WrappedLifecycleComponentVerticle(org.eclipse.hono.util.WrappedLifecycleComponentVerticle) DeploymentOptions(io.vertx.core.DeploymentOptions)

Example 3 with AuthenticationService

use of org.eclipse.hono.service.auth.AuthenticationService in project hono by eclipse.

the class Application method doStart.

@Override
protected void doStart() {
    if (!(authenticationService instanceof Verticle)) {
        throw new IllegalStateException("Authentication service must be a vert.x Verticle");
    }
    LOG.info("deploying {} {} instances ...", appConfig.getMaxInstances(), getComponentName());
    final CompletableFuture<Void> startup = new CompletableFuture<>();
    // deploy authentication service (once only)
    final Future<String> authServiceDeploymentTracker = vertx.deployVerticle((Verticle) authenticationService).onSuccess(ok -> registerHealthCheckProvider(authenticationService));
    // deploy AMQP 1.0 server
    final Future<String> amqpServerDeploymentTracker = vertx.deployVerticle(this::amqpServer, new DeploymentOptions().setInstances(appConfig.getMaxInstances()));
    // deploy notification receiver
    final Future<String> notificationReceiverTracker = vertx.deployVerticle(new WrappedLifecycleComponentVerticle(notificationReceiver()));
    CompositeFuture.all(authServiceDeploymentTracker, amqpServerDeploymentTracker, notificationReceiverTracker).compose(s -> healthCheckServer.start()).onSuccess(ok -> startup.complete(null)).onFailure(startup::completeExceptionally);
    startup.join();
}
Also used : MessagingKafkaConsumerConfigProperties(org.eclipse.hono.client.kafka.consumer.MessagingKafkaConsumerConfigProperties) MessagingKafkaProducerConfigProperties(org.eclipse.hono.client.kafka.producer.MessagingKafkaProducerConfigProperties) ProtonBasedDeviceRegistrationClient(org.eclipse.hono.client.registry.amqp.ProtonBasedDeviceRegistrationClient) CommandRouterService(org.eclipse.hono.service.commandrouter.CommandRouterService) LoggerFactory(org.slf4j.LoggerFactory) Watcher(io.fabric8.kubernetes.client.Watcher) ServiceConfigProperties(org.eclipse.hono.config.ServiceConfigProperties) KafkaAdminClientOptions(org.eclipse.hono.client.kafka.KafkaAdminClientOptions) AbstractServiceApplication(org.eclipse.hono.service.quarkus.AbstractServiceApplication) RegistrationResult(org.eclipse.hono.util.RegistrationResult) ProtonSaslAuthenticatorFactory(io.vertx.proton.sasl.ProtonSaslAuthenticatorFactory) ClientConfigProperties(org.eclipse.hono.config.ClientConfigProperties) KafkaConsumerOptions(org.eclipse.hono.client.kafka.consumer.KafkaConsumerOptions) ProtonBasedCommandConsumerFactoryImpl(org.eclipse.hono.commandrouter.impl.amqp.ProtonBasedCommandConsumerFactoryImpl) NotificationConstants(org.eclipse.hono.notification.NotificationConstants) ProtonBasedNotificationReceiver(org.eclipse.hono.client.notification.amqp.ProtonBasedNotificationReceiver) CachingKafkaProducerFactory(org.eclipse.hono.client.kafka.producer.CachingKafkaProducerFactory) CommandRouterServiceImpl(org.eclipse.hono.commandrouter.impl.CommandRouterServiceImpl) CommandTargetMapper(org.eclipse.hono.commandrouter.CommandTargetMapper) TenantClient(org.eclipse.hono.client.registry.TenantClient) KafkaBasedCommandConsumerFactoryImpl(org.eclipse.hono.commandrouter.impl.kafka.KafkaBasedCommandConsumerFactoryImpl) Caches(org.eclipse.hono.service.cache.Caches) Future(io.vertx.core.Future) DeviceConnectionInfo(org.eclipse.hono.deviceconnection.infinispan.client.DeviceConnectionInfo) ConfigMapping(io.smallrye.config.ConfigMapping) List(java.util.List) KafkaProducerFactory(org.eclipse.hono.client.kafka.producer.KafkaProducerFactory) Buffer(io.vertx.core.buffer.Buffer) ServiceOptions(org.eclipse.hono.config.quarkus.ServiceOptions) MicrometerKafkaClientMetricsSupport(org.eclipse.hono.client.kafka.metrics.MicrometerKafkaClientMetricsSupport) ApplicationScoped(javax.enterprise.context.ApplicationScoped) NotificationEventBusSupport(org.eclipse.hono.notification.NotificationEventBusSupport) AdapterInstanceStatusService(org.eclipse.hono.commandrouter.AdapterInstanceStatusService) CommandRouterAmqpServer(org.eclipse.hono.commandrouter.CommandRouterAmqpServer) ProtonBasedTenantClient(org.eclipse.hono.client.registry.amqp.ProtonBasedTenantClient) CompletableFuture(java.util.concurrent.CompletableFuture) ClientOptions(org.eclipse.hono.config.quarkus.ClientOptions) Cache(com.github.benmanes.caffeine.cache.Cache) InternalKafkaTopicCleanupService(org.eclipse.hono.commandrouter.impl.kafka.InternalKafkaTopicCleanupService) Inject(javax.inject.Inject) WatcherException(io.fabric8.kubernetes.client.WatcherException) CompositeFuture(io.vertx.core.CompositeFuture) CommonKafkaClientOptions(org.eclipse.hono.client.kafka.CommonKafkaClientOptions) HealthCheckHandler(io.vertx.ext.healthchecks.HealthCheckHandler) KafkaClientMetricsSupport(org.eclipse.hono.client.kafka.metrics.KafkaClientMetricsSupport) KafkaMetricsOptions(org.eclipse.hono.client.kafka.metrics.KafkaMetricsOptions) DeviceRegistrationClient(org.eclipse.hono.client.registry.DeviceRegistrationClient) HealthCheckProvider(org.eclipse.hono.service.HealthCheckProvider) KafkaAdminClientConfigProperties(org.eclipse.hono.client.kafka.KafkaAdminClientConfigProperties) WrappedLifecycleComponentVerticle(org.eclipse.hono.util.WrappedLifecycleComponentVerticle) HonoConnection(org.eclipse.hono.client.HonoConnection) DelegatingCommandRouterAmqpEndpoint(org.eclipse.hono.service.commandrouter.DelegatingCommandRouterAmqpEndpoint) RequestResponseClientConfigProperties(org.eclipse.hono.client.RequestResponseClientConfigProperties) NotificationReceiver(org.eclipse.hono.notification.NotificationReceiver) NotificationKafkaConsumerConfigProperties(org.eclipse.hono.client.notification.kafka.NotificationKafkaConsumerConfigProperties) TenantResult(org.eclipse.hono.util.TenantResult) Logger(org.slf4j.Logger) Tracer(io.opentracing.Tracer) MessagingClientProvider(org.eclipse.hono.client.util.MessagingClientProvider) KafkaBasedNotificationReceiver(org.eclipse.hono.client.notification.kafka.KafkaBasedNotificationReceiver) AuthenticationService(org.eclipse.hono.service.auth.AuthenticationService) KafkaProducerOptions(org.eclipse.hono.client.kafka.producer.KafkaProducerOptions) Pod(io.fabric8.kubernetes.api.model.Pod) Verticle(io.vertx.core.Verticle) RequestResponseClientOptions(org.eclipse.hono.client.RequestResponseClientOptions) TenantObject(org.eclipse.hono.util.TenantObject) NoopKafkaClientMetricsSupport(org.eclipse.hono.client.kafka.metrics.NoopKafkaClientMetricsSupport) CommandRouterMetrics(org.eclipse.hono.commandrouter.CommandRouterMetrics) DeploymentOptions(io.vertx.core.DeploymentOptions) AmqpEndpoint(org.eclipse.hono.service.amqp.AmqpEndpoint) CommandConsumerFactory(org.eclipse.hono.commandrouter.CommandConsumerFactory) SendMessageSampler(org.eclipse.hono.client.SendMessageSampler) WrappedLifecycleComponentVerticle(org.eclipse.hono.util.WrappedLifecycleComponentVerticle) Verticle(io.vertx.core.Verticle) CompletableFuture(java.util.concurrent.CompletableFuture) DeploymentOptions(io.vertx.core.DeploymentOptions) WrappedLifecycleComponentVerticle(org.eclipse.hono.util.WrappedLifecycleComponentVerticle)

Aggregations

CompositeFuture (io.vertx.core.CompositeFuture)3 DeploymentOptions (io.vertx.core.DeploymentOptions)3 Verticle (io.vertx.core.Verticle)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 ApplicationScoped (javax.enterprise.context.ApplicationScoped)3 Inject (javax.inject.Inject)3 AuthenticationService (org.eclipse.hono.service.auth.AuthenticationService)3 AbstractServiceApplication (org.eclipse.hono.service.quarkus.AbstractServiceApplication)3 WrappedLifecycleComponentVerticle (org.eclipse.hono.util.WrappedLifecycleComponentVerticle)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 Promise (io.vertx.core.Promise)2 Cache (com.github.benmanes.caffeine.cache.Cache)1 Pod (io.fabric8.kubernetes.api.model.Pod)1 Watcher (io.fabric8.kubernetes.client.Watcher)1 WatcherException (io.fabric8.kubernetes.client.WatcherException)1 Tracer (io.opentracing.Tracer)1 ConfigMapping (io.smallrye.config.ConfigMapping)1 Future (io.vertx.core.Future)1 Buffer (io.vertx.core.buffer.Buffer)1