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

Add system.runtime.nodes information to web UI #11653

Merged
merged 3 commits into from
Apr 7, 2022

Conversation

whutpencil
Copy link
Contributor

@whutpencil whutpencil commented Mar 24, 2022

Description

The fact that you can't see a list of workers in the Web UI doesn't seem elegant. The goal of this PR is to improve it. The effect is shown in the figure below:

image

The value of active workers became a hyperlink.

When you click it, you will enter a new page with the contents as you run select * from system.runtime.nodes; the results obtained.

At the same time, each node ID and node IP supports jumping to the corresponding machine to view information.

image

image

image

This is the effect of having multiple nodes in a formal cluster:

image

Is this change a fix, improvement, new feature, refactoring, or other?
Improvement.

Is this a change to the core query engine, a connector, client library, or the SPI interfaces? (be specific)
No.

How would you describe this change to a non-technical end user or system administrator?

Related issues, pull requests, and links

Documentation

(x) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.

Release notes

( ) No release notes entries required.
(x) Release notes entries required with the following suggested text:

# Web UI
* Add list of nodes to UI. ({issue}`11653`)

@cla-bot cla-bot bot added the cla-signed label Mar 24, 2022
@findepi findepi added enhancement New feature or request ui Web UI labels Mar 24, 2022
@findepi findepi assigned raghavsethi and unassigned raghavsethi Mar 24, 2022
@findepi
Copy link
Member

findepi commented Mar 24, 2022

@dedep PTAL

@whutpencil
Copy link
Contributor Author

@findepi Why hasn't anyone reviewed the code for so long? What happened to Trino community activity? If I can, I am willing to participate in the review process of assisting the community. LOL ^^

@findepi
Copy link
Member

findepi commented Mar 31, 2022

@whutpencil i am not a frontend dev person, so I wouldn't want to review myself, but let me try again find someone.

return state;
}
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have a checkstyle error here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@JsonProperty("coordinator") String coordinator,
@JsonProperty("state") String state)
{
this.nodeId = nodeId;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use requireNonNull.

            this.nodeId = requireNonNull(nodeId, "nodeId is null");
            this.nodeIp = requireNonNull(nodeIp, "nodeIp is null");
            ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

private final String nodeIp;
private final String nodeVersion;
private final String coordinator;
private final String state;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If state is either "active" or "inactive" then maybe it's better to have an enum for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

private final String nodeId;
private final String nodeIp;
private final String nodeVersion;
private final String coordinator;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo, coordinator should be boolean. Why convert it to a String?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.


refreshLoop() {
clearTimeout(this.timeoutId); // to stop multiple series of refreshLoop from going on simultaneously
// const nodeId = getFirstParameter(window.location.search);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the commented code line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

initialized: true,
});
});

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this empty line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

}

refreshLoop() {
clearTimeout(this.timeoutId); // to stop multiple series of refreshLoop from going on simultaneously
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this.timeoutId? I can't find where you set it.
I suppose you wanted to send a request in the loop, but you didn't add setTimeout anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

<div id="worker-list">
<div class="loader">Loading...</div>
</div>
<!--<div id="worker-threads">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the commented code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

})
for (var index in workerInfo) {
this.setState({
workerId: addToHistory(workerInfo[index].nodeId, this.state.workerId),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addToHistory function signature is:
export function addToHistory (value: number, valuesArray: number[]): number[] {

You don't pass numbers, but strings.
I don't think you should use this function here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

workerInfo: workerInfo
})
for (var index in workerInfo) {
this.setState({
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that you didn't design the state well. Instead of

{
            workerId: string[],
            workerIp: string[],
            workerVersion: string[],
            ...
}

I would do (typescript notation):

{
   workers: [
            workerId: string,
            workerIp: string,
            workerVersion: string,
            ...
   ]
}

This way, the model is more concise and easier to work on

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@whutpencil
Copy link
Contributor Author

@dedep Thank you very much for your detailed review. I'm not a full-time front-end staff, so I didn't use the corresponding data structure well in the implementation process. I learned a lot from your comments and have made changes according to your modification opinions. Please review again.

this.nodeId = requireNonNull(nodeId, "nodeId is null");
this.nodeIp = requireNonNull(nodeIp, "nodeIp is null");
this.nodeVersion = requireNonNull(nodeVersion, "nodeVersion is null");
this.coordinator = requireNonNull(coordinator, "coordinator is null");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to do the requireNonNull check for a primitive (boolean) type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

workerInfo: null,
initialized: false,
ended: false,
workers: [{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

                workerId: String,
                workerIp: String,
                workerVersion: String,
                coordinator: Boolean,
                state: String

is not a correct JavaScript code. The code snippet I posted before was written in Typescript to show you the types.

So, I think it should be just: workers: []

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


refreshLoop() {
clearTimeout(this.timeoutId);
$.get('/ui/api/worker', function (workerInfo) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rename workerInfo to workers to signal that this is an array.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

this.state = {
workerInfo: null,
initialized: false,
ended: false,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that ended property is not used anywhere. IMO, you can remove this line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@whutpencil whutpencil requested a review from dedep April 2, 2022 02:07
@whutpencil
Copy link
Contributor Author

@dedep Excuse me, do you have any further amendments? Could this PR be merged into the master?

@electrum electrum merged commit 1214c7f into trinodb:master Apr 7, 2022
@electrum
Copy link
Member

electrum commented Apr 7, 2022

Thanks for your contribution!

@github-actions github-actions bot added this to the 376 milestone Apr 7, 2022
@whutpencil whutpencil deleted the worker_ui branch April 11, 2022 01:22
@mosabua
Copy link
Member

mosabua commented Apr 14, 2022

Hey @whutpencil .. I would like to feature this PR in the Trino Community Broadcast next week. Would you be interested in joining me a guest in the episode?

@mosabua
Copy link
Member

mosabua commented Apr 20, 2022

I am going ahead with demoing this in Trino Community Broadcast 35 on Thursday ..

@whutpencil
Copy link
Contributor Author

whutpencil commented Apr 21, 2022 via email

@mosabua
Copy link
Member

mosabua commented Apr 26, 2022

You can watch the demo and such now.. https://trino.io/episodes/35.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed enhancement New feature or request ui Web UI
Development

Successfully merging this pull request may close these issues.

6 participants