Skip to content

Commit

Permalink
HollowConsumerBuilder override HollowUpdatePlanner
Browse files Browse the repository at this point in the history
  • Loading branch information
mengqwang committed Aug 14, 2024
1 parent 3fb3819 commit e98434e
Showing 1 changed file with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.netflix.hollow.api.client.FailedTransitionTracker;
import com.netflix.hollow.api.client.HollowAPIFactory;
import com.netflix.hollow.api.client.HollowClientUpdater;
import com.netflix.hollow.api.client.IHollowUpdatePlanner;
import com.netflix.hollow.api.client.StaleHollowReferenceDetector;
import com.netflix.hollow.api.codegen.HollowAPIClassJavaGenerator;
import com.netflix.hollow.api.consumer.fs.HollowFilesystemBlobRetriever;
Expand Down Expand Up @@ -190,16 +191,30 @@ protected <B extends Builder<B>> HollowConsumer(B builder) {
// duplicated with HollowConsumer(...) constructor above. We cannot chain constructor calls because that
// constructor subscribes to the announcement watcher and we have more setup to do first
this.metrics = new HollowConsumerMetrics();
this.updater = new HollowClientUpdater(builder.blobRetriever,
builder.refreshListeners,
builder.apiFactory,
builder.doubleSnapshotConfig,
builder.hashCodeFinder,
builder.memoryMode,
builder.objectLongevityConfig,
builder.objectLongevityDetector,
metrics,
builder.metricsCollector);
if (builder.hollowUpdatePlanner != null) {
this.updater = new HollowClientUpdater(
builder.refreshListeners,
builder.apiFactory,
builder.doubleSnapshotConfig,
builder.hashCodeFinder,
builder.memoryMode,
builder.objectLongevityConfig,
builder.objectLongevityDetector,
metrics,
builder.metricsCollector,
builder.hollowUpdatePlanner);
} else {
this.updater = new HollowClientUpdater(builder.blobRetriever,
builder.refreshListeners,
builder.apiFactory,
builder.doubleSnapshotConfig,
builder.hashCodeFinder,
builder.memoryMode,
builder.objectLongevityConfig,
builder.objectLongevityDetector,
metrics,
builder.metricsCollector);
}
updater.setFilter(builder.typeFilter);
if(builder.skipTypeShardUpdateWithNoAdditions)
updater.setSkipShardUpdateWithNoAdditions(true);
Expand Down Expand Up @@ -1085,6 +1100,7 @@ public static class Builder<B extends HollowConsumer.Builder<B>> {
protected MemoryMode memoryMode = MemoryMode.ON_HEAP;
protected HollowMetricsCollector<HollowConsumerMetrics> metricsCollector;
protected boolean skipTypeShardUpdateWithNoAdditions = false;
protected IHollowUpdatePlanner hollowUpdatePlanner = null;

public B withBlobRetriever(HollowConsumer.BlobRetriever blobRetriever) {
this.blobRetriever = blobRetriever;
Expand Down Expand Up @@ -1156,6 +1172,11 @@ public B withRefreshListeners(HollowConsumer.RefreshListener... refreshListeners
return (B)this;
}

public B withHollowUpdatePlanner(IHollowUpdatePlanner hollowUpdatePlanner) {
this.hollowUpdatePlanner = hollowUpdatePlanner;
return (B)this;
}

/**
* Provide the code generated API class that extends {@link HollowAPI} with one or more types
* cached for direct field reads.
Expand Down

0 comments on commit e98434e

Please sign in to comment.