Search in sources :

Example 1 with HTMLWriter

use of diskCacheV111.util.HTMLWriter in project dcache by dCache.

the class HttpBillingEngine method printMainStatisticsPage.

private void printMainStatisticsPage(OutputStream out) throws HttpException {
    HTMLWriter html = new HTMLWriter(out, _context);
    try {
        Object[][] x = _billing.sendAndWait("get billing info", Object[][].class);
        html.addHeader("/styles/billing.css", "dCache Billing");
        printTotalStatistics(html, x);
        try {
            Map<String, long[]> map = _billing.sendAndWait("get pool statistics", Map.class);
            printPoolStatistics(html, map, null);
        } catch (InterruptedException | TimeoutCacheException e) {
            throw e;
        } catch (CacheException e) {
            html.print("<p class=\"error\">This 'billingCell' doesn't support: 'get pool statistics':");
            html.print("<blockquote><pre>" + e + "</pre></blockquote>");
        }
    } catch (NoRouteToCellException e) {
        throw new HttpException(500, "No connection to billing");
    } catch (TimeoutCacheException e) {
        throw new HttpException(500, "Request Timed Out");
    } catch (InterruptedException | CacheException e) {
        throw new HttpException(500, "Problem : " + e.getMessage());
    } finally {
        html.addFooter(getClass().getName());
    }
}
Also used : HTMLWriter(diskCacheV111.util.HTMLWriter) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) CacheException(diskCacheV111.util.CacheException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) HttpException(dmg.util.HttpException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException)

Example 2 with HTMLWriter

use of diskCacheV111.util.HTMLWriter in project dcache by dCache.

the class HttpPoolMgrEngineV3 method printRestoreInfo.

private void printRestoreInfo(OutputStream out, String sorting, String grep) {
    HTMLWriter html = new HTMLWriter(out, _context);
    html.addHeader("/styles/restoreHandler.css", "dCache Dataset Restore Monitor");
    RestoreHandlerInfo[] list = _lazyRestoreList.stream().map(o -> o[0]).toArray(RestoreHandlerInfo[]::new);
    Arrays.sort(list, new OurComparator(sorting));
    html.beginTable("sortable", "pnfs", "PnfsId", "subnet", "Subnet", "candidate", "PoolCandidate", "started", "Started", "clients", "Clients", "retries", "Retries", "status", "Status");
    for (RestoreHandlerInfo info : list) {
        if ((grep == null) || grepOk(grep, info)) {
            showRestoreInfo(html, info);
        }
    }
    html.endTable();
    html.addFooter(getClass().getName());
}
Also used : CellInfoProvider(dmg.cells.nucleus.CellInfoProvider) Arrays(java.util.Arrays) PoolManagerGetRestoreHandlerInfo(org.dcache.poolmanager.PoolManagerGetRestoreHandlerInfo) RestoreHandlerInfo(diskCacheV111.vehicles.RestoreHandlerInfo) Date(java.util.Date) HTMLWriter(diskCacheV111.util.HTMLWriter) LoggerFactory(org.slf4j.LoggerFactory) SimpleDateFormat(java.text.SimpleDateFormat) HtmlEscapers(com.google.common.html.HtmlEscapers) CellEndpoint(dmg.cells.nucleus.CellEndpoint) ArrayList(java.util.ArrayList) AgingHash(dmg.util.AgingHash) HttpException(dmg.util.HttpException) HttpResponseEngine(dmg.util.HttpResponseEngine) CacheException(diskCacheV111.util.CacheException) StorageInfo(diskCacheV111.vehicles.StorageInfo) CellStub(org.dcache.cells.CellStub) Map(java.util.Map) EnumSet(java.util.EnumSet) OutputStream(java.io.OutputStream) PrintWriter(java.io.PrintWriter) FileAttributes(org.dcache.vehicles.FileAttributes) PnfsId(diskCacheV111.util.PnfsId) CellMessageReceiver(dmg.cells.nucleus.CellMessageReceiver) Logger(org.slf4j.Logger) Escaper(com.google.common.escape.Escaper) PoolManagerHandlerSubscriber(org.dcache.poolmanager.PoolManagerHandlerSubscriber) CellInfo(dmg.cells.nucleus.CellInfo) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) HttpRequest(dmg.util.HttpRequest) CellCommandListener(dmg.cells.nucleus.CellCommandListener) CellLifeCycleAware(dmg.cells.nucleus.CellLifeCycleAware) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) TreeMap(java.util.TreeMap) Args(org.dcache.util.Args) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) CellMessageSender(dmg.cells.nucleus.CellMessageSender) FileAttribute(org.dcache.namespace.FileAttribute) CellPath(dmg.cells.nucleus.CellPath) Comparator(java.util.Comparator) DomainContextAware(dmg.cells.nucleus.DomainContextAware) Collections(java.util.Collections) Partition(org.dcache.poolmanager.Partition) SECONDS(java.util.concurrent.TimeUnit.SECONDS) PnfsMapPathMessage(diskCacheV111.vehicles.PnfsMapPathMessage) HTMLWriter(diskCacheV111.util.HTMLWriter) PoolManagerGetRestoreHandlerInfo(org.dcache.poolmanager.PoolManagerGetRestoreHandlerInfo) RestoreHandlerInfo(diskCacheV111.vehicles.RestoreHandlerInfo)

Example 3 with HTMLWriter

use of diskCacheV111.util.HTMLWriter in project dcache by dCache.

the class HttpBillingEngine method printPerPoolStatisticsPage.

private void printPerPoolStatisticsPage(OutputStream out, String pool) {
    HTMLWriter html = new HTMLWriter(out, _context);
    try {
        html.addHeader("/styles/billing.css", "dCache Billing");
        Map<String, long[]> map = _billing.sendAndWait("get pool statistics " + pool, Map.class);
        printPoolStatistics(html, map, pool);
    } catch (NoRouteToCellException e) {
        html.print("<blockquote><pre>No connection to billing</pre></blockquote>");
    } catch (TimeoutCacheException e) {
        html.print("<blockquote><pre>Request Timed Out</pre></blockquote>");
    } catch (InterruptedException | CacheException e) {
        html.print("<blockquote><pre>" + e + "</pre></blockquote>");
    } finally {
        html.addFooter(getClass().getName());
    }
}
Also used : HTMLWriter(diskCacheV111.util.HTMLWriter) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) CacheException(diskCacheV111.util.CacheException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException)

Example 4 with HTMLWriter

use of diskCacheV111.util.HTMLWriter in project dcache by dCache.

the class HttpPoolMgrEngineV3 method printLazyRestoreInfo.

private void printLazyRestoreInfo(OutputStream out, String sorting, String grep) {
    HTMLWriter html = new HTMLWriter(out, _context);
    html.addHeader("/styles/restoreHandler.css", "dCache Dataset Restore Monitor (Lazy)");
    html.beginTable("sortable", "pnfs", "PnfsId", "subnet", "Subnet", "candidate", "PoolCandidate", "started", "Started", "clients", "Clients", "retries", "Retries", "status", "Status");
    List<Object[]> copy = new ArrayList<>(_lazyRestoreList);
    Collections.sort(copy, new OurComparator(sorting));
    for (Object[] a : copy) {
        if ((grep == null) || grepOk(grep, a)) {
            showRestoreInfo(html, (RestoreHandlerInfo) a[0], (String) a[1], (StorageInfo) a[2]);
        }
    }
    html.endTable();
    html.addFooter(getClass().getName());
}
Also used : HTMLWriter(diskCacheV111.util.HTMLWriter) ArrayList(java.util.ArrayList)

Example 5 with HTMLWriter

use of diskCacheV111.util.HTMLWriter in project dcache by dCache.

the class PoolInfoObserverEngineV2 method queryUrl.

@Override
public void queryUrl(HttpRequest request) throws HttpException {
    String[] urlItems = request.getRequestTokens();
    int offset = request.getRequestTokenOffset();
    OutputStream out = request.getOutputStream();
    _requestCounter++;
    request.printHttpHeader(0);
    HTMLWriter html = new HTMLWriter(out, _context);
    try {
        html.addHeader("/styles/poolinfo.css", "Pool Property Tables");
        if (urlItems.length < 1) {
            return;
        }
        if (urlItems.length > 1 && urlItems[1].equals("list")) {
            Object o = _context.get("poolgroup-map.ser");
            if (o == null) {
                html.println("<h3>Information not yet available</h3>");
                return;
            } else if (!(o instanceof PoolCellQueryContainer)) {
                html.println("<h3>Internal error: poolgroup-map.ser contains unknown class</h3>");
                return;
            }
            _container = (PoolCellQueryContainer) o;
            String className = urlItems.length > 2 ? urlItems[2] : null;
            String groupName = urlItems.length > 3 ? urlItems[3] : null;
            String selection = urlItems.length > 4 ? urlItems[4] : null;
            printClassMenu(html, className);
            if (className == null) {
                return;
            }
            if (_showPoolGroupUsage) {
                printGroupList(html, className);
            } else {
                printGroupMenu(html, className, groupName);
            }
            if (groupName == null) {
                return;
            }
            html.println("<h3>Pool group <emph>" + groupName + "</emph></h3>");
            printMenuTable(html, _tableSelection.entrySet(), "/pools/list/" + className + "/" + groupName + "/", selection);
            if (selection == null) {
                return;
            }
            Map<String, Object> poolMap = _container.getPoolMap(className, groupName);
            if (poolMap == null) {
                return;
            }
            switch(selection) {
                case "cells":
                    printCells(html, poolMap);
                    break;
                case "spaces":
                    printPools(html, poolMap);
                    break;
                case "queues":
                    printPoolActions(html, poolMap);
                    break;
            }
        }
    } catch (Exception e) {
        _errorCounter++;
        showProblem(html, e.getMessage());
        html.println("<ul>");
        for (int i = 0; i < urlItems.length; i++) {
            html.println("<li> [" + i + "] " + urlItems[i] + "</li>");
        }
        html.println("</ul>");
    } finally {
        html.addFooter(getClass().getName() + " [$Rev$]");
    }
}
Also used : HTMLWriter(diskCacheV111.util.HTMLWriter) OutputStream(java.io.OutputStream) HttpException(dmg.util.HttpException)

Aggregations

HTMLWriter (diskCacheV111.util.HTMLWriter)5 CacheException (diskCacheV111.util.CacheException)3 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)3 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)3 HttpException (dmg.util.HttpException)3 OutputStream (java.io.OutputStream)2 ArrayList (java.util.ArrayList)2 Escaper (com.google.common.escape.Escaper)1 HtmlEscapers (com.google.common.html.HtmlEscapers)1 PnfsId (diskCacheV111.util.PnfsId)1 PnfsMapPathMessage (diskCacheV111.vehicles.PnfsMapPathMessage)1 RestoreHandlerInfo (diskCacheV111.vehicles.RestoreHandlerInfo)1 StorageInfo (diskCacheV111.vehicles.StorageInfo)1 CellCommandListener (dmg.cells.nucleus.CellCommandListener)1 CellEndpoint (dmg.cells.nucleus.CellEndpoint)1 CellInfo (dmg.cells.nucleus.CellInfo)1 CellInfoProvider (dmg.cells.nucleus.CellInfoProvider)1 CellLifeCycleAware (dmg.cells.nucleus.CellLifeCycleAware)1 CellMessageReceiver (dmg.cells.nucleus.CellMessageReceiver)1 CellMessageSender (dmg.cells.nucleus.CellMessageSender)1