Skip to content

Commit 6dbe0b4

Browse files
committed
fix(Overview): display table r/o replicas
1 parent 1a35cfc commit 6dbe0b4

File tree

3 files changed

+72
-4
lines changed

3 files changed

+72
-4
lines changed

src/containers/Tenant/Schema/SchemaInfoViewer/SchemaInfoViewer.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ const formatTabletMetricsItem = createInfoFormatter({
2121
defaultValueFormatter: formatNumber,
2222
});
2323

24+
const formatFollowerGroupItem = createInfoFormatter({
25+
values: {
26+
FollowerCount: formatNumber,
27+
},
28+
});
29+
30+
const formatPartitionConfigItem = createInfoFormatter({
31+
values: {
32+
FollowerCount: formatNumber,
33+
CrossDataCenterFollowerCount: formatNumber,
34+
},
35+
});
36+
2437
const formatTableStatsItem = createInfoFormatter({
2538
values: {
2639
DataSize: formatBytes,
@@ -57,7 +70,7 @@ class SchemaInfoViewer extends React.Component {
5770

5871
renderContent(data) {
5972
const {PathDescription = {}} = data;
60-
const {TableStats = {}, TabletMetrics = {}} = PathDescription;
73+
const {TableStats = {}, TabletMetrics = {}, Table: {PartitionConfig = {}} = {}} = PathDescription;
6174
const {
6275
PartCount,
6376
RowCount,
@@ -82,6 +95,7 @@ class SchemaInfoViewer extends React.Component {
8295

8396
...restTableStats
8497
} = TableStats;
98+
const {FollowerGroups, FollowerCount, CrossDataCenterFollowerCount} = PartitionConfig;
8599

86100
const tableStatsInfo = [
87101
formatTableStats({
@@ -116,8 +130,25 @@ class SchemaInfoViewer extends React.Component {
116130
formatTabletMetricsItem(key, TabletMetrics[key])
117131
);
118132

133+
const partitionConfigInfo = [];
134+
135+
if (Array.isArray(FollowerGroups) && FollowerGroups.length > 0) {
136+
partitionConfigInfo.push(...Object.keys(FollowerGroups[0]).map((key) =>
137+
formatFollowerGroupItem(key, FollowerGroups[0][key])
138+
));
139+
} else if (FollowerCount !== undefined) {
140+
partitionConfigInfo.push(
141+
formatPartitionConfigItem('FollowerCount', FollowerCount)
142+
);
143+
} else if (CrossDataCenterFollowerCount !== undefined) {
144+
partitionConfigInfo.push(
145+
formatPartitionConfigItem('CrossDataCenterFollowerCount', CrossDataCenterFollowerCount)
146+
);
147+
}
148+
119149
if ([
120150
tabletMetricsInfo,
151+
partitionConfigInfo,
121152
tableStatsInfo.flat(),
122153
].flat().length === 0) {
123154
return (
@@ -127,9 +158,10 @@ class SchemaInfoViewer extends React.Component {
127158

128159
return (
129160
<div className={b('row')}>
130-
{tabletMetricsInfo.length > 0 ? (
161+
{tabletMetricsInfo.length > 0 || partitionConfigInfo.length > 0 ? (
131162
<div className={b('col')}>
132163
{this.renderItem(tabletMetricsInfo, 'Tablet Metrics')}
164+
{this.renderItem(partitionConfigInfo, 'Partition Config')}
133165
</div>
134166
) : null}
135167
<div className={b('col')}>

src/services/api.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
8383
path,
8484
enums: true,
8585
backup: false,
86-
partition_config: false,
8786
partition_stats: false,
8887
partitioning_info: false,
8988
},

src/types/api/schema.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ interface TPathDescription {
4747
Children?: TDirEntry[];
4848

4949
// for table
50-
Table?: unknown;
50+
Table?: TTableDescription;
5151
TableStats?: TTableStats;
5252
TabletMetrics?: unknown;
5353
TablePartitions?: unknown[];
@@ -82,6 +82,43 @@ interface TDirEntry {
8282
Version?: TPathVersion;
8383
}
8484

85+
// incomplete
86+
export interface TTableDescription {
87+
PartitionConfig?: TPartitionConfig;
88+
}
89+
90+
// incomplete
91+
export interface TPartitionConfig {
92+
/** uint64 */
93+
FollowerCount?: string;
94+
/**
95+
* uint32
96+
* @deprecated use FollowerGroups
97+
*/
98+
CrossDataCenterFollowerCount?: string;
99+
/** 0 or 1 items */
100+
FollowerGroups?: TFollowerGroup[];
101+
}
102+
103+
export interface TFollowerGroup {
104+
/** uint32 */
105+
FollowerCount?: string;
106+
AllowLeaderPromotion?: boolean;
107+
AllowClientRead?: boolean;
108+
/** uint32[] */
109+
AllowedNodeIDs?: string[];
110+
/**
111+
* uint32[]
112+
* @deprecated use AllowedDataCenters
113+
*/
114+
AllowedDataCenterNumIDs?: string[];
115+
RequireAllDataCenters?: boolean;
116+
LocalNodeOnly?: boolean;
117+
RequireDifferentNodes?: boolean;
118+
FollowerCountPerDataCenter?: boolean; // multiplies FollowerCount by number of DataCenters
119+
AllowedDataCenters?: string[];
120+
}
121+
85122
interface TTableStats {
86123
/** uint64 */
87124
DataSize?: string;

0 commit comments

Comments
 (0)