@hawtio/react
Version:
A Hawtio reimplementation based on TypeScript + React.
599 lines (555 loc) • 29 kB
JavaScript
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
var _chunkOJIIWKORjs = require('./chunk-OJIIWKOR.js');
require('./chunk-HS42NURZ.js');
require('./chunk-BLJGIIMV.js');
require('./chunk-WYFZRJ4C.js');
var _chunkBJ6TSPQKjs = require('./chunk-BJ6TSPQK.js');
var _chunkBHIEXRGKjs = require('./chunk-BHIEXRGK.js');
// src/plugins/runtime/Metrics.tsx
var _victory = require('@patternfly/react-charts/victory');
var _reactcore = require('@patternfly/react-core');
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
// src/plugins/runtime/runtime-service.ts
var _jolokiajs = require('jolokia.js'); var _jolokiajs2 = _interopRequireDefault(_jolokiajs);
var RuntimeService = (_class = class {constructor() { _class.prototype.__init.call(this); }
__init() {this.handlers = []}
convertMsToDaysHours(ms) {
const seconds = Math.floor(ms / 1e3);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
const days = Math.floor(hours / 24);
return `${days} days, ${hours % 24} hours`;
}
async loadSystemProperties() {
const systemProperties = [];
const attr = await _chunkBJ6TSPQKjs.jolokiaService.readAttribute("java.lang:type=Runtime", "SystemProperties").catch((e) => {
_chunkBHIEXRGKjs.eventService.notify({ type: "warning", message: _chunkBJ6TSPQKjs.jolokiaService.errorMessage(e) });
return {};
});
for (const [k, v] of Object.entries(attr)) {
systemProperties.push({ key: k, value: v });
}
return systemProperties;
}
async registerLoadThreadsRequest(callback) {
const handler = await _chunkBJ6TSPQKjs.jolokiaService.register(
{
type: "exec",
mbean: "java.lang:type=Threading",
operation: "dumpAllThreads(boolean,boolean)",
arguments: [true, true]
},
(resp) => {
if (!_jolokiajs2.default.isResponseFetchError(resp) && !_jolokiajs2.default.isError(resp)) {
const threads = resp.value;
callback(threads);
}
}
);
this.handlers.push(handler);
}
loadThreads() {
return _chunkBJ6TSPQKjs.jolokiaService.execute("java.lang:type=Threading", "dumpAllThreads(boolean,boolean)", [
false,
false
]);
}
async isThreadContentionMonitoringEnabled() {
const res = await _chunkBJ6TSPQKjs.jolokiaService.readAttribute("java.lang:type=Threading", "ThreadContentionMonitoringEnabled").catch((e) => {
_chunkBHIEXRGKjs.eventService.notify({ type: "warning", message: _chunkBJ6TSPQKjs.jolokiaService.errorMessage(e) });
return false;
});
return res;
}
async enableThreadContentionMonitoring(enabled) {
return await _chunkBJ6TSPQKjs.jolokiaService.writeAttribute("java.lang:type=Threading", "ThreadContentionMonitoringEnabled", enabled).catch((e) => {
_chunkBHIEXRGKjs.eventService.notify({ type: "warning", message: _chunkBJ6TSPQKjs.jolokiaService.errorMessage(e) });
});
}
async dumpThreads() {
const threads = await _chunkBJ6TSPQKjs.jolokiaService.execute("java.lang:type=Threading", "dumpAllThreads(boolean, boolean)", [
true,
true
]);
const thrs = threads;
let dumpedThreads = "";
thrs.forEach((thread) => {
const name = thread.threadName;
const daemon = thread.daemon ? " daemon" : "";
let threadInfo = `"${name}" #${thread.threadId}${daemon} priority:${thread.priority} State:${thread.threadState}`;
thread.stackTrace.forEach((st) => {
const lineNo = st.lineNumber > 0 ? ":" + st.lineNumber : "";
const native = st.nativeMethod ? "(Native)" : "";
threadInfo += `
at ${st.className}.${st.methodName}(${st.fileName}${lineNo})${native}`;
});
dumpedThreads += (dumpedThreads === "" ? "" : "\n\n") + threadInfo;
});
return dumpedThreads;
}
getRegisterRequest(mbean, attribute, _args) {
const request = { type: "read", mbean };
if (attribute) {
request.attribute = attribute;
}
return request;
}
responseCallback(response, callback) {
const req = response.request;
switch (req.mbean) {
case "java.lang:type=Threading": {
const threadCount = response.value;
callback({ type: "JVM", name: "Thread Count", value: threadCount });
break;
}
case "java.lang:type=Memory": {
const mb = response.value;
const heapUsed = this.formatBytes(mb.used);
callback({
type: "JVM",
name: "Heap Used",
value: _nullishCoalesce(heapUsed[0], () => ( "")),
unit: heapUsed[1]
});
break;
}
case "java.lang:type=OperatingSystem": {
const osMetrics = response.value;
const cpuLoad = (_nullishCoalesce(_nullishCoalesce(osMetrics.CpuLoad, () => ( osMetrics.SystemCpuLoad)), () => ( 0))) * 100;
const loadAverage = osMetrics.SystemLoadAverage;
const memFree = this.formatBytes(osMetrics.FreePhysicalMemorySize);
const memTotal = this.formatBytes(osMetrics.TotalPhysicalMemorySize);
const chartUnit = memTotal[1];
const chartMemFree = this.formatBytes(osMetrics.FreePhysicalMemorySize, chartUnit);
const chartMemAvail = this.formatBytes(osMetrics.TotalPhysicalMemorySize, chartUnit);
callback({ type: "System", name: "Available Processors", value: String(osMetrics.AvailableProcessors) });
callback({
type: "System",
name: "CPU Load",
value: String(cpuLoad),
unit: "%",
available: 100,
chart: true,
chartUnit: "%",
chartValue: String(cpuLoad),
chartAvailable: 100
});
callback({ type: "System", name: "Load Average", value: String(loadAverage) });
callback({
type: "System",
name: "Memory Used",
value: memFree[0],
unit: memFree[1],
available: memTotal[0],
availableUnit: memTotal[1],
chartValue: chartMemFree[0],
chartAvailable: chartMemAvail[0],
chart: true
});
callback({
type: "System",
name: "File Descriptors Used",
value: osMetrics.OpenFileDescriptorCount,
available: osMetrics.MaxFileDescriptorCount
});
break;
}
case "java.lang:type=ClassLoading": {
const loadedClassCount = response.value;
callback({ type: "JVM", name: "Classes Loaded", value: loadedClassCount });
break;
}
case "java.lang:type=Runtime": {
const runtimeMetrics = response.value;
callback({ type: "JVM", name: "Start time", value: new Date(runtimeMetrics.StartTime).toLocaleString() });
callback({ type: "JVM", name: "Uptime", value: this.convertMsToDaysHours(runtimeMetrics.Uptime) });
break;
}
}
}
getJolokiaRequests() {
const requests = [];
requests.push(this.getRegisterRequest("java.lang:type=Threading", "ThreadCount"));
requests.push(this.getRegisterRequest("java.lang:type=Memory", "HeapMemoryUsage"));
requests.push(this.getRegisterRequest("java.lang:type=Runtime"));
requests.push(this.getRegisterRequest("java.lang:type=OperatingSystem"));
requests.push(this.getRegisterRequest("java.lang:type=ClassLoading", "LoadedClassCount"));
return requests;
}
async registerMetrics(callback) {
for (const request of this.getJolokiaRequests()) {
const handler = await _chunkBJ6TSPQKjs.jolokiaService.register(request, (resp) => {
if (!_jolokiajs2.default.isResponseFetchError(resp) && !_jolokiajs2.default.isError(resp)) {
this.responseCallback(resp, callback);
}
});
this.handlers.push(handler);
}
}
async loadMetrics() {
const metrics = [];
const responses = await _chunkBJ6TSPQKjs.jolokiaService.bulkRequest(this.getJolokiaRequests());
responses.forEach((resp) => {
if (!_jolokiajs2.default.isError(resp)) {
this.responseCallback(resp, (metric) => metrics.push(metric));
}
});
return metrics;
}
formatBytes(bytes, convertTo) {
if (bytes === 0) {
return [0, "Bytes"];
}
const kilobytes = 1024;
const decimalPlaces = 2;
const units = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
let i;
if (convertTo && units.includes(convertTo)) {
i = units.indexOf(convertTo);
} else {
i = Math.floor(Math.log(bytes) / Math.log(kilobytes));
}
const value = parseFloat((bytes / Math.pow(kilobytes, i)).toFixed(decimalPlaces));
const unit = units[i];
return [value, _nullishCoalesce(unit, () => ( ""))];
}
unregisterAll() {
this.handlers.forEach((handle) => _chunkBJ6TSPQKjs.jolokiaService.unregister(handle));
this.handlers = [];
}
}, _class);
var runtimeService = new RuntimeService();
// src/plugins/runtime/Metrics.tsx
var _jsxruntime = require('react/jsx-runtime');
var Metrics = () => {
const [metrics, setMetrics] = _react.useState.call(void 0, {});
_react.useEffect.call(void 0, () => {
const readMetrics = async () => {
const metricsList = await runtimeService.loadMetrics();
let metricsRecord = {};
metricsList.forEach((metric) => metricsRecord = { ...metricsRecord, [metric.name]: metric });
setMetrics(metricsRecord);
};
readMetrics();
const registerMetricsRequests = async () => {
const metricsRecord = {};
await runtimeService.registerMetrics((metric) => {
metricsRecord[metric.name] = metric;
});
setMetrics(metricsRecord);
};
registerMetricsRequests();
return () => runtimeService.unregisterAll();
}, []);
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.Grid, { hasGutter: true, span: 6, children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.GridItem, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.Card, { isCompact: true, children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Title, { headingLevel: "h2", children: "System" }) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.CardBody, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionList, { children: Object.values(metrics).filter((m) => m.type === "System").map((metric, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.DescriptionListGroup, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionListTerm, { children: metric.name }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.DescriptionListDescription, { children: [
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { children: [
metric.value ? String(_chunkBJ6TSPQKjs.roundNumber.call(void 0, metric.value, 2)) : metric.value,
" ",
_nullishCoalesce(metric.unit, () => ( "")),
metric.available && ` of ${String(_chunkBJ6TSPQKjs.roundNumber.call(void 0, metric.available, 2))} ${_nullishCoalesce(_nullishCoalesce(metric.availableUnit, () => ( metric.unit)), () => ( ""))}`
] }),
metric.chart && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_victory.ChartBullet,
{
ariaDesc: metric.chartUnit,
ariaTitle: metric.chartValue + " " + metric.chartUnit,
comparativeWarningMeasureData: [
{ name: "Warning", y: 0.9 * metric.chartAvailable }
],
constrainToVisibleArea: true,
maxDomain: { y: metric.chartAvailable },
name: metric.name,
primarySegmentedMeasureData: [{ name: metric.chartUnit, y: metric.chartValue }],
width: 600
}
)
] })
] }, index)) }) })
] }) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.GridItem, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.Card, { isCompact: true, children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.CardHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Title, { headingLevel: "h2", children: "JVM" }) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.CardBody, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionList, { children: Object.values(metrics).filter((m) => m.type === "JVM").map((metric, index) => {
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.DescriptionListGroup, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DescriptionListTerm, { children: metric.name }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.DescriptionListDescription, { children: [
metric.value ? String(_chunkBJ6TSPQKjs.roundNumber.call(void 0, metric.value, 2)) : metric.value,
" ",
_nullishCoalesce(metric.unit, () => ( "")),
metric.available && ` of ${String(_chunkBJ6TSPQKjs.roundNumber.call(void 0, metric.available, 2))} ${_nullishCoalesce(_nullishCoalesce(metric.availableUnit, () => ( metric.unit)), () => ( ""))}`
] })
] }, index);
}) }) })
] }) })
] });
};
// src/plugins/runtime/Runtime.tsx
var _reactrouterdom = require('react-router-dom');
// src/plugins/runtime/SysProps.tsx
var SysProps = () => {
const [properties, setProperties] = _react.useState.call(void 0, []);
_react.useEffect.call(void 0, () => {
runtimeService.loadSystemProperties().then((props) => {
setProperties(props);
});
}, []);
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_chunkOJIIWKORjs.FilteredTable,
{
tableColumns: [
{
name: "Property Name",
key: "key",
percentageWidth: 20
},
{
name: "Property Value",
key: "value",
percentageWidth: 80
}
],
rows: properties,
searchCategories: [
{
name: "Name",
key: "key"
},
{
name: "Value",
key: "value"
}
]
}
);
};
// src/plugins/runtime/Threads.tsx
var _deprecated = require('@patternfly/react-core/deprecated');
// src/plugins/runtime/ThreadInfoModal.tsx
var ThreadState = ({ state }) => {
switch (state) {
case "RUNNABLE":
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Label, { color: "green", children: state });
case "WAITING":
case "TIMED_WAITING":
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Label, { color: "orange", children: state });
default:
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Label, { color: "grey", children: state });
}
};
var ThreadInfoModal = ({ thread, isOpen, setIsOpen }) => {
if (!thread) {
return null;
}
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_deprecated.Modal,
{
bodyAriaLabel: "Thread Details",
tabIndex: 0,
variant: _deprecated.ModalVariant.medium,
title: "Thread details",
isOpen,
onClose: () => setIsOpen(false),
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.Grid, { hasGutter: true, children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomItem, { itemName: "ID", itemValue: thread.threadId }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomItem, { itemName: "State", itemValue: thread.threadState }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomItem, { itemName: "Name", itemValue: thread.threadName }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomItem, { itemName: "Native", itemValue: thread.inNative ? "Yes" : "No" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomItem, { itemName: "Suspended", itemValue: thread.suspended ? "Yes" : "No" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomItem, { itemName: "Waited Count", itemValue: thread.waitedCount }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomItem, { itemName: "Waited Time", itemValue: thread.waitedTime }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomItem, { itemName: "Blocked Count", itemValue: thread.blockedCount }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomItem, { itemName: "Blocked Time", itemValue: thread.blockedTime }),
thread.lockInfo && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomItem, { itemName: "Lock Name", itemValue: thread.lockInfo.lockName }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomItem, { itemName: "Lock Class Name", itemValue: thread.lockInfo.className }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomItem, { itemName: "Identity Hash Code", itemValue: thread.lockInfo.identityHashCode })
] }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomItem, { itemName: "Waiting for lock owned by", itemValue: thread.lockOwnerId }),
thread.lockedSynchronizers && thread.lockedSynchronizers.length > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.GridItem, { span: 3, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "i", { children: "Locked Synchronizers" }) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.GridItem, { span: 9, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: thread.lockedSynchronizers.map((synchronizer) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { title: "Class Name", children: synchronizer.className }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { title: "Identity Hash Code", children: synchronizer.identityHashCode })
] })) }) })
] }),
thread.lockedMonitors && thread.lockedMonitors.length > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.GridItem, { span: 3, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "i", { children: "Locked Monitors" }) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.GridItem, { span: 9, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ol", { children: thread.lockedMonitors.map((monitor, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { children: [
"Frame: ",
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "strong", { children: monitor.lockedStackDepth }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { color: "#4cb140" }, children: monitor.lockedStackFrame.className }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "strong", { children: "." }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "strong", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { color: "#519de9" }, children: monitor.lockedStackFrame.methodName }) }),
"(",
monitor.lockedStackFrame.fileName,
monitor.lockedStackFrame.lineNumber > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { children: [
":",
monitor.lockedStackFrame.lineNumber
] }),
monitor.lockedStackFrame.nativeMethod && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { color: "orange" }, children: "(Native)" })
] }, "monitor-key-" + index)) }) })
] }),
thread.stackTrace.length > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.GridItem, { span: 2, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "i", { children: "Stack Trace" }) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.GridItem, { span: 10, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ol", { children: thread.stackTrace.map((frame, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { color: "#4cb140" }, children: frame.className }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "strong", { children: "." }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "strong", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { color: "#519de9" }, children: frame.methodName }) }),
"(",
frame.fileName,
" ",
frame.lineNumber > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { children: [
":",
frame.lineNumber
] }),
")",
frame.nativeMethod && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { color: "orange" }, children: "(Native)" })
] }, "stacktrace-" + index)) }) })
] })
] })
}
);
};
var CustomItem = ({ itemName, itemValue }) => {
if (!itemValue) {
return null;
}
if (typeof itemValue === "number" && itemValue < 0) {
return null;
}
if (typeof itemValue === "string" && itemValue === "") {
return null;
}
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.GridItem, { span: 3, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "i", { children: itemName }) }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.GridItem, { span: 9, children: [
" ",
itemName === "State" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadState, { state: itemValue }) : itemValue
] })
] });
};
// src/plugins/runtime/Threads.tsx
var ThreadsDumpModal = ({ isOpen, setIsOpen }) => {
const [threadsDump, setThreadsDump] = _react.useState.call(void 0, "");
_react.useEffect.call(void 0, () => {
if (!isOpen) {
return;
}
const readThreadDump = async () => {
const threadsDump2 = await runtimeService.dumpThreads();
setThreadsDump(threadsDump2);
};
readThreadDump();
}, [isOpen]);
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_deprecated.Modal,
{
bodyAriaLabel: "Thread Dump",
tabIndex: 0,
isOpen,
variant: "large",
title: "Thread Dump",
onClose: () => setIsOpen(false),
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.CodeBlock, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.CodeBlockCode, { children: threadsDump }) })
}
);
};
var Threads = () => {
const [threads, setThreads] = _react.useState.call(void 0, []);
const [currentThread, setCurrentThread] = _react.useState.call(void 0, );
const [isThreadsDumpModalOpen, setIsThreadsDumpModalOpen] = _react.useState.call(void 0, false);
const [isThreadDetailsOpen, setIsThreadDetailsOpen] = _react.useState.call(void 0, false);
const [threadConnectionMonitoring, setThreadConnectionMonitoring] = _react.useState.call(void 0, false);
_react.useEffect.call(void 0, () => {
const readThreads = async () => {
const threads2 = await runtimeService.loadThreads();
setThreads(threads2);
setThreadConnectionMonitoring(await runtimeService.isThreadContentionMonitoringEnabled());
runtimeService.registerLoadThreadsRequest((newThreads) => {
setThreads(newThreads);
});
};
readThreads();
return () => runtimeService.unregisterAll();
}, []);
const onThreadDumpClick = () => {
setIsThreadsDumpModalOpen(true);
};
const handleConnectionThreadMonitoring = async () => {
await runtimeService.enableThreadContentionMonitoring(!threadConnectionMonitoring);
setThreadConnectionMonitoring(!threadConnectionMonitoring);
};
const DetailsButton = (thread) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_reactcore.Button,
{
onClick: (_event) => {
setIsThreadDetailsOpen(true);
setCurrentThread(thread);
},
size: "sm",
variant: "link",
children: "Details"
}
);
const ExtraToolBar = () => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.ToolbarGroup, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.ToolbarItem, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.Button, { variant: "primary", onClick: handleConnectionThreadMonitoring, size: "sm", children: [
threadConnectionMonitoring ? "Disable" : "Enable",
" connection thread monitoring"
] }) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.ToolbarItem, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Button, { variant: "secondary", onClick: onThreadDumpClick, size: "sm", children: "Thread dump" }) })
] });
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react2.default.Fragment, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadsDumpModal, { isOpen: isThreadsDumpModalOpen, setIsOpen: setIsThreadsDumpModalOpen }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadInfoModal, { isOpen: isThreadDetailsOpen, thread: currentThread, setIsOpen: setIsThreadDetailsOpen }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_chunkOJIIWKORjs.FilteredTable,
{
tableColumns: [
{ key: "threadId", name: "ID", percentageWidth: 10 },
{ key: "threadState", name: "State", percentageWidth: 10 },
{ key: "threadName", name: "Name", percentageWidth: 30 },
{ key: "waitedTime", name: "Waited Time", percentageWidth: 10 },
{ key: "blockedTime", name: "Blocked Time", percentageWidth: 10 },
{ key: "inNative", name: "Native", percentageWidth: 10 },
{ key: "suspended", name: "Suspended", percentageWidth: 10 },
{ renderer: DetailsButton, percentageWidth: 10 }
],
searchCategories: [
{
name: "Name",
key: "threadName"
},
{
name: "State",
key: "threadState"
}
],
rows: threads,
extraToolbarRight: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ExtraToolBar, {})
}
)
] });
};
// src/plugins/runtime/Runtime.tsx
var Runtime = () => {
const location = _reactrouterdom.useLocation.call(void 0, );
const navItems = [
{ id: "sysprops", title: "System properties", component: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SysProps, {}) },
{ id: "metrics", title: "Metrics", component: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Metrics, {}) },
{ id: "threads", title: "Threads", component: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Threads, {}) }
];
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react2.default.Fragment, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.PageSection, { hasBodyWrapper: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Title, { headingLevel: "h1", children: "Runtime" }) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.PageGroup, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.PageSection, { type: "tabs", hasBodyWrapper: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Nav, { "aria-label": "Runtime Nav", variant: "horizontal-subnav", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.NavList, { children: navItems.map(({ id, title }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.NavItem, { isActive: location.pathname === `/runtime/${id}`, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactrouterdom.NavLink, { to: id, children: title }) }, id)) }) }) }) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.PageSection, { padding: { default: "noPadding" }, hasBodyWrapper: false, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactrouterdom.Routes, { children: [
navItems.map(({ id, component }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactrouterdom.Route, { path: id, element: component }, id)),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactrouterdom.Route, { path: "/", element: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactrouterdom.Navigate, { to: "sysprops" }) })
] }) })
] });
};
exports.Metrics = Metrics; exports.Runtime = Runtime; exports.ThreadInfoModal = ThreadInfoModal; exports.ThreadState = ThreadState; exports.Threads = Threads;
//# sourceMappingURL=ui-34P6E3UU.js.map