Skip to content

Commit

Permalink
Add overall IMS update timeout
Browse files Browse the repository at this point in the history
Not set by default
This closes #762
  • Loading branch information
kwin committed Aug 14, 2024
1 parent ca93a32 commit cca3c69
Showing 1 changed file with 6 additions and 0 deletions.
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

0 comments on commit cca3c69

Please sign in to comment.