Unverified Commit e16ed024 authored by Licho's avatar Licho Committed by GitHub

Remove paimon and jvm monitor (#3618)

Signed-off-by: 's avatarlicho <lecho.sun@gmail.com> Signed-off-by: 's avatarsunlichao11 <sunlichao11@jd.com> Co-authored-by: 's avatarsunlichao11 <sunlichao11@jd.com>
parent ed895809
...@@ -12,6 +12,9 @@ logs.zip ...@@ -12,6 +12,9 @@ logs.zip
# Mobile Tools for Java (J2ME) # Mobile Tools for Java (J2ME)
.mtj.tmp/ .mtj.tmp/
# sqlite
dinky.db
# Package Files # # Package Files #
*.jar *.jar
*.war *.war
......
...@@ -329,17 +329,6 @@ ...@@ -329,17 +329,6 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>io.github.datalinkdc</groupId>
<artifactId>dinky-shaded-paimon</artifactId>
<version>1.0.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency> <dependency>
<groupId>org.flywaydb</groupId> <groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId> <artifactId>flyway-core</artifactId>
......
...@@ -24,7 +24,6 @@ import static org.dinky.data.constant.MonitorTableConstant.JOB_ID; ...@@ -24,7 +24,6 @@ import static org.dinky.data.constant.MonitorTableConstant.JOB_ID;
import org.dinky.data.constant.MonitorTableConstant; import org.dinky.data.constant.MonitorTableConstant;
import org.dinky.data.enums.SseTopic; import org.dinky.data.enums.SseTopic;
import org.dinky.data.vo.MetricsVO; import org.dinky.data.vo.MetricsVO;
import org.dinky.utils.PaimonUtil;
import org.dinky.utils.SqliteUtil; import org.dinky.utils.SqliteUtil;
import java.sql.SQLException; import java.sql.SQLException;
...@@ -90,20 +89,6 @@ public class MetricsContextHolder { ...@@ -90,20 +89,6 @@ public class MetricsContextHolder {
return; // Return early to avoid unnecessary operations return; // Return early to avoid unnecessary operations
} }
pool.execute(() -> { pool.execute(() -> {
metricsVOS.add(o);
long current = System.currentTimeMillis();
long duration = current - lastDumpTime.get();
// Temporary cache monitoring information, mainly to prevent excessive buffering of write IO,
// when metricsVOS data reaches 1000 or the time exceeds 15 seconds
if (metricsVOS.size() >= 1000 || duration >= 15000) {
List<MetricsVO> snapshot;
synchronized (this) { // Enter synchronized block only when necessary
snapshot = new ArrayList<>(metricsVOS);
metricsVOS.clear();
lastDumpTime.set(current);
}
PaimonUtil.write(MonitorTableConstant.DINKY_METRICS, snapshot, MetricsVO.class);
}
String topic = StrFormatter.format("{}/{}", SseTopic.METRICS.getValue(), key); String topic = StrFormatter.format("{}/{}", SseTopic.METRICS.getValue(), key);
SseSessionContextHolder.sendTopic(topic, o); // Ensure only successfully added metrics are sent SseSessionContextHolder.sendTopic(topic, o); // Ensure only successfully added metrics are sent
}); });
......
...@@ -24,8 +24,6 @@ import org.dinky.daemon.task.DaemonTaskConfig; ...@@ -24,8 +24,6 @@ import org.dinky.daemon.task.DaemonTaskConfig;
import org.dinky.data.annotations.GaugeM; import org.dinky.data.annotations.GaugeM;
import org.dinky.data.metrics.BaseMetrics; import org.dinky.data.metrics.BaseMetrics;
import org.dinky.data.metrics.MetricsTotal; import org.dinky.data.metrics.MetricsTotal;
import org.dinky.data.model.SystemConfiguration;
import org.dinky.job.handler.SystemMetricsHandler;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Arrays; import java.util.Arrays;
...@@ -63,9 +61,6 @@ public class SystemMetricsTask implements DaemonTask { ...@@ -63,9 +61,6 @@ public class SystemMetricsTask implements DaemonTask {
@Override @Override
public boolean dealTask() { public boolean dealTask() {
if (SystemConfiguration.getInstances().getMetricsSysEnable().getValue()) {
SystemMetricsHandler.refresh();
}
return false; return false;
} }
......
/*
*
* 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.
*
*/
package org.dinky.utils;
import org.dinky.shaded.paimon.types.DataType;
import org.dinky.shaded.paimon.types.DataTypes;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Map;
import cn.hutool.core.map.MapUtil;
public class PaimonTypeUtil {
private static final Map<Class<?>, DataType> TYPE_MAP = MapUtil.<Class<?>, DataType>builder(
String.class, DataTypes.STRING())
.put(Integer.class, DataTypes.INT())
.put(Long.class, DataTypes.BIGINT())
.put(Double.class, DataTypes.DOUBLE())
.put(Float.class, DataTypes.FLOAT())
.put(Boolean.class, DataTypes.BOOLEAN())
.put(Byte.class, DataTypes.TINYINT())
.put(Short.class, DataTypes.SMALLINT())
.put(BigDecimal.class, DataTypes.DECIMAL(30, 4))
.put(Date.class, DataTypes.TIMESTAMP(3))
.put(LocalDateTime.class, DataTypes.TIMESTAMP(3))
.build();
public static DataType classToDataType(Class<?> clazz) {
return TYPE_MAP.getOrDefault(clazz, DataTypes.STRING());
}
}
/*
*
* 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 { JVMMetric } from '@/pages/Metrics/Server/data';
import { Area, AreaConfig } from '@ant-design/plots';
import React from 'react';
import { Chart } from '@ant-design/plots/es/interface';
type CpuProps = {
data: JVMMetric[];
chartConfig: Chart;
};
type Cpu = {
time: Date;
value: string | number;
};
const CPU: React.FC<CpuProps> = (props) => {
const { data, chartConfig } = props;
const dataList: Cpu[] = data.map((x) => {
return { time: x.time, value: Number(x.jvm.cpuUsed.toFixed(2)) };
});
const config: AreaConfig = {
...chartConfig,
data: dataList,
axis: {
y: {
min: 0,
max: 100
}
},
tooltip: {
name: 'Cpu Used',
channel: 'y',
valueFormatter: (num: Number) => {
return num + ' %';
}
}
};
return <Area {...config} />;
};
export default CPU;
/*
*
* 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 { JVMMetric } from '@/pages/Metrics/Server/data';
import { Area, AreaConfig } from '@ant-design/plots';
import React from 'react';
import { Chart } from '@ant-design/plots/es/interface';
type HeapProps = {
data: JVMMetric[];
max: number;
chartConfig: Chart;
};
type Heap = {
time: Date;
value: string | number;
};
const Heap: React.FC<HeapProps> = (props) => {
const { data, max, chartConfig } = props;
const dataList: Heap[] = data.map((x) => {
return {
time: x.time,
value: parseInt(String(x.jvm.heapUsed / (1024 * 1024)))
};
});
const config: AreaConfig = {
...chartConfig,
data: dataList,
tooltip: {
name: 'Heap Memory',
channel: 'y',
valueFormat: (datum: Number) => {
return datum + ' MB';
}
}
};
return <Area {...config} />;
};
export default Heap;
/*
*
* 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 { JVMMetric } from '@/pages/Metrics/Server/data';
import { Area, AreaConfig } from '@ant-design/plots';
import React from 'react';
import { Chart } from '@ant-design/plots/es/interface';
type NonHeapProps = {
data: JVMMetric[];
max: number;
chartConfig: Chart;
};
type NonHeap = {
time: Date;
value: number;
};
const NonHeap: React.FC<NonHeapProps> = (props) => {
const { data, max, chartConfig } = props;
const dataList: NonHeap[] = data.map((x) => {
return {
time: x.time,
value: parseInt(String(x.jvm.nonHeapMax / (1024 * 1024)))
};
});
const config: AreaConfig = {
...chartConfig,
data: dataList,
axis: {
y: {
min: 0,
max: max
}
},
tooltip: {
name: 'NonHeap Memory',
channel: 'y',
valueFormat: (datum: Number) => {
return datum + ' MB';
}
}
};
return <Area {...config} />;
};
export default NonHeap;
/*
*
* 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 { JVMMetric } from '@/pages/Metrics/Server/data';
import { Area, AreaConfig } from '@ant-design/plots';
import React from 'react';
import { Chart } from '@ant-design/plots/es/interface';
type ThreadProps = {
data: JVMMetric[];
chartConfig: Chart;
};
type Thread = {
time: Date;
value: string | number;
name: string;
};
const Thread: React.FC<ThreadProps> = (props) => {
const { data, chartConfig } = props;
const dataList: Thread[] = data.map((x) => {
return { time: x.time, value: x.jvm.threadPeakCount, name: 'Peak' };
});
const dataList2: Thread[] = data.map((x) => {
return { time: x.time, value: x.jvm.threadCount, name: 'Count' };
});
const dataListAll = dataList.concat(dataList2);
const config: AreaConfig = {
...chartConfig,
data: dataListAll,
colorField: 'name',
shapeField: 'name',
stack: false,
tooltip: {}
};
return <Area {...config} />;
};
export default Thread;
...@@ -28,48 +28,3 @@ export type MetricsDataType = { ...@@ -28,48 +28,3 @@ export type MetricsDataType = {
model: string; model: string;
heartTime: Date; heartTime: Date;
}; };
export type JVMMetric = {
jvm: JVMType;
cpu: CPUType;
mem: MemoryType;
time: Date;
};
export type FlinkMetricsData = Record<string, Record<string, string>>;
export type JvmDataRecord = {
cpuLastValue: number;
heapMax: number;
heapLastValue: number;
nonHeapMax: number;
nonHeapLastValue: number;
threadPeakCount: number;
threadCount: number;
};
type JVMType = {
total: number;
max: number;
free: number;
cpuUsed: number;
nonHeapMax: number;
nonHeapUsed: number;
heapMax: number;
heapUsed: number;
threadPeakCount: number;
threadCount: number;
version: string;
home: string;
};
type CPUType = {
cpuNum: number;
sys: number;
wait: number;
free: number;
};
type MemoryType = {
total: number;
used: number;
free: number;
};
/*
*
* 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 { CPUIcon, HeapIcon, OutHeapIcon, ThreadIcon } from '@/components/Icons/MetricsIcon';
import useHookRequest from '@/hooks/useHookRequest';
import { SseData } from '@/models/Sse';
import { SSE_TOPIC } from '@/pages/DevOps/constants';
import { MetricsTimeFilter } from '@/pages/DevOps/JobDetail/data';
import { getMetricsData } from '@/pages/DevOps/JobDetail/srvice';
import CPU from '@/pages/Metrics/Server/CPU';
import { JvmDataRecord, JVMMetric, MetricsDataType } from '@/pages/Metrics/Server/data';
import Heap from '@/pages/Metrics/Server/Heap';
import NonHeap from '@/pages/Metrics/Server/OutHeap';
import Thread from '@/pages/Metrics/Server/Thread';
import { useModel } from '@@/exports';
import { ProCard } from '@ant-design/pro-components';
import { Space } from 'antd';
import React, { useEffect, useState } from 'react';
import { Chart } from '@ant-design/plots/es/interface';
import { LineOptions } from '@ant-design/plots/lib/core';
export const imgStyle = {
display: 'block',
width: 24,
height: 24
};
type ServerProp = {
timeRange: MetricsTimeFilter;
};
const Server: React.FC<ServerProp> = (props) => {
const { timeRange } = props;
const [jvmData, setJvmData] = useState<JVMMetric[]>([]);
const processData = (source: JVMMetric[], datas: MetricsDataType[]) => {
datas.forEach((data) => {
const d: JVMMetric = data.content;
d.time = data.heartTime;
source.push(d);
});
return source;
};
useHookRequest<MetricsDataType[], any>(getMetricsData, {
defaultParams: [timeRange, 'local'],
refreshDeps: [timeRange],
onSuccess: (result: MetricsDataType[]) => {
setJvmData(() => processData([], result));
}
});
const { subscribeTopic } = useModel('Sse', (model: any) => ({
subscribeTopic: model.subscribeTopic
}));
useEffect(() => {
if (timeRange.isReal) {
return subscribeTopic([`${SSE_TOPIC.METRICS}/local`], (data: SseData) =>
setJvmData((prevState) => [...processData(prevState, [data.data])])
);
}
}, [timeRange]);
const commonConfig: LineOptions = {
data: [],
autoFit: true,
animation: {
update: {
type: false
}
},
yField: 'value',
xField: (d) => new Date(d.time)
};
const jvmMetric = jvmData[jvmData.length - 1];
const showLastData: JvmDataRecord = jvmMetric
? {
cpuLastValue: Number(jvmMetric.jvm.cpuUsed.toFixed(2)),
heapMax: Number((jvmMetric.jvm.heapMax / (1024 * 1024)).toFixed(0)),
heapLastValue: Number((jvmMetric.jvm.heapUsed / (1024 * 1024)).toFixed(0)),
nonHeapMax: Number((jvmMetric.jvm.nonHeapMax / (1024 * 1024)).toFixed(0)),
nonHeapLastValue: Number((jvmMetric.jvm.nonHeapUsed / (1024 * 1024)).toFixed(0)),
threadPeakCount: jvmMetric.jvm.threadPeakCount,
threadCount: jvmMetric.jvm.threadCount
}
: {
cpuLastValue: 0,
heapMax: 0,
heapLastValue: 0,
nonHeapMax: 0,
nonHeapLastValue: 0,
threadPeakCount: 0,
threadCount: 0
};
const extraDataBuilder = (data: JvmDataRecord) => {
return {
cpuLastValue: data.cpuLastValue + '%',
heapLastValue: data.heapLastValue + ' / ' + data.heapMax + ' MB',
nonHeapLastValue: data.nonHeapLastValue + ' / ' + data.nonHeapMax + ' MB',
threadCount: data.threadCount + ' / ' + data.threadPeakCount
};
};
return (
<>
<ProCard bordered split={'vertical'}>
<ProCard
title={
<Space>
<CPUIcon style={imgStyle} />
CPU
</Space>
}
extra={extraDataBuilder(showLastData).cpuLastValue}
bodyStyle={{ paddingBlock: 0, height: 200 }}
colSpan={'25%'}
>
<CPU data={jvmData} chartConfig={commonConfig} />
</ProCard>
<ProCard
title={
<Space>
<HeapIcon style={imgStyle} />
Heap
</Space>
}
extra={extraDataBuilder(showLastData).heapLastValue}
bodyStyle={{ paddingBlock: 0, height: 200 }}
colSpan={'25%'}
>
<Heap data={jvmData} max={showLastData.heapMax} chartConfig={commonConfig} />
</ProCard>
<ProCard
title={
<Space>
<ThreadIcon style={imgStyle} />
Thread
</Space>
}
extra={extraDataBuilder(showLastData).threadCount}
bodyStyle={{ paddingBlock: 0, height: 200 }}
colSpan={'25%'}
>
<Thread data={jvmData} chartConfig={commonConfig} />
</ProCard>
<ProCard
title={
<Space>
<OutHeapIcon style={imgStyle} />
Out Heap
</Space>
}
extra={extraDataBuilder(showLastData).nonHeapLastValue}
bodyStyle={{ paddingBlock: 0, height: 200 }}
colSpan={'25%'}
>
<NonHeap data={jvmData} max={showLastData.nonHeapMax} chartConfig={commonConfig} />
</ProCard>
</ProCard>
</>
);
};
export default Server;
...@@ -65,11 +65,6 @@ export default () => { ...@@ -65,11 +65,6 @@ export default () => {
header={{ extra: [<MetricsFilter key={''} onTimeSelect={onTimeSelectChange} />] }} header={{ extra: [<MetricsFilter key={''} onTimeSelect={onTimeSelectChange} />] }}
content={ content={
<> <>
{showServer.data && (
<ProCard collapsible title={'Dinky Server'} ghost bordered hoverable>
<Server timeRange={timeRange} />
</ProCard>
)}
{/*<Job />*/} {/*<Job />*/}
<JobMetricsList timeRange={timeRange} /> <JobMetricsList timeRange={timeRange} />
</> </>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment