Package io.undertow.io

Examples of io.undertow.io.Sender


            }
        }

        exchange.setResponseCode(200);
        exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, "text/html; charset=ISO-8859-1");
        final Sender resp = exchange.getResponseSender();

        final StringBuilder buf = new StringBuilder();
        buf.append("<html><head>\n<title>Mod_cluster Status</title>\n</head><body>\n");
        buf.append("<h1>" + MOD_CLUSTER_EXPOSED_VERSION + "</h1>");

        final String uri = exchange.getRequestPath();
        final String nonce = getNonce();
        if (refreshTime <= 0) {
            buf.append("<a href=\"").append(uri).append("?").append(nonce).append("&refresh=").append(refreshTime).append("\">Auto Refresh</a>");
        }
        buf.append(" <a href=\"").append(uri).append("?").append(nonce).append("&Cmd=DUMP&Range=ALL").append("\">show DUMP output</a>");
        buf.append(" <a href=\"").append(uri).append("?").append(nonce).append("&Cmd=INFO&Range=ALL").append("\">show INFO output</a>");
        buf.append("\n");

        // Show load balancing groups
        final Map<String, List<Node>> nodes = new LinkedHashMap<>();
        for (final Node node : container.getNodes()) {
            final String domain = node.getNodeConfig().getDomain() != null ? node.getNodeConfig().getDomain() : "";
            List<Node> list = nodes.get(domain);
            if (list == null) {
                list = new ArrayList<>();
                nodes.put(domain, list);
            }
            list.add(node);
        }

        for (Map.Entry<String, List<Node>> entry : nodes.entrySet()) {
            final String groupName = entry.getKey();
            if (reduceDisplay) {
                buf.append("<br/><br/>LBGroup " + groupName + ": ");
            } else {
                buf.append("<h1> LBGroup " + groupName + ": ");
            }
            if (allowCmd) {
                domainCommandString(buf, uri, MCMPAction.ENABLE, groupName);
                domainCommandString(buf, uri, MCMPAction.DISABLE, groupName);
            }

            for (final Node node : entry.getValue()) {
                final NodeConfig nodeConfig = node.getNodeConfig();
                if (reduceDisplay) {
                    buf.append("<br/><br/>Node " + nodeConfig.getJvmRoute());
                    printProxyStat(buf, node, reduceDisplay);
                } else {
                    buf.append("<h1> Node " + nodeConfig.getJvmRoute() + " (" + nodeConfig.getConnectionURI() + "): </h1>\n");
                }

                if (allowCmd) {
                    nodeCommandString(buf, uri, MCMPAction.ENABLE, nodeConfig.getJvmRoute());
                    nodeCommandString(buf, uri, MCMPAction.DISABLE, nodeConfig.getJvmRoute());
                }
                if (!reduceDisplay) {
                    buf.append("<br/>\n");
                    buf.append("Balancer: " + nodeConfig.getBalancer() + ",LBGroup: " + nodeConfig.getDomain());
                    String flushpackets = "off";
                    if (nodeConfig.isFlushPackets()) {
                        flushpackets = "Auto";
                    }
                    buf.append(",Flushpackets: " + flushpackets + ",Flushwait: " + nodeConfig.getFlushwait() + ",Ping: " + nodeConfig.getPing() + " ,Smax: " + nodeConfig.getPing() + ",Ttl: " + nodeConfig.getTtl());
                    printProxyStat(buf, node, reduceDisplay);
                } else {
                    buf.append("<br/>\n");
                }
                // the sessionid list is mostly for demos.
                if (displaySessionIds) {
                    // buf.append(",Num sessions: " + container.getJVMRouteSessionCount(nodeConfig.getJvmRoute()));
                }
                buf.append("\n");

                // Process the virtual-host of the node
                printInfoHost(buf, uri, reduceDisplay, allowCmd, node);
            }
        }

        // Display the all the actives sessions
        if (displaySessionIds) {
            printInfoSessions(buf, Collections.<SessionId>emptyList());
        }

        buf.append("</body></html>\n");
        resp.send(buf.toString());
    }
View Full Code Here


                }
                Set<Integer> codes = responseCodes;
                if (codes == null ? exchange.getResponseCode() >= 400 : codes.contains(Integer.valueOf(exchange.getResponseCode()))) {
                    final String errorPage = "<html><head><title>Error</title></head><body>" + exchange.getResponseCode() + " - " + StatusCodes.getReason(exchange.getResponseCode()) + "</body></html>";
                    exchange.getResponseHeaders().put(Headers.CONTENT_LENGTH, "" + errorPage.length());
                    Sender sender = exchange.getResponseSender();
                    sender.send(errorPage);
                    return true;
                }
                return false;
            }
        });
View Full Code Here

            underlyingResource.serve(sender, exchange, completionCallback);
            return;
        }
        //it is not cached yet, install a wrapper to grab the data
        if (existing == null || !existing.enabled() || !existing.reference()) {
            Sender newSender = sender;

            final DirectBufferCache.CacheEntry entry;
            if (existing == null) {
                entry = dataCache.add(cacheKey, length.intValue(), cachingResourceManager.getMaxAge());
            } else {
View Full Code Here

            handleRequest(method, exchange);
        } catch (Exception e) {
            UndertowLogger.ROOT_LOGGER.errorf(e, "failed to process management request");
            exchange.setResponseCode(500);
            exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, CONTENT_TYPE);
            final Sender sender = exchange.getResponseSender();
            sender.send("failed to process management request");
        }
    }
View Full Code Here

     * @param response    the response string
     */
    static void sendResponse(final HttpServerExchange exchange, final String response) {
        exchange.setResponseCode(200);
        exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, CONTENT_TYPE);
        final Sender sender = exchange.getResponseSender();
        sender.send(response);
    }
View Full Code Here

            }
        }

        exchange.setResponseCode(200);
        exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, "text/html; charset=ISO-8859-1");
        final Sender resp = exchange.getResponseSender();

        final StringBuilder buf = new StringBuilder();
        buf.append("<html><head>\n<title>Mod_cluster Status</title>\n</head><body>\n");
        buf.append("<h1>" + MOD_CLUSTER_EXPOSED_VERSION + "</h1>");

        final String uri = exchange.getRequestPath();
        final String nonce = getNonce();
        if (refreshTime <= 0) {
            buf.append("<a href=\"").append(uri).append("?").append(nonce).append("&refresh=").append(refreshTime).append("\">Auto Refresh</a>");
        }
        buf.append(" <a href=\"").append(uri).append("?").append(nonce).append("&Cmd=DUMP&Range=ALL").append("\">show DUMP output</a>");
        buf.append(" <a href=\"").append(uri).append("?").append(nonce).append("&Cmd=INFO&Range=ALL").append("\">show INFO output</a>");
        buf.append("\n");

        // Show load balancing groups
        final Map<String, List<Node>> nodes = new LinkedHashMap<>();
        for (final Node node : container.getNodes()) {
            final String domain = node.getNodeConfig().getDomain() != null ? node.getNodeConfig().getDomain() : "";
            List<Node> list = nodes.get(domain);
            if (list == null) {
                list = new ArrayList<>();
                nodes.put(domain, list);
            }
            list.add(node);
        }

        for (Map.Entry<String, List<Node>> entry : nodes.entrySet()) {
            final String groupName = entry.getKey();
            if (reduceDisplay) {
                buf.append("<br/><br/>LBGroup " + groupName + ": ");
            } else {
                buf.append("<h1> LBGroup " + groupName + ": ");
            }
            if (allowCmd) {
                domainCommandString(buf, uri, MCMPAction.ENABLE, groupName);
                domainCommandString(buf, uri, MCMPAction.DISABLE, groupName);
            }

            for (final Node node : entry.getValue()) {
                final NodeConfig nodeConfig = node.getNodeConfig();
                if (reduceDisplay) {
                    buf.append("<br/><br/>Node " + nodeConfig.getJvmRoute());
                    printProxyStat(buf, node, reduceDisplay);
                } else {
                    buf.append("<h1> Node " + nodeConfig.getJvmRoute() + " (" + nodeConfig.getConnectionURI() + "): </h1>\n");
                }

                if (allowCmd) {
                    nodeCommandString(buf, uri, MCMPAction.ENABLE, nodeConfig.getJvmRoute());
                    nodeCommandString(buf, uri, MCMPAction.DISABLE, nodeConfig.getJvmRoute());
                }
                if (!reduceDisplay) {
                    buf.append("<br/>\n");
                    buf.append("Balancer: " + nodeConfig.getBalancer() + ",LBGroup: " + nodeConfig.getDomain());
                    String flushpackets = "off";
                    if (nodeConfig.isFlushPackets()) {
                        flushpackets = "Auto";
                    }
                    buf.append(",Flushpackets: " + flushpackets + ",Flushwait: " + nodeConfig.getFlushwait() + ",Ping: " + nodeConfig.getPing() + " ,Smax: " + nodeConfig.getPing() + ",Ttl: " + nodeConfig.getTtl());
                    printProxyStat(buf, node, reduceDisplay);
                } else {
                    buf.append("<br/>\n");
                }
                // the sessionid list is mostly for demos.
                if (displaySessionIds) {
                    // buf.append(",Num sessions: " + container.getJVMRouteSessionCount(nodeConfig.getJvmRoute()));
                }
                buf.append("\n");

                // Process the virtual-host of the node
                printInfoHost(buf, uri, reduceDisplay, allowCmd, node);
            }
        }

        // Display the all the actives sessions
        if (displaySessionIds) {
            printInfoSessions(buf, Collections.<SessionId>emptyList());
        }

        buf.append("</body></html>\n");
        resp.send(buf.toString());
    }
View Full Code Here

                Set<Integer> codes = responseCodes;
                if (codes == null ? exchange.getResponseCode() >= 400 : codes.contains(Integer.valueOf(exchange.getResponseCode()))) {
                    final String errorPage = "<html><head><title>Error</title></head><body>" + exchange.getResponseCode() + " - " + StatusCodes.getReason(exchange.getResponseCode()) + "</body></html>";
                    exchange.getResponseHeaders().put(Headers.CONTENT_LENGTH, "" + errorPage.length());
                    exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/html");
                    Sender sender = exchange.getResponseSender();
                    sender.send(errorPage);
                    return true;
                }
                return false;
            }
        });
View Full Code Here

            return;
        }
        final DirectBufferCache.CacheEntry existing = dataCache.get(cacheKey);
        //it is not cached yet, install a wrapper to grab the data
        if (existing == null || !existing.enabled() || !existing.reference()) {
            Sender newSender = sender;

            final DirectBufferCache.CacheEntry entry;
            if (existing == null) {
                entry = dataCache.add(cacheKey, length.intValue());
            } else {
View Full Code Here

                Set<Integer> codes = responseCodes;
                if (codes == null ? exchange.getResponseCode() >= 400 : codes.contains(Integer.valueOf(exchange.getResponseCode()))) {
                    final String errorPage = "<html><head><title>Error</title></head><body>" + exchange.getResponseCode() + " - " + StatusCodes.getReason(exchange.getResponseCode()) + "</body></html>";
                    exchange.getResponseHeaders().put(Headers.CONTENT_LENGTH, "" + errorPage.length());
                    exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/html");
                    Sender sender = exchange.getResponseSender();
                    sender.send(errorPage);
                    return true;
                }
                return false;
            }
        });
View Full Code Here

            underlyingResource.serve(sender, exchange, completionCallback);
            return;
        }
        //it is not cached yet, install a wrapper to grab the data
        if (existing == null || !existing.enabled() || !existing.reference()) {
            Sender newSender = sender;

            final DirectBufferCache.CacheEntry entry;
            if (existing == null) {
                entry = dataCache.add(cacheKey, length.intValue(), cachingResourceManager.getMaxAge());
            } else {
View Full Code Here

TOP

Related Classes of io.undertow.io.Sender

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.