Skip to content

Commit dffccf0

Browse files
committed
removing unnecessary code
1 parent e43301d commit dffccf0

File tree

8 files changed

+5
-82
lines changed

8 files changed

+5
-82
lines changed

client/src/main/java/io/split/client/HttpSegmentChangeFetcher.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
1515
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
1616
import org.apache.hc.core5.http.HttpStatus;
17-
import org.apache.hc.core5.http.Header;
1817
import org.apache.hc.core5.http.io.entity.EntityUtils;
1918
import org.apache.hc.core5.net.URIBuilder;
2019
import org.slf4j.Logger;
@@ -23,8 +22,6 @@
2322
import java.net.URI;
2423
import java.net.URISyntaxException;
2524
import java.nio.charset.StandardCharsets;
26-
import java.util.Arrays;
27-
import java.util.stream.Collectors;
2825

2926
import static com.google.common.base.Preconditions.checkNotNull;
3027

@@ -40,9 +37,6 @@ public final class HttpSegmentChangeFetcher implements SegmentChangeFetcher {
4037
private static final String CACHE_CONTROL_HEADER_NAME = "Cache-Control";
4138
private static final String CACHE_CONTROL_HEADER_VALUE = "no-cache";
4239

43-
private static final String HEADER_FASTLY_DEBUG_NAME = "Fastly-Debug";
44-
private static final String HEADER_FASTLY_DEBUG_VALUE = "1";
45-
4640
private final CloseableHttpClient _client;
4741
private final URI _target;
4842
private final TelemetryRuntimeProducer _telemetryRuntimeProducer;
@@ -81,10 +75,6 @@ public SegmentChange fetch(String segmentName, long since, FetchOptions options)
8175
request.setHeader(CACHE_CONTROL_HEADER_NAME, CACHE_CONTROL_HEADER_VALUE);
8276
}
8377

84-
if (options.fastlyDebugHeaderEnabled()) {
85-
request.addHeader(HEADER_FASTLY_DEBUG_NAME, HEADER_FASTLY_DEBUG_VALUE);
86-
}
87-
8878
response = _client.execute(request);
8979

9080
int statusCode = response.getCode();

client/src/main/java/io/split/client/HttpSplitChangeFetcher.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ public final class HttpSplitChangeFetcher implements SplitChangeFetcher {
3838
private static final String HEADER_CACHE_CONTROL_NAME = "Cache-Control";
3939
private static final String HEADER_CACHE_CONTROL_VALUE = "no-cache";
4040

41-
private static final String HEADER_FASTLY_DEBUG_NAME = "Fastly-Debug";
42-
private static final String HEADER_FASTLY_DEBUG_VALUE = "1";
43-
4441
private final CloseableHttpClient _client;
4542
private final URI _target;
4643
private final TelemetryRuntimeProducer _telemetryRuntimeProducer;
@@ -84,10 +81,6 @@ public SplitChange fetch(long since, FetchOptions options) {
8481
request.setHeader(HEADER_CACHE_CONTROL_NAME, HEADER_CACHE_CONTROL_VALUE);
8582
}
8683

87-
if (options.fastlyDebugHeaderEnabled()) {
88-
request.addHeader(HEADER_FASTLY_DEBUG_NAME, HEADER_FASTLY_DEBUG_VALUE);
89-
}
90-
9184
response = _client.execute(request);
9285

9386
int statusCode = response.getCode();

client/src/main/java/io/split/client/SplitClientConfig.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public class SplitClientConfig {
7373
private final int _uniqueKeysRefreshRateInMemory;
7474
private final int _uniqueKeysRefreshRateRedis;
7575
private static int _filterUniqueKeysRefreshRate;
76-
private final boolean _cdnDebugLogging;
7776
private final OperationMode _operationMode;
7877
private long _validateAfterInactivityInMillis;
7978
private final long _startingSyncCallBackoffBaseMs;
@@ -135,7 +134,6 @@ private SplitClientConfig(String endpoint,
135134
int onDemandFetchRetryDelayMs,
136135
int onDemandFetchMaxRetries,
137136
int failedAttemptsBeforeLogging,
138-
boolean cdnDebugLogging,
139137
OperationMode operationMode,
140138
long validateAfterInactivityInMillis,
141139
long startingSyncCallBackoffBaseMs,
@@ -190,7 +188,6 @@ private SplitClientConfig(String endpoint,
190188
_onDemandFetchRetryDelayMs = onDemandFetchRetryDelayMs;
191189
_onDemandFetchMaxRetries = onDemandFetchMaxRetries;
192190
_failedAttemptsBeforeLogging = failedAttemptsBeforeLogging;
193-
_cdnDebugLogging = cdnDebugLogging;
194191
_operationMode = operationMode;
195192
_storageMode = storageMode;
196193
_validateAfterInactivityInMillis = validateAfterInactivityInMillis;
@@ -367,8 +364,6 @@ public int get_telemetryRefreshRate() {
367364

368365
public int failedAttemptsBeforeLogging() {return _failedAttemptsBeforeLogging;}
369366

370-
public boolean cdnDebugLogging() { return _cdnDebugLogging; }
371-
372367
public OperationMode operationMode() { return _operationMode;}
373368

374369
public long validateAfterInactivityInMillis() {
@@ -445,7 +440,6 @@ public static final class Builder {
445440
private int _onDemandFetchRetryDelayMs = 50;
446441
private final int _onDemandFetchMaxRetries = 10;
447442
private final int _failedAttemptsBeforeLogging = 10;
448-
private final boolean _cdnDebugLogging = true;
449443
private OperationMode _operationMode = OperationMode.STANDALONE;
450444
private long _validateAfterInactivityInMillis = 1000;
451445
private static final long STARTING_SYNC_CALL_BACKOFF_BASE_MS = 1000; //backoff base starting at 1 seconds
@@ -1086,7 +1080,6 @@ public SplitClientConfig build() {
10861080
_onDemandFetchRetryDelayMs,
10871081
_onDemandFetchMaxRetries,
10881082
_failedAttemptsBeforeLogging,
1089-
_cdnDebugLogging,
10901083
_operationMode,
10911084
_validateAfterInactivityInMillis,
10921085
STARTING_SYNC_CALL_BACKOFF_BASE_MS,

client/src/main/java/io/split/engine/common/FetchOptions.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public Builder() {}
1313
public Builder(FetchOptions opts) {
1414
_targetCN = opts._targetCN;
1515
_cacheControlHeaders = opts._cacheControlHeaders;
16-
_fastlyDebugHeader = opts._fastlyDebugHeader;
1716
_flagSetsFilter = opts._flagSetsFilter;
1817
}
1918

@@ -22,11 +21,6 @@ public Builder cacheControlHeaders(boolean on) {
2221
return this;
2322
}
2423

25-
public Builder fastlyDebugHeader(boolean on) {
26-
_fastlyDebugHeader = on;
27-
return this;
28-
}
29-
3024
public Builder targetChangeNumber(long targetCN) {
3125
_targetCN = targetCN;
3226
return this;
@@ -38,23 +32,18 @@ public Builder flagSetsFilter(String flagSetsFilter) {
3832
}
3933

4034
public FetchOptions build() {
41-
return new FetchOptions(_cacheControlHeaders, _targetCN, _fastlyDebugHeader, _flagSetsFilter);
35+
return new FetchOptions(_cacheControlHeaders, _targetCN, _flagSetsFilter);
4236
}
4337

4438
private long _targetCN = DEFAULT_TARGET_CHANGENUMBER;
4539
private boolean _cacheControlHeaders = false;
46-
private boolean _fastlyDebugHeader = false;
4740
private String _flagSetsFilter = "";
4841
}
4942

5043
public boolean cacheControlHeadersEnabled() {
5144
return _cacheControlHeaders;
5245
}
5346

54-
public boolean fastlyDebugHeaderEnabled() {
55-
return _fastlyDebugHeader;
56-
}
57-
5847
public long targetCN() { return _targetCN; }
5948

6049
public boolean hasCustomCN() { return _targetCN != DEFAULT_TARGET_CHANGENUMBER; }
@@ -65,11 +54,9 @@ public String flagSetsFilter() {
6554

6655
private FetchOptions(boolean cacheControlHeaders,
6756
long targetCN,
68-
boolean fastlyDebugHeader,
6957
String flagSetsFilter) {
7058
_cacheControlHeaders = cacheControlHeaders;
7159
_targetCN = targetCN;
72-
_fastlyDebugHeader = fastlyDebugHeader;
7360
_flagSetsFilter = flagSetsFilter;
7461
}
7562

@@ -82,19 +69,17 @@ public boolean equals(Object obj) {
8269
FetchOptions other = (FetchOptions) obj;
8370

8471
return Objects.equals(_cacheControlHeaders, other._cacheControlHeaders)
85-
&& Objects.equals(_fastlyDebugHeader, other._fastlyDebugHeader)
8672
&& Objects.equals(_targetCN, other._targetCN)
8773
&& Objects.equals(_flagSetsFilter, other._flagSetsFilter);
8874
}
8975

9076
@Override
9177
public int hashCode() {
92-
return com.google.common.base.Objects.hashCode(_cacheControlHeaders, _fastlyDebugHeader,
78+
return com.google.common.base.Objects.hashCode(_cacheControlHeaders,
9379
_targetCN, _flagSetsFilter);
9480
}
9581

9682
private final boolean _cacheControlHeaders;
97-
private final boolean _fastlyDebugHeader;
9883
private final long _targetCN;
9984
private final String _flagSetsFilter;
10085
}

client/src/main/java/io/split/engine/common/SyncManagerImp.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ public static SyncManagerImp build(SplitTasks splitTasks,
9898
config.streamingRetryDelay(),
9999
config.streamingFetchMaxRetries(),
100100
config.failedAttemptsBeforeLogging(),
101-
config.cdnDebugLogging(),
102101
config.getSetsFilter());
103102

104103
PushManager pushManager = PushManagerImp.build(synchronizer,

client/src/main/java/io/split/engine/common/SynchronizerImp.java

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import io.split.client.events.EventsTask;
44
import io.split.client.impressions.ImpressionsManager;
55
import io.split.client.impressions.UniqueKeysTracker;
6-
import io.split.client.utils.Json;
76
import io.split.engine.experiments.FetchResult;
87
import io.split.engine.experiments.SplitFetcher;
98
import io.split.engine.experiments.SplitSynchronizationTask;
@@ -17,8 +16,6 @@
1716
import org.slf4j.LoggerFactory;
1817

1918
import java.util.HashSet;
20-
import java.util.List;
21-
import java.util.Map;
2219
import java.util.function.Function;
2320
import java.util.stream.Collectors;
2421

@@ -45,7 +42,6 @@ public class SynchronizerImp implements Synchronizer {
4542
private final int _onDemandFetchRetryDelayMs;
4643
private final int _onDemandFetchMaxRetries;
4744
private final int _failedAttemptsBeforeLogging;
48-
private final boolean _cdnResponseHeadersLogging;
4945
private final String _sets;
5046

5147
public SynchronizerImp(SplitTasks splitTasks,
@@ -55,15 +51,13 @@ public SynchronizerImp(SplitTasks splitTasks,
5551
int onDemandFetchRetryDelayMs,
5652
int onDemandFetchMaxRetries,
5753
int failedAttemptsBeforeLogging,
58-
boolean cdnResponseHeadersLogging,
5954
HashSet<String> sets) {
6055
_splitSynchronizationTask = checkNotNull(splitTasks.getSplitSynchronizationTask());
6156
_splitFetcher = checkNotNull(splitFetcher);
6257
_segmentSynchronizationTaskImp = checkNotNull(splitTasks.getSegmentSynchronizationTask());
6358
_splitCacheProducer = checkNotNull(splitCacheProducer);
6459
this.segmentCacheProducer = checkNotNull(segmentCacheProducer);
6560
_onDemandFetchRetryDelayMs = checkNotNull(onDemandFetchRetryDelayMs);
66-
_cdnResponseHeadersLogging = cdnResponseHeadersLogging;
6761
_onDemandFetchMaxRetries = onDemandFetchMaxRetries;
6862
_failedAttemptsBeforeLogging = failedAttemptsBeforeLogging;
6963
_impressionManager = splitTasks.getImpressionManager();
@@ -135,12 +129,6 @@ private SyncResult attemptSplitsSync(long targetChangeNumber,
135129
}
136130
}
137131

138-
private void logCdnHeaders(String prefix, int maxRetries, int remainingAttempts, List<Map<String, String>> headers) {
139-
if (maxRetries - remainingAttempts > _failedAttemptsBeforeLogging) {
140-
_log.info(String.format("%s: CDN Debug headers: %s", prefix, Json.toJson(headers)));
141-
}
142-
}
143-
144132
@Override
145133
public void refreshSplits(Long targetChangeNumber) {
146134

@@ -151,7 +139,6 @@ public void refreshSplits(Long targetChangeNumber) {
151139
FastlyHeadersCaptor captor = new FastlyHeadersCaptor();
152140
FetchOptions opts = new FetchOptions.Builder()
153141
.cacheControlHeaders(true)
154-
.fastlyDebugHeader(_cdnResponseHeadersLogging)
155142
.flagSetsFilter(_sets)
156143
.build();
157144

@@ -161,9 +148,7 @@ public void refreshSplits(Long targetChangeNumber) {
161148
int attempts = _onDemandFetchMaxRetries - regularResult.remainingAttempts();
162149
if (regularResult.success()) {
163150
_log.debug(String.format("Refresh completed in %s attempts.", attempts));
164-
if (_cdnResponseHeadersLogging) {
165-
logCdnHeaders("[splits]", _onDemandFetchMaxRetries , regularResult.remainingAttempts(), captor.get());
166-
}
151+
167152
regularResult._fetchResult.getSegments().stream()
168153
.forEach(segmentName -> forceRefreshSegment(segmentName));
169154
return;
@@ -183,11 +168,6 @@ public void refreshSplits(Long targetChangeNumber) {
183168
} else {
184169
_log.debug(String.format("No changes fetched after %s attempts with CDN bypassed.", withoutCDNAttempts));
185170
}
186-
187-
if (_cdnResponseHeadersLogging) {
188-
logCdnHeaders("[splits]", _onDemandFetchMaxRetries + ON_DEMAND_FETCH_BACKOFF_MAX_RETRIES,
189-
withCDNBypassed.remainingAttempts(), captor.get());
190-
}
191171
}
192172

193173
@Override
@@ -237,7 +217,6 @@ public void refreshSegment(String segmentName, Long targetChangeNumber) {
237217
FastlyHeadersCaptor captor = new FastlyHeadersCaptor();
238218
FetchOptions opts = new FetchOptions.Builder()
239219
.cacheControlHeaders(true)
240-
.fastlyDebugHeader(_cdnResponseHeadersLogging)
241220
.build();
242221

243222
SyncResult regularResult = attemptSegmentSync(segmentName, targetChangeNumber, opts,
@@ -246,9 +225,7 @@ public void refreshSegment(String segmentName, Long targetChangeNumber) {
246225
int attempts = _onDemandFetchMaxRetries - regularResult.remainingAttempts();
247226
if (regularResult.success()) {
248227
_log.debug(String.format("Segment %s refresh completed in %s attempts.", segmentName, attempts));
249-
if (_cdnResponseHeadersLogging) {
250-
logCdnHeaders(String.format("[segment/%s]", segmentName), _onDemandFetchMaxRetries , regularResult.remainingAttempts(), captor.get());
251-
}
228+
252229
return;
253230
}
254231

@@ -264,11 +241,6 @@ public void refreshSegment(String segmentName, Long targetChangeNumber) {
264241
} else {
265242
_log.debug(String.format("No changes fetched for segment %s after %s attempts with CDN bypassed.", segmentName, withoutCDNAttempts));
266243
}
267-
268-
if (_cdnResponseHeadersLogging) {
269-
logCdnHeaders(String.format("[segment/%s]", segmentName), _onDemandFetchMaxRetries + ON_DEMAND_FETCH_BACKOFF_MAX_RETRIES,
270-
withCDNBypassed.remainingAttempts(), captor.get());
271-
}
272244
}
273245

274246
@Override

client/src/test/java/io/split/engine/common/FetcherOptionsTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
import org.junit.Test;
44

5-
import java.util.Map;
6-
import java.util.function.Function;
7-
85
import static org.junit.Assert.assertEquals;
96

107
public class FetcherOptionsTest {
@@ -13,13 +10,11 @@ public class FetcherOptionsTest {
1310
public void optionsPropagatedOk() {
1411
FetchOptions options = new FetchOptions.Builder()
1512
.cacheControlHeaders(true)
16-
.fastlyDebugHeader(true)
1713
.targetChangeNumber(123)
1814
.flagSetsFilter("set1,set2")
1915
.build();
2016

2117
assertEquals(options.cacheControlHeadersEnabled(), true);
22-
assertEquals(options.fastlyDebugHeaderEnabled(), true);
2318
assertEquals(options.targetCN(), 123);
2419
assertEquals("set1,set2", options.flagSetsFilter());
2520
}

client/src/test/java/io/split/engine/common/SynchronizerTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void beforeMethod() {
6565

6666
_splitTasks = SplitTasks.build(_refreshableSplitFetcherTask, _segmentFetcher, _impressionsManager, _eventsTask, _telemetrySyncTask, _uniqueKeysTracker);
6767

68-
_synchronizer = new SynchronizerImp(_splitTasks, _splitFetcher, _splitCacheProducer, _segmentCacheProducer, 50, 10, 5, false, new HashSet<>());
68+
_synchronizer = new SynchronizerImp(_splitTasks, _splitFetcher, _splitCacheProducer, _segmentCacheProducer, 50, 10, 5, new HashSet<>());
6969
}
7070

7171
@Test
@@ -161,7 +161,6 @@ public void testCDNBypassIsRequestedAfterNFailures() {
161161
50,
162162
3,
163163
1,
164-
true,
165164
new HashSet<>());
166165

167166
ArgumentCaptor<FetchOptions> optionsCaptor = ArgumentCaptor.forClass(FetchOptions.class);
@@ -194,7 +193,6 @@ public void testCDNBypassRequestLimitAndBackoff() throws NoSuchFieldException, I
194193
50,
195194
3,
196195
1,
197-
true,
198196
new HashSet<>());
199197

200198
ArgumentCaptor<FetchOptions> optionsCaptor = ArgumentCaptor.forClass(FetchOptions.class);
@@ -250,7 +248,6 @@ public void testCDNBypassRequestLimitAndForSegmentsBackoff() throws NoSuchFieldE
250248
50,
251249
3,
252250
1,
253-
true,
254251
new HashSet<>());
255252

256253
SegmentFetcher fetcher = Mockito.mock(SegmentFetcher.class);
@@ -309,7 +306,6 @@ public void testDataRecording(){
309306
50,
310307
3,
311308
1,
312-
true,
313309
new HashSet<>());
314310
imp.startPeriodicDataRecording();
315311

0 commit comments

Comments
 (0)