Skip to content

Commit

Permalink
add server status to all instance tables (#14720)
Browse files Browse the repository at this point in the history
  • Loading branch information
jadami10 authored Jan 14, 2025
1 parent 25d17da commit 269f483
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,15 @@ import PinotMethodUtils from '../utils/PinotMethodUtils';
import Utils from '../utils/Utils';
import Loading from './Loading';

type BaseProps = {
type Props = {
instanceType: InstanceType;
showInstanceDetails?: boolean;
instanceNames: string[] | null;
liveInstanceNames?: string[];
};

type ClusterProps = BaseProps & {
cluster: string;
tenant?: never;
};

type TenantProps = BaseProps & {
tenant: string;
cluster?: never;
};

type Props = ClusterProps | TenantProps;

export const AsyncInstanceTable = ({
instanceType,
cluster,
instanceNames,
liveInstanceNames,
showInstanceDetails = false,
Expand All @@ -70,10 +57,10 @@ export const AsyncInstanceTable = ({

useEffect(() => {
// async load all the other details
if(showInstanceDetails && cluster && instanceNames && liveInstanceNames) {
if(showInstanceDetails && instanceNames && liveInstanceNames) {
fetchAdditionalInstanceDetails();
}
}, [showInstanceDetails, cluster, instanceNames, liveInstanceNames]);
}, [showInstanceDetails, instanceNames, liveInstanceNames]);

const fetchAdditionalInstanceDetails = async () => {
const additionalData = await PinotMethodUtils.getInstanceData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Props = {
};


const Instances = ({ clusterName, instanceType, instances, liveInstanceNames }: Props) => {
const Instances = ({ instanceType, instances, liveInstanceNames }: Props) => {
const order = [
InstanceType.CONTROLLER,
InstanceType.BROKER,
Expand All @@ -45,7 +45,6 @@ const Instances = ({ clusterName, instanceType, instances, liveInstanceNames }:
return (
<AsyncInstanceTable
key={startCase(key)}
cluster={clusterName}
instanceType={key}
showInstanceDetails
instanceNames={instances?.[key] || null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const TenantPageDetails = ({ match }: RouteComponentProps<Props>) => {
const [showEditConfig, setShowEditConfig] = useState(false);
const [config, setConfig] = useState('{}');

const instanceColumns = ["Instance Name", "# of segments"];
const instanceColumns = ["Instance Name", "# of segments", "Status"];
const loadingInstanceData = Utils.getLoadingTableData(instanceColumns);
const [instanceCountData, setInstanceCountData] = useState<TableData>(loadingInstanceData);

Expand Down Expand Up @@ -187,10 +187,13 @@ const TenantPageDetails = ({ match }: RouteComponentProps<Props>) => {
const fetchSegmentData = async () => {
const result = await PinotMethodUtils.getSegmentList(tableName);
const data = await PinotMethodUtils.fetchServerToSegmentsCountData(tableName, tableType);
const liveInstanceNames = await PinotMethodUtils.getLiveInstances();
const {columns, records} = result;
setInstanceCountData({
columns: instanceColumns,
records: data.records
records: data.records.map((record) => {
return [...record, liveInstanceNames.data.includes(record[0]) ? 'Alive' : 'Dead'];
})
});

const segmentTableRows = [];
Expand Down
25 changes: 17 additions & 8 deletions pinot-controller/src/main/resources/app/pages/Tenants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const TenantPage = ({ match }: RouteComponentProps<Props>) => {
[InstanceType.BROKER]: null,
[InstanceType.SERVER]: null,
})
const [liveInstanceNames, setLiveInstanceNames] = useState<string[]>();

useEffect(() => {
fetchInstanceData();
Expand All @@ -58,6 +59,10 @@ const TenantPage = ({ match }: RouteComponentProps<Props>) => {
[InstanceType.BROKER]: Array.isArray(brokerNames) ? brokerNames : [],
[InstanceType.SERVER]: Array.isArray(serverNames) ? serverNames : [],
});

const liveInstanceNames = await PinotMethodUtils.getLiveInstances();
setLiveInstanceNames(liveInstanceNames.data || []);

}

return (
Expand All @@ -76,16 +81,18 @@ const TenantPage = ({ match }: RouteComponentProps<Props>) => {
<div>
<CustomButton
onClick={() => {}}
tooltipTitle="Recalculates the segment to server mapping for all tables in this tenant"
enableTooltip={true}
// Tooltips do not render on disabled buttons. Add this back when we have a working implementation.
// tooltipTitle="Recalculates the segment to server mapping for all tables in this tenant"
// enableTooltip={true}
isDisabled={true}
>
Rebalance Server Tenant
</CustomButton>
<CustomButton
onClick={() => {}}
tooltipTitle="Rebuilds brokerResource mappings for all tables in this tenant"
enableTooltip={true}
// Tooltips do not render on disabled buttons. Add this back when we have a working implementation.
// tooltipTitle="Rebuilds brokerResource mappings for all tables in this tenant"
// enableTooltip={true}
isDisabled={true}
>
Rebuild Broker Resource
Expand All @@ -99,18 +106,20 @@ const TenantPage = ({ match }: RouteComponentProps<Props>) => {
baseUrl={`/tenants/${tenantName}/table/`}
/>
<Grid container spacing={2}>
<Grid item xs={6}>
<Grid item xs={12}>
<AsyncInstanceTable
instanceNames={instanceNames[InstanceType.BROKER]}
instanceType={InstanceType.BROKER}
tenant={tenantName}
liveInstanceNames={liveInstanceNames}
showInstanceDetails
/>
</Grid>
<Grid item xs={6}>
<Grid item xs={12}>
<AsyncInstanceTable
instanceNames={instanceNames[InstanceType.SERVER]}
instanceType={InstanceType.SERVER}
tenant={tenantName}
liveInstanceNames={liveInstanceNames}
showInstanceDetails
/>
</Grid>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,26 @@ const getClusterName = () => {
// This method is used to fetch array of live instances name
// API: /zk/ls?path=:ClusterName/LIVEINSTANCES
// Expected Output: []
const getLiveInstance = (clusterName) => {
const getLiveInstance = (clusterName: string) => {
const params = encodeURIComponent(`/${clusterName}/LIVEINSTANCES`);
return zookeeperGetList(params).then((data) => {
return data;
});
};

const getLiveInstances = () => {
let localclusterName: string | null = localStorage.getItem('pinot_ui:clusterName');
let clusterNameRes: Promise<string>;
if(!localclusterName || localclusterName === ''){
clusterNameRes = getClusterName();
} else {
clusterNameRes = Promise.resolve(localclusterName);
}
return clusterNameRes.then((clusterName) => {
return getLiveInstance(clusterName);
});
};

// This method is used to diaplay cluster congifuration on cluster manager home page
// API: /cluster/configs
// Expected Output: {columns: [], records: []}
Expand Down Expand Up @@ -1277,6 +1290,7 @@ export default {
getSegmentCountAndStatus,
getClusterName,
getLiveInstance,
getLiveInstances,
getLiveInstanceConfig,
getInstanceConfig,
getInstanceDetails,
Expand Down

0 comments on commit 269f483

Please sign in to comment.