throw new HTTPRedirect( "instrument-manager.html" );
}
}
String chart = getParameter( parameters, "chart", null );
InstrumentSampleSnapshot snapshot = desc.getSnapshot();
String type;
switch ( desc.getType() )
{
case DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_COUNTER:
type = "Counter";
break;
case DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MAXIMUM:
type = "Max Value";
break;
case DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MINIMUM:
type = "Min Value";
break;
case DefaultInstrumentManager.INSTRUMENT_SAMPLE_TYPE_MEAN:
type = "Mean Value";
break;
default:
type = "Unknown";
break;
}
out.println( "<html>" );
out.println( "<head><title>" + desc.getDescription() + "</title></head>" );
out.println( "<body>" );
breadCrumbs( out, desc, false );
out.println( "<h2>Instrument Sample</h2>" );
startTable( out );
tableRow( out, 0, "Name", desc.getName() );
tableRow( out, 0, "Description", desc.getDescription() );
tableRow( out, 0, "Type", type );
tableRow( out, 0, "Interval", desc.getInterval() + "ms." );
tableRow( out, 0, "Size", Integer.toString( desc.getSize() ) );
if ( desc.getLeaseExpirationTime() > 0 )
{
String renewUrl = "sample-lease.html?name=" + urlEncode( desc.getName() )
+ ( chart == null ? "" : "&chart=true" ) + "&lease=";
String value = new Date( desc.getLeaseExpirationTime() ).toString();
if ( !getConnector().isReadOnly() )
{
value = value + " (Renew <a href='" + renewUrl + "600000'>10min</a>, "
+ "<a href='" + renewUrl + "3600000'>1hr</a>, "
+ "<a href='" + renewUrl + "86400000'>1day</a>)";
}
// Make the text red if it is about to expire.
if ( desc.getLeaseExpirationTime() - System.currentTimeMillis() < 300000 )
{
value = "<font color='ff0000'>" + value + "</font>";
}
tableRow( out, 0, "Expiration", value );
}
else
{
tableRow( out, 0, "Expiration", "Permanent" );
}
endTable( out );
if ( chart == null )
{
out.println( "<h2>Data Samples (<a href='sample.html?name="
+ urlEncode( desc.getName() ) + "&chart=true'>Chart</a>)</h2>" );
startTable( out );
startTableHeaderRow( out );
tableHeaderCell( out, "Period" );
tableHeaderCell( out, "Value" );
endTableHeaderRow( out );
long time = snapshot.getTime();
int[] samples = snapshot.getSamples();
for ( int i = 0; i < samples.length; i++ )
{
startTableRow( out, i );
tableCell( out, new Date( time ).toString() );
tableCellRight( out, Integer.toString( samples[samples.length - i - 1] ) );
endTableRow( out );
time -= snapshot.getInterval();
}
endTable( out );
}
else
{