com.alibaba.dubbo.monitor.simple.RegistryContainer Java Examples

The following examples show how to use com.alibaba.dubbo.monitor.simple.RegistryContainer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DependenciesPageHandler.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public Page handle(URL url) {
    String application = url.getParameter("application");
    if (application == null || application.length() == 0) {
        throw new IllegalArgumentException("Please input application parameter.");
    }
    boolean reverse = url.getParameter("reverse", false);
    List<List<String>> rows = new ArrayList<List<String>>();
    Set<String> directly = RegistryContainer.getInstance().getDependencies(application, reverse);
    Set<String> indirectly = new HashSet<String>();
    appendDependency(rows, reverse, application, 0, new HashSet<String>(), indirectly);
    indirectly.remove(application);
    return new Page("<a href=\"applications.html\">Applications</a> &gt; " + application + 
            " &gt; <a href=\"providers.html?application=" + application + "\">Providers</a> | <a href=\"consumers.html?application=" + application + "\">Consumers</a> | " +
            (reverse ? "<a href=\"dependencies.html?application=" + application + "\">Depends On</a> | Used By" 
                    : "Depends On | <a href=\"dependencies.html?application=" + application + "&reverse=true\">Used By</a>"), (reverse ? "Used By" : "Depends On") + " (" + directly.size() + "/" + indirectly.size() + ")", new String[] { "Application Name:"}, rows);
}
 
Example #2
Source File: DependenciesPageHandler.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
public Page handle(URL url) {
    String application = url.getParameter("application");
    if (application == null || application.length() == 0) {
        throw new IllegalArgumentException("Please input application parameter.");
    }
    boolean reverse = url.getParameter("reverse", false);
    List<List<String>> rows = new ArrayList<List<String>>();
    Set<String> directly = RegistryContainer.getInstance().getDependencies(application, reverse);
    Set<String> indirectly = new HashSet<String>();
    appendDependency(rows, reverse, application, 0, new HashSet<String>(), indirectly);
    indirectly.remove(application);
    return new Page("<a href=\"applications.html\">Applications</a> &gt; " + application + 
            " &gt; <a href=\"providers.html?application=" + application + "\">Providers</a> | <a href=\"consumers.html?application=" + application + "\">Consumers</a> | " +
            (reverse ? "<a href=\"dependencies.html?application=" + application + "\">Depends On</a> | Used By" 
                    : "Depends On | <a href=\"dependencies.html?application=" + application + "&reverse=true\">Used By</a>"), (reverse ? "Used By" : "Depends On") + " (" + directly.size() + "/" + indirectly.size() + ")", new String[] { "Application Name:"}, rows);
}
 
Example #3
Source File: UnregisterPageHandler.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public Page handle(URL url) {
    String provider = url.getParameterAndDecoded("provider");
    if (provider == null || provider.length() == 0) {
        throw new IllegalArgumentException("Please input provider parameter.");
    }
    URL providerUrl = URL.valueOf(provider);
    RegistryContainer.getInstance().getRegistry().unregister(providerUrl);
    String parameter;
    if (url.hasParameter("service")) {
        parameter = "service=" + url.getParameter("service");
    } else if (url.hasParameter("host")) {
        parameter = "host=" + url.getParameter("host");
    } else if (url.hasParameter("application")) {
        parameter = "application=" + url.getParameter("application");
    } else {
        parameter = "service=" + providerUrl.getServiceInterface();
    }
    return new Page("<script type=\"text/javascript\">window.location.href=\"providers.html?" + parameter + "\";</script>");
}
 
Example #4
Source File: UnsubscribePageHandler.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
public Page handle(URL url) {
    String consumer = url.getParameterAndDecoded("consumer");
    if (consumer == null || consumer.length() == 0) {
        throw new IllegalArgumentException("Please input consumer parameter.");
    }
    URL consumerUrl = URL.valueOf(consumer);
    RegistryContainer.getInstance().getRegistry().unsubscribe(consumerUrl, NotifyListenerAdapter.NOTIFY_LISTENER);
    String parameter;
    if (url.hasParameter("service")) {
        parameter = "service=" + url.getParameter("service");
    } else if (url.hasParameter("host")) {
        parameter = "host=" + url.getParameter("host");
    } else if (url.hasParameter("application")) {
        parameter = "application=" + url.getParameter("application");
    } else {
        parameter = "service=" + consumerUrl.getServiceInterface();
    }
    return new Page("<script type=\"text/javascript\">window.location.href=\"consumers.html?" + parameter + "\";</script>");
}
 
Example #5
Source File: UnregisterPageHandler.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
public Page handle(URL url) {
    String provider = url.getParameterAndDecoded("provider");
    if (provider == null || provider.length() == 0) {
        throw new IllegalArgumentException("Please input provider parameter.");
    }
    URL providerUrl = URL.valueOf(provider);
    RegistryContainer.getInstance().getRegistry().unregister(providerUrl);
    String parameter;
    if (url.hasParameter("service")) {
        parameter = "service=" + url.getParameter("service");
    } else if (url.hasParameter("host")) {
        parameter = "host=" + url.getParameter("host");
    } else if (url.hasParameter("application")) {
        parameter = "application=" + url.getParameter("application");
    } else {
        parameter = "service=" + providerUrl.getServiceInterface();
    }
    return new Page("<script type=\"text/javascript\">window.location.href=\"providers.html?" + parameter + "\";</script>");
}
 
Example #6
Source File: UnsubscribePageHandler.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public Page handle(URL url) {
    String consumer = url.getParameterAndDecoded("consumer");
    if (consumer == null || consumer.length() == 0) {
        throw new IllegalArgumentException("Please input consumer parameter.");
    }
    URL consumerUrl = URL.valueOf(consumer);
    RegistryContainer.getInstance().getRegistry().unsubscribe(consumerUrl, NotifyListenerAdapter.NOTIFY_LISTENER);
    String parameter;
    if (url.hasParameter("service")) {
        parameter = "service=" + url.getParameter("service");
    } else if (url.hasParameter("host")) {
        parameter = "host=" + url.getParameter("host");
    } else if (url.hasParameter("application")) {
        parameter = "application=" + url.getParameter("application");
    } else {
        parameter = "service=" + consumerUrl.getServiceInterface();
    }
    return new Page("<script type=\"text/javascript\">window.location.href=\"consumers.html?" + parameter + "\";</script>");
}
 
Example #7
Source File: DependenciesPageHandler.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public Page handle(URL url) {
    String application = url.getParameter("application");
    if (application == null || application.length() == 0) {
        throw new IllegalArgumentException("Please input application parameter.");
    }
    boolean reverse = url.getParameter("reverse", false);
    List<List<String>> rows = new ArrayList<List<String>>();
    Set<String> directly = RegistryContainer.getInstance().getDependencies(application, reverse);
    Set<String> indirectly = new HashSet<String>();
    appendDependency(rows, reverse, application, 0, new HashSet<String>(), indirectly);
    indirectly.remove(application);
    return new Page("<a href=\"applications.html\">Applications</a> &gt; " + application + 
            " &gt; <a href=\"providers.html?application=" + application + "\">Providers</a> | <a href=\"consumers.html?application=" + application + "\">Consumers</a> | " +
            (reverse ? "<a href=\"dependencies.html?application=" + application + "\">Depends On</a> | Used By" 
                    : "Depends On | <a href=\"dependencies.html?application=" + application + "&reverse=true\">Used By</a>"), (reverse ? "Used By" : "Depends On") + " (" + directly.size() + "/" + indirectly.size() + ")", new String[] { "Application Name:"}, rows);
}
 
Example #8
Source File: DependenciesPageHandler.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
public Page handle(URL url) {
    String application = url.getParameter("application");
    if (application == null || application.length() == 0) {
        throw new IllegalArgumentException("Please input application parameter.");
    }
    boolean reverse = url.getParameter("reverse", false);
    List<List<String>> rows = new ArrayList<List<String>>();
    Set<String> directly = RegistryContainer.getInstance().getDependencies(application, reverse);
    Set<String> indirectly = new HashSet<String>();
    appendDependency(rows, reverse, application, 0, new HashSet<String>(), indirectly);
    indirectly.remove(application);
    return new Page("<a href=\"applications.html\">Applications</a> &gt; " + application + 
            " &gt; <a href=\"providers.html?application=" + application + "\">Providers</a> | <a href=\"consumers.html?application=" + application + "\">Consumers</a> | " +
            (reverse ? "<a href=\"dependencies.html?application=" + application + "\">Depends On</a> | Used By" 
                    : "Depends On | <a href=\"dependencies.html?application=" + application + "&reverse=true\">Used By</a>"), (reverse ? "Used By" : "Depends On") + " (" + directly.size() + "/" + indirectly.size() + ")", new String[] { "Application Name:"}, rows);
}
 
Example #9
Source File: UnsubscribePageHandler.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
public Page handle(URL url) {
    String consumer = url.getParameterAndDecoded("consumer");
    if (consumer == null || consumer.length() == 0) {
        throw new IllegalArgumentException("Please input consumer parameter.");
    }
    URL consumerUrl = URL.valueOf(consumer);
    RegistryContainer.getInstance().getRegistry().unsubscribe(consumerUrl, NotifyListenerAdapter.NOTIFY_LISTENER);
    String parameter;
    if (url.hasParameter("service")) {
        parameter = "service=" + url.getParameter("service");
    } else if (url.hasParameter("host")) {
        parameter = "host=" + url.getParameter("host");
    } else if (url.hasParameter("application")) {
        parameter = "application=" + url.getParameter("application");
    } else {
        parameter = "service=" + consumerUrl.getServiceInterface();
    }
    return new Page("<script type=\"text/javascript\">window.location.href=\"consumers.html?" + parameter + "\";</script>");
}
 
Example #10
Source File: UnregisterPageHandler.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
public Page handle(URL url) {
    String provider = url.getParameterAndDecoded("provider");
    if (provider == null || provider.length() == 0) {
        throw new IllegalArgumentException("Please input provider parameter.");
    }
    URL providerUrl = URL.valueOf(provider);
    RegistryContainer.getInstance().getRegistry().unregister(providerUrl);
    String parameter;
    if (url.hasParameter("service")) {
        parameter = "service=" + url.getParameter("service");
    } else if (url.hasParameter("host")) {
        parameter = "host=" + url.getParameter("host");
    } else if (url.hasParameter("application")) {
        parameter = "application=" + url.getParameter("application");
    } else {
        parameter = "service=" + providerUrl.getServiceInterface();
    }
    return new Page("<script type=\"text/javascript\">window.location.href=\"providers.html?" + parameter + "\";</script>");
}
 
Example #11
Source File: UnregisterPageHandler.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public Page handle(URL url) {
    String provider = url.getParameterAndDecoded("provider");
    if (provider == null || provider.length() == 0) {
        throw new IllegalArgumentException("Please input provider parameter.");
    }
    URL providerUrl = URL.valueOf(provider);
    RegistryContainer.getInstance().getRegistry().unregister(providerUrl);
    String parameter;
    if (url.hasParameter("service")) {
        parameter = "service=" + url.getParameter("service");
    } else if (url.hasParameter("host")) {
        parameter = "host=" + url.getParameter("host");
    } else if (url.hasParameter("application")) {
        parameter = "application=" + url.getParameter("application");
    } else {
        parameter = "service=" + providerUrl.getServiceInterface();
    }
    return new Page("<script type=\"text/javascript\">window.location.href=\"providers.html?" + parameter + "\";</script>");
}
 
Example #12
Source File: UnsubscribePageHandler.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public Page handle(URL url) {
    String consumer = url.getParameterAndDecoded("consumer");
    if (consumer == null || consumer.length() == 0) {
        throw new IllegalArgumentException("Please input consumer parameter.");
    }
    URL consumerUrl = URL.valueOf(consumer);
    RegistryContainer.getInstance().getRegistry().unsubscribe(consumerUrl, NotifyListenerAdapter.NOTIFY_LISTENER);
    String parameter;
    if (url.hasParameter("service")) {
        parameter = "service=" + url.getParameter("service");
    } else if (url.hasParameter("host")) {
        parameter = "host=" + url.getParameter("host");
    } else if (url.hasParameter("application")) {
        parameter = "application=" + url.getParameter("application");
    } else {
        parameter = "service=" + consumerUrl.getServiceInterface();
    }
    return new Page("<script type=\"text/javascript\">window.location.href=\"consumers.html?" + parameter + "\";</script>");
}
 
Example #13
Source File: DependenciesPageHandler.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public Page handle(URL url) {
    String application = url.getParameter("application");
    if (application == null || application.length() == 0) {
        throw new IllegalArgumentException("Please input application parameter.");
    }
    boolean reverse = url.getParameter("reverse", false);
    List<List<String>> rows = new ArrayList<List<String>>();
    Set<String> directly = RegistryContainer.getInstance().getDependencies(application, reverse);
    Set<String> indirectly = new HashSet<String>();
    appendDependency(rows, reverse, application, 0, new HashSet<String>(), indirectly);
    indirectly.remove(application);
    return new Page("<a href=\"applications.html\">Applications</a> &gt; " + application + 
            " &gt; <a href=\"providers.html?application=" + application + "\">Providers</a> | <a href=\"consumers.html?application=" + application + "\">Consumers</a> | " +
            (reverse ? "<a href=\"dependencies.html?application=" + application + "\">Depends On</a> | Used By" 
                    : "Depends On | <a href=\"dependencies.html?application=" + application + "&reverse=true\">Used By</a>"), (reverse ? "Used By" : "Depends On") + " (" + directly.size() + "/" + indirectly.size() + ")", new String[] { "Application Name:"}, rows);
}
 
Example #14
Source File: UnsubscribePageHandler.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public Page handle(URL url) {
    String consumer = url.getParameterAndDecoded("consumer");
    if (consumer == null || consumer.length() == 0) {
        throw new IllegalArgumentException("Please input consumer parameter.");
    }
    URL consumerUrl = URL.valueOf(consumer);
    RegistryContainer.getInstance().getRegistry().unsubscribe(consumerUrl, NotifyListenerAdapter.NOTIFY_LISTENER);
    String parameter;
    if (url.hasParameter("service")) {
        parameter = "service=" + url.getParameter("service");
    } else if (url.hasParameter("host")) {
        parameter = "host=" + url.getParameter("host");
    } else if (url.hasParameter("application")) {
        parameter = "application=" + url.getParameter("application");
    } else {
        parameter = "service=" + consumerUrl.getServiceInterface();
    }
    return new Page("<script type=\"text/javascript\">window.location.href=\"consumers.html?" + parameter + "\";</script>");
}
 
Example #15
Source File: UnregisterPageHandler.java    From dubbox with Apache License 2.0 6 votes vote down vote up
public Page handle(URL url) {
    String provider = url.getParameterAndDecoded("provider");
    if (provider == null || provider.length() == 0) {
        throw new IllegalArgumentException("Please input provider parameter.");
    }
    URL providerUrl = URL.valueOf(provider);
    RegistryContainer.getInstance().getRegistry().unregister(providerUrl);
    String parameter;
    if (url.hasParameter("service")) {
        parameter = "service=" + url.getParameter("service");
    } else if (url.hasParameter("host")) {
        parameter = "host=" + url.getParameter("host");
    } else if (url.hasParameter("application")) {
        parameter = "application=" + url.getParameter("application");
    } else {
        parameter = "service=" + providerUrl.getServiceInterface();
    }
    return new Page("<script type=\"text/javascript\">window.location.href=\"providers.html?" + parameter + "\";</script>");
}
 
Example #16
Source File: ServicesPageHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Page handle(URL url) {
    Set<String> services = RegistryContainer.getInstance().getServices();
    List<List<String>> rows = new ArrayList<List<String>>();
    int providerCount = 0;
    int consumerCount = 0;
    if (services != null && services.size() > 0) {
        for (String service : services) {
            List<URL> providers = RegistryContainer.getInstance().getProvidersByService(service);
            int providerSize = providers == null ? 0 : providers.size();
            providerCount += providerSize;
            List<URL> consumers = RegistryContainer.getInstance().getConsumersByService(service);
            int consumerSize = consumers == null ? 0 : consumers.size();
            consumerCount += consumerSize;
            List<String> row = new ArrayList<String>();
            row.add(service);
            if (providerSize > 0 || consumerSize > 0) {
                if (providerSize > 0) {
                    URL provider = providers.iterator().next();
                    row.add(provider.getParameter(Constants.APPLICATION_KEY, ""));
                    row.add(provider.getParameter("owner", "") + (provider.hasParameter("organization") ?  " (" + provider.getParameter("organization") + ")" : ""));
                } else {
                    row.add("");
                    row.add("");
                }
                row.add(providerSize == 0 ? "<font color=\"red\">No provider</a>" : "<a href=\"providers.html?service=" + service + "\">Providers(" + providerSize + ")</a>");
                row.add(consumerSize == 0 ? "<font color=\"blue\">No consumer</a>" : "<a href=\"consumers.html?service=" + service + "\">Consumers(" + consumerSize + ")</a>");
                row.add("<a href=\"statistics.html?service=" + service + "\">Statistics</a>");
                row.add("<a href=\"charts.html?service=" + service + "\">Charts</a>");
                rows.add(row);
            }
        }
    }
    return new Page("Services", "Services (" + rows.size() + ")",
            new String[] { "Service Name:", "Application", "Owner", "Providers(" + providerCount + ")", "Consumers(" + consumerCount + ")", "Statistics", "Charts" }, rows);
}
 
Example #17
Source File: DependenciesPageHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private void appendDependency(List<List<String>> rows, boolean reverse, String application, int level, Set<String> appended, Set<String> indirectly) {
    List<String> row = new ArrayList<String>();
    StringBuilder buf = new StringBuilder();
    if (level > 0) {
        for (int i = 0; i < level; i ++) {
            buf.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|");
        }
        buf.append(reverse ? "&lt;-- " : "--&gt; ");
    }
    boolean end = false;
    if (level > 5) {
        buf.append(" <font color=\"blue\">More...</font>");
        end = true;
    } else {
        buf.append(application);
        if (appended.contains(application)) {
            buf.append(" <font color=\"red\">(Cycle)</font>");
            end = true;
        }
    }
    row.add(buf.toString());
    rows.add(row);
    if (end) {
        return;
    }
    
    appended.add(application);
    indirectly.add(application);
    Set<String> dependencies = RegistryContainer.getInstance().getDependencies(application, reverse);
    if (dependencies != null && dependencies.size() > 0) {
        for (String dependency : dependencies) {
            appendDependency(rows, reverse, dependency, level + 1, appended, indirectly);
        }
    }
    appended.remove(application);
}
 
Example #18
Source File: HostsPageHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Page handle(URL url) {
    List<List<String>> rows = new ArrayList<List<String>>();
    Set<String> hosts = RegistryContainer.getInstance().getHosts();
    int providersCount = 0;
    int consumersCount = 0;
    if (hosts != null && hosts.size() > 0) {
        for (String host : hosts) {
            List<String> row = new ArrayList<String>();
            row.add(NetUtils.getHostName(host) + "/" + host);
            
            List<URL> providers = RegistryContainer.getInstance().getProvidersByHost(host);
            List<URL> consumers = RegistryContainer.getInstance().getConsumersByHost(host);
            
            if (providers != null && providers.size() > 0
                    || consumers != null && consumers.size() > 0) {
                URL provider = (providers != null && providers.size() > 0 ? providers.iterator().next() : consumers.iterator().next());
                row.add(provider.getParameter(Constants.APPLICATION_KEY, ""));
                row.add(provider.getParameter("owner", "") + (provider.hasParameter("organization") ?  " (" + provider.getParameter("organization") + ")" : ""));
            } else {
                row.add("");
                row.add("");
            }
            
            int proviedSize = providers == null ? 0 : providers.size();
            providersCount += proviedSize;
            row.add(proviedSize == 0 ? "<font color=\"blue\">No provider</font>" : "<a href=\"providers.html?host=" + host + "\">Providers(" + proviedSize + ")</a>");
            
            int consumersSize = consumers == null ? 0 : consumers.size();
            consumersCount += consumersSize;
            row.add(consumersSize == 0 ? "<font color=\"blue\">No consumer</font>" : "<a href=\"consumers.html?host=" + host + "\">Consumers(" + consumersSize + ")</a>");
            
            rows.add(row);
        }
    }
    return new Page("Hosts", "Hosts (" + rows.size() + ")",
            new String[] { "Host Name/IP:", "Application", "Owner", "Providers(" + providersCount + ")", "Consumers(" + consumersCount + ")" }, rows);
}
 
Example #19
Source File: HostsPageHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Page handle(URL url) {
    List<List<String>> rows = new ArrayList<List<String>>();
    Set<String> hosts = RegistryContainer.getInstance().getHosts();
    int providersCount = 0;
    int consumersCount = 0;
    if (hosts != null && hosts.size() > 0) {
        for (String host : hosts) {
            List<String> row = new ArrayList<String>();
            row.add(NetUtils.getHostName(host) + "/" + host);
            
            List<URL> providers = RegistryContainer.getInstance().getProvidersByHost(host);
            List<URL> consumers = RegistryContainer.getInstance().getConsumersByHost(host);
            
            if (providers != null && providers.size() > 0
                    || consumers != null && consumers.size() > 0) {
                URL provider = (providers != null && providers.size() > 0 ? providers.iterator().next() : consumers.iterator().next());
                row.add(provider.getParameter(Constants.APPLICATION_KEY, ""));
                row.add(provider.getParameter("owner", "") + (provider.hasParameter("organization") ?  " (" + provider.getParameter("organization") + ")" : ""));
            } else {
                row.add("");
                row.add("");
            }
            
            int proviedSize = providers == null ? 0 : providers.size();
            providersCount += proviedSize;
            row.add(proviedSize == 0 ? "<font color=\"blue\">No provider</font>" : "<a href=\"providers.html?host=" + host + "\">Providers(" + proviedSize + ")</a>");
            
            int consumersSize = consumers == null ? 0 : consumers.size();
            consumersCount += consumersSize;
            row.add(consumersSize == 0 ? "<font color=\"blue\">No consumer</font>" : "<a href=\"consumers.html?host=" + host + "\">Consumers(" + consumersSize + ")</a>");
            
            rows.add(row);
        }
    }
    return new Page("Hosts", "Hosts (" + rows.size() + ")",
            new String[] { "Host Name/IP:", "Application", "Owner", "Providers(" + providersCount + ")", "Consumers(" + consumersCount + ")" }, rows);
}
 
Example #20
Source File: DependenciesPageHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private void appendDependency(List<List<String>> rows, boolean reverse, String application, int level, Set<String> appended, Set<String> indirectly) {
    List<String> row = new ArrayList<String>();
    StringBuilder buf = new StringBuilder();
    if (level > 0) {
        for (int i = 0; i < level; i ++) {
            buf.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|");
        }
        buf.append(reverse ? "&lt;-- " : "--&gt; ");
    }
    boolean end = false;
    if (level > 5) {
        buf.append(" <font color=\"blue\">More...</font>");
        end = true;
    } else {
        buf.append(application);
        if (appended.contains(application)) {
            buf.append(" <font color=\"red\">(Cycle)</font>");
            end = true;
        }
    }
    row.add(buf.toString());
    rows.add(row);
    if (end) {
        return;
    }
    
    appended.add(application);
    indirectly.add(application);
    Set<String> dependencies = RegistryContainer.getInstance().getDependencies(application, reverse);
    if (dependencies != null && dependencies.size() > 0) {
        for (String dependency : dependencies) {
            appendDependency(rows, reverse, dependency, level + 1, appended, indirectly);
        }
    }
    appended.remove(application);
}
 
Example #21
Source File: ServicesPageHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Page handle(URL url) {
    Set<String> services = RegistryContainer.getInstance().getServices();
    List<List<String>> rows = new ArrayList<List<String>>();
    int providerCount = 0;
    int consumerCount = 0;
    if (services != null && services.size() > 0) {
        for (String service : services) {
            List<URL> providers = RegistryContainer.getInstance().getProvidersByService(service);
            int providerSize = providers == null ? 0 : providers.size();
            providerCount += providerSize;
            List<URL> consumers = RegistryContainer.getInstance().getConsumersByService(service);
            int consumerSize = consumers == null ? 0 : consumers.size();
            consumerCount += consumerSize;
            List<String> row = new ArrayList<String>();
            row.add(service);
            if (providerSize > 0 || consumerSize > 0) {
                if (providerSize > 0) {
                    URL provider = providers.iterator().next();
                    row.add(provider.getParameter(Constants.APPLICATION_KEY, ""));
                    row.add(provider.getParameter("owner", "") + (provider.hasParameter("organization") ?  " (" + provider.getParameter("organization") + ")" : ""));
                } else {
                    row.add("");
                    row.add("");
                }
                row.add(providerSize == 0 ? "<font color=\"red\">No provider</a>" : "<a href=\"providers.html?service=" + service + "\">Providers(" + providerSize + ")</a>");
                row.add(consumerSize == 0 ? "<font color=\"blue\">No consumer</a>" : "<a href=\"consumers.html?service=" + service + "\">Consumers(" + consumerSize + ")</a>");
                row.add("<a href=\"statistics.html?service=" + service + "\">Statistics</a>");
                row.add("<a href=\"charts.html?service=" + service + "\">Charts</a>");
                rows.add(row);
            }
        }
    }
    return new Page("Services", "Services (" + rows.size() + ")",
            new String[] { "Service Name:", "Application", "Owner", "Providers(" + providerCount + ")", "Consumers(" + consumerCount + ")", "Statistics", "Charts" }, rows);
}
 
Example #22
Source File: DependenciesPageHandler.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
private void appendDependency(List<List<String>> rows, boolean reverse, String application, int level, Set<String> appended, Set<String> indirectly) {
    List<String> row = new ArrayList<String>();
    StringBuilder buf = new StringBuilder();
    if (level > 0) {
        for (int i = 0; i < level; i ++) {
            buf.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|");
        }
        buf.append(reverse ? "&lt;-- " : "--&gt; ");
    }
    boolean end = false;
    if (level > 5) {
        buf.append(" <font color=\"blue\">More...</font>");
        end = true;
    } else {
        buf.append(application);
        if (appended.contains(application)) {
            buf.append(" <font color=\"red\">(Cycle)</font>");
            end = true;
        }
    }
    row.add(buf.toString());
    rows.add(row);
    if (end) {
        return;
    }
    
    appended.add(application);
    indirectly.add(application);
    Set<String> dependencies = RegistryContainer.getInstance().getDependencies(application, reverse);
    if (dependencies != null && dependencies.size() > 0) {
        for (String dependency : dependencies) {
            appendDependency(rows, reverse, dependency, level + 1, appended, indirectly);
        }
    }
    appended.remove(application);
}
 
Example #23
Source File: HostsPageHandler.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public Page handle(URL url) {
    List<List<String>> rows = new ArrayList<>();
    Set<String> hosts = RegistryContainer.getInstance().getHosts();
    int providersCount = 0;
    int consumersCount = 0;
    if (hosts != null && hosts.size() > 0) {
        for (String host : hosts) {
            List<String> row = new ArrayList<String>();
            row.add(NetUtils.getHostName(host) + "/" + host);
            
            List<URL> providers = RegistryContainer.getInstance().getProvidersByHost(host);
            List<URL> consumers = RegistryContainer.getInstance().getConsumersByHost(host);
            
            if (providers != null && providers.size() > 0
                    || consumers != null && consumers.size() > 0) {
                URL provider = (providers != null && providers.size() > 0 ? providers.iterator().next() : consumers.iterator().next());
                row.add(provider.getParameter(Constants.APPLICATION_KEY, ""));
                row.add(provider.getParameter("owner", "") + (provider.hasParameter("organization") ?  " (" + provider.getParameter("organization") + ")" : ""));
            } else {
                row.add("");
                row.add("");
            }
            
            int proviedSize = providers == null ? 0 : providers.size();
            providersCount += proviedSize;
            row.add(proviedSize == 0 ? "<font color=\"blue\">No provider</font>" : "<a href=\"providers.html?host=" + host + "\">Providers(" + proviedSize + ")</a>");
            
            int consumersSize = consumers == null ? 0 : consumers.size();
            consumersCount += consumersSize;
            row.add(consumersSize == 0 ? "<font color=\"blue\">No consumer</font>" : "<a href=\"consumers.html?host=" + host + "\">Consumers(" + consumersSize + ")</a>");
            
            rows.add(row);
        }
    }
    return new Page("Hosts", "Hosts (" + rows.size() + ")",
            new String[] { "Host Name/IP:", "Application", "Owner", "Providers(" + providersCount + ")", "Consumers(" + consumersCount + ")" }, rows);
}
 
Example #24
Source File: ServicesPageHandler.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public Page handle(URL url) {
    Set<String> services = RegistryContainer.getInstance().getServices();
    List<List<String>> rows = new ArrayList<List<String>>();
    int providerCount = 0;
    int consumerCount = 0;
    if (services != null && services.size() > 0) {
        for (String service : services) {
            List<URL> providers = RegistryContainer.getInstance().getProvidersByService(service);
            int providerSize = providers == null ? 0 : providers.size();
            providerCount += providerSize;
            List<URL> consumers = RegistryContainer.getInstance().getConsumersByService(service);
            int consumerSize = consumers == null ? 0 : consumers.size();
            consumerCount += consumerSize;
            List<String> row = new ArrayList<String>();
            row.add(service);
            if (providerSize > 0 || consumerSize > 0) {
                if (providerSize > 0) {
                    URL provider = providers.iterator().next();
                    row.add(provider.getParameter(Constants.APPLICATION_KEY, ""));
                    row.add(provider.getParameter("owner", "") + (provider.hasParameter("organization") ?  " (" + provider.getParameter("organization") + ")" : ""));
                } else {
                    row.add("");
                    row.add("");
                }
                row.add(providerSize == 0 ? "<font color=\"red\">No provider</a>" : "<a href=\"providers.html?service=" + service + "\">Providers(" + providerSize + ")</a>");
                row.add(consumerSize == 0 ? "<font color=\"blue\">No consumer</a>" : "<a href=\"consumers.html?service=" + service + "\">Consumers(" + consumerSize + ")</a>");
                row.add("<a href=\"statistics.html?service=" + service + "\">Statistics</a>");
                row.add("<a href=\"charts.html?service=" + service + "\">Charts</a>");
                rows.add(row);
            }
        }
    }
    return new Page("Services", "Services (" + rows.size() + ")",
            new String[] { "Service Name:", "Application", "Owner", "Providers(" + providerCount + ")", "Consumers(" + consumerCount + ")", "Statistics", "Charts" }, rows);
}
 
Example #25
Source File: DependenciesPageHandler.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
private void appendDependency(List<List<String>> rows, boolean reverse, String application, int level, Set<String> appended, Set<String> indirectly) {
    List<String> row = new ArrayList<String>();
    StringBuilder buf = new StringBuilder();
    if (level > 0) {
        for (int i = 0; i < level; i ++) {
            buf.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|");
        }
        buf.append(reverse ? "&lt;-- " : "--&gt; ");
    }
    boolean end = false;
    if (level > 5) {
        buf.append(" <font color=\"blue\">More...</font>");
        end = true;
    } else {
        buf.append(application);
        if (appended.contains(application)) {
            buf.append(" <font color=\"red\">(Cycle)</font>");
            end = true;
        }
    }
    row.add(buf.toString());
    rows.add(row);
    if (end) {
        return;
    }
    
    appended.add(application);
    indirectly.add(application);
    Set<String> dependencies = RegistryContainer.getInstance().getDependencies(application, reverse);
    if (dependencies != null && dependencies.size() > 0) {
        for (String dependency : dependencies) {
            appendDependency(rows, reverse, dependency, level + 1, appended, indirectly);
        }
    }
    appended.remove(application);
}
 
Example #26
Source File: HostsPageHandler.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public Page handle(URL url) {
    List<List<String>> rows = new ArrayList<List<String>>();
    Set<String> hosts = RegistryContainer.getInstance().getHosts();
    int providersCount = 0;
    int consumersCount = 0;
    if (hosts != null && hosts.size() > 0) {
        for (String host : hosts) {
            List<String> row = new ArrayList<String>();
            row.add(NetUtils.getHostName(host) + "/" + host);
            
            List<URL> providers = RegistryContainer.getInstance().getProvidersByHost(host);
            List<URL> consumers = RegistryContainer.getInstance().getConsumersByHost(host);
            
            if (providers != null && providers.size() > 0
                    || consumers != null && consumers.size() > 0) {
                URL provider = (providers != null && providers.size() > 0 ? providers.iterator().next() : consumers.iterator().next());
                row.add(provider.getParameter(Constants.APPLICATION_KEY, ""));
                row.add(provider.getParameter("owner", "") + (provider.hasParameter("organization") ?  " (" + provider.getParameter("organization") + ")" : ""));
            } else {
                row.add("");
                row.add("");
            }
            
            int proviedSize = providers == null ? 0 : providers.size();
            providersCount += proviedSize;
            row.add(proviedSize == 0 ? "<font color=\"blue\">No provider</font>" : "<a href=\"providers.html?host=" + host + "\">Providers(" + proviedSize + ")</a>");
            
            int consumersSize = consumers == null ? 0 : consumers.size();
            consumersCount += consumersSize;
            row.add(consumersSize == 0 ? "<font color=\"blue\">No consumer</font>" : "<a href=\"consumers.html?host=" + host + "\">Consumers(" + consumersSize + ")</a>");
            
            rows.add(row);
        }
    }
    return new Page("Hosts", "Hosts (" + rows.size() + ")",
            new String[] { "Host Name/IP:", "Application", "Owner", "Providers(" + providersCount + ")", "Consumers(" + consumersCount + ")" }, rows);
}
 
Example #27
Source File: ServicesPageHandler.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public Page handle(URL url) {
    Set<String> services = RegistryContainer.getInstance().getServices();
    List<List<String>> rows = new ArrayList<List<String>>();
    int providerCount = 0;
    int consumerCount = 0;
    if (services != null && services.size() > 0) {
        for (String service : services) {
            List<URL> providers = RegistryContainer.getInstance().getProvidersByService(service);
            int providerSize = providers == null ? 0 : providers.size();
            providerCount += providerSize;
            List<URL> consumers = RegistryContainer.getInstance().getConsumersByService(service);
            int consumerSize = consumers == null ? 0 : consumers.size();
            consumerCount += consumerSize;
            List<String> row = new ArrayList<String>();
            row.add(service);
            if (providerSize > 0 || consumerSize > 0) {
                if (providerSize > 0) {
                    URL provider = providers.iterator().next();
                    row.add(provider.getParameter(Constants.APPLICATION_KEY, ""));
                    row.add(provider.getParameter("owner", "") + (provider.hasParameter("organization") ?  " (" + provider.getParameter("organization") + ")" : ""));
                } else {
                    row.add("");
                    row.add("");
                }
                row.add(providerSize == 0 ? "<font color=\"red\">No provider</a>" : "<a href=\"providers.html?service=" + service + "\">Providers(" + providerSize + ")</a>");
                row.add(consumerSize == 0 ? "<font color=\"blue\">No consumer</a>" : "<a href=\"consumers.html?service=" + service + "\">Consumers(" + consumerSize + ")</a>");
                row.add("<a href=\"statistics.html?service=" + service + "\">Statistics</a>");
                row.add("<a href=\"charts.html?service=" + service + "\">Charts</a>");
                rows.add(row);
            }
        }
    }
    return new Page("Services", "Services (" + rows.size() + ")",
            new String[] { "Service Name:", "Application", "Owner", "Providers(" + providerCount + ")", "Consumers(" + consumerCount + ")", "Statistics", "Charts" }, rows);
}
 
Example #28
Source File: DependenciesPageHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
private void appendDependency(List<List<String>> rows, boolean reverse, String application, int level, Set<String> appended, Set<String> indirectly) {
    List<String> row = new ArrayList<String>();
    StringBuilder buf = new StringBuilder();
    if (level > 0) {
        for (int i = 0; i < level; i ++) {
            buf.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|");
        }
        buf.append(reverse ? "&lt;-- " : "--&gt; ");
    }
    boolean end = false;
    if (level > 5) {
        buf.append(" <font color=\"blue\">More...</font>");
        end = true;
    } else {
        buf.append(application);
        if (appended.contains(application)) {
            buf.append(" <font color=\"red\">(Cycle)</font>");
            end = true;
        }
    }
    row.add(buf.toString());
    rows.add(row);
    if (end) {
        return;
    }
    
    appended.add(application);
    indirectly.add(application);
    Set<String> dependencies = RegistryContainer.getInstance().getDependencies(application, reverse);
    if (dependencies != null && dependencies.size() > 0) {
        for (String dependency : dependencies) {
            appendDependency(rows, reverse, dependency, level + 1, appended, indirectly);
        }
    }
    appended.remove(application);
}
 
Example #29
Source File: HostsPageHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Page handle(URL url) {
    List<List<String>> rows = new ArrayList<List<String>>();
    Set<String> hosts = RegistryContainer.getInstance().getHosts();
    int providersCount = 0;
    int consumersCount = 0;
    if (hosts != null && hosts.size() > 0) {
        for (String host : hosts) {
            List<String> row = new ArrayList<String>();
            row.add(NetUtils.getHostName(host) + "/" + host);
            
            List<URL> providers = RegistryContainer.getInstance().getProvidersByHost(host);
            List<URL> consumers = RegistryContainer.getInstance().getConsumersByHost(host);
            
            if (providers != null && providers.size() > 0
                    || consumers != null && consumers.size() > 0) {
                URL provider = (providers != null && providers.size() > 0 ? providers.iterator().next() : consumers.iterator().next());
                row.add(provider.getParameter(Constants.APPLICATION_KEY, ""));
                row.add(provider.getParameter("owner", "") + (provider.hasParameter("organization") ?  " (" + provider.getParameter("organization") + ")" : ""));
            } else {
                row.add("");
                row.add("");
            }
            
            int proviedSize = providers == null ? 0 : providers.size();
            providersCount += proviedSize;
            row.add(proviedSize == 0 ? "<font color=\"blue\">No provider</font>" : "<a href=\"providers.html?host=" + host + "\">Providers(" + proviedSize + ")</a>");
            
            int consumersSize = consumers == null ? 0 : consumers.size();
            consumersCount += consumersSize;
            row.add(consumersSize == 0 ? "<font color=\"blue\">No consumer</font>" : "<a href=\"consumers.html?host=" + host + "\">Consumers(" + consumersSize + ")</a>");
            
            rows.add(row);
        }
    }
    return new Page("Hosts", "Hosts (" + rows.size() + ")",
            new String[] { "Host Name/IP:", "Application", "Owner", "Providers(" + providersCount + ")", "Consumers(" + consumersCount + ")" }, rows);
}
 
Example #30
Source File: ServicesPageHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Page handle(URL url) {
    Set<String> services = RegistryContainer.getInstance().getServices();
    List<List<String>> rows = new ArrayList<List<String>>();
    int providerCount = 0;
    int consumerCount = 0;
    if (services != null && services.size() > 0) {
        for (String service : services) {
            List<URL> providers = RegistryContainer.getInstance().getProvidersByService(service);
            int providerSize = providers == null ? 0 : providers.size();
            providerCount += providerSize;
            List<URL> consumers = RegistryContainer.getInstance().getConsumersByService(service);
            int consumerSize = consumers == null ? 0 : consumers.size();
            consumerCount += consumerSize;
            List<String> row = new ArrayList<String>();
            row.add(service);
            if (providerSize > 0 || consumerSize > 0) {
                if (providerSize > 0) {
                    URL provider = providers.iterator().next();
                    row.add(provider.getParameter(Constants.APPLICATION_KEY, ""));
                    row.add(provider.getParameter("owner", "") + (provider.hasParameter("organization") ?  " (" + provider.getParameter("organization") + ")" : ""));
                } else {
                    row.add("");
                    row.add("");
                }
                row.add(providerSize == 0 ? "<font color=\"red\">No provider</a>" : "<a href=\"providers.html?service=" + service + "\">Providers(" + providerSize + ")</a>");
                row.add(consumerSize == 0 ? "<font color=\"blue\">No consumer</a>" : "<a href=\"consumers.html?service=" + service + "\">Consumers(" + consumerSize + ")</a>");
                row.add("<a href=\"statistics.html?service=" + service + "\">Statistics</a>");
                row.add("<a href=\"charts.html?service=" + service + "\">Charts</a>");
                rows.add(row);
            }
        }
    }
    return new Page("Services", "Services (" + rows.size() + ")",
            new String[] { "Service Name:", "Application", "Owner", "Providers(" + providerCount + ")", "Consumers(" + consumerCount + ")", "Statistics", "Charts" }, rows);
}