harikrishna-patnala commented on code in PR #9659:
URL: https://github.com/apache/cloudstack/pull/9659#discussion_r1896650250


##########
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) {

Review Comment:
   the getCommandTimeoutsMap parses the value from the global setting which is 
supposed to be in a specific format. Though we are already checking the format 
while setting value in the global setting, here I kept it as safe check not to 
fail the actual command and goes with default value / hardcoded value set on 
the command. 



-- 
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]

Reply via email to