You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by go...@apache.org on 2022/02/20 01:55:01 UTC
[incubator-inlong] branch master updated: [INLONG-2603][TubeMQ] Remove obsolete metric codes (#2604)
This is an automated email from the ASF dual-hosted git repository.
gosonzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-inlong.git
The following commit(s) were added to refs/heads/master by this push:
new 15d4741 [INLONG-2603][TubeMQ] Remove obsolete metric codes (#2604)
15d4741 is described below
commit 15d474190e7ef60dd057892035d85e20de8e0c7d
Author: gosonzhang <46...@qq.com>
AuthorDate: Sun Feb 20 09:54:54 2022 +0800
[INLONG-2603][TubeMQ] Remove obsolete metric codes (#2604)
---
.../tubemq/corebase/metric/AbsMetricItem.java | 77 -----
.../tubemq/corebase/metric/CountMetricItem.java | 36 ---
.../tubemq/corebase/metric/GaugeMaxMetricItem.java | 39 ---
.../tubemq/corebase/metric/GaugeMinMetricItem.java | 39 ---
.../corebase/metric/GaugeNormMetricItem.java | 36 ---
.../inlong/tubemq/corebase/metric/MetricSet.java | 53 ----
.../inlong/tubemq/corebase/metric/MetricType.java | 49 ---
.../inlong/tubemq/corebase/metric/MetricValue.java | 42 ---
.../tubemq/corebase/metric/MetricValueType.java | 55 ----
.../tubemq/corebase/metric/MetricValues.java | 38 ---
.../tubemq/corebase/metric/TimeDltMetricItem.java | 348 ---------------------
.../tubemq/corebase/metric/ValueAdjustType.java | 49 ---
.../tubemq/corebase/metric/MetricItemTest.java | 140 ---------
13 files changed, 1001 deletions(-)
diff --git a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/AbsMetricItem.java b/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/AbsMetricItem.java
deleted file mode 100644
index 6b1bc45..0000000
--- a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/AbsMetricItem.java
+++ /dev/null
@@ -1,77 +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.
- */
-
-package org.apache.inlong.tubemq.corebase.metric;
-
-import java.util.concurrent.atomic.AtomicLong;
-import org.apache.inlong.tubemq.corebase.utils.Tuple2;
-
-public abstract class AbsMetricItem {
-
- protected final MetricType metricType;
- protected final MetricValueType valueType;
- protected final String name;
- protected final AtomicLong value = new AtomicLong(0);
-
- public AbsMetricItem(MetricType metricType, MetricValueType valueType,
- String name, long initialValue) {
- this.metricType = metricType;
- this.valueType = valueType;
- this.name = name;
- this.value.set(initialValue);
- }
-
- public String getName() {
- return name;
- }
-
- public boolean isCounterMetric() {
- return metricType == MetricType.COUNTER;
- }
-
- public MetricType getMetricType() {
- return metricType;
- }
-
- public MetricValueType getMetricValueType() {
- return valueType;
- }
-
- public Tuple2<String, Long> getNameValue() {
- return new Tuple2<>(name, value.get());
- }
-
- public long incrementAndGet() {
- return value.incrementAndGet();
- }
-
- public long addAndGet(long dltData) {
- return value.addAndGet(dltData);
- }
-
- public boolean compareAndSet(long expect, long update) {
- return value.compareAndSet(expect, update);
- }
-
- public long decrementAndGet() {
- return value.decrementAndGet();
- }
-
- public abstract long getValue(boolean resetValue);
-
- public abstract boolean update(long newValue);
-}
diff --git a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/CountMetricItem.java b/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/CountMetricItem.java
deleted file mode 100644
index ab59da6..0000000
--- a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/CountMetricItem.java
+++ /dev/null
@@ -1,36 +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.
- */
-
-package org.apache.inlong.tubemq.corebase.metric;
-
-public class CountMetricItem extends AbsMetricItem {
-
- public CountMetricItem(String name) {
- super(MetricType.COUNTER, MetricValueType.MAX, name, 0);
- }
-
- @Override
- public long getValue(boolean resetValue) {
- return resetValue ? value.getAndSet(0) : value.get();
- }
-
- @Override
- public boolean update(long newValue) {
- value.set(newValue);
- return true;
- }
-}
diff --git a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/GaugeMaxMetricItem.java b/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/GaugeMaxMetricItem.java
deleted file mode 100644
index 8cd68cb..0000000
--- a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/GaugeMaxMetricItem.java
+++ /dev/null
@@ -1,39 +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.
- */
-
-package org.apache.inlong.tubemq.corebase.metric;
-
-public class GaugeMaxMetricItem extends AbsMetricItem {
-
- public GaugeMaxMetricItem(String name) {
- super(MetricType.GAUGE, MetricValueType.MAX, name, 0);
- }
-
- @Override
- public long getValue(boolean resetValue) {
- return resetValue ? value.getAndSet(0) : value.get();
- }
-
- @Override
- public boolean update(long newValue) {
- long curValue = value.get();
- if (newValue > curValue) {
- return value.compareAndSet(curValue, newValue);
- }
- return false;
- }
-}
diff --git a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/GaugeMinMetricItem.java b/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/GaugeMinMetricItem.java
deleted file mode 100644
index c3b03e9..0000000
--- a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/GaugeMinMetricItem.java
+++ /dev/null
@@ -1,39 +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.
- */
-
-package org.apache.inlong.tubemq.corebase.metric;
-
-public class GaugeMinMetricItem extends AbsMetricItem {
-
- public GaugeMinMetricItem(String name) {
- super(MetricType.GAUGE, MetricValueType.MIN, name, Long.MAX_VALUE);
- }
-
- @Override
- public long getValue(boolean resetValue) {
- return resetValue ? value.getAndSet(Long.MAX_VALUE) : value.get();
- }
-
- @Override
- public boolean update(long newValue) {
- long curValue = value.get();
- if (newValue < curValue) {
- return value.compareAndSet(curValue, newValue);
- }
- return false;
- }
-}
diff --git a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/GaugeNormMetricItem.java b/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/GaugeNormMetricItem.java
deleted file mode 100644
index 8ac21fc..0000000
--- a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/GaugeNormMetricItem.java
+++ /dev/null
@@ -1,36 +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.
- */
-
-package org.apache.inlong.tubemq.corebase.metric;
-
-public class GaugeNormMetricItem extends AbsMetricItem {
-
- public GaugeNormMetricItem(String name) {
- super(MetricType.GAUGE, MetricValueType.NORMAL, name, 0);
- }
-
- @Override
- public long getValue(boolean resetValue) {
- return value.get();
- }
-
- @Override
- public boolean update(long newValue) {
- value.set(newValue);
- return true;
- }
-}
diff --git a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/MetricSet.java b/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/MetricSet.java
deleted file mode 100644
index 15e71c7..0000000
--- a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/MetricSet.java
+++ /dev/null
@@ -1,53 +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.
- */
-
-package org.apache.inlong.tubemq.corebase.metric;
-
-import java.util.Map;
-
-/**
- * An interface for metric item set.
- */
-public interface MetricSet {
- /**
- * Get the current recorded values.
- *
- * @param keyValMap the read result, the key is metric item's full name
- */
- void getValue(Map<String, Long> keyValMap);
-
- /**
- * Get the current recorded values.
- *
- * @param strBuff string buffer, json format
- */
- void getValue(StringBuilder strBuff);
-
- /**
- * Get the current recorded values and reset to zero.
- *
- * @param keyValMap the read result, the key is metric item's full name
- */
- void snapShort(Map<String, Long> keyValMap);
-
- /**
- * Get the current recorded values and reset to zero.
- *
- * @param strBuff string buffer, json format
- */
- void snapShort(StringBuilder strBuff);
-}
diff --git a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/MetricType.java b/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/MetricType.java
deleted file mode 100644
index e17cbfc..0000000
--- a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/MetricType.java
+++ /dev/null
@@ -1,49 +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.
- */
-
-package org.apache.inlong.tubemq.corebase.metric;
-
-public enum MetricType {
- UNKNOWN(0, "Unknown"),
- COUNTER(1, "Counter"),
- GAUGE(2, "Gauge");
-
- MetricType(int id, String name) {
- this.id = id;
- this.name = name;
- }
-
- public int getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public static MetricType valueOf(int value) {
- for (MetricType metricType : MetricType.values()) {
- if (metricType.getId() == value) {
- return metricType;
- }
- }
- return UNKNOWN;
- }
-
- private final int id;
- private final String name;
-}
diff --git a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/MetricValue.java b/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/MetricValue.java
deleted file mode 100644
index 18e0477..0000000
--- a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/MetricValue.java
+++ /dev/null
@@ -1,42 +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.
- */
-
-package org.apache.inlong.tubemq.corebase.metric;
-
-public class MetricValue {
- private final String type;
- private final String name;
- private final long value;
-
- public MetricValue(String type, String name, long value) {
- this.name = name;
- this.type = type;
- this.value = value;
- }
-
- public String getName() {
- return name;
- }
-
- public String getType() {
- return type;
- }
-
- public long getValue() {
- return value;
- }
-}
diff --git a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/MetricValueType.java b/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/MetricValueType.java
deleted file mode 100644
index ded31b7..0000000
--- a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/MetricValueType.java
+++ /dev/null
@@ -1,55 +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.
- */
-
-package org.apache.inlong.tubemq.corebase.metric;
-
-public enum MetricValueType {
- NORMAL(0, "Normal", "Current value"),
- MIN(1, "Min", "Historical minimum value"),
- MAX(2, "Max", "Historical maximum value");
-
- MetricValueType(int id, String name, String desc) {
- this.id = id;
- this.name = name;
- this.desc = desc;
- }
-
- public int getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public String getDesc() {
- return desc;
- }
-
- public static MetricValueType valueOf(int value) {
- for (MetricValueType valueType : MetricValueType.values()) {
- if (valueType.getId() == value) {
- return valueType;
- }
- }
- return NORMAL;
- }
-
- private final int id;
- private final String name;
- private final String desc;
-}
diff --git a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/MetricValues.java b/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/MetricValues.java
deleted file mode 100644
index 1ab380d..0000000
--- a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/MetricValues.java
+++ /dev/null
@@ -1,38 +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.
- */
-
-package org.apache.inlong.tubemq.corebase.metric;
-
-import java.util.Map;
-
-public class MetricValues {
- private final String lastResetTime;
- private final Map<String, Long> metricValues;
-
- public MetricValues(String lastResetTime, Map<String, Long> metricValues) {
- this.lastResetTime = lastResetTime;
- this.metricValues = metricValues;
- }
-
- public String getLastResetTime() {
- return lastResetTime;
- }
-
- public Map<String, Long> getMetricValues() {
- return metricValues;
- }
-}
diff --git a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/TimeDltMetricItem.java b/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/TimeDltMetricItem.java
deleted file mode 100644
index 18feee3..0000000
--- a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/TimeDltMetricItem.java
+++ /dev/null
@@ -1,348 +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.
- */
-
-package org.apache.inlong.tubemq.corebase.metric;
-
-import java.util.Map;
-
-/**
- *
- * Time consumption statistics category, currently includes the max, min, and
- * 17 histogram data statistical intervals(multiplied by the exponential of 2).
- * The time consumption can be increased or reduced according to the coefficient.
- * According to the metric data output by the Map, the key will be composed with Name
- * as the prefix for content association of output indicators under this category
- */
-public class TimeDltMetricItem {
- private final String name;
- private final String itemPrefix;
- private final boolean enableHistogram;
- private final ValueAdjustType adjustType;
- private final int multiple;
-
- // statistic count
- private final AbsMetricItem totalCount =
- new CountMetricItem("count");
- private final String totalCntJmxKey;
- // boundary values
- protected final AbsMetricItem procTimeDltLst =
- new GaugeNormMetricItem("dlt_ms_lst");
- private final String dltLastJmxKey;
- private final AbsMetricItem procTimeDltMin =
- new GaugeMinMetricItem("dlt_ms_min");
- private final String dltMinJmxKey;
- private final AbsMetricItem procTimeDltMax =
- new GaugeMaxMetricItem("dlt_ms_max");
- private final String dltMaxJmxKey;
- // time dlt from 000 ~ 1024
- private final AbsMetricItem procTimeDlt000000T000004 =
- new CountMetricItem("dlt_ms_000000t000004");
- private final AbsMetricItem procTimeDlt000004T000008 =
- new CountMetricItem("dlt_ms_000004t000008");
- private final AbsMetricItem procTimeDlt000008T000016 =
- new CountMetricItem("dlt_ms_000008t000016");
- private final AbsMetricItem procTimeDlt000016T000032 =
- new CountMetricItem("dlt_ms_000016t000032");
- private final AbsMetricItem procTimeDlt000032T000064 =
- new CountMetricItem("dlt_ms_000032t000064");
- private final AbsMetricItem procTimeDlt000064T000128 =
- new CountMetricItem("dlt_ms_000064t000128");
- private final AbsMetricItem procTimeDlt000128T000256 =
- new CountMetricItem("dlt_ms_000128t000256");
- private final AbsMetricItem procTimeDlt000256T000512 =
- new CountMetricItem("dlt_ms_000256t000512");
- private final AbsMetricItem procTimeDlt000512T001024 =
- new CountMetricItem("dlt_ms_000512t001024");
- // time dlt from 1024 ~ max
- private final AbsMetricItem procTimeDlt001024T002048 =
- new CountMetricItem("dlt_ms_001024t002048");
- private final AbsMetricItem procTimeDlt002048T004096 =
- new CountMetricItem("dlt_ms_002048t004096");
- private final AbsMetricItem procTimeDlt004096T008192 =
- new CountMetricItem("dlt_ms_004096t008192");
- private final AbsMetricItem procTimeDlt008192T016384 =
- new CountMetricItem("dlt_ms_008192t016384");
- private final AbsMetricItem procTimeDlt016384T032768 =
- new CountMetricItem("dlt_ms_016384t032768");
- private final AbsMetricItem procTimeDlt032768T065535 =
- new CountMetricItem("dlt_ms_032768t065535");
- private final AbsMetricItem procTimeDlt065535T131072 =
- new CountMetricItem("dlt_ms_065535t131072");
- private final AbsMetricItem procTimeDlt131072Tffffff =
- new CountMetricItem("dlt_ms_131072tffffff");
-
- public TimeDltMetricItem(String metricName) {
- this(metricName, false, ValueAdjustType.KEEPSAME, 1);
- }
-
- public TimeDltMetricItem(String metricName, boolean enableHistogram) {
- this(metricName, enableHistogram, ValueAdjustType.KEEPSAME, 1);
- }
-
- public TimeDltMetricItem(String metricName, boolean enableHistogram,
- ValueAdjustType adjustType, int multiple) {
- if (metricName.endsWith("_")) {
- this.name = metricName.substring(0, metricName.length() - 1);
- this.itemPrefix = metricName;
- } else {
- this.name = metricName;
- this.itemPrefix = metricName + "_";
- }
- this.enableHistogram = enableHistogram;
- this.adjustType = adjustType;
- if (adjustType != ValueAdjustType.KEEPSAME && multiple == 0) {
- this.multiple = 1;
- } else {
- this.multiple = multiple;
- }
- StringBuilder strBuff = new StringBuilder(512);
- this.totalCntJmxKey = strBuff.append(itemPrefix)
- .append(totalCount.getName()).toString();
- strBuff.delete(0, strBuff.length());
- this.dltLastJmxKey = strBuff.append(itemPrefix)
- .append(procTimeDltLst.getName()).toString();
- strBuff.delete(0, strBuff.length());
- this.dltMinJmxKey = strBuff.append(itemPrefix)
- .append(procTimeDltMin.getName()).toString();
- strBuff.delete(0, strBuff.length());
- this.dltMaxJmxKey = strBuff.append(itemPrefix)
- .append(procTimeDltMax.getName()).toString();
- strBuff.delete(0, strBuff.length());
- }
-
- public String getTotalCntKey() {
- return this.totalCntJmxKey;
- }
-
- public String getDltLastJmxKey() {
- return this.dltLastJmxKey;
- }
-
- public String getDltMinJmxKey() {
- return dltMinJmxKey;
- }
-
- public String getDltMaxJmxKey() {
- return dltMaxJmxKey;
- }
-
- public void getProcTimeDltDuration(Map<String, Long> metricValues,
- boolean resetValue) {
- // total measure count
- metricValues.put(totalCntJmxKey, totalCount.getValue(resetValue));
- // the latest value
- metricValues.put(dltLastJmxKey, procTimeDltLst.getValue(resetValue));
- // min and max value
- metricValues.put(dltMinJmxKey, procTimeDltMin.getValue(resetValue));
- metricValues.put(dltMaxJmxKey, procTimeDltMax.getValue(resetValue));
- }
-
- public void updProcTimeDlt(long dltTime) {
- // update boundary values
- totalCount.incrementAndGet();
- procTimeDltLst.update(dltTime);
- procTimeDltMin.update(dltTime);
- procTimeDltMax.update(dltTime);
- if (enableHistogram) {
- // adjust value size
- if (adjustType != ValueAdjustType.KEEPSAME) {
- if (adjustType == ValueAdjustType.ZOOMIN) {
- dltTime *= multiple;
- } else {
- dltTime /= multiple;
- }
- }
- // statistic histogram
- if (dltTime < 4) {
- procTimeDlt000000T000004.incrementAndGet();
- } else if (dltTime < 8) {
- procTimeDlt000004T000008.incrementAndGet();
- } else if (dltTime < 16) {
- procTimeDlt000008T000016.incrementAndGet();
- } else if (dltTime < 32) {
- procTimeDlt000016T000032.incrementAndGet();
- } else if (dltTime < 64) {
- procTimeDlt000032T000064.incrementAndGet();
- } else if (dltTime < 128) {
- procTimeDlt000064T000128.incrementAndGet();
- } else if (dltTime < 256) {
- procTimeDlt000128T000256.incrementAndGet();
- } else if (dltTime < 512) {
- procTimeDlt000256T000512.incrementAndGet();
- } else if (dltTime < 1024) {
- procTimeDlt000512T001024.incrementAndGet();
- } else if (dltTime < 2048) {
- procTimeDlt001024T002048.incrementAndGet();
- } else if (dltTime < 4096) {
- procTimeDlt002048T004096.incrementAndGet();
- } else if (dltTime < 8192) {
- procTimeDlt004096T008192.incrementAndGet();
- } else if (dltTime < 16384) {
- procTimeDlt008192T016384.incrementAndGet();
- } else if (dltTime < 32768) {
- procTimeDlt016384T032768.incrementAndGet();
- } else if (dltTime < 65535) {
- procTimeDlt032768T065535.incrementAndGet();
- } else if (dltTime < 131072) {
- procTimeDlt065535T131072.incrementAndGet();
- } else {
- procTimeDlt131072Tffffff.incrementAndGet();
- }
- }
- }
-
- public void getMapMetrics(Map<String, Long> metricValues, boolean resetValue) {
- // total measure count
- metricValues.put(totalCntJmxKey, totalCount.getValue(resetValue));
- // the latest value
- metricValues.put(dltLastJmxKey, procTimeDltLst.getValue(resetValue));
- // min and max value
- metricValues.put(dltMinJmxKey, procTimeDltMin.getValue(resetValue));
- metricValues.put(dltMaxJmxKey, procTimeDltMax.getValue(resetValue));
- if (!enableHistogram) {
- return;
- }
- StringBuilder strBuff = new StringBuilder(512);
- metricValues.put(strBuff.append(itemPrefix)
- .append(adjustType.getName()).toString(), (long) multiple);
- strBuff.delete(0, strBuff.length());
- // 00000 ~ 00128
- metricValues.put(strBuff.append(itemPrefix)
- .append(procTimeDlt000000T000004.getName()).toString(),
- procTimeDlt000000T000004.getValue(resetValue));
- strBuff.delete(0, strBuff.length());
- metricValues.put(strBuff.append(itemPrefix)
- .append(procTimeDlt000004T000008.getName()).toString(),
- procTimeDlt000004T000008.getValue(resetValue));
- strBuff.delete(0, strBuff.length());
- metricValues.put(strBuff.append(itemPrefix)
- .append(procTimeDlt000008T000016.getName()).toString(),
- procTimeDlt000008T000016.getValue(resetValue));
- strBuff.delete(0, strBuff.length());
- metricValues.put(strBuff.append(itemPrefix)
- .append(procTimeDlt000016T000032.getName()).toString(),
- procTimeDlt000016T000032.getValue(resetValue));
- strBuff.delete(0, strBuff.length());
- metricValues.put(strBuff.append(itemPrefix)
- .append(procTimeDlt000032T000064.getName()).toString(),
- procTimeDlt000032T000064.getValue(resetValue));
- strBuff.delete(0, strBuff.length());
- metricValues.put(strBuff.append(itemPrefix)
- .append(procTimeDlt000064T000128.getName()).toString(),
- procTimeDlt000064T000128.getValue(resetValue));
- strBuff.delete(0, strBuff.length());
- // 00128 ~ 04096
- metricValues.put(strBuff.append(itemPrefix)
- .append(procTimeDlt000128T000256.getName()).toString(),
- procTimeDlt000128T000256.getValue(resetValue));
- strBuff.delete(0, strBuff.length());
- metricValues.put(strBuff.append(itemPrefix)
- .append(procTimeDlt000256T000512.getName()).toString(),
- procTimeDlt000256T000512.getValue(resetValue));
- strBuff.delete(0, strBuff.length());
- metricValues.put(strBuff.append(itemPrefix)
- .append(procTimeDlt000512T001024.getName()).toString(),
- procTimeDlt000512T001024.getValue(resetValue));
- strBuff.delete(0, strBuff.length());
- metricValues.put(strBuff.append(itemPrefix)
- .append(procTimeDlt001024T002048.getName()).toString(),
- procTimeDlt001024T002048.getValue(resetValue));
- strBuff.delete(0, strBuff.length());
- metricValues.put(strBuff.append(itemPrefix)
- .append(procTimeDlt002048T004096.getName()).toString(),
- procTimeDlt002048T004096.getValue(resetValue));
- strBuff.delete(0, strBuff.length());
- // 04096 ~ max
- metricValues.put(strBuff.append(itemPrefix)
- .append(procTimeDlt004096T008192.getName()).toString(),
- procTimeDlt004096T008192.getValue(resetValue));
- strBuff.delete(0, strBuff.length());
- metricValues.put(strBuff.append(itemPrefix)
- .append(procTimeDlt008192T016384.getName()).toString(),
- procTimeDlt008192T016384.getValue(resetValue));
- strBuff.delete(0, strBuff.length());
- metricValues.put(strBuff.append(itemPrefix)
- .append(procTimeDlt016384T032768.getName()).toString(),
- procTimeDlt016384T032768.getValue(resetValue));
- strBuff.delete(0, strBuff.length());
- metricValues.put(strBuff.append(itemPrefix)
- .append(procTimeDlt032768T065535.getName()).toString(),
- procTimeDlt032768T065535.getValue(resetValue));
- strBuff.delete(0, strBuff.length());
- metricValues.put(strBuff.append(itemPrefix)
- .append(procTimeDlt065535T131072.getName()).toString(),
- procTimeDlt065535T131072.getValue(resetValue));
- strBuff.delete(0, strBuff.length());
- metricValues.put(strBuff.append(itemPrefix)
- .append(procTimeDlt131072Tffffff.getName()).toString(),
- procTimeDlt131072Tffffff.getValue(resetValue));
- strBuff.delete(0, strBuff.length());
- }
-
- public void getStrMetrics(StringBuilder strBuff, boolean resetValue) {
- strBuff.append("\"").append(name).append("\":{\"")
- .append(totalCount.getName()).append("\":")
- .append(totalCount.getValue(resetValue)).append(",\"")
- .append(procTimeDltLst.getName()).append("\":")
- .append(procTimeDltLst.getValue(resetValue)).append(",\"")
- .append(procTimeDltMin.getName()).append("\":")
- .append(procTimeDltMin.getValue(resetValue)).append(",\"")
- .append(procTimeDltMax.getName()).append("\":")
- .append(procTimeDltMax.getValue(resetValue));
- if (enableHistogram) {
- strBuff.append(",\"dlt_histogram\":{\"adjustType\":\"").append(adjustType.getName())
- .append("\",\"multiple\":").append(multiple).append(",\"")
- .append(procTimeDlt000000T000004.getName()).append("\":")
- .append(procTimeDlt000000T000004.getValue(resetValue))
- .append(",\"").append(procTimeDlt000004T000008.getName()).append("\":")
- .append(procTimeDlt000004T000008.getValue(resetValue))
- .append(",\"").append(procTimeDlt000008T000016.getName()).append("\":")
- .append(procTimeDlt000008T000016.getValue(resetValue))
- .append(",\"").append(procTimeDlt000016T000032.getName()).append("\":")
- .append(procTimeDlt000016T000032.getValue(resetValue))
- .append(",\"").append(procTimeDlt000032T000064.getName()).append("\":")
- .append(procTimeDlt000032T000064.getValue(resetValue))
- .append(",\"").append(procTimeDlt000064T000128.getName()).append("\":")
- .append(procTimeDlt000064T000128.getValue(resetValue))
- .append(",\"").append(procTimeDlt000128T000256.getName()).append("\":")
- .append(procTimeDlt000128T000256.getValue(resetValue))
- .append(",\"").append(procTimeDlt000256T000512.getName()).append("\":")
- .append(procTimeDlt000256T000512.getValue(resetValue))
- .append(",\"").append(procTimeDlt000512T001024.getName()).append("\":")
- .append(procTimeDlt000512T001024.getValue(resetValue))
- .append(",\"").append(procTimeDlt001024T002048.getName()).append("\":")
- .append(procTimeDlt001024T002048.getValue(resetValue))
- .append(",\"").append(procTimeDlt002048T004096.getName()).append("\":")
- .append(procTimeDlt002048T004096.getValue(resetValue))
- .append(",\"").append(procTimeDlt004096T008192.getName()).append("\":")
- .append(procTimeDlt004096T008192.getValue(resetValue))
- .append(",\"").append(procTimeDlt008192T016384.getName()).append("\":")
- .append(procTimeDlt008192T016384.getValue(resetValue))
- .append(",\"").append(procTimeDlt016384T032768.getName()).append("\":")
- .append(procTimeDlt016384T032768.getValue(resetValue))
- .append(",\"").append(procTimeDlt032768T065535.getName()).append("\":")
- .append(procTimeDlt032768T065535.getValue(resetValue))
- .append(",\"").append(procTimeDlt065535T131072.getName()).append("\":")
- .append(procTimeDlt065535T131072.getValue(resetValue))
- .append(",\"").append(procTimeDlt131072Tffffff.getName()).append("\":")
- .append(procTimeDlt131072Tffffff.getValue(resetValue))
- .append("}}");
- } else {
- strBuff.append("}");
- }
- }
-}
diff --git a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/ValueAdjustType.java b/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/ValueAdjustType.java
deleted file mode 100644
index 89e6b0a..0000000
--- a/inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corebase/metric/ValueAdjustType.java
+++ /dev/null
@@ -1,49 +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.
- */
-
-package org.apache.inlong.tubemq.corebase.metric;
-
-public enum ValueAdjustType {
- ZOOMOUT(-1, "Zoom-out"),
- KEEPSAME(0, "Keep-same"),
- ZOOMIN(1, "Zoom-in");
-
- ValueAdjustType(int id, String name) {
- this.id = id;
- this.name = name;
- }
-
- public int getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public static ValueAdjustType valueOf(int value) {
- for (ValueAdjustType adjustType : ValueAdjustType.values()) {
- if (adjustType.getId() == value) {
- return adjustType;
- }
- }
- return KEEPSAME;
- }
-
- private final int id;
- private final String name;
-}
diff --git a/inlong-tubemq/tubemq-core/src/test/java/org/apache/inlong/tubemq/corebase/metric/MetricItemTest.java b/inlong-tubemq/tubemq-core/src/test/java/org/apache/inlong/tubemq/corebase/metric/MetricItemTest.java
deleted file mode 100644
index 86c074d..0000000
--- a/inlong-tubemq/tubemq-core/src/test/java/org/apache/inlong/tubemq/corebase/metric/MetricItemTest.java
+++ /dev/null
@@ -1,140 +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.
- */
-
-package org.apache.inlong.tubemq.corebase.metric;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-public class MetricItemTest {
- private static final Logger logger =
- LoggerFactory.getLogger(MetricItemTest.class);
-
- @Test
- public void testMetricItem() {
- try {
- final CountMetricItem countMetricItem =
- new CountMetricItem("CountMetricItem");
- final GaugeNormMetricItem gaugeNormMetricItem =
- new GaugeNormMetricItem("GaugeNormMetricItem");
- final GaugeMaxMetricItem gaugeMaxMetricItem =
- new GaugeMaxMetricItem("GaugeMaxMetricItem");
- final GaugeMinMetricItem gaugeMinMetricItem =
- new GaugeMinMetricItem("GaugeMinMetricItem");
-
- countMetricItem.incrementAndGet();
- countMetricItem.incrementAndGet();
- countMetricItem.incrementAndGet();
- countMetricItem.decrementAndGet();
-
- gaugeNormMetricItem.update(1000);
- gaugeNormMetricItem.update(2000);
- gaugeNormMetricItem.update(500);
-
- gaugeMaxMetricItem.update(1000);
- gaugeMaxMetricItem.update(5000);
- gaugeMaxMetricItem.update(3000);
-
- gaugeMinMetricItem.update(1000);
- gaugeMinMetricItem.update(1);
- gaugeMinMetricItem.update(10000);
-
- Assert.assertEquals(2, countMetricItem.getValue(false));
- Assert.assertEquals(500, gaugeNormMetricItem.getValue(false));
- Assert.assertEquals(5000, gaugeMaxMetricItem.getValue(false));
- Assert.assertEquals(1, gaugeMinMetricItem.getValue(false));
-
- countMetricItem.getValue(true);
- gaugeNormMetricItem.getValue(true);
- gaugeMaxMetricItem.getValue(true);
- gaugeMinMetricItem.getValue(true);
-
- Assert.assertEquals(0, countMetricItem.getValue(false));
- Assert.assertEquals(500, gaugeNormMetricItem.getValue(false));
- Assert.assertEquals(0, gaugeMaxMetricItem.getValue(false));
- Assert.assertEquals(Long.MAX_VALUE, gaugeMinMetricItem.getValue(false));
-
- Assert.assertEquals(MetricType.COUNTER.getId(),
- countMetricItem.getMetricType().getId());
- Assert.assertEquals(MetricValueType.MAX.getId(),
- countMetricItem.getMetricValueType().getId());
- Assert.assertEquals(MetricType.GAUGE.getId(),
- gaugeNormMetricItem.getMetricType().getId());
- Assert.assertEquals(MetricValueType.NORMAL.getId(),
- gaugeNormMetricItem.getMetricValueType().getId());
- Assert.assertEquals(MetricType.GAUGE.getId(),
- gaugeMaxMetricItem.getMetricType().getId());
- Assert.assertEquals(MetricValueType.MAX.getId(),
- gaugeMaxMetricItem.getMetricValueType().getId());
- Assert.assertEquals(MetricType.GAUGE.getId(),
- gaugeMinMetricItem.getMetricType().getId());
- Assert.assertEquals(MetricValueType.MIN.getId(),
- gaugeMinMetricItem.getMetricValueType().getId());
- } catch (Exception ex) {
- logger.error("error happens" + ex);
- }
- }
-
- @Test
- public void testProcTimeDltMetricItem() {
- try {
- final TimeDltMetricItem procDltMetricItem =
- new TimeDltMetricItem("test");
-
- procDltMetricItem.updProcTimeDlt(2);
- procDltMetricItem.updProcTimeDlt(6);
- procDltMetricItem.updProcTimeDlt(15);
- procDltMetricItem.updProcTimeDlt(30);
- procDltMetricItem.updProcTimeDlt(60);
- procDltMetricItem.updProcTimeDlt(120);
- procDltMetricItem.updProcTimeDlt(240);
- procDltMetricItem.updProcTimeDlt(270);
- procDltMetricItem.updProcTimeDlt(520);
- procDltMetricItem.updProcTimeDlt(1030);
- procDltMetricItem.updProcTimeDlt(2060);
- procDltMetricItem.updProcTimeDlt(3060);
- procDltMetricItem.updProcTimeDlt(8060);
- procDltMetricItem.updProcTimeDlt(16370);
- procDltMetricItem.updProcTimeDlt(20000);
- procDltMetricItem.updProcTimeDlt(33000);
- procDltMetricItem.updProcTimeDlt(55000);
-
- Map<String, Long> metricValues = new LinkedHashMap<>();
- procDltMetricItem.getMapMetrics(metricValues, false);
-
- StringBuilder strBuff = new StringBuilder(512);
- procDltMetricItem.getStrMetrics(strBuff, false);
- String result = strBuff.toString();
- strBuff.delete(0, strBuff.length());
-
- procDltMetricItem.getStrMetrics(strBuff, true);
- result = strBuff.toString();
- strBuff.delete(0, strBuff.length());
-
- procDltMetricItem.getStrMetrics(strBuff, false);
- result = strBuff.toString();
- strBuff.delete(0, strBuff.length());
- } catch (Exception ex) {
- logger.error("error happens" + ex);
- }
- }
-}