mirror of https://github.com/apache/druid.git
Add supervisor card in home view (#7551)
* Add supervisor card in home view * hide the text under conditions
This commit is contained in:
parent
ce7298b51e
commit
20755f4ca0
|
@ -51,6 +51,11 @@ export interface HomeViewState {
|
|||
segmentCount: number;
|
||||
segmentCountError: string | null;
|
||||
|
||||
supervisorCountLoading: boolean;
|
||||
runningSupervisorCount: number;
|
||||
suspendedSupervisorCount: number;
|
||||
supervisorCountError: string | null;
|
||||
|
||||
taskCountLoading: boolean;
|
||||
runningTaskCount: number;
|
||||
pendingTaskCount: number;
|
||||
|
@ -72,6 +77,7 @@ export class HomeView extends React.Component<HomeViewProps, HomeViewState> {
|
|||
private statusQueryManager: QueryManager<string, any>;
|
||||
private datasourceQueryManager: QueryManager<string, any>;
|
||||
private segmentQueryManager: QueryManager<string, any>;
|
||||
private supervisorQueryManager: QueryManager<string, any>;
|
||||
private taskQueryManager: QueryManager<string, any>;
|
||||
private dataServerQueryManager: QueryManager<string, any>;
|
||||
private middleManagerQueryManager: QueryManager<string, any>;
|
||||
|
@ -91,6 +97,11 @@ export class HomeView extends React.Component<HomeViewProps, HomeViewState> {
|
|||
segmentCount: 0,
|
||||
segmentCountError: null,
|
||||
|
||||
supervisorCountLoading: false,
|
||||
runningSupervisorCount: 0,
|
||||
suspendedSupervisorCount: 0,
|
||||
supervisorCountError: null,
|
||||
|
||||
taskCountLoading: false,
|
||||
runningTaskCount: 0,
|
||||
pendingTaskCount: 0,
|
||||
|
@ -188,6 +199,30 @@ export class HomeView extends React.Component<HomeViewProps, HomeViewState> {
|
|||
|
||||
this.segmentQueryManager.runQuery(`SELECT COUNT(*) as "count" FROM sys.segments`);
|
||||
|
||||
// -------------------------
|
||||
this.supervisorQueryManager = new QueryManager({
|
||||
processQuery: async (query: string) => {
|
||||
const resp = await axios.get('/druid/indexer/v1/supervisor?full');
|
||||
const data = resp.data;
|
||||
const runningSupervisorCount = data.filter((d: any) => d.spec.suspended === false).length;
|
||||
const suspendedSupervisorCount = data.filter((d: any) => d.spec.suspended === true).length;
|
||||
return {
|
||||
runningSupervisorCount,
|
||||
suspendedSupervisorCount
|
||||
};
|
||||
},
|
||||
onStateChange: ({result, loading, error}) => {
|
||||
this.setState({
|
||||
runningSupervisorCount: result ? result.runningSupervisorCount : 0,
|
||||
suspendedSupervisorCount: result ? result.suspendedSupervisorCount : 0,
|
||||
supervisorCountLoading: loading,
|
||||
supervisorCountError: error
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.supervisorQueryManager.runQuery('dummy');
|
||||
|
||||
// -------------------------
|
||||
|
||||
this.taskQueryManager = new QueryManager({
|
||||
|
@ -332,6 +367,19 @@ GROUP BY 1`);
|
|||
error: state.datasourceCountError
|
||||
})}
|
||||
|
||||
{this.renderCard({
|
||||
href: '#tasks',
|
||||
icon: IconNames.LIST_COLUMNS,
|
||||
title: 'Supervisors',
|
||||
loading: state.supervisorCountLoading,
|
||||
content: <>
|
||||
{!Boolean(state.runningSupervisorCount + state.suspendedSupervisorCount) && <p>0 supervisors</p>}
|
||||
{Boolean(state.runningSupervisorCount) && <p>{pluralIfNeeded(state.runningSupervisorCount, 'running supervisor')}</p>}
|
||||
{Boolean(state.suspendedSupervisorCount) && <p>{pluralIfNeeded(state.suspendedSupervisorCount, 'suspended supervisor')}</p>}
|
||||
</>,
|
||||
error: state.supervisorCountError
|
||||
})}
|
||||
|
||||
{this.renderCard({
|
||||
href: '#tasks',
|
||||
icon: IconNames.GANTT_CHART,
|
||||
|
|
Loading…
Reference in New Issue