You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by ha...@apache.org on 2018/04/21 09:20:15 UTC
[incubator-skywalking-ui] branch 5.0.0/beta updated: Refactor
Application page * Add Server info
This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a commit to branch 5.0.0/beta
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking-ui.git
The following commit(s) were added to refs/heads/5.0.0/beta by this push:
new f1429e1 Refactor Application page * Add Server info
f1429e1 is described below
commit f1429e14193e8aa0133c584fa90e32020e14fedf
Author: hanahmily <ha...@gmail.com>
AuthorDate: Sat Apr 21 17:12:37 2018 +0800
Refactor Application page
* Add Server info
---
mock/application.js | 9 +-
mock/server.js | 2 -
src/common/menu.js | 4 -
src/common/router.js | 3 -
src/components/RankList/index.js | 114 +++++++++++++++++++
src/components/RankList/index.less | 52 +++++++++
src/models/application.js | 91 +++++++++++++++-
src/models/server.js | 70 ------------
src/routes/Application/Application.js | 99 ++++++++++++++---
src/routes/Application/Server.js | 129 ++++++++++++++++++++++
src/routes/Server/Server.js | 199 ----------------------------------
11 files changed, 474 insertions(+), 298 deletions(-)
diff --git a/mock/application.js b/mock/application.js
index 9f68b65..4db60b7 100644
--- a/mock/application.js
+++ b/mock/application.js
@@ -33,7 +33,14 @@ export default {
{
data: {
'getSlowService|10': [{ 'key|+1': 1, name: '@name', 'avgResponseTime|200-1000': 1 }],
- 'getServerThroughput|10': [{ 'key|+1': 1, name: '@name', 'callsPerSec|100-10000': 1 }],
+ 'getServerThroughput|10': [{
+ 'key|+1': 3,
+ osName: 'Linux-@name',
+ host: 'WORKSAPCE-@name',
+ pid: '@natural(4, 20)',
+ 'ipv4|1-3': ['@ip'],
+ 'value|100-10000': 1,
+ }],
getApplicationTopology: () => {
const application = mockjs.mock({
nodes: [
diff --git a/mock/server.js b/mock/server.js
index 7a63465..29abf0f 100644
--- a/mock/server.js
+++ b/mock/server.js
@@ -26,12 +26,10 @@ export default {
'searchServer|5': [
{
'key|+1': 3,
- name: function() { return `server-${this.key}`; }, // eslint-disable-line
os: 'Mac-@name',
host: 'WORKSAPCE-@name',
pid: '@natural(4, 20)',
'ipv4|1-3': ['@ip'],
- applicationCode: 'Frontend',
},
],
},
diff --git a/src/common/menu.js b/src/common/menu.js
index 344043c..c287e00 100644
--- a/src/common/menu.js
+++ b/src/common/menu.js
@@ -31,10 +31,6 @@ const menuData = [{
icon: 'appstore',
path: 'application',
}, {
- name: 'Server',
- icon: 'database',
- path: 'server',
-}, {
name: 'Service',
icon: 'api',
path: 'service',
diff --git a/src/common/router.js b/src/common/router.js
index 96d5981..7af628a 100644
--- a/src/common/router.js
+++ b/src/common/router.js
@@ -100,9 +100,6 @@ export const getRouterData = (app) => {
'/application': {
component: dynamicWrapper(app, ['application'], () => import('../routes/Application/Application')),
},
- '/server': {
- component: dynamicWrapper(app, ['server'], () => import('../routes/Server/Server')),
- },
'/service': {
component: dynamicWrapper(app, ['service'], () => import('../routes/Service/Service')),
},
diff --git a/src/components/RankList/index.js b/src/components/RankList/index.js
new file mode 100644
index 0000000..72ac1bb
--- /dev/null
+++ b/src/components/RankList/index.js
@@ -0,0 +1,114 @@
+/**
+ * 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, { PureComponent } from 'react';
+import { List, Row, Col, Tag } from 'antd';
+import styles from './index.less';
+
+
+class RankList extends PureComponent {
+ renderLabel = (item) => {
+ const { renderLabel } = this.props;
+ if (!renderLabel) {
+ return item.label;
+ }
+ return renderLabel(item);
+ }
+ renderValue = (item) => {
+ const { renderValue } = this.props;
+ if (!renderValue) {
+ return item.value;
+ }
+ return renderValue(item);
+ }
+ renderTitle = (item, maxDuration) => {
+ const { onClick } = this.props;
+ return (
+ <div className={styles.progressWrap}>
+ {maxDuration > 0 ? (
+ <div
+ className={styles.progress}
+ style={{
+ backgroundColor: '#87CEFA',
+ width: `${(item.value * 100) / maxDuration}%`,
+ height: 25,
+ }}
+ />
+ ) : null}
+ <div className={styles.mainInfo}>
+ <span>{onClick ?
+ <a onClick={() => onClick(item.key, item)}>{this.renderLabel(item)}</a>
+ : this.renderLabel(item)}
+ </span>
+ <span className={styles.value}>{this.renderValue(item)}
+ </span>
+ </div>
+ </div>);
+ }
+ renderBadges = (item) => {
+ const { renderBadge } = this.props;
+ return (
+ <Row type="flex" justify="start" gutter={15}>
+ {
+ renderBadge(item).map((_) => {
+ return (
+ <Col key={_.key}>
+ <span>{_.label}</span>
+ {Array.isArray(_.value) ? _.value.map(
+ v => <Tag key={v} style={{ marginLeft: 5 }}>{v}</Tag>)
+ : <Tag style={{ marginLeft: 5 }}>{_.value}</Tag>
+ }
+ </Col>
+ );
+ })
+ }
+ </Row>
+ );
+ }
+ render() {
+ const { data, loading, renderBadge } = this.props;
+ let maxValue = 0;
+ const sortData = data.sort((a, b) => {
+ if (a.value > b.value) {
+ maxValue = a.value > maxValue ? a.value : maxValue;
+ } else {
+ maxValue = b.value > maxValue ? b.value : maxValue;
+ }
+ return b.value - a.value;
+ });
+ return (
+ <List
+ className={styles.rankList}
+ itemLayout="horizontal"
+ size="small"
+ dataSource={sortData}
+ loading={loading}
+ renderItem={item => (
+ <List.Item>
+ <List.Item.Meta
+ title={this.renderTitle(item, maxValue)}
+ description={renderBadge ? this.renderBadges(item) : null}
+ />
+ </List.Item>
+ )}
+ />
+ );
+ }
+}
+
+export default RankList;
diff --git a/src/components/RankList/index.less b/src/components/RankList/index.less
new file mode 100644
index 0000000..2a151a0
--- /dev/null
+++ b/src/components/RankList/index.less
@@ -0,0 +1,52 @@
+/*
+ * 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 '~antd/lib/style/themes/default.less';
+
+.rankList {
+ padding: 5px 0;
+ position: relative;
+ width: 100%;
+ .progressWrap {
+ background-color: @background-color-base;
+ position: relative;
+ height: 25px;
+ }
+ .progress {
+ position: absolute;
+ z-index: 10;
+ transition: all 0.4s cubic-bezier(0.08, 0.82, 0.17, 1) 0s;
+ border-radius: 1px 0 0 1px;
+ background-color: @primary-color;
+ width: 0;
+ height: 100%;
+ }
+ .mainInfo {
+ position: absolute;
+ z-index: 20;
+ width: 100%;
+ .value {
+ float: right;
+ }
+ a {
+ color: #001529;
+ }
+ a:hover {
+ color: #1890ff;
+ }
+ }
+}
diff --git a/src/models/application.js b/src/models/application.js
index 67a109a..99590db 100644
--- a/src/models/application.js
+++ b/src/models/application.js
@@ -17,6 +17,7 @@
import { generateModal } from '../utils/models';
+import { query as queryService } from '../services/graphql';
const optionsQuery = `
query ApplicationOption($duration: Duration!) {
@@ -34,10 +35,13 @@ const dataQuery = `
name
avgResponseTime
}
- getServerThroughput(applicationId: $applicationId, duration: $duration, topN: 10) {
+ getServerThroughput(applicationId: $applicationId, duration: $duration, topN: 999999) {
key: id
osName
- callsPerSec
+ host
+ pid
+ ipv4
+ value: callsPerSec
}
getApplicationTopology(applicationId: $applicationId, duration: $duration) {
nodes {
@@ -67,6 +71,30 @@ const dataQuery = `
}
`;
+const serverQuery = `
+query Application($serverId: ID!, $duration: Duration!) {
+ getServerResponseTimeTrend(serverId: $serverId, duration: $duration) {
+ trendList
+ }
+ getServerTPSTrend(serverId: $serverId, duration: $duration) {
+ trendList
+ }
+ getCPUTrend(serverId: $serverId, duration: $duration) {
+ cost
+ }
+ getGCTrend(serverId: $serverId, duration: $duration) {
+ youngGC
+ oldGC
+ }
+ getMemoryTrend(serverId: $serverId, duration: $duration) {
+ heap
+ maxHeap
+ noheap
+ maxNoheap
+ }
+}
+`;
+
export default generateModal({
namespace: 'application',
state: {
@@ -77,7 +105,66 @@ export default generateModal({
nodes: [],
calls: [],
},
+ showServer: false,
+ serverInfo: {},
+ getServerResponseTimeTrend: {
+ trendList: [],
+ },
+ getServerTPSTrend: {
+ trendList: [],
+ },
+ getCPUTrend: {
+ cost: [],
+ },
+ getMemoryTrend: {
+ heap: [],
+ maxHeap: [],
+ noheap: [],
+ maxNoheap: [],
+ },
+ getGCTrend: {
+ youngGC: [],
+ oldGC: [],
+ },
},
optionsQuery,
dataQuery,
+ effects: {
+ *fetchServer({ payload }, { call, put }) {
+ const { variables, serverInfo } = payload;
+ const response = yield call(queryService, 'server', { variables, query: serverQuery });
+ if (!response.data) {
+ return;
+ }
+ yield put({
+ type: 'saveServer',
+ payload: response.data,
+ serverInfo,
+ });
+ },
+ },
+ reducers: {
+ saveServer(preState, { payload, serverInfo }) {
+ const { data } = preState;
+ return {
+ ...preState,
+ data: {
+ ...data,
+ serverInfo,
+ ...payload,
+ showServer: true,
+ },
+ };
+ },
+ hideServer(preState) {
+ const { data } = preState;
+ return {
+ ...preState,
+ data: {
+ ...data,
+ showServer: false,
+ },
+ };
+ },
+ },
});
diff --git a/src/models/server.js b/src/models/server.js
deleted file mode 100644
index b139b8c..0000000
--- a/src/models/server.js
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * 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 { generateModal } from '../utils/models';
-
-const dataQuery = `
- query Application($serverId: ID!, $duration: Duration!) {
- getServerResponseTimeTrend(serverId: $serverId, duration: $duration) {
- trendList
- }
- getServerTPSTrend(serverId: $serverId, duration: $duration) {
- trendList
- }
- getCPUTrend(serverId: $serverId, duration: $duration) {
- cost
- }
- getGCTrend(serverId: $serverId, duration: $duration) {
- youngGC
- oldGC
- }
- getMemoryTrend(serverId: $serverId, duration: $duration) {
- heap
- maxHeap
- noheap
- maxNoheap
- }
- }
-`;
-
-export default generateModal({
- namespace: 'server',
- state: {
- serverInfo: {},
- getServerResponseTimeTrend: {
- trendList: [],
- },
- getServerTPSTrend: {
- trendList: [],
- },
- getCPUTrend: {
- cost: [],
- },
- getMemoryTrend: {
- heap: [],
- maxHeap: [],
- noheap: [],
- maxNoheap: [],
- },
- getGCTrend: {
- youngGC: [],
- oldGC: [],
- },
- },
- dataQuery,
-});
diff --git a/src/routes/Application/Application.js b/src/routes/Application/Application.js
index 6bb59eb..e8cd473 100644
--- a/src/routes/Application/Application.js
+++ b/src/routes/Application/Application.js
@@ -18,9 +18,11 @@
import React, { PureComponent } from 'react';
import { connect } from 'dva';
-import { Row, Col, Select, Card, Form } from 'antd';
+import { Row, Col, Select, Card, Form, Breadcrumb } from 'antd';
+import Server from './Server';
import { AppTopology } from '../../components/Topology';
import { Panel, Ranking } from '../../components/Page';
+import RankList from '../../components/RankList';
const { Option } = Select;
const { Item: FormItem } = Form;
@@ -31,11 +33,12 @@ const middleColResponsiveProps = {
md: 12,
lg: 12,
xl: 12,
- style: { marginBottom: 24, marginTop: 24 },
+ style: { marginTop: 8 },
};
@connect(state => ({
application: state.application,
+ duration: state.global.duration,
globalVariables: state.global.globalVariables,
}))
@Form.create({
@@ -74,12 +77,29 @@ export default class Application extends PureComponent {
});
}
handleChange = (variables) => {
+ const { data: { serverInfo, showServer } } = this.props.application;
+ if (showServer) {
+ this.handleSelectServer(serverInfo.key, serverInfo);
+ } else {
+ this.props.dispatch({
+ type: 'application/fetchData',
+ payload: { variables },
+ });
+ }
+ }
+ handleGoApplication = () => {
this.props.dispatch({
- type: 'application/fetchData',
- payload: { variables },
+ type: 'application/hideServer',
});
}
- render() {
+ handleSelectServer = (serverId, serverInfo) => {
+ const { globalVariables: { duration } } = this.props;
+ this.props.dispatch({
+ type: 'application/fetchServer',
+ payload: { variables: { duration, serverId }, serverInfo },
+ });
+ }
+ renderApp = () => {
const { getFieldDecorator } = this.props.form;
const { variables: { values, options }, data } = this.props.application;
return (
@@ -106,14 +126,17 @@ export default class Application extends PureComponent {
globalVariables={this.props.globalVariables}
onChange={this.handleChange}
>
- <Card
- bordered={false}
- bodyStyle={{ padding: 0, marginTop: 24 }}
- >
- <AppTopology elements={data.getApplicationTopology} layout={{ name: 'concentric', startAngle: Math.PI, minNodeSpacing: 250 }} />
- </Card>
- <Row gutter={24}>
- <Col {...middleColResponsiveProps}>
+ <Row gutter={8}>
+ <Col {...{ ...middleColResponsiveProps, xl: 18, lg: 12, md: 24 }}>
+ <Card
+ title="Application Map"
+ bordered={false}
+ bodyStyle={{ padding: 0 }}
+ >
+ <AppTopology elements={data.getApplicationTopology} height={649} layout={{ name: 'concentric', startAngle: Math.PI, minNodeSpacing: 250 }} />
+ </Card>
+ </Col>
+ <Col {...{ ...middleColResponsiveProps, xl: 6, lg: 12, md: 24 }}>
<Card
title="Slow Service"
bordered={false}
@@ -122,13 +145,32 @@ export default class Application extends PureComponent {
<Ranking data={data.getSlowService} title="name" content="avgResponseTime" unit="ms" />
</Card>
</Col>
- <Col {...middleColResponsiveProps}>
+ </Row>
+ <Row gutter={8}>
+ <Col {...{ ...middleColResponsiveProps, xl: 24, lg: 24, md: 24 }}>
<Card
- title="Servers Throughput"
+ title="Running Server"
bordered={false}
- bodyStyle={{ padding: '0px 10px' }}
+ bodyStyle={{ padding: 5 }}
>
- <Ranking data={data.getServerThroughput} title="name" content="callsPerSec" unit="t/s" />
+ <RankList
+ data={data.getServerThroughput}
+ renderLabel={_ => `${_.pid}@${_.host}`}
+ renderValue={_ => `${_.value} cps`}
+ renderBadge={_ => ([
+ {
+ key: 'ip',
+ label: 'IP',
+ value: _.ipv4,
+ },
+ {
+ key: 'os',
+ label: 'OS',
+ value: _.osName,
+ },
+ ])}
+ onClick={this.handleSelectServer}
+ />
</Card>
</Col>
</Row>
@@ -136,4 +178,27 @@ export default class Application extends PureComponent {
</div>
);
}
+ render() {
+ const { application, duration } = this.props;
+ const { data } = application;
+ const { showServer, serverInfo } = data;
+ return (
+ <Row type="flex" justify="start">
+ <Col span={showServer ? 0 : 24}>
+ {this.renderApp()}
+ </Col>
+ {showServer ? (
+ <Col span={showServer ? 24 : 0}>
+ <Breadcrumb>
+ <Breadcrumb.Item>
+ <a onClick={this.handleGoApplication}>Application</a>
+ </Breadcrumb.Item>
+ <Breadcrumb.Item>{serverInfo.key}</Breadcrumb.Item>
+ </Breadcrumb>
+ <Server data={data} duration={duration} />
+ </Col>
+ ) : null}
+ </Row>
+ );
+ }
}
diff --git a/src/routes/Application/Server.js b/src/routes/Application/Server.js
new file mode 100644
index 0000000..ced51fc
--- /dev/null
+++ b/src/routes/Application/Server.js
@@ -0,0 +1,129 @@
+/**
+ * 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, { PureComponent } from 'react';
+import { Row, Col, Card } from 'antd';
+import {
+ ChartCard, MiniArea, MiniBar, Line, Area, StackBar,
+} from '../../components/Charts';
+import DescriptionList from '../../components/DescriptionList';
+import { axis } from '../../utils/time';
+import { avgTimeSeries } from '../../utils/utils';
+
+const { Description } = DescriptionList;
+
+
+export default class Server extends PureComponent {
+ bytesToMB = list => list.map(_ => parseFloat((_ / (1024 ** 2)).toFixed(2)))
+ render() {
+ const { duration, data } = this.props;
+ const { serverInfo, getServerResponseTimeTrend, getServerTPSTrend,
+ getCPUTrend, getMemoryTrend, getGCTrend } = data;
+ return (
+ <div>
+ <Card title="Info" style={{ marginTop: 24 }} bordered={false}>
+ <DescriptionList>
+ <Description term="Application Code">{serverInfo.applicationCode}</Description>
+ <Description term="Host Name">{serverInfo.host}</Description>
+ <Description term="IPv4">{serverInfo.ipv4 ? serverInfo.ipv4.join() : ''}</Description>
+ <Description term="Process Id">{serverInfo.pid}</Description>
+ <Description term="OS">{serverInfo.osName}</Description>
+ </DescriptionList>
+ </Card>
+ <Row gutter={24}>
+ <Col xs={24} sm={24} md={24} lg={12} xl={12} style={{ marginTop: 24 }}>
+ <ChartCard
+ title="Avg Response Time"
+ total={`${avgTimeSeries(getServerResponseTimeTrend.trendList)} ms`}
+ contentHeight={46}
+ >
+ {getServerResponseTimeTrend.trendList.length > 0 ? (
+ <MiniArea
+ animate={false}
+ color="#975FE4"
+ data={axis(duration, getServerResponseTimeTrend.trendList)}
+ />
+ ) : (<span style={{ display: 'none' }} />)}
+ </ChartCard>
+ </Col>
+ <Col xs={24} sm={24} md={24} lg={12} xl={12} style={{ marginTop: 24 }}>
+ <ChartCard
+ title="Avg Throughput"
+ total={`${avgTimeSeries(getServerTPSTrend.trendList)}`}
+ >
+ <MiniBar
+ animate={false}
+ height={46}
+ data={axis(duration, getServerTPSTrend.trendList)}
+ />
+ </ChartCard>
+ </Col>
+ </Row>
+ <Row gutter={24}>
+ <Col xs={24} sm={24} md={24} lg={24} xl={24} style={{ marginTop: 24 }}>
+ <ChartCard
+ title="CPU %"
+ contentHeight={150}
+ >
+ <Line
+ data={axis(duration, getCPUTrend.cost)}
+ />
+ </ChartCard>
+ </Col>
+ </Row>
+ <Row gutter={24}>
+ <Col xs={24} sm={24} md={12} lg={12} xl={12} style={{ marginTop: 24 }}>
+ <ChartCard
+ title="Heap MB"
+ contentHeight={150}
+ >
+ <Area
+ data={axis(duration, this.bytesToMB(getMemoryTrend.heap), ({ x, y }) => ({ x, y, type: 'value' }))
+ .concat(axis(duration, this.bytesToMB(getMemoryTrend.maxHeap), ({ x, y }) => ({ x, y, type: 'free' })))}
+ />
+ </ChartCard>
+ </Col>
+ <Col xs={24} sm={24} md={12} lg={12} xl={12} style={{ marginTop: 24 }}>
+ <ChartCard
+ title="Non-Heap MB"
+ contentHeight={150}
+ >
+ <Area
+ data={axis(duration, this.bytesToMB(getMemoryTrend.noheap), ({ x, y }) => ({ x, y, type: 'value' }))
+ .concat(axis(duration, this.bytesToMB(getMemoryTrend.maxNoheap), ({ x, y }) => ({ x, y, type: 'free' })))}
+ />
+ </ChartCard>
+ </Col>
+ </Row>
+ <Row gutter={24}>
+ <Col xs={24} sm={24} md={24} lg={24} xl={24} style={{ marginTop: 24 }}>
+ <ChartCard
+ title="GC ms"
+ contentHeight={150}
+ >
+ <StackBar
+ data={axis(duration, getGCTrend.oldGC, ({ x, y }) => ({ x, y, type: 'oldGC' }))
+ .concat(axis(duration, getGCTrend.youngGC, ({ x, y }) => ({ x, y, type: 'youngGC' })))}
+ />
+ </ChartCard>
+ </Col>
+ </Row>
+ </div>
+ );
+ }
+}
diff --git a/src/routes/Server/Server.js b/src/routes/Server/Server.js
deleted file mode 100644
index 6469c79..0000000
--- a/src/routes/Server/Server.js
+++ /dev/null
@@ -1,199 +0,0 @@
-/**
- * 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, { PureComponent } from 'react';
-import { connect } from 'dva';
-import { Row, Col, Card, Form } from 'antd';
-import {
- ChartCard, MiniArea, MiniBar, Line, Area, StackBar,
-} from '../../components/Charts';
-import DescriptionList from '../../components/DescriptionList';
-import { axis } from '../../utils/time';
-import { avgTimeSeries } from '../../utils/utils';
-import { Panel, Search } from '../../components/Page';
-
-const { Description } = DescriptionList;
-const { Item: FormItem } = Form;
-
-@connect(state => ({
- server: state.server,
- duration: state.global.duration,
- globalVariables: state.global.globalVariables,
-}))
-@Form.create({
- mapPropsToFields(props) {
- const { variables: { values, labels } } = props.server;
- return {
- serverId: Form.createFormField({
- value: { key: values.serverId ? values.serverId : '', label: labels.serverId ? labels.serverId : '' },
- }),
- };
- },
-})
-export default class Server extends PureComponent {
- handleSelect = (selected) => {
- this.props.dispatch({
- type: 'server/save',
- payload: {
- variables: {
- values: { serverId: selected.key },
- labels: { serverId: selected.label },
- },
- data: {
- serverInfo: selected,
- },
- },
- });
- }
- handleChange = (variables) => {
- this.props.dispatch({
- type: 'server/fetchData',
- payload: { variables },
- });
- }
- bytesToMB = list => list.map(_ => parseFloat((_ / (1024 ** 2)).toFixed(2)))
- render() {
- const { form, duration, server } = this.props;
- const { getFieldDecorator } = form;
- const { variables: { values }, data } = server;
- const { serverInfo, getServerResponseTimeTrend, getServerTPSTrend,
- getCPUTrend, getMemoryTrend, getGCTrend } = data;
- return (
- <div>
- <Form layout="inline">
- <FormItem>
- {getFieldDecorator('serverId')(
- <Search
- placeholder="Select a server"
- onSelect={this.handleSelect.bind(this)}
- url="/server/search"
- variables={{ duration: this.props.globalVariables.duration }}
- query={`
- query SearchServer($keyword: String!, $duration: Duration!) {
- searchServer(keyword: $keyword, duration: $duration) {
- key: id
- osName
- host
- pid
- ipv4
- applicationCode
- }
- }
- `}
- transform={r => ({ ...r, label: `${r.pid}@${r.host}:${r.applicationCode}` })}
- />
- )}
- </FormItem>
- </Form>
- <Panel
- variables={values}
- globalVariables={this.props.globalVariables}
- onChange={this.handleChange}
- >
- <Card title="Info" style={{ marginTop: 24 }} bordered={false}>
- <DescriptionList>
- <Description term="Application Code">{serverInfo.applicationCode}</Description>
- <Description term="Host Name">{serverInfo.host}</Description>
- <Description term="IPv4">{serverInfo.ipv4 ? serverInfo.ipv4.join() : ''}</Description>
- <Description term="Process Id">{serverInfo.pid}</Description>
- <Description term="OS">{serverInfo.osName}</Description>
- </DescriptionList>
- </Card>
- <Row gutter={24}>
- <Col xs={24} sm={24} md={24} lg={12} xl={12} style={{ marginTop: 24 }}>
- <ChartCard
- title="Avg Response Time"
- total={`${avgTimeSeries(getServerResponseTimeTrend.trendList)} ms`}
- contentHeight={46}
- >
- {getServerResponseTimeTrend.trendList.length > 0 ? (
- <MiniArea
- animate={false}
- color="#975FE4"
- data={axis(duration, getServerResponseTimeTrend.trendList)}
- />
- ) : (<span style={{ display: 'none' }} />)}
- </ChartCard>
- </Col>
- <Col xs={24} sm={24} md={24} lg={12} xl={12} style={{ marginTop: 24 }}>
- <ChartCard
- title="Avg Throughput"
- total={`${avgTimeSeries(getServerTPSTrend.trendList)}`}
- >
- <MiniBar
- animate={false}
- height={46}
- data={axis(duration, getServerTPSTrend.trendList)}
- />
- </ChartCard>
- </Col>
- </Row>
- <Row gutter={24}>
- <Col xs={24} sm={24} md={24} lg={24} xl={24} style={{ marginTop: 24 }}>
- <ChartCard
- title="CPU %"
- contentHeight={150}
- >
- <Line
- data={axis(duration, getCPUTrend.cost)}
- />
- </ChartCard>
- </Col>
- </Row>
- <Row gutter={24}>
- <Col xs={24} sm={24} md={12} lg={12} xl={12} style={{ marginTop: 24 }}>
- <ChartCard
- title="Heap MB"
- contentHeight={150}
- >
- <Area
- data={axis(duration, this.bytesToMB(getMemoryTrend.heap), ({ x, y }) => ({ x, y, type: 'value' }))
- .concat(axis(duration, this.bytesToMB(getMemoryTrend.maxHeap), ({ x, y }) => ({ x, y, type: 'free' })))}
- />
- </ChartCard>
- </Col>
- <Col xs={24} sm={24} md={12} lg={12} xl={12} style={{ marginTop: 24 }}>
- <ChartCard
- title="Non-Heap MB"
- contentHeight={150}
- >
- <Area
- data={axis(duration, this.bytesToMB(getMemoryTrend.noheap), ({ x, y }) => ({ x, y, type: 'value' }))
- .concat(axis(duration, this.bytesToMB(getMemoryTrend.maxNoheap), ({ x, y }) => ({ x, y, type: 'free' })))}
- />
- </ChartCard>
- </Col>
- </Row>
- <Row gutter={24}>
- <Col xs={24} sm={24} md={24} lg={24} xl={24} style={{ marginTop: 24 }}>
- <ChartCard
- title="GC ms"
- contentHeight={150}
- >
- <StackBar
- data={axis(duration, getGCTrend.oldGC, ({ x, y }) => ({ x, y, type: 'oldGC' }))
- .concat(axis(duration, getGCTrend.youngGC, ({ x, y }) => ({ x, y, type: 'youngGC' })))}
- />
- </ChartCard>
- </Col>
- </Row>
- </Panel>
- </div>
- );
- }
-}
--
To stop receiving notification emails like this one, please contact
hanahmily@apache.org.