@Override public UserVerifierDto editUserVerifier(UserVerifierDto userVerifier) throws ControlServiceException { LOG.info("Adding new user verifier {}", userVerifier); UserVerifierDto saved = null; if (userVerifier != null) { saved = userVerifierService.saveUserVerifier(userVerifier); LOG.info("Saved user verifier {}", saved); if (saved != null) { Notification thriftNotification = new Notification(); thriftNotification.setAppId(saved.getApplicationId()); thriftNotification.setUserVerifierToken(saved.getVerifierToken()); if (userVerifier.getId() == null) { LOG.info("Add new user verifier ..."); thriftNotification.setOp(Operation.ADD_USER_VERIFIER); LOG.info("Send notification to operation servers about new user verifier."); } else { thriftNotification.setOp(Operation.UPDATE_USER_VERIFIER); LOG.info("Send notification to operation servers about update " + "user verifier configuration."); } controlZkService.sendEndpointNotification(thriftNotification); } } return saved; }
@Override public LogAppenderDto editLogAppender(LogAppenderDto logAppender) throws ControlServiceException { LogAppenderDto saved = null; if (logAppender != null) { saved = logAppenderService.saveLogAppender(logAppender); if (saved != null) { Notification thriftNotification = new Notification(); thriftNotification.setAppId(saved.getApplicationId()); thriftNotification.setAppenderId(saved.getId()); if (logAppender.getId() == null) { LOG.info("Add new log appender ..."); thriftNotification.setOp(Operation.ADD_LOG_APPENDER); LOG.info("Send notification to operation servers about new appender."); } else { thriftNotification.setOp(Operation.UPDATE_LOG_APPENDER); LOG.info("Send notification to operation servers about update appender configuration."); } controlZkService.sendEndpointNotification(thriftNotification); } } return saved; }
@Override public void deleteUserVerifier(String userVerifierId) throws ControlServiceException { UserVerifierDto userVerifierDto = userVerifierService.findUserVerifierById(userVerifierId); LOG.info("Remove user verifier ..."); userVerifierService.removeUserVerifierById(userVerifierId); Notification thriftNotification = new Notification(); thriftNotification.setAppId(userVerifierDto.getApplicationId()); thriftNotification.setUserVerifierToken(userVerifierDto.getVerifierToken()); thriftNotification.setOp(Operation.REMOVE_USER_VERIFIER); LOG.info("Send notification to operation servers about removing user verifier."); controlZkService.sendEndpointNotification(thriftNotification); }
@Override public void deleteLogAppender(String logAppenderId) throws ControlServiceException { LogAppenderDto logAppenderDto = logAppenderService.findLogAppenderById(logAppenderId); LOG.info("Remove log appender ..."); logAppenderService.removeLogAppenderById(logAppenderId); Notification thriftNotification = new Notification(); thriftNotification.setAppId(logAppenderDto.getApplicationId()); thriftNotification.setAppenderId(logAppenderDto.getId()); thriftNotification.setOp(Operation.REMOVE_LOG_APPENDER); LOG.info("Send notification to operation servers about removing appender."); controlZkService.sendEndpointNotification(thriftNotification); }
@Override public ApplicationDto editApplication(ApplicationDto application) throws ControlServiceException { ApplicationDto storedApplication = applicationService .findAppByApplicationToken(application.getApplicationToken()); if (storedApplication != null) { application.setId(storedApplication.getId()); } boolean update = !isEmpty(application.getId()); ApplicationDto appDto = applicationService.saveApp(application); if (update) { LOG.info("[{}] Broadcasting notification about application {} update.", application.getId(), application.getApplicationToken()); Notification thriftNotification = new Notification(); thriftNotification.setAppId(appDto.getId()); thriftNotification.setAppSeqNumber(appDto.getSequenceNumber()); thriftNotification.setOp(Operation.APP_UPDATE); controlZkService.sendEndpointNotification(thriftNotification); } return appDto; }
private <T> Notification toNotification(UpdateNotificationDto<T> notification) { Notification thriftNotification = new Notification(); thriftNotification.setAppId(notification.getAppId()); thriftNotification.setAppSeqNumber(notification.getAppSeqNumber()); thriftNotification.setGroupId(notification.getGroupId()); thriftNotification.setGroupSeqNumber(notification.getGroupSeqNumber()); thriftNotification.setTopicId(notification.getTopicId()); thriftNotification.setOp(getOperation(notification.getChangeType())); T payload = notification.getPayload(); if (payload != null) { if (payload instanceof NotificationDto) { NotificationDto dto = (NotificationDto) payload; thriftNotification.setNotificationId(dto.getId()); } } return thriftNotification; }
unsetOp(); } else { setOp((Operation)value);