All Downloads are FREE. Search and download functionalities are using the official Maven repository.

webapp.src.components.WorkerList.jsx Maven / Gradle / Ivy

There is a newer version: 468
Show newest version
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import React from "react";

const SMALL_SPARKLINE_PROPERTIES = {
    width: '100%',
    height: '57px',
    fillColor: '#3F4552',
    lineColor: '#747F96',
    spotColor: '#1EDCFF',
    tooltipClassname: 'sparkline-tooltip',
    disableHiddenCheck: true,
};

export class WorkerList extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            initialized: false,
            workers: []
        };
        this.refreshLoop = this.refreshLoop.bind(this);
    }

    refreshLoop() {
        clearTimeout(this.timeoutId);
        $.get('/ui/api/worker', function (workers) {
            if (workers != null) {
                workers.sort(function (workerA, workerB) {
                    if (workerA.coordinator && !workerB.coordinator) {
                        return -1;
                    }
                    if (!workerA.coordinator && workerB.coordinator) {
                        return 1;
                    }
                    return workerA.nodeId.localeCompare(workerB.nodeId);
                });
            }
            this.setState({
                initialized: true,
                workers: workers
            })
            this.resetTimer();
        }.bind(this))
                .fail(() => {
                    this.setState({
                        initialized: true,
                    });
                    this.resetTimer();
                });
    }

    resetTimer() {
        clearTimeout(this.timeoutId);
        this.timeoutId = setTimeout(this.refreshLoop.bind(this), 1000);
    }

    componentDidMount() {
        this.refreshLoop();
    }

    render() {
        const workers = this.state.workers;
        if (workers === null) {
            if (this.state.initialized === false) {
                return (
                    
Loading...
); } else { return (

Worker list information could not be loaded

); } } let workerList = function () { let trs = []; workers.forEach((worker) => { trs.push( {worker.nodeId} {worker.nodeIp} {worker.nodeVersion} {String(worker.coordinator)} {worker.state} ); }); return trs; }; return (

Overview


{workerList()}
Node ID Node IP Node Version Coordinator State
); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy