org.jboss.system.server.profileservice.repository.clustered.sync
Class AbstractSynchronizationPolicy

java.lang.Object
  extended by org.jboss.system.server.profileservice.repository.clustered.sync.AbstractSynchronizationPolicy
All Implemented Interfaces:
SynchronizationPolicy

public abstract class AbstractSynchronizationPolicy
extends Object
implements SynchronizationPolicy

Abstract base class to support implementations of SynchronizationPolicy.

Implements the various RepositorySynchronizationPolicy acceptXXX methods by checking if a Boolean property has been set dictating the response; if not delegates the call to one of the abstract protected methods that subclasses implement.

Version:
$Revision: $
Author:
Brian Stansberry

Field Summary
static long DEFAULT_REMOVAL_TRACKING_TIME
          Default value for getRemovalTrackingTime(), equal to 30 days.
 
Constructor Summary
AbstractSynchronizationPolicy()
           
 
Method Summary
protected abstract  boolean acceptAddition(RepositoryItemMetadata toAdd, RepositoryItemMetadata joinersPrevious, boolean merge)
           
 boolean acceptJoinAddition(RepositoryItemMetadata toAdd, RepositoryItemMetadata joinersPrevious)
          Should the item represented by toAdd that is available on a newly joining node be accepted for use around the cluster when the cluster's records show no record of an item with the same path? Such a case potentially could mean newly joining node was unaware of an earlier removal that occurred while it was offline and that the cluster has also purged from its records.
 boolean acceptJoinReincarnation(RepositoryItemMetadata reincarnation, RepositoryItemMetadata current)
          Should the item represented by reincarnation that is available on a newly joining node be accepted for use around the cluster when the cluster's records show an item with the same path was previously removed? Such a case potentially could mean the newly joining node was unaware of a removal that occurred while it was offline.
 boolean acceptJoinRemoval(RepositoryItemMetadata current, RepositoryItemMetadata joinersItem)
          Should the item represented by toRemovethat is unavailable on a merging set of nodes be removed from around the cluster when the cluster's records show an item with the same path? Such a case potentially could mean the newly joining node was unaware of a new deployment of the item that occurred while it was offline.
 boolean acceptJoinUpdate(RepositoryItemMetadata update, RepositoryItemMetadata current)
          Should the item represented by update that is available on a newly joining node be accepted for use around the cluster when the cluster's records show an item with the same path with a different version? Such a case potentially could mean the newly joining node was unaware of changes that occurred while it was offline.
 boolean acceptMergeAddition(RepositoryItemMetadata toAdd)
          Should the item represented by toAdd that is available on a merging set of nodes be accepted for use around the cluster when the cluster's records show no record of an item with the same path? Such a case potentially could mean the merging nodes were unaware of an earlier removal that occurred while the cluster was split and that the cluster has also purged from its records.
 boolean acceptMergeReincarnation(RepositoryItemMetadata reincarnation, RepositoryItemMetadata current)
          Should the item represented by reincarnation that is available on a merging set of nodes be accepted for use around the cluster when the cluster's records show an item with the same path was previously removed? Such a case potentially could mean the merging nodes were unaware of a removal that occurred while the cluster was split.
 boolean acceptMergeRemoval(RepositoryItemMetadata current, RepositoryItemMetadata mergersView)
          Should the item represented by toRemove that is unavailable on a newly joining node be removed from around the cluster when the cluster's records show an item with the same path? Such a case potentially could mean the newly joining node was unaware of a new deployment of the item that occurred while the cluster was split.
 boolean acceptMergeUpdate(RepositoryItemMetadata update, RepositoryItemMetadata current)
          Should the item represented by update that is available on a merging set of nodes be accepted for use around the cluster when the cluster's records show an item with the same path with a different version? Such a case potentially could mean the merging nodes were unaware of changes that occurred while the cluster was split.
protected abstract  boolean acceptReincarnation(RepositoryItemMetadata reincarnation, RepositoryItemMetadata current, boolean merge)
           
protected abstract  boolean acceptRemoval(RepositoryItemMetadata current, RepositoryItemMetadata sendersView, boolean merge)
           
protected abstract  boolean acceptUpdate(RepositoryItemMetadata update, RepositoryItemMetadata current, boolean merge)
           
 Boolean getAllowJoinAdditions()
          Gets any fixed response to acceptJoinAddition(RepositoryItemMetadata, RepositoryItemMetadata).
 Boolean getAllowJoinReincarnations()
          Gets any fixed response to acceptJoinReincarnation(RepositoryItemMetadata, RepositoryItemMetadata).
 Boolean getAllowJoinRemovals()
          Gets any fixed response to acceptJoinRemoval(RepositoryItemMetadata, RepositoryItemMetadata).
 Boolean getAllowJoinUpdates()
          Gets any fixed response to acceptJoinUpdate(RepositoryItemMetadata, RepositoryItemMetadata).
 Boolean getAllowMergeAdditions()
          Gets any fixed response to acceptMergeAddition(RepositoryItemMetadata).
 Boolean getAllowMergeReincarnations()
          Gets any fixed response to acceptMergeReincarnation(RepositoryItemMetadata, RepositoryItemMetadata).
 Boolean getAllowMergeRemovals()
          Gets any fixed response to acceptMergeRemoval(RepositoryItemMetadata, RepositoryItemMetadata).
 Boolean getAllowMergeUpdates()
          Gets any fixed response to acceptMergeUpdate(RepositoryItemMetadata, RepositoryItemMetadata).
 long getRemovalTrackingTime()
          Gets how long in ms this policy should remembered removed items for use in detecting reincarnations.
 boolean isDeveloperMode()
          Gets whether this policy is in a very lenient "developer mode" in which case it will return true to all acceptXXX calls.
 boolean purgeRemovedItems(RepositoryContentMetadata content)
          Request that the policy remove any RepositoryItemMetadata objects that are listed as removed if the policy no longer wishes to consider them in its decision making.
 void setAllowJoinAdditions(Boolean allow)
          Sets any fixed response to acceptJoinAddition(RepositoryItemMetadata, RepositoryItemMetadata).
 void setAllowJoinReincarnations(Boolean allow)
          Sets any fixed response to acceptJoinReincarnation(RepositoryItemMetadata, RepositoryItemMetadata).
 void setAllowJoinRemovals(Boolean allow)
          Sets any fixed response to acceptJoinRemoval(RepositoryItemMetadata, RepositoryItemMetadata).
 void setAllowJoinUpdates(Boolean allow)
          Sets any fixed response to acceptJoinUpdate(RepositoryItemMetadata, RepositoryItemMetadata).
 void setAllowMergeAdditions(Boolean allow)
          Sets any fixed response to acceptMergeAddition(RepositoryItemMetadata).
 void setAllowMergeReincarnations(Boolean allow)
          Sets any fixed response to acceptMergeReincarnation(RepositoryItemMetadata, RepositoryItemMetadata).
 void setAllowMergeRemovals(Boolean allow)
          Sets any fixed response to acceptMergeRemoval(RepositoryItemMetadata, RepositoryItemMetadata).
 void setAllowMergeUpdates(Boolean allow)
          Sets any fixed response to acceptMergeUpdate(RepositoryItemMetadata, RepositoryItemMetadata).
 void setDeveloperMode(boolean developerMode)
          Sets whether this policy is in a very lenient "developer mode" in which case it will return true to all acceptXXX calls.
 void setRemovalTrackingTime(long removalTrackingTime)
          Sets how long in ms this policy should remembered removed items for use in detecting reincarnations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_REMOVAL_TRACKING_TIME

public static final long DEFAULT_REMOVAL_TRACKING_TIME
Default value for getRemovalTrackingTime(), equal to 30 days.

See Also:
Constant Field Values
Constructor Detail

AbstractSynchronizationPolicy

public AbstractSynchronizationPolicy()
Method Detail

getAllowJoinAdditions

public Boolean getAllowJoinAdditions()
Gets any fixed response to acceptJoinAddition(RepositoryItemMetadata, RepositoryItemMetadata).

Returns:
a fixed response, or null if there is no fixed response and the call should be delegated to acceptAddition(RepositoryItemMetadata, RepositoryItemMetadata, boolean)

setAllowJoinAdditions

public void setAllowJoinAdditions(Boolean allow)
Sets any fixed response to acceptJoinAddition(RepositoryItemMetadata, RepositoryItemMetadata).

Parameters:
allow - the fixed response, or null if there is no fixed response and the call should be delegated to acceptAddition(RepositoryItemMetadata, RepositoryItemMetadata, boolean)

getAllowJoinReincarnations

public Boolean getAllowJoinReincarnations()
Gets any fixed response to acceptJoinReincarnation(RepositoryItemMetadata, RepositoryItemMetadata).

Returns:
a fixed response, or null if there is no fixed response and the call should be delegated to acceptReincarnation(RepositoryItemMetadata, RepositoryItemMetadata, boolean)

setAllowJoinReincarnations

public void setAllowJoinReincarnations(Boolean allow)
Sets any fixed response to acceptJoinReincarnation(RepositoryItemMetadata, RepositoryItemMetadata).

Parameters:
allow - the fixed response, or null if there is no fixed response and the call should be delegated to acceptReincarnation(RepositoryItemMetadata, RepositoryItemMetadata, boolean)

getAllowJoinUpdates

public Boolean getAllowJoinUpdates()
Gets any fixed response to acceptJoinUpdate(RepositoryItemMetadata, RepositoryItemMetadata).

Returns:
a fixed response, or null if there is no fixed response and the call should be delegated to acceptUpdate(RepositoryItemMetadata, RepositoryItemMetadata, boolean)

setAllowJoinUpdates

public void setAllowJoinUpdates(Boolean allow)
Sets any fixed response to acceptJoinUpdate(RepositoryItemMetadata, RepositoryItemMetadata).

Parameters:
allow - the fixed response, or null if there is no fixed response and the call should be delegated to acceptUpdate(RepositoryItemMetadata, RepositoryItemMetadata, boolean)

getAllowJoinRemovals

public Boolean getAllowJoinRemovals()
Gets any fixed response to acceptJoinRemoval(RepositoryItemMetadata, RepositoryItemMetadata).

Returns:
a fixed response, or null if there is no fixed response and the call should be delegated to acceptRemoval(RepositoryItemMetadata, RepositoryItemMetadata, boolean)

setAllowJoinRemovals

public void setAllowJoinRemovals(Boolean allow)
Sets any fixed response to acceptJoinRemoval(RepositoryItemMetadata, RepositoryItemMetadata).

Parameters:
allow - the fixed response, or null if there is no fixed response and the call should be delegated to acceptRemoval(RepositoryItemMetadata, RepositoryItemMetadata, boolean)

getAllowMergeAdditions

public Boolean getAllowMergeAdditions()
Gets any fixed response to acceptMergeAddition(RepositoryItemMetadata).

Returns:
a fixed response, or null if there is no fixed response and the call should be delegated to acceptAddition(RepositoryItemMetadata, RepositoryItemMetadata, boolean)

setAllowMergeAdditions

public void setAllowMergeAdditions(Boolean allow)
Sets any fixed response to acceptMergeAddition(RepositoryItemMetadata).

Parameters:
allow - the fixed response, or null if there is no fixed response and the call should be delegated to acceptAddition(RepositoryItemMetadata, RepositoryItemMetadata, boolean)

getAllowMergeReincarnations

public Boolean getAllowMergeReincarnations()
Gets any fixed response to acceptMergeReincarnation(RepositoryItemMetadata, RepositoryItemMetadata).

Returns:
a fixed response, or null if there is no fixed response and the call should be delegated to acceptReincarnation(RepositoryItemMetadata, RepositoryItemMetadata, boolean)

setAllowMergeReincarnations

public void setAllowMergeReincarnations(Boolean allow)
Sets any fixed response to acceptMergeReincarnation(RepositoryItemMetadata, RepositoryItemMetadata).

Parameters:
allow - the fixed response, or null if there is no fixed response and the call should be delegated to acceptReincarnation(RepositoryItemMetadata, RepositoryItemMetadata, boolean)

getAllowMergeUpdates

public Boolean getAllowMergeUpdates()
Gets any fixed response to acceptMergeUpdate(RepositoryItemMetadata, RepositoryItemMetadata).

Returns:
a fixed response, or null if there is no fixed response and the call should be delegated to acceptUpdate(RepositoryItemMetadata, RepositoryItemMetadata, boolean)

setAllowMergeUpdates

public void setAllowMergeUpdates(Boolean allow)
Sets any fixed response to acceptMergeUpdate(RepositoryItemMetadata, RepositoryItemMetadata).

Parameters:
allow - the fixed response, or null if there is no fixed response and the call should be delegated to acceptUpdate(RepositoryItemMetadata, RepositoryItemMetadata, boolean)

getAllowMergeRemovals

public Boolean getAllowMergeRemovals()
Gets any fixed response to acceptMergeRemoval(RepositoryItemMetadata, RepositoryItemMetadata).

Returns:
a fixed response, or null if there is no fixed response and the call should be delegated to acceptRemoval(RepositoryItemMetadata, RepositoryItemMetadata, boolean)

setAllowMergeRemovals

public void setAllowMergeRemovals(Boolean allow)
Sets any fixed response to acceptMergeRemoval(RepositoryItemMetadata, RepositoryItemMetadata).

Parameters:
allow - the fixed response, or null if there is no fixed response and the call should be delegated to acceptRemoval(RepositoryItemMetadata, RepositoryItemMetadata, boolean)

isDeveloperMode

public boolean isDeveloperMode()
Gets whether this policy is in a very lenient "developer mode" in which case it will return true to all acceptXXX calls. The purpose of this is to eliminate any need for development servers to coordinate system timestamps.

Returns:
true if the policy is in developer mode.

setDeveloperMode

public void setDeveloperMode(boolean developerMode)
Sets whether this policy is in a very lenient "developer mode" in which case it will return true to all acceptXXX calls. The purpose of this is to eliminate any need for development servers to coordinate system timestamps.

Parameters:
developerMode - true if the policy should be in developer mode.

getRemovalTrackingTime

public long getRemovalTrackingTime()
Gets how long in ms this policy should remembered removed items for use in detecting reincarnations. Default is DEFAULT_REMOVAL_TRACKING_TIME.

Returns:
the number of ms, or a number less than 1 to indicate removed items should not be remembered.

setRemovalTrackingTime

public void setRemovalTrackingTime(long removalTrackingTime)
Sets how long in ms this policy should remembered removed items for use in detecting reincarnations. Default is DEFAULT_REMOVAL_TRACKING_TIME.

Parameters:
removalTrackingTime - the number of ms, or a number less than 1 to indicate removed items should not be remembered.

acceptJoinAddition

public boolean acceptJoinAddition(RepositoryItemMetadata toAdd,
                                  RepositoryItemMetadata joinersPrevious)
Description copied from interface: SynchronizationPolicy
Should the item represented by toAdd that is available on a newly joining node be accepted for use around the cluster when the cluster's records show no record of an item with the same path? Such a case potentially could mean newly joining node was unaware of an earlier removal that occurred while it was offline and that the cluster has also purged from its records.

Specified by:
acceptJoinAddition in interface SynchronizationPolicy
Parameters:
toAdd - the item to add
joinersPrevious - information, if available, on the timestamp of the item that was present on the joining node when it stopped. May be null, indicating the joining node was unaware of the item when stopped.
Returns:
true if the addition should be accepted

acceptJoinReincarnation

public boolean acceptJoinReincarnation(RepositoryItemMetadata reincarnation,
                                       RepositoryItemMetadata current)
Description copied from interface: SynchronizationPolicy
Should the item represented by reincarnation that is available on a newly joining node be accepted for use around the cluster when the cluster's records show an item with the same path was previously removed? Such a case potentially could mean the newly joining node was unaware of a removal that occurred while it was offline.

Specified by:
acceptJoinReincarnation in interface SynchronizationPolicy
Parameters:
reincarnation - the new version of the item
current - the cluster's current version of the item, showing when it was removed and by whom. The "when" should reflect this node's time of removal, not the time on the node that originated the removal.
Returns:
true if the reincarnation should be accepted

acceptJoinRemoval

public boolean acceptJoinRemoval(RepositoryItemMetadata current,
                                 RepositoryItemMetadata joinersItem)
Description copied from interface: SynchronizationPolicy
Should the item represented by toRemovethat is unavailable on a merging set of nodes be removed from around the cluster when the cluster's records show an item with the same path? Such a case potentially could mean the newly joining node was unaware of a new deployment of the item that occurred while it was offline.

Specified by:
acceptJoinRemoval in interface SynchronizationPolicy
Parameters:
current - the cluster's current version of the item
joinersItem - the joining node's view of item to remove. May be null, indicating the sender is unaware of the item. If not null, the timestamp of this item should reflect when the item was removed, if known. If the time the item was removed is not known, the timestamp should reflect the last known timestamp of the item that was removed.
Returns:
true if the removal should be accepted

acceptJoinUpdate

public boolean acceptJoinUpdate(RepositoryItemMetadata update,
                                RepositoryItemMetadata current)
Description copied from interface: SynchronizationPolicy
Should the item represented by update that is available on a newly joining node be accepted for use around the cluster when the cluster's records show an item with the same path with a different version? Such a case potentially could mean the newly joining node was unaware of changes that occurred while it was offline.

Specified by:
acceptJoinUpdate in interface SynchronizationPolicy
Parameters:
update - the new version of the item
current - the cluster's current version of the item
Returns:
true if the update should be accepted

acceptMergeAddition

public boolean acceptMergeAddition(RepositoryItemMetadata toAdd)
Description copied from interface: SynchronizationPolicy
Should the item represented by toAdd that is available on a merging set of nodes be accepted for use around the cluster when the cluster's records show no record of an item with the same path? Such a case potentially could mean the merging nodes were unaware of an earlier removal that occurred while the cluster was split and that the cluster has also purged from its records.

Specified by:
acceptMergeAddition in interface SynchronizationPolicy
Parameters:
toAdd - the item to add
Returns:
true if the addition should be accepted

acceptMergeReincarnation

public boolean acceptMergeReincarnation(RepositoryItemMetadata reincarnation,
                                        RepositoryItemMetadata current)
Description copied from interface: SynchronizationPolicy
Should the item represented by reincarnation that is available on a merging set of nodes be accepted for use around the cluster when the cluster's records show an item with the same path was previously removed? Such a case potentially could mean the merging nodes were unaware of a removal that occurred while the cluster was split.

Specified by:
acceptMergeReincarnation in interface SynchronizationPolicy
Parameters:
reincarnation - the new version of the item
current - the cluster's current version of the item, showing when it was removed and by whom
Returns:
true if the reincarnation should be accepted

acceptMergeRemoval

public boolean acceptMergeRemoval(RepositoryItemMetadata current,
                                  RepositoryItemMetadata mergersView)
Description copied from interface: SynchronizationPolicy
Should the item represented by toRemove that is unavailable on a newly joining node be removed from around the cluster when the cluster's records show an item with the same path? Such a case potentially could mean the newly joining node was unaware of a new deployment of the item that occurred while the cluster was split.

Specified by:
acceptMergeRemoval in interface SynchronizationPolicy
Parameters:
current - the cluster's current version of the item
mergersView - the merging node's view of item to remove. May be null, indicating the sender is unaware of the item. If not null, the timestamp of this item should reflect when the item was removed, if known. If the time the item was removed is not known, the timestamp should reflect the last known timestamp of the item that was removed.
Returns:
true if the removal should be accepted

acceptMergeUpdate

public boolean acceptMergeUpdate(RepositoryItemMetadata update,
                                 RepositoryItemMetadata current)
Description copied from interface: SynchronizationPolicy
Should the item represented by update that is available on a merging set of nodes be accepted for use around the cluster when the cluster's records show an item with the same path with a different version? Such a case potentially could mean the merging nodes were unaware of changes that occurred while the cluster was split.

Specified by:
acceptMergeUpdate in interface SynchronizationPolicy
Parameters:
update - the new version of the item
current - the cluster's current version of the item
Returns:
true if the update should be accepted

purgeRemovedItems

public boolean purgeRemovedItems(RepositoryContentMetadata content)
Description copied from interface: SynchronizationPolicy
Request that the policy remove any RepositoryItemMetadata objects that are listed as removed if the policy no longer wishes to consider them in its decision making. Used to prevent perpetual growth in the size of the RepositoryContentMetadata by eventually purging records of removed items.

Specified by:
purgeRemovedItems in interface SynchronizationPolicy
Parameters:
content - the content. Cannot be null.
Returns:
true if any items were purged, false if not

acceptAddition

protected abstract boolean acceptAddition(RepositoryItemMetadata toAdd,
                                          RepositoryItemMetadata joinersPrevious,
                                          boolean merge)

acceptReincarnation

protected abstract boolean acceptReincarnation(RepositoryItemMetadata reincarnation,
                                               RepositoryItemMetadata current,
                                               boolean merge)

acceptRemoval

protected abstract boolean acceptRemoval(RepositoryItemMetadata current,
                                         RepositoryItemMetadata sendersView,
                                         boolean merge)

acceptUpdate

protected abstract boolean acceptUpdate(RepositoryItemMetadata update,
                                        RepositoryItemMetadata current,
                                        boolean merge)


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.