You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/11/02 15:26:31 UTC

[GitHub] [pinot] jadami10 commented on a diff in pull request #9699: UI: re define the segment status

jadami10 commented on code in PR #9699:
URL: https://github.com/apache/pinot/pull/9699#discussion_r1011935933


##########
pinot-controller/src/main/resources/app/utils/Utils.tsx:
##########
@@ -345,6 +346,28 @@ const splitStringByLastUnderscore = (str: string) => {
   return [beforeUnderscore, afterUnderscore];
 }
 
+export const getDisplaySegmentStatus = (idealState, externalView): DISPLAY_SEGMENT_STATUS => {
+  const externalViewStatesArray = Object.values(externalView || {});
+
+  // if EV is empty or EV contains ERROR state then segment is in Bad state
+  if(externalViewStatesArray.length === 0 || externalViewStatesArray.includes(SEGMENT_STATUS.ERROR)) {
+    return DISPLAY_SEGMENT_STATUS.BAD;

Review Comment:
   why don't we make this even clearer?
   ```
   if(externalViewStatesArray.length === 0) {
     return DISPLAY_SEGMENT_STATUS.MISSING
   }
   
   if (externalViewStatesArray.includes(SEGMENT_STATUS.ERROR)) {
     return DISPLAY_SEGMENT_STATUS.ERROR
   }
   ```
   no need to force people to mouse over to see why it's actually bad.



##########
pinot-controller/src/main/resources/app/components/SegmentStatusRenderer.tsx:
##########
@@ -0,0 +1,107 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 {
+  Chip,
+  makeStyles,
+  Tooltip,
+} from "@material-ui/core";
+import { DISPLAY_SEGMENT_STATUS } from "Models";
+import React, { useEffect, useState } from "react";
+
+const useStyles = makeStyles((theme) => ({
+  error: {
+    color: theme.palette.error.main,
+    border: `1px solid ${theme.palette.error.main}`,
+  },
+  success: {
+    color: theme.palette.success.main,
+    border: `1px solid ${theme.palette.success.main}`,
+  },
+  info: {
+    color: theme.palette.info.main,
+    border: `1px solid ${theme.palette.info.main}`,
+  },
+  warning: {
+    color: theme.palette.warning.main,
+    border: `1px solid ${theme.palette.warning.main}`,
+  }
+}));
+
+interface SegmentStatusRendererProps {
+  status: DISPLAY_SEGMENT_STATUS;
+}
+
+export enum StatusVariant {
+  Error = "error",
+  Warning = "warning",
+  Info = "info",
+  Success = "success",
+}
+
+export const SegmentStatusRenderer = ({
+  status,
+}: SegmentStatusRendererProps) => {
+  const [statusTooltipTitle, setStatusTooltipTitle] = useState<string>("");
+  const [statusVariant, setStatusVariant] = useState<StatusVariant | null>(
+    null
+  );
+  const segmentStatusRendererClasses = useStyles();
+
+  useEffect(() => {
+    initializeValues();
+  }, []);
+
+  const initializeValues = () => {
+    switch (status) {
+      case DISPLAY_SEGMENT_STATUS.GOOD: {
+        setStatusVariant(StatusVariant.Success);
+        setStatusTooltipTitle("All the servers are ONLINE/CONSUMING.");
+
+        break;
+      }
+      case DISPLAY_SEGMENT_STATUS.BAD: {
+        setStatusVariant(StatusVariant.Error);
+        setStatusTooltipTitle("One or more servers are in ERROR state");
+
+        break;
+      }
+      case DISPLAY_SEGMENT_STATUS.PARTIAL: {
+        setStatusVariant(StatusVariant.Warning);
+        setStatusTooltipTitle("External View is OFFLINE and does not match Ideal State");
+
+        break;

Review Comment:
   can we add a default? seems like `Info` would be fine here? I believe that's the gray one



##########
pinot-controller/src/main/resources/app/components/Table.tsx:
##########
@@ -381,6 +381,11 @@ export default function CustomizedTables({
 
   const makeCell = (cellData, rowIndex) => {
     if (Object.prototype.toString.call(cellData) === '[object Object]') {
+      // render custom table cell

Review Comment:
   great addition. this has been getting quite complex supporting every table in pinot



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org