Search in sources :

Example 1 with CachedAnnouncement

use of org.apache.sling.discovery.base.connectors.announcement.CachedAnnouncement in project sling by apache.

the class TopologyWebConsolePlugin method listIncomingTopologyConnectors.

/**
     * Render the incoming topology connectors - including the header-div and table
     */
private void listIncomingTopologyConnectors(final PrintWriter pw) {
    boolean odd = false;
    pw.println("<div class=\"ui-widget-header ui-corner-top buttonGroup\" style=\"height: 15px;\">");
    pw.println("<span style=\"float: left; margin-left: 1em;\">Incoming topology connectors</span>");
    pw.println("</div>");
    pw.println("<table class=\"adapters nicetable ui-widget tablesorter\">");
    pw.println("<thead>");
    pw.println("<tr>");
    pw.println("<th class=\"header ui-widget-header\">Owner slingId</th>");
    pw.println("<th class=\"header ui-widget-header\">Server info</th>");
    pw.println("<th class=\"header ui-widget-header\">Last heartbeat</th>");
    pw.println("<th class=\"header ui-widget-header\">Timeout</th>");
    pw.println("</tr>");
    pw.println("</thead>");
    pw.println("<tbody>");
    Collection<CachedAnnouncement> incomingConnections = announcementRegistry.listLocalIncomingAnnouncements();
    for (Iterator<CachedAnnouncement> it = incomingConnections.iterator(); it.hasNext(); ) {
        CachedAnnouncement incomingCachedAnnouncement = it.next();
        Announcement incomingAnnouncement = incomingCachedAnnouncement.getAnnouncement();
        String oddEven = odd ? "odd" : "even";
        odd = !odd;
        pw.println("<tr class=\"" + oddEven + " ui-state-default\">");
        pw.println("<td>" + incomingAnnouncement.getOwnerId() + "</td>");
        if (incomingAnnouncement.getServerInfo() != null) {
            pw.println("<td>" + incomingAnnouncement.getServerInfo() + "</td>");
        } else {
            pw.println("<td><i>n/a</i></td>");
        }
        pw.println("<td>" + beautifiedTimeDiff(incomingCachedAnnouncement.getLastPing()) + "</td>");
        pw.println("<td>" + beautifiedDueTime(incomingCachedAnnouncement.getSecondsUntilTimeout()) + "</td>");
        pw.println("</tr>");
    }
    pw.println("</tbody>");
    pw.println("</table>");
    pw.println("<br/>");
    pw.println("<br/>");
}
Also used : CachedAnnouncement(org.apache.sling.discovery.base.connectors.announcement.CachedAnnouncement) Announcement(org.apache.sling.discovery.base.connectors.announcement.Announcement) CachedAnnouncement(org.apache.sling.discovery.base.connectors.announcement.CachedAnnouncement)

Example 2 with CachedAnnouncement

use of org.apache.sling.discovery.base.connectors.announcement.CachedAnnouncement in project sling by apache.

the class TopologyWebConsolePlugin method printConfiguration.

public void printConfiguration(final PrintWriter pw) {
    final TopologyView topology = this.currentView;
    pw.println(TITLE);
    pw.println("---------------------------------------");
    pw.println();
    if (topology == null) {
        pw.println("No topology available yet!");
        return;
    }
    pw.print("Topology");
    if (!topology.isCurrent()) {
        pw.print(" CHANGING! (the view is no longer current!)");
    }
    pw.println();
    pw.println();
    final Set<ClusterView> clusters = topology.getClusterViews();
    final ClusterView myCluster = topology.getLocalInstance().getClusterView();
    printCluster(pw, myCluster, myCluster);
    for (Iterator<ClusterView> it = clusters.iterator(); it.hasNext(); ) {
        ClusterView clusterView = it.next();
        if (clusterView.equals(myCluster)) {
            // skip - I already rendered that
            continue;
        }
        printCluster(pw, clusterView, myCluster);
    }
    pw.println();
    pw.println();
    final Collection<CachedAnnouncement> incomingConnections = announcementRegistry.listLocalIncomingAnnouncements();
    if (incomingConnections.size() > 0) {
        pw.println("Incoming topology connectors");
        pw.println("---------------------------------------");
        for (final CachedAnnouncement incomingCachedAnnouncement : incomingConnections) {
            Announcement incomingAnnouncement = incomingCachedAnnouncement.getAnnouncement();
            pw.print("Owner Sling Id : ");
            pw.print(incomingAnnouncement.getOwnerId());
            pw.println();
            if (incomingAnnouncement.getServerInfo() != null) {
                pw.print("Server Info : ");
                pw.print(incomingAnnouncement.getServerInfo());
                pw.println();
            }
            pw.println("Last heartbeat received : " + beautifiedTimeDiff(incomingCachedAnnouncement.getLastPing()));
            pw.println("Timeout : " + beautifiedDueTime(incomingCachedAnnouncement.getSecondsUntilTimeout()));
            pw.println();
        }
        pw.println();
        pw.println();
    }
    final Collection<TopologyConnectorClientInformation> outgoingConnections = connectorRegistry.listOutgoingConnectors();
    if (outgoingConnections.size() > 0) {
        pw.println("Outgoing topology connectors");
        pw.println("---------------------------------------");
        for (final TopologyConnectorClientInformation topologyConnectorClient : outgoingConnections) {
            final String remoteSlingId = topologyConnectorClient.getRemoteSlingId();
            final boolean autoStopped = topologyConnectorClient.isAutoStopped();
            final boolean isConnected = topologyConnectorClient.isConnected() && remoteSlingId != null;
            pw.print("Connector URL : ");
            pw.print(topologyConnectorClient.getConnectorUrl());
            pw.println();
            if (autoStopped) {
                pw.println("Conncted to Sling Id : auto-stopped");
                pw.println("Connector status : auto-stopped due to local-loop");
            } else if (isConnected && !topologyConnectorClient.representsLoop()) {
                pw.print("Connected to Sling Id : ");
                pw.println(remoteSlingId);
                pw.println("Connector status : ok, in use");
            } else if (topologyConnectorClient.representsLoop()) {
                pw.print("Connected to Sling Id : ");
                pw.println(remoteSlingId);
                pw.println("Connector status : ok, unused (loop or duplicate): standby");
            } else {
                final int statusCode = topologyConnectorClient.getStatusCode();
                final String statusDetails = topologyConnectorClient.getStatusDetails();
                final String tooltipText;
                switch(statusCode) {
                    case HttpServletResponse.SC_UNAUTHORIZED:
                        tooltipText = HttpServletResponse.SC_UNAUTHORIZED + ": possible setup issue of discovery.impl on target instance, or wrong URL";
                        break;
                    case HttpServletResponse.SC_NOT_FOUND:
                        tooltipText = HttpServletResponse.SC_NOT_FOUND + ": possible white list rejection by target instance";
                        break;
                    case -1:
                        tooltipText = "-1: check error log. possible connection refused.";
                        break;
                    default:
                        tooltipText = null;
                }
                pw.println("Connected to Sling Id : not connected");
                pw.print("Connector status : not ok");
                if (tooltipText != null) {
                    pw.print(" (");
                    pw.print(tooltipText);
                    pw.print(")");
                }
                pw.print(" (HTTP StatusCode: " + statusCode + ", " + statusDetails + ")");
                pw.println();
                pw.println("Last heartbeat sent : " + beautifiedTimeDiff(topologyConnectorClient.getLastPingSent()));
                pw.println("Next heartbeat due : " + beautifiedDueTime(topologyConnectorClient.getNextPingDue()));
            }
            pw.println();
        }
        pw.println();
        pw.println();
    }
    if (topologyLog.size() > 0) {
        pw.println("Topology Change History");
        pw.println("---------------------------------------");
        for (final String aLogEntry : topologyLog) {
            pw.println(aLogEntry);
        }
        pw.println();
        pw.println();
    }
    if (propertyChangeLog.size() > 0) {
        pw.println("Property Change History");
        pw.println("---------------------------------------");
        for (final String aLogEntry : propertyChangeLog) {
            pw.println(aLogEntry);
        }
        pw.println();
    }
    pw.println("SyncTokenService History");
    pw.println("---------------------------------------");
    if (!config.useSyncTokenService()) {
        pw.println("(disabled - useSyncTokenService flag is false)");
    } else if (syncTokenService == null) {
        pw.println("(no SyncTokenService available)");
    } else {
        ClusterSyncHistory clusterSyncHistory = syncTokenService.getClusterSyncHistory();
        if (clusterSyncHistory == null) {
            pw.println("(no history available)");
        } else {
            for (String syncHistoryEntry : clusterSyncHistory.getSyncHistory()) {
                pw.println(syncHistoryEntry);
            }
        }
    }
    pw.println();
    pw.println();
}
Also used : ClusterView(org.apache.sling.discovery.ClusterView) CachedAnnouncement(org.apache.sling.discovery.base.connectors.announcement.CachedAnnouncement) Announcement(org.apache.sling.discovery.base.connectors.announcement.Announcement) CachedAnnouncement(org.apache.sling.discovery.base.connectors.announcement.CachedAnnouncement) ClusterSyncHistory(org.apache.sling.discovery.commons.providers.spi.base.ClusterSyncHistory) TopologyConnectorClientInformation(org.apache.sling.discovery.base.connectors.ping.TopologyConnectorClientInformation) TopologyView(org.apache.sling.discovery.TopologyView)

Example 3 with CachedAnnouncement

use of org.apache.sling.discovery.base.connectors.announcement.CachedAnnouncement in project sling by apache.

the class TopologyWebConsolePlugin method printConfiguration.

public void printConfiguration(final PrintWriter pw) {
    final TopologyView topology = this.currentView;
    pw.println(TITLE);
    pw.println("---------------------------------------");
    pw.println();
    if (topology == null) {
        pw.println("No topology available yet!");
        return;
    }
    pw.print("Topology");
    if (!topology.isCurrent()) {
        pw.print(" CHANGING! (the view is no longer current!)");
    }
    pw.println();
    pw.println();
    final Set<ClusterView> clusters = topology.getClusterViews();
    final ClusterView myCluster = topology.getLocalInstance().getClusterView();
    printCluster(pw, myCluster, myCluster);
    for (Iterator<ClusterView> it = clusters.iterator(); it.hasNext(); ) {
        ClusterView clusterView = it.next();
        if (clusterView.equals(myCluster)) {
            // skip - I already rendered that
            continue;
        }
        printCluster(pw, clusterView, myCluster);
    }
    pw.println();
    pw.println();
    final Collection<CachedAnnouncement> incomingConnections = announcementRegistry.listLocalIncomingAnnouncements();
    if (incomingConnections.size() > 0) {
        pw.println("Incoming topology connectors");
        pw.println("---------------------------------------");
        for (final CachedAnnouncement incomingCachedAnnouncement : incomingConnections) {
            Announcement incomingAnnouncement = incomingCachedAnnouncement.getAnnouncement();
            pw.print("Owner Sling Id : ");
            pw.print(incomingAnnouncement.getOwnerId());
            pw.println();
            if (incomingAnnouncement.getServerInfo() != null) {
                pw.print("Server Info : ");
                pw.print(incomingAnnouncement.getServerInfo());
                pw.println();
            }
            pw.println("Last heartbeat received : " + beautifiedTimeDiff(incomingCachedAnnouncement.getLastPing()));
            pw.println("Timeout : " + beautifiedDueTime(incomingCachedAnnouncement.getSecondsUntilTimeout()));
            pw.println();
        }
        pw.println();
        pw.println();
    }
    final Collection<TopologyConnectorClientInformation> outgoingConnections = connectorRegistry.listOutgoingConnectors();
    if (outgoingConnections.size() > 0) {
        pw.println("Outgoing topology connectors");
        pw.println("---------------------------------------");
        for (final TopologyConnectorClientInformation topologyConnectorClient : outgoingConnections) {
            final String remoteSlingId = topologyConnectorClient.getRemoteSlingId();
            final boolean autoStopped = topologyConnectorClient.isAutoStopped();
            final boolean isConnected = topologyConnectorClient.isConnected() && remoteSlingId != null;
            pw.print("Connector URL : ");
            pw.print(topologyConnectorClient.getConnectorUrl());
            pw.println();
            if (autoStopped) {
                pw.println("Conncted to Sling Id : auto-stopped");
                pw.println("Connector status : auto-stopped due to local-loop");
            } else if (isConnected && !topologyConnectorClient.representsLoop()) {
                pw.print("Connected to Sling Id : ");
                pw.println(remoteSlingId);
                pw.println("Connector status : ok, in use");
            } else if (topologyConnectorClient.representsLoop()) {
                pw.print("Connected to Sling Id : ");
                pw.println(remoteSlingId);
                pw.println("Connector status : ok, unused (loop or duplicate): standby");
            } else {
                final int statusCode = topologyConnectorClient.getStatusCode();
                final String statusDetails = topologyConnectorClient.getStatusDetails();
                final String tooltipText;
                switch(statusCode) {
                    case HttpServletResponse.SC_UNAUTHORIZED:
                        tooltipText = HttpServletResponse.SC_UNAUTHORIZED + ": possible setup issue of discovery.oak on target instance, or wrong URL";
                        break;
                    case HttpServletResponse.SC_NOT_FOUND:
                        tooltipText = HttpServletResponse.SC_NOT_FOUND + ": possible white list rejection by target instance";
                        break;
                    case -1:
                        tooltipText = "-1: check error log. possible connection refused.";
                        break;
                    default:
                        tooltipText = null;
                }
                pw.println("Connected to Sling Id : not connected");
                pw.print("Connector status : not ok");
                if (tooltipText != null) {
                    pw.print(" (");
                    pw.print(tooltipText);
                    pw.print(")");
                }
                pw.print(" (HTTP StatusCode: " + statusCode + ", " + statusDetails + ")");
                pw.println();
                pw.println("Last heartbeat sent : " + beautifiedTimeDiff(topologyConnectorClient.getLastPingSent()));
                pw.println("Next heartbeat due : " + beautifiedDueTime(topologyConnectorClient.getNextPingDue()));
            }
            pw.println();
        }
        pw.println();
        pw.println();
    }
    if (topologyLog.size() > 0) {
        pw.println("Topology Change History");
        pw.println("---------------------------------------");
        for (final String aLogEntry : topologyLog) {
            pw.println(aLogEntry);
        }
        pw.println();
        pw.println();
    }
    if (propertyChangeLog.size() > 0) {
        pw.println("Property Change History");
        pw.println("---------------------------------------");
        for (final String aLogEntry : propertyChangeLog) {
            pw.println(aLogEntry);
        }
        pw.println();
    }
    pw.println("Oak Discovery-Lite Descriptor History");
    pw.println("---------------------------------------");
    updateDiscoveryLiteHistory();
    for (String discoLiteHistoryEntry : discoveryLiteHistory) {
        pw.println(discoLiteHistoryEntry);
    }
    pw.println();
    pw.println();
    pw.println("ClusterSyncService History");
    pw.println("---------------------------------------");
    for (String syncHistoryEntry : clusterSyncService.getSyncHistory()) {
        pw.println(syncHistoryEntry);
    }
    pw.println();
    pw.println();
}
Also used : ClusterView(org.apache.sling.discovery.ClusterView) CachedAnnouncement(org.apache.sling.discovery.base.connectors.announcement.CachedAnnouncement) Announcement(org.apache.sling.discovery.base.connectors.announcement.Announcement) CachedAnnouncement(org.apache.sling.discovery.base.connectors.announcement.CachedAnnouncement) TopologyConnectorClientInformation(org.apache.sling.discovery.base.connectors.ping.TopologyConnectorClientInformation) TopologyView(org.apache.sling.discovery.TopologyView)

Example 4 with CachedAnnouncement

use of org.apache.sling.discovery.base.connectors.announcement.CachedAnnouncement in project sling by apache.

the class TopologyWebConsolePlugin method listIncomingTopologyConnectors.

/**
     * Render the incoming topology connectors - including the header-div and table
     */
private void listIncomingTopologyConnectors(final PrintWriter pw) {
    boolean odd = false;
    pw.println("<div class=\"ui-widget-header ui-corner-top buttonGroup\" style=\"height: 15px;\">");
    pw.println("<span style=\"float: left; margin-left: 1em;\">Incoming topology connectors</span>");
    pw.println("</div>");
    pw.println("<table class=\"adapters nicetable ui-widget tablesorter\">");
    pw.println("<thead>");
    pw.println("<tr>");
    pw.println("<th class=\"header ui-widget-header\">Owner slingId</th>");
    pw.println("<th class=\"header ui-widget-header\">Server info</th>");
    pw.println("<th class=\"header ui-widget-header\">Last heartbeat</th>");
    pw.println("<th class=\"header ui-widget-header\">Timeout</th>");
    pw.println("</tr>");
    pw.println("</thead>");
    pw.println("<tbody>");
    Collection<CachedAnnouncement> incomingConnections = announcementRegistry.listLocalIncomingAnnouncements();
    for (Iterator<CachedAnnouncement> it = incomingConnections.iterator(); it.hasNext(); ) {
        CachedAnnouncement incomingCachedAnnouncement = it.next();
        Announcement incomingAnnouncement = incomingCachedAnnouncement.getAnnouncement();
        String oddEven = odd ? "odd" : "even";
        odd = !odd;
        pw.println("<tr class=\"" + oddEven + " ui-state-default\">");
        pw.println("<td>" + incomingAnnouncement.getOwnerId() + "</td>");
        if (incomingAnnouncement.getServerInfo() != null) {
            pw.println("<td>" + incomingAnnouncement.getServerInfo() + "</td>");
        } else {
            pw.println("<td><i>n/a</i></td>");
        }
        pw.println("<td>" + beautifiedTimeDiff(incomingCachedAnnouncement.getLastPing()) + "</td>");
        pw.println("<td>" + beautifiedDueTime(incomingCachedAnnouncement.getSecondsUntilTimeout()) + "</td>");
        pw.println("</tr>");
    }
    pw.println("</tbody>");
    pw.println("</table>");
    pw.println("<br/>");
    pw.println("<br/>");
}
Also used : CachedAnnouncement(org.apache.sling.discovery.base.connectors.announcement.CachedAnnouncement) Announcement(org.apache.sling.discovery.base.connectors.announcement.Announcement) CachedAnnouncement(org.apache.sling.discovery.base.connectors.announcement.CachedAnnouncement)

Aggregations

Announcement (org.apache.sling.discovery.base.connectors.announcement.Announcement)4 CachedAnnouncement (org.apache.sling.discovery.base.connectors.announcement.CachedAnnouncement)4 ClusterView (org.apache.sling.discovery.ClusterView)2 TopologyView (org.apache.sling.discovery.TopologyView)2 TopologyConnectorClientInformation (org.apache.sling.discovery.base.connectors.ping.TopologyConnectorClientInformation)2 ClusterSyncHistory (org.apache.sling.discovery.commons.providers.spi.base.ClusterSyncHistory)1