Skip to content
Snippets Groups Projects
Commit bb136bb4 authored by Tobias Pietzsch's avatar Tobias Pietzsch
Browse files

formatted, removed unused member variables, added javadoc

parent b713eced
No related branches found
Tags
No related merge requests found
......@@ -6,8 +6,6 @@ import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.util.log.Log;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -16,20 +14,17 @@ import java.io.PrintWriter;
import java.net.URISyntaxException;
/**
* Created by moon on 1/19/15.
* Provides a list of available datasets on this {@link BigDataServer}
*
* @author HongKee Moon <moon@mpi-cbg.de>
*/
public class JsonHandler extends ContextHandler
{
private static final org.eclipse.jetty.util.log.Logger LOG = Log.getLogger( JsonHandler.class );
private final Server server;
private final ContextHandlerCollection handlers;
public JsonHandler( final Server server, ContextHandlerCollection handlers ) throws IOException, URISyntaxException
public JsonHandler( final Server server, final ContextHandlerCollection handlers ) throws IOException, URISyntaxException
{
this.server = server;
this.handlers = handlers;
setContextPath( "/json" );
}
......@@ -50,9 +45,9 @@ public class JsonHandler extends ContextHandler
ow.close();
}
private void getJsonDatasetList( PrintWriter out ) throws IOException
private void getJsonDatasetList( final PrintWriter out ) throws IOException
{
JsonWriter writer = new JsonWriter( out );
final JsonWriter writer = new JsonWriter( out );
writer.setIndent( "\t" );
......@@ -60,16 +55,16 @@ public class JsonHandler extends ContextHandler
getContexts( writer );
writer.endObject(); // }
writer.endObject();
writer.flush();
writer.close();
}
private String getContexts( JsonWriter writer ) throws IOException
private String getContexts( final JsonWriter writer ) throws IOException
{
StringBuilder sb = new StringBuilder();
final StringBuilder sb = new StringBuilder();
for ( final Handler handler : server.getChildHandlersByClass( CellHandler.class ) )
{
CellHandler contextHandler = null;
......
......@@ -28,11 +28,11 @@ public class ManagerHandler extends ContextHandler
private final String baseURL;
private final Server server;
private final ContextHandlerCollection handlers;
private final StatisticsHandler statHandler;
private final ConnectorStatistics connectorStats;
private String contexts = null;
......@@ -41,7 +41,7 @@ public class ManagerHandler extends ContextHandler
private long sizeDataSets = 0;
public ManagerHandler( final String baseURL, final Server server, final ConnectorStatistics connectorStats, final StatisticsHandler statHandler, ContextHandlerCollection handlers ) throws IOException, URISyntaxException
public ManagerHandler( final String baseURL, final Server server, final ConnectorStatistics connectorStats, final StatisticsHandler statHandler, final ContextHandlerCollection handlers ) throws IOException, URISyntaxException
{
this.baseURL = baseURL;
this.server = server;
......@@ -78,12 +78,12 @@ public class ManagerHandler extends ContextHandler
}
public String getByteSizeString( long size )
public String getByteSizeString( final long size )
{
if ( size <= 0 )
return "0";
final String[] units = new String[] { "B", "kB", "MB", "GB", "TB" };
int digitGroups = ( int ) ( Math.log10( size ) / Math.log10( 1024 ) );
final int digitGroups = ( int ) ( Math.log10( size ) / Math.log10( 1024 ) );
return new DecimalFormat( "#,##0.#" ).format( size / Math.pow( 1024, digitGroups ) ) + " " + units[ digitGroups ];
}
......@@ -102,10 +102,10 @@ public class ManagerHandler extends ContextHandler
private String getHtml()
{
// manager.st should be under {WorkingFolder}/templates/
StringTemplateGroup templates =
final StringTemplateGroup templates =
new StringTemplateGroup( "manager", "templates" );
StringTemplate t = templates.getInstanceOf( "manager" );
final StringTemplate t = templates.getInstanceOf( "manager" );
t.setAttribute( "bytesSent", getByteSizeString( statHandler.getResponsesBytesTotal() ) );
t.setAttribute( "msgPerSec", connectorStats.getMessagesOutPerSecond() );
......@@ -131,7 +131,7 @@ public class ManagerHandler extends ContextHandler
noDataSets = 0;
sizeDataSets = 0;
StringBuilder sb = new StringBuilder();
final StringBuilder sb = new StringBuilder();
for ( final Handler handler : server.getChildHandlersByClass( CellHandler.class ) )
{
CellHandler contextHandler = null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment