Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Ingestion view task query optimization by adding a toggle button that steers (#80) #90

Merged
merged 1 commit into from
Mar 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 18 additions & 59 deletions web-console/src/views/ingestion-view/ingestion-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
* limitations under the License.
*/

import { Alert, Button, ButtonGroup, Intent, Label, MenuItem, Switch } from '@blueprintjs/core';
import { Tooltip2 } from '@blueprintjs/popover2';
import { Alert, Button, ButtonGroup, Intent, Label, MenuItem } from '@blueprintjs/core';
import { IconNames } from '@blueprintjs/icons';
import React from 'react';
import SplitterLayout from 'react-splitter-layout';
Expand Down Expand Up @@ -144,8 +143,6 @@ export interface IngestionViewState {
supervisorTableActionDialogActions: BasicAction[];
hiddenTaskColumns: LocalStorageBackedArray<string>;
hiddenSupervisorColumns: LocalStorageBackedArray<string>;

preferOverlord: boolean;
}

function statusToColor(status: string): string {
Expand Down Expand Up @@ -245,8 +242,6 @@ ORDER BY "rank" DESC, "created_time" DESC`;
hiddenSupervisorColumns: new LocalStorageBackedArray<string>(
LocalStorageKeys.SUPERVISOR_TABLE_COLUMN_SELECTION,
),

preferOverlord: true,
};

this.supervisorQueryManager = new QueryManager({
Expand Down Expand Up @@ -283,43 +278,25 @@ ORDER BY "rank" DESC, "created_time" DESC`;
});

this.taskQueryManager = new QueryManager({
processQuery: async capabilities => {
const { preferOverlord } = this.state;
const hasOverlordAccess = capabilities.hasOverlordAccess();
const hasSql = capabilities.hasSql();

if (!hasOverlordAccess && !hasSql) {
throw new Error(`must have overlord or SQL access`);
}

if (preferOverlord) {
return hasOverlordAccess
? IngestionView.tasksViaOverlord()
: IngestionView.tasksViaSql();
} else {
return hasSql
? IngestionView.tasksViaSql()
: IngestionView.tasksViaOverlord();
}
},
onStateChange: tasksState => {
this.setState({
tasksState,
processQuery: async capabilities => {
if (capabilities.hasSql()) {
return await queryDruidSql({
query: IngestionView.TASK_SQL,
});
},
});
}

static tasksViaSql = async () => {
return await queryDruidSql({
query: IngestionView.TASK_SQL,
} else if (capabilities.hasOverlordAccess()) {
const resp = await Api.instance.get(`/druid/indexer/v1/tasks`);
return IngestionView.parseTasks(resp.data);
} else {
throw new Error(`must have SQL or overlord access`);
}
},
onStateChange: tasksState => {
this.setState({
tasksState,
});
},
});
};

static tasksViaOverlord = async () => {
const resp = await Api.instance.get(`/druid/indexer/v1/tasks`);
return IngestionView.parseTasks(resp.data);
};
}

static parseTasks = (data: any[]): TaskQueryResultRow[] => {
return data.map((d: any) => {
Expand Down Expand Up @@ -357,13 +334,6 @@ ORDER BY "rank" DESC, "created_time" DESC`;
this.taskQueryManager.terminate();
}

private handlePreferOverlordSwitchChange = () => {
this.setState(state => ({
...state,
preferOverlord: !state.preferOverlord,
}));
};

private readonly closeSpecDialogs = () => {
this.setState({
supervisorSpecDialogOpen: false,
Expand Down Expand Up @@ -1168,17 +1138,6 @@ ORDER BY "rank" DESC, "created_time" DESC`;
localStorageKey={LocalStorageKeys.TASKS_REFRESH_RATE}
onRefresh={auto => this.taskQueryManager.rerunLastQuery(auto)}
/>
{/* Toggle switch to prefer overload over SQL since SQL can affect metadata store performance with large number of tasks */}
<Tooltip2
content="Turning on the toggle will prefer overlord followed by sql for task listing. Turning off will reverse the order."
hoverOpenDelay={800}
>
<Switch
label="Prefer Overlord"
checked={this.state.preferOverlord}
onChange={this.handlePreferOverlordSwitchChange}
/>
</Tooltip2>
{this.renderBulkTasksActions()}
<TableColumnSelector
columns={taskTableColumns}
Expand Down