Skip to content

Commit

Permalink
feat(frontend): 资源池统计视图 #6519
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 17883
  • Loading branch information
JustaCattt authored and jinquantianxia committed Sep 10, 2024
1 parent ed68220 commit b4b2f19
Show file tree
Hide file tree
Showing 15 changed files with 261 additions and 835 deletions.
177 changes: 173 additions & 4 deletions dbm-ui/frontend/src/common/const/clusterTypeInfos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@ import { t } from '@locales/index';

import { ClusterTypes } from './clusterTypes';
import { DBTypes } from './dbTypes';
import { MachineTypes } from './machineTypes';

interface InfoItem {
export interface ClusterTypeInfoItem {
id: ClusterTypes;
name: string;
dbType: DBTypes;
moduleId: ExtractedControllerDataKeys;
machineList: {
id: MachineTypes;
name: string;
}[];
}
type InfoType = {
[x in ClusterTypes]?: InfoItem;
[x in ClusterTypes]?: ClusterTypeInfoItem;
};
type RequiredInfoType = {
[x in ClusterTypes]: InfoItem;
[x in ClusterTypes]: ClusterTypeInfoItem;
};

const mysql: InfoType = {
Expand All @@ -24,18 +29,47 @@ const mysql: InfoType = {
name: t('MySQL单节点'),
dbType: DBTypes.MYSQL,
moduleId: 'mysql',
machineList: [
{
id: MachineTypes.SINGLE,
name: t('后端存储机型'),
},
],
},
[ClusterTypes.TENDBHA]: {
id: ClusterTypes.TENDBHA,
name: t('MySQL主从'),
dbType: DBTypes.MYSQL,
moduleId: 'mysql',
machineList: [
{
id: MachineTypes.BACKEND,
name: t('后端存储机型'),
},
{
id: MachineTypes.PROXY,
name: t('Proxy机型'),
},
],
},
};

const spider: InfoType = {
[ClusterTypes.TENDBCLUSTER]: {
id: ClusterTypes.TENDBCLUSTER,
name: 'TenDBCluster',
dbType: DBTypes.MYSQL,
dbType: DBTypes.TENDBCLUSTER,
moduleId: 'mysql',
machineList: [
{
id: MachineTypes.SPIDER,
name: t('接入层Master'),
},
{
id: MachineTypes.REMOTE,
name: t('后端存储规格'),
},
],
},
};

Expand All @@ -45,30 +79,76 @@ const redis: InfoType = {
name: 'TendisCache',
dbType: DBTypes.REDIS,
moduleId: 'redis',
machineList: [
{
id: MachineTypes.TENDISCACHE,
name: t('后端存储机型'),
},
{
id: MachineTypes.TWEMPROXY,
name: t('Proxy机型'),
},
],
},
[ClusterTypes.TWEMPROXY_TENDIS_SSD_INSTANCE]: {
id: ClusterTypes.TWEMPROXY_TENDIS_SSD_INSTANCE,
name: 'TendisSSD',
dbType: DBTypes.REDIS,
moduleId: 'redis',
machineList: [
{
id: MachineTypes.TENDISSSD,
name: t('后端存储机型'),
},
{
id: MachineTypes.TWEMPROXY,
name: t('Proxy机型'),
},
],
},
[ClusterTypes.PREDIXY_TENDISPLUS_CLUSTER]: {
id: ClusterTypes.PREDIXY_TENDISPLUS_CLUSTER,
name: 'Tendisplus',
dbType: DBTypes.REDIS,
moduleId: 'redis',
machineList: [
{
id: MachineTypes.TENDISPLUS,
name: t('后端存储机型'),
},
{
id: MachineTypes.PREDIXY,
name: t('Proxy机型'),
},
],
},
[ClusterTypes.PREDIXY_REDIS_CLUSTER]: {
id: ClusterTypes.PREDIXY_REDIS_CLUSTER,
name: 'RedisCluster',
dbType: DBTypes.REDIS,
moduleId: 'redis',
machineList: [
{
id: MachineTypes.TENDISCACHE,
name: t('后端存储机型'),
},
{
id: MachineTypes.PREDIXY,
name: t('Proxy机型'),
},
],
},
[ClusterTypes.REDIS_INSTANCE]: {
id: ClusterTypes.REDIS_INSTANCE,
name: t('Redis主从'),
dbType: DBTypes.REDIS,
moduleId: 'redis',
machineList: [
{
id: MachineTypes.TENDISCACHE,
name: t('后端存储机型'),
},
],
},
};

Expand All @@ -78,42 +158,98 @@ const bigdata: InfoType = {
name: 'ES',
dbType: DBTypes.ES,
moduleId: 'bigdata',
machineList: [
{
id: MachineTypes.ES_MASTER,
name: t('Master节点规格'),
},
{
id: MachineTypes.ES_CLIENT,
name: t('Client节点规格'),
},
{
id: MachineTypes.ES_DATANODE,
name: t('冷_热节点规格'),
},
],
},
[ClusterTypes.KAFKA]: {
id: ClusterTypes.KAFKA,
name: 'Kafka',
dbType: DBTypes.KAFKA,
moduleId: 'bigdata',
machineList: [
{
id: MachineTypes.ZOOKEEPER,
name: t('Zookeeper节点规格'),
},
{
id: MachineTypes.BROKER,
name: t('Broker节点规格'),
},
],
},
[ClusterTypes.HDFS]: {
id: ClusterTypes.HDFS,
name: 'HDFS',
dbType: DBTypes.HDFS,
moduleId: 'bigdata',
machineList: [
{
id: MachineTypes.HDFS_DATANODE,
name: t('DataNode节点规格'),
},
{
id: MachineTypes.HDFS_MASTER,
name: t('NameNode_Zookeeper_JournalNode节点规格'),
},
],
},
[ClusterTypes.INFLUXDB]: {
id: ClusterTypes.INFLUXDB,
name: 'InfuxDB',
dbType: DBTypes.INFLUXDB,
moduleId: 'bigdata',
machineList: [
{
id: MachineTypes.INFLUXDB,
name: t('后端存储机型'),
},
],
},
[ClusterTypes.PULSAR]: {
id: ClusterTypes.PULSAR,
name: 'Pulsar',
dbType: DBTypes.PULSAR,
moduleId: 'bigdata',
machineList: [
{
id: MachineTypes.PULSAR_BOOKKEEPER,
name: t('Bookkeeper节点规格'),
},
{
id: MachineTypes.PULSAR_ZOOKEEPER,
name: t('Zookeeper节点规格'),
},
{
id: MachineTypes.PULSAR_BROKER,
name: t('Broker节点规格'),
},
],
},
[ClusterTypes.RIAK]: {
id: ClusterTypes.RIAK,
name: 'Riak',
dbType: DBTypes.RIAK,
moduleId: 'bigdata',
machineList: [],
},
[ClusterTypes.DORIS]: {
id: ClusterTypes.DORIS,
name: 'Doris',
dbType: DBTypes.DORIS,
moduleId: 'bigdata',
machineList: [],
},
};

Expand All @@ -123,12 +259,32 @@ const mongo: InfoType = {
name: t('Mongo副本集'),
dbType: DBTypes.MONGODB,
moduleId: 'mongodb',
machineList: [
{
id: MachineTypes.MONGODB,
name: t('Mongodb规格'),
},
],
},
[ClusterTypes.MONGO_SHARED_CLUSTER]: {
id: ClusterTypes.MONGO_SHARED_CLUSTER,
name: t('Mongo 分片集群'),
dbType: DBTypes.MONGODB,
moduleId: 'mongodb',
machineList: [
{
id: MachineTypes.MONGOS,
name: t('Mongos规格'),
},
{
id: MachineTypes.MONGODB,
name: t('ConfigSvr规格'),
},
{
id: MachineTypes.MONGO_CONFIG,
name: t('ShardSvr规格'),
},
],
},
};

Expand All @@ -138,12 +294,24 @@ const sqlserver: InfoType = {
name: t('SQLServer单节点'),
dbType: DBTypes.SQLSERVER,
moduleId: 'sqlserver',
machineList: [
{
id: MachineTypes.SQLSERVER_SINGLE,
name: t('单节点规格'),
},
],
},
[ClusterTypes.SQLSERVER_HA]: {
id: ClusterTypes.SQLSERVER_HA,
name: t('SQLServer主从'),
dbType: DBTypes.SQLSERVER,
moduleId: 'sqlserver',
machineList: [
{
id: MachineTypes.SQLSERVER_HA,
name: t('主从规格'),
},
],
},
};

Expand All @@ -152,6 +320,7 @@ const sqlserver: InfoType = {
*/
export const clusterTypeInfos: RequiredInfoType = {
...mysql,
...spider,
...redis,
...bigdata,
...mongo,
Expand Down
45 changes: 10 additions & 35 deletions dbm-ui/frontend/src/services/model/db-resource/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@
* the specific language governing permissions and limitations under the License.
*/

import { MachineTypes } from '@common/const';

import { t } from '@locales/index';
import { clusterTypeInfos, ClusterTypes, MachineTypes } from '@common/const';

export default class Summary {
dedicated_biz: number;
for_biz_name: string;
city: string;
spec_id?: number;
spec_name?: string;
spec_cluster_type?: ClusterTypes;
spec_machine_type?: MachineTypes;
device_class?: string;
disk_summary?: string;
Expand All @@ -34,6 +33,7 @@ export default class Summary {
this.city = payload.city;
this.spec_id = payload.spec_id;
this.spec_name = payload.spec_name;
this.spec_cluster_type = payload.spec_cluster_type;
this.spec_machine_type = payload.spec_machine_type;
this.device_class = payload.device_class;
this.disk_summary = payload.disk_summary;
Expand All @@ -46,38 +46,13 @@ export default class Summary {
return `${this.device_class} (${this.disk_summary})`;
}

get spec_machine_display() {
const machineTypeMap: Record<MachineTypes, string> = {
[MachineTypes.SINGLE]: t('后端存储机型'),
[MachineTypes.SPIDER]: t('接入层Master'),
[MachineTypes.REMOTE]: t('后端存储规格'),
[MachineTypes.PROXY]: t('Proxy机型'),
[MachineTypes.BACKEND]: t('后端存储机型'),
[MachineTypes.PREDIXY]: t('Proxy机型'),
[MachineTypes.TWEMPROXY]: t('Proxy机型'),
[MachineTypes.INFLUXDB]: t('后端存储机型'),
[MachineTypes.RIAK]: t('后端存储机型'),
[MachineTypes.BROKER]: t('Broker节点规格'),
[MachineTypes.ZOOKEEPER]: t('Zookeeper节点规格'),
[MachineTypes.REDIS]: t('后端存储机型'),
[MachineTypes.TENDISCACHE]: t('后端存储机型'),
[MachineTypes.TENDISSSD]: t('后端存储机型'),
[MachineTypes.TENDISPLUS]: t('后端存储机型'),
[MachineTypes.ES_DATANODE]: t('冷_热节点规格'),
[MachineTypes.ES_MASTER]: t('Master节点规格'),
[MachineTypes.ES_CLIENT]: t('Client节点规格'),
[MachineTypes.HDFS_MASTER]: t('NameNode_Zookeeper_JournalNode节点规格'),
[MachineTypes.HDFS_DATANODE]: t('DataNode节点规格'),
[MachineTypes.MONGOS]: t('Mongos规格'),
[MachineTypes.MONGODB]: t('ShardSvr规格'),
[MachineTypes.MONGO_CONFIG]: t('ConfigSvr规格'),
[MachineTypes.SQLSERVER_HA]: t('后端存储机型'),
[MachineTypes.SQLSERVER_SINGLE]: t('后端存储机型'),
[MachineTypes.PULSAR_BROKER]: t('Broker节点规格'),
[MachineTypes.PULSAR_BOOKKEEPER]: t('Bookkeeper节点规格'),
[MachineTypes.PULSAR_ZOOKEEPER]: t('Zookeeper节点规格'),
};
return this.spec_machine_type ? machineTypeMap[this.spec_machine_type] : '';
get spec_type_display() {
if (!this.spec_cluster_type || !this.spec_machine_type) {
return '--';
}
const { name, machineList } = clusterTypeInfos[this.spec_cluster_type];
const matchMachine = machineList.find(({ id }) => id === this.spec_machine_type);
return matchMachine ? `${name} - ${matchMachine.name}` : '--';
}

get sub_zone_detail_display() {
Expand Down
Loading

0 comments on commit b4b2f19

Please sign in to comment.