org.apache.sling.discovery.impl.topology.announcement
Class Announcement

java.lang.Object
  extended by org.apache.sling.discovery.impl.topology.announcement.Announcement

public class Announcement
extends Object

An announcement is the information exchanged by the topology connector and contains all clusters and instances which both the topology connector client and servlet see (in their part before joining the two worlds).

An announcement is exchanged in json format and carries a timeout.


Constructor Summary
Announcement(String ownerId)
           
Announcement(String ownerId, int protocolVersion)
           
 
Method Summary
 void addIncomingTopologyAnnouncement(Announcement incomingTopologyAnnouncement)
          adds an incoming announcement to this announcement
 String asJSON()
          Convert this announcement into json
 org.apache.sling.commons.json.JSONObject asJSONObject()
          Convert this announcement into a json object
 boolean correspondsTo(Announcement announcement)
          Compare this Announcement with another one, ignoring the 'created' property - which gets added to the JSON object automatically due to SLING-3389 wire-backwards-compatibility - and backoffInterval introduced as part of SLING-3382
static Announcement fromJSON(String topologyAnnouncementJSON)
          Create an announcement form json
 long getBackoffInterval()
          Gets the backoffInterval which the connector servlets passes back to the client to use as the next heartbeatInterval
 String getOwnerId()
          Returns the slingid of the owner of this announcement.
 String getPrimaryKey()
          the key which is unique to this announcement
 int getProtocolVersion()
          Returns the protocolVersion of this announcement
 boolean getResetBackoff()
          gets the resetBackoff flag
 String getServerInfo()
          the information about the server where this announcement came from
 boolean isCorrectVersion()
          check whether this is announcement contains the valid protocol version
 boolean isInherited()
          Returns the inherited flag - if true this means that this announcement is the response of a topology connect
 boolean isLoop()
          Returns the loop flag - set when this announcement represents a loop detected in the topology connectors
 boolean isValid()
          check whether this is a valid announcement, containing the minimal information
 Collection<org.apache.sling.discovery.InstanceDescription> listInstances()
          Returns the list of instances that are contained in this announcement
 void persistTo(org.apache.sling.api.resource.Resource announcementsResource)
          Persists this announcement using the given 'announcements' resource, under which a node with the primary key is created
 void removeInherited(String ownerId)
          Remove all announcements that match the given owner Id
 void setBackoffInterval(long backoffInterval)
          Sets the backoffInterval which the connector servlets passes back to the client to use as the next heartbeatInterval
 void setInherited(boolean inherited)
          set the inherited flag - if true this means this announcement is the response of a topology connect
 void setLocalCluster(org.apache.sling.discovery.ClusterView localCluster)
          sets the local clusterview
 void setLoop(boolean loop)
          Sets the loop falg - set true when this announcement should represent a loop detected in the topology connectors
 void setResetBackoff(boolean resetBackoff)
          sets the resetBackoff flag
 void setServerInfo(String serverInfo)
          sets the information about the server where this announcement came from
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Announcement

public Announcement(String ownerId)

Announcement

public Announcement(String ownerId,
                    int protocolVersion)
Method Detail

toString

public String toString()
Overrides:
toString in class Object

isCorrectVersion

public boolean isCorrectVersion()
check whether this is announcement contains the valid protocol version


isValid

public boolean isValid()
check whether this is a valid announcement, containing the minimal information


setInherited

public void setInherited(boolean inherited)
set the inherited flag - if true this means this announcement is the response of a topology connect


isInherited

public boolean isInherited()
Returns the inherited flag - if true this means that this announcement is the response of a topology connect


setLoop

public void setLoop(boolean loop)
Sets the loop falg - set true when this announcement should represent a loop detected in the topology connectors


setBackoffInterval

public void setBackoffInterval(long backoffInterval)
Sets the backoffInterval which the connector servlets passes back to the client to use as the next heartbeatInterval


getBackoffInterval

public long getBackoffInterval()
Gets the backoffInterval which the connector servlets passes back to the client to use as the next heartbeatInterval


setResetBackoff

public void setResetBackoff(boolean resetBackoff)
sets the resetBackoff flag


getResetBackoff

public boolean getResetBackoff()
gets the resetBackoff flag


isLoop

public boolean isLoop()
Returns the loop flag - set when this announcement represents a loop detected in the topology connectors


getProtocolVersion

public int getProtocolVersion()
Returns the protocolVersion of this announcement


setServerInfo

public void setServerInfo(String serverInfo)
sets the information about the server where this announcement came from


getServerInfo

public String getServerInfo()
the information about the server where this announcement came from


getOwnerId

public String getOwnerId()
Returns the slingid of the owner of this announcement.

The owner is the instance which initiated the topology connection


asJSONObject

public org.apache.sling.commons.json.JSONObject asJSONObject()
                                                      throws org.apache.sling.commons.json.JSONException
Convert this announcement into a json object

Throws:
org.apache.sling.commons.json.JSONException

fromJSON

public static Announcement fromJSON(String topologyAnnouncementJSON)
                             throws org.apache.sling.commons.json.JSONException
Create an announcement form json

Throws:
org.apache.sling.commons.json.JSONException

setLocalCluster

public void setLocalCluster(org.apache.sling.discovery.ClusterView localCluster)
sets the local clusterview


addIncomingTopologyAnnouncement

public void addIncomingTopologyAnnouncement(Announcement incomingTopologyAnnouncement)
adds an incoming announcement to this announcement


asJSON

public String asJSON()
              throws org.apache.sling.commons.json.JSONException
Convert this announcement into json

Throws:
org.apache.sling.commons.json.JSONException

getPrimaryKey

public String getPrimaryKey()
the key which is unique to this announcement


listInstances

public Collection<org.apache.sling.discovery.InstanceDescription> listInstances()
Returns the list of instances that are contained in this announcement


persistTo

public void persistTo(org.apache.sling.api.resource.Resource announcementsResource)
               throws org.apache.sling.api.resource.PersistenceException,
                      org.apache.sling.commons.json.JSONException
Persists this announcement using the given 'announcements' resource, under which a node with the primary key is created

Throws:
org.apache.sling.api.resource.PersistenceException
org.apache.sling.commons.json.JSONException

removeInherited

public void removeInherited(String ownerId)
Remove all announcements that match the given owner Id


correspondsTo

public boolean correspondsTo(Announcement announcement)
                      throws org.apache.sling.commons.json.JSONException
Compare this Announcement with another one, ignoring the 'created' property - which gets added to the JSON object automatically due to SLING-3389 wire-backwards-compatibility - and backoffInterval introduced as part of SLING-3382

Throws:
org.apache.sling.commons.json.JSONException


Copyright © 2007–2014 The Apache Software Foundation. All rights reserved.