You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:26:37 UTC
[sling-org-apache-sling-discovery-commons] 34/38: SLING-5191 /
SLING-4603 : rename ConsistencyService to ClusterSyncService - plus making
timeout/interval values for the same configurable in discovery.oak
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.discovery.commons-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-commons.git
commit fc2a80519003cb565b5df55a30956d3fb27b333d
Author: Stefan Egli <st...@apache.org>
AuthorDate: Fri Oct 23 11:50:05 2015 +0000
SLING-5191 / SLING-4603 : rename ConsistencyService to ClusterSyncService - plus making timeout/interval values for the same configurable in discovery.oak
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/commons@1710183 13f79535-47bb-0310-9956-ffa450edef68
---
.../commons/providers/BaseTopologyView.java | 4 +--
.../commons/providers/ViewStateManager.java | 2 +-
.../providers/base/ViewStateManagerFactory.java | 4 +--
.../providers/base/ViewStateManagerImpl.java | 34 +++++++++++-----------
...istencyService.java => ClusterSyncService.java} | 6 ++--
...istencyHistory.java => ClusterSyncHistory.java} | 2 +-
...viceChain.java => ClusterSyncServiceChain.java} | 24 +++++++--------
.../providers/spi/base/DiscoveryLiteConfig.java | 4 +--
...vice.java => OakBacklogClusterSyncService.java} | 26 ++++++++---------
...nsistencyService.java => SyncTokenService.java} | 34 +++++++++++-----------
.../commons/providers/base/ClusterTest.java | 4 +--
.../providers/base/TestMinEventDelayHandler.java | 4 +--
.../providers/base/TestViewStateManager.java | 18 ++++++------
...cyService.java => TestOakSyncTokenService.java} | 14 ++++-----
14 files changed, 90 insertions(+), 90 deletions(-)
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/BaseTopologyView.java b/src/main/java/org/apache/sling/discovery/commons/providers/BaseTopologyView.java
index 67127a2..ccd9988 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/BaseTopologyView.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/BaseTopologyView.java
@@ -52,7 +52,7 @@ public abstract class BaseTopologyView implements TopologyView {
/**
* Returns the id that shall be used in the syncToken
- * by the ConsistencyService.
+ * by the ClusterSyncService.
* <p>
* The clusterSyncId uniquely identifies each change
* of the local cluster for all participating instances.
@@ -72,7 +72,7 @@ public abstract class BaseTopologyView implements TopologyView {
* of the TopologyView for all participating instances
* in the whole topology).
* <p>
- * This id can further safely be used by the ConsistencyService
+ * This id can further safely be used by the ClusterSyncService
* to identify a syncToken that it writes and that all
* other instances in the lcoal cluster wait for, before
* sending a TOPOLOGY_CHANGED event.
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/ViewStateManager.java b/src/main/java/org/apache/sling/discovery/commons/providers/ViewStateManager.java
index 16a70c5..50f20a0 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/ViewStateManager.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/ViewStateManager.java
@@ -26,7 +26,7 @@ import org.apache.sling.discovery.TopologyEventListener;
* The ViewStateManager is at the core of managing TopologyEventListeners,
* the 'view state' (changing vs changed) and sending out the appropriate
* and according TopologyEvents to the registered listeners - depending
- * on the implementation it also supports the ConsistencyService, which is
+ * on the implementation it also supports the ClusterSyncService, which is
* invoked on handleNewView.
*/
public interface ViewStateManager {
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/base/ViewStateManagerFactory.java b/src/main/java/org/apache/sling/discovery/commons/providers/base/ViewStateManagerFactory.java
index 0b9ad02..5df0eea 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/base/ViewStateManagerFactory.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/base/ViewStateManagerFactory.java
@@ -21,7 +21,7 @@ package org.apache.sling.discovery.commons.providers.base;
import java.util.concurrent.locks.Lock;
import org.apache.sling.discovery.commons.providers.ViewStateManager;
-import org.apache.sling.discovery.commons.providers.spi.ConsistencyService;
+import org.apache.sling.discovery.commons.providers.spi.ClusterSyncService;
/**
* Used to create an implementation classes of type ViewStateManager
@@ -31,7 +31,7 @@ import org.apache.sling.discovery.commons.providers.spi.ConsistencyService;
public class ViewStateManagerFactory {
public static ViewStateManager newViewStateManager(Lock lock,
- ConsistencyService consistencyService) {
+ ClusterSyncService consistencyService) {
return new ViewStateManagerImpl(lock, consistencyService);
}
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/base/ViewStateManagerImpl.java b/src/main/java/org/apache/sling/discovery/commons/providers/base/ViewStateManagerImpl.java
index 61b39f6..5930022 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/base/ViewStateManagerImpl.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/base/ViewStateManagerImpl.java
@@ -36,7 +36,7 @@ import org.apache.sling.discovery.TopologyEventListener;
import org.apache.sling.discovery.commons.providers.BaseTopologyView;
import org.apache.sling.discovery.commons.providers.EventHelper;
import org.apache.sling.discovery.commons.providers.ViewStateManager;
-import org.apache.sling.discovery.commons.providers.spi.ConsistencyService;
+import org.apache.sling.discovery.commons.providers.spi.ClusterSyncService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,7 +47,7 @@ import org.slf4j.LoggerFactory;
* <p>
* Note re synchronization: this class rquires a lock object to be passed
* in the constructor - this will be applied to all public methods
- * appropriately. Additionally, the ConsistencyService callback will
+ * appropriately. Additionally, the ClusterSyncService callback will
* also be locked using the provided lock object.
*/
public class ViewStateManagerImpl implements ViewStateManager {
@@ -107,12 +107,12 @@ public class ViewStateManagerImpl implements ViewStateManager {
protected final Lock lock;
/**
- * An optional ConsistencyService can be provided in the constructor which, when set, will
+ * An optional ClusterSyncService can be provided in the constructor which, when set, will
* be invoked upon a new view becoming available (in handleNewView) and the actual
- * TOPOLOGY_CHANGED event will only be sent once the ConsistencyService.sync method
+ * TOPOLOGY_CHANGED event will only be sent once the ClusterSyncService.sync method
* does the according callback (which can be synchronous or asynchronous again).
*/
- private final ConsistencyService consistencyService;
+ private final ClusterSyncService consistencyService;
/**
* A modification counter that increments on each of the following methods:
@@ -123,7 +123,7 @@ public class ViewStateManagerImpl implements ViewStateManager {
* <li>handleNewView()</li>
* </ul>
* with the intent that - when a consistencyService is set - the callback from the
- * ConsistencyService can check if any of the above methods was invoked - and if so,
+ * ClusterSyncService can check if any of the above methods was invoked - and if so,
* it does not send the TOPOLOGY_CHANGED event due to those new facts that happened
* while it was synching with the repository.
*/
@@ -139,13 +139,13 @@ public class ViewStateManagerImpl implements ViewStateManager {
/**
* Creates a new ViewStateManager which synchronizes each method with the given
- * lock and which optionally uses the given ConsistencyService to sync the repository
+ * lock and which optionally uses the given ClusterSyncService to sync the repository
* upon handling a new view where an instances leaves the local cluster.
* @param lock the lock to be used - must not be null
- * @param consistencyService optional (ie can be null) - the ConsistencyService to
+ * @param consistencyService optional (ie can be null) - the ClusterSyncService to
* sync the repository upon handling a new view where an instances leaves the local cluster.
*/
- ViewStateManagerImpl(Lock lock, ConsistencyService consistencyService) {
+ ViewStateManagerImpl(Lock lock, ClusterSyncService consistencyService) {
if (lock==null) {
throw new IllegalArgumentException("lock must not be null");
}
@@ -486,10 +486,10 @@ public class ViewStateManagerImpl implements ViewStateManager {
return true;
}
- final boolean invokeConsistencyService;
+ final boolean invokeClusterSyncService;
if (consistencyService==null) {
- logger.info("handleNewViewNonDelayed: no consistencyService set - continuing directly.");
- invokeConsistencyService = false;
+ logger.info("handleNewViewNonDelayed: no ClusterSyncService set - continuing directly.");
+ invokeClusterSyncService = false;
} else {
// there used to be a distinction between:
// * if no previousView is set, then we should invoke the consistencyService
@@ -503,16 +503,16 @@ public class ViewStateManagerImpl implements ViewStateManager {
//
// which is a long way of saying: if the consistencyService is configured,
// then we always use it, hence:
- logger.info("handleNewViewNonDelayed: consistencyService set - invoking consistencyService");
- invokeConsistencyService = true;
+ logger.info("handleNewViewNonDelayed: ClusterSyncService set - invoking...");
+ invokeClusterSyncService = true;
}
- if (invokeConsistencyService) {
+ if (invokeClusterSyncService) {
// if "instances from the local cluster have been removed"
// then:
// run the set consistencyService
final int lastModCnt = modCnt;
- logger.info("handleNewViewNonDelayed: invoking waitForAsyncEvents, then consistencyService (modCnt={})", modCnt);
+ logger.info("handleNewViewNonDelayed: invoking waitForAsyncEvents, then clusterSyncService (modCnt={})", modCnt);
asyncEventSender.enqueue(new AsyncEvent() {
@Override
@@ -567,7 +567,7 @@ public class ViewStateManagerImpl implements ViewStateManager {
});
} else {
- // otherwise we're either told not to use any ConsistencyService
+ // otherwise we're either told not to use any ClusterSyncService
// or using it is not applicable at this stage - so continue
// with sending the TOPOLOGY_CHANGED (or TOPOLOGY_INIT if there
// are any newly bound topology listeners) directly
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/spi/ConsistencyService.java b/src/main/java/org/apache/sling/discovery/commons/providers/spi/ClusterSyncService.java
similarity index 95%
rename from src/main/java/org/apache/sling/discovery/commons/providers/spi/ConsistencyService.java
rename to src/main/java/org/apache/sling/discovery/commons/providers/spi/ClusterSyncService.java
index 0aec6a8..7bf9ce1 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/spi/ConsistencyService.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/spi/ClusterSyncService.java
@@ -21,7 +21,7 @@ package org.apache.sling.discovery.commons.providers.spi;
import org.apache.sling.discovery.commons.providers.BaseTopologyView;
/**
- * The ConsistencyService can be used to establish strong
+ * The ClusterSyncService can be used to establish strong
* consistency with the underlying (eventually consistent) repository in use.
* <p>
* The issue is described in length in SLING-4627 - the short
@@ -41,7 +41,7 @@ import org.apache.sling.discovery.commons.providers.BaseTopologyView;
* to settle before the topology-dependent activity can continue
* </li>
* </ul>
- * Both of these two aspects are handled by this ConsistencyService.
+ * Both of these two aspects are handled by this ClusterSyncService.
* The former one by introducing a 'sync token' that gets written
* to the repository and on receiving it by the peers they know
* that the writing instance is aware of the ongoing change, that
@@ -54,7 +54,7 @@ import org.apache.sling.discovery.commons.providers.BaseTopologyView;
* is still being deactivated (eg has backlog). So this second
* part is repository dependent.
*/
-public interface ConsistencyService {
+public interface ClusterSyncService {
/**
* Starts the synchronization process and calls the provided
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/ConsistencyHistory.java b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/ClusterSyncHistory.java
similarity index 98%
rename from src/main/java/org/apache/sling/discovery/commons/providers/spi/base/ConsistencyHistory.java
rename to src/main/java/org/apache/sling/discovery/commons/providers/spi/base/ClusterSyncHistory.java
index a6e793b..6526eb2 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/ConsistencyHistory.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/ClusterSyncHistory.java
@@ -27,7 +27,7 @@ import java.util.List;
import org.apache.sling.discovery.commons.providers.BaseTopologyView;
-public class ConsistencyHistory {
+public class ClusterSyncHistory {
class HistoryEntry {
BaseTopologyView view;
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/ConsistencyServiceChain.java b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/ClusterSyncServiceChain.java
similarity index 74%
rename from src/main/java/org/apache/sling/discovery/commons/providers/spi/base/ConsistencyServiceChain.java
rename to src/main/java/org/apache/sling/discovery/commons/providers/spi/base/ClusterSyncServiceChain.java
index 7695fe6..1094f1c 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/ConsistencyServiceChain.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/ClusterSyncServiceChain.java
@@ -23,25 +23,25 @@ import java.util.Iterator;
import java.util.List;
import org.apache.sling.discovery.commons.providers.BaseTopologyView;
-import org.apache.sling.discovery.commons.providers.spi.ConsistencyService;
+import org.apache.sling.discovery.commons.providers.spi.ClusterSyncService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Allows chaining of ConsistencyServices, itself implementing
- * the ConsistencyService interface
+ * Allows chaining of ClusterSyncService, itself implementing
+ * the ClusterSyncService interface
*/
-public class ConsistencyServiceChain implements ConsistencyService {
+public class ClusterSyncServiceChain implements ClusterSyncService {
protected final Logger logger = LoggerFactory.getLogger(getClass());
- private final List<ConsistencyService> chain;
+ private final List<ClusterSyncService> chain;
/**
- * Creates a new chain of ConsistencyServices that calls a
- * cascaded sync with the provided ConsistencyServices.
+ * Creates a new chain of ClusterSyncService that calls a
+ * cascaded sync with the provided ClusterSyncService.
*/
- public ConsistencyServiceChain(ConsistencyService... chain) {
+ public ClusterSyncServiceChain(ClusterSyncService... chain) {
if (chain==null || chain.length==0) {
throw new IllegalArgumentException("chain must be 1 or more");
}
@@ -50,18 +50,18 @@ public class ConsistencyServiceChain implements ConsistencyService {
@Override
public void sync(BaseTopologyView view, Runnable callback) {
- final Iterator<ConsistencyService> chainIt = chain.iterator();
+ final Iterator<ClusterSyncService> chainIt = chain.iterator();
chainedSync(view, callback, chainIt);
}
private void chainedSync(final BaseTopologyView view, final Runnable callback,
- final Iterator<ConsistencyService> chainIt) {
+ final Iterator<ClusterSyncService> chainIt) {
if (!chainIt.hasNext()) {
logger.debug("doSync: done with sync chain, invoking callback");
callback.run();
return;
}
- ConsistencyService next = chainIt.next();
+ ClusterSyncService next = chainIt.next();
next.sync(view, new Runnable() {
@Override
@@ -74,7 +74,7 @@ public class ConsistencyServiceChain implements ConsistencyService {
@Override
public void cancelSync() {
- for (ConsistencyService consistencyService : chain) {
+ for (ClusterSyncService consistencyService : chain) {
consistencyService.cancelSync();
}
}
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/DiscoveryLiteConfig.java b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/DiscoveryLiteConfig.java
index fe811b1..2114a50 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/DiscoveryLiteConfig.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/DiscoveryLiteConfig.java
@@ -39,12 +39,12 @@ public interface DiscoveryLiteConfig {
* Returns the timeout (in milliseconds) to be used when waiting for the sync tokens or id mapping
* @return the timeout (in milliseconds) to be used when waiting for the sync tokens or id mapping
*/
- long getBgTimeoutMillis();
+ long getClusterSyncServiceTimeoutMillis();
/**
* Returns the interval (in milliseconds) to be used when waiting for the sync tokens or id mapping
* @return the interval (in milliseconds) to be used when waiting for the sync tokens or id mapping
*/
- long getBgIntervalMillis();
+ long getClusterSyncServiceIntervalMillis();
}
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogConsistencyService.java b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogClusterSyncService.java
similarity index 90%
rename from src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogConsistencyService.java
rename to src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogClusterSyncService.java
index e972b05..fa07268 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogConsistencyService.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/OakBacklogClusterSyncService.java
@@ -33,16 +33,16 @@ import org.apache.sling.commons.json.JSONException;
import org.apache.sling.discovery.ClusterView;
import org.apache.sling.discovery.InstanceDescription;
import org.apache.sling.discovery.commons.providers.BaseTopologyView;
-import org.apache.sling.discovery.commons.providers.spi.ConsistencyService;
+import org.apache.sling.discovery.commons.providers.spi.ClusterSyncService;
import org.apache.sling.settings.SlingSettingsService;
/**
- * The OakBacklogConsistencyService will wait until all instances
+ * The OakBacklogClusterSyncService will wait until all instances
* in the local cluster are no longer in any backlog state.
*/
@Component(immediate = false)
-@Service(value = { ConsistencyService.class, OakBacklogConsistencyService.class })
-public class OakBacklogConsistencyService extends AbstractServiceWithBackgroundCheck implements ConsistencyService {
+@Service(value = { ClusterSyncService.class, OakBacklogClusterSyncService.class })
+public class OakBacklogClusterSyncService extends AbstractServiceWithBackgroundCheck implements ClusterSyncService {
static enum BacklogStatus {
UNDEFINED /* when there was an error retrieving the backlog status with oak */,
@@ -62,14 +62,14 @@ public class OakBacklogConsistencyService extends AbstractServiceWithBackgroundC
@Reference
protected SlingSettingsService settingsService;
- private ConsistencyHistory consistencyHistory = new ConsistencyHistory();
+ private ClusterSyncHistory consistencyHistory = new ClusterSyncHistory();
- public static OakBacklogConsistencyService testConstructorAndActivate(
+ public static OakBacklogClusterSyncService testConstructorAndActivate(
final DiscoveryLiteConfig commonsConfig,
final IdMapService idMapService,
final SlingSettingsService settingsService,
ResourceResolverFactory resourceResolverFactory) {
- OakBacklogConsistencyService service = testConstructor(commonsConfig, idMapService, settingsService, resourceResolverFactory);
+ OakBacklogClusterSyncService service = testConstructor(commonsConfig, idMapService, settingsService, resourceResolverFactory);
service.activate();
return service;
}
@@ -86,12 +86,12 @@ public class OakBacklogConsistencyService extends AbstractServiceWithBackgroundC
* @throws LoginException when the login for initialization failed
* @throws JSONException when the descriptor wasn't proper json at init time
*/
- public static OakBacklogConsistencyService testConstructor(
+ public static OakBacklogClusterSyncService testConstructor(
final DiscoveryLiteConfig commonsConfig,
final IdMapService idMapService,
final SlingSettingsService settingsService,
ResourceResolverFactory resourceResolverFactory) {
- OakBacklogConsistencyService service = new OakBacklogConsistencyService();
+ OakBacklogClusterSyncService service = new OakBacklogClusterSyncService();
if (commonsConfig == null) {
throw new IllegalArgumentException("commonsConfig must not be null");
}
@@ -114,11 +114,11 @@ public class OakBacklogConsistencyService extends AbstractServiceWithBackgroundC
logger.info("activate: activated with slingId="+slingId);
}
- public void setConsistencyHistory(ConsistencyHistory consistencyHistory) {
+ public void setConsistencyHistory(ClusterSyncHistory consistencyHistory) {
this.consistencyHistory = consistencyHistory;
}
- public ConsistencyHistory getConsistencyHistory() {
+ public ClusterSyncHistory getConsistencyHistory() {
return consistencyHistory;
}
@@ -145,7 +145,7 @@ public class OakBacklogConsistencyService extends AbstractServiceWithBackgroundC
private void waitWhileBacklog(final BaseTopologyView view, final Runnable runnable) {
// start backgroundChecking until the backlogStatus
// is NO_BACKLOG
- startBackgroundCheck("OakSyncTokenConsistencyService-backlog-waiting", new BackgroundCheck() {
+ startBackgroundCheck("OakBacklogClusterSyncService-backlog-waiting", new BackgroundCheck() {
@Override
public boolean check() {
@@ -173,7 +173,7 @@ public class OakBacklogConsistencyService extends AbstractServiceWithBackgroundC
return false;
}
}
- }, runnable, getCommonsConfig().getBgTimeoutMillis(), getCommonsConfig().getBgIntervalMillis());
+ }, runnable, getCommonsConfig().getClusterSyncServiceTimeoutMillis(), getCommonsConfig().getClusterSyncServiceIntervalMillis());
}
private BacklogStatus getBacklogStatus(BaseTopologyView view) {
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/SyncTokenConsistencyService.java b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/SyncTokenService.java
similarity index 88%
rename from src/main/java/org/apache/sling/discovery/commons/providers/spi/base/SyncTokenConsistencyService.java
rename to src/main/java/org/apache/sling/discovery/commons/providers/spi/base/SyncTokenService.java
index 1e0cfc2..23ac970 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/SyncTokenConsistencyService.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/SyncTokenService.java
@@ -31,7 +31,7 @@ import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.discovery.InstanceDescription;
import org.apache.sling.discovery.commons.providers.BaseTopologyView;
-import org.apache.sling.discovery.commons.providers.spi.ConsistencyService;
+import org.apache.sling.discovery.commons.providers.spi.ClusterSyncService;
import org.apache.sling.discovery.commons.providers.util.ResourceHelper;
import org.apache.sling.settings.SlingSettingsService;
@@ -46,8 +46,8 @@ import org.apache.sling.settings.SlingSettingsService;
* and are aware of the new discoveryLite view.
*/
@Component(immediate = false)
-@Service(value = { ConsistencyService.class, SyncTokenConsistencyService.class })
-public class SyncTokenConsistencyService extends AbstractServiceWithBackgroundCheck implements ConsistencyService {
+@Service(value = { ClusterSyncService.class, SyncTokenService.class })
+public class SyncTokenService extends AbstractServiceWithBackgroundCheck implements ClusterSyncService {
@Reference
protected DiscoveryLiteConfig commonsConfig;
@@ -58,22 +58,22 @@ public class SyncTokenConsistencyService extends AbstractServiceWithBackgroundCh
@Reference
protected SlingSettingsService settingsService;
- protected ConsistencyHistory consistencyHistory = new ConsistencyHistory();
+ protected ClusterSyncHistory clusterSyncHistory = new ClusterSyncHistory();
- public static SyncTokenConsistencyService testConstructorAndActivate(
+ public static SyncTokenService testConstructorAndActivate(
DiscoveryLiteConfig commonsConfig,
ResourceResolverFactory resourceResolverFactory,
SlingSettingsService settingsService) {
- SyncTokenConsistencyService service = testConstructor(commonsConfig, resourceResolverFactory, settingsService);
+ SyncTokenService service = testConstructor(commonsConfig, resourceResolverFactory, settingsService);
service.activate();
return service;
}
- public static SyncTokenConsistencyService testConstructor(
+ public static SyncTokenService testConstructor(
DiscoveryLiteConfig commonsConfig,
ResourceResolverFactory resourceResolverFactory,
SlingSettingsService settingsService) {
- SyncTokenConsistencyService service = new SyncTokenConsistencyService();
+ SyncTokenService service = new SyncTokenService();
if (commonsConfig == null) {
throw new IllegalArgumentException("commonsConfig must not be null");
}
@@ -95,12 +95,12 @@ public class SyncTokenConsistencyService extends AbstractServiceWithBackgroundCh
logger.info("activate: activated with slingId="+slingId);
}
- public void setConsistencyHistory(ConsistencyHistory consistencyHistory) {
- this.consistencyHistory = consistencyHistory;
+ public void setConsistencyHistory(ClusterSyncHistory consistencyHistory) {
+ this.clusterSyncHistory = consistencyHistory;
}
- public ConsistencyHistory getConsistencyHistory() {
- return consistencyHistory;
+ public ClusterSyncHistory getClusterSyncHistory() {
+ return clusterSyncHistory;
}
/** Get or create a ResourceResolver **/
@@ -125,7 +125,7 @@ public class SyncTokenConsistencyService extends AbstractServiceWithBackgroundCh
protected void syncToken(final BaseTopologyView view, final Runnable callback) {
- startBackgroundCheck("SyncTokenConsistencyService", new BackgroundCheck() {
+ startBackgroundCheck("SyncTokenService", new BackgroundCheck() {
@Override
public boolean check() {
@@ -136,14 +136,14 @@ public class SyncTokenConsistencyService extends AbstractServiceWithBackgroundCh
// that they will have to wait until the timeout hits
// so to try to avoid this, retry storing my sync token later:
- consistencyHistory.addHistoryEntry(view, "storing my syncToken ("+localClusterSyncTokenId+")");
+ clusterSyncHistory.addHistoryEntry(view, "storing my syncToken ("+localClusterSyncTokenId+")");
return false;
}
// 2) then check if all others have done the same already
return seenAllSyncTokens(view);
}
- }, callback, commonsConfig.getBgTimeoutMillis(), commonsConfig.getBgIntervalMillis());
+ }, callback, commonsConfig.getClusterSyncServiceTimeoutMillis(), commonsConfig.getClusterSyncServiceIntervalMillis());
}
private boolean storeMySyncToken(String syncTokenId) {
@@ -227,10 +227,10 @@ public class SyncTokenConsistencyService extends AbstractServiceWithBackgroundCh
}
if (!success) {
logger.info("seenAllSyncTokens: not yet seen all expected syncTokens (see above for details)");
- consistencyHistory.addHistoryEntry(view, historyEntry.toString());
+ clusterSyncHistory.addHistoryEntry(view, historyEntry.toString());
return false;
} else {
- consistencyHistory.addHistoryEntry(view, "seen all syncTokens");
+ clusterSyncHistory.addHistoryEntry(view, "seen all syncTokens");
}
resourceResolver.commit();
diff --git a/src/test/java/org/apache/sling/discovery/commons/providers/base/ClusterTest.java b/src/test/java/org/apache/sling/discovery/commons/providers/base/ClusterTest.java
index 2bf3705..18ad1ba 100644
--- a/src/test/java/org/apache/sling/discovery/commons/providers/base/ClusterTest.java
+++ b/src/test/java/org/apache/sling/discovery/commons/providers/base/ClusterTest.java
@@ -31,7 +31,7 @@ import org.apache.sling.discovery.TopologyEvent;
import org.apache.sling.discovery.TopologyEvent.Type;
import org.apache.sling.discovery.commons.providers.BaseTopologyView;
import org.apache.sling.discovery.commons.providers.base.ViewStateManagerImpl;
-import org.apache.sling.discovery.commons.providers.spi.ConsistencyService;
+import org.apache.sling.discovery.commons.providers.spi.ClusterSyncService;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -59,7 +59,7 @@ public class ClusterTest {
}
private ViewStateManagerImpl newMgr() {
- ViewStateManagerImpl mgr = new ViewStateManagerImpl(new ReentrantLock(), new ConsistencyService() {
+ ViewStateManagerImpl mgr = new ViewStateManagerImpl(new ReentrantLock(), new ClusterSyncService() {
public void sync(BaseTopologyView view, Runnable callback) {
callback.run();
diff --git a/src/test/java/org/apache/sling/discovery/commons/providers/base/TestMinEventDelayHandler.java b/src/test/java/org/apache/sling/discovery/commons/providers/base/TestMinEventDelayHandler.java
index d28b912..fc78c44 100644
--- a/src/test/java/org/apache/sling/discovery/commons/providers/base/TestMinEventDelayHandler.java
+++ b/src/test/java/org/apache/sling/discovery/commons/providers/base/TestMinEventDelayHandler.java
@@ -32,7 +32,7 @@ import org.apache.sling.discovery.commons.providers.DefaultClusterView;
import org.apache.sling.discovery.commons.providers.DummyTopologyView;
import org.apache.sling.discovery.commons.providers.EventHelper;
import org.apache.sling.discovery.commons.providers.base.ViewStateManagerImpl;
-import org.apache.sling.discovery.commons.providers.spi.ConsistencyService;
+import org.apache.sling.discovery.commons.providers.spi.ClusterSyncService;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
@@ -56,7 +56,7 @@ public class TestMinEventDelayHandler {
@Before
public void setup() throws Exception {
- mgr = new ViewStateManagerImpl(new ReentrantLock(), new ConsistencyService() {
+ mgr = new ViewStateManagerImpl(new ReentrantLock(), new ClusterSyncService() {
public void sync(BaseTopologyView view, Runnable callback) {
callback.run();
diff --git a/src/test/java/org/apache/sling/discovery/commons/providers/base/TestViewStateManager.java b/src/test/java/org/apache/sling/discovery/commons/providers/base/TestViewStateManager.java
index e80268c..8dd1796 100644
--- a/src/test/java/org/apache/sling/discovery/commons/providers/base/TestViewStateManager.java
+++ b/src/test/java/org/apache/sling/discovery/commons/providers/base/TestViewStateManager.java
@@ -38,7 +38,7 @@ import org.apache.sling.discovery.commons.providers.DefaultClusterView;
import org.apache.sling.discovery.commons.providers.DefaultInstanceDescription;
import org.apache.sling.discovery.commons.providers.DummyTopologyView;
import org.apache.sling.discovery.commons.providers.EventHelper;
-import org.apache.sling.discovery.commons.providers.spi.ConsistencyService;
+import org.apache.sling.discovery.commons.providers.spi.ClusterSyncService;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -49,12 +49,12 @@ public class TestViewStateManager {
private static final Logger logger = LoggerFactory.getLogger(TestViewStateManager.class);
- private class ConsistencyServiceWithSemaphore implements ConsistencyService {
+ private class ClusterSyncServiceWithSemaphore implements ClusterSyncService {
private final Semaphore semaphore;
private final Lock lock;
- public ConsistencyServiceWithSemaphore(Lock lock, Semaphore semaphore) {
+ public ClusterSyncServiceWithSemaphore(Lock lock, Semaphore semaphore) {
this.lock = lock;
this.semaphore = semaphore;
}
@@ -63,9 +63,9 @@ public class TestViewStateManager {
try {
lock.unlock();
try{
- logger.info("ConsistencyServiceWithSemaphore.sync: acquiring lock ...");
+ logger.info("ClusterSyncServiceWithSemaphore.sync: acquiring lock ...");
semaphore.acquire();
- logger.info("ConsistencyServiceWithSemaphore.sync: lock acquired.");
+ logger.info("ClusterSyncServiceWithSemaphore.sync: lock acquired.");
} finally {
lock.lock();
}
@@ -88,7 +88,7 @@ public class TestViewStateManager {
@Before
public void setup() throws Exception {
- mgr = new ViewStateManagerImpl(new ReentrantLock(), new ConsistencyService() {
+ mgr = new ViewStateManagerImpl(new ReentrantLock(), new ClusterSyncService() {
public void sync(BaseTopologyView view, Runnable callback) {
callback.run();
@@ -225,7 +225,7 @@ public class TestViewStateManager {
@Test
public void testCancelSync() throws Exception {
final List<Runnable> syncCallbacks = new LinkedList<Runnable>();
- mgr = new ViewStateManagerImpl(new ReentrantLock(), new ConsistencyService() {
+ mgr = new ViewStateManagerImpl(new ReentrantLock(), new ClusterSyncService() {
public void sync(BaseTopologyView view, Runnable callback) {
synchronized(syncCallbacks) {
@@ -526,7 +526,7 @@ public class TestViewStateManager {
commonsLogger.setLevel(Level.INFO); // change here to DEBUG in case of issues with this test
final Semaphore serviceSemaphore = new Semaphore(0);
final ReentrantLock lock = new ReentrantLock();
- final ConsistencyServiceWithSemaphore cs = new ConsistencyServiceWithSemaphore(lock, serviceSemaphore );
+ final ClusterSyncServiceWithSemaphore cs = new ClusterSyncServiceWithSemaphore(lock, serviceSemaphore );
mgr = new ViewStateManagerImpl(lock, cs);
final DummyListener listener = new DummyListener();
mgr.bind(listener);
@@ -588,7 +588,7 @@ public class TestViewStateManager {
final Semaphore serviceSemaphore = new Semaphore(0);
final Semaphore testSemaphore = new Semaphore(0);
final ReentrantLock lock = new ReentrantLock();
- final ConsistencyServiceWithSemaphore cs = new ConsistencyServiceWithSemaphore(lock, serviceSemaphore );
+ final ClusterSyncServiceWithSemaphore cs = new ClusterSyncServiceWithSemaphore(lock, serviceSemaphore );
mgr = new ViewStateManagerImpl(lock, cs);
final DummyListener listener = new DummyListener();
mgr.bind(listener);
diff --git a/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/TestOakSyncTokenConsistencyService.java b/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/TestOakSyncTokenService.java
similarity index 95%
rename from src/test/java/org/apache/sling/discovery/commons/providers/spi/base/TestOakSyncTokenConsistencyService.java
rename to src/test/java/org/apache/sling/discovery/commons/providers/spi/base/TestOakSyncTokenService.java
index 357c8a5..591fea8 100644
--- a/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/TestOakSyncTokenConsistencyService.java
+++ b/src/test/java/org/apache/sling/discovery/commons/providers/spi/base/TestOakSyncTokenService.java
@@ -34,13 +34,13 @@ import org.apache.sling.discovery.commons.providers.base.TestHelper;
import org.apache.sling.discovery.commons.providers.base.ViewStateManagerFactory;
import org.apache.sling.discovery.commons.providers.spi.base.DiscoveryLiteConfig;
import org.apache.sling.discovery.commons.providers.spi.base.IdMapService;
-import org.apache.sling.discovery.commons.providers.spi.base.OakBacklogConsistencyService;
+import org.apache.sling.discovery.commons.providers.spi.base.OakBacklogClusterSyncService;
import org.apache.sling.jcr.api.SlingRepository;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-public class TestOakSyncTokenConsistencyService {
+public class TestOakSyncTokenService {
private static final String SYNCTOKEN_PATH = "/var/discovery/commons/synctokens";
@@ -71,12 +71,12 @@ public class TestOakSyncTokenConsistencyService {
}
@Override
- public long getBgTimeoutMillis() {
+ public long getClusterSyncServiceTimeoutMillis() {
return bgTimeoutMillis;
}
@Override
- public long getBgIntervalMillis() {
+ public long getClusterSyncServiceIntervalMillis() {
return bgIntervalMillis;
}
@@ -119,7 +119,7 @@ public class TestOakSyncTokenConsistencyService {
public void testOneNode() throws Exception {
DummyTopologyView one = TestHelper.newView(true, slingId1, slingId1, slingId1);
Lock lock = new ReentrantLock();
- OakBacklogConsistencyService cs = OakBacklogConsistencyService.testConstructorAndActivate(new SimpleCommonsConfig(), idMapService1, new DummySlingSettingsService(slingId1), factory1);
+ OakBacklogClusterSyncService cs = OakBacklogClusterSyncService.testConstructorAndActivate(new SimpleCommonsConfig(), idMapService1, new DummySlingSettingsService(slingId1), factory1);
ViewStateManager vsm = ViewStateManagerFactory.newViewStateManager(lock, cs);
DummyListener l = new DummyListener();
assertEquals(0, l.countEvents());
@@ -145,7 +145,7 @@ public class TestOakSyncTokenConsistencyService {
String slingId2 = UUID.randomUUID().toString();
DummyTopologyView two1 = TestHelper.newView(true, slingId1, slingId1, slingId1, slingId2);
Lock lock1 = new ReentrantLock();
- OakBacklogConsistencyService cs1 = OakBacklogConsistencyService.testConstructorAndActivate(new SimpleCommonsConfig(), idMapService1, new DummySlingSettingsService(slingId1), factory1);
+ OakBacklogClusterSyncService cs1 = OakBacklogClusterSyncService.testConstructorAndActivate(new SimpleCommonsConfig(), idMapService1, new DummySlingSettingsService(slingId1), factory1);
ViewStateManager vsm1 = ViewStateManagerFactory.newViewStateManager(lock1, cs1);
DummyListener l = new DummyListener();
vsm1.bind(l);
@@ -161,7 +161,7 @@ public class TestOakSyncTokenConsistencyService {
Lock lock2 = new ReentrantLock();
IdMapService idMapService2 = IdMapService.testConstructor(
new SimpleCommonsConfig(), new DummySlingSettingsService(slingId2), factory2);
- OakBacklogConsistencyService cs2 = OakBacklogConsistencyService.testConstructorAndActivate(new SimpleCommonsConfig(), idMapService2, new DummySlingSettingsService(slingId2), factory2);
+ OakBacklogClusterSyncService cs2 = OakBacklogClusterSyncService.testConstructorAndActivate(new SimpleCommonsConfig(), idMapService2, new DummySlingSettingsService(slingId2), factory2);
ViewStateManager vsm2 = ViewStateManagerFactory.newViewStateManager(lock2, cs2);
cs1.triggerBackgroundCheck();
cs2.triggerBackgroundCheck();
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.