Author: reschke
Date: Tue Apr 16 11:50:15 2019
New Revision: 1857645

URL: http://svn.apache.org/viewvc?rev=1857645&view=rev
Log:
OAK-8139: DocumentDiscoveryLiteService hasBacklog silencing must support maven 
version format (ported to 1.10)

Modified:
    jackrabbit/oak/branches/1.10/   (props changed)
    
jackrabbit/oak/branches/1.10/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteService.java
    
jackrabbit/oak/branches/1.10/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteServiceTest.java

Propchange: jackrabbit/oak/branches/1.10/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Apr 16 11:50:15 2019
@@ -1,3 +1,3 @@
 /jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1850874,1850882,1851236,1851253,1851451,1851533-1851535,1851619,1852052,1852084,1852120,1852451,1852492-1852493,1852528,1852582,1852584,1852601,1852920,1853141,1853229,1853393,1853429,1853433,1853441,1853866,1853868,1853870,1853893,1853969,1853997,1854034,1854044,1854055,1854058,1854113,1854373,1854377,1854380,1854385,1854401,1854403,1854455,1854461-1854462,1854466,1854468,1854515,1854533,1854539,1854701,1854773-1854774,1854827,1854848,1854859,1854930,1854990-1854991,1855032,1855221,1855477-1855478,1855776,1857010,1857104,1857159,1857212,1857221,1857238,1857247,1857253,1857294,1857314,1857577,1857635
+/jackrabbit/oak/trunk:1850874,1850882,1851236,1851253,1851451,1851533-1851535,1851619,1852052,1852084,1852120,1852451,1852492-1852493,1852528,1852582,1852584,1852601,1852920,1853141,1853229,1853393,1853429,1853433,1853441,1853866,1853868,1853870,1853893,1853969,1853997,1854034,1854044,1854055,1854058,1854113,1854373,1854377,1854380,1854385,1854401,1854403,1854455,1854461-1854462,1854466,1854468,1854515,1854533,1854539,1854701,1854773-1854774,1854827,1854848,1854859,1854930,1854990-1854991,1855032,1855221,1855477-1855478,1855776,1857010,1857104,1857159,1857212,1857221,1857238,1857247,1857253,1857294,1857314,1857577,1857635,1857638
 /jackrabbit/trunk:1345480

Modified: 
jackrabbit/oak/branches/1.10/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteService.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.10/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteService.java?rev=1857645&r1=1857644&r2=1857645&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.10/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteService.java
 (original)
+++ 
jackrabbit/oak/branches/1.10/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteService.java
 Tue Apr 16 11:50:15 2019
@@ -509,15 +509,11 @@ public class DocumentDiscoveryLiteServic
         if (lastWrittenRootRevStr == null) {
             boolean warn = false;
             Object oakVersion = 
clusterNode.get(ClusterNodeInfo.OAK_VERSION_KEY);
-            if (oakVersion!=null && (oakVersion instanceof String)) {
-                try{
-                    Version actual = Version.parseVersion((String) oakVersion);
-                    Version introduced = Version.parseVersion("1.3.5");
-                    if (actual.compareTo(introduced)>=0) {
-                        warn = true;
-                    }
-                } catch(Exception e) {
-                    logger.debug("hasBacklog: couldn't parse version 
"+oakVersion+" : "+e);
+            if (oakVersion != null && (oakVersion instanceof String)) {
+                try {
+                    warn = versionPredates("1.3.5", (String) oakVersion);
+                } catch (Exception e) {
+                    logger.debug("hasBacklog: couldn't parse version " + 
oakVersion + " : " + e);
                     warn = true;
                 }
             }
@@ -542,6 +538,17 @@ public class DocumentDiscoveryLiteServic
         return hasBacklog;
     }
 
+    static boolean versionPredates(String base, String compare) {
+        Version one = Version.parseVersion(substSnapshotPrefix(compare));
+        Version two = Version.parseVersion(substSnapshotPrefix(base));
+        return two.compareTo(one) > 0;
+    }
+
+    private static String substSnapshotPrefix(String version) {
+        String snapshot = "-SNAPSHOT";
+        return version.endsWith(snapshot) ? version.substring(0, 
version.length() - snapshot.length()) + ".999999" : version;
+    }
+
     private ClusterViewDocument doCheckView(final Set<Integer> activeNodes, 
final Set<Integer> recoveringNodes,
             final Set<Integer> backlogNodes, final Set<Integer> inactiveNodes) 
{
         logger.trace("doCheckView: start: activeNodes: {}, recoveringNodes: 
{}, backlogNodes: {}, inactiveNodes: {}", activeNodes,

Modified: 
jackrabbit/oak/branches/1.10/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteServiceTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.10/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteServiceTest.java?rev=1857645&r1=1857644&r2=1857645&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.10/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteServiceTest.java
 (original)
+++ 
jackrabbit/oak/branches/1.10/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteServiceTest.java
 Tue Apr 16 11:50:15 2019
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.oak.plugins.document;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
@@ -105,4 +107,17 @@ public class DocumentDiscoveryLiteServic
         doStartStopFiesta(LOOP_CNT);
     }
 
+    @Test
+    public void versionCompare() {
+        // see OAK-8139
+
+        assertTrue(DocumentDiscoveryLiteService.versionPredates("1.3.5", 
"1.0.0"));
+        assertTrue(DocumentDiscoveryLiteService.versionPredates("1.3.5", 
"1.0.10-SNAPSHOT"));
+        assertTrue(DocumentDiscoveryLiteService.versionPredates("1.3.5", 
"1.3.4"));
+
+        assertFalse(DocumentDiscoveryLiteService.versionPredates("1.3.5", 
"1.4.0"));
+        assertFalse(DocumentDiscoveryLiteService.versionPredates("1.3.5", 
"1.14-SNAPSHOT"));
+        assertFalse(DocumentDiscoveryLiteService.versionPredates("1.3.5", 
"1.4.0"));
+        assertFalse(DocumentDiscoveryLiteService.versionPredates("1.3.5", 
"4.0.0"));
+    }
 }


Reply via email to