forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server, ui: use POST request method for HotRangesV2 service
Initially, `HotRangesV2` service in status server was defined to use GET method to handle HTTP request. It was convenient way to display response data in Advanced debugging page since it allowed to render response body right on to page. But now, hot ranges will be used on user facing page and request dispatching for hot ranges api should follow generic workflow: initialize `HotRangesRequest` protobuf message and dispatch request with `src/util/api` service. This restriction forces to use POST method (since GET method doesn't allow to provide request body). In addition, Hot Ranges debugging page is refactored to use `api` service. Release note: None Release justification: bug fixes and low-risk updates to new functionality
- Loading branch information
Showing
9 changed files
with
123 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
pkg/ui/workspaces/db-console/src/views/reports/containers/hotranges/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
import React, { useCallback, useEffect, useState } from "react"; | ||
import { RouteComponentProps, withRouter } from "react-router-dom"; | ||
import moment from "moment"; | ||
import { Button } from "@cockroachlabs/ui-components"; | ||
import { cockroach } from "src/js/protos"; | ||
import { getHotRanges } from "src/util/api"; | ||
|
||
type HotRangesProps = RouteComponentProps<{ node_id: string }>; | ||
|
||
const HotRanges = (props: HotRangesProps) => { | ||
const nodeIdParam = props.match.params["node_id"]; | ||
const [nodeId, setNodeId] = useState(nodeIdParam); | ||
const [time, setTime] = useState<moment.Moment>(moment()); | ||
const [hotRanges, setHotRanges] = useState< | ||
cockroach.server.serverpb.HotRangesResponseV2["ranges"] | ||
>([]); | ||
const requestHotRanges = useCallback(() => { | ||
const request = cockroach.server.serverpb.HotRangesRequest.create({ | ||
node_id: nodeId, | ||
}); | ||
getHotRanges(request).then(response => { | ||
setHotRanges(response.ranges); | ||
setTime(moment()); | ||
}); | ||
}, [nodeId]); | ||
useEffect(requestHotRanges, [requestHotRanges, nodeId]); | ||
useEffect(() => { | ||
setNodeId(nodeIdParam); | ||
}, [nodeIdParam]); | ||
return ( | ||
<div | ||
style={{ | ||
display: "flex", | ||
flexDirection: "column", | ||
}} | ||
> | ||
<span>{`Node ID: ${nodeId ?? "All nodes"}`}</span> | ||
<span>{`Time: ${time.toISOString()}`}</span> | ||
<Button onClick={requestHotRanges} intent={"secondary"}> | ||
Refresh | ||
</Button> | ||
<pre className="state-json-box">{JSON.stringify(hotRanges, null, 2)}</pre> | ||
</div> | ||
); | ||
}; | ||
|
||
export default withRouter(HotRanges); |