diff --git a/pinot-controller/src/main/resources/app/components/AsyncInstanceTable.tsx b/pinot-controller/src/main/resources/app/components/AsyncInstanceTable.tsx index 12d6b94a0ce6..c6a06b9a2444 100644 --- a/pinot-controller/src/main/resources/app/components/AsyncInstanceTable.tsx +++ b/pinot-controller/src/main/resources/app/components/AsyncInstanceTable.tsx @@ -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, @@ -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( diff --git a/pinot-controller/src/main/resources/app/components/Homepage/InstancesTables.tsx b/pinot-controller/src/main/resources/app/components/Homepage/InstancesTables.tsx index dd5621f447b5..3b466165c84f 100644 --- a/pinot-controller/src/main/resources/app/components/Homepage/InstancesTables.tsx +++ b/pinot-controller/src/main/resources/app/components/Homepage/InstancesTables.tsx @@ -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, @@ -45,7 +45,6 @@ const Instances = ({ clusterName, instanceType, instances, liveInstanceNames }: return ( ) => { 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(loadingInstanceData); @@ -187,10 +187,13 @@ const TenantPageDetails = ({ match }: RouteComponentProps) => { 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 = []; diff --git a/pinot-controller/src/main/resources/app/pages/Tenants.tsx b/pinot-controller/src/main/resources/app/pages/Tenants.tsx index e43c17c36b0e..e1a1697c9144 100644 --- a/pinot-controller/src/main/resources/app/pages/Tenants.tsx +++ b/pinot-controller/src/main/resources/app/pages/Tenants.tsx @@ -46,6 +46,7 @@ const TenantPage = ({ match }: RouteComponentProps) => { [InstanceType.BROKER]: null, [InstanceType.SERVER]: null, }) + const [liveInstanceNames, setLiveInstanceNames] = useState(); useEffect(() => { fetchInstanceData(); @@ -58,6 +59,10 @@ const TenantPage = ({ match }: RouteComponentProps) => { [InstanceType.BROKER]: Array.isArray(brokerNames) ? brokerNames : [], [InstanceType.SERVER]: Array.isArray(serverNames) ? serverNames : [], }); + + const liveInstanceNames = await PinotMethodUtils.getLiveInstances(); + setLiveInstanceNames(liveInstanceNames.data || []); + } return ( @@ -76,16 +81,18 @@ const TenantPage = ({ match }: RouteComponentProps) => {
{}} - 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 {}} - 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 @@ -99,18 +106,20 @@ const TenantPage = ({ match }: RouteComponentProps) => { baseUrl={`/tenants/${tenantName}/table/`} /> - + - + diff --git a/pinot-controller/src/main/resources/app/utils/PinotMethodUtils.ts b/pinot-controller/src/main/resources/app/utils/PinotMethodUtils.ts index 4207e59f4760..a4f1bae1fc6b 100644 --- a/pinot-controller/src/main/resources/app/utils/PinotMethodUtils.ts +++ b/pinot-controller/src/main/resources/app/utils/PinotMethodUtils.ts @@ -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; + 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: []} @@ -1277,6 +1290,7 @@ export default { getSegmentCountAndStatus, getClusterName, getLiveInstance, + getLiveInstances, getLiveInstanceConfig, getInstanceConfig, getInstanceDetails,