You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ag...@apache.org on 2021/08/22 15:10:51 UTC
[arrow-datafusion] branch master updated: [Ballista] Add executor
last seen info to the ui (#895)
This is an automated email from the ASF dual-hosted git repository.
agrove pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/master by this push:
new d3e88d9 [Ballista] Add executor last seen info to the ui (#895)
d3e88d9 is described below
commit d3e88d9d2dbf92ec0b4b6f381dad299b8e0fd2bf
Author: sathis <sa...@gmail.com>
AuthorDate: Sun Aug 22 20:40:44 2021 +0530
[Ballista] Add executor last seen info to the ui (#895)
---
ballista/rust/scheduler/src/api/handlers.rs | 21 +++++++++++++++++----
ballista/ui/scheduler/src/components/DataTable.tsx | 19 +++++++++++++++++++
ballista/ui/scheduler/src/components/NodesList.tsx | 8 ++++----
3 files changed, 40 insertions(+), 8 deletions(-)
diff --git a/ballista/rust/scheduler/src/api/handlers.rs b/ballista/rust/scheduler/src/api/handlers.rs
index ee0ee73..b65f4e2 100644
--- a/ballista/rust/scheduler/src/api/handlers.rs
+++ b/ballista/rust/scheduler/src/api/handlers.rs
@@ -11,27 +11,40 @@
// limitations under the License.
use crate::SchedulerServer;
-use ballista_core::{serde::scheduler::ExecutorMeta, BALLISTA_VERSION};
+use ballista_core::BALLISTA_VERSION;
use warp::Rejection;
#[derive(Debug, serde::Serialize)]
struct StateResponse {
- executors: Vec<ExecutorMeta>,
+ executors: Vec<ExecutorMetaResponse>,
started: u128,
version: &'static str,
}
+#[derive(Debug, serde::Serialize)]
+pub struct ExecutorMetaResponse {
+ pub id: String,
+ pub host: String,
+ pub port: u16,
+ pub last_seen: u128,
+}
+
pub(crate) async fn scheduler_state(
data_server: SchedulerServer,
) -> Result<impl warp::Reply, Rejection> {
// TODO: Display last seen information in UI
- let executors: Vec<ExecutorMeta> = data_server
+ let executors: Vec<ExecutorMetaResponse> = data_server
.state
.get_executors_metadata()
.await
.unwrap_or_default()
.into_iter()
- .map(|(metadata, _duration)| metadata)
+ .map(|(metadata, duration)| ExecutorMetaResponse {
+ id: metadata.id,
+ host: metadata.host,
+ port: metadata.port,
+ last_seen: duration.as_millis(),
+ })
.collect();
let response = StateResponse {
executors,
diff --git a/ballista/ui/scheduler/src/components/DataTable.tsx b/ballista/ui/scheduler/src/components/DataTable.tsx
index 188ddc8..70e17c0 100644
--- a/ballista/ui/scheduler/src/components/DataTable.tsx
+++ b/ballista/ui/scheduler/src/components/DataTable.tsx
@@ -60,6 +60,25 @@ interface DataTableProps {
maxW?: number;
pb?: number;
}
+
+export const ElapsedCell: (props: any) => React.ReactNode = (props: any) => {
+ const time = new Date(new Date().getTime() - props.value);
+ return (
+ <TimeAgo
+ date={time}
+ formatter={(
+ value: number,
+ unit: TimeAgo.Unit,
+ suffix: TimeAgo.Suffix
+ ) => {
+ if (unit === "second") return "just now";
+ const plural: string = value !== 1 ? "s" : "";
+ return `${value} ${unit}${plural} ${suffix}`;
+ }}
+ />
+ );
+};
+
export const DateCell: (props: any) => React.ReactNode = (props: any) => {
return (
<TimeAgo
diff --git a/ballista/ui/scheduler/src/components/NodesList.tsx b/ballista/ui/scheduler/src/components/NodesList.tsx
index 3ad85fc..f437e46 100644
--- a/ballista/ui/scheduler/src/components/NodesList.tsx
+++ b/ballista/ui/scheduler/src/components/NodesList.tsx
@@ -17,7 +17,7 @@
import React from "react";
import { Box } from "@chakra-ui/react";
-import { Column, DateCell, DataTable } from "./DataTable";
+import { Column, ElapsedCell, DataTable } from "./DataTable";
export enum NodeStatus {
RUNNING = "RUNNING",
@@ -50,9 +50,9 @@ const columns: Column<any>[] = [
accessor: "status",
},
{
- Header: "Started",
- accessor: "started",
- Cell: DateCell,
+ Header: "Last Seen",
+ accessor: "last_seen",
+ Cell: ElapsedCell,
},
];