(control) Better looking UUIDs

This commit is contained in:
Viktor Lofgren 2023-07-11 23:11:02 +02:00
parent 00d9773b44
commit 0b0cf48849
12 changed files with 68 additions and 36 deletions

View File

@ -2,9 +2,18 @@ package nu.marginalia.control.model;
public record EventLogEntry(
String serviceName,
String instance,
String instanceFull,
String eventTime,
String eventType,
String eventMessage)
{
public String instance() {
return instanceFull.substring(0, 8);
}
public String instanceColor() {
return '#' + instanceFull.substring(0, 6);
}
public String instanceColor2() {
return '#' + instanceFull.substring(25, 31);
}
}

View File

@ -6,7 +6,7 @@ public record MessageQueueEntry (
String senderInbox,
String recipientInbox,
String function,
String ownerInstance,
String ownerInstanceFull,
long ownerTick,
String state,
String createdTime,
@ -14,4 +14,13 @@ public record MessageQueueEntry (
int ttl
)
{
public String ownerInstance() {
return ownerInstanceFull.substring(0, 8);
}
public String ownerInstanceColor() {
return '#' + ownerInstanceFull.substring(0, 6);
}
public String ownerInstanceColor2() {
return '#' + ownerInstanceFull.substring(25, 31);
}
}

View File

@ -3,11 +3,20 @@ package nu.marginalia.control.model;
public record ProcessHeartbeat(
String processId,
String processBase,
String uuid,
String uuidFull,
double lastSeenMillis,
Integer progress,
String status
) {
public String uuid() {
return uuidFull.substring(0, 8);
}
public String uuidColor() {
return '#' + uuidFull.substring(0, 6);
}
public String uuidColor2() {
return '#' + uuidFull.substring(25, 31);
}
public boolean isMissing() {
return lastSeenMillis > 10000;
}

View File

@ -3,12 +3,20 @@ package nu.marginalia.control.model;
public record ServiceHeartbeat(
String serviceId,
String serviceBase,
String uuid,
String uuidFull,
double lastSeenMillis,
boolean alive
) {
public boolean isMissing() {
return lastSeenMillis > 10000;
}
public String uuid() {
return uuidFull.substring(0, 8);
}
public String uuidColor() {
return '#' + uuidFull.substring(0, 6);
}
public String uuidColor2() {
return '#' + uuidFull.substring(25, 31);
}
}

View File

@ -32,7 +32,7 @@ public class EventLogService {
while (rs.next()) {
entries.add(new EventLogEntry(
rs.getString("SERVICE_NAME"),
trimUUID(rs.getString("INSTANCE")),
rs.getString("INSTANCE"),
rs.getTimestamp("EVENT_TIME").toLocalDateTime().toLocalTime().toString(),
rs.getString("EVENT_TYPE"),
rs.getString("EVENT_MESSAGE")
@ -44,11 +44,5 @@ public class EventLogService {
throw new RuntimeException(ex);
}
}
private String trimUUID(String uuid) {
if (uuid.length() > 8) {
return uuid.substring(0, 8);
}
return uuid;
}
}

View File

@ -34,7 +34,7 @@ public class HeartbeatService {
heartbeats.add(new ServiceHeartbeat(
rs.getString("SERVICE_NAME"),
rs.getString("SERVICE_BASE"),
trimUUID(rs.getString("INSTANCE")),
rs.getString("INSTANCE"),
rs.getLong("TSDIFF") / 1000.,
rs.getBoolean("ALIVE")
));
@ -59,12 +59,13 @@ public class HeartbeatService {
var rs = stmt.executeQuery();
while (rs.next()) {
int progress = rs.getInt("PROGRESS");
heartbeats.add(new ProcessHeartbeat(
rs.getString("PROCESS_NAME"),
rs.getString("PROCESS_BASE"),
trimUUID(rs.getString("INSTANCE")),
rs.getString("INSTANCE"),
rs.getLong("TSDIFF") / 1000.,
rs.getInt("PROGRESS"),
progress < 0 ? null : progress,
rs.getString("STATUS")
));
}
@ -75,10 +76,5 @@ public class HeartbeatService {
return heartbeats;
}
private String trimUUID(String uuid) {
if (uuid.length() > 8) {
return uuid.substring(0, 8);
}
return uuid;
}
}

View File

@ -38,7 +38,7 @@ public class MessageQueueViewService {
rs.getString("SENDER_INBOX"),
rs.getString("RECIPIENT_INBOX"),
rs.getString("FUNCTION"),
trimUUID(rs.getString("OWNER_INSTANCE")),
rs.getString("OWNER_INSTANCE"),
rs.getLong("OWNER_TICK"),
rs.getString("STATE"),
rs.getTimestamp("CREATED_TIME").toLocalDateTime().toLocalTime().toString(),
@ -52,15 +52,5 @@ public class MessageQueueViewService {
throw new RuntimeException(ex);
}
}
private String trimUUID(String uuid) {
if (null == uuid) {
return "";
}
if (uuid.length() > 8) {
return uuid.substring(0, 8);
}
return uuid;
}
}

View File

@ -8,6 +8,11 @@ body {
grid-template-areas:
"left right";
}
.uuidPip {
margin-left: 0.25ch;
border-radius: 2ch;
border: 1px solid #ccc;
}
h1 {
font-family: serif;
}

View File

@ -23,7 +23,10 @@
{{#each events}}
<tr>
<td>{{serviceName}}</td>
<td>{{instance}}</td>
<td title="{{instanceFull}}">
<span style="background-color: {{instanceColor}}" class="uuidPip">&nbsp;</span><span style="background-color: {{instanceColor2}}" class="uuidPip">&nbsp;</span>
{{instance}}
</td>
<td>{{eventTime}}</td>
<td>{{eventType}}</td>
<td>{{eventMessage}}</td>

View File

@ -33,7 +33,10 @@
<td>{{recipientInbox}}</td>
<td>{{senderInbox}}</td>
<td>{{function}}</td>
<td>{{ownerInstance}}</td>
<td title="{{ownerInstanceFull}}">
<span style="background-color: {{ownerInstanceColor}}" class="uuidPip">&nbsp;</span><span style="background-color: {{ownerInstanceColor2}}" class="uuidPip">&nbsp;</span>
{{ownerInstance}}
</td>
<td>{{ownerTick}}</td>
<td>{{state}}</td>
<td>{{createdTime}}</td>

View File

@ -22,7 +22,10 @@
{{#each heartbeats}}
<tr class="{{#if isMissing}}missing{{/if}}" style="{{progressStyle}}">
<td>{{processId}}</td>
<td>{{uuid}}</td>
<td title="{{uuidFull}}">
<span style="background-color: {{uuidColor}}" class="uuidPip">&nbsp;</span><span style="background-color: {{uuidColor2}}" class="uuidPip">&nbsp;</span>
{{uuid}}
</td>
<td>{{status}}</td>
<td>{{#if progress}}{{progress}}%{{/if}}</td>
<td>{{#unless isStopped}}{{lastSeenMillis}}{{/unless}}</td>

View File

@ -20,7 +20,10 @@
{{#each heartbeats}}
<tr class="{{#if isMissing}}missing{{/if}} {{#unless alive}}terminated{{/unless}}">
<td>{{serviceId}}</td>
<td>{{uuid}}</td>
<td title="{{uuidFull}}">
<span style="background-color: {{uuidColor}}" class="uuidPip">&nbsp;</span><span style="background-color: {{uuidColor2}}" class="uuidPip">&nbsp;</span>
{{uuid}}
</td>
<td>{{lastSeenMillis}}</td>
</tr>
{{/each}}