import { InputAdornment, Table, TableBody, TableCell, TableHead, TableRow, TextField, TextFieldProps, } from "@material-ui/core"; import { orange } from "@material-ui/core/colors"; import { SearchOutlined } from "@material-ui/icons"; import Autocomplete from "@material-ui/lab/Autocomplete"; import Pagination from "@material-ui/lab/Pagination"; import React, { useContext, useState } from "react"; import { Link } from "react-router-dom"; import { GlobalContext } from "../App"; import { Actor } from "../type/actor"; import { Worker } from "../type/worker"; import { longTextCut } from "../util/func"; import { useFilter } from "../util/hook"; import StateCounter from "./StatesCounter"; import { StatusChip } from "./StatusChip"; import RayletWorkerTable, { ExpandableTableRow } from "./WorkerTable"; const ActorTable = ({ actors = {}, workers = [], }: { actors: { [actorId: string]: Actor }; workers?: Worker[]; }) => { const [pageNo, setPageNo] = useState(1); const { changeFilter, filterFunc } = useFilter(); const [pageSize, setPageSize] = useState(10); const { ipLogMap } = useContext(GlobalContext); const actorList = Object.values(actors || {}) .map((e) => ({ ...e, functionDesc: Object.values( e.taskSpec?.functionDescriptor?.javaFunctionDescriptor || e.taskSpec?.functionDescriptor?.pythonFunctionDescriptor || {}, ).join(" "), })) .filter(filterFunc); const list = actorList.slice((pageNo - 1) * pageSize, pageNo * pageSize); return (
e.state)), )} onInputChange={(_: any, value: string) => { changeFilter("state", value.trim()); }} renderInput={(params: TextFieldProps) => ( )} /> e.address?.ipAddress)), )} onInputChange={(_: any, value: string) => { changeFilter("address.ipAddress", value.trim()); }} renderInput={(params: TextFieldProps) => ( )} /> { changeFilter("pid", value.trim()); }, endAdornment: ( ), }} /> { changeFilter("functionDesc", value.trim()); }, endAdornment: ( ), }} /> { changeFilter("name", value.trim()); }, endAdornment: ( ), }} /> { changeFilter("actorId", value.trim()); }, endAdornment: ( ), }} /> { setPageSize(Math.min(Number(value), 500) || 10); }, }} />
setPageNo(num)} count={Math.ceil(actorList.length / pageSize)} />
{[ "", "ID(Num Restarts)", "Name", "Task Func Desc", "Job Id", "Pid", "IP", "Port", "State", "Log", ].map((col) => ( {col} ))} {list.map( ({ actorId, functionDesc, jobId, pid, address, state, name, numRestarts, }) => ( e.pid === pid && address.ipAddress === e.coreWorkerStats[0].ipAddress, ).length } expandComponent={ e.pid === pid && address.ipAddress === e.coreWorkerStats[0].ipAddress, )} mini /> } key={actorId} > 0 ? orange[500] : "inherit", }} > {actorId}({numRestarts}) {name} {longTextCut(functionDesc, 60)} {jobId} {pid} {address?.ipAddress} {address?.port} {ipLogMap[address?.ipAddress] && ( Log )} ), )}
); }; export default ActorTable;