harikrishna-patnala commented on code in PR #9659:
URL: https://github.com/apache/cloudstack/pull/9659#discussion_r1904928463
##########
engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java:
##########
@@ -424,15 +428,78 @@ private void setEmptyAnswers(final Commands commands,
final Command[] cmds) {
}
}
+ protected int getTimeout(final Commands commands, int timeout) {
+ int result;
+ if (timeout > 0) {
+ result = timeout;
+ } else {
+ result = Wait.value();
+ }
+
+ int granularTimeout = getTimeoutFromGranularWaitTime(commands);
+ return (granularTimeout > 0) ? granularTimeout : result;
+ }
+
+ protected int getTimeoutFromGranularWaitTime(final Commands commands) {
+ int maxWait = 0;
+ if (MapUtils.isNotEmpty(_commandTimeouts)) {
+ for (final Command cmd : commands) {
+ String simpleCommandName = cmd.getClass().getSimpleName();
+ Integer commandTimeout =
_commandTimeouts.get(simpleCommandName);
+ if (commandTimeout != null && commandTimeout > maxWait) {
+ maxWait = commandTimeout;
+ }
+ }
+ }
+
+ return maxWait;
+ }
+
+ private void initializeCommandTimeouts() {
+ String commandWaits = GranularWaitTimeForCommands.value().trim();
+ if (StringUtils.isNotEmpty(commandWaits)) {
+ try {
+ _commandTimeouts = getCommandTimeoutsMap(commandWaits);
+ logger.info(String.format("Timeouts for management server
internal commands successfully initialized from global setting
commands.timeout: %s", _commandTimeouts));
+ } catch (Exception e) {
+ logger.error("Error initializing command timeouts map: " +
e.getMessage());
+ _commandTimeouts = new HashMap<>();
+ }
+ }
+ }
+
+ private Map<String, Integer> getCommandTimeoutsMap(String commandWaits) {
+ String[] commandPairs = commandWaits.split(",");
+ Map<String, Integer> commandTimeouts = new HashMap<>();
+
+ for (String commandPair : commandPairs) {
+ String[] parts = commandPair.trim().split("=");
+ if (parts.length == 2) {
+ String commandName = parts[0].trim();
+ int commandTimeout = Integer.parseInt(parts[1].trim());
Review Comment:
updated the exception handling @shwstppr , please review again.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]