|
@@ -1,146 +1,29 @@
|
|
import React from 'react';
|
|
import React from 'react';
|
|
-import useInterval from 'lib/hooks/useInterval';
|
|
|
|
-import BytesFormatted from 'components/common/BytesFormatted/BytesFormatted';
|
|
|
|
-import TableHeaderCell from 'components/common/table/TableHeaderCell/TableHeaderCell';
|
|
|
|
-import { Table } from 'components/common/table/Table/Table.styled';
|
|
|
|
-import PageHeading from 'components/common/PageHeading/PageHeading';
|
|
|
|
-import * as Metrics from 'components/common/Metrics';
|
|
|
|
-import { useAppDispatch, useAppSelector } from 'lib/hooks/redux';
|
|
|
|
-import { ClusterNameRoute } from 'lib/paths';
|
|
|
|
-import {
|
|
|
|
- fetchBrokers,
|
|
|
|
- fetchClusterStats,
|
|
|
|
- selectStats,
|
|
|
|
-} from 'redux/reducers/brokers/brokersSlice';
|
|
|
|
-import useAppParams from 'lib/hooks/useAppParams';
|
|
|
|
|
|
+import { Route, Routes } from 'react-router-dom';
|
|
|
|
+import { getNonExactPath, RouteParams } from 'lib/paths';
|
|
|
|
+import BrokersList from 'components/Brokers/List/BrokersList';
|
|
|
|
+import Broker from 'components/Brokers/Broker/Broker';
|
|
|
|
+import { BreadcrumbRoute } from 'components/common/Breadcrumb/Breadcrumb.route';
|
|
|
|
|
|
-const Brokers: React.FC = () => {
|
|
|
|
- const dispatch = useAppDispatch();
|
|
|
|
- const { clusterName } = useAppParams<ClusterNameRoute>();
|
|
|
|
- const {
|
|
|
|
- brokerCount,
|
|
|
|
- activeControllers,
|
|
|
|
- onlinePartitionCount,
|
|
|
|
- offlinePartitionCount,
|
|
|
|
- inSyncReplicasCount,
|
|
|
|
- outOfSyncReplicasCount,
|
|
|
|
- underReplicatedPartitionCount,
|
|
|
|
- diskUsage,
|
|
|
|
- version,
|
|
|
|
- items,
|
|
|
|
- } = useAppSelector(selectStats);
|
|
|
|
-
|
|
|
|
- const replicas = (inSyncReplicasCount ?? 0) + (outOfSyncReplicasCount ?? 0);
|
|
|
|
- const areAllInSync = inSyncReplicasCount && replicas === inSyncReplicasCount;
|
|
|
|
- const partitionIsOffline = offlinePartitionCount && offlinePartitionCount > 0;
|
|
|
|
- React.useEffect(() => {
|
|
|
|
- dispatch(fetchClusterStats(clusterName));
|
|
|
|
- dispatch(fetchBrokers(clusterName));
|
|
|
|
- }, [clusterName, dispatch]);
|
|
|
|
-
|
|
|
|
- useInterval(() => {
|
|
|
|
- fetchClusterStats(clusterName);
|
|
|
|
- fetchBrokers(clusterName);
|
|
|
|
- }, 5000);
|
|
|
|
-
|
|
|
|
- return (
|
|
|
|
- <>
|
|
|
|
- <PageHeading text="Brokers" />
|
|
|
|
- <Metrics.Wrapper>
|
|
|
|
- <Metrics.Section title="Uptime">
|
|
|
|
- <Metrics.Indicator label="Total Brokers">
|
|
|
|
- {brokerCount}
|
|
|
|
- </Metrics.Indicator>
|
|
|
|
- <Metrics.Indicator label="Active Controllers">
|
|
|
|
- {activeControllers}
|
|
|
|
- </Metrics.Indicator>
|
|
|
|
- <Metrics.Indicator label="Version">{version}</Metrics.Indicator>
|
|
|
|
- </Metrics.Section>
|
|
|
|
- <Metrics.Section title="Partitions">
|
|
|
|
- <Metrics.Indicator
|
|
|
|
- label="Online"
|
|
|
|
- isAlert
|
|
|
|
- alertType={partitionIsOffline ? 'error' : 'success'}
|
|
|
|
- >
|
|
|
|
- {partitionIsOffline ? (
|
|
|
|
- <Metrics.RedText>{onlinePartitionCount}</Metrics.RedText>
|
|
|
|
- ) : (
|
|
|
|
- onlinePartitionCount
|
|
|
|
- )}
|
|
|
|
- <Metrics.LightText>
|
|
|
|
- {' '}
|
|
|
|
- of {(onlinePartitionCount || 0) + (offlinePartitionCount || 0)}
|
|
|
|
- </Metrics.LightText>
|
|
|
|
- </Metrics.Indicator>
|
|
|
|
- <Metrics.Indicator
|
|
|
|
- label="URP"
|
|
|
|
- title="Under replicated partitions"
|
|
|
|
- isAlert
|
|
|
|
- alertType={!underReplicatedPartitionCount ? 'success' : 'error'}
|
|
|
|
- >
|
|
|
|
- {!underReplicatedPartitionCount ? (
|
|
|
|
- <Metrics.LightText>
|
|
|
|
- {underReplicatedPartitionCount}
|
|
|
|
- </Metrics.LightText>
|
|
|
|
- ) : (
|
|
|
|
- <Metrics.RedText>{underReplicatedPartitionCount}</Metrics.RedText>
|
|
|
|
- )}
|
|
|
|
- </Metrics.Indicator>
|
|
|
|
- <Metrics.Indicator
|
|
|
|
- label="In Sync Replicas"
|
|
|
|
- isAlert
|
|
|
|
- alertType={areAllInSync ? 'success' : 'error'}
|
|
|
|
- >
|
|
|
|
- {areAllInSync ? (
|
|
|
|
- replicas
|
|
|
|
- ) : (
|
|
|
|
- <Metrics.RedText>{inSyncReplicasCount}</Metrics.RedText>
|
|
|
|
- )}
|
|
|
|
- <Metrics.LightText> of {replicas}</Metrics.LightText>
|
|
|
|
- </Metrics.Indicator>
|
|
|
|
- <Metrics.Indicator label="Out Of Sync Replicas">
|
|
|
|
- {outOfSyncReplicasCount}
|
|
|
|
- </Metrics.Indicator>
|
|
|
|
- </Metrics.Section>
|
|
|
|
- </Metrics.Wrapper>
|
|
|
|
- <Table isFullwidth>
|
|
|
|
- <thead>
|
|
|
|
- <tr>
|
|
|
|
- <TableHeaderCell title="Broker" />
|
|
|
|
- <TableHeaderCell title="Segment Size (Mb)" />
|
|
|
|
- <TableHeaderCell title="Segment Count" />
|
|
|
|
- <TableHeaderCell title="Port" />
|
|
|
|
- <TableHeaderCell title="Host" />
|
|
|
|
- </tr>
|
|
|
|
- </thead>
|
|
|
|
- <tbody>
|
|
|
|
- {(!diskUsage || diskUsage.length === 0) && (
|
|
|
|
- <tr>
|
|
|
|
- <td colSpan={10}>Disk usage data not available</td>
|
|
|
|
- </tr>
|
|
|
|
- )}
|
|
|
|
-
|
|
|
|
- {diskUsage &&
|
|
|
|
- diskUsage.length !== 0 &&
|
|
|
|
- diskUsage.map(({ brokerId, segmentSize, segmentCount }) => {
|
|
|
|
- const brokerItem = items?.find((item) => item.id === brokerId);
|
|
|
|
-
|
|
|
|
- return (
|
|
|
|
- <tr key={brokerId}>
|
|
|
|
- <td>{brokerId}</td>
|
|
|
|
- <td>
|
|
|
|
- <BytesFormatted value={segmentSize} />
|
|
|
|
- </td>
|
|
|
|
- <td>{segmentCount}</td>
|
|
|
|
- <td>{brokerItem?.port}</td>
|
|
|
|
- <td>{brokerItem?.host}</td>
|
|
|
|
- </tr>
|
|
|
|
- );
|
|
|
|
- })}
|
|
|
|
- </tbody>
|
|
|
|
- </Table>
|
|
|
|
- </>
|
|
|
|
- );
|
|
|
|
-};
|
|
|
|
|
|
+const Brokers: React.FC = () => (
|
|
|
|
+ <Routes>
|
|
|
|
+ <Route
|
|
|
|
+ index
|
|
|
|
+ element={
|
|
|
|
+ <BreadcrumbRoute>
|
|
|
|
+ <BrokersList />
|
|
|
|
+ </BreadcrumbRoute>
|
|
|
|
+ }
|
|
|
|
+ />
|
|
|
|
+ <Route
|
|
|
|
+ path={getNonExactPath(RouteParams.brokerId)}
|
|
|
|
+ element={
|
|
|
|
+ <BreadcrumbRoute>
|
|
|
|
+ <Broker />
|
|
|
|
+ </BreadcrumbRoute>
|
|
|
|
+ }
|
|
|
|
+ />
|
|
|
|
+ </Routes>
|
|
|
|
+);
|
|
|
|
|
|
export default Brokers;
|
|
export default Brokers;
|