Examples of HTMLFormatter


Examples of org.apache.cassandra.net.http.HTMLFormatter

      httpResponse.println(formatter.toString());
    }

    private String handleNodeDetails()
    {
        HTMLFormatter formatter = new HTMLFormatter();

        formatter.appendLine("Token: " + storageService_.getToken());
        RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
        formatter.appendLine("Up time (in seconds): " + (runtimeMxBean.getUptime()/1000));

        MemoryMXBean memoryMxBean = ManagementFactory.getMemoryMXBean();
        MemoryUsage memUsage = memoryMxBean.getHeapMemoryUsage();
        java.text.DecimalFormat df = new java.text.DecimalFormat("#0.00");
        String smemUsed = df.format((double)memUsage.getUsed()/(1024 * 1024));
        String smemMax = df.format((double)memUsage.getMax()/(1024 * 1024));
        formatter.appendLine("Heap memory usage (in MB): " + smemUsed + "/" + smemMax);

        formatter.appendLine("<br>");
        formatter.appendLine("<br>");

        /*
         * Display DB statatics if we have something to show.
        */
        displayDBStatistics(formatter, df);

        formatter.appendLine("<button onClick=\"window.location='" + StorageService.getHostUrl() + "?" + LOADME + "=T'\">Load Me</button>");
        formatter.appendLine("<button onClick=\"window.location='" + StorageService.getHostUrl() + "?" + COMPACTME + "=T'\">Compact Me</button>");
        formatter.appendLine("<button onClick=\"window.location='" + StorageService.getHostUrl() + "?" + KILLME + "=T'\">Kill Me</button>");

        formatter.appendLine("<br>");
        formatter.appendLine("<br><a href='" + StorageService.getHostUrl() + "'>Back to live nodes list" + "</a>");

        return formatter.toString();
    }
View Full Code Here

Examples of org.apache.cassandra.net.http.HTMLFormatter

    /*
     * Serve the summary of the current node.
     */
    private String serveSummary()
    {
        HTMLFormatter formatter = new HTMLFormatter();

        Set<EndPoint> liveNodeList = Gossiper.instance().getAllMembers();
        // we want this set of live nodes sorted based on the hostname
        EndPoint[] liveNodes = liveNodeList.toArray(new EndPoint[0]);
        Arrays.sort(liveNodes);

        String[] sHeaders = {"Node No.", "Host:Port", "Status", "Leader", "Load Info", "Token", "Generation No."};
        formatter.startTable();
        formatter.addHeaders(sHeaders);
        int iNodeNumber = 0;
        for( EndPoint curNode : liveNodes )
        {
            formatter.startRow();
            ++iNodeNumber;

            // Node No.
            formatter.addCol("" + iNodeNumber);
            // Host:Port
            formatter.addCol("<a href='http://" + curNode.getHost() + ":" + DatabaseDescriptor.getHttpPort() + "/home?" + DETAILS + "=T'>" + curNode.getHost() + ":" + curNode.getPort() + "</a>");
            //Status
            String status = ( FailureDetector.instance().isAlive(curNode) ) ? "Up" : "Down";
            formatter.addCol(status);
            //Leader
            boolean isLeader = StorageService.instance().isLeader(curNode);
            formatter.addCol(Boolean.toString(isLeader));
            //Load Info
            String loadInfo = getLoadInfo(curNode);
            formatter.addCol(loadInfo);
            // Token
            if(curNode == null)
                formatter.addCol("NULL!");
            else
                formatter.addCol(storageService_.getToken(curNode));
            // Generation Number
            formatter.addCol(Integer.toString(Gossiper.instance().getCurrentGenerationNumber(curNode)));

            formatter.endRow();
        }

        formatter.endTable();

        return formatter.toString();
    }
View Full Code Here

Examples of org.apache.cassandra.net.http.HTMLFormatter

        return formatter.toString();
    }

    private String serveRingView()
    {
        HTMLFormatter formatter = new HTMLFormatter();
        String[] sHeaders = {"Range No.", "Range", "N1", "N2", "N3"};
        formatter.startTable();
        formatter.addHeaders(sHeaders);

        Map<Range, List<EndPoint>> oldRangeToEndPointMap = StorageService.instance().getRangeToEndPointMap();
        Set<Range> rangeSet = oldRangeToEndPointMap.keySet();

        int iNodeNumber = 0;
        for ( Range range : rangeSet )
        {
          formatter.startRow();
            ++iNodeNumber;

            // Range No.
            formatter.addCol("" + iNodeNumber);

            // Range
            formatter.addCol("(" + range.left() + ",<br>" + range.right() + "]");

            List<EndPoint> replicas = oldRangeToEndPointMap.get(range);
            for ( EndPoint replica : replicas )
            {
              // N1 N2 N3
              formatter.addCol(replica.toString());
            }

            formatter.endRow();
        }

        formatter.endTable();

        return formatter.toString();
    }
View Full Code Here

Examples of org.apache.cassandra.net.http.HTMLFormatter

    /*
     * Returns the HTML code for a form to query data from the db cluster.
     */
    private String serveQueryForm(String queryResult)
    {
        HTMLFormatter formatter = new HTMLFormatter();
        formatter.appendLine("<BR><fieldset><legend>Query the cluster</legend>");
        formatter.appendLine("<FORM action=\"" + StorageService.getHostUrl() + "/home?" + QUERY + "=T\" method=\"post\">");

        // get the list of column families
        Table table = Table.open("Mailbox");
        Set<String> columnFamilyComboBoxSet = table.getColumnFamilies();

        formatter.append("select from ");
        formatter.addCombobox(columnFamilyComboBoxSet, "columnfamily", 0);
        formatter.append(" : <INPUT name=columnName>");
        formatter.appendLine(" where key = <INPUT name=key>");
        formatter.appendLine("<BR>");
        formatter.appendLine("<INPUT type=\"submit\" value=\"Send\"> <INPUT type=\"reset\">");

        formatter.appendLine("</FORM>");
        formatter.addDivElement(QUERYRESULTSDIV, queryResult);
        formatter.appendLine("</fieldset><BR>");

        return formatter.toString();
    }
View Full Code Here

Examples of org.apache.cassandra.net.http.HTMLFormatter

    /*
     * Returns the HTML code for a form to to run custom code on the cluster.
     */
    private String serveGroovyForm(String scriptResult)
    {
        HTMLFormatter formatter = new HTMLFormatter();
        formatter.appendLine("<BR><fieldset><legend>Run custom code on the cluster</legend>");
        formatter.appendLine("<FORM action=\"" + StorageService.getHostUrl() + "/home?" + SCRIPT + "=T\" method=\"post\">");
        formatter.append(" Callout name : <INPUT name=calloutName>");
        formatter.appendLine("<BR>");
        formatter.append("Groovy code to run on the server:<br>");
        formatter.append("<textarea name=scriptTextArea rows=\"10\" cols=\"100\"></textarea>");
        formatter.appendLine("<BR>");
        formatter.appendLine("<INPUT name=deploy type=\"submit\" value=\"Deploy\"> <INPUT name=execute type=\"submit\" value=\"Execute\"> <INPUT name=reset type=\"reset\">");

        formatter.appendLine("</FORM>");
        formatter.addDivElement(SCRIPTRESULTSDIV, scriptResult);
        formatter.appendLine("</fieldset><BR>");

        return formatter.toString();
    }
View Full Code Here

Examples of org.apache.cassandra.net.http.HTMLFormatter

    /*
     * Returns the HTML code for a form to insert data into the db cluster.
     */
    private String serveInsertForm(String insertResult)
    {
        HTMLFormatter formatter = new HTMLFormatter();
        formatter.appendLine("<BR><fieldset>\n<legend>Insert data into the cluster</legend>\n");
        formatter.appendLine("<FORM action=\"" + StorageService.getHostUrl() + "/home?" + INSERT + "=T\" method=\"post\">");

        // get the list of column families
        Table table = Table.open("Mailbox");
        Set<String> columnFamilyComboBoxSet = table.getColumnFamilies();

        formatter.append("insert into ");
        formatter.addCombobox(columnFamilyComboBoxSet, "columnfamily", 0);
        formatter.append(" : <INPUT name=columnName>");
        formatter.append(" data = <INPUT name=data>");
        formatter.appendLine(" where key = <INPUT name=key>\n");
        formatter.appendLine("<BR>\n");
        formatter.appendLine("<INPUT type=\"submit\" value=\"Send\"> <INPUT type=\"reset\">\n");

        formatter.appendLine("</FORM>\n");
        formatter.addDivElement(INSERTRESULTSDIV, insertResult);
        formatter.appendLine("</fieldset>\n<BR>\n");

        return formatter.toString();
    }
View Full Code Here

Examples of org.apache.cassandra.net.http.HTMLFormatter

    }

    private void doGet(org.apache.cassandra.net.http.HttpRequest httpRequest, HttpWriteResponse httpResponse)
    {
        boolean fServeSummary = true;
        HTMLFormatter formatter = new HTMLFormatter();
        String query = httpRequest.getQuery();
        /*
         * we do not care about the path for most requests except those
         * from the load balancer
         */
        String path = httpRequest.getPath();
        /* for the health checks, just return the string only */
        if(path.contains(LB_HEALTH_CHECK))
        {
          httpResponse.println(handleLBHealthCheck());
            return;
        }

        formatter.startBody(true, getJSFunctions(), true, true);
        formatter.appendLine("<h1><font color=\"white\"> Cluster map </font></h1>");

        StringBuilder sbResult = new StringBuilder();
        do
        {
            if(query.contains(DETAILS))
            {
                fServeSummary = false;
                sbResult.append(handleNodeDetails());
                break;
            }
            else if(query.contains(LOADME))
            {
                sbResult.append(handleLoadMe());
                break;
            }
            else if(query.contains(KILLME))
            {
                sbResult.append(handleKillMe());
                break;
            }
            else if(query.contains(COMPACTME))
            {
                sbResult.append(handleCompactMe());
                break;
            }
        }
        while(false);

        //formatter.appendLine("<br>-------END DEBUG INFO-------<br><br>");

        if(fServeSummary)
        {
            formatter.appendLine(handlePageDisplay(null, null, null));
        }

        formatter.appendLine("<br>");

        if(sbResult.toString() != null)
        {
            formatter.appendLine(sbResult.toString());
        }

        formatter.endBody();
        httpResponse.println(formatter.toString());
    }
View Full Code Here

Examples of org.apache.cassandra.net.http.HTMLFormatter

    */
    private void doPost(org.apache.cassandra.net.http.HttpRequest httpRequest, HttpWriteResponse httpResponse)
    {
        String query = httpRequest.getQuery();

        HTMLFormatter formatter = new HTMLFormatter();
        formatter.startBody(true, getJSFunctions(), true, true);
        formatter.appendLine("<h1><font color=\"white\"> Cluster map </font></h1>");

        // write a shell for adding some javascript to do in-place updates
        StringBuilder sbResult = new StringBuilder();
        do
        {
            if(query.contains(QUERY))
            {
                sbResult.append(handleQuery(httpRequest));
                break;
            }
            else if(query.contains(INSERT))
            {
                sbResult.append(handleInsert(httpRequest));
                break;
            }
            else if(query.contains(SCRIPT))
            {
                sbResult.append(handleScript(httpRequest));
                break;
            }
        }
        while(false);

        if(sbResult.toString() != null)
        {
            formatter.appendLine(sbResult.toString());
        }

        formatter.endBody();

      httpResponse.println(formatter.toString());
    }
View Full Code Here

Examples of org.apache.cassandra.net.http.HTMLFormatter

      httpResponse.println(formatter.toString());
    }

    private String handleNodeDetails()
    {
        HTMLFormatter formatter = new HTMLFormatter();

        formatter.appendLine(storageService_.getToken());
        RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
        formatter.appendLine("Up time (in seconds): " + (runtimeMxBean.getUptime()/1000));

        MemoryMXBean memoryMxBean = ManagementFactory.getMemoryMXBean();
        MemoryUsage memUsage = memoryMxBean.getHeapMemoryUsage();
        java.text.DecimalFormat df = new java.text.DecimalFormat("#0.00");
        String smemUsed = df.format((double)memUsage.getUsed()/(1024 * 1024));
        String smemMax = df.format((double)memUsage.getMax()/(1024 * 1024));
        formatter.appendLine("Heap memory usage (in MB): " + smemUsed + "/" + smemMax);

        formatter.appendLine("<br>");
        formatter.appendLine("<br>");

        /*
         * Display DB statatics if we have something to show.
        */
        displayDBStatistics(formatter, df);

        formatter.appendLine("<button onClick=\"window.location='" + StorageService.getHostUrl() + "?" + LOADME + "=T'\">Load Me</button>");
        formatter.appendLine("<button onClick=\"window.location='" + StorageService.getHostUrl() + "?" + COMPACTME + "=T'\">Compact Me</button>");
        formatter.appendLine("<button onClick=\"window.location='" + StorageService.getHostUrl() + "?" + KILLME + "=T'\">Kill Me</button>");

        formatter.appendLine("<br>");
        formatter.appendLine("<br><a href='" + StorageService.getHostUrl() + "'>Back to live nodes list" + "</a>");

        return formatter.toString();
    }
View Full Code Here

Examples of org.apache.cassandra.net.http.HTMLFormatter

    /*
     * Serve the summary of the current node.
     */
    private String serveSummary()
    {
        HTMLFormatter formatter = new HTMLFormatter();

        Set<EndPoint> liveNodeList = Gossiper.instance().getAllMembers();
        // we want this set of live nodes sorted based on the hostname
        EndPoint[] liveNodes = liveNodeList.toArray(new EndPoint[0]);
        Arrays.sort(liveNodes);

        String[] sHeaders = {"Node No.", "Host:Port", "Status", "Load Info", "Token", "Generation No."};
        formatter.startTable();
        formatter.addHeaders(sHeaders);
        int iNodeNumber = 0;
        for( EndPoint curNode : liveNodes )
        {
            formatter.startRow();
            ++iNodeNumber;

            // Node No.
            formatter.addCol("" + iNodeNumber);
            // Host:Port
            formatter.addCol("<a href='http://" + curNode.getHost() + ":" + DatabaseDescriptor.getHttpPort() + "/home?" + DETAILS + "=T'>" + curNode.getHost() + ":" + curNode.getPort() + "</a>");
            //Status
            String status = ( FailureDetector.instance().isAlive(curNode) ) ? "Up" : "Down";
            formatter.addCol(status);
            //Load Info
            String loadInfo = getLoadInfo(curNode);
            formatter.addCol(loadInfo);
            // Token
            if(curNode == null)
                formatter.addCol("NULL!");
            else
                formatter.addCol(storageService_.getToken(curNode));
            // Generation Number
            formatter.addCol(Integer.toString(Gossiper.instance().getCurrentGenerationNumber(curNode)));

            formatter.endRow();
        }

        formatter.endTable();

        return formatter.toString();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.