import * as React from 'react'; import './index.less'; import Url from 'lib/url-parser'; import { observer } from 'mobx-react'; import { topic, IRealConsumeDetail, ITopicBaseInfo, IRealTimeTraffic } from 'store/topic'; import { Table, Tooltip, Icon, PageHeader, Descriptions, Spin, Switch } from 'component/antd'; import { ILabelValue } from 'types/base-type'; import { copyString, transMSecondToHour } from 'lib/utils'; import moment from 'moment'; import { StatusGraghCom } from 'component/flow-table'; import { renderTrafficTable } from 'container/network-flow'; import { timeFormat, indexUrl } from 'constants/strategy'; interface IInfoProps { baseInfo: ITopicBaseInfo; } @observer export class BaseInformation extends React.Component { public clusterId: number; public topicName: string; public percentile: string; constructor(props: any) { super(props); const url = Url(); this.clusterId = Number(url.search.clusterId); this.topicName = url.search.topic; this.percentile = "75thPercentile"; } public updateRealStatus = () => { topic.getRealTimeTraffic(this.clusterId, this.topicName); } public updateConsumeStatus = () => { topic.getRealConsume(this.clusterId, this.topicName, this.percentile); } public onSwitch = (val: boolean) => { this.percentile = val ? '99thPercentile' : "75thPercentile" topic.getRealConsume(this.clusterId, this.topicName, this.percentile); } public fillBaseInfo() { const { baseInfo } = this.props; const createTime = moment(baseInfo.createTime).format(timeFormat); const modifyTime = moment(baseInfo.modifyTime).format(timeFormat); const retentionTime = transMSecondToHour(baseInfo.retentionTime); if (baseInfo) { const infoList: ILabelValue[] = [{ label: '健康分', value: baseInfo.score, }, { label: '分区数', value: baseInfo.partitionNum, }, { label: '副本数', value: baseInfo.replicaNum, }, { label: '存储时间', value: `${retentionTime} 小时`, }, { label: '创建时间', value: createTime, }, { label: '更改时间', value: modifyTime, }, { label: '压缩格式', value: baseInfo.topicCodeC, }, { label: '集群ID', value: baseInfo.clusterId, }, { label: '所属region', value: baseInfo.regionNameList && baseInfo.regionNameList.join(','), }]; const infoHide: ILabelValue[] = [{ label: 'Bootstrap Severs', value: baseInfo.bootstrapServers, }, { label: 'Topic说明', value: baseInfo.description, }]; return ( <>
基本信息
{baseInfo.appName} copyString(baseInfo.principals)} type="copy" className="didi-theme overview-theme" /> {baseInfo.principals} {infoList.map((item: ILabelValue, index: number) => ( {item.value} ))} {infoHide.map((item: ILabelValue, index: number) => ( copyString(item.value)} type="copy" className="didi-theme overview-theme" /> {item.value} ))} ); } } public realTimeTraffic() { const realTraffic = topic.realTraffic; if (realTraffic) { return ( <> {renderTrafficTable(this.updateRealStatus, StatusGragh)} ); } } public realTimeConsume() { const consumeColumns = [{ title: ' ', dataIndex: 'metricsName', key: 'metricsName', }, { title: 'RequestQueueTime', dataIndex: 'requestQueueTimeMs', key: 'requestQueueTimeMs', render: (t: number) => t === null ? '' : (t ? t.toFixed(2) : 0), }, { title: 'LocalTime', dataIndex: 'localTimeMs', key: 'localTimeMs', render: (t: number) => t === null ? '' : (t ? t.toFixed(2) : 0), }, { title: 'RemoteTime', dataIndex: 'remoteTimeMs', key: 'remoteTimeMs', render: (t: number) => t === null ? '' : (t ? t.toFixed(2) : 0), }, { title: 'ThrottleTime', dataIndex: 'throttleTimeMs', key: 'throttleTimeMs', render: (t: number) => t === null ? '' : (t ? t.toFixed(2) : 0), }, { title: 'ResponseQueueTime', dataIndex: 'responseQueueTimeMs', key: 'responseQueueTimeMs', render: (t: number) => t === null ? '' : (t ? t.toFixed(2) : 0), }, { title: 'ResponseSendTime', dataIndex: 'responseSendTimeMs', key: 'responseSendTimeMs', render: (t: number) => t === null ? '' : (t ? t.toFixed(2) : 0), }, { title: 'TotalTime', dataIndex: 'totalTimeMs', key: 'totalTimeMs', render: (t: number) => t === null ? '' : (t ? t.toFixed(2) : 0), }]; const realConsume = topic.realConsume; if (realConsume) { const consumeData: IRealConsumeDetail[] = []; Object.keys(realConsume).map((key: string) => { if (realConsume[key]) { realConsume[key].metricsName = (key === '0') ? 'Produce' : 'Fetch'; consumeData.push(realConsume[key]); } }); return ( <>
实时耗时 指标说明 默认展示75分位数据,点击开启99分位数据 刷新
); } } public componentDidMount() { topic.getRealTimeTraffic(this.clusterId, this.topicName); topic.getRealConsume(this.clusterId, this.topicName, this.percentile); } public render() { return ( <>
{this.fillBaseInfo()} {this.realTimeTraffic()} {this.realTimeConsume()}
); } } @observer export class StatusGragh extends StatusGraghCom { public getData = () => { return topic.realTraffic; } public getLoading = () => { return topic.realLoading; } }