Search in sources :

Example 1 with ReporterEvent

use of io.gravitee.am.common.event.ReporterEvent in project gravitee-access-management by gravitee-io.

the class AuditReporterManagerImpl method updateReporter.

private void updateReporter(String reporterId, ReporterEvent reporterEvent) {
    final String eventType = reporterEvent.toString().toLowerCase();
    logger.info("Domain {} has received {} reporter event for {}", domain.getName(), eventType, reporterId);
    reporterRepository.findById(reporterId).flatMapSingle(reporter -> environmentService.findById(domain.getReferenceId()).map(env -> new GraviteeContext(env.getOrganizationId(), env.getId(), domain.getId())).map(ctx -> Tuples.of(reporter, ctx))).subscribeOn(Schedulers.io()).subscribe(tupleReporterContext -> {
        updateReporterProvider(tupleReporterContext.getT1(), tupleReporterContext.getT2());
        logger.info("Reporter {} {}d for domain {}", reporterId, eventType, domain.getName());
    }, error -> logger.error("Unable to {} reporter for domain {}", eventType, domain.getName(), error));
}
Also used : EnvironmentService(io.gravitee.am.service.EnvironmentService) ReporterEvent(io.gravitee.am.common.event.ReporterEvent) LoggerFactory(org.slf4j.LoggerFactory) Tuples(reactor.util.function.Tuples) Autowired(org.springframework.beans.factory.annotation.Autowired) ReporterRepository(io.gravitee.am.repository.management.api.ReporterRepository) Single(io.reactivex.Single) InitializingBean(org.springframework.beans.factory.InitializingBean) ConcurrentMap(java.util.concurrent.ConcurrentMap) EventBusReporterWrapper(io.gravitee.am.service.reporter.vertx.EventBusReporterWrapper) Vertx(io.vertx.reactivex.core.Vertx) ReporterPluginManager(io.gravitee.am.plugins.reporter.core.ReporterPluginManager) ReferenceType(io.gravitee.am.model.ReferenceType) Schedulers(io.reactivex.schedulers.Schedulers) GraviteeContext(io.gravitee.am.common.utils.GraviteeContext) EventListener(io.gravitee.common.event.EventListener) AuditReporterVerticle(io.gravitee.am.service.reporter.impl.AuditReporterVerticle) EventManager(io.gravitee.am.common.event.EventManager) AuditReporterManager(io.gravitee.am.gateway.handler.common.audit.AuditReporterManager) Logger(org.slf4j.Logger) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Event(io.gravitee.common.event.Event) Domain(io.gravitee.am.model.Domain) Reporter(io.gravitee.am.model.Reporter) AbstractService(io.gravitee.common.service.AbstractService) Payload(io.gravitee.am.model.common.event.Payload) RxHelper(io.vertx.reactivex.core.RxHelper) GraviteeContext(io.gravitee.am.common.utils.GraviteeContext)

Example 2 with ReporterEvent

use of io.gravitee.am.common.event.ReporterEvent in project gravitee-access-management by gravitee-io.

the class AuditReporterManagerImpl method deployReporter.

private void deployReporter(String reporterId, ReporterEvent reporterEvent) {
    final String eventType = reporterEvent.toString().toLowerCase();
    logger.info("Domain {} has received {} reporter event for {}", domain.getName(), eventType, reporterId);
    reporterRepository.findById(reporterId).flatMapSingle(reporter -> environmentService.findById(domain.getReferenceId()).map(env -> new GraviteeContext(env.getOrganizationId(), env.getId(), domain.getId())).map(ctx -> Tuples.of(reporter, ctx))).subscribeOn(Schedulers.io()).subscribe(tupleReporterContext -> {
        if (reporters.containsKey(reporterId)) {
            updateReporterProvider(tupleReporterContext.getT1(), tupleReporterContext.getT2());
        } else {
            startReporterProvider(tupleReporterContext.getT1(), tupleReporterContext.getT2());
        }
        logger.info("Reporter {} {}d for domain {}", reporterId, eventType, domain.getName());
    }, error -> logger.error("Unable to {} reporter for domain {}", eventType, domain.getName(), error));
}
Also used : EnvironmentService(io.gravitee.am.service.EnvironmentService) ReporterEvent(io.gravitee.am.common.event.ReporterEvent) LoggerFactory(org.slf4j.LoggerFactory) Tuples(reactor.util.function.Tuples) Autowired(org.springframework.beans.factory.annotation.Autowired) ReporterRepository(io.gravitee.am.repository.management.api.ReporterRepository) Single(io.reactivex.Single) InitializingBean(org.springframework.beans.factory.InitializingBean) ConcurrentMap(java.util.concurrent.ConcurrentMap) EventBusReporterWrapper(io.gravitee.am.service.reporter.vertx.EventBusReporterWrapper) Vertx(io.vertx.reactivex.core.Vertx) ReporterPluginManager(io.gravitee.am.plugins.reporter.core.ReporterPluginManager) ReferenceType(io.gravitee.am.model.ReferenceType) Schedulers(io.reactivex.schedulers.Schedulers) GraviteeContext(io.gravitee.am.common.utils.GraviteeContext) EventListener(io.gravitee.common.event.EventListener) AuditReporterVerticle(io.gravitee.am.service.reporter.impl.AuditReporterVerticle) EventManager(io.gravitee.am.common.event.EventManager) AuditReporterManager(io.gravitee.am.gateway.handler.common.audit.AuditReporterManager) Logger(org.slf4j.Logger) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Event(io.gravitee.common.event.Event) Domain(io.gravitee.am.model.Domain) Reporter(io.gravitee.am.model.Reporter) AbstractService(io.gravitee.common.service.AbstractService) Payload(io.gravitee.am.model.common.event.Payload) RxHelper(io.vertx.reactivex.core.RxHelper) GraviteeContext(io.gravitee.am.common.utils.GraviteeContext)

Aggregations

EventManager (io.gravitee.am.common.event.EventManager)2 ReporterEvent (io.gravitee.am.common.event.ReporterEvent)2 GraviteeContext (io.gravitee.am.common.utils.GraviteeContext)2 AuditReporterManager (io.gravitee.am.gateway.handler.common.audit.AuditReporterManager)2 Domain (io.gravitee.am.model.Domain)2 ReferenceType (io.gravitee.am.model.ReferenceType)2 Reporter (io.gravitee.am.model.Reporter)2 Payload (io.gravitee.am.model.common.event.Payload)2 ReporterPluginManager (io.gravitee.am.plugins.reporter.core.ReporterPluginManager)2 ReporterRepository (io.gravitee.am.repository.management.api.ReporterRepository)2 EnvironmentService (io.gravitee.am.service.EnvironmentService)2 AuditReporterVerticle (io.gravitee.am.service.reporter.impl.AuditReporterVerticle)2 EventBusReporterWrapper (io.gravitee.am.service.reporter.vertx.EventBusReporterWrapper)2 Event (io.gravitee.common.event.Event)2 EventListener (io.gravitee.common.event.EventListener)2 AbstractService (io.gravitee.common.service.AbstractService)2 Single (io.reactivex.Single)2 Schedulers (io.reactivex.schedulers.Schedulers)2 RxHelper (io.vertx.reactivex.core.RxHelper)2 Vertx (io.vertx.reactivex.core.Vertx)2