Skip to content

Commit 6c5ecde

Browse files
int is enough.
1 parent 1596b6d commit 6c5ecde

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

x-pack/plugin/autoscaling/src/main/java/org/elasticsearch/xpack/autoscaling/shards/FrozenShardsDeciderService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ public String name() {
5353
@Override
5454
public AutoscalingDeciderResult scale(Settings configuration, AutoscalingDeciderContext context) {
5555
// we assume that nodes do not grow beyond 64GB here.
56-
long shards = countFrozenShards(context.state().metadata());
56+
int shards = countFrozenShards(context.state().metadata());
5757
long memory = shards * MEMORY_PER_SHARD.get(configuration).getBytes();
5858
return new AutoscalingDeciderResult(AutoscalingCapacity.builder().total(null, memory).build(), new FrozenShardsReason(shards));
5959
}
6060

61-
static long countFrozenShards(Metadata metadata) {
61+
static int countFrozenShards(Metadata metadata) {
6262
return StreamSupport.stream(metadata.spliterator(), false)
6363
.filter(imd -> isFrozenIndex(imd.getSettings()))
64-
.mapToLong(IndexMetadata::getTotalNumberOfShards)
64+
.mapToInt(IndexMetadata::getTotalNumberOfShards)
6565
.sum();
6666
}
6767

x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/shards/FrozenShardsDeciderServiceTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ public void testIsFrozenIndex() {
4242

4343
public void testCountFrozenShards() {
4444
final Metadata.Builder builder = Metadata.builder();
45-
long count = 0;
45+
int count = 0;
4646
for (int i = 0; i < randomInt(20); ++i) {
4747
int shards = between(1, 3);
4848
int replicas = between(0, 2);
4949
String tierPreference = randomBoolean() ? DataTier.DATA_FROZEN : randomNonFrozenTierPreference();
5050
if (Objects.equals(tierPreference, DataTier.DATA_FROZEN)) {
51-
count += (long) shards * (replicas + 1);
51+
count += shards * (replicas + 1);
5252
}
5353
builder.put(
5454
IndexMetadata.builder("index" + i).settings(indexSettings(tierPreference)).numberOfShards(shards).numberOfReplicas(replicas)

0 commit comments

Comments
 (0)