eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From qingwz...@apache.org
Subject eagle git commit: [EAGLE-876] TopologyBaseAPIEntity comparison should consider rack info
Date Fri, 20 Jan 2017 03:12:44 GMT
Repository: eagle
Updated Branches:
  refs/heads/master 9c71b0ea0 -> 015d57788


[EAGLE-876] TopologyBaseAPIEntity comparison should consider rack info

https://issues.apache.org/jira/browse/EAGLE-876

Author: Zhao, Qingwen <qingwzhao@apache.org>

Closes #785 from qingwen220/EAGLE-876.


Project: http://git-wip-us.apache.org/repos/asf/eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/eagle/commit/015d5778
Tree: http://git-wip-us.apache.org/repos/asf/eagle/tree/015d5778
Diff: http://git-wip-us.apache.org/repos/asf/eagle/diff/015d5778

Branch: refs/heads/master
Commit: 015d577883f72707d7c38015840607be4ae226fb
Parents: 9c71b0e
Author: Zhao, Qingwen <qingwzhao@apache.org>
Authored: Fri Jan 20 11:10:34 2017 +0800
Committer: Zhao, Qingwen <qingwzhao@apache.org>
Committed: Fri Jan 20 11:10:34 2017 +0800

----------------------------------------------------------------------
 .../topology/extractor/mr/MRTopologyEntityParser.java |  7 ++++---
 .../eagle/topology/storm/TopologyDataPersistBolt.java | 14 +++++++-------
 .../eagle/topology/utils/EntityBuilderHelper.java     |  2 +-
 3 files changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/eagle/blob/015d5778/eagle-topology-check/eagle-topology-app/src/main/java/org/apache/eagle/topology/extractor/mr/MRTopologyEntityParser.java
----------------------------------------------------------------------
diff --git a/eagle-topology-check/eagle-topology-app/src/main/java/org/apache/eagle/topology/extractor/mr/MRTopologyEntityParser.java
b/eagle-topology-check/eagle-topology-app/src/main/java/org/apache/eagle/topology/extractor/mr/MRTopologyEntityParser.java
index f860f1c..918679b 100644
--- a/eagle-topology-check/eagle-topology-app/src/main/java/org/apache/eagle/topology/extractor/mr/MRTopologyEntityParser.java
+++ b/eagle-topology-check/eagle-topology-app/src/main/java/org/apache/eagle/topology/extractor/mr/MRTopologyEntityParser.java
@@ -41,7 +41,8 @@ import java.util.Map;
 import java.util.regex.Matcher;
 
 import static org.apache.eagle.topology.TopologyConstants.*;
-import static org.apache.eagle.topology.utils.EntityBuilderHelper.generateKey;
+import static org.apache.eagle.topology.utils.EntityBuilderHelper.generateHostKey;
+
 
 public class MRTopologyEntityParser implements TopologyEntityParser {
 
@@ -156,7 +157,7 @@ public class MRTopologyEntityParser implements TopologyEntityParser {
                     nodeManagerEntity.setStatus(state);
                 }
 
-                nodeKey = generateKey(nodeManagerEntity);
+                nodeKey = generateHostKey(nodeManagerEntity);
                 if (nmMap.containsKey(nodeKey)) {
                     if (nmMap.get(nodeKey).getLastUpdateTime() < nodeManagerEntity.getLastHealthUpdate())
{
                         updateStatusCount(statusCount, nmMap.get(nodeKey).getStatus(), -1);
@@ -219,4 +220,4 @@ public class MRTopologyEntityParser implements TopologyEntityParser {
         return entity;
     }
 
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/eagle/blob/015d5778/eagle-topology-check/eagle-topology-app/src/main/java/org/apache/eagle/topology/storm/TopologyDataPersistBolt.java
----------------------------------------------------------------------
diff --git a/eagle-topology-check/eagle-topology-app/src/main/java/org/apache/eagle/topology/storm/TopologyDataPersistBolt.java
b/eagle-topology-check/eagle-topology-app/src/main/java/org/apache/eagle/topology/storm/TopologyDataPersistBolt.java
index 9be78e0..4a61c89 100644
--- a/eagle-topology-check/eagle-topology-app/src/main/java/org/apache/eagle/topology/storm/TopologyDataPersistBolt.java
+++ b/eagle-topology-check/eagle-topology-app/src/main/java/org/apache/eagle/topology/storm/TopologyDataPersistBolt.java
@@ -19,7 +19,6 @@
 package org.apache.eagle.topology.storm;
 
 import static org.apache.eagle.topology.TopologyConstants.HOSTNAME_TAG;
-import static org.apache.eagle.topology.TopologyConstants.RACK_TAG;
 import static org.apache.eagle.topology.TopologyConstants.ROLE_TAG;
 import static org.apache.eagle.topology.TopologyConstants.SITE_TAG;
 
@@ -76,18 +75,18 @@ public class TopologyDataPersistBolt extends BaseRichBolt {
         }
         String serviceName = input.getStringByField(TopologyConstants.SERVICE_NAME_FIELD);
         TopologyEntityParserResult result = (TopologyEntityParserResult) input.getValueByField(TopologyConstants.TOPOLOGY_DATA_FIELD);
-        Set<String> availableHostnames = new HashSet<String>();
+        Set<String> availableHostNames = new HashSet<String>();
         List<TopologyBaseAPIEntity> entitiesForDeletion = new ArrayList<>();
         List<TopologyBaseAPIEntity> entitiesToWrite = new ArrayList<>();
 
-        filterEntitiesToWrite(result, availableHostnames, entitiesToWrite);
+        filterEntitiesToWrite(result, availableHostNames, entitiesToWrite);
 
         String query = String.format("%s[@site=\"%s\"]{*}", serviceName, this.config.dataExtractorConfig.site);
         try {
             GenericServiceAPIResponseEntity<TopologyBaseAPIEntity> response = client.search().query(query).pageSize(Integer.MAX_VALUE).send();
             if (response.isSuccess() && response.getObj() != null) {
                 for (TopologyBaseAPIEntity entity : response.getObj()) {
-                    if (!availableHostnames.isEmpty() && !availableHostnames.contains(generateKey(entity)))
{
+                    if (!availableHostNames.isEmpty() && !availableHostNames.contains(generatePersistKey(entity)))
{
                         entitiesForDeletion.add(entity);
                     }
                 }
@@ -105,11 +104,11 @@ public class TopologyDataPersistBolt extends BaseRichBolt {
     private void filterEntitiesToWrite(TopologyEntityParserResult result, Set<String>
availableHostnames, List<TopologyBaseAPIEntity> entitiesToWrite) {
         if (!result.getSlaveNodes().isEmpty()) {
             for (TopologyBaseAPIEntity entity : result.getMasterNodes()) {
-                availableHostnames.add(generateKey(entity));
+                availableHostnames.add(generatePersistKey(entity));
                 entitiesToWrite.add(entity);
             }
             for (TopologyBaseAPIEntity entity : result.getSlaveNodes()) {
-                availableHostnames.add(generateKey(entity));
+                availableHostnames.add(generatePersistKey(entity));
                 entitiesToWrite.add(entity);
             }
         } else {
@@ -156,10 +155,11 @@ public class TopologyDataPersistBolt extends BaseRichBolt {
         entities.clear();
     }
 
-    private String generateKey(TopologyBaseAPIEntity entity) {
+    private String generatePersistKey(TopologyBaseAPIEntity entity) {
         return new HashCodeBuilder().append(entity.getTags().get(TopologyConstants.SITE_TAG))
                 .append(entity.getTags().get(TopologyConstants.HOSTNAME_TAG))
                 .append(entity.getTags().get(TopologyConstants.ROLE_TAG))
+                .append(entity.getTags().get(TopologyConstants.RACK_TAG))
                 .build().toString();
     }
 

http://git-wip-us.apache.org/repos/asf/eagle/blob/015d5778/eagle-topology-check/eagle-topology-app/src/main/java/org/apache/eagle/topology/utils/EntityBuilderHelper.java
----------------------------------------------------------------------
diff --git a/eagle-topology-check/eagle-topology-app/src/main/java/org/apache/eagle/topology/utils/EntityBuilderHelper.java
b/eagle-topology-check/eagle-topology-app/src/main/java/org/apache/eagle/topology/utils/EntityBuilderHelper.java
index 8aa1d88..5654c6f 100644
--- a/eagle-topology-check/eagle-topology-app/src/main/java/org/apache/eagle/topology/utils/EntityBuilderHelper.java
+++ b/eagle-topology-check/eagle-topology-app/src/main/java/org/apache/eagle/topology/utils/EntityBuilderHelper.java
@@ -65,7 +65,7 @@ public class EntityBuilderHelper {
         return key.indexOf(TopologyConstants.COLON) > 0 ? key.substring(0, key.indexOf(TopologyConstants.COLON))
: key;
     }
 
-    public static String generateKey(TopologyBaseAPIEntity entity) {
+    public static String generateHostKey(TopologyBaseAPIEntity entity) {
         return new HashCodeBuilder().append(entity.getTags().get(TopologyConstants.SITE_TAG))
                 .append(entity.getTags().get(TopologyConstants.HOSTNAME_TAG))
                 .append(entity.getTags().get(TopologyConstants.ROLE_TAG))


Mime
View raw message