Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1923,7 +1923,7 @@
"actualReplicaCount": 2,
"replicaDeltaCount": 1,
"reason": null,
"keys": 1,
"keys": 4,
"pipelineID": "a10ffab6-8ed5-414a-aaf5-79890ff3e8a1",
"replicas": [
{
Expand Down Expand Up @@ -1997,7 +1997,7 @@
"actualReplicaCount": 2,
"replicaDeltaCount": 2,
"reason": null,
"keys": 1,
"keys": 3,
"pipelineID": "a10ffab6-8ed5-414a-aaf5-79890ff3e8a1",
"replicas": [
{
Expand Down Expand Up @@ -2071,7 +2071,7 @@
"actualReplicaCount": 2,
"replicaDeltaCount": 2,
"reason": null,
"keys": 1,
"keys": 2,
"pipelineID": "a10ffab6-8ed5-414a-aaf5-79890ff3e8a1",
"replicas": [
{
Expand Down Expand Up @@ -2108,7 +2108,7 @@
"actualReplicaCount": 2,
"replicaDeltaCount": 2,
"reason": null,
"keys": 1,
"keys": 5,
"pipelineID": "a10ffab6-8ed5-414a-aaf5-79890ff3e8a1",
"replicas": [
{
Expand Down Expand Up @@ -2145,7 +2145,7 @@
"actualReplicaCount": 2,
"replicaDeltaCount": 2,
"reason": null,
"keys": 1,
"keys": 3,
"pipelineID": "a10ffab6-8ed5-414a-aaf5-79890ff3e8a1",
"replicas": [
{
Expand Down Expand Up @@ -2182,7 +2182,7 @@
"actualReplicaCount": 2,
"replicaDeltaCount": 2,
"reason": null,
"keys": 1,
"keys": 6,
"pipelineID": "a10ffab6-8ed5-414a-aaf5-79890ff3e8a2",
"replicas": [
{
Expand Down Expand Up @@ -2219,7 +2219,7 @@
"actualReplicaCount": 2,
"replicaDeltaCount": 2,
"reason": null,
"keys": 1,
"keys": 2,
"pipelineID": "a10ffab6-8ed5-414a-aaf5-79890ff3e8a3",
"replicas": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const breadcrumbNameMap: IBreadcrumbNameMap = {
'/Datanodes': 'Datanodes',
'/Pipelines': 'Pipelines',
'/MissingContainers': 'Missing Containers',
'/Containers': 'Containers',
'/Insights': 'Insights',
'/DiskUsage': 'Disk Usage',
'/Heatmap': 'Heatmap',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ const BucketsTable: React.FC<BucketsTableProps> = ({
dataSource={getFilteredData(data)}
columns={filterSelectedColumns()}
loading={loading}
rowKey='volume'
rowKey={(record: Bucket) => `${record.volumeName}/${record.name}`}
pagination={paginationConfig}
scroll={{ x: 'max-content', scrollToFirstRowOnChange: true }}
locale={{ filterTitle: '' }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
/*
* 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 React, { useRef } from 'react';
import filesize from 'filesize';
import { AxiosError } from 'axios';
import { Popover, Table } from 'antd';
import {
ColumnsType,
TablePaginationConfig
} from 'antd/es/table';
import { NodeIndexOutlined } from '@ant-design/icons';

import { getFormattedTime } from '@/v2/utils/momentUtils';
import { showDataFetchError } from '@/utils/common';
import { AxiosGetHelper } from '@/utils/axiosRequestHelper';
import {
Container, ContainerKeysResponse, ContainerReplica,
ContainerTableProps,
ExpandedRowState, KeyResponse
} from '@/v2/types/container.types';

const size = filesize.partial({ standard: 'iec' });

export const COLUMNS: ColumnsType<Container> = [
{
title: 'Container ID',
dataIndex: 'containerID',
key: 'containerID',
sorter: (a: Container, b: Container) => a.containerID - b.containerID
},
{
title: 'No. of Keys',
dataIndex: 'keys',
key: 'keys',
sorter: (a: Container, b: Container) => a.keys - b.keys
},
{
title: 'Actual/Expected Replica(s)',
dataIndex: 'expectedReplicaCount',
key: 'expectedReplicaCount',
render: (expectedReplicaCount: number, record: Container) => {
const actualReplicaCount = record.actualReplicaCount;
return (
<span>
{actualReplicaCount} / {expectedReplicaCount}
</span>
);
}
},
{
title: 'Datanodes',
dataIndex: 'replicas',
key: 'replicas',
render: (replicas: ContainerReplica[]) => {
const renderDatanodes = (replicas: ContainerReplica[]) => {
return replicas?.map((replica: any, idx: number) => (
<div key={idx} className='datanode-container-v2'>
<NodeIndexOutlined /> {replica.datanodeHost}
</div>
))
}

return (
<Popover
content={renderDatanodes(replicas)}
title='Datanodes'
placement='bottomRight'
trigger='hover'>
<strong>{replicas.length}</strong> datanodes
</Popover>
)
}
},
{
title: 'Pipeline ID',
dataIndex: 'pipelineID',
key: 'pipelineID'
},
{
title: 'Unhealthy Since',
dataIndex: 'unhealthySince',
key: 'unhealthySince',
render: (unhealthySince: number) => getFormattedTime(unhealthySince, 'lll'),
sorter: (a: Container, b: Container) => a.unhealthySince - b.unhealthySince
}
];

const KEY_TABLE_COLUMNS: ColumnsType<KeyResponse> = [
{
title: 'Volume',
dataIndex: 'Volume',
key: 'Volume'
},
{
title: 'Bucket',
dataIndex: 'Bucket',
key: 'Bucket'
},
{
title: 'Key',
dataIndex: 'Key',
key: 'Key'
},
{
title: 'Size',
dataIndex: 'DataSize',
key: 'DataSize',
render: (dataSize: number) => <div>{size(dataSize)}</div>
},
{
title: 'Date Created',
dataIndex: 'CreationTime',
key: 'CreationTime',
render: (date: string) => getFormattedTime(date, 'lll')
},
{
title: 'Date Modified',
dataIndex: 'ModificationTime',
key: 'ModificationTime',
render: (date: string) => getFormattedTime(date, 'lll')
},
{
title: 'Path',
dataIndex: 'CompletePath',
key: 'path'
}
];

const ContainerTable: React.FC<ContainerTableProps> = ({
data,
loading,
selectedColumns,
expandedRow,
expandedRowSetter,
searchColumn = 'containerID',
searchTerm = ''
}) => {

const cancelSignal = useRef<AbortController>();

function filterSelectedColumns() {
const columnKeys = selectedColumns.map((column) => column.value);
return COLUMNS.filter(
(column) => columnKeys.indexOf(column.key as string) >= 0
);
}

function loadRowData(containerID: number) {
const { request, controller } = AxiosGetHelper(
`/api/v1/containers/${containerID}/keys`,
cancelSignal.current
);
cancelSignal.current = controller;

request.then(response => {
const containerKeysResponse: ContainerKeysResponse = response.data;
expandedRowSetter({
...expandedRow,
[containerID]: {
...expandedRow[containerID],
loading: false,
dataSource: containerKeysResponse.keys,
totalCount: containerKeysResponse.totalCount
}
});
}).catch(error => {
expandedRowSetter({
...expandedRow,
[containerID]: {
...expandedRow[containerID],
loading: false
}
});
showDataFetchError((error as AxiosError).toString());
});
}

function getFilteredData(data: Container[]) {

return data?.filter(
(container: Container) => {
return (searchColumn === 'containerID')
? container[searchColumn].toString().includes(searchTerm)
: container[searchColumn].includes(searchTerm)
}
) ?? [];
}

function onRowExpandClick(expanded: boolean, record: Container) {
if (expanded) {
loadRowData(record.containerID);
}
else {
cancelSignal.current && cancelSignal.current.abort();
}
}

function expandedRowRender(record: Container) {
const containerId = record.containerID
const containerKeys: ExpandedRowState = expandedRow[containerId];
const dataSource = containerKeys?.dataSource ?? [];
const paginationConfig: TablePaginationConfig = {
showTotal: (total: number, range) => `${range[0]}-${range[1]} of ${total} Keys`
}

return (
<Table
loading={containerKeys?.loading ?? true}
dataSource={dataSource}
columns={KEY_TABLE_COLUMNS}
pagination={paginationConfig}
rowKey={(record: KeyResponse) => `${record.Volume}/${record.Bucket}/${record.Key}`}
locale={{ filterTitle: '' }} />
)
};

const paginationConfig: TablePaginationConfig = {
showTotal: (total: number, range) => (
`${range[0]}-${range[1]} of ${total} Containers`
),
showSizeChanger: true
};

return (
<div>
<Table
rowKey='containerID'
dataSource={getFilteredData(data)}
columns={filterSelectedColumns()}
loading={loading}
pagination={paginationConfig}
scroll={{ x: 'max-content', scrollToFirstRowOnChange: true }}
locale={{ filterTitle: '' }}
expandable={{
expandRowByClick: true,
expandedRowRender: expandedRowRender,
onExpand: onRowExpandClick
}} />
</div>
);
}

export default ContainerTable;
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import AclPanel from '@/v2/components/aclDrawer/aclDrawer';
import Search from '@/v2/components/search/search';
import MultiSelect from '@/v2/components/select/multiSelect';
import SingleSelect, { Option } from '@/v2/components/select/singleSelect';
import BucketsTable, { COLUMNS } from '@/v2/components/tables/bucketsTable';

import { AutoReloadHelper } from '@/utils/autoReloadHelper';
import { AxiosGetHelper, cancelRequests } from "@/utils/axiosRequestHelper";
Expand All @@ -39,7 +40,6 @@ import {
} from '@/v2/types/bucket.types';

import './buckets.less';
import BucketsTable, { COLUMNS } from '@/v2/components/tables/bucketsTable';


const LIMIT_OPTIONS: Option[] = [
Expand Down
Loading