You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:26:53 UTC

[sling-org-apache-sling-discovery-base] 06/08: SLING-6809 : toString improved to enlist more details - including a paranoia fallback that goes to the previous output in case of any Exception

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.1.8
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit fe51cdd4d6b4b01114b553a015417bf75d90c776
Author: Stefan Egli <st...@apache.org>
AuthorDate: Fri May 5 12:29:57 2017 +0000

    SLING-6809 : toString improved to enlist more details - including a paranoia fallback that goes to the previous output in case of any Exception
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1794027 13f79535-47bb-0310-9956-ffa450edef68
---
 .../base/commons/DefaultTopologyView.java          | 26 +++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/discovery/base/commons/DefaultTopologyView.java b/src/main/java/org/apache/sling/discovery/base/commons/DefaultTopologyView.java
index a85c20b..978ebaf 100644
--- a/src/main/java/org/apache/sling/discovery/base/commons/DefaultTopologyView.java
+++ b/src/main/java/org/apache/sling/discovery/base/commons/DefaultTopologyView.java
@@ -243,8 +243,32 @@ public class DefaultTopologyView extends BaseTopologyView {
 
     @Override
     public String toString() {
+        StringBuilder sb = new StringBuilder();
+        try{
+            boolean firstCluster = true;
+            for (ClusterView clusterView : getClusterViews()) {
+                if (!firstCluster) {
+                    sb.append(", ");
+                }
+                firstCluster = false;
+                sb.append("[clusterId=" + clusterView.getId() + ", instances=");
+                boolean firstInstance = true;
+                for (InstanceDescription id : clusterView.getInstances()) {
+                    if (!firstInstance) {
+                        sb.append(", ");
+                    }
+                    firstInstance = false;
+                    sb.append("[id=" + id.getSlingId() + ", isLeader=" + id.isLeader() + 
+                            ", isLocal=" + id.isLocal() + "]");
+                }
+                sb.append("]");
+            }
+        } catch(Exception e) {
+            // paranoia fallback
+            sb = new StringBuilder(instances.toString());
+        }
         return "DefaultTopologyView[current=" + isCurrent() + ", num=" + instances.size() + ", instances="
-                + instances + "]";
+                + sb + "]";
     }
 
     @Override

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.