Skip to content

Commit 0910fdc

Browse files
committed
Skip license refresh if no shards to allocate
1 parent dbc1557 commit 0910fdc

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

server/src/main/java/org/elasticsearch/cluster/routing/allocation/NodeAllocationStatsAndWeightsCalculator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ public Map<String, NodeAllocationStatsAndWeight> nodesAllocationStatsAndWeights(
7070
ClusterInfo clusterInfo,
7171
@Nullable DesiredBalance desiredBalance
7272
) {
73-
writeLoadForecaster.refreshLicence();
73+
if (metadata.indices().isEmpty() == false) {
74+
// must not use licensed features when just starting up
75+
writeLoadForecaster.refreshLicence();
76+
}
7477
var weightFunction = new WeightFunction(shardBalanceFactor, indexBalanceFactor, writeLoadBalanceFactor, diskUsageBalanceFactor);
7578
var avgShardsPerNode = WeightFunction.avgShardPerNode(metadata, routingNodes);
7679
var avgWriteLoadPerNode = WeightFunction.avgWriteLoadPerNode(writeLoadForecaster, metadata, routingNodes);

server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/BalancedShardsAllocator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ public BalancedShardsAllocator(ClusterSettings clusterSettings, WriteLoadForecas
145145

146146
@Override
147147
public void allocate(RoutingAllocation allocation) {
148-
writeLoadForecaster.refreshLicence();
148+
if (allocation.metadata().indices().isEmpty() == false) {
149+
// must not use licensed features when just starting up
150+
writeLoadForecaster.refreshLicence();
151+
}
149152

150153
assert allocation.ignoreDisable() == false;
151154

0 commit comments

Comments
 (0)