Package org.apache.sling.discovery.base.connectors.announcement

# Class AnnouncementRegistryImpl

java.lang.Object
org.apache.sling.discovery.base.connectors.announcement.AnnouncementRegistryImpl

All Implemented Interfaces:
  `AnnouncementRegistry`

public class AnnouncementRegistryImpl extends Object implements AnnouncementRegistry
Default implementation of the AnnouncementRegistry which handles JSON-backed announcements and does so by storing them in a local like /var/discovery/impl/clusterNodes/$slingId/announcement.

## Constructor Summary

Constructors
Constructor
Description
`AnnouncementRegistryImpl()`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`activate()`
`void`
`addAllExcept(Announcement target, org.apache.sling.discovery.ClusterView clusterView, AnnouncementFilter filter)`
Add all registered announcements to the given target announcement that are accepted by the given filter
`void`
`checkExpiredAnnouncements()`
Check for expired announcements and remove any if applicable
`boolean`
`hasActiveAnnouncement(String ownerId)`
Whether or not the given owner has an active (ie not expired) announcement registered
`Collection<Announcement>`
`listAnnouncementsInSameCluster(org.apache.sling.discovery.ClusterView localClusterView)`
list all announcements that were received by instances in the local cluster
`Collection<org.apache.sling.discovery.InstanceDescription>`
`listInstances(org.apache.sling.discovery.ClusterView localClusterView)`
Returns the list of instances contained in all non-expired announcements of this registry
`Collection<Announcement>`
`listLocalAnnouncements()`
list all announcements that were received (incoming or inherited) by this instance
`Collection<CachedAnnouncement>`
`listLocalIncomingAnnouncements()`
list all announcements that this instance received (incoming)
`long`
`registerAnnouncement(Announcement topologyAnnouncement)`
Register the given announcement - and returns the backoff interval (in seconds) for stable connectors - or -1 if the registration was not successful (likely indicating a loop)
`static AnnouncementRegistryImpl`
`testConstructor(org.apache.sling.api.resource.ResourceResolverFactory resourceResolverFactory, org.apache.sling.settings.SlingSettingsService slingSettingsService, BaseConfig config)`
`static AnnouncementRegistryImpl`
`testConstructorAndActivate(org.apache.sling.api.resource.ResourceResolverFactory resourceResolverFactory, org.apache.sling.settings.SlingSettingsService slingSettingsService, BaseConfig config)`
`void`
`unregisterAnnouncement(String ownerId)`
Unregister the announcement owned by the given slingId

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### AnnouncementRegistryImpl

public AnnouncementRegistryImpl()

## Method Details

### testConstructorAndActivate

public static AnnouncementRegistryImpl testConstructorAndActivate(org.apache.sling.api.resource.ResourceResolverFactory resourceResolverFactory, org.apache.sling.settings.SlingSettingsService slingSettingsService, BaseConfig config)

### testConstructor

public static AnnouncementRegistryImpl testConstructor(org.apache.sling.api.resource.ResourceResolverFactory resourceResolverFactory, org.apache.sling.settings.SlingSettingsService slingSettingsService, BaseConfig config)

### activate

protected void activate()

### unregisterAnnouncement

public void unregisterAnnouncement(String ownerId)
Description copied from interface: `AnnouncementRegistry`
Unregister the announcement owned by the given slingId

Specified by:
  `unregisterAnnouncement` in interface `AnnouncementRegistry`

### listLocalAnnouncements

public Collection<Announcement> listLocalAnnouncements()
Description copied from interface: `AnnouncementRegistry`
list all announcements that were received (incoming or inherited) by this instance

Specified by:
  `listLocalAnnouncements` in interface `AnnouncementRegistry`

### listLocalIncomingAnnouncements

public Collection<CachedAnnouncement> listLocalIncomingAnnouncements()
Description copied from interface: `AnnouncementRegistry`
list all announcements that this instance received (incoming)

Specified by:
  `listLocalIncomingAnnouncements` in interface `AnnouncementRegistry`

### listAnnouncementsInSameCluster

public Collection<Announcement> listAnnouncementsInSameCluster(org.apache.sling.discovery.ClusterView localClusterView)
Description copied from interface: `AnnouncementRegistry`
list all announcements that were received by instances in the local cluster

Specified by:
  `listAnnouncementsInSameCluster` in interface `AnnouncementRegistry`

### hasActiveAnnouncement

public boolean hasActiveAnnouncement(String ownerId)
Description copied from interface: `AnnouncementRegistry`
Whether or not the given owner has an active (ie not expired) announcement registered

Specified by:
  `hasActiveAnnouncement` in interface `AnnouncementRegistry`

### registerAnnouncement

public long registerAnnouncement(Announcement topologyAnnouncement)
Description copied from interface: `AnnouncementRegistry`
Register the given announcement - and returns the backoff interval (in seconds) for stable connectors - or -1 if the registration was not successful (likely indicating a loop)

Specified by:
  `registerAnnouncement` in interface `AnnouncementRegistry`
Returns:
  the backoff interval (in seconds) for stable connectors - or -1 if the registration was not successful (likely indicating a loop)

### addAllExcept

public void addAllExcept(Announcement target, org.apache.sling.discovery.ClusterView clusterView, AnnouncementFilter filter)
Description copied from interface: `AnnouncementRegistry`
Add all registered announcements to the given target announcement that are accepted by the given filter

Specified by:
  `addAllExcept` in interface `AnnouncementRegistry`

### checkExpiredAnnouncements

public void checkExpiredAnnouncements()
Description copied from interface: `AnnouncementRegistry`
Check for expired announcements and remove any if applicable

Specified by:
  `checkExpiredAnnouncements` in interface `AnnouncementRegistry`

### listInstances

public Collection<org.apache.sling.discovery.InstanceDescription> listInstances(org.apache.sling.discovery.ClusterView localClusterView)
Description copied from interface: `AnnouncementRegistry`
Returns the list of instances contained in all non-expired announcements of this registry

Specified by:
  `listInstances` in interface `AnnouncementRegistry`