This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.discovery.oak-1.0.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-oak.git
commit 38813a3f65f689823cc908db604b1165437c2abe Author: Stefan Egli <[email protected]> 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/oak@1710183 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/sling/discovery/oak/Config.java | 31 ++++++++++++++++---- .../sling/discovery/oak/OakDiscoveryService.java | 34 +++++++++++----------- .../discovery/oak/TopologyWebConsolePlugin.java | 12 ++++---- .../discovery/oak/OakDiscoveryServiceTest.java | 4 +-- .../oak/its/setup/OakVirtualInstanceBuilder.java | 32 ++++++++++---------- 5 files changed, 66 insertions(+), 47 deletions(-) diff --git a/src/main/java/org/apache/sling/discovery/oak/Config.java b/src/main/java/org/apache/sling/discovery/oak/Config.java index 9b8cd11..4bb4095 100644 --- a/src/main/java/org/apache/sling/discovery/oak/Config.java +++ b/src/main/java/org/apache/sling/discovery/oak/Config.java @@ -73,6 +73,16 @@ public class Config implements BaseConfig, DiscoveryLiteConfig { public static final String DISCOVERY_LITE_CHECK_INTERVAL_KEY = "discoveryLiteCheckInterval"; protected long discoveryLiteCheckInterval = DEFAULT_DISCOVERY_LITE_CHECK_INTERVAL; + public static final long DEFAULT_CLUSTER_SYNC_SERVICE_TIMEOUT = 120; + @Property(longValue=DEFAULT_CLUSTER_SYNC_SERVICE_TIMEOUT) + public static final String CLUSTER_SYNC_SERVICE_TIMEOUT_KEY = "clusterSyncServiceTimeout"; + protected long clusterSyncServiceTimeout = DEFAULT_CLUSTER_SYNC_SERVICE_TIMEOUT; + + public static final long DEFAULT_CLUSTER_SYNC_SERVICE_INTERVAL = 2; + @Property(longValue=DEFAULT_CLUSTER_SYNC_SERVICE_INTERVAL) + public static final String CLUSTER_SYNC_SERVICE_INTERVAL_KEY = "clusterSyncServiceInterval"; + protected long clusterSyncServiceInterval = DEFAULT_CLUSTER_SYNC_SERVICE_INTERVAL; + /** * If set to true a syncToken will be used on top of waiting for * deactivating instances to be fully processed. @@ -234,6 +244,17 @@ public class Config implements BaseConfig, DiscoveryLiteConfig { logger.debug("configure: discoveryLiteCheckInterval='{}'", this.discoveryLiteCheckInterval); + this.clusterSyncServiceTimeout = PropertiesUtil.toLong( + properties.get(CLUSTER_SYNC_SERVICE_TIMEOUT_KEY), + DEFAULT_CLUSTER_SYNC_SERVICE_TIMEOUT); + logger.debug("configure: clusterSyncServiceTimeout='{}'", + this.clusterSyncServiceTimeout); + + this.clusterSyncServiceInterval = PropertiesUtil.toLong( + properties.get(CLUSTER_SYNC_SERVICE_INTERVAL_KEY), + DEFAULT_CLUSTER_SYNC_SERVICE_TIMEOUT); + logger.debug("configure: clusterSyncServiceInterval='{}'", + this.clusterSyncServiceInterval); this.minEventDelay = PropertiesUtil.toInteger( properties.get(MIN_EVENT_DELAY_KEY), @@ -473,15 +494,13 @@ public class Config implements BaseConfig, DiscoveryLiteConfig { } @Override - public long getBgTimeoutMillis() { - // TODO: currently hard coded - return -1; + public long getClusterSyncServiceTimeoutMillis() { + return clusterSyncServiceTimeout * 1000; } @Override - public long getBgIntervalMillis() { - // TODO: currently hard coded - return 1000; + public long getClusterSyncServiceIntervalMillis() { + return clusterSyncServiceInterval * 1000; } public boolean getSyncTokenEnabled() { diff --git a/src/main/java/org/apache/sling/discovery/oak/OakDiscoveryService.java b/src/main/java/org/apache/sling/discovery/oak/OakDiscoveryService.java index 0b27f95..a75a2ef 100644 --- a/src/main/java/org/apache/sling/discovery/oak/OakDiscoveryService.java +++ b/src/main/java/org/apache/sling/discovery/oak/OakDiscoveryService.java @@ -60,12 +60,12 @@ import org.apache.sling.discovery.commons.providers.DefaultClusterView; import org.apache.sling.discovery.commons.providers.DefaultInstanceDescription; import org.apache.sling.discovery.commons.providers.ViewStateManager; import org.apache.sling.discovery.commons.providers.base.ViewStateManagerFactory; -import org.apache.sling.discovery.commons.providers.spi.ConsistencyService; -import org.apache.sling.discovery.commons.providers.spi.base.ConsistencyHistory; -import org.apache.sling.discovery.commons.providers.spi.base.ConsistencyServiceChain; +import org.apache.sling.discovery.commons.providers.spi.ClusterSyncService; +import org.apache.sling.discovery.commons.providers.spi.base.ClusterSyncHistory; +import org.apache.sling.discovery.commons.providers.spi.base.ClusterSyncServiceChain; 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.SyncTokenConsistencyService; +import org.apache.sling.discovery.commons.providers.spi.base.OakBacklogClusterSyncService; +import org.apache.sling.discovery.commons.providers.spi.base.SyncTokenService; import org.apache.sling.discovery.commons.providers.util.PropertyNameHelper; import org.apache.sling.discovery.commons.providers.util.ResourceHelper; import org.apache.sling.discovery.oak.pinger.OakViewChecker; @@ -133,10 +133,10 @@ public class OakDiscoveryService extends BaseDiscoveryService { private IdMapService idMapService; @Reference - private OakBacklogConsistencyService oakBacklogConsistencyService; + private OakBacklogClusterSyncService oakBacklogClusterSyncService; @Reference - private SyncTokenConsistencyService syncTokenConsistencyService; + private SyncTokenService syncTokenService; /** the slingId of the local instance **/ private String slingId; @@ -157,8 +157,8 @@ public class OakDiscoveryService extends BaseDiscoveryService { OakViewChecker connectorPinger, Scheduler scheduler, IdMapService idMapService, - OakBacklogConsistencyService oakBacklogConsistencyService, - SyncTokenConsistencyService syncTokenConsistencyService, + OakBacklogClusterSyncService oakBacklogClusterSyncService, + SyncTokenService syncTokenService, ResourceResolverFactory factory) { OakDiscoveryService discoService = new OakDiscoveryService(); discoService.settingsService = settingsService; @@ -169,8 +169,8 @@ public class OakDiscoveryService extends BaseDiscoveryService { discoService.oakViewChecker = connectorPinger; discoService.scheduler = scheduler; discoService.idMapService = idMapService; - discoService.oakBacklogConsistencyService = oakBacklogConsistencyService; - discoService.syncTokenConsistencyService = syncTokenConsistencyService; + discoService.oakBacklogClusterSyncService = oakBacklogClusterSyncService; + discoService.syncTokenService = syncTokenService; discoService.resourceResolverFactory = factory; return discoService; } @@ -210,15 +210,15 @@ public class OakDiscoveryService extends BaseDiscoveryService { slingId = settingsService.getSlingId(); - ConsistencyService consistencyService; + ClusterSyncService consistencyService; if (config.getSyncTokenEnabled()) { //TODO: ConsistencyHistory is implemented a little bit hacky .. - ConsistencyHistory consistencyHistory = new ConsistencyHistory(); - oakBacklogConsistencyService.setConsistencyHistory(consistencyHistory); - syncTokenConsistencyService.setConsistencyHistory(consistencyHistory); - consistencyService = new ConsistencyServiceChain(oakBacklogConsistencyService, syncTokenConsistencyService); + ClusterSyncHistory consistencyHistory = new ClusterSyncHistory(); + oakBacklogClusterSyncService.setConsistencyHistory(consistencyHistory); + syncTokenService.setConsistencyHistory(consistencyHistory); + consistencyService = new ClusterSyncServiceChain(oakBacklogClusterSyncService, syncTokenService); } else { - consistencyService = oakBacklogConsistencyService; + consistencyService = oakBacklogClusterSyncService; } viewStateManager = ViewStateManagerFactory.newViewStateManager(viewStateManagerLock, consistencyService); diff --git a/src/main/java/org/apache/sling/discovery/oak/TopologyWebConsolePlugin.java b/src/main/java/org/apache/sling/discovery/oak/TopologyWebConsolePlugin.java index f4d4658..c823411 100644 --- a/src/main/java/org/apache/sling/discovery/oak/TopologyWebConsolePlugin.java +++ b/src/main/java/org/apache/sling/discovery/oak/TopologyWebConsolePlugin.java @@ -65,7 +65,7 @@ import org.apache.sling.discovery.base.connectors.ping.ConnectorRegistry; import org.apache.sling.discovery.base.connectors.ping.TopologyConnectorClientInformation; import org.apache.sling.discovery.commons.InstancesDiff; import org.apache.sling.discovery.commons.providers.spi.base.DiscoveryLiteDescriptor; -import org.apache.sling.discovery.commons.providers.spi.base.OakBacklogConsistencyService; +import org.apache.sling.discovery.commons.providers.spi.base.OakBacklogClusterSyncService; import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -114,7 +114,7 @@ public class TopologyWebConsolePlugin extends AbstractWebConsolePlugin implement protected ResourceResolverFactory resourceResolverFactory; @Reference - private OakBacklogConsistencyService consistencyService; + private OakBacklogClusterSyncService clusterSyncService; private TopologyView currentView; @@ -318,9 +318,9 @@ public class TopologyWebConsolePlugin extends AbstractWebConsolePlugin implement pw.println("</pre>"); pw.println("<br/>"); - pw.println("<p class=\"statline ui-state-highlight\">ConsistencyService History</p>"); + pw.println("<p class=\"statline ui-state-highlight\">ClusterSyncService History</p>"); pw.println("<pre>"); - for (String syncHistoryEntry : consistencyService.getSyncHistory()) { + for (String syncHistoryEntry : clusterSyncService.getSyncHistory()) { pw.println(syncHistoryEntry); } pw.println("</pre>"); @@ -983,9 +983,9 @@ public class TopologyWebConsolePlugin extends AbstractWebConsolePlugin implement pw.println(); pw.println(); - pw.println("ConsistencyService History"); + pw.println("ClusterSyncService History"); pw.println("---------------------------------------"); - for (String syncHistoryEntry : consistencyService.getSyncHistory()) { + for (String syncHistoryEntry : clusterSyncService.getSyncHistory()) { pw.println(syncHistoryEntry); } pw.println(); diff --git a/src/test/java/org/apache/sling/discovery/oak/OakDiscoveryServiceTest.java b/src/test/java/org/apache/sling/discovery/oak/OakDiscoveryServiceTest.java index d5610fc..5ca93bd 100644 --- a/src/test/java/org/apache/sling/discovery/oak/OakDiscoveryServiceTest.java +++ b/src/test/java/org/apache/sling/discovery/oak/OakDiscoveryServiceTest.java @@ -56,12 +56,12 @@ public class OakDiscoveryServiceTest { } @Override - public long getBgTimeoutMillis() { + public long getClusterSyncServiceTimeoutMillis() { return bgTimeoutMillis; } @Override - public long getBgIntervalMillis() { + public long getClusterSyncServiceIntervalMillis() { return bgIntervalMillis; } diff --git a/src/test/java/org/apache/sling/discovery/oak/its/setup/OakVirtualInstanceBuilder.java b/src/test/java/org/apache/sling/discovery/oak/its/setup/OakVirtualInstanceBuilder.java index b25d2ff..acf20e3 100644 --- a/src/test/java/org/apache/sling/discovery/oak/its/setup/OakVirtualInstanceBuilder.java +++ b/src/test/java/org/apache/sling/discovery/oak/its/setup/OakVirtualInstanceBuilder.java @@ -33,9 +33,9 @@ import org.apache.sling.discovery.base.its.setup.VirtualInstance; import org.apache.sling.discovery.base.its.setup.VirtualInstanceBuilder; import org.apache.sling.discovery.base.its.setup.mock.MockFactory; 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.discovery.commons.providers.spi.base.RepositoryTestHelper; -import org.apache.sling.discovery.commons.providers.spi.base.SyncTokenConsistencyService; +import org.apache.sling.discovery.commons.providers.spi.base.SyncTokenService; import org.apache.sling.discovery.oak.OakDiscoveryService; import org.apache.sling.discovery.oak.cluster.OakClusterViewService; import org.apache.sling.discovery.oak.pinger.OakViewChecker; @@ -54,8 +54,8 @@ public class OakVirtualInstanceBuilder extends VirtualInstanceBuilder { private IdMapService idMapService; private OakViewChecker oakViewChecker; private SimulatedLeaseCollection leaseCollection; - private OakBacklogConsistencyService consistencyService; - private SyncTokenConsistencyService syncTokenConsistencyService; + private OakBacklogClusterSyncService consistencyService; + private SyncTokenService syncTokenService; @Override public VirtualInstanceBuilder createNewRepository() throws Exception { @@ -189,26 +189,26 @@ public class OakVirtualInstanceBuilder extends VirtualInstanceBuilder { return OakViewChecker.testConstructor(getSlingSettingsService(), getResourceResolverFactory(), getConnectorRegistry(), getAnnouncementRegistry(), getScheduler(), getConfig()); } - private OakBacklogConsistencyService getOakBacklogConsistencyService() throws Exception { + private OakBacklogClusterSyncService getOakBacklogClusterSyncService() throws Exception { if (consistencyService == null) { - consistencyService = createOakBacklogConsistencyService(); + consistencyService = createOakBacklogClusterSyncService(); } return consistencyService; } - private OakBacklogConsistencyService createOakBacklogConsistencyService() { - return OakBacklogConsistencyService.testConstructorAndActivate(getConfig(), getIdMapService(), getSlingSettingsService(), getResourceResolverFactory()); + private OakBacklogClusterSyncService createOakBacklogClusterSyncService() { + return OakBacklogClusterSyncService.testConstructorAndActivate(getConfig(), getIdMapService(), getSlingSettingsService(), getResourceResolverFactory()); } - private SyncTokenConsistencyService getSyncTokenConsistencyService() throws Exception { - if (syncTokenConsistencyService == null) { - syncTokenConsistencyService = createSyncTokenConsistencyService(); + private SyncTokenService getSyncTokenService() throws Exception { + if (syncTokenService == null) { + syncTokenService = createSyncTokenService(); } - return syncTokenConsistencyService; + return syncTokenService; } - private SyncTokenConsistencyService createSyncTokenConsistencyService() { - return SyncTokenConsistencyService.testConstructorAndActivate(getConfig(), getResourceResolverFactory(), getSlingSettingsService()); + private SyncTokenService createSyncTokenService() { + return SyncTokenService.testConstructorAndActivate(getConfig(), getResourceResolverFactory(), getSlingSettingsService()); } @Override @@ -222,8 +222,8 @@ public class OakVirtualInstanceBuilder extends VirtualInstanceBuilder { getOakViewChecker(), getScheduler(), getIdMapService(), - getOakBacklogConsistencyService(), - getSyncTokenConsistencyService(), + getOakBacklogClusterSyncService(), + getSyncTokenService(), getResourceResolverFactory()); } -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
