Skip to content
Snippets Groups Projects
Commit cfaf76be authored by HongKee Moon's avatar HongKee Moon
Browse files

Add "Number of datasets" and "Total size of datasets" in manager context

parent fe54e0ee
Branches
Tags
No related merge requests found
...@@ -15,6 +15,7 @@ import org.eclipse.jetty.util.log.Log; ...@@ -15,6 +15,7 @@ import org.eclipse.jetty.util.log.Log;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.net.URISyntaxException; import java.net.URISyntaxException;
...@@ -34,6 +35,12 @@ public class ManagerHandler extends ContextHandler ...@@ -34,6 +35,12 @@ public class ManagerHandler extends ContextHandler
private final ConnectorStatistics connectorStats; private final ConnectorStatistics connectorStats;
private String contexts = null;
private int noDataSets = 0;
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, ContextHandlerCollection handlers ) throws IOException, URISyntaxException
{ {
this.baseURL = baseURL; this.baseURL = baseURL;
...@@ -105,28 +112,41 @@ public class ManagerHandler extends ContextHandler ...@@ -105,28 +112,41 @@ public class ManagerHandler extends ContextHandler
t.setAttribute( "openConnections", connectorStats.getConnectionsOpen() ); t.setAttribute( "openConnections", connectorStats.getConnectionsOpen() );
t.setAttribute( "maxOpenConnections", connectorStats.getConnectionsOpenMax() ); t.setAttribute( "maxOpenConnections", connectorStats.getConnectionsOpenMax() );
t.setAttribute( "contexts", getContexts() ); getContexts();
t.setAttribute( "contexts", contexts );
t.setAttribute( "noDataSets", noDataSets );
t.setAttribute( "sizeDataSets", getByteSizeString( sizeDataSets ) );
t.setAttribute( "statHtml", statHandler.toStatsHTML() ); t.setAttribute( "statHtml", statHandler.toStatsHTML() );
return t.toString(); return t.toString();
} }
private String getContexts() private void getContexts()
{ {
StringBuilder sb = new StringBuilder(); if ( contexts == null )
for ( final Handler handler : server.getChildHandlersByClass( CellHandler.class ) )
{ {
CellHandler contextHandler = null; noDataSets = 0;
if ( handler instanceof CellHandler ) sizeDataSets = 0;
StringBuilder sb = new StringBuilder();
for ( final Handler handler : server.getChildHandlersByClass( CellHandler.class ) )
{ {
sb.append( "<tr>\n<th>" ); CellHandler contextHandler = null;
contextHandler = ( CellHandler ) handler; if ( handler instanceof CellHandler )
sb.append( contextHandler.getContextPath() + "</th>\n<td>" ); {
sb.append( contextHandler.getXmlFile() + "</td>\n</tr>\n" ); sb.append( "<tr>\n<th>" );
contextHandler = ( CellHandler ) handler;
sb.append( contextHandler.getContextPath() + "</th>\n<td>" );
sb.append( contextHandler.getXmlFile() + "</td>\n</tr>\n" );
noDataSets++;
sizeDataSets += new File( contextHandler.getXmlFile().replace( ".xml", ".h5" ) ).length();
}
} }
contexts = sb.toString();
} }
return sb.toString();
} }
private void deploy( final String datasetName, final String fileLocation, final Request baseRequest, final HttpServletResponse response ) throws IOException private void deploy( final String datasetName, final String fileLocation, final Request baseRequest, final HttpServletResponse response ) throws IOException
......
...@@ -43,6 +43,14 @@ This page is refreshed in every 5 secs.<br/> ...@@ -43,6 +43,14 @@ This page is refreshed in every 5 secs.<br/>
<th>Max open connections:</th> <th>Max open connections:</th>
<td>$maxOpenConnections$</td> <td>$maxOpenConnections$</td>
</tr> </tr>
<tr>
<th>Number of datasets:</th>
<td>$noDataSets$</td>
</tr>
<tr>
<th>Total size of datasets:</th>
<td>$sizeDataSets$</td>
</tr>
</table> </table>
<hr> <hr>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment