Author: reschke
Date: Tue Apr 16 10:02:07 2019
New Revision: 1857638
URL: http://svn.apache.org/viewvc?rev=1857638&view=rev
Log:
OAK-8139: DocumentDiscoveryLiteService hasBacklog silencing must support maven
version format
Modified:
jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteService.java
jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteServiceTest.java
Modified:
jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteService.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteService.java?rev=1857638&r1=1857637&r2=1857638&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteService.java
(original)
+++
jackrabbit/oak/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteService.java
Tue Apr 16 10:02:07 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/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteServiceTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteServiceTest.java?rev=1857638&r1=1857637&r2=1857638&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteServiceTest.java
(original)
+++
jackrabbit/oak/trunk/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteServiceTest.java
Tue Apr 16 10:02:07 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"));
+ }
}