You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2020/10/28 10:20:07 UTC
[cloudstack] branch master updated: Fix Usage failed to get pid
(#4144)
This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new f66ae34 Fix Usage failed to get pid (#4144)
f66ae34 is described below
commit f66ae34ea713e57a7aa2a049f7cf5984bfd8cd39
Author: div8cn <35...@users.noreply.github.com>
AuthorDate: Wed Oct 28 18:19:53 2020 +0800
Fix Usage failed to get pid (#4144)
* Update UsageManagerImpl.java
When System.getProperty Failure to get the PID will cause the service to stay in the config phase. The startup cannot continue and there will be no log output
Use managementfactory to get the PID and throw an exception when the PID cannot be obtained.
* Update usage/src/main/java/com/cloud/usage/UsageManagerImpl.java
Co-authored-by: dahn <da...@gmail.com>
* Update UsageManagerImpl.java
* Update UsageManagerImpl.java
* Update UsageManagerImpl.java
Co-authored-by: dahn <da...@gmail.com>
---
usage/src/main/java/com/cloud/usage/UsageManagerImpl.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/usage/src/main/java/com/cloud/usage/UsageManagerImpl.java b/usage/src/main/java/com/cloud/usage/UsageManagerImpl.java
index b47a9ca..1d34588 100644
--- a/usage/src/main/java/com/cloud/usage/UsageManagerImpl.java
+++ b/usage/src/main/java/com/cloud/usage/UsageManagerImpl.java
@@ -278,7 +278,14 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
s_logger.error("Unhandled exception configuring UsageManger", e);
throw new ConfigurationException("Unhandled exception configuring UsageManager " + e.toString());
}
- _pid = Integer.parseInt(System.getProperty("pid"));
+
+ try {
+ _pid = (int) ProcessHandle.current().pid();
+ } catch (Exception e) {
+ String msg = String.format("Unable to get process Id for %s!", e.toString());
+ s_logger.debug(msg);
+ throw new ConfigurationException(msg);
+ }
return true;
}