Skip to content

Commit d35428f

Browse files
authored
rename evictImmediatelyOnHoldRelease to areWeakEntriesEphemeral (#18900)
1 parent 8b5533b commit d35428f

File tree

6 files changed

+33
-27
lines changed

6 files changed

+33
-27
lines changed

indexing-service/src/test/java/org/apache/druid/indexing/common/task/CompactionTaskRunTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2073,7 +2073,7 @@ public boolean isVirtualStorage()
20732073
}
20742074

20752075
@Override
2076-
public boolean isVirtualStorageFabricEvictImmediatelyOnHoldRelease()
2076+
public boolean isVirtualStorageEphemeral()
20772077
{
20782078
return true;
20792079
}

server/src/main/java/org/apache/druid/segment/loading/SegmentLoaderConfig.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ public class SegmentLoaderConfig
8282
* waiting for space pressure to trigger eviction. This setting is not intended to be configured directly by
8383
* administrators. Instead, it is expected to be set when appropriate via {@link #setVirtualStorage}.
8484
*/
85-
@JsonProperty("virtualStorageFabricEvictImmediatelyOnHoldRelease")
86-
private boolean virtualStorageFabricEvictImmediatelyOnHoldRelease = false;
85+
@JsonProperty("virtualStorageIsEphemeral")
86+
private boolean virtualStorageIsEphemeral = false;
8787

8888
private long combinedMaxSize = 0;
8989

@@ -162,9 +162,9 @@ public int getVirtualStorageLoadThreads()
162162
return virtualStorageLoadThreads;
163163
}
164164

165-
public boolean isVirtualStorageFabricEvictImmediatelyOnHoldRelease()
165+
public boolean isVirtualStorageEphemeral()
166166
{
167-
return virtualStorageFabricEvictImmediatelyOnHoldRelease;
167+
return virtualStorageIsEphemeral;
168168
}
169169

170170
public SegmentLoaderConfig setLocations(List<StorageLocationConfig> locations)
@@ -174,15 +174,15 @@ public SegmentLoaderConfig setLocations(List<StorageLocationConfig> locations)
174174
}
175175

176176
/**
177-
* Sets {@link #virtualStorage} and {@link #virtualStorageFabricEvictImmediatelyOnHoldRelease}.
177+
* Sets {@link #virtualStorage} and {@link #virtualStorageIsEphemeral}.
178178
*/
179179
public SegmentLoaderConfig setVirtualStorage(
180180
boolean virtualStorage,
181-
boolean virtualStorageFabricEvictImmediatelyOnHoldRelease
181+
boolean virtualStorageFabricEphemeral
182182
)
183183
{
184184
this.virtualStorage = virtualStorage;
185-
this.virtualStorageFabricEvictImmediatelyOnHoldRelease = virtualStorageFabricEvictImmediatelyOnHoldRelease;
185+
this.virtualStorageIsEphemeral = virtualStorageFabricEphemeral;
186186
return this;
187187
}
188188

@@ -216,9 +216,9 @@ public String toString()
216216
", numThreadsToLoadSegmentsIntoPageCacheOnBootstrap=" + numThreadsToLoadSegmentsIntoPageCacheOnBootstrap +
217217
", infoDir=" + infoDir +
218218
", statusQueueMaxSize=" + statusQueueMaxSize +
219-
", useVirtualStorageFabric=" + virtualStorage +
220-
", virtualStorageFabricLoadThreads=" + virtualStorageLoadThreads +
221-
", virtualStorageFabricEvictImmediatelyOnHoldRelease=" + virtualStorageFabricEvictImmediatelyOnHoldRelease +
219+
", virtualStorage=" + virtualStorage +
220+
", virtualStorageLoadThreads=" + virtualStorageLoadThreads +
221+
", virtualStorageIsEphemeral=" + virtualStorageIsEphemeral +
222222
", combinedMaxSize=" + combinedMaxSize +
223223
'}';
224224
}

server/src/main/java/org/apache/druid/segment/loading/SegmentLocalCacheManager.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ public SegmentLocalCacheManager(
147147
if (config.getNumThreadsToLoadSegmentsIntoPageCacheOnBootstrap() > 0) {
148148
throw DruidException.defensive("Invalid configuration: virtualStorage is incompatible with numThreadsToLoadSegmentsIntoPageCacheOnBootstrap");
149149
}
150-
if (config.isVirtualStorageFabricEvictImmediatelyOnHoldRelease()) {
150+
if (config.isVirtualStorageEphemeral()) {
151151
for (StorageLocation location : locations) {
152-
location.setEvictImmediatelyOnHoldRelease(true);
152+
location.setAreWeakEntriesEphemeral(true);
153153
}
154154
}
155155
virtualStorageLoadOnDemandExec =
@@ -533,9 +533,9 @@ private AcquireSegmentAction acquireExistingSegment(SegmentCacheEntryIdentifier
533533
public void load(final DataSegment dataSegment) throws SegmentLoadingException
534534
{
535535
if (config.isVirtualStorage()) {
536-
if (config.isVirtualStorageFabricEvictImmediatelyOnHoldRelease()) {
536+
if (config.isVirtualStorageEphemeral()) {
537537
throw DruidException.defensive(
538-
"load() should not be called when virtualStorageFabricEvictImmediatelyOnHoldRelease is enabled"
538+
"load() should not be called when virtualStorageIsEphemeral is true"
539539
);
540540
}
541541
// virtual storage doesn't do anything with loading immediately, but check to see if the segment is already cached
@@ -579,9 +579,9 @@ public void bootstrap(
579579
) throws SegmentLoadingException
580580
{
581581
if (config.isVirtualStorage()) {
582-
if (config.isVirtualStorageFabricEvictImmediatelyOnHoldRelease()) {
582+
if (config.isVirtualStorageEphemeral()) {
583583
throw DruidException.defensive(
584-
"bootstrap() should not be called when virtualStorageFabricEvictImmediatelyOnHoldRelease is enabled"
584+
"bootstrap() should not be called when virtualStorageIsEphemeral is true"
585585
);
586586
}
587587
// during bootstrap, check if the segment exists in a location and mount it, getCachedSegments already
@@ -1083,7 +1083,7 @@ public void mount(StorageLocation mountLocation) throws SegmentLoadingException
10831083
unmount();
10841084
}
10851085

1086-
if (config.isVirtualStorageFabricEvictImmediatelyOnHoldRelease()) {
1086+
if (config.isVirtualStorageEphemeral()) {
10871087
setDeleteInfoFileOnUnmount();
10881088
}
10891089
}

server/src/main/java/org/apache/druid/segment/loading/StorageLocation.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@
8080
* is repeated until either a sufficient amount of space has been reclaimed, or no additional space is able to be
8181
* reclaimed, in which case the new reservation fails.
8282
* <p>
83+
* There is an auxilary mode for weak references when {@link #areWeakEntriesEphemeral} is set to true. In this mode, weak
84+
* entries are short-lived entries that only exist while one or more reservation hold are active, and are unmounted when
85+
* the holds are released. This is useful in cases where entries are unlikely to be re-used such as in asynchronous
86+
* tasks.
87+
* <p>
8388
* This class is thread-safe, so that multiple threads can update its state at the same time.
8489
* One example usage is that a historical server can use multiple threads to load different segments in parallel
8590
* from deep storage.
@@ -106,7 +111,7 @@ public class StorageLocation
106111
@GuardedBy("lock")
107112
private WeakCacheEntry hand;
108113

109-
private volatile boolean evictImmediatelyOnHoldRelease = false;
114+
private volatile boolean areWeakEntriesEphemeral = false;
110115

111116
/**
112117
* Current total size of files in bytes, including weak entries.
@@ -170,11 +175,12 @@ public File getPath()
170175
}
171176

172177
/**
173-
* Sets whether weak cache entries should be immediately evicted once all holds are released.
178+
* Sets whether weak cache entries should be retained after all holds are released. If true, weak references are
179+
* removed and unmounted immediately after all holds are released
174180
*/
175-
public void setEvictImmediatelyOnHoldRelease(final boolean evictImmediatelyOnHoldRelease)
181+
public void setAreWeakEntriesEphemeral(final boolean areWeakEntriesEphemeral)
176182
{
177-
this.evictImmediatelyOnHoldRelease = evictImmediatelyOnHoldRelease;
183+
this.areWeakEntriesEphemeral = areWeakEntriesEphemeral;
178184
}
179185

180186
public <T extends CacheEntry> T getStaticCacheEntry(CacheEntryIdentifier entryId)
@@ -448,7 +454,7 @@ private Runnable createWeakEntryReleaseRunnable(
448454
return () -> {
449455
weakEntry.release();
450456

451-
if (!isNewEntry && !evictImmediatelyOnHoldRelease) {
457+
if (!isNewEntry && !areWeakEntriesEphemeral) {
452458
// No need to consider removal from weakCacheEntries on hold release.
453459
return;
454460
}
@@ -462,7 +468,7 @@ private Runnable createWeakEntryReleaseRunnable(
462468
// Furthermore, if evictImmediatelyOnHoldRelease is set, evict on release if all holds are gone.
463469
final boolean isMounted = weakCacheEntry.cacheEntry.isMounted();
464470
if ((isNewEntry && !isMounted)
465-
|| (evictImmediatelyOnHoldRelease && !weakCacheEntry.isHeld())) {
471+
|| (areWeakEntriesEphemeral && !weakCacheEntry.isHeld())) {
466472
unlinkWeakEntry(weakCacheEntry);
467473
weakCacheEntry.unmount(); // call even if never mounted, to terminate the phaser
468474
if (isMounted) {

server/src/test/java/org/apache/druid/segment/loading/SegmentLoaderConfigTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ public void testSetVirtualStorage()
3131

3232
// Verify default values
3333
Assert.assertFalse(config.isVirtualStorage());
34-
Assert.assertFalse(config.isVirtualStorageFabricEvictImmediatelyOnHoldRelease());
34+
Assert.assertFalse(config.isVirtualStorageEphemeral());
3535

3636
// Set both to true
3737
config.setVirtualStorage(true, true);
3838

3939
// Verify both fields are set
4040
Assert.assertTrue(config.isVirtualStorage());
41-
Assert.assertTrue(config.isVirtualStorageFabricEvictImmediatelyOnHoldRelease());
41+
Assert.assertTrue(config.isVirtualStorageEphemeral());
4242
}
4343
}

server/src/test/java/org/apache/druid/segment/loading/SegmentLocalCacheManagerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ public boolean isVirtualStorage()
11971197
}
11981198

11991199
@Override
1200-
public boolean isVirtualStorageFabricEvictImmediatelyOnHoldRelease()
1200+
public boolean isVirtualStorageEphemeral()
12011201
{
12021202
return true;
12031203
}

0 commit comments

Comments
 (0)