Skip to content

Commit

Permalink
Merge pull request PelicanPlatform#1039 from CannonLock/add-cache-page
Browse files Browse the repository at this point in the history
Add Cache Webpage
  • Loading branch information
haoming29 authored Apr 4, 2024
2 parents 5a56148 + 36e74e2 commit ba668ab
Show file tree
Hide file tree
Showing 12 changed files with 587 additions and 217 deletions.
65 changes: 65 additions & 0 deletions web_ui/frontend/app/cache/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/***************************************************************
*
* Copyright (C) 2024, Pelican Project, Morgridge Institute for Research
*
* 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 {Box, Tooltip} from "@mui/material";

import {Sidebar} from "@/components/layout/Sidebar";
import Link from "next/link";
import Image from "next/image";
import PelicanLogo from "@/public/static/images/PelicanPlatformLogo_Icon.png";
import IconButton from "@mui/material/IconButton";
import BuildIcon from "@mui/icons-material/Build";
import Main from "@/components/layout/Main";

export const metadata = {
title: 'Pelican Cache',
description: 'Software designed to make data distribution easy',
}

export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<Box display={"flex"} flexDirection={"row"}>
<Sidebar>
<Link href={"/"}>
<Image
src={PelicanLogo}
alt={"Pelican Logo"}
width={36}
height={36}
/>
</Link>
<Box pt={1}>
<Tooltip title={"Config"} placement={"right"}>
<Link href={"/config/"}>
<IconButton>
<BuildIcon/>
</IconButton>
</Link>
</Tooltip>
</Box>
</Sidebar>
<Main>
{children}
</Main>
</Box>
)
}
153 changes: 153 additions & 0 deletions web_ui/frontend/app/cache/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/***************************************************************
*
* Copyright (C) 2023, Pelican Project, Morgridge Institute for Research
*
* 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.
*
***************************************************************/

"use client"

import {Box, Grid, Typography} from "@mui/material";

import RateGraph from "@/components/graphs/RateGraph";
import StatusBox from "@/components/StatusBox";
import {DataExportTable} from "@/components/DataExportTable";
import {DataPoint, TimeDuration} from "@/components/graphs/prometheus";
import FederationOverview from "@/components/FederationOverview";
import LineGraph from "@/components/graphs/LineGraph";

export default function Home() {

return (
<Box width={"100%"}>
<Grid container spacing={2}>
<Grid item xs={12} lg={4}>
<Typography variant="h4" mb={2}>Status</Typography>
<StatusBox/>
</Grid>
<Grid item xs={12} lg={4}>
<Typography variant={"h4"} component={"h2"} mb={2}>Data Exports</Typography>
<Box sx={{borderRadius: 2, overflow: "hidden"}}>
<DataExportTable/>
</Box>
</Grid>
<Grid item xs={12} lg={4}>
<FederationOverview/>
</Grid>
<Grid item xs={12} lg={6}>
<Box sx={{backgroundColor: "#F6F6F6", borderRadius: "1rem"}} p={2}>
<Typography variant="h4" mb={1}>Storage</Typography>
<Box minHeight={"200px"}>
<LineGraph
duration={TimeDuration.fromString("7d")}
resolution={TimeDuration.fromString("3h")}
metrics={['xrootd_storage_volume_bytes{ns="/cache",server_type="cache",type="total"}', 'xrootd_storage_volume_bytes{ns="/cache",server_type="cache",type="free"}']}
boxProps={{
maxHeight:"400px",
flexGrow:1,
justifyContent:"center",
display:"flex",
bgcolor:"white",
borderRadius:2
}}
options={{
scales: {
x: {
type: 'time',
time: {
round: 'second',
minUnit: 'minute'
}
}
},
plugins: {
zoom: {
zoom: {
drag: {
enabled: true,
},
mode: 'x',
// TODO - Implement smart update on zoom: onZoom: (chart) => console.log(chart)
},
},
},
}}
datasetOptions={[
{label: "Total Storage (Gigabytes)", borderColor: "#000000"},
{label: "Free Storage (Gigabytes)", borderColor: "#54ff80"}
]}
datasetTransform={(dataset) => {
dataset.data = dataset.data.map(p => {
let {x, y} = p as DataPoint
y = y / (10**9)
return {x: x, y: y}
})

return dataset
}}
/>
</Box>
</Box>
</Grid>
<Grid item xs={12} lg={6}>
<Box sx={{backgroundColor: "#F6F6F6", borderRadius: "1rem"}} p={2}>
<Typography variant="h4" mb={1}>Transfer Rate</Typography>
<Box minHeight={"200px"}>
<RateGraph
rate={TimeDuration.fromString("3h")}
duration={TimeDuration.fromString("7d")}
resolution={TimeDuration.fromString("3h")}
metrics={['xrootd_server_bytes{direction="rx"}', 'xrootd_server_bytes{direction="tx"}']}
boxProps={{
maxHeight:"400px",
flexGrow:1,
justifyContent:"center",
display:"flex",
bgcolor:"white",
borderRadius:2
}}
options={{
scales: {
x: {
type: 'time',
time: {
round: 'second',
minUnit: 'minute'
}
}
},
plugins: {
zoom: {
zoom: {
drag: {
enabled: true,
},
mode: 'x',
// TODO - Implement smart update on zoom: onZoom: (chart) => console.log(chart)
},
},
},
}}
datasetOptions={[
{label: "Bytes Received (Bps)", borderColor: "#0071ff"},
{label: "Bytes Sent (Bps)", borderColor: "#54ff80"}
]}
/>
</Box>
</Box>
</Grid>
</Grid>
</Box>
)
}
24 changes: 16 additions & 8 deletions web_ui/frontend/app/config/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,29 @@

"use client"

import RateGraph from "@/components/graphs/RateGraph";
import StatusBox from "@/components/StatusBox";

import {TimeDuration} from "@/components/graphs/prometheus";

import {
Box,
Grid,
Typography,
Skeleton,
Link,
Container,
Tooltip, Snackbar, Button
Tooltip,
Snackbar,
Button
} from "@mui/material";
import React, {useEffect, useMemo, useState} from "react";
import {OverridableStringUnion} from "@mui/types";
import {Variant} from "@mui/material/styles/createTypography";
import {TypographyPropsVariantOverrides} from "@mui/material/Typography";
import TextField from "@mui/material/TextField";
import {
AppRegistration,
ArrowDropDown,
ArrowDropUp,
AssistantDirection,
QuestionMark,
TripOrigin
TripOrigin,
Cached
} from '@mui/icons-material';
import {default as NextLink} from "next/link";
import {merge, isEmpty, isMatch} from "lodash"
Expand Down Expand Up @@ -426,6 +423,17 @@ function Config() {
</NextLink>
</Box>
}
{ enabledServers.includes("cache") &&
<Box pt={1}>
<NextLink href={"/cache/"}>
<Tooltip title={"Cache"} placement={"right"}>
<IconButton>
<Cached/>
</IconButton>
</Tooltip>
</NextLink>
</Box>
}
</Sidebar>
<Main>
<Container maxWidth={"xl"}>
Expand Down
30 changes: 17 additions & 13 deletions web_ui/frontend/app/origin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,19 @@ export default function Home() {
return (
<Box width={"100%"}>
<Grid container spacing={2}>
<Grid item xs={12} lg={4}>
<Typography variant="h4">Status</Typography>
<Grid item xs={12} lg={6}>
<Typography variant="h4" mb={2}>Status</Typography>
<StatusBox/>
</Grid>
<Grid item xs={12} lg={8}>
<Grid item xs={12} lg={6}>
<Typography variant={"h4"} component={"h2"} mb={2}>Data Exports</Typography>
<Box sx={{borderRadius: 2, overflow: "hidden"}}>
<DataExportTable/>
</Box>
</Grid>
<Grid item xs={12} lg={6}>
<Box sx={{backgroundColor: "#F6F6F6", borderRadius: "1rem"}} p={2}>
<Typography variant="h4" mb={1}>Transfer Rate</Typography>
<Box minHeight={"200px"}>
<RateGraph
rate={TimeDuration.fromString("3h")}
Expand All @@ -47,14 +54,17 @@ export default function Home() {
maxHeight:"400px",
flexGrow:1,
justifyContent:"center",
display:"flex"
display:"flex",
bgcolor:"white",
borderRadius:2
}}
options={{
scales: {
x: {
type: 'time',
time: {
round: 'second',
minUnit: 'minute'
}
}
},
Expand All @@ -71,20 +81,14 @@ export default function Home() {
},
}}
datasetOptions={[
{label: "xrootd_server_bytes{direction=\"rx\"}", borderColor: "#0071ff"},
{label: "xrootd_server_bytes{direction=\"tx\"}", borderColor: "#54ff80"}
{label: "Bytes Received (Bps)", borderColor: "#0071ff"},
{label: "Bytes Sent (Bps)", borderColor: "#54ff80"}
]}
/>
</Box>
</Box>
</Grid>
<Grid item xs={12} lg={4}>
<Typography variant={"h4"} component={"h2"} mb={2}>Data Exports</Typography>
<Box sx={{backgroundColor: "#F6F6F6", borderRadius: "1rem", overflow: "hidden"}}>
<DataExportTable/>
</Box>
</Grid>
<Grid item xs={12} lg={4}>
<Grid item xs={12} lg={6}>
<FederationOverview/>
</Grid>
</Grid>
Expand Down
22 changes: 17 additions & 5 deletions web_ui/frontend/components/DataExportTable.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
import {Table, TableCell, TableBody, TableContainer, TableHead, TableRow, Paper, Typography, Box} from '@mui/material';
"use client"

import {
Table,
TableCell,
TableBody,
TableContainer,
TableHead,
TableRow,
Paper,
Typography,
Box,
BoxProps
} from '@mui/material';
import React, {FunctionComponent, ReactElement, useEffect, useMemo, useRef, useState} from "react";
import {Skeleton} from "@mui/material";

Expand Down Expand Up @@ -64,8 +77,7 @@ export const RecordTable = ({ data }: { data: Record[] }): ReactElement => {
)
}


export const DataExportTable = () => {
export const DataExportTable = ({boxProps}: {boxProps?: BoxProps}) => {

const [data, setData] = useState<ExportData[] | undefined>(undefined);
const [error, setError] = useState<string | undefined>(undefined);
Expand Down Expand Up @@ -100,8 +112,8 @@ export const DataExportTable = () => {
}

return (
<>
<Box sx={{backgroundColor: "#F6F6F6"}} {...boxProps}>
{data ? <RecordTable data={data} /> : <Skeleton variant={"rectangular"} height={200} width={"100%"} />}
</>
</Box>
)
}
2 changes: 0 additions & 2 deletions web_ui/frontend/components/FederationOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ const FederationOverview = () => {
return
}

console.log(config)

return (

<Box>
Expand Down
Loading

0 comments on commit ba668ab

Please sign in to comment.