use of com.sequenceiq.cloudbreak.cloud.notification.model.ResourceNotification in project cloudbreak by hortonworks.
the class ResourceNotifier method notifyAllocation.
@Override
public ResourcePersisted notifyAllocation(CloudResource cloudResource, CloudContext cloudContext) {
ResourceNotification notification = new ResourceNotification(cloudResource, cloudContext, ResourceNotificationType.CREATE);
LOGGER.info("Sending resource allocation notification: {}, context: {}", notification, cloudContext);
eventBus.notify("resource-persisted", eventFactory.createEvent(notification));
return notification.getResult();
}
use of com.sequenceiq.cloudbreak.cloud.notification.model.ResourceNotification in project cloudbreak by hortonworks.
the class ResourceNotifier method notifyDeletion.
@Override
public ResourcePersisted notifyDeletion(CloudResource cloudResource, CloudContext cloudContext) {
ResourceNotification notification = new ResourceNotification(cloudResource, cloudContext, ResourceNotificationType.DELETE);
LOGGER.info("Sending resource deletion notification: {}, context: {}", notification, cloudContext);
eventBus.notify("resource-persisted", eventFactory.createEvent(notification));
return notification.getResult();
}
use of com.sequenceiq.cloudbreak.cloud.notification.model.ResourceNotification in project cloudbreak by hortonworks.
the class ResourceNotifier method notifyUpdate.
@Override
public ResourcePersisted notifyUpdate(CloudResource cloudResource, CloudContext cloudContext) {
ResourceNotification notification = new ResourceNotification(cloudResource, cloudContext, ResourceNotificationType.UPDATE);
LOGGER.info("Sending resource update notification: {}, context: {}", notification, cloudContext);
eventBus.notify("resource-persisted", eventFactory.createEvent(notification));
return notification.getResult();
}
use of com.sequenceiq.cloudbreak.cloud.notification.model.ResourceNotification in project cloudbreak by hortonworks.
the class ResourcePersistenceHandler method accept.
@Override
public void accept(Event<ResourceNotification> event) {
LOGGER.info("Resource notification event received: {}", event);
ResourceNotification notification = event.getData();
RetryUtil.withDefaultRetries().retry(() -> {
ResourceNotification notificationPersisted;
switch(notification.getType()) {
case CREATE:
notificationPersisted = cloudResourcePersisterService.persist(notification);
break;
case UPDATE:
notificationPersisted = cloudResourcePersisterService.update(notification);
break;
case DELETE:
notificationPersisted = cloudResourcePersisterService.delete(notification);
break;
default:
throw new IllegalArgumentException("Unsupported notification type: " + notification.getType());
}
notificationPersisted.getPromise().onNext(new ResourcePersisted());
}).checkIfRecoverable(e -> e instanceof TransientDataAccessException).ifNotRecoverable(e -> notification.getPromise().onError(e)).run();
}
use of com.sequenceiq.cloudbreak.cloud.notification.model.ResourceNotification in project cloudbreak by hortonworks.
the class LogContextAspects method buildLogContextForPersistenceHandler.
@Before("com.sequenceiq.cloudbreak.logger.LogContextAspects.interceptResourcePersistenceHandlerAcceptMethod()")
public void buildLogContextForPersistenceHandler(JoinPoint joinPoint) {
Event<ResourceNotification> event = (Event<ResourceNotification>) joinPoint.getArgs()[0];
CloudContext cloudContext = event.getData().getCloudContext();
buildMdcContext(cloudContext, event);
LOGGER.debug("A Resource persistence handler's 'accept' method has been intercepted: {}, MDC logger context is built.", joinPoint.toShortString());
}
Aggregations