Skip to content

Commit f42474a

Browse files
authored
Merge branch 'main' into astandrik.2024
2 parents a34530f + 74f7a58 commit f42474a

File tree

13 files changed

+179
-48
lines changed

13 files changed

+179
-48
lines changed

src/components/ShardsTable/columns.tsx

Lines changed: 12 additions & 3 deletions
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

Lines changed: 5 additions & 3 deletions
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/AppWithClusters/AppWithClusters.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React from 'react';
33
import type {Store} from '@reduxjs/toolkit';
44
import type {History} from 'history';
55

6+
import {getLogsLink as getLogsLinkDefault} from '../../utils/logs';
67
import type {
78
GetLogsLink,
89
GetMonitoringClusterLink,
@@ -31,7 +32,7 @@ export interface AppWithClustersProps {
3132
export function AppWithClusters({
3233
store,
3334
history,
34-
getLogsLink,
35+
getLogsLink = getLogsLinkDefault,
3536
getMonitoringLink = getMonitoringLinkDefault,
3637
getMonitoringClusterLink = getMonitoringClusterLinkDefault,
3738
userSettings,

src/containers/AppWithClusters/ExtendedCluster/ExtendedCluster.tsx

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,19 @@ const getAdditionalBalancerInfo = (balancer: string) => {
3838
};
3939
};
4040

41-
const getAdditionalClusterProps = (
42-
clusterName: string | undefined,
43-
monitoring: string | undefined,
44-
balancer: string | undefined,
45-
getMonitoringClusterLink?: GetMonitoringClusterLink,
46-
) => {
41+
interface GetAdditionalClusterProps {
42+
clusterName: string | undefined;
43+
monitoring: string | undefined;
44+
balancer: string | undefined;
45+
getMonitoringClusterLink?: GetMonitoringClusterLink;
46+
}
47+
48+
const getAdditionalClusterProps = ({
49+
clusterName,
50+
monitoring,
51+
balancer,
52+
getMonitoringClusterLink,
53+
}: GetAdditionalClusterProps) => {
4754
const additionalClusterProps: AdditionalClusterProps = {};
4855

4956
if (monitoring && getMonitoringClusterLink) {
@@ -61,14 +68,25 @@ const getAdditionalClusterProps = (
6168
return additionalClusterProps;
6269
};
6370

64-
const getAdditionalTenantsProps = (
65-
clusterName: string | undefined,
66-
monitoring: string | undefined,
67-
balancer: string | undefined,
68-
useClusterBalancerAsBackend: boolean | undefined,
69-
getMonitoringLink?: GetMonitoringLink,
70-
getLogsLink?: GetLogsLink,
71-
) => {
71+
interface GetAdditionalTenantsProps {
72+
clusterName: string | undefined;
73+
monitoring: string | undefined;
74+
balancer: string | undefined;
75+
logging: string | undefined;
76+
useClusterBalancerAsBackend: boolean | undefined;
77+
getMonitoringLink?: GetMonitoringLink;
78+
getLogsLink?: GetLogsLink;
79+
}
80+
81+
const getAdditionalTenantsProps = ({
82+
clusterName,
83+
monitoring,
84+
balancer,
85+
logging,
86+
useClusterBalancerAsBackend,
87+
getMonitoringLink,
88+
getLogsLink,
89+
}: GetAdditionalTenantsProps) => {
7290
const additionalTenantsProps: AdditionalTenantsProps = {};
7391

7492
additionalTenantsProps.prepareTenantBackend = (
@@ -104,12 +122,12 @@ const getAdditionalTenantsProps = (
104122
};
105123
}
106124

107-
if (clusterName && getLogsLink) {
125+
if (logging && getLogsLink) {
108126
additionalTenantsProps.getLogsLink = (dbName?: string) => {
109127
if (dbName) {
110128
return getLogsLink({
111129
dbName,
112-
clusterName,
130+
logging,
113131
});
114132
}
115133

@@ -133,27 +151,28 @@ export function ExtendedCluster({
133151
getLogsLink,
134152
}: ExtendedClusterProps) {
135153
const additionalNodesProps = useAdditionalNodesProps();
136-
const {name, balancer, monitoring} = useClusterBaseInfo();
154+
const {name, balancer, monitoring, logging} = useClusterBaseInfo();
137155

138156
const [useClusterBalancerAsBackend] = useSetting<boolean>(USE_CLUSTER_BALANCER_AS_BACKEND_KEY);
139157

140158
return (
141159
<div className={b()}>
142160
<ClusterComponent
143-
additionalClusterProps={getAdditionalClusterProps(
144-
name,
161+
additionalClusterProps={getAdditionalClusterProps({
162+
clusterName: name,
145163
monitoring,
146164
balancer,
147165
getMonitoringClusterLink,
148-
)}
149-
additionalTenantsProps={getAdditionalTenantsProps(
150-
name,
166+
})}
167+
additionalTenantsProps={getAdditionalTenantsProps({
168+
clusterName: name,
151169
monitoring,
152170
balancer,
171+
logging,
153172
useClusterBalancerAsBackend,
154173
getMonitoringLink,
155174
getLogsLink,
156-
)}
175+
})}
157176
additionalNodesProps={additionalNodesProps}
158177
/>
159178
</div>

src/containers/AppWithClusters/ExtendedTenant/ExtendedTenant.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function ExtendedTenant({
1515
getMonitoringLink,
1616
getLogsLink,
1717
}: ExtendedTenantProps) {
18-
const {monitoring, name: clusterName} = useClusterBaseInfo();
18+
const {monitoring, logging} = useClusterBaseInfo();
1919
const additionalNodesProps = useAdditionalNodesProps();
2020

2121
const additionalTenantProps = {
@@ -31,10 +31,10 @@ export function ExtendedTenant({
3131
return null;
3232
},
3333
getLogsLink: (dbName?: string) => {
34-
if (clusterName && dbName && getLogsLink) {
34+
if (logging && dbName && getLogsLink) {
3535
return getLogsLink({
3636
dbName,
37-
clusterName,
37+
logging,
3838
});
3939
}
4040

src/containers/Tablet/Tablet.tsx

Lines changed: 6 additions & 4 deletions
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

Lines changed: 7 additions & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 6 deletions
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

Lines changed: 11 additions & 3 deletions
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)