import React from 'react'; import { ClusterName } from 'redux/interfaces'; import useInterval from 'lib/hooks/useInterval'; import BytesFormatted from 'components/common/BytesFormatted/BytesFormatted'; import { useParams } from 'react-router'; 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 { fetchBrokers, fetchClusterStats, selectStats, } from 'redux/reducers/brokers/brokersSlice'; const Brokers: React.FC = () => { const dispatch = useAppDispatch(); const { clusterName } = useParams<{ clusterName: ClusterName }>(); const { brokerCount, activeControllers, onlinePartitionCount, offlinePartitionCount, inSyncReplicasCount, outOfSyncReplicasCount, underReplicatedPartitionCount, diskUsage, version, items, } = useAppSelector(selectStats); const replicas = inSyncReplicasCount ?? 0 + (outOfSyncReplicasCount ?? 0); const areAllInSync = inSyncReplicasCount && replicas === inSyncReplicasCount; React.useEffect(() => { dispatch(fetchClusterStats(clusterName)); dispatch(fetchBrokers(clusterName)); }, [clusterName, dispatch]); useInterval(() => { fetchClusterStats(clusterName); fetchBrokers(clusterName); }, 5000); return ( <> {brokerCount} {activeControllers} {version} 0 ? 'error' : 'success' } > {offlinePartitionCount && offlinePartitionCount > 0 ? ( {onlinePartitionCount} ) : ( onlinePartitionCount )} {' '} of {(onlinePartitionCount || 0) + (offlinePartitionCount || 0)} {underReplicatedPartitionCount === 0 ? ( {underReplicatedPartitionCount} ) : ( {underReplicatedPartitionCount} )} {areAllInSync ? ( replicas ) : ( {inSyncReplicasCount} )} of {replicas} {outOfSyncReplicasCount} {(!diskUsage || diskUsage.length === 0) && ( )} {diskUsage && diskUsage.length !== 0 && diskUsage.map(({ brokerId, segmentSize, segmentCount }) => ( ))}
Disk usage data not available
{brokerId} {segmentCount} {items && items[brokerId]?.port} {items && items[brokerId]?.host}
); }; export default Brokers;