@Bean public PropertyPathEndpoint propertyPathEndpoint(BusProperties busProperties) { return new PropertyPathEndpoint(new CompositePropertyPathNotificationExtractor(this.extractors), busProperties.getId()); }
public String getApplicationId() { return bus.getId(); }
private Void updateLastTargetQueries(final String tenant, final List<TargetPoll> polls) { LOG.debug("Persist {} targetqueries.", polls.size()); final List<List<String>> pollChunks = Lists.partition( polls.stream().map(TargetPoll::getControllerId).collect(Collectors.toList()), Constants.MAX_ENTRIES_IN_STATEMENT); pollChunks.forEach(chunk -> { setLastTargetQuery(tenant, System.currentTimeMillis(), chunk); chunk.forEach(controllerId -> afterCommit.afterCommit( () -> eventPublisher.publishEvent(new TargetPollEvent(controllerId, tenant, bus.getId())))); }); return null; }
@Bean public ServiceMatcher serviceMatcher(@BusPathMatcher PathMatcher pathMatcher, BusProperties properties, Environment environment) { String[] configNames = environment.getProperty(CLOUD_CONFIG_NAME_PROPERTY, String[].class, new String[] {}); ServiceMatcher serviceMatcher = new ServiceMatcher(pathMatcher, properties.getId(), configNames); return serviceMatcher; }
@Bean public ServiceMatcher serviceMatcher(@BusPathMatcher PathMatcher pathMatcher, BusProperties properties, Environment environment) { String[] configNames = environment.getProperty(CLOUD_CONFIG_NAME_PROPERTY, String[].class, new String[] {}); ServiceMatcher serviceMatcher = new ServiceMatcher(pathMatcher, properties.getId(), configNames); return serviceMatcher; }
@Bean @ConditionalOnEnabledEndpoint public EnvironmentBusEndpoint environmentBusEndpoint( ApplicationContext context, BusProperties bus) { return new EnvironmentBusEndpoint(context, bus.getId()); } }
@Bean @ConditionalOnEnabledEndpoint public RefreshBusEndpoint refreshBusEndpoint(ApplicationContext context, BusProperties bus) { return new RefreshBusEndpoint(context, bus.getId()); } }
@Bean @ConditionalOnEnabledEndpoint public RefreshBusEndpoint refreshBusEndpoint(ApplicationContext context, BusProperties bus) { return new RefreshBusEndpoint(context, bus.getId()); } }
private void sendRolloutGroupDeletedEvents(final JpaRollout rollout) { final List<Long> groupIds = rollout.getRolloutGroups().stream().map(RolloutGroup::getId) .collect(Collectors.toList()); afterCommit.afterCommit(() -> groupIds.forEach(rolloutGroupId -> eventPublisher .publishEvent(new RolloutGroupDeletedEvent(tenantAware.getCurrentTenant(), rolloutGroupId, JpaRolloutGroup.class.getName(), bus.getId())))); }
/** * Sends the {@link CancelTargetAssignmentEvent} for a specific target to * the eventPublisher. * * @param target * the Target which has been assigned to a distribution set * @param actionId * the action id of the assignment */ void cancelAssignDistributionSetEvent(final Target target, final Long actionId) { afterCommit.afterCommit( () -> eventPublisher.publishEvent(new CancelTargetAssignmentEvent(target, actionId, bus.getId()))); }
@Bean @ConditionalOnEnabledEndpoint public EnvironmentBusEndpoint environmentBusEndpoint( ApplicationContext context, BusProperties bus) { return new EnvironmentBusEndpoint(context, bus.getId()); } }
private void cancelAssignDistributionSetEvent(final JpaTarget target, final Long actionId) { afterCommit.afterCommit( () -> eventPublisher.publishEvent(new CancelTargetAssignmentEvent(target, actionId, bus.getId()))); } }
protected void sendTargetAssignDistributionSetEvent(final String tenant, final long distributionSetId, final List<Action> actions) { if (CollectionUtils.isEmpty(actions)) { return; } afterCommit.afterCommit(() -> eventPublisher.publishEvent(new TargetAssignDistributionSetEvent(tenant, distributionSetId, actions, bus.getId(), actions.get(0).isMaintenanceWindowAvailable()))); }
protected void sendTargetUpdatedEvent(final JpaTarget target) { afterCommit.afterCommit(() -> eventPublisher.publishEvent(new TargetUpdatedEvent(target, bus.getId()))); }
@Bean public PropertyPathEndpoint propertyPathEndpoint(BusProperties busProperties) { return new PropertyPathEndpoint(new CompositePropertyPathNotificationExtractor(this.extractors), busProperties.getId()); }
@Override @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) public void delete(final Collection<Long> targetIDs) { final List<JpaTarget> targets = targetRepository.findAllById(targetIDs); if (targets.size() < targetIDs.size()) { throw new EntityNotFoundException(Target.class, targetIDs, targets.stream().map(Target::getId).collect(Collectors.toList())); } targetRepository.deleteByIdIn(targetIDs); afterCommit.afterCommit(() -> targets.forEach(target -> eventPublisher.publishEvent( new TargetDeletedEvent(tenantAware.getCurrentTenant(), target.getId(), target.getControllerId(), Optional.ofNullable(target.getAddress()).map(URI::toString).orElse(null), JpaTarget.class.getName(), bus.getId())))); }
@Override public void requestControllerAttributes(final String controllerId) { final JpaTarget target = getByControllerIdAndThrowIfNotFound(controllerId); target.setRequestControllerAttributes(true); eventPublisher.publishEvent(new TargetAttributesRequestedEvent(tenantAware.getCurrentTenant(), target.getId(), target.getControllerId(), target.getAddress() != null ? target.getAddress().toString() : null, JpaTarget.class.getName(), bus.getId())); }
private void requestControllerAttributes(final String controllerId) { final JpaTarget target = (JpaTarget) getByControllerId(controllerId) .orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId)); target.setRequestControllerAttributes(true); eventPublisher.publishEvent(new TargetAttributesRequestedEvent(tenantAware.getCurrentTenant(), target.getId(), target.getControllerId(), target.getAddress() != null ? target.getAddress().toString() : null, JpaTarget.class.getName(), bus.getId())); }
@Override @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) public void deleteMetaData(final String controllerId, final String key) { final JpaTargetMetadata metadata = (JpaTargetMetadata) getMetaDataByControllerId(controllerId, key) .orElseThrow(() -> new EntityNotFoundException(TargetMetadata.class, controllerId, key)); final JpaTarget target = touch(controllerId); targetMetadataRepository.deleteById(metadata.getId()); // target update event is set to ignore "lastModifiedAt" field so it is // not send automatically within the touch() method eventPublisher.publishEvent(new TargetUpdatedEvent(target, bus.getId())); }
@Override @Transactional @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) public Target findOrRegisterTargetIfItDoesNotexist(final String controllerId, final URI address) { final Specification<JpaTarget> spec = (targetRoot, query, cb) -> cb .equal(targetRoot.get(JpaTarget_.controllerId), controllerId); final Optional<JpaTarget> target = targetRepository.findOne(spec); if (!target.isPresent()) { final Target result = targetRepository.save((JpaTarget) entityFactory.target().create() .controllerId(controllerId).description("Plug and Play target: " + controllerId).name(controllerId) .status(TargetUpdateStatus.REGISTERED).lastTargetQuery(System.currentTimeMillis()) .address(Optional.ofNullable(address).map(URI::toString).orElse(null)).build()); afterCommit.afterCommit(() -> eventPublisher.publishEvent(new TargetPollEvent(result, bus.getId()))); return result; } return updateTargetStatus(target.get(), address); }