@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); }
public Object getFieldValue(_Fields field) { switch (field) { case APP_ID: return getAppId(); return getAppSeqNumber(); return getGroupId(); return getGroupSeqNumber(); return getProfileFilterId(); return getProfileFilterSeqNumber(); return getConfigurationId(); return getConfigurationSeqNumber(); return getNotificationId(); return getTopicId(); return getOp(); return getAppenderId(); return getUserVerifierToken();
@Override public void read(org.apache.thrift.protocol.TProtocol prot, onNotification_args struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.notification = new Notification(); struct.notification.read(iprot); struct.setNotificationIsSet(true); } } }
/** * Notify endpoints. * * @param notification the notification * @param profileFilter the profile filter * @param configuration the configuration */ private void notifyEndpoints(ChangeNotificationDto notification, ProfileFilterDto profileFilter, ConfigurationDto configuration) { Notification thriftNotification = new Notification(); thriftNotification.setAppId(notification.getAppId()); thriftNotification.setAppSeqNumber(notification.getAppSeqNumber()); thriftNotification.setGroupId(notification.getGroupId()); thriftNotification.setGroupSeqNumber(notification.getGroupSeqNumber()); if (profileFilter != null) { thriftNotification.setProfileFilterId(profileFilter.getId()); thriftNotification.setProfileFilterSeqNumber(profileFilter.getSequenceNumber()); } if (configuration != null) { thriftNotification.setConfigurationId(configuration.getId()); thriftNotification.setConfigurationSeqNumber(configuration.getSequenceNumber()); } controlZkService.sendEndpointNotification(thriftNotification); }
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; }
@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); }
ApplicationDto appDto = applicationService.findAppById(notification.getAppId()); LOG.debug("Processing cache notification {} for app {}", notification, appDto); if (appDto != null) { if (notification.getOp() == Operation.APP_UPDATE) { LOG.debug("Reseting application info {}", appDto.getId()); cacheService.resetAppById(appDto.getId()); return; if (notification.getProfileFilterId() != null) { ProfileFilterDto filterDto = cacheService.getFilter(notification.getProfileFilterId()); LOG.debug("Processing filter {}", filterDto); if (filterDto.getEndpointProfileSchemaId() != null if (notification.getGroupId() != null) { cacheService.resetGroup(notification.getGroupId()); if (notification.getAppSeqNumber() != 0) { LOG.debug("Going to update application {} with seqNumber {} in thread {}", appDto.getApplicationToken(), notification.getAppSeqNumber(), Thread.currentThread().getId()); synchronized (cacheService) { int currentSeqNumber = cacheService.getAppSeqNumber( appDto.getApplicationToken()).getSeqNumber(); if (currentSeqNumber < notification.getAppSeqNumber()) { cacheService.putAppSeqNumber( appDto.getApplicationToken(), new AppSeqNumber(appDto.getTenantId(), appDto.getId(), appDto.getApplicationToken(), notification.getAppSeqNumber())); LOG.debug("Update application {} with seqNumber {} in thread {}",
@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; }
protected void processLogAppenderNotification(Notification notification) { LOG.debug("Process log appender notification [{}]", notification); String appenderId = notification.getAppenderId(); switch (notification.getOp()) { case ADD_LOG_APPENDER: addLogAppender(appenderId); break; case REMOVE_LOG_APPENDER: removeLogAppender(appenderId); break; case UPDATE_LOG_APPENDER: removeLogAppender(appenderId); addLogAppender(appenderId); break; default: LOG.debug("[{}][{}] Operation [{}] is not supported.", applicationToken, appenderId, notification.getOp()); } }
/** * Process a notification. * * @param notification notification */ public void processNotification(Notification notification) { LOG.debug("Process user verifier notification [{}]", notification); String verifierToken = notification.getUserVerifierToken(); switch (notification.getOp()) { case ADD_USER_VERIFIER: addUserVerifier(verifierToken); break; case REMOVE_USER_VERIFIER: removeUserVerifier(verifierToken); break; case UPDATE_USER_VERIFIER: removeUserVerifier(verifierToken); addUserVerifier(verifierToken); break; default: LOG.debug("[{}][{}] Operation [{}] is not supported.", applicationId, verifierToken, notification.getOp()); } }
public Notification deepCopy() { return new Notification(this); }
@Override public void onNotification(Notification notification) throws TException { LOG.debug("Received Notification from control service {}", notification); LOG.debug("Going to notify cache service.."); processCacheNotification(notification); if (notification.getOp() != Operation.APP_UPDATE) { LOG.debug("Going to notify akka service.."); akkaService.onNotification(notification); } }
@Override public void onNotification(Notification notification) { ApplicationDto applicationDto = context.getApplicationService() .findAppById(notification.getAppId()); if (applicationDto != null) { LOG.debug("Sending message {} to EPS actor", notification); opsActor.tell(new ThriftNotificationMessage( applicationDto.getApplicationToken(), notification), ActorRef.noSender()); } else { LOG.warn("Can't find corresponding application for: {}", notification); } }
/** * Send to specific topic. * * @param message the message */ private void sendToSpecificTopic(ThriftNotificationMessage message) { Notification notification = message.getNotification(); ActorRef topicActor = getOrCreateTopic(notification.getTopicId()); topicActor.tell(message, self()); }
/** * Broadcast to all endpoints. * * @param message the message */ private void broadcastToAllEndpoints(ThriftNotificationMessage message) { String notificationId = message.getNotification().getNotificationId(); NotificationDto notificationDto = notificationService.findNotificationById(notificationId); if (notificationDto == null) { LOG.warn("Can't find notification by id {}. Probably it has already expired!"); } else { notificationCache.put(notificationDto.getSecNum(), notificationDto); LOG.debug("[{}] Put notification to topic actor cache {}", notificationDto.getTopicId(), notificationDto); NotificationMessage notificationMessage = NotificationMessage.fromNotifications( Collections.singletonList(notificationDto)); for (ActorInfo endpoint : endpointSessions.values()) { if (isSchemaVersionMatch( notificationDto, endpoint.getSystemNfVersion(), endpoint.getUserNfVersion())) { endpoint.getActorRef().tell(notificationMessage, self()); } } } }
@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; }
public void read(org.apache.thrift.protocol.TProtocol iprot, onNotification_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // NOTIFICATION if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.notification = new Notification(); struct.notification.read(iprot); struct.setNotificationIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); }
/** * Performs a deep copy on <i>other</i>. */ public onNotification_args(onNotification_args other) { if (other.isSetNotification()) { this.notification = new Notification(other.notification); } }
@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; }