Skip to content

Commit 790919f

Browse files
committed
Remvoing String format in RemoteStoreMigrationAllocationDecider
Signed-off-by: RS146BIJAY <[email protected]>
1 parent 47feca7 commit 790919f

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

server/src/main/java/org/opensearch/cluster/routing/allocation/decider/RemoteStoreMigrationAllocationDecider.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
101101
if (migrationDirection.equals(Direction.NONE)) {
102102
// remote backed indices on docrep nodes and non remote backed indices on remote nodes are not allowed
103103
boolean isNoDecision = remoteSettingsBackedIndex ^ targetNode.isRemoteStoreNode();
104-
String reason = String.format(Locale.ROOT, " for %sremote store backed index", remoteSettingsBackedIndex ? "" : "non ");
104+
String reason = " for " + (remoteSettingsBackedIndex ? "" : "non ") + "remote store backed index";
105105
return allocation.decision(
106106
isNoDecision ? Decision.NO : Decision.YES,
107107
NAME,
@@ -114,11 +114,9 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing
114114
// check for remote store backed indices
115115
if (remoteSettingsBackedIndex && targetNode.isRemoteStoreNode() == false) {
116116
// allocations and relocations must be to a remote node
117-
String reason = String.format(
118-
Locale.ROOT,
119-
" because a remote store backed index's shard copy can only be %s to a remote node",
120-
((shardRouting.assignedToNode() == false) ? "allocated" : "relocated")
121-
);
117+
String reason = new StringBuilder(" because a remote store backed index's shard copy can only be ")
118+
.append((shardRouting.assignedToNode() == false) ? "allocated" : "relocated")
119+
.append(" to a remote node").toString();
122120
return allocation.decision(Decision.NO, NAME, getDecisionDetails(false, shardRouting, targetNode, reason));
123121
}
124122

@@ -168,16 +166,10 @@ private Decision replicaShardDecision(ShardRouting replicaShardRouting, Discover
168166

169167
// get detailed reason for the decision
170168
private String getDecisionDetails(boolean isYes, ShardRouting shardRouting, DiscoveryNode targetNode, String reason) {
171-
return String.format(
172-
Locale.ROOT,
173-
"[%s migration_direction]: %s shard copy %s be %s to a %s node%s",
174-
migrationDirection.direction,
175-
(shardRouting.primary() ? "primary" : "replica"),
176-
(isYes ? "can" : "can not"),
177-
((shardRouting.assignedToNode() == false) ? "allocated" : "relocated"),
178-
(targetNode.isRemoteStoreNode() ? "remote" : "non-remote"),
179-
reason
180-
);
169+
return new StringBuilder("[").append(migrationDirection.direction).append(" migration_direction]: ")
170+
.append(shardRouting.primary() ? "primary" : "replica").append(" shard copy ").append(isYes ? "can" : "can not")
171+
.append(" be ").append((shardRouting.assignedToNode() == false) ? "allocated" : "relocated").append(" to a ")
172+
.append(targetNode.isRemoteStoreNode() ? "remote" : "non-remote").append(" node ").append(reason).toString();
181173
}
182174

183175
}

0 commit comments

Comments
 (0)