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

Add overall IMS update timeout #763

Merged
merged 1 commit into from
Aug 19, 2024
Merged
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 @@ -118,6 +118,8 @@ public class IMSUserManagement implements ExternalGroupManagement {
int connectTimeout() default 2000;
@AttributeDefinition(name = "Socket Timeout", description = "The time waiting for data – after establishing the connection; maximum time of inactivity between two data packets. Given in milliseconds.")
int socketTimeout() default 10000;
@AttributeDefinition(name = "Overall Timeout", description = "The maximum time updating groups in IMS should take. If expired the operation fails with an exception. Negative values mean no timeout. Given in milliseconds.")
long overallTimeout() default -1;
@AttributeDefinition(name = "AEM Product Profiles", description = "The given product profile names are automatically added to each synchronized IMS group. The given product profile names must exist for an AEM product!")
String[] productProfiles() default {};
@AttributeDefinition(name = "Group Administrators", description = "The given users are automatically added to each synchronized IMS group as administrator. The given user ids must already exist!")
Expand Down Expand Up @@ -236,6 +238,7 @@ public int updateGroups(Collection<AuthorizableConfigBean> groupConfigs) throws
if (config.isDifferentialUpdates()) {
existingImsGroups = getGroups(token);
}
long startEpoch = System.currentTimeMillis();
List<ActionCommand> actionCommands = new LinkedList<>();
List<String> updatedGroupNames = new LinkedList<>();
for (AuthorizableConfigBean groupConfig : groupConfigs) {
Expand Down Expand Up @@ -288,6 +291,9 @@ public int updateGroups(Collection<AuthorizableConfigBean> groupConfigs) throws
LOG.warn("Some warnings during updating groups with request {}", getRequestInfo(response.associatedRequest));
response.warnings.stream().forEach(w -> LOG.warn("Warning updating a group: {}", w));
}
if (config.overallTimeout() > 0 && System.currentTimeMillis() - startEpoch > config.overallTimeout()) {
throw new IOException("Timeout updating IMS groups, exceeded overall timeout of " + config.overallTimeout() + " ms");
}
}
return updatedGroupNames.size();
}
Expand Down
Loading