Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ public Synchronizer build(DataSourceBuildInputs context) {
context.getBaseLogger(),
context.getSelectorSource(),
payloadFilter,
initialReconnectDelay
initialReconnectDelay,
context.getThreadPriority()
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,25 @@ class StreamingSynchronizerImpl implements Synchronizer {

private final AtomicBoolean started = new AtomicBoolean(false);

private final int threadPriority;

public StreamingSynchronizerImpl(
HttpProperties httpProperties,
URI baseUri,
String requestPath,
LDLogger logger,
SelectorSource selectorSource,
String payloadFilter,
Duration initialReconnectDelaySeconds
Duration initialReconnectDelaySeconds,
int threadPriority
) {
this.httpProperties = httpProperties;
this.selectorSource = selectorSource;
this.logger = logger.subLogger(Loggers.STREAMING_SYNCHRONIZER);
this.payloadFilter = payloadFilter;
this.streamUri = HttpHelpers.concatenateUriPath(baseUri, requestPath);
this.initialReconnectDelay = initialReconnectDelaySeconds;
this.threadPriority = threadPriority;

// The stream will lazily start when `next` is called.
}
Expand Down Expand Up @@ -173,8 +177,7 @@ private Thread getRunThread() {
}
});
thread.setName("LaunchDarkly-FDv2-streaming-synchronizer");
// TODO: Implement thread priority.
//streamThread.setPriority();
thread.setPriority(threadPriority);
thread.setDaemon(true);
return thread;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public void receivesMultipleChangesets() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

// First changeset
Expand Down Expand Up @@ -103,7 +104,8 @@ public void httpNonRecoverableError() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -131,7 +133,8 @@ public void httpRecoverableError() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -159,7 +162,8 @@ public void networkError() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -192,7 +196,8 @@ public void invalidEventData() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -223,7 +228,8 @@ public void shutdownBeforeEventReceived() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> nextFuture = synchronizer.next();
Expand Down Expand Up @@ -262,7 +268,8 @@ public void shutdownAfterEventReceived() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -304,7 +311,8 @@ public void goodbyeEventInResponse() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

// First result should be goodbye
Expand Down Expand Up @@ -353,7 +361,8 @@ public void heartbeatEvent() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -391,7 +400,8 @@ public void selectorWithVersionAndState() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -445,7 +455,8 @@ public void selectorRefetchedOnReconnection() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

// First result should be an error from the 503
Expand Down Expand Up @@ -505,7 +516,8 @@ public void errorEventFromServer() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

// Error event should be logged but not queued, so we should get the changeset
Expand Down Expand Up @@ -543,7 +555,8 @@ public void selectorWithVersionOnly() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -583,7 +596,8 @@ public void selectorWithEmptyState() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -616,7 +630,8 @@ public void closeCalledMultipleTimes() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

// Call close multiple times - should not throw exceptions
Expand Down Expand Up @@ -652,7 +667,8 @@ public void invalidEventStructureCausesInterrupt() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -687,7 +703,8 @@ public void payloadFilterIsAddedToRequest() throws Exception {
testLogger,
selectorSource,
"myFilter",
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -728,7 +745,8 @@ public void payloadFilterWithSelectorBothAddedToRequest() throws Exception {
testLogger,
selectorSource,
"testFilter",
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -767,7 +785,8 @@ public void emptyPayloadFilterNotAddedToRequest() throws Exception {
testLogger,
selectorSource,
"",
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -806,7 +825,8 @@ public void nullPayloadFilterNotAddedToRequest() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -846,7 +866,8 @@ public void fdv1FallbackFlagSetToTrueInSuccessResponse() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -881,7 +902,8 @@ public void fdv1FallbackFlagSetToFalseWhenHeaderNotPresent() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -911,7 +933,8 @@ public void fdv1FallbackFlagSetToTrueInErrorResponse() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -948,7 +971,8 @@ public void environmentIdExtractedFromHeaders() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -986,7 +1010,8 @@ public void bothFdv1FallbackAndEnvironmentIdExtractedFromHeaders() throws Except
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -1023,7 +1048,8 @@ public void serializationExceptionWithoutFallbackHeader() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down Expand Up @@ -1061,7 +1087,8 @@ public void serializationExceptionPreservesFallbackHeader() throws Exception {
testLogger,
selectorSource,
null,
Duration.ofMillis(100)
Duration.ofMillis(100),
Thread.NORM_PRIORITY
);

CompletableFuture<FDv2SourceResult> resultFuture = synchronizer.next();
Expand Down