Skip to content

Commit 65e0502

Browse files
authored
Rename shared cache static constant settings (elastic#79999) (elastic#80255)
The FrozenCacheService contains various settings whose Java static constants have a different prefix: FROZEN_CACHE_*, SNAPSHOT_CACHE_* or SHARED_CACHE_*. This commit renames the constants so that they all start with SHARED_CACHE_ prefix.
1 parent 37327d4 commit 65e0502

File tree

14 files changed

+93
-99
lines changed

14 files changed

+93
-99
lines changed

x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/AbstractFrozenAutoscalingIntegTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
8585
.put(super.nodeSettings(nodeOrdinal, otherSettings))
8686
.put(SELF_GENERATED_LICENSE_TYPE.getKey(), "trial");
8787
if (DiscoveryNode.hasRole(otherSettings, DiscoveryNodeRole.DATA_FROZEN_NODE_ROLE)) {
88-
builder.put(FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey(), new ByteSizeValue(10, ByteSizeUnit.MB));
88+
builder.put(FrozenCacheService.SHARED_CACHE_SIZE_SETTING.getKey(), new ByteSizeValue(10, ByteSizeUnit.MB));
8989
}
9090
return builder.build();
9191
}

x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/BaseFrozenSearchableSnapshotsIntegTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
2525
Settings.Builder builder = Settings.builder().put(super.nodeSettings(nodeOrdinal, otherSettings));
2626
if (DiscoveryNode.canContainData(otherSettings)) {
2727
builder.put(
28-
FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey(),
28+
FrozenCacheService.SHARED_CACHE_SIZE_SETTING.getKey(),
2929
rarely()
3030
? randomBoolean()
3131
? new ByteSizeValue(randomIntBetween(1, 10), ByteSizeUnit.KB).getStringRep()

x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/BaseSearchableSnapshotsIntegTestCase.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
9393
);
9494
}
9595
if (randomBoolean()) {
96-
builder.put(FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey(), ByteSizeValue.ZERO.getStringRep());
96+
builder.put(FrozenCacheService.SHARED_CACHE_SIZE_SETTING.getKey(), ByteSizeValue.ZERO.getStringRep());
9797
}
9898
builder.put(
99-
FrozenCacheService.SNAPSHOT_CACHE_REGION_SIZE_SETTING.getKey(),
99+
FrozenCacheService.SHARED_CACHE_REGION_SIZE_SETTING.getKey(),
100100
rarely()
101101
? pageAligned(new ByteSizeValue(randomIntBetween(4, 1024), ByteSizeUnit.KB))
102102
: pageAligned(new ByteSizeValue(randomIntBetween(1, 10), ByteSizeUnit.MB))
@@ -111,7 +111,7 @@ protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
111111
}
112112
if (randomBoolean()) {
113113
builder.put(
114-
FrozenCacheService.FROZEN_CACHE_RECOVERY_RANGE_SIZE_SETTING.getKey(),
114+
FrozenCacheService.SHARED_CACHE_RECOVERY_RANGE_SIZE_SETTING.getKey(),
115115
rarely()
116116
? pageAligned(new ByteSizeValue(randomIntBetween(4, 1024), ByteSizeUnit.KB))
117117
: pageAligned(new ByteSizeValue(randomIntBetween(1, 10), ByteSizeUnit.MB))

x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsCanMatchOnCoordinatorIntegTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected Settings nodeSettings(int nodeOrdinal, Settings nodeSettings) {
6565
return Settings.builder()
6666
.put(super.nodeSettings(nodeOrdinal, nodeSettings))
6767
// Have a shared cache of reasonable size available on each node because tests randomize over frozen and cold allocation
68-
.put(FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey(), ByteSizeValue.ofMb(randomLongBetween(1, 10)))
68+
.put(FrozenCacheService.SHARED_CACHE_SIZE_SETTING.getKey(), ByteSizeValue.ofMb(randomLongBetween(1, 10)))
6969
.build();
7070
}
7171

x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/blob/SearchableSnapshotsBlobStoreCacheIntegTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ public static void setUpCacheSettings() {
8686
builder.put(CacheService.SNAPSHOT_CACHE_RECOVERY_RANGE_SIZE_SETTING.getKey(), blobCacheMaxLength);
8787

8888
// Frozen (shared cache) cache should be large enough to not cause direct reads
89-
builder.put(FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING.getKey(), ByteSizeValue.ofMb(128));
89+
builder.put(FrozenCacheService.SHARED_CACHE_SIZE_SETTING.getKey(), ByteSizeValue.ofMb(128));
9090
// Align ranges to match the blob cache max length
91-
builder.put(FrozenCacheService.SNAPSHOT_CACHE_REGION_SIZE_SETTING.getKey(), blobCacheMaxLength);
91+
builder.put(FrozenCacheService.SHARED_CACHE_REGION_SIZE_SETTING.getKey(), blobCacheMaxLength);
9292
builder.put(FrozenCacheService.SHARED_CACHE_RANGE_SIZE_SETTING.getKey(), blobCacheMaxLength);
93-
builder.put(FrozenCacheService.FROZEN_CACHE_RECOVERY_RANGE_SIZE_SETTING.getKey(), blobCacheMaxLength);
93+
builder.put(FrozenCacheService.SHARED_CACHE_RECOVERY_RANGE_SIZE_SETTING.getKey(), blobCacheMaxLength);
9494
cacheSettings = builder.build();
9595
}
9696

x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/shared/NodesCachesStatsIntegTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void testNodesCachesStats() throws Exception {
9696
final long cacheSize = FrozenCacheService.calculateCacheSize(clusterService.getSettings(), totalFsSize);
9797
assertThat(nodeCachesStats.getSize(), equalTo(cacheSize));
9898

99-
final long regionSize = FrozenCacheService.SNAPSHOT_CACHE_REGION_SIZE_SETTING.get(clusterService.getSettings()).getBytes();
99+
final long regionSize = FrozenCacheService.SHARED_CACHE_REGION_SIZE_SETTING.get(clusterService.getSettings()).getBytes();
100100
assertThat(nodeCachesStats.getRegionSize(), equalTo(regionSize));
101101

102102
assertThat(nodeCachesStats.getNumRegions(), equalTo(Math.toIntExact(cacheSize / regionSize)));

x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/shared/PartiallyCachedShardAllocationIntegTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
import static org.elasticsearch.index.IndexSettings.INDEX_SOFT_DELETES_SETTING;
5555
import static org.elasticsearch.test.NodeRoles.onlyRole;
5656
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
57-
import static org.elasticsearch.xpack.searchablesnapshots.cache.shared.FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING;
57+
import static org.elasticsearch.xpack.searchablesnapshots.cache.shared.FrozenCacheService.SHARED_CACHE_SIZE_SETTING;
5858
import static org.hamcrest.Matchers.equalTo;
5959
import static org.hamcrest.Matchers.hasItem;
6060

@@ -65,7 +65,7 @@ protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
6565
return Settings.builder()
6666
.put(super.nodeSettings(nodeOrdinal, otherSettings))
6767
// default to no cache: the tests create nodes with a cache configured as needed
68-
.put(SNAPSHOT_CACHE_SIZE_SETTING.getKey(), ByteSizeValue.ZERO)
68+
.put(SHARED_CACHE_SIZE_SETTING.getKey(), ByteSizeValue.ZERO)
6969
.build();
7070
}
7171

@@ -123,7 +123,7 @@ public void testPartialSearchableSnapshotNotAllocatedToNodesWithoutCache() throw
123123
.getDecisions()
124124
.stream()
125125
.anyMatch(
126-
d -> d.getExplanation().contains(SNAPSHOT_CACHE_SIZE_SETTING.getKey())
126+
d -> d.getExplanation().contains(SHARED_CACHE_SIZE_SETTING.getKey())
127127
&& d.getExplanation().contains("frozen searchable snapshot shards cannot be allocated to this node")
128128
)
129129
);
@@ -136,7 +136,7 @@ public void testPartialSearchableSnapshotAllocatedToNodesWithCache() throws Exce
136136
final List<String> newNodeNames = internalCluster().startDataOnlyNodes(
137137
between(1, 3),
138138
Settings.builder()
139-
.put(SNAPSHOT_CACHE_SIZE_SETTING.getKey(), new ByteSizeValue(randomLongBetween(1, ByteSizeValue.ofMb(10).getBytes())))
139+
.put(SHARED_CACHE_SIZE_SETTING.getKey(), new ByteSizeValue(randomLongBetween(1, ByteSizeValue.ofMb(10).getBytes())))
140140
.build()
141141
);
142142

@@ -158,7 +158,7 @@ public void testOnlyPartialSearchableSnapshotAllocatedToDedicatedFrozenNodes() t
158158
final List<String> newNodeNames = internalCluster().startNodes(
159159
between(1, 3),
160160
Settings.builder()
161-
.put(SNAPSHOT_CACHE_SIZE_SETTING.getKey(), new ByteSizeValue(randomLongBetween(1, ByteSizeValue.ofMb(10).getBytes())))
161+
.put(SHARED_CACHE_SIZE_SETTING.getKey(), new ByteSizeValue(randomLongBetween(1, ByteSizeValue.ofMb(10).getBytes())))
162162
.put(onlyRole(DiscoveryNodeRole.DATA_FROZEN_NODE_ROLE))
163163
.build()
164164
);
@@ -244,7 +244,7 @@ public void onFailure(Exception e) {
244244
final List<String> newNodes = internalCluster().startDataOnlyNodes(
245245
2,
246246
Settings.builder()
247-
.put(SNAPSHOT_CACHE_SIZE_SETTING.getKey(), new ByteSizeValue(randomLongBetween(1, ByteSizeValue.ofMb(10).getBytes())))
247+
.put(SHARED_CACHE_SIZE_SETTING.getKey(), new ByteSizeValue(randomLongBetween(1, ByteSizeValue.ofMb(10).getBytes())))
248248
.build()
249249
);
250250
final ActionFuture<RestoreSnapshotResponse> responseFuture = client().execute(MountSearchableSnapshotAction.INSTANCE, req);

x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshots.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,14 @@ public List<Setting<?>> getSettings() {
296296
CacheService.SNAPSHOT_CACHE_MAX_FILES_TO_SYNC_AT_ONCE_SETTING,
297297
CacheService.SNAPSHOT_CACHE_SYNC_SHUTDOWN_TIMEOUT,
298298
SearchableSnapshotEnableAllocationDecider.SEARCHABLE_SNAPSHOTS_ALLOCATE_ON_ROLLING_RESTART,
299-
FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING,
300-
FrozenCacheService.SNAPSHOT_CACHE_SIZE_MAX_HEADROOM_SETTING,
301-
FrozenCacheService.SNAPSHOT_CACHE_REGION_SIZE_SETTING,
299+
FrozenCacheService.SHARED_CACHE_SIZE_SETTING,
300+
FrozenCacheService.SHARED_CACHE_SIZE_MAX_HEADROOM_SETTING,
301+
FrozenCacheService.SHARED_CACHE_REGION_SIZE_SETTING,
302302
FrozenCacheService.SHARED_CACHE_RANGE_SIZE_SETTING,
303-
FrozenCacheService.FROZEN_CACHE_RECOVERY_RANGE_SIZE_SETTING,
304-
FrozenCacheService.SNAPSHOT_CACHE_MAX_FREQ_SETTING,
305-
FrozenCacheService.SNAPSHOT_CACHE_DECAY_INTERVAL_SETTING,
306-
FrozenCacheService.SNAPSHOT_CACHE_MIN_TIME_DELTA_SETTING,
303+
FrozenCacheService.SHARED_CACHE_RECOVERY_RANGE_SIZE_SETTING,
304+
FrozenCacheService.SHARED_CACHE_MAX_FREQ_SETTING,
305+
FrozenCacheService.SHARED_CACHE_DECAY_INTERVAL_SETTING,
306+
FrozenCacheService.SHARED_CACHE_MIN_TIME_DELTA_SETTING,
307307
BlobStoreCacheMaintenanceService.SNAPSHOT_SNAPSHOT_CLEANUP_INTERVAL_SETTING,
308308
BlobStoreCacheMaintenanceService.SNAPSHOT_SNAPSHOT_CLEANUP_KEEP_ALIVE_SETTING,
309309
BlobStoreCacheMaintenanceService.SNAPSHOT_SNAPSHOT_CLEANUP_BATCH_SIZE_SETTING,

x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/action/cache/FrozenCacheInfoNodeAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import java.io.IOException;
2323

24-
import static org.elasticsearch.xpack.searchablesnapshots.cache.shared.FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING;
24+
import static org.elasticsearch.xpack.searchablesnapshots.cache.shared.FrozenCacheService.SHARED_CACHE_SIZE_SETTING;
2525

2626
public class FrozenCacheInfoNodeAction extends ActionType<FrozenCacheInfoResponse> {
2727

@@ -53,7 +53,7 @@ public static class TransportAction extends HandledTransportAction<Request, Froz
5353
@Inject
5454
public TransportAction(Settings settings, TransportService transportService, ActionFilters actionFilters) {
5555
super(NAME, transportService, actionFilters, Request::new);
56-
response = new FrozenCacheInfoResponse(SNAPSHOT_CACHE_SIZE_SETTING.get(settings).isNonZeroSize());
56+
response = new FrozenCacheInfoResponse(SHARED_CACHE_SIZE_SETTING.get(settings).isNonZeroSize());
5757
}
5858

5959
@Override

x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/allocation/decider/HasFrozenCacheAllocationDecider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import org.elasticsearch.snapshots.SearchableSnapshotsSettings;
2020
import org.elasticsearch.xpack.searchablesnapshots.cache.shared.FrozenCacheInfoService;
2121

22-
import static org.elasticsearch.xpack.searchablesnapshots.cache.shared.FrozenCacheService.SNAPSHOT_CACHE_SIZE_SETTING;
22+
import static org.elasticsearch.xpack.searchablesnapshots.cache.shared.FrozenCacheService.SHARED_CACHE_SIZE_SETTING;
2323

2424
public class HasFrozenCacheAllocationDecider extends AllocationDecider {
2525

@@ -28,7 +28,7 @@ public class HasFrozenCacheAllocationDecider extends AllocationDecider {
2828
private static final Decision STILL_FETCHING = Decision.single(
2929
Decision.Type.THROTTLE,
3030
NAME,
31-
"value of [" + SNAPSHOT_CACHE_SIZE_SETTING.getKey() + "] on this node is not known yet"
31+
"value of [" + SHARED_CACHE_SIZE_SETTING.getKey() + "] on this node is not known yet"
3232
);
3333

3434
private static final Decision HAS_FROZEN_CACHE = Decision.single(
@@ -41,7 +41,7 @@ public class HasFrozenCacheAllocationDecider extends AllocationDecider {
4141
Decision.Type.NO,
4242
NAME,
4343
"node setting ["
44-
+ SNAPSHOT_CACHE_SIZE_SETTING.getKey()
44+
+ SHARED_CACHE_SIZE_SETTING.getKey()
4545
+ "] is set to zero, or the node is not a ["
4646
+ DiscoveryNodeRole.DATA_FROZEN_NODE_ROLE.roleName()
4747
+ "] node, so frozen searchable snapshot shards cannot be allocated to this node"

0 commit comments

Comments
 (0)