You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by jl...@apache.org on 2022/06/03 04:01:33 UTC
[pinot] branch master updated: Not overwrite the whole SystemResourceInfo config map (#8820)
This is an automated email from the ASF dual-hosted git repository.
jlli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 7b9e16b65d Not overwrite the whole SystemResourceInfo config map (#8820)
7b9e16b65d is described below
commit 7b9e16b65dcd63ecc339a4063a4b4269d1f8cf6f
Author: Liang Mingqiang <se...@gmail.com>
AuthorDate: Thu Jun 2 21:01:28 2022 -0700
Not overwrite the whole SystemResourceInfo config map (#8820)
---
.../pinot/server/starter/helix/BaseServerStarter.java | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/pinot-server/src/main/java/org/apache/pinot/server/starter/helix/BaseServerStarter.java b/pinot-server/src/main/java/org/apache/pinot/server/starter/helix/BaseServerStarter.java
index ee555d9dfe..a411daec2d 100644
--- a/pinot-server/src/main/java/org/apache/pinot/server/starter/helix/BaseServerStarter.java
+++ b/pinot-server/src/main/java/org/apache/pinot/server/starter/helix/BaseServerStarter.java
@@ -343,10 +343,21 @@ public abstract class BaseServerStarter implements ServiceStartable {
}
// Update system resource info (CPU, memory, etc)
- Map<String, String> systemResourceInfoMap = new SystemResourceInfo().toMap();
- if (!systemResourceInfoMap.equals(znRecord.getMapField(Instance.SYSTEM_RESOURCE_INFO_KEY))) {
- LOGGER.info("Updating instance: {} with system resource info: {}", _instanceId, systemResourceInfoMap);
- znRecord.setMapField(Instance.SYSTEM_RESOURCE_INFO_KEY, systemResourceInfoMap);
+ Map<String, String> newSystemResourceInfoMap = new SystemResourceInfo().toMap();
+ Map<String, String> existingSystemResourceInfoMap =
+ znRecord.getMapField(CommonConstants.Helix.Instance.SYSTEM_RESOURCE_INFO_KEY);
+ if (!newSystemResourceInfoMap.equals(existingSystemResourceInfoMap)) {
+ LOGGER.info("Updating instance: {} with new system resource info: {}", _instanceId, newSystemResourceInfoMap);
+ if (existingSystemResourceInfoMap == null) {
+ existingSystemResourceInfoMap = newSystemResourceInfoMap;
+ } else {
+ // existingSystemResourceInfoMap may contains more KV pairs than newSystemResourceInfoMap,
+ // we need to preserve those KV pairs and only update the different values.
+ for (Map.Entry<String, String> entry : newSystemResourceInfoMap.entrySet()) {
+ existingSystemResourceInfoMap.put(entry.getKey(), entry.getValue());
+ }
+ }
+ znRecord.setMapField(Instance.SYSTEM_RESOURCE_INFO_KEY, existingSystemResourceInfoMap);
updated = true;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org