com.bigdata.counters.render
Class XHTMLRenderer

java.lang.Object
  extended by com.bigdata.counters.render.XHTMLRenderer
All Implemented Interfaces:
IRenderer

public class XHTMLRenderer
extends Object
implements IRenderer

(X)HTML rendering of a CounterSet.

Version:
$Id: XHTMLRenderer.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson
TODO:
UI widgets for regex filters, depth, correlated., make documentation available on the counters via click through on their name.

Nested Class Summary
static class XHTMLRenderer.HTMLPivotTableRenderer
           
 class XHTMLRenderer.HTMLValueFormatter
           
 
Field Summary
 ICounterSelector counterSelector
          Selects the counters to be rendered.
protected static org.apache.log4j.Logger log
           
 URLQueryModel model
          Describes the state of the controller.
static String ps
           
 
Constructor Summary
XHTMLRenderer(URLQueryModel model, ICounterSelector counterSelector)
           
 
Method Summary
protected  boolean acceptEvent(Event e)
          Applies the URLQueryModel.eventFilters to the event.
static String attrib(String s)
          Encoding a string for including in an (X)HTML attribute value.
static String cdata(String s)
          Encode a string for including in a CDATA section.
protected  String getEventKey(Event e)
          The key for an event group is formed by combining the String value of the fields of the event identified by the orderEventBy[] in order and using a ":" when combining two or more event fields together.
protected  String getEventTable(Event e)
           
 void render(Writer w)
          Render the data.
protected  String value(ICounter counter, Object val)
          Deprecated. Move into formatter objects.
protected  void writeBody(Writer w)
           
protected  void writeCounter(Writer w, ICounter counter)
          Writes details on a single counter using a HistoryTable view.
protected  void writeCounterSet(Writer w, CounterSet counterSet, int depth)
          Writes all counters in the hierarchy starting with the specified CounterSet in a single table (this is the navigational view of the counter set hierarchy).
protected  void writeDocType(Writer w)
           
protected  void writeEventFlyover(Writer w, Event e)
          Pretty up an event by rendering onto the Writer as an (X)HTML table.
protected  void writeEvents(Writer w, IEventReportingService eventReportingService)
          Plots events using flot.
protected  void writeFlot(Writer w, IEventReportingService eventReportingService)
          Write the html to render the Flot-based time-series chart, plotting the supplied events.
protected  void writeFullPath(Writer w, String path)
          Deprecated. by refactor inside of a rendering object.
protected  void writeHead(Writer w)
           
protected  void writeHistoryTable(Writer w, ICounter[] a, PeriodEnum basePeriod, TimestampFormatEnum timestampFormat)
          Writes out a table containing the histories for the selected counters.
protected  void writeHtml(Writer w)
          The start html tag.
protected  void writePath(Writer w, String path, int rootDepth)
          Deprecated. by refactor inside of a rendering object.
protected  void writePivotTable(Writer w, ICounter[] a)
          Writes data in a format suitable for use in a pivot table.
protected  void writePivotTable(Writer w, ICounter[] a, PeriodEnum basePeriod, TimestampFormatEnum timestampFormat)
          Writes out a pivot table view.
protected  void writeResource(Writer w, String resource)
          Write a text file into the html.
protected  void writeScripts(Writer w)
           
protected  void writeTitle(Writer w)
           
protected  void writeXmlDecl(Writer w)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.log4j.Logger log

ps

public static final String ps
See Also:
Constant Field Values

model

public final URLQueryModel model
Describes the state of the controller.


counterSelector

public final ICounterSelector counterSelector
Selects the counters to be rendered.

Constructor Detail

XHTMLRenderer

public XHTMLRenderer(URLQueryModel model,
                     ICounterSelector counterSelector)
Parameters:
model - Describes the state of the controller (e.g., as parsed from the URL query parameters).
counterSelector - Selects the counters to be rendered.
Method Detail

render

public void render(Writer w)
            throws IOException
Description copied from interface: IRenderer
Render the data.

Specified by:
render in interface IRenderer
Parameters:
w -
Throws:
IOException

writeXmlDecl

protected void writeXmlDecl(Writer w)
                     throws IOException
Throws:
IOException

writeDocType

protected void writeDocType(Writer w)
                     throws IOException
Parameters:
w -
Throws:
IOException

writeHtml

protected void writeHtml(Writer w)
                  throws IOException
The start html tag.

Throws:
IOException

writeHead

protected void writeHead(Writer w)
                  throws IOException
Throws:
IOException

writeTitle

protected void writeTitle(Writer w)
                   throws IOException
Throws:
IOException

writeScripts

protected void writeScripts(Writer w)
                     throws IOException
Throws:
IOException

writeBody

protected void writeBody(Writer w)
                  throws IOException
Throws:
IOException

writeFullPath

protected void writeFullPath(Writer w,
                             String path)
                      throws IOException
Deprecated. by refactor inside of a rendering object.

A clickable trail of the path from the root.

Throws:
IOException

writePath

protected void writePath(Writer w,
                         String path,
                         int rootDepth)
                  throws IOException
Deprecated. by refactor inside of a rendering object.

A clickable trail of the path.

Parameters:
rootDepth - The path components will be shown beginning at this depth - ZERO (0) is the root.
Throws:
IOException

writeCounterSet

protected void writeCounterSet(Writer w,
                               CounterSet counterSet,
                               int depth)
                        throws IOException
Writes all counters in the hierarchy starting with the specified CounterSet in a single table (this is the navigational view of the counter set hierarchy).

Throws:
IOException

writeCounter

protected void writeCounter(Writer w,
                            ICounter counter)
                     throws IOException
Writes details on a single counter using a HistoryTable view.

Parameters:
counter - The counter.
Throws:
IOException

writeHistoryTable

protected void writeHistoryTable(Writer w,
                                 ICounter[] a,
                                 PeriodEnum basePeriod,
                                 TimestampFormatEnum timestampFormat)
                          throws IOException
Writes out a table containing the histories for the selected counters.

Parameters:
a - The selected counters.
basePeriod - Identifies the history to be written for each of the selected counters by its based reporting period.
timestampFormat - The format in which to report the timestamp associated with the row.
Throws:
IllegalArgumentException - if w is null.
IllegalArgumentException - if a is null.
IllegalArgumentException - if any element of a null.
IllegalArgumentException - if any element of a does not use a HistoryInstrument.
IOException
TODO:
review use of basePeriod - this is URLQueryModel.period, right?

writePivotTable

protected void writePivotTable(Writer w,
                               ICounter[] a,
                               PeriodEnum basePeriod,
                               TimestampFormatEnum timestampFormat)
                        throws IOException
Writes out a pivot table view.

Parameters:
w - Where to write the data.
a - The selected counters.
basePeriod -
timestampFormat -
Throws:
IOException
TODO:
review use of basePeriod. is this URLQueryModel.period?

writePivotTable

protected void writePivotTable(Writer w,
                               ICounter[] a)
                        throws IOException
Writes data in a format suitable for use in a pivot table.

The pivot table data are selected in the same manner as the correlated view and are used to generate a HistoryTable. There will be one data row per row in the history table. There will be one category column for each capturing group in the URLQueryModel.pattern, one column for the timestamp associated with the row, and one for the value of each performance counter selected by the URLQueryModel.pattern.

Since the pivot table and the correlated view are both based on the HistoryTable you can switch between these views simply by changing the URLQueryModel.reportType using the URL query parameter.

Throws:
IOException
See Also:
ReportEnum.pivot

writeFlot

protected void writeFlot(Writer w,
                         IEventReportingService eventReportingService)
                  throws IOException
Write the html to render the Flot-based time-series chart, plotting the supplied events.

Throws:
IOException

acceptEvent

protected boolean acceptEvent(Event e)
Applies the URLQueryModel.eventFilters to the event.

Parameters:
e - The event.
Returns:
true if the filters accept the event.

getEventKey

protected String getEventKey(Event e)
The key for an event group is formed by combining the String value of the fields of the event identified by the orderEventBy[] in order and using a ":" when combining two or more event fields together.


getEventTable

protected String getEventTable(Event e)

writeEvents

protected void writeEvents(Writer w,
                           IEventReportingService eventReportingService)
                    throws IOException
Plots events using flot.

Throws:
IOException
See Also:
ReportEnum.events, URLQueryModel.eventFilters, FIXME Modify to allow visualization of a performance counter timeseries data. FIXME Modify to allow linked viz of performance counter timeseries w/ an event timeseries and an overview that controls what is seen in both.
TODO:
allow a data label for the start point to be specified as a query parameter. E.g., the indexName+partitionId or the hostname., clicking on the overview should reset to the total view., allow aggregation of elapsed time for events and have click through to the individual events broken out using eventOrderBy=uuid., a form to set the various query parameters., a dashboard view of the federation as a jsp page incorporating output from a variety of sources. basically a replacement for the use of a worksheet to look at views of the data which we know to be interesting. since I don't want to force the bundling of a servlet engine with each service, this could be a standoff module.

writeEventFlyover

protected void writeEventFlyover(Writer w,
                                 Event e)
                          throws IOException
Pretty up an event by rendering onto the Writer as an (X)HTML table.

Parameters:
w - The writer.
e - The event.
Throws:
IOException

writeResource

protected void writeResource(Writer w,
                             String resource)
                      throws IOException
Write a text file into the html. The supplied resource will be relative to this class.

Throws:
IOException

cdata

public static String cdata(String s)
Encode a string for including in a CDATA section.

Parameters:
s - The string.
Returns:
The encoded string.

attrib

public static String attrib(String s)
Encoding a string for including in an (X)HTML attribute value.

Parameters:
s - The string.
Returns:

value

protected String value(ICounter counter,
                       Object val)
Deprecated. Move into formatter objects.

Formats a counter value as a String AND performs any escaping necessary for inclusion in a CDATA section (we do both operations together so that we can format IServiceCounters.LOCAL_HTTPD as a link anchor.

Parameters:
counter - The counter.
value - The counter value (MAY be null).
Returns:


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.