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:00 UTC
[sling-org-apache-sling-discovery-base] 03/20: SLING-5256 : change
in localClusterSyncTokenId should always trigger a TOPOLOGY_CHANGED -
ensured by adjusting ViewStateManager.onlyDiffersInProperties and
DefaultTopologyView.compareTopology accordingly including new tests for
both - plus added OakDiscoveryServiceTest.testDescriptorSeqNumChange to
verify that discovery.oak now properly detects otherwise-equal topologies
when their sequence_number==localClusterSyncTokenId differs (unlikely to
happen under normal load situations though)
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git
commit ac39af55c6ea24b2e89b74bd4fcb1af801e822c8
Author: Stefan Egli <st...@apache.org>
AuthorDate: Wed Nov 4 10:37:59 2015 +0000
SLING-5256 : change in localClusterSyncTokenId should always trigger a TOPOLOGY_CHANGED - ensured by adjusting ViewStateManager.onlyDiffersInProperties and DefaultTopologyView.compareTopology accordingly including new tests for both - plus added OakDiscoveryServiceTest.testDescriptorSeqNumChange to verify that discovery.oak now properly detects otherwise-equal topologies when their sequence_number==localClusterSyncTokenId differs (unlikely to happen under normal load situations though)
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1712527 13f79535-47bb-0310-9956-ffa450edef68
---
.../base/commons/DefaultTopologyView.java | 6 ++++
.../base/commons/DefaultTopologyViewTest.java | 40 ++++++++++++++++++++++
2 files changed, 46 insertions(+)
diff --git a/src/main/java/org/apache/sling/discovery/base/commons/DefaultTopologyView.java b/src/main/java/org/apache/sling/discovery/base/commons/DefaultTopologyView.java
index 653e6d8..a85c20b 100644
--- a/src/main/java/org/apache/sling/discovery/base/commons/DefaultTopologyView.java
+++ b/src/main/java/org/apache/sling/discovery/base/commons/DefaultTopologyView.java
@@ -68,6 +68,12 @@ public class DefaultTopologyView extends BaseTopologyView {
if (other == null) {
throw new IllegalArgumentException("other must not be null");
}
+ if ((localClusterSyncTokenId == null && other.localClusterSyncTokenId != null)
+ || (other.localClusterSyncTokenId == null && localClusterSyncTokenId != null)
+ || (localClusterSyncTokenId != null && !localClusterSyncTokenId.equals(other.localClusterSyncTokenId))) {
+ logger.debug("compareTopology: different localClusterSyncTokenId");
+ return Type.TOPOLOGY_CHANGED;
+ }
if (this.instances.size() != other.instances.size()) {
logger.debug("compareTopology: different number of instances");
return Type.TOPOLOGY_CHANGED;
diff --git a/src/test/java/org/apache/sling/discovery/base/commons/DefaultTopologyViewTest.java b/src/test/java/org/apache/sling/discovery/base/commons/DefaultTopologyViewTest.java
index 27446f3..0082844 100644
--- a/src/test/java/org/apache/sling/discovery/base/commons/DefaultTopologyViewTest.java
+++ b/src/test/java/org/apache/sling/discovery/base/commons/DefaultTopologyViewTest.java
@@ -31,10 +31,12 @@ import java.util.UUID;
import org.apache.sling.discovery.InstanceDescription;
import org.apache.sling.discovery.InstanceFilter;
+import org.apache.sling.discovery.TopologyEvent;
import org.apache.sling.discovery.TopologyEvent.Type;
import org.apache.sling.discovery.base.its.setup.TopologyHelper;
import org.apache.sling.discovery.commons.providers.DefaultClusterView;
import org.apache.sling.discovery.commons.providers.DefaultInstanceDescription;
+import org.apache.sling.discovery.commons.providers.spi.LocalClusterView;
import org.junit.Test;
import junitx.util.PrivateAccessor;
@@ -74,6 +76,44 @@ public class DefaultTopologyViewTest {
}
@Test
+ public void testComparelocalClusterSyncTokenId() throws Exception {
+ String clusterViewId = UUID.randomUUID().toString();
+ String slingId = UUID.randomUUID().toString();
+ String syncTokenId = UUID.randomUUID().toString();
+
+ DefaultTopologyView t1 = createSingleInstanceTopology(slingId, clusterViewId, syncTokenId);
+ DefaultTopologyView t2 = createSingleInstanceTopology(slingId, clusterViewId, syncTokenId);
+
+ assertNull(t1.compareTopology(t2));
+ assertNull(t2.compareTopology(t1));
+
+ DefaultTopologyView t3 = createSingleInstanceTopology(slingId, clusterViewId, UUID.randomUUID().toString());
+ assertEquals(TopologyEvent.Type.TOPOLOGY_CHANGED, t1.compareTopology(t3));
+ assertEquals(TopologyEvent.Type.TOPOLOGY_CHANGED, t3.compareTopology(t1));
+ assertEquals(TopologyEvent.Type.TOPOLOGY_CHANGED, t2.compareTopology(t3));
+ assertEquals(TopologyEvent.Type.TOPOLOGY_CHANGED, t3.compareTopology(t2));
+
+ DefaultTopologyView t4 = createSingleInstanceTopology(slingId, clusterViewId, null);
+ assertEquals(TopologyEvent.Type.TOPOLOGY_CHANGED, t1.compareTopology(t4));
+ assertEquals(TopologyEvent.Type.TOPOLOGY_CHANGED, t4.compareTopology(t1));
+ assertEquals(TopologyEvent.Type.TOPOLOGY_CHANGED, t2.compareTopology(t4));
+ assertEquals(TopologyEvent.Type.TOPOLOGY_CHANGED, t4.compareTopology(t2));
+
+ DefaultTopologyView t5 = createSingleInstanceTopology(slingId, clusterViewId, null);
+ assertNull(t5.compareTopology(t4));
+ assertNull(t4.compareTopology(t5));
+ }
+
+ private DefaultTopologyView createSingleInstanceTopology(String slingId, String clusterViewId, String syncTokenId) {
+ LocalClusterView clusterView = new LocalClusterView(clusterViewId, syncTokenId);
+ DefaultInstanceDescription instance =
+ TopologyHelper.createInstanceDescription(slingId, true, clusterView);
+ DefaultTopologyView t = new DefaultTopologyView();
+ t.setLocalClusterView(clusterView);
+ return t;
+ }
+
+ @Test
public void testCompare() throws Exception {
DefaultTopologyView newView = TopologyHelper.createTopologyView(UUID
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.