Package org.apache.cassandra.net.http

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


    /*
     * 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

        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

    /*
     * 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

    /*
     * 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

    /*
     * 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

TOP

Related Classes of org.apache.cassandra.net.http.HTMLFormatter

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.