@@ -95,9 +95,9 @@ abstract class AbstractHollowProducer {
95
95
boolean isInitialized ;
96
96
97
97
private final long targetMaxTypeShardSize ;
98
- private final boolean allowTypeResharding ;
99
98
private final boolean focusHoleFillInFewestShards ;
100
-
99
+ private final boolean allowTypeResharding ;
100
+ private final boolean forceCoverageOfTypeResharding ; // exercise re-sharding often (for testing)
101
101
102
102
@ Deprecated
103
103
public AbstractHollowProducer (
@@ -106,7 +106,7 @@ public AbstractHollowProducer(
106
106
this (new HollowFilesystemBlobStager (), publisher , announcer ,
107
107
Collections .emptyList (),
108
108
new VersionMinterWithCounter (), null , 0 ,
109
- DEFAULT_TARGET_MAX_TYPE_SHARD_SIZE , false , false , null ,
109
+ DEFAULT_TARGET_MAX_TYPE_SHARD_SIZE , false , false , false , null ,
110
110
new DummyBlobStorageCleaner (), new BasicSingleProducerEnforcer (),
111
111
null , true );
112
112
}
@@ -118,7 +118,8 @@ public AbstractHollowProducer(
118
118
this (b .stager , b .publisher , b .announcer ,
119
119
b .eventListeners ,
120
120
b .versionMinter , b .snapshotPublishExecutor ,
121
- b .numStatesBetweenSnapshots , b .targetMaxTypeShardSize , b .focusHoleFillInFewestShards , b .allowTypeResharding ,
121
+ b .numStatesBetweenSnapshots , b .targetMaxTypeShardSize , b .focusHoleFillInFewestShards ,
122
+ b .allowTypeResharding , b .forceCoverageOfTypeResharding ,
122
123
b .metricsCollector , b .blobStorageCleaner , b .singleProducerEnforcer ,
123
124
b .hashCodeFinder , b .doIntegrityCheck );
124
125
}
@@ -134,6 +135,7 @@ private AbstractHollowProducer(
134
135
long targetMaxTypeShardSize ,
135
136
boolean focusHoleFillInFewestShards ,
136
137
boolean allowTypeResharding ,
138
+ boolean forceCoverageOfTypeResharding ,
137
139
HollowMetricsCollector <HollowProducerMetrics > metricsCollector ,
138
140
HollowProducer .BlobStorageCleaner blobStorageCleaner ,
139
141
SingleProducerEnforcer singleProducerEnforcer ,
@@ -150,6 +152,7 @@ private AbstractHollowProducer(
150
152
this .doIntegrityCheck = doIntegrityCheck ;
151
153
this .targetMaxTypeShardSize = targetMaxTypeShardSize ;
152
154
this .allowTypeResharding = allowTypeResharding ;
155
+ this .forceCoverageOfTypeResharding = forceCoverageOfTypeResharding ;
153
156
this .focusHoleFillInFewestShards = focusHoleFillInFewestShards ;
154
157
155
158
HollowWriteStateEngine writeEngine = hashCodeFinder == null
@@ -399,6 +402,12 @@ long runCycle(
399
402
!writeEngine .hasIdenticalSchemas (readStates .current ().getStateEngine ());
400
403
updateHeaderTags (writeEngine , toVersion , schemaChangedFromPriorVersion );
401
404
405
+ if (allowTypeResharding && forceCoverageOfTypeResharding ) {
406
+ int randomFactor = (int ) Math .pow (2 , (int ) (Math .random () * 9 ) - 4 ); // random power of 2 in the range [-4, 4]
407
+ long adjustedShardSize = targetMaxTypeShardSize * randomFactor ;
408
+ writeEngine .setTargetMaxTypeShardSize (adjustedShardSize );
409
+ }
410
+
402
411
// 3a. Publish, run checks & validation, then announce new state consumers
403
412
publish (listeners , toVersion , artifacts );
404
413
0 commit comments