Search in sources :

Example 1 with WebappInstanceLog

use of io.datarouter.webappinstance.storage.webappinstancelog.WebappInstanceLog in project datarouter by hotpads.

the class WebappInstanceService method updateWebappInstanceTable.

public WebappInstance updateWebappInstanceTable() {
    String buildId = buildProperties.getBuildId();
    String commitId = gitProperties.getIdAbbrev().orElse(GitProperties.UNKNOWN_STRING);
    Counters.inc("App heartbeat " + serverType.getServerTypeString());
    Counters.inc("App heartbeat type-build " + serverType.getServerTypeString() + " " + buildId);
    Counters.inc("App heartbeat type-commit " + serverType.getServerTypeString() + " " + commitId);
    Counters.inc("App heartbeat build " + buildId);
    Counters.inc("App heartbeat commit " + commitId);
    WebappInstance webappInstance = buildCurrentWebappInstance();
    webappInstanceDao.put(webappInstance);
    webappInstanceLogDao.put(new WebappInstanceLog(webappInstance));
    if (settings.webappInstancePublisher.get()) {
        WebappInstanceDto dto = webappInstance.toDto();
        webappInstancePublisher.add(dto);
    }
    return webappInstance;
}
Also used : WebappInstanceDto(io.datarouter.instrumentation.webappinstance.WebappInstanceDto) WebappInstanceLog(io.datarouter.webappinstance.storage.webappinstancelog.WebappInstanceLog) WebappInstance(io.datarouter.webappinstance.storage.webappinstance.WebappInstance)

Example 2 with WebappInstanceLog

use of io.datarouter.webappinstance.storage.webappinstancelog.WebappInstanceLog in project datarouter by hotpads.

the class WebappInstanceLogHandler method webappInstanceLog.

@Handler(defaultHandler = true)
public Mav webappInstanceLog(String webappName, String serverName) {
    Mav mav = new Mav(files.jsp.admin.datarouter.webappInstances.webappInstanceLogJsp);
    WebappInstanceLogKey prefix = new WebappInstanceLogKey(webappName, serverName, null, null);
    List<WebappInstanceLog> logs = dao.scanWithPrefix(prefix).sort(Comparator.comparing(log -> log.getKey().getStartup(), Collections.reverseOrder())).list();
    int logCount = logs.size();
    ZoneId zoneId = currentUserSessionInfoService.getZoneId(request);
    List<WebappInstanceLogJspDto> logJspDtos = new ArrayList<>(logCount);
    for (int i = 0; i < logCount; ++i) {
        Instant fallbackRefreshedLast = i == 0 ? Instant.now() : logs.get(i - 1).getKey().getStartup();
        logJspDtos.add(new WebappInstanceLogJspDto(logs.get(i), fallbackRefreshedLast, zoneId));
    }
    mav.put("logs", logJspDtos);
    return mav;
}
Also used : Mav(io.datarouter.web.handler.mav.Mav) ZoneId(java.time.ZoneId) WebappInstanceLogKey(io.datarouter.webappinstance.storage.webappinstancelog.WebappInstanceLogKey) Instant(java.time.Instant) ArrayList(java.util.ArrayList) WebappInstanceLog(io.datarouter.webappinstance.storage.webappinstancelog.WebappInstanceLog) BaseHandler(io.datarouter.web.handler.BaseHandler)

Aggregations

WebappInstanceLog (io.datarouter.webappinstance.storage.webappinstancelog.WebappInstanceLog)2 WebappInstanceDto (io.datarouter.instrumentation.webappinstance.WebappInstanceDto)1 BaseHandler (io.datarouter.web.handler.BaseHandler)1 Mav (io.datarouter.web.handler.mav.Mav)1 WebappInstance (io.datarouter.webappinstance.storage.webappinstance.WebappInstance)1 WebappInstanceLogKey (io.datarouter.webappinstance.storage.webappinstancelog.WebappInstanceLogKey)1 Instant (java.time.Instant)1 ZoneId (java.time.ZoneId)1 ArrayList (java.util.ArrayList)1