From 0ed41a39e476473fcfec78922ddbcb4eb46badd6 Mon Sep 17 00:00:00 2001 From: Brian Long Date: Fri, 28 Feb 2025 17:48:43 -0500 Subject: [PATCH] fixed ASIE shard model parsing --- .../com/inteligr8/alfresco/asie/model/Shard.java | 12 ++++++++---- .../alfresco/asie/model/ShardInstance.java | 14 +++++++------- .../inteligr8/alfresco/asie/model/SolrHost.java | 2 ++ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/shared/src/main/java/com/inteligr8/alfresco/asie/model/Shard.java b/shared/src/main/java/com/inteligr8/alfresco/asie/model/Shard.java index 6841050..21491d0 100644 --- a/shared/src/main/java/com/inteligr8/alfresco/asie/model/Shard.java +++ b/shared/src/main/java/com/inteligr8/alfresco/asie/model/Shard.java @@ -19,7 +19,7 @@ public class Shard implements Serializable { private final String spec; protected Shard(ShardSet shardSet, int shardId) { - this.spec = shardSet.getCore() + "~" + shardId; + this.spec = shardSet.getCore() + "-" + shardId; } protected Shard(String spec) { @@ -34,16 +34,20 @@ public class Shard implements Serializable { } public String getSpec() { - return spec; + return this.spec; + } + + public String getCoreName() { + return this.spec; } public String extractShardSetCore() { - int pos = this.spec.indexOf('~'); + int pos = this.spec.lastIndexOf('-'); return this.spec.substring(0, pos); } public int extractShardId() { - int pos = this.spec.indexOf('~'); + int pos = this.spec.lastIndexOf('-'); return Integer.parseInt(this.spec.substring(pos+1)); } diff --git a/shared/src/main/java/com/inteligr8/alfresco/asie/model/ShardInstance.java b/shared/src/main/java/com/inteligr8/alfresco/asie/model/ShardInstance.java index 53aa456..cbd5dbf 100644 --- a/shared/src/main/java/com/inteligr8/alfresco/asie/model/ShardInstance.java +++ b/shared/src/main/java/com/inteligr8/alfresco/asie/model/ShardInstance.java @@ -13,7 +13,7 @@ public class ShardInstance implements Serializable { private final String spec; protected ShardInstance(Shard shard, SolrHost node) { - this.spec = shard.getSpec() + "~" + node.getSpec(); + this.spec = node.getSpec() + "~" + shard.getSpec(); } public org.alfresco.repo.index.shard.ShardInstance toAlfrescoModel(org.alfresco.repo.index.shard.Shard shard) { @@ -33,14 +33,14 @@ public class ShardInstance implements Serializable { return spec; } - public Shard extractShard() { - int pos = this.spec.indexOf('~'); - return Shard.from(this.spec.substring(0, pos)); - } - public SolrHost extractNode() { int pos = this.spec.indexOf('~'); - return SolrHost.from(this.spec.substring(pos+1)); + return SolrHost.from(this.spec.substring(0, pos)); + } + + public Shard extractShard() { + int pos = this.spec.indexOf('~'); + return Shard.from(this.spec.substring(pos+1)); } @Override diff --git a/shared/src/main/java/com/inteligr8/alfresco/asie/model/SolrHost.java b/shared/src/main/java/com/inteligr8/alfresco/asie/model/SolrHost.java index b935e97..c674e33 100644 --- a/shared/src/main/java/com/inteligr8/alfresco/asie/model/SolrHost.java +++ b/shared/src/main/java/com/inteligr8/alfresco/asie/model/SolrHost.java @@ -41,6 +41,8 @@ public class SolrHost implements Serializable { this.spec = spec; Matcher matcher = PATTERN.matcher(spec); + if (!matcher.find()) + throw new IllegalArgumentException(); this.hostname = matcher.group(1); this.port = Integer.parseInt(matcher.group(2)); this.path = matcher.group(3);