Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLING-12288 - Allow configuration of timeouts for SubscriberReady check #139

Merged
merged 1 commit into from
Apr 16, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,14 @@ public void activate(SubscriberConfiguration config, BundleContext context, Map<
requireNonNull(precondition);
requireNonNull(bookKeeperFactory);

long idleMillies = getLong(properties, SubscriberReady.DEFAULT_IDLE_TIME_MILLIS);
if (config.editable()) {
commandPoller = new CommandPoller(messagingProvider, topics, subSlingId, subAgentName, delay::signal);
}

if (config.subscriberIdleCheck()) {
AtomicBoolean readyHolder = subscriberReadyStore.getReadyHolder(subAgentName);

idleCheck = new SubscriberReady(subAgentName, idleMillies, SubscriberReady.DEFAULT_FORCE_IDLE_MILLIS, readyHolder, System::currentTimeMillis);
idleCheck = new SubscriberReady(subAgentName, config.idleMillies(), config.forceReadyMillies(), readyHolder, System::currentTimeMillis);
idleReadyCheck = new SubscriberIdleCheck(context, idleCheck);
} else {
idleCheck = new NoopIdle();
Expand Down Expand Up @@ -218,10 +217,6 @@ public void activate(SubscriberConfiguration config, BundleContext context, Map<
queueNames, config.subscriberIdleCheck());
}

private long getLong(Map<String, Object> properties, long defaultValue) {
return Long.parseLong(properties.getOrDefault("idleMillies", Long.valueOf(defaultValue)).toString());
}

public static String escapeTopicName(URI messagingUri, String topicName) {
return String.format("%s%s_%s",
messagingUri.getHost(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,10 @@

@AttributeDefinition(name = "ContentPackageExtractor.overwritePrimaryTypesOfFolders", description = "The flag determines whether the primary node types of folders should be overwritten during content package extraction, with a default value of 'true'.")
boolean contentPackageExtractorOverwritePrimaryTypesOfFolders() default true;

@AttributeDefinition(description = "Number of ms being idle before reporting ready.")
int idleMillies() default 10 * 1000;

@AttributeDefinition(description = "Number of ms to force subscriber reporting idle.")
int forceReadyMillies() default 300 * 1000;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.SECONDS;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
Expand All @@ -43,8 +42,6 @@
* After becoming ready once, the check stays ready.
*/
public class SubscriberReady implements IdleCheck {
public static final long DEFAULT_IDLE_TIME_MILLIS = SECONDS.toMillis(10);
public static final long DEFAULT_FORCE_IDLE_MILLIS = MINUTES.toMillis(5);
public static final long ACCEPTABLE_AGE_DIFF_MS = MINUTES.toMillis(2);
public static final int MAX_RETRIES = 10;

Expand Down