com.clickzetta.platform.metrics.MetricsSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clickzetta-java Show documentation
Show all versions of clickzetta-java Show documentation
The java SDK for clickzetta's Lakehouse
package com.clickzetta.platform.metrics;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.concurrent.TimeUnit;
public class MetricsSerializer {
public static final MetricsSerializer INSTANCE = new MetricsSerializer();
public String serialize(MetricBase metricBase) throws IOException {
MetricsInfo metricsInfo = new MetricsInfo(metricBase);
return MetricsInfo.toJsonString(metricsInfo);
}
public T deserialize(String jsonString) throws IOException {
MetricsInfo metricsInfo = MetricsInfo.fromJsonString(jsonString);
return metricsInfo.toMetricBase();
}
public static void main(String[] args) throws IOException {
SessionMetrics metrics = new SessionMetrics(new LinkedHashMap() {{
put("namespace", "test"); put("server", "test"); }});
metrics.getPushDataQPS().mark(1);
metrics.getPushDataFailedQPS().mark(2);
metrics.getPushDataRecordCount().mark(3);
metrics.getPushDataE2ELatency().update(4, TimeUnit.MILLISECONDS);
metrics.getPushDataThroughput().mark(5);
// ser & des
String string = INSTANCE.serialize(metrics);
SessionMetrics sm = INSTANCE.deserialize(string);
System.out.println(sm.getPushDataQPS().getCount());
System.out.println(sm.getPushDataFailedQPS().getCount());
System.out.println(sm.getPushDataRecordCount().getCount());
System.out.println(sm.getPushDataE2ELatency().getCount());
System.out.println(sm.getPushDataThroughput().getCount());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy