• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

knowledgepixels / nanopub-registry / 23976591988

04 Apr 2026 09:57AM UTC coverage: 31.828% (+0.5%) from 31.28%
23976591988

push

github

web-flow
Merge pull request #91 from knowledgepixels/perf/seqnum-batch-allocation

perf: batch seqNum allocation to reduce global counter contention

216 of 754 branches covered (28.65%)

Branch coverage included in aggregate %.

714 of 2168 relevant lines covered (32.93%)

5.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
src/main/java/com/knowledgepixels/registry/MainPage.java
1
package com.knowledgepixels.registry;
2

3
import com.mongodb.client.ClientSession;
4
import io.vertx.ext.web.RoutingContext;
5

6
import java.io.IOException;
7

8
import static com.knowledgepixels.registry.RegistryDB.*;
9

10
public class MainPage extends Page {
11

12
    public static void show(RoutingContext context) {
13
        MainPage page;
14
        try (ClientSession s = RegistryDB.getClient().startSession()) {
×
15
            s.startTransaction();
×
16
            page = new MainPage(s, context);
×
17
            page.show();
×
18
        } catch (IOException ex) {
×
19
            ex.printStackTrace();
×
20
        } finally {
21
            context.response().end();
×
22
            // TODO Clean-up here?
23
        }
24
    }
×
25

26
    private MainPage(ClientSession mongoSession, RoutingContext context) {
27
        super(mongoSession, context);
×
28
    }
×
29

30
    protected void show() throws IOException {
31
        RoutingContext c = getContext();
×
32
        String format;
33
        String ext = getExtension();
×
34
        if ("json".equals(ext)) {
×
35
            format = "application/json";
×
36
        } else if (ext == null || "html".equals(ext)) {
×
37
            String suppFormats = "application/json,text/html";
×
38
            format = Utils.getMimeType(c, suppFormats);
×
39
        } else {
×
40
            c.response().setStatusCode(400).setStatusMessage("Invalid request: " + getFullRequest());
×
41
            return;
×
42
        }
43

44
        if (getPresentationFormat() != null) {
×
45
            setRespContentType(getPresentationFormat());
×
46
        } else {
47
            setRespContentType(format);
×
48
        }
49

50
        if ("application/json".equals(format)) {
×
51
            println(RegistryInfo.getLocal(mongoSession).asJson());
×
52
        } else {
53
            String status = getValue(mongoSession, Collection.SERVER_INFO.toString(), "status").toString();
×
54
            printHtmlHeader("Nanopub Registry");
×
55
            println("<h1>Nanopub Registry</h1>");
×
56
            if (isSet(mongoSession, Collection.SERVER_INFO.toString(), "testInstance")) {
×
57
                println("<p style=\"color: red\">This is a test instance.</p>");
×
58
            }
59
            println("<h3>Formats</h3>");
×
60
            println("<p>");
×
61
            println("<a href=\".json\">.json</a> |");
×
62
            println("<a href=\".json.txt\">.json.txt</a>");
×
63
            println("</p>");
×
64
            println("<h3>Server</h3>");
×
65
            println("<ul>");
×
66
            println("<li><em>setupId:</em> " + getValue(mongoSession, Collection.SERVER_INFO.toString(), "setupId") + "</li>");
×
67
            println("<li><em>coverageTypes:</em> " + getValue(mongoSession, Collection.SERVER_INFO.toString(), "coverageTypes") + "</li>");
×
68
            println("<li><em>coverageAgents:</em> " + getValue(mongoSession, Collection.SERVER_INFO.toString(), "coverageAgents") + "</li>");
×
69
            println("<li><em>status:</em> " + status + "</li>");
×
70
            println("<li><em>seqNum:</em> " + getMaxValue(mongoSession, Collection.NANOPUBS.toString(), "seqNum") + "</li>");
×
71
            println("<li><em>nanopubCount:</em> " + collection(Collection.NANOPUBS.toString()).estimatedDocumentCount() + "</li>");
×
72
            println("<li><em>trustStateCounter:</em> " + getValue(mongoSession, Collection.SERVER_INFO.toString(), "trustStateCounter") + "</li>");
×
73
            Object lastTimeUpdate = getValue(mongoSession, Collection.SERVER_INFO.toString(), "lastTrustStateUpdate");
×
74
            if (lastTimeUpdate != null) {
×
75
                println("<li><em>lastTrustStateUpdate:</em> " + lastTimeUpdate.toString().replaceFirst("\\.[^.]*$", "") + "</li>");
×
76
            } else {
77
                println("<li><em>lastTrustStateUpdate:</em> null</li>");
×
78
            }
79
            Object trustStateHash = getValue(mongoSession, Collection.SERVER_INFO.toString(), "trustStateHash");
×
80
            if (trustStateHash != null) trustStateHash = trustStateHash.toString().substring(0, 10);
×
81
            println("<li><em>trustStateHash:</em> " + trustStateHash + "</li>");
×
82
            String oSetting = getValue(mongoSession, Collection.SETTING.toString(), "original").toString();
×
83
            println("<li><em>originalSetting:</em> <a href=\"/np/" + oSetting + "\"><code>" + oSetting.substring(0, 10) + "</code></a></li>");
×
84
            String cSetting = getValue(mongoSession, Collection.SETTING.toString(), "current").toString();
×
85
            println("<li><em>currentSetting:</em> <a href=\"/np/" + cSetting + "\"><code>" + cSetting.substring(0, 10) + "</code></a></li>");
×
86
            println("</ul>");
×
87

88
            println("<h3>Agents</h3>");
×
89
            if (status.equals("launching") || status.equals("coreLoading")) {
×
90
                println("<p><em>(loading...)</em></p>");
×
91
            } else {
92
                println("<p>Count: " + collection(Collection.AGENTS.toString()).countDocuments(mongoSession) + "</p>");
×
93
                println("<p><a href=\"/agents\">&gt; agents</a></pi>");
×
94
            }
95

96
            println("<h3>Accounts</h3>");
×
97
            if (status.equals("launching") || status.equals("coreLoading")) {
×
98
                println("<p><em>(loading...)</em></p>");
×
99
            } else {
100
                println("<p>Count: " + collection(Collection.ACCOUNTS.toString()).countDocuments(mongoSession) + "</p>");
×
101
                println("<p><a href=\"/list\">&gt; accounts</a></pi>");
×
102
            }
103

104
            println("<h3>Nanopubs</h3>");
×
105
            println("<p>Count: " + collection(Collection.NANOPUBS.toString()).estimatedDocumentCount() + "</p>");
×
106
            println("<p><a href=\"/nanopubs\">&gt; nanopubs</a></pi>");
×
107
            printHtmlFooter();
×
108
        }
109
    }
×
110

111
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc