Skip to content

Commit 065aabd

Browse files
committed
Add endpoint methods to current monitor, replace modal data
1 parent aa4ab5d commit 065aabd

File tree

6 files changed

+244
-6
lines changed

6 files changed

+244
-6
lines changed

server/monitor/src/main/java/org/apache/accumulo/monitor/next/InformationFetcher.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
import jakarta.ws.rs.NotFoundException;
4141

42+
import org.apache.accumulo.core.Constants;
4243
import org.apache.accumulo.core.client.TableNotFoundException;
4344
import org.apache.accumulo.core.client.admin.TabletInformation;
4445
import org.apache.accumulo.core.client.admin.servers.ServerId;
@@ -84,14 +85,16 @@ public static class InstanceSummary {
8485
private final String instanceUUID;
8586
private final Set<String> zooKeepers;
8687
private final Set<String> volumes;
88+
private final String version;
8789

8890
public InstanceSummary(String instanceName, String instanceUUID, Set<String> zooKeepers,
89-
Set<String> volumes) {
91+
Set<String> volumes, String version) {
9092
super();
9193
this.instanceName = instanceName;
9294
this.instanceUUID = instanceUUID;
9395
this.zooKeepers = zooKeepers;
9496
this.volumes = volumes;
97+
this.version = version;
9598
}
9699

97100
public String getInstanceName() {
@@ -109,6 +112,10 @@ public Set<String> getZooKeepers() {
109112
public Set<String> getVolumes() {
110113
return volumes;
111114
}
115+
116+
public String getVersion() {
117+
return version;
118+
}
112119
}
113120

114121
private class MetricFetcher implements Runnable {
@@ -392,7 +399,8 @@ public InstanceSummary getInstanceSummary() {
392399
return new InstanceSummary(ctx.getInstanceName(),
393400
ctx.instanceOperations().getInstanceId().canonical(),
394401
Set.of(ctx.getZooKeepers().split(",")), ctx.getVolumeManager().getVolumes().stream()
395-
.map(v -> v.toString()).collect(Collectors.toSet()));
402+
.map(v -> v.toString()).collect(Collectors.toSet()),
403+
Constants.VERSION);
396404
}
397405

398406
public Collection<MetricResponse> getCompactors(String resourceGroup) {

server/monitor/src/main/java/org/apache/accumulo/monitor/next/NewMonitor.java

+5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import io.javalin.Javalin;
5757
import io.javalin.http.staticfiles.Location;
5858
import io.javalin.json.JavalinJackson;
59+
import io.javalin.plugin.bundled.CorsPluginConfig;
5960
import io.javalin.security.RouteRole;
6061
import io.micrometer.core.instrument.Meter.Id;
6162
import io.micrometer.core.instrument.cumulative.CumulativeDistributionSummary;
@@ -123,6 +124,10 @@ public void start() throws IOException {
123124
mapper.registerModule(new Jdk8Module());
124125
}));
125126

127+
config.bundledPlugins.enableCors(cors -> {
128+
cors.addRule(CorsPluginConfig.CorsRule::anyHost);
129+
});
130+
126131
final HttpConnectionFactory httpFactory = new HttpConnectionFactory();
127132

128133
// Set up TLS

server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js

+190
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,15 @@ function getJSONForTable(call, sessionDataVar) {
308308
});
309309
}
310310

311+
/**
312+
* Wraps the getJSONForTable function to call the new server
313+
* TODO: Remove this function once the new server is fully integrated
314+
*/
315+
function getJSONfromNewServer(call, sessionDataVar) {
316+
const url = 'http://localhost:43331' + call;
317+
return getJSONForTable(url, sessionDataVar);
318+
}
319+
311320
/**
312321
* Performs POST call and builds console logging message if successful
313322
* @param {string} call REST url called
@@ -497,3 +506,184 @@ function clearAllTableCells(tableId) {
497506
$(this).text("");
498507
});
499508
}
509+
510+
// NEW REST CALLS
511+
512+
/**
513+
* REST GET call for /stats,
514+
* stores it on a sessionStorage variable
515+
*/
516+
function getStats() {
517+
return getJSONfromNewServer('/stats', 'stats');
518+
}
519+
520+
/**
521+
* REST GET call for /metrics,
522+
* stores it on a sessionStorage variable
523+
*/
524+
function getMetrics() {
525+
return getJSONfromNewServer('/metrics', 'metrics');
526+
}
527+
528+
/**
529+
* REST GET call for /metrics/lastUpdate,
530+
* stores it on a sessionStorage variable
531+
*/
532+
function getMetricsLastUpdate() {
533+
return getJSONfromNewServer('/metrics/lastUpdate', 'metricsLastUpdate');
534+
}
535+
536+
/**
537+
* REST GET call for /metrics/instance,
538+
* stores it on a sessionStorage variable
539+
*/
540+
function getMetricsInstance() {
541+
return getJSONfromNewServer('/metrics/instance', 'metricsInstance');
542+
}
543+
544+
/**
545+
* REST GET call for /metrics/groups,
546+
* stores it on a sessionStorage variable
547+
*/
548+
function getMetricsGroups() {
549+
return getJSONfromNewServer('/metrics/groups', 'metricsGroups');
550+
}
551+
552+
/**
553+
* REST GET call for /metrics/manager,
554+
* stores it on a sessionStorage variable
555+
*/
556+
function getMetricsManager() {
557+
return getJSONfromNewServer('/metrics/manager', 'metricsManager');
558+
}
559+
560+
/**
561+
* REST GET call for /metrics/gc,
562+
* stores it on a sessionStorage variable
563+
*/
564+
function getMetricsGc() {
565+
return getJSONfromNewServer('/metrics/gc', 'metricsGc');
566+
}
567+
568+
/**
569+
* REST GET call for /metrics/compactors/summary and /metrics/compactors/summary/{group},
570+
* stores it on a sessionStorage variable
571+
* @param {string} [group] Optional group name
572+
*/
573+
function getMetricsCompactorsSummary(group) {
574+
const url = group ? `/metrics/compactors/summary/${group}` : '/metrics/compactors/summary';
575+
const sessionDataVar = group ? `metricsCompactorsSummary_${group}` : 'metricsCompactorsSummary';
576+
return getJSONfromNewServer(url, sessionDataVar);
577+
}
578+
579+
/**
580+
* REST GET call for /metrics/compactors/detail/{group},
581+
* stores it on a sessionStorage variable
582+
* @param {string} group Group name
583+
*/
584+
function getMetricsCompactorsDetail(group) {
585+
const url = `/metrics/compactors/detail/${group}`;
586+
const sessionDataVar = `metricsCompactorsDetail_${group}`;
587+
return getJSONfromNewServer(url, sessionDataVar);
588+
}
589+
590+
/**
591+
* REST GET call for /metrics/sservers/summary and /metrics/sservers/summary/{group},
592+
* stores it on a sessionStorage variable
593+
* @param {string} [group] Optional group name
594+
*/
595+
function getMetricsSserversSummary(group) {
596+
const url = group ? `/metrics/sservers/summary/${group}` : '/metrics/sservers/summary';
597+
const sessionDataVar = group ? `metricsSserversSummary_${group}` : 'metricsSserversSummary';
598+
return getJSONfromNewServer(url, sessionDataVar);
599+
}
600+
601+
/**
602+
* REST GET call for /metrics/sservers/detail/{group},
603+
* stores it on a sessionStorage variable
604+
* @param {string} group Group name
605+
*/
606+
function getMetricsSserversDetail(group) {
607+
const url = `/metrics/sservers/detail/${group}`;
608+
const sessionDataVar = `metricsSserversDetail_${group}`;
609+
return getJSONfromNewServer(url, sessionDataVar);
610+
}
611+
612+
/**
613+
* REST GET call for /metrics/tservers/summary and /metrics/tservers/summary/{group},
614+
* stores it on a sessionStorage variable
615+
* @param {string} [group] Optional group name
616+
*/
617+
function getMetricsTserversSummary(group) {
618+
const url = group ? `/metrics/tservers/summary/${group}` : '/metrics/tservers/summary';
619+
const sessionDataVar = group ? `metricsTserversSummary_${group}` : 'metricsTserversSummary';
620+
return getJSONfromNewServer(url, sessionDataVar);
621+
}
622+
623+
/**
624+
* REST GET call for /metrics/tservers/detail/{group},
625+
* stores it on a sessionStorage variable
626+
* @param {string} group Group name
627+
*/
628+
function getMetricsTserversDetail(group) {
629+
const url = `/metrics/tservers/detail/${group}`;
630+
const sessionDataVar = `metricsTserversDetail_${group}`;
631+
return getJSONfromNewServer(url, sessionDataVar);
632+
}
633+
634+
/**
635+
* REST GET call for /metrics/compactions/summary,
636+
* stores it on a sessionStorage variable
637+
*/
638+
function getMetricsCompactionsSummary() {
639+
return getJSONfromNewServer('/metrics/compactions/summary', 'metricsCompactionsSummary');
640+
}
641+
642+
/**
643+
* REST GET call for /metrics/compactions/detail and /metrics/compactions/detail/{num},
644+
* stores it on a sessionStorage variable
645+
* @param {number} [num] Optional detail number
646+
*/
647+
function getMetricsCompactionsDetail(num) {
648+
const url = num ? `/metrics/compactions/detail/${num}` : '/metrics/compactions/detail';
649+
const sessionDataVar = num ? `metricsCompactionsDetail_${num}` : 'metricsCompactionsDetail';
650+
return getJSONfromNewServer(url, sessionDataVar);
651+
}
652+
653+
/**
654+
* REST GET call for /metrics/tables and /metrics/tables/{name},
655+
* stores it on a sessionStorage variable
656+
* @param {string} [name] Optional table name
657+
*/
658+
function getMetricsTables(name) {
659+
const url = name ? `/metrics/tables/${name}` : '/metrics/tables';
660+
const sessionDataVar = name ? `metricsTables_${name}` : 'metricsTables';
661+
return getJSONfromNewServer(url, sessionDataVar);
662+
}
663+
664+
/**
665+
* REST GET call for /metrics/tables/{name}/tablets,
666+
* stores it on a sessionStorage variable
667+
* @param {string} name The table name
668+
*/
669+
function getMetricsTableTabletsByName(name) {
670+
const url = `/metrics/tables/${name}/tablets`;
671+
const sessionDataVar = `metricsTableTablets_${name}`;
672+
return getJSONfromNewServer(url, sessionDataVar);
673+
}
674+
675+
/**
676+
* REST GET call for /metrics/deployment,
677+
* stores it on a sessionStorage variable
678+
*/
679+
function getMetricsDeployment() {
680+
return getJSONfromNewServer('/metrics/deployment', 'metricsDeployment');
681+
}
682+
683+
/**
684+
* REST GET call for /metrics/suggestions,
685+
* stores it on a sessionStorage variable
686+
*/
687+
function getMetricsSuggestions() {
688+
return getJSONfromNewServer('/metrics/suggestions', 'metricsSuggestions');
689+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
21+
$(document).ready(function () {
22+
getMetricsInstance().then(function () {
23+
const data = JSON.parse(sessionStorage.metricsInstance);
24+
$('#modal-version').text(data.version);
25+
$('#modal-instance-name').text(data.instanceName);
26+
$('#modal-instance-id').text(data.instanceUUID);
27+
$('#modal-zk-hosts').text(data.zooKeepers);
28+
$('#modal-volumes').text(data.volumes);
29+
});
30+
});

server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/default.ftl

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
</#if>
5959
<script src="/resources/js/navbar.js"></script>
6060
<script src="/resources/js/systemAlert.js"></script>
61+
<script src="/resources/js/modals.js"></script>
6162
</head>
6263

6364
<body>

server/monitor/src/main/resources/org/apache/accumulo/monitor/templates/modals.ftl

+8-4
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,23 @@
3939
</div>
4040
<div class="row justify-content-evenly">
4141
<div class="col-sm-4 text-end">Version</div>
42-
<div class="col-sm-8 text-start">${version}</div>
42+
<div class="col-sm-8 text-start"><span id="modal-version"></span></div>
4343
</div>
4444
<div class="row justify-content-evenly">
4545
<div class="col-sm-4 text-end">Instance&nbsp;Name</div>
46-
<div class="col-sm-8 text-start">${instance_name}</div>
46+
<div class="col-sm-8 text-start"><span id="modal-instance-name"></span></div>
4747
</div>
4848
<div class="row justify-content-evenly">
4949
<div class="col-sm-4 text-end">Instance&nbsp;Id</div>
50-
<div class="col-sm-8 text-start">${instance_id}</div>
50+
<div class="col-sm-8 text-start"><span id="modal-instance-id"></span></div>
5151
</div>
5252
<div class="row justify-content-evenly">
5353
<div class="col-sm-4 text-end">ZooKeeper&nbsp;Hosts</div>
54-
<div class="col-sm-8 text-start">${zk_hosts}</div>
54+
<div class="col-sm-8 text-start"><span id="modal-zk-hosts"></span></div>
55+
</div>
56+
<div class="row justify-content-evenly">
57+
<div class="col-sm-4 text-end">Volumes</div>
58+
<div class="col-sm-8 text-start"><span id="modal-volumes"></span></div>
5559
</div>
5660
</div>
5761
</div>

0 commit comments

Comments
 (0)