Skip to content

Commit 63d5afd

Browse files
authored
feat: followerId for tablets (#2025)
1 parent 78965ed commit 63d5afd

File tree

7 files changed

+44
-20
lines changed

7 files changed

+44
-20
lines changed

src/components/ShardsTable/columns.tsx

+12-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ export const getPathColumn: GetShardsColumn = ({schemaPath = ''}) => {
1919
name: TOP_SHARDS_COLUMNS_IDS.Path,
2020
header: TOP_SHARDS_COLUMNS_TITLES.Path,
2121
render: ({row}) => {
22-
// row.Path - relative schema path
23-
return <LinkToSchemaObject path={schemaPath + row.Path}>{row.Path}</LinkToSchemaObject>;
22+
// row.RelativePath - relative schema path
23+
return (
24+
<LinkToSchemaObject path={schemaPath + row.RelativePath}>
25+
{row.RelativePath}
26+
</LinkToSchemaObject>
27+
);
2428
},
2529
width: 300,
2630
};
@@ -43,7 +47,12 @@ export const getTabletIdColumn: GetShardsColumn = () => {
4347
if (!row.TabletId) {
4448
return EMPTY_DATA_PLACEHOLDER;
4549
}
46-
return <TabletNameWrapper tabletId={row.TabletId} />;
50+
return (
51+
<TabletNameWrapper
52+
tabletId={row.TabletId}
53+
followerId={row.FollowerId || undefined}
54+
/>
55+
);
4756
},
4857
width: 220,
4958
};

src/components/TabletNameWrapper/TabletNameWrapper.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ import i18n from './i18n';
1111

1212
interface TabletNameWrapperProps {
1313
tabletId: string | number;
14+
followerId?: string | number;
1415
database?: string;
1516
}
1617

17-
export function TabletNameWrapper({tabletId, database}: TabletNameWrapperProps) {
18+
export function TabletNameWrapper({tabletId, followerId, database}: TabletNameWrapperProps) {
1819
const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges();
1920

20-
const tabletPath = getTabletPagePath(tabletId, {database});
21+
const tabletPath = getTabletPagePath(tabletId, {database, followerId: followerId?.toString()});
22+
const tabletName = `${tabletId}${followerId ? `.${followerId}` : ''}`;
2123

2224
return (
2325
<CellWithPopover
@@ -37,7 +39,7 @@ export function TabletNameWrapper({tabletId, database}: TabletNameWrapperProps)
3739
behavior={PopoverBehavior.Immediate}
3840
>
3941
<EntityStatus
40-
name={tabletId.toString()}
42+
name={tabletName}
4143
path={tabletPath}
4244
hasClipboardButton
4345
showStatus={false}

src/containers/Tablet/Tablet.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ export function Tablet() {
6363

6464
const {id} = useParams<{id: string}>();
6565

66-
const [{database: queryDatabase, clusterName: queryClusterName}] =
66+
const [{database: queryDatabase, clusterName: queryClusterName, followerId: queryFollowerId}] =
6767
useQueryParams(tabletPageQueryParams);
6868

6969
const [autoRefreshInterval] = useAutoRefreshInterval();
7070
const {currentData, isFetching, error} = tabletApi.useGetTabletQuery(
71-
{id, database: queryDatabase ?? undefined},
71+
{id, database: queryDatabase ?? undefined, followerId: queryFollowerId ?? undefined},
7272
{pollingInterval: autoRefreshInterval},
7373
);
7474

@@ -131,7 +131,9 @@ function TabletContent({
131131
history: ITabletPreparedHistoryItem[];
132132
}) {
133133
const isEmpty = !Object.keys(tablet).length;
134-
const {Overall, HiveId} = tablet;
134+
const {Overall, HiveId, FollowerId} = tablet;
135+
136+
const tabletName = `${id}${FollowerId ? `.${FollowerId}` : ''}`;
135137

136138
return (
137139
<EmptyStateWrapper
@@ -143,7 +145,7 @@ function TabletContent({
143145
<EntityPageTitle
144146
entityName={i18n('tablet.header')}
145147
status={Overall ?? EFlag.Grey}
146-
id={id}
148+
id={tabletName}
147149
/>
148150
<TabletControls tablet={tablet} />
149151
<TabletInfo tablet={tablet} />

src/containers/Tablets/TabletsTable.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ function getColumns({database}: {database?: string}) {
5353
return EMPTY_DATA_PLACEHOLDER;
5454
}
5555

56-
return <TabletNameWrapper tabletId={row.TabletId} database={database} />;
56+
return (
57+
<TabletNameWrapper
58+
tabletId={row.TabletId}
59+
database={database}
60+
followerId={row.FollowerId || undefined}
61+
/>
62+
);
5763
},
5864
},
5965
{

src/routes.ts

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export const tabletPageQueryParams = {
124124
database: StringParam,
125125
clusterName: StringParam,
126126
activeTab: StringParam,
127+
followerId: StringParam,
127128
} as const;
128129

129130
type TabletPageQuery = QueryParamsTypeFromQueryObject<typeof tabletPageQueryParams>;

src/store/reducers/shardsWorkload/shardsWorkload.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,14 @@ LIMIT 20`;
7070
}
7171

7272
function createShardQueryImmediate(path: string, database: string, sortOrder?: SortOrder[]) {
73-
const pathSelect = `CAST(SUBSTRING(CAST(Path AS String), ${database.length}) AS Utf8) AS Path`;
73+
const pathSelect = `CAST(SUBSTRING(CAST(Path AS String), ${database.length}) AS Utf8) AS RelativePath`;
7474

7575
const orderBy = prepareOrderByFromTableSort(sortOrder);
7676

7777
return `${QUERY_TECHNICAL_MARK}
7878
SELECT
7979
${pathSelect},
80-
TabletId,
81-
CPUCores,
82-
DataSize,
83-
NodeId,
84-
InFlightTxCount
80+
\`.sys/partition_stats\`.*
8581
FROM \`.sys/partition_stats\`
8682
WHERE
8783
Path='${path}'

src/store/reducers/tablet.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ export const tabletApi = api.injectEndpoints({
88
endpoints: (build) => ({
99
getTablet: build.query({
1010
queryFn: async (
11-
{id, database}: {id: string; database?: string; nodeId?: string},
11+
{
12+
id,
13+
database,
14+
followerId,
15+
}: {id: string; database?: string; nodeId?: string; followerId?: string},
1216
{signal},
1317
) => {
1418
try {
@@ -50,8 +54,12 @@ export const tabletApi = api.injectEndpoints({
5054
}, []);
5155

5256
const {TabletStateInfo = []} = tabletResponseData;
53-
const [tabletData = {}] = TabletStateInfo;
54-
const {TabletId} = tabletData;
57+
const tabletData =
58+
followerId === undefined
59+
? TabletStateInfo.find((t) => t.Leader)
60+
: TabletStateInfo.find((t) => t.FollowerId?.toString() === followerId);
61+
62+
const {TabletId} = tabletData || {};
5563

5664
return {data: {id: TabletId, data: tabletData, history: historyData}};
5765
} catch (error) {

0 commit comments

Comments
 (0)